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 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     {
6067       if (CPC_INNER_P ())
6068         uaaf = INTERFACE_INNER_MODIFIERS;
6069       else
6070         uaaf = INTERFACE_MODIFIERS;
6071       
6072       check_modifiers ("Illegal modifier `%s' for interface declaration", 
6073                        flags, uaaf);
6074     }
6075   else
6076     check_modifiers ((current_function_decl ?
6077                       "Illegal modifier `%s' for local class declaration" :
6078                       "Illegal modifier `%s' for class declaration"),
6079                      flags, uaaf|sca|icaf);
6080   return 0;
6081 }
6082
6083 static void
6084 make_nested_class_name (cpc_list)
6085      tree cpc_list;
6086 {
6087   tree name;
6088
6089   if (!cpc_list)
6090     return;
6091   else
6092     make_nested_class_name (TREE_CHAIN (cpc_list));
6093
6094   /* Pick the qualified name when dealing with the first upmost
6095      enclosing class */
6096   name = (TREE_CHAIN (cpc_list) ? 
6097           TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
6098   obstack_grow (&temporary_obstack,
6099                 IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
6100   /* Why is NO_DOLLAR_IN_LABEL defined? */
6101 #if 0
6102 #ifdef NO_DOLLAR_IN_LABEL
6103   fatal ("make_nested_class_name: Can't use '$' as a separator "
6104          "for inner classes");
6105 #endif
6106 #endif
6107   obstack_1grow (&temporary_obstack, '$');
6108 }
6109
6110 /* Can't redefine a class already defined in an earlier scope. */
6111
6112 static int
6113 check_inner_class_redefinition (raw_name, cl)
6114      tree raw_name, cl;
6115 {
6116   tree scope_list;
6117
6118   for (scope_list = GET_CPC_LIST (); scope_list; 
6119        scope_list = GET_NEXT_ENCLOSING_CPC (scope_list))
6120     if (raw_name == GET_CPC_UN_NODE (scope_list))
6121       {
6122         parse_error_context 
6123           (cl, "The class name `%s' is already defined in this scope. An inner class may not have the same simple name as any of its enclosing classes",
6124            IDENTIFIER_POINTER (raw_name));
6125         return 1;
6126       }
6127   return 0;
6128 }
6129
6130 static tree
6131 find_as_inner_class (enclosing, name, cl)
6132      tree enclosing, name, cl;
6133 {
6134   tree qual, to_return;
6135   if (!enclosing)
6136     return NULL_TREE;
6137
6138   name = TYPE_NAME (name);
6139
6140   /* First search: within the scope of `enclosing', search for name */
6141   if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6142     qual = EXPR_WFL_QUALIFICATION (cl);
6143   else if (cl)
6144     qual = build_tree_list (cl, NULL_TREE);
6145   else
6146     qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6147   
6148   if ((to_return = find_as_inner_class_do (qual, enclosing)))
6149     return to_return;
6150
6151   /* We're dealing with a qualified name. Try to resolve thing until
6152      we get something that is an enclosing class. */
6153   if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6154     {
6155       tree acc = NULL_TREE, decl = NULL_TREE, ptr;
6156
6157       for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl; 
6158           qual = TREE_CHAIN (qual))
6159         {
6160           acc = merge_qualified_name (acc, 
6161                                       EXPR_WFL_NODE (TREE_PURPOSE (qual)));
6162           BUILD_PTR_FROM_NAME (ptr, acc);
6163           decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
6164         }
6165
6166       /* A NULL qual and a decl means that the search ended
6167          successfully?!? We have to do something then. FIXME */
6168       
6169       if (decl)
6170         enclosing = decl;
6171       else
6172         qual = EXPR_WFL_QUALIFICATION (cl);
6173     }
6174   /* Otherwise, create a qual for the other part of the resolution. */
6175   else
6176     qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6177
6178   return find_as_inner_class_do (qual, enclosing);
6179 }
6180
6181 /* We go inside the list of sub classes and try to find a way
6182    through. */
6183
6184 static tree
6185 find_as_inner_class_do (qual, enclosing)
6186      tree qual, enclosing;
6187 {
6188   if (!qual)
6189     return NULL_TREE;
6190
6191   for (; qual && enclosing; qual = TREE_CHAIN (qual))
6192     {
6193       tree name_to_match = EXPR_WFL_NODE (TREE_PURPOSE (qual));
6194       tree next_enclosing = NULL_TREE;
6195       tree inner_list;
6196
6197       for (inner_list = DECL_INNER_CLASS_LIST (enclosing);
6198            inner_list; inner_list = TREE_CHAIN (inner_list))
6199         {
6200           if (TREE_VALUE (inner_list) == name_to_match)
6201             {
6202               next_enclosing = TREE_PURPOSE (inner_list);
6203               break;
6204             }
6205         }
6206       enclosing = next_enclosing;
6207     }
6208
6209   return (!qual && enclosing ? enclosing : NULL_TREE);
6210 }
6211
6212 /* Reach all inner classes and tie their unqualified name to a
6213    DECL. */
6214
6215 static void
6216 set_nested_class_simple_name_value (outer, set)
6217      tree outer;
6218      int set;
6219 {
6220   tree l;
6221
6222   for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
6223     IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ? 
6224                                                 TREE_PURPOSE (l) : NULL_TREE);
6225 }
6226
6227 static void
6228 link_nested_class_to_enclosing ()
6229 {
6230   if (GET_ENCLOSING_CPC ())
6231     {
6232       tree enclosing = GET_ENCLOSING_CPC_CONTEXT ();
6233       DECL_INNER_CLASS_LIST (enclosing) = 
6234         tree_cons (GET_CPC (), GET_CPC_UN (),
6235                    DECL_INNER_CLASS_LIST (enclosing));
6236       enclosing = enclosing;
6237     }
6238 }
6239
6240 static tree
6241 maybe_make_nested_class_name (name)
6242      tree name;
6243 {
6244   tree id = NULL_TREE;
6245
6246   if (CPC_INNER_P ())
6247     {
6248       make_nested_class_name (GET_CPC_LIST ());
6249       obstack_grow0 (&temporary_obstack,
6250                      IDENTIFIER_POINTER (name), 
6251                      IDENTIFIER_LENGTH (name));
6252       id = get_identifier (obstack_finish (&temporary_obstack));
6253       if (ctxp->package)
6254         QUALIFIED_P (id) = 1;
6255     }
6256   return id;
6257 }
6258
6259 /* If DECL is NULL, create and push a new DECL, record the current
6260    line CL and do other maintenance things.  */
6261
6262 static tree
6263 maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
6264      tree decl, raw_name, qualified_name, cl;
6265 {
6266   if (!decl)
6267     decl = push_class (make_class (), qualified_name);
6268
6269   /* Take care of the file and line business */
6270   DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
6271   /* If we're emiting xrefs, store the line/col number information */
6272   if (flag_emit_xref)
6273     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
6274   else
6275     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
6276   CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
6277   CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
6278     IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
6279
6280   PUSH_CPC (decl, raw_name);
6281   DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
6282
6283   /* Link the declaration to the already seen ones */
6284   TREE_CHAIN (decl) = ctxp->class_list;
6285   ctxp->class_list = decl;
6286
6287   /* Create a new nodes in the global lists */
6288   ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
6289   all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
6290
6291   /* Install a new dependency list element */
6292   create_jdep_list (ctxp);
6293
6294   SOURCE_FRONTEND_DEBUG (("Defining class/interface %s", 
6295                           IDENTIFIER_POINTER (qualified_name)));
6296   return decl;
6297 }
6298
6299 static void
6300 add_superinterfaces (decl, interface_list)
6301      tree decl, interface_list;
6302 {
6303   tree node;
6304   /* Superinterface(s): if present and defined, parser_check_super_interface ()
6305      takes care of ensuring that:
6306        - This is an accessible interface type,
6307        - Circularity detection.
6308    parser_add_interface is then called. If present but not defined,
6309    the check operation is delayed until the super interface gets
6310    defined.  */
6311   for (node = interface_list; node; node = TREE_CHAIN (node))
6312     {
6313       tree current = TREE_PURPOSE (node);
6314       tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
6315       if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
6316         {
6317           if (!parser_check_super_interface (idecl, decl, current))
6318             parser_add_interface (decl, idecl, current);
6319         }
6320       else
6321         register_incomplete_type (JDEP_INTERFACE,
6322                                   current, decl, NULL_TREE);
6323     }
6324 }
6325
6326 /* Create an interface in pass1 and return its decl. Return the
6327    interface's decl in pass 2.  */
6328
6329 static tree
6330 create_interface (flags, id, super)
6331      int flags;
6332      tree id, super;
6333 {
6334   tree raw_name = EXPR_WFL_NODE (id);
6335   tree q_name = parser_qualified_classname (flags & ACC_STATIC, raw_name);
6336   tree decl = IDENTIFIER_CLASS_VALUE (q_name);
6337
6338   EXPR_WFL_NODE (id) = q_name;  /* Keep source location, even if refined. */
6339
6340   /* Basic checks: scope, redefinition, modifiers */ 
6341   if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
6342     {
6343       PUSH_ERROR ();
6344       return NULL_TREE;
6345     }
6346
6347   /* Suspend the current parsing context if we're parsing an inner
6348      interface */
6349   if (CPC_INNER_P ())
6350     java_parser_context_suspend ();
6351
6352   /* Push a new context for (static) initialized upon declaration fields */
6353   java_parser_context_push_initialized_field ();
6354
6355   /* Interface modifiers check
6356        - public/abstract allowed (already done at that point)
6357        - abstract is obsolete (comes first, it's a warning, or should be)
6358        - Can't use twice the same (checked in the modifier rule) */
6359   if ((flags & ACC_ABSTRACT) && flag_redundant)
6360     parse_warning_context 
6361       (MODIFIER_WFL (ABSTRACT_TK),
6362        "Redundant use of `abstract' modifier. Interface `%s' is implicitely abstract", IDENTIFIER_POINTER (raw_name));
6363
6364   /* Create a new decl if DECL is NULL, otherwise fix it */
6365   decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
6366
6367   /* Set super info and mark the class a complete */
6368   set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl), 
6369                   object_type_node, ctxp->interface_number);
6370   ctxp->interface_number = 0;
6371   CLASS_COMPLETE_P (decl) = 1;
6372   add_superinterfaces (decl, super);
6373
6374   return decl;
6375 }
6376
6377 /* Anonymous class counter. Will be reset to 1 every time a non
6378    anonymous class gets created. */
6379 static int anonymous_class_counter = 1;
6380
6381 /* Patch anonymous class CLASS, by either extending or implementing
6382    DEP.  */
6383
6384 static void
6385 patch_anonymous_class (type_decl, class_decl, wfl)
6386     tree type_decl, class_decl, wfl;
6387 {
6388   tree class = TREE_TYPE (class_decl);
6389   tree type =  TREE_TYPE (type_decl);
6390   tree binfo = TYPE_BINFO (class);
6391
6392   /* If it's an interface, implement it */
6393   if (CLASS_INTERFACE (type_decl))
6394     {
6395       tree s_binfo;
6396       int length;
6397
6398       if (parser_check_super_interface (type_decl, class_decl, wfl))
6399         return;
6400
6401       s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
6402       length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
6403       TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
6404       TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
6405       /* And add the interface */
6406       parser_add_interface (class_decl, type_decl, wfl);
6407     }
6408   /* Otherwise, it's a type we want to extend */
6409   else
6410     {
6411       if (parser_check_super (type_decl, class_decl, wfl))
6412         return;
6413       BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
6414     }
6415 }
6416
6417 static tree
6418 create_anonymous_class (location, type_name)
6419     int location;
6420     tree type_name;
6421 {
6422   char buffer [80];
6423   tree super = NULL_TREE, itf = NULL_TREE;
6424   tree id, type_decl, class;
6425
6426   /* The unqualified name of the anonymous class. It's just a number. */
6427   sprintf (buffer, "%d", anonymous_class_counter++);
6428   id = build_wfl_node (get_identifier (buffer));
6429   EXPR_WFL_LINECOL (id) = location;
6430
6431   /* We know about the type to extend/implement. We go ahead */
6432   if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
6433     {
6434       /* Create a class which either implements on extends the designated
6435          class. The class bears an innacessible name. */
6436       if (CLASS_INTERFACE (type_decl))
6437         {
6438           /* It's OK to modify it here. It's been already used and
6439              shouldn't be reused */
6440           ctxp->interface_number = 1;
6441           /* Interfaces should presented as a list of WFLs */
6442           itf = build_tree_list (type_name, NULL_TREE);
6443         }
6444       else
6445         super = type_name;
6446     }
6447
6448   class = create_class (ACC_FINAL, id, super, itf);
6449
6450   /* We didn't know anything about the stuff. We register a dependence. */
6451   if (!type_decl)
6452     register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);
6453
6454   ANONYMOUS_CLASS_P (TREE_TYPE (class)) = 1;
6455   return class;
6456 }
6457
6458 /* Create a class in pass1 and return its decl. Return class
6459    interface's decl in pass 2.  */
6460
6461 static tree
6462 create_class (flags, id, super, interfaces)
6463      int flags;
6464      tree id, super, interfaces;
6465 {
6466   tree raw_name = EXPR_WFL_NODE (id);
6467   tree class_id, decl;
6468   tree super_decl_type;
6469
6470   class_id = parser_qualified_classname (0, raw_name);
6471   decl = IDENTIFIER_CLASS_VALUE (class_id);
6472   EXPR_WFL_NODE (id) = class_id;
6473
6474   /* Basic check: scope, redefinition, modifiers */
6475   if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
6476     {
6477       PUSH_ERROR ();
6478       return NULL_TREE;
6479     }
6480   
6481   /* Suspend the current parsing context if we're parsing an inner
6482      class or an anonymous class. */
6483   if (CPC_INNER_P ())
6484     java_parser_context_suspend ();
6485   /* Push a new context for (static) initialized upon declaration fields */
6486   java_parser_context_push_initialized_field ();
6487
6488   /* Class modifier check: 
6489        - Allowed modifier (already done at that point)
6490        - abstract AND final forbidden 
6491        - Public classes defined in the correct file */
6492   if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
6493     parse_error_context
6494       (id, "Class `%s' can't be declared both abstract and final",
6495        IDENTIFIER_POINTER (raw_name));
6496
6497   /* Create a new decl if DECL is NULL, otherwise fix it */
6498   decl = maybe_create_class_interface_decl (decl, raw_name, class_id, id);
6499
6500   /* If SUPER exists, use it, otherwise use Object */
6501   if (super)
6502     {
6503       /* Can't extend java.lang.Object */
6504       if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
6505         {
6506           parse_error_context (id, "Can't extend `java.lang.Object'");
6507           return NULL_TREE;
6508         }
6509
6510       super_decl_type = 
6511         register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
6512     }
6513   else if (TREE_TYPE (decl) != object_type_node)
6514     super_decl_type = object_type_node;
6515   /* We're defining java.lang.Object */
6516   else
6517     super_decl_type = NULL_TREE;
6518
6519   /* Set super info and mark the class a complete */
6520   set_super_info (flags, TREE_TYPE (decl), super_decl_type, 
6521                   ctxp->interface_number);
6522   ctxp->interface_number = 0;
6523   CLASS_COMPLETE_P (decl) = 1;
6524   add_superinterfaces (decl, interfaces);
6525
6526   /* If the class is a top level inner class, install an alias. */
6527   if (INNER_CLASS_DECL_P (decl) && CLASS_STATIC (decl))
6528     {
6529       tree alias = parser_qualified_classname (1, raw_name);
6530       IDENTIFIER_GLOBAL_VALUE (alias) = decl;
6531     }
6532
6533   /* Add the private this$<n> field, Replicate final locals still in
6534      scope as private final fields mangled like val$<local_name>.
6535      This doesn't not occur for top level (static) inner classes. */
6536   if (PURE_INNER_CLASS_DECL_P (decl))
6537     add_inner_class_fields (decl, current_function_decl);
6538
6539   /* If doing xref, store the location at which the inherited class
6540      (if any) was seen. */
6541   if (flag_emit_xref && super)
6542     DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
6543
6544   /* Eventually sets the @deprecated tag flag */
6545   CHECK_DEPRECATED (decl);
6546
6547   /* Reset the anonymous class counter when declaring non inner classes */
6548   if (!INNER_CLASS_DECL_P (decl))
6549     anonymous_class_counter = 1;
6550
6551   return decl;
6552 }
6553
6554 /* End a class declaration: register the statements used to create
6555    $finit$ and <clinit>, pop the current class and resume the prior
6556    parser context if necessary.  */
6557
6558 static void
6559 end_class_declaration (resume)
6560      int resume;
6561 {
6562   /* If an error occured, context weren't pushed and won't need to be
6563      popped by a resume. */
6564   int no_error_occured = ctxp->next && GET_CPC () != error_mark_node;
6565
6566   java_parser_context_pop_initialized_field ();
6567   POP_CPC ();
6568   if (resume && no_error_occured)
6569     java_parser_context_resume ();
6570 }
6571
6572 static void
6573 add_inner_class_fields (class_decl, fct_decl)
6574      tree class_decl;
6575      tree fct_decl;
6576 {
6577   tree block, marker, f;
6578
6579   f = add_field (TREE_TYPE (class_decl),
6580                  build_current_thisn (TREE_TYPE (class_decl)),
6581                  build_pointer_type (TREE_TYPE (DECL_CONTEXT (class_decl))), 
6582                  ACC_PRIVATE);
6583   FIELD_THISN (f) = 1;
6584
6585   if (!fct_decl)
6586     return;
6587     
6588   for (block = GET_CURRENT_BLOCK (fct_decl); 
6589        block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block))
6590     {
6591       tree decl;
6592       for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl))
6593         {
6594           char *name, *pname;
6595           tree wfl, init, list;
6596           
6597           /* Avoid non final arguments. */
6598           if (!LOCAL_FINAL (decl))
6599             continue;
6600           
6601           MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl));
6602           MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl));
6603           wfl = build_wfl_node (get_identifier (name));
6604           init = build_wfl_node (get_identifier (pname));
6605           /* Build an initialization for the field: it will be
6606              initialized by a parameter added to $finit$, bearing a
6607              mangled name of the field itself (param$<n>.) The
6608              parameter is provided to $finit$ by the constructor
6609              invoking it (hence the constructor will also feature a
6610              hidden parameter, set to the value of the outer context
6611              local at the time the inner class is created.)
6612              
6613              Note: we take into account all possible locals that can
6614              be accessed by the inner class. It's actually not trivial
6615              to minimize these aliases down to the ones really
6616              used. One way to do that would be to expand all regular
6617              methods first, then $finit$ to get a picture of what's
6618              used.  It works with the exception that we would have to
6619              go back on all constructor invoked in regular methods to
6620              have their invokation reworked (to include the right amount
6621              of alias initializer parameters.)
6622
6623              The only real way around, I think, is a first pass to
6624              identify locals really used in the inner class. We leave
6625              the flag FIELD_LOCAL_ALIAS_USED around for that future
6626              use.
6627              
6628              On the other hand, it only affect local inner classes,
6629              whose constructors (and $finit$ call) will be featuring
6630              unecessary arguments. It's easy for a developper to keep
6631              this number of parameter down by using the `final'
6632              keyword only when necessary. For the time being, we can
6633              issue a warning on unecessary finals. FIXME */
6634           init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl), 
6635                                    wfl, init);
6636
6637           /* Register the field. The TREE_LIST holding the part
6638              initialized/initializer will be marked ARG_FINAL_P so
6639              that the created field can be marked
6640              FIELD_LOCAL_ALIAS. */
6641           list = build_tree_list (wfl, init);
6642           ARG_FINAL_P (list) = 1;
6643           register_fields (ACC_PRIVATE | ACC_FINAL, TREE_TYPE (decl), list);
6644         }
6645     }
6646
6647   if (!CPC_INITIALIZER_STMT (ctxp))
6648     return;
6649
6650   /* If we ever registered an alias field, insert and marker to
6651      remeber where the list ends. The second part of the list (the one
6652      featuring initialized fields) so it can be later reversed to
6653      enforce 8.5. The marker will be removed during that operation. */
6654   marker = build_tree_list (NULL_TREE, NULL_TREE);
6655   TREE_CHAIN (marker) = CPC_INITIALIZER_STMT (ctxp);
6656   SET_CPC_INITIALIZER_STMT (ctxp, marker);
6657 }
6658
6659 /* Can't use lookup_field () since we don't want to load the class and
6660    can't set the CLASS_LOADED_P flag */
6661
6662 static tree
6663 find_field (class, name)
6664      tree class;
6665      tree name;
6666 {
6667   tree decl;
6668   for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
6669     {
6670       if (DECL_NAME (decl) == name)
6671         return decl;
6672     }
6673   return NULL_TREE;
6674 }
6675
6676 /* Wrap around lookup_field that doesn't potentially upset the value
6677    of CLASS */
6678
6679 static tree
6680 lookup_field_wrapper (class, name)
6681      tree class, name;
6682 {
6683   tree type = class;
6684   tree decl;
6685   java_parser_context_save_global ();
6686   decl = lookup_field (&type, name);
6687
6688   /* Last chance: if we're within the context of an inner class, we
6689      might be trying to access a local variable defined in an outer
6690      context. We try to look for it now. */
6691   if (INNER_CLASS_TYPE_P (class) && (!decl || decl == error_mark_node))
6692     {
6693       char *alias_buffer;
6694       MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
6695       name = get_identifier (alias_buffer);
6696       type = class;
6697       decl = lookup_field (&type, name);
6698       if (decl && decl != error_mark_node)
6699         FIELD_LOCAL_ALIAS_USED (decl) = 1;
6700     }
6701
6702   java_parser_context_restore_global ();
6703   return decl == error_mark_node ? NULL : decl;
6704 }
6705
6706 /* Find duplicate field within the same class declarations and report
6707    the error. Returns 1 if a duplicated field was found, 0
6708    otherwise.  */
6709
6710 static int
6711 duplicate_declaration_error_p (new_field_name, new_type, cl)
6712      tree new_field_name, new_type, cl;
6713 {
6714   /* This might be modified to work with method decl as well */
6715   tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
6716   if (decl)
6717     {
6718       char *t1 = xstrdup (purify_type_name
6719                          ((TREE_CODE (new_type) == POINTER_TYPE 
6720                            && TREE_TYPE (new_type) == NULL_TREE) ?
6721                           IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
6722                           lang_printable_name (new_type, 1)));
6723       /* The type may not have been completed by the time we report
6724          the error */
6725       char *t2 = xstrdup (purify_type_name
6726                          ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE 
6727                            && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
6728                           IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
6729                           lang_printable_name (TREE_TYPE (decl), 1)));
6730       parse_error_context 
6731         (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)", 
6732          t1, IDENTIFIER_POINTER (new_field_name),
6733          t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
6734          DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
6735       free (t1);
6736       free (t2);
6737       return 1;
6738     }
6739   return 0;
6740 }
6741
6742 /* Field registration routine. If TYPE doesn't exist, field
6743    declarations are linked to the undefined TYPE dependency list, to
6744    be later resolved in java_complete_class () */
6745
6746 static void
6747 register_fields (flags, type, variable_list)
6748      int flags;
6749      tree type, variable_list;
6750 {
6751   tree current, saved_type;
6752   tree class_type = NULL_TREE;
6753   int saved_lineno = lineno;
6754   int must_chain = 0;
6755   tree wfl = NULL_TREE;
6756
6757   if (GET_CPC ())
6758     class_type = TREE_TYPE (GET_CPC ());
6759
6760   if (!class_type || class_type == error_mark_node)
6761     return;
6762
6763   /* If we're adding fields to interfaces, those fields are public,
6764      static, final */
6765   if (CLASS_INTERFACE (TYPE_NAME (class_type)))
6766     {
6767       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
6768                                  flags, ACC_PUBLIC, "interface field(s)");
6769       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
6770                                  flags, ACC_STATIC, "interface field(s)");
6771       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
6772                                  flags, ACC_FINAL, "interface field(s)");
6773       check_modifiers ("Illegal interface member modifier `%s'", flags,
6774                        INTERFACE_FIELD_MODIFIERS);
6775       flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
6776     }
6777
6778   /* Obtain a suitable type for resolution, if necessary */
6779   SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
6780
6781   /* If TYPE is fully resolved and we don't have a reference, make one */
6782   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6783
6784   for (current = variable_list, saved_type = type; current; 
6785        current = TREE_CHAIN (current), type = saved_type)
6786     {
6787       tree real_type;
6788       tree field_decl;
6789       tree cl = TREE_PURPOSE (current);
6790       tree init = TREE_VALUE (current);
6791       tree current_name = EXPR_WFL_NODE (cl);
6792
6793       /* Can't declare static fields in inner classes */
6794       if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
6795           && !CLASS_INTERFACE (TYPE_NAME (class_type)))
6796         parse_error_context 
6797           (cl, "Field `%s' can't be static in innerclass `%s'. Only members of interfaces and top-level classes can be static",
6798            IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
6799            lang_printable_name (class_type, 0));
6800
6801       /* Process NAME, as it may specify extra dimension(s) for it */
6802       type = build_array_from_name (type, wfl, current_name, &current_name);
6803
6804       /* Type adjustment. We may have just readjusted TYPE because
6805          the variable specified more dimensions. Make sure we have
6806          a reference if we can and don't have one already. Also
6807          change the name if we have an init. */
6808       if (type != saved_type)
6809         {
6810           PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6811           if (init)
6812             EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
6813         }
6814
6815       real_type = GET_REAL_TYPE (type);
6816       /* Check for redeclarations */
6817       if (duplicate_declaration_error_p (current_name, real_type, cl))
6818         continue;
6819
6820       /* Set lineno to the line the field was found and create a
6821          declaration for it. Eventually sets the @deprecated tag flag. */
6822       if (flag_emit_xref)
6823         lineno = EXPR_WFL_LINECOL (cl);
6824       else
6825         lineno = EXPR_WFL_LINENO (cl);
6826       field_decl = add_field (class_type, current_name, real_type, flags);
6827       CHECK_DEPRECATED (field_decl);
6828
6829       /* If the couple initializer/initialized is marked ARG_FINAL_P, we
6830          mark the created field FIELD_LOCAL_ALIAS, so that we can 
6831          hide parameters to this inner class $finit$ and constructors. */
6832       if (ARG_FINAL_P (current))
6833         FIELD_LOCAL_ALIAS (field_decl) = 1;
6834       
6835       /* Check if we must chain. */
6836       if (must_chain)
6837         register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
6838           
6839       /* If we have an initialization value tied to the field */
6840       if (init)
6841         {
6842           /* The field is declared static */
6843           if (flags & ACC_STATIC)
6844             {
6845               /* We include the field and its initialization part into
6846                  a list used to generate <clinit>. After <clinit> is
6847                  walked, field initializations will be processed and
6848                  fields initialized with known constants will be taken
6849                  out of <clinit> and have their DECL_INITIAL set
6850                  appropriately. */
6851               TREE_CHAIN (init) = CPC_STATIC_INITIALIZER_STMT (ctxp);
6852               SET_CPC_STATIC_INITIALIZER_STMT (ctxp, init);
6853               if (TREE_OPERAND (init, 1) 
6854                   && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
6855                 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
6856             }
6857           /* A non-static field declared with an immediate initialization is
6858              to be initialized in <init>, if any.  This field is remembered
6859              to be processed at the time of the generation of <init>. */
6860           else
6861             {
6862               TREE_CHAIN (init) = CPC_INITIALIZER_STMT (ctxp);
6863               SET_CPC_INITIALIZER_STMT (ctxp, init);
6864             }
6865           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
6866           DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
6867         }
6868     }
6869   lineno = saved_lineno;
6870 }
6871
6872 /* Generate $finit$, using the list of initialized fields to populate
6873    its body. $finit$'s parameter(s) list is adjusted to include the
6874    one(s) used to initialized the field(s) caching outer context
6875    local(s). */
6876
6877 static tree
6878 generate_finit (class_type)
6879      tree class_type;
6880 {
6881   int count = 0;
6882   tree list = TYPE_FINIT_STMT_LIST (class_type);
6883   tree mdecl, current, parms;
6884
6885   parms = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION, 
6886                                                   class_type, NULL_TREE, 
6887                                                   &count);
6888   CRAFTED_PARAM_LIST_FIXUP (parms);
6889   mdecl = create_artificial_method (class_type, ACC_PRIVATE, void_type_node,
6890                                     finit_identifier_node, parms);
6891   fix_method_argument_names (parms, mdecl);
6892   layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
6893                        mdecl, NULL_TREE);
6894   DECL_FUNCTION_NAP (mdecl) = count;
6895   start_artificial_method_body (mdecl);
6896
6897   for (current = list; current; current = TREE_CHAIN (current))
6898     java_method_add_stmt (mdecl, 
6899                           build_debugable_stmt (EXPR_WFL_LINECOL (current), 
6900                                                 current));
6901   end_artificial_method_body (mdecl);
6902   return mdecl;
6903 }
6904
6905 static void
6906 add_instance_initializer (mdecl)
6907      tree mdecl;
6908 {
6909   tree current;
6910   tree stmt_list = TYPE_II_STMT_LIST (DECL_CONTEXT (mdecl));
6911   tree compound = NULL_TREE;
6912
6913   if (stmt_list)
6914     {
6915       for (current = stmt_list; current; current = TREE_CHAIN (current))
6916         compound = add_stmt_to_compound (compound, NULL_TREE, current);
6917
6918       java_method_add_stmt (mdecl, build1 (INSTANCE_INITIALIZERS_EXPR,
6919                                            NULL_TREE, compound));
6920     }
6921 }
6922
6923 /* Shared accros method_declarator and method_header to remember the
6924    patch stage that was reached during the declaration of the method.
6925    A method DECL is built differently is there is no patch
6926    (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
6927    pending on the currently defined method.  */
6928
6929 static int patch_stage;
6930
6931 /* Check the method declaration and add the method to its current
6932    class.  If the argument list is known to contain incomplete types,
6933    the method is partially added and the registration will be resume
6934    once the method arguments resolved. If TYPE is NULL, we're dealing
6935    with a constructor.  */
6936
6937 static tree
6938 method_header (flags, type, mdecl, throws)
6939      int flags;
6940      tree type, mdecl, throws;
6941 {
6942   tree meth = TREE_VALUE (mdecl);
6943   tree id = TREE_PURPOSE (mdecl);
6944   tree type_wfl = NULL_TREE;
6945   tree meth_name = NULL_TREE;
6946   tree current, orig_arg, this_class = NULL;
6947   int saved_lineno;
6948   int constructor_ok = 0, must_chain;
6949   int count;
6950   
6951   check_modifiers_consistency (flags);
6952
6953   if (GET_CPC ())
6954     this_class = TREE_TYPE (GET_CPC ());
6955
6956   if (!this_class || this_class == error_mark_node)
6957     return NULL_TREE;
6958   
6959   /* There are some forbidden modifiers for an abstract method and its
6960      class must be abstract as well.  */
6961   if (type && (flags & ACC_ABSTRACT))
6962     {
6963       ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
6964       ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
6965       ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
6966       ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
6967       ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
6968       if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
6969           && !CLASS_INTERFACE (TYPE_NAME (this_class)))
6970         parse_error_context 
6971           (id, "Class `%s' must be declared abstract to define abstract method `%s'", 
6972            IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
6973            IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6974     }
6975
6976   /* Things to be checked when declaring a constructor */
6977   if (!type)
6978     {
6979       int ec = java_error_count;
6980       /* 8.6: Constructor declarations: we might be trying to define a
6981          method without specifying a return type. */
6982       if (EXPR_WFL_NODE (id) != GET_CPC_UN ())
6983         parse_error_context 
6984           (id, "Invalid method declaration, return type required");
6985       /* 8.6.3: Constructor modifiers */
6986       else
6987         {
6988           JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
6989           JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
6990           JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
6991           JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
6992           JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
6993         }
6994       /* If we found error here, we don't consider it's OK to tread
6995          the method definition as a constructor, for the rest of this
6996          function */
6997       if (ec == java_error_count)
6998         constructor_ok = 1;
6999     }
7000
7001   /* Method declared within the scope of an interface are implicitly
7002      abstract and public. Conflicts with other erroneously provided
7003      modifiers are checked right after. */
7004
7005   if (CLASS_INTERFACE (TYPE_NAME (this_class)))
7006     {
7007       /* If FLAGS isn't set because of a modifier, turn the
7008          corresponding modifier WFL to NULL so we issue a warning on
7009          the obsolete use of the modifier */
7010       if (!(flags & ACC_PUBLIC))
7011         MODIFIER_WFL (PUBLIC_TK) = NULL;
7012       if (!(flags & ACC_ABSTRACT))
7013         MODIFIER_WFL (ABSTRACT_TK) = NULL;
7014       flags |= ACC_PUBLIC;
7015       flags |= ACC_ABSTRACT;
7016     }
7017
7018   /* Inner class can't declare static methods */
7019   if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
7020     {
7021       parse_error_context 
7022         (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
7023          IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
7024          lang_printable_name (this_class, 0));
7025     }
7026
7027   /* Modifiers context reset moved up, so abstract method declaration
7028      modifiers can be later checked.  */
7029
7030   /* Set constructor returned type to void and method name to <init>,
7031      unless we found an error identifier the constructor (in which
7032      case we retain the original name) */
7033   if (!type)
7034     {
7035       type = void_type_node;
7036       if (constructor_ok)
7037         meth_name = init_identifier_node;
7038     }
7039   else
7040     meth_name = EXPR_WFL_NODE (id);
7041
7042   /* Do the returned type resolution and registration if necessary */
7043   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7044
7045   if (meth_name)
7046     type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
7047   EXPR_WFL_NODE (id) = meth_name;
7048   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7049
7050   if (must_chain)
7051     {
7052       patch_stage = JDEP_METHOD_RETURN;
7053       register_incomplete_type (patch_stage, type_wfl, id, type);
7054       TREE_TYPE (meth) = GET_REAL_TYPE (type);
7055     }
7056   else
7057     TREE_TYPE (meth) = type;
7058
7059   saved_lineno = lineno;
7060   /* When defining an abstract or interface method, the curly
7061      bracket at level 1 doesn't exist because there is no function
7062      body */
7063   lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 : 
7064             EXPR_WFL_LINENO (id));
7065
7066   /* Remember the original argument list */
7067   orig_arg = TYPE_ARG_TYPES (meth);
7068
7069   if (patch_stage)              /* includes ret type and/or all args */
7070     {
7071       jdep *jdep;
7072       meth = add_method_1 (this_class, flags, meth_name, meth);
7073       /* Patch for the return type */
7074       if (patch_stage == JDEP_METHOD_RETURN)
7075         {
7076           jdep = CLASSD_LAST (ctxp->classd_list);
7077           JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
7078         }
7079       /* This is the stop JDEP. METH allows the function's signature
7080          to be computed. */
7081       register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
7082     }
7083   else
7084     meth = add_method (this_class, flags, meth_name, 
7085                        build_java_signature (meth));
7086
7087   /* Remember final parameters */
7088   MARK_FINAL_PARMS (meth, orig_arg);
7089
7090   /* Fix the method argument list so we have the argument name
7091      information */
7092   fix_method_argument_names (orig_arg, meth);
7093
7094   /* Register the parameter number and re-install the current line
7095      number */
7096   DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
7097   lineno = saved_lineno;
7098
7099   /* Register exception specified by the `throws' keyword for
7100      resolution and set the method decl appropriate field to the list.
7101      Note: the grammar ensures that what we get here are class
7102      types. */
7103   if (throws)
7104     {
7105       throws = nreverse (throws);
7106       for (current = throws; current; current = TREE_CHAIN (current))
7107         {
7108           register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
7109                                     NULL_TREE, NULL_TREE);
7110           JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) = 
7111             &TREE_VALUE (current);
7112         }
7113       DECL_FUNCTION_THROWS (meth) = throws;
7114     }
7115
7116   /* We set the DECL_NAME to ID so we can track the location where
7117      the function was declared. This allow us to report
7118      redefinition error accurately. When method are verified,
7119      DECL_NAME is reinstalled properly (using the content of the
7120      WFL node ID) (see check_method_redefinition). We don't do that
7121      when Object is being defined. Constructor <init> names will be
7122      reinstalled the same way. */
7123   if (TREE_TYPE (GET_CPC ()) != object_type_node)
7124     DECL_NAME (meth) = id;
7125
7126   /* Set the flag if we correctly processed a constructor */
7127   if (constructor_ok)
7128     {
7129       DECL_CONSTRUCTOR_P (meth) = 1;
7130       /* Compute and store the number of artificial parameters declared
7131          for this constructor */
7132       for (count = 0, current = TYPE_FIELDS (this_class); current; 
7133            current = TREE_CHAIN (current))
7134         if (FIELD_LOCAL_ALIAS (current))
7135           count++;
7136       DECL_FUNCTION_NAP (meth) = count;
7137     }
7138
7139   /* Eventually set the @deprecated tag flag */
7140   CHECK_DEPRECATED (meth);
7141
7142   /* If doing xref, store column and line number information instead
7143      of the line number only. */
7144   if (flag_emit_xref)
7145     DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
7146
7147   return meth;
7148 }
7149
7150 static void
7151 fix_method_argument_names (orig_arg, meth)
7152     tree orig_arg, meth;
7153 {
7154   tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
7155   if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
7156     {
7157       TREE_PURPOSE (arg) = this_identifier_node;
7158       arg = TREE_CHAIN (arg);
7159     }
7160   while (orig_arg != end_params_node)
7161     {
7162       TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
7163       orig_arg = TREE_CHAIN (orig_arg);
7164       arg = TREE_CHAIN (arg);
7165     }
7166 }
7167
7168 /* Complete the method declaration with METHOD_BODY.  */
7169
7170 static void
7171 finish_method_declaration (method_body)
7172      tree method_body;
7173 {
7174   int flags;
7175
7176   if (!current_function_decl)
7177     return;
7178
7179   flags = get_access_flags_from_decl (current_function_decl);
7180
7181   /* 8.4.5 Method Body */
7182   if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
7183     {
7184       tree wfl = DECL_NAME (current_function_decl);
7185       parse_error_context (wfl, 
7186                            "%s method `%s' can't have a body defined",
7187                            (METHOD_NATIVE (current_function_decl) ?
7188                             "Native" : "Abstract"),
7189                            IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7190       method_body = NULL_TREE;
7191     }
7192   else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
7193     {
7194       tree wfl = DECL_NAME (current_function_decl);
7195       parse_error_context
7196         (wfl, 
7197          "Non native and non abstract method `%s' must have a body defined",
7198          IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7199       method_body = NULL_TREE;
7200     }
7201
7202   if (flag_emit_class_files && method_body 
7203       && TREE_CODE (method_body) == NOP_EXPR 
7204       && TREE_TYPE (current_function_decl) 
7205       && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
7206     method_body = build1 (RETURN_EXPR, void_type_node, NULL);
7207     
7208   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
7209   maybe_absorb_scoping_blocks ();
7210   /* Exit function's body */
7211   exit_block ();
7212   /* Merge last line of the function with first line, directly in the
7213      function decl. It will be used to emit correct debug info. */
7214   if (!flag_emit_xref)
7215     DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
7216
7217   /* Since function's argument's list are shared, reset the
7218      ARG_FINAL_P parameter that might have been set on some of this
7219      function parameters. */
7220   UNMARK_FINAL_PARMS (current_function_decl);
7221   
7222   /* So we don't have an irrelevant function declaration context for
7223      the next static block we'll see. */
7224   current_function_decl = NULL_TREE;
7225 }
7226
7227 /* Build a an error message for constructor circularity errors.  */
7228
7229 static char *
7230 constructor_circularity_msg (from, to)
7231      tree from, to;
7232 {
7233   static char string [4096];
7234   char *t = xstrdup (lang_printable_name (from, 0));
7235   sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
7236   free (t);
7237   return string;
7238 }
7239
7240 /* Verify a circular call to METH. Return 1 if an error is found, 0
7241    otherwise.  */
7242
7243 static int
7244 verify_constructor_circularity (meth, current)
7245      tree meth, current;
7246 {
7247   static tree list = NULL_TREE;
7248   tree c;
7249   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7250     {
7251       if (TREE_VALUE (c) == meth)
7252         {
7253           char *t;
7254           if (list)
7255             {
7256               tree liste;
7257               list = nreverse (list);
7258               for (liste = list; liste; liste = TREE_CHAIN (liste))
7259                 {
7260                   parse_error_context 
7261                     (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s",
7262                      constructor_circularity_msg
7263                       (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste)))); 
7264                   java_error_count--;
7265                 }
7266             }
7267           t = xstrdup (lang_printable_name (meth, 0));
7268           parse_error_context (TREE_PURPOSE (c), 
7269                                "%s: recursive invocation of constructor `%s'",
7270                                constructor_circularity_msg (current, meth), t);
7271           free (t);
7272           list = NULL_TREE;
7273           return 1;
7274         }
7275     }
7276   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7277     {
7278       list = tree_cons (c, current, list);
7279       if (verify_constructor_circularity (meth, TREE_VALUE (c)))
7280         return 1;
7281       list = TREE_CHAIN (list);
7282     }
7283   return 0;
7284 }
7285
7286 /* Check modifiers that can be declared but exclusively */
7287
7288 static void
7289 check_modifiers_consistency (flags)
7290      int flags;
7291 {
7292   int acc_count = 0;
7293   tree cl = NULL_TREE;
7294
7295   THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, PUBLIC_TK, acc_count, cl);
7296   THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, PRIVATE_TK, acc_count, cl);
7297   THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
7298   if (acc_count > 1)
7299     parse_error_context
7300       (cl, "Inconsistent member declaration.  At most one of `public', `private', or `protected' may be specified");
7301
7302   acc_count = 0;
7303   cl = NULL_TREE;
7304   THIS_MODIFIER_ONLY (flags, ACC_FINAL, FINAL_TK - PUBLIC_TK,
7305                       acc_count, cl);
7306   THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK - PUBLIC_TK,
7307                       acc_count, cl);
7308   if (acc_count > 1)
7309     parse_error_context (cl,
7310                          "Inconsistent member declaration.  At most one of `final' or `volatile' may be specified");
7311 }
7312
7313 /* Check the methode header METH for abstract specifics features */
7314
7315 static void
7316 check_abstract_method_header (meth)
7317      tree meth;
7318 {
7319   int flags = get_access_flags_from_decl (meth);
7320   /* DECL_NAME might still be a WFL node */
7321   tree name = GET_METHOD_NAME (meth);
7322
7323   OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
7324                               ACC_ABSTRACT, "abstract method",
7325                               IDENTIFIER_POINTER (name));
7326   OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags, 
7327                               ACC_PUBLIC, "abstract method",
7328                               IDENTIFIER_POINTER (name));
7329
7330   check_modifiers ("Illegal modifier `%s' for interface method",
7331                   flags, INTERFACE_METHOD_MODIFIERS);
7332 }
7333
7334 /* Create a FUNCTION_TYPE node and start augmenting it with the
7335    declared function arguments. Arguments type that can't be resolved
7336    are left as they are, but the returned node is marked as containing
7337    incomplete types.  */
7338
7339 static tree
7340 method_declarator (id, list)
7341      tree id, list;
7342 {
7343   tree arg_types = NULL_TREE, current, node;
7344   tree meth = make_node (FUNCTION_TYPE);
7345   jdep *jdep;
7346
7347   patch_stage = JDEP_NO_PATCH;
7348
7349   /* If we're dealing with an inner class constructor, we hide the
7350      this$<n> decl in the name field of its parameter declaration.  We
7351      also might have to hide the outer context local alias
7352      initializers. Not done when the class is a toplevel class. */
7353   if (PURE_INNER_CLASS_DECL_P (GET_CPC ()) 
7354       && EXPR_WFL_NODE (id) == GET_CPC_UN ())
7355     {
7356       tree aliases_list, type, thisn;
7357       /* First the aliases, linked to the regular parameters */
7358       aliases_list =
7359         build_alias_initializer_parameter_list (AIPL_FUNCTION_DECLARATION, 
7360                                                 TREE_TYPE (GET_CPC ()),
7361                                                 NULL_TREE, NULL);
7362       list = chainon (nreverse (aliases_list), list);
7363
7364       /* Then this$<n> */
7365       type = TREE_TYPE (DECL_CONTEXT (GET_CPC ()));
7366       thisn = build_current_thisn (TYPE_NAME (GET_CPC ()));
7367       list = tree_cons (build_wfl_node (thisn), build_pointer_type (type),
7368                         list);
7369     }
7370   
7371   for (current = list; current; current = TREE_CHAIN (current))
7372     {
7373       int must_chain = 0;
7374       tree wfl_name = TREE_PURPOSE (current);
7375       tree type = TREE_VALUE (current);
7376       tree name = EXPR_WFL_NODE (wfl_name);
7377       tree already, arg_node;
7378       tree type_wfl = NULL_TREE;
7379       tree real_type;
7380
7381       /* Obtain a suitable type for resolution, if necessary */
7382       SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7383
7384       /* Process NAME, as it may specify extra dimension(s) for it */
7385       type = build_array_from_name (type, type_wfl, name, &name);
7386       EXPR_WFL_NODE (wfl_name) = name;
7387
7388       real_type = GET_REAL_TYPE (type);
7389       if (TREE_CODE (real_type) == RECORD_TYPE)
7390         {
7391           real_type = promote_type (real_type);
7392           if (TREE_CODE (type) == TREE_LIST)
7393             TREE_PURPOSE (type) = real_type;
7394         }
7395
7396       /* Check redefinition */
7397       for (already = arg_types; already; already = TREE_CHAIN (already))
7398         if (TREE_PURPOSE (already) == name)
7399           {
7400             parse_error_context
7401               (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
7402                IDENTIFIER_POINTER (name),
7403                IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7404             break;
7405           }
7406
7407       /* If we've an incomplete argument type, we know there is a location
7408          to patch when the type get resolved, later.  */
7409       jdep = NULL;
7410       if (must_chain)
7411         {
7412           patch_stage = JDEP_METHOD;
7413           type = register_incomplete_type (patch_stage, 
7414                                            type_wfl, wfl_name, type);
7415           jdep = CLASSD_LAST (ctxp->classd_list);
7416           JDEP_MISC (jdep) = id;
7417         }
7418
7419       /* The argument node: a name and a (possibly) incomplete type.  */
7420       arg_node = build_tree_list (name, real_type);
7421       /* Remeber arguments declared final. */
7422       ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
7423       
7424       if (jdep)
7425         JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
7426       TREE_CHAIN (arg_node) = arg_types;
7427       arg_types = arg_node;
7428     }
7429   TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
7430   node = build_tree_list (id, meth);
7431   return node;
7432 }
7433
7434 static int
7435 unresolved_type_p (wfl, returned)
7436      tree wfl;
7437      tree *returned;
7438      
7439 {
7440   if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
7441     {
7442       if (returned)
7443         {
7444           tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
7445           if (decl && current_class && (decl == TYPE_NAME (current_class)))
7446             *returned = TREE_TYPE (decl);
7447           else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
7448             *returned = TREE_TYPE (GET_CPC ());
7449           else
7450             *returned = NULL_TREE;
7451         }
7452       return 1;
7453     }
7454   if (returned)
7455     *returned = wfl;
7456   return 0;
7457 }
7458
7459 /* From NAME, build a qualified identifier node using the
7460    qualification from the current package definition. */
7461
7462 static tree
7463 parser_qualified_classname (is_static, name)
7464      int is_static;
7465      tree name;
7466 {
7467   tree nested_class_name;
7468
7469   if (!is_static 
7470       && (nested_class_name = maybe_make_nested_class_name (name)))
7471     return nested_class_name;
7472
7473   if (ctxp->package)
7474     return merge_qualified_name (ctxp->package, name);
7475   else 
7476     return name;
7477 }
7478
7479 /* Called once the type a interface extends is resolved. Returns 0 if
7480    everything is OK.  */
7481
7482 static int
7483 parser_check_super_interface (super_decl, this_decl, this_wfl)
7484      tree super_decl, this_decl, this_wfl;
7485 {
7486   tree super_type = TREE_TYPE (super_decl);
7487
7488   /* Has to be an interface */
7489   if (!CLASS_INTERFACE (super_decl))
7490     {
7491       parse_error_context 
7492         (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
7493          (TYPE_ARRAY_P (super_type) ? "array" : "class"),
7494          IDENTIFIER_POINTER (DECL_NAME (super_decl)),
7495          (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ? 
7496           "interface" : "class"),
7497          IDENTIFIER_POINTER (DECL_NAME (this_decl)));
7498       return 1;
7499     }
7500
7501   /* Check scope: same package OK, other package: OK if public */
7502   if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
7503     return 1;
7504
7505   SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
7506                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7507                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7508   return 0;
7509 }
7510
7511 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
7512    0 if everthing is OK.  */
7513
7514 static int
7515 parser_check_super (super_decl, this_decl, wfl)
7516      tree super_decl, this_decl, wfl;
7517 {
7518   tree super_type = TREE_TYPE (super_decl);
7519
7520   /* SUPER should be a CLASS (neither an array nor an interface) */
7521   if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
7522     {
7523       parse_error_context 
7524         (wfl, "Class `%s' can't subclass %s `%s'",
7525          IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7526          (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
7527          IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7528       return 1;
7529     }
7530
7531   if (CLASS_FINAL (TYPE_NAME (super_type)))
7532     {
7533       parse_error_context (wfl, "Can't subclass final classes: %s",
7534                            IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7535       return 1;
7536     }
7537
7538   /* Check scope: same package OK, other package: OK if public */
7539   if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
7540     return 1;
7541   
7542   SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
7543                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7544                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7545   return 0;
7546 }
7547
7548 /* Create a new dependency list and link it (in a LIFO manner) to the
7549    CTXP list of type dependency list.  */
7550
7551 static void
7552 create_jdep_list (ctxp)
7553      struct parser_ctxt *ctxp;
7554 {
7555   jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));      
7556   new->first = new->last = NULL;
7557   new->next = ctxp->classd_list;
7558   ctxp->classd_list = new;
7559 }
7560
7561 static jdeplist *
7562 reverse_jdep_list (ctxp)
7563      struct parser_ctxt *ctxp;
7564 {
7565   register jdeplist *prev = NULL, *current, *next;
7566   for (current = ctxp->classd_list; current; current = next)
7567     {
7568       next = current->next;
7569       current->next = prev;
7570       prev = current;
7571     }
7572   return prev;
7573 }
7574
7575 /* Create a fake pointer based on the ID stored in
7576    TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
7577    registered again. */
7578
7579 static tree
7580 obtain_incomplete_type (type_name)
7581      tree type_name;
7582 {
7583   tree ptr, name;
7584
7585   if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
7586     name = EXPR_WFL_NODE (type_name);
7587   else if (INCOMPLETE_TYPE_P (type_name))
7588     name = TYPE_NAME (type_name);
7589   else
7590     fatal ("invalid type name - obtain_incomplete_type");
7591
7592   for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
7593     if (TYPE_NAME (ptr) == name)
7594       break;
7595
7596   if (!ptr)
7597     {
7598       push_obstacks (&permanent_obstack, &permanent_obstack);
7599       BUILD_PTR_FROM_NAME (ptr, name);
7600       layout_type (ptr);
7601       pop_obstacks ();
7602       TREE_CHAIN (ptr) = ctxp->incomplete_class;
7603       ctxp->incomplete_class = ptr;
7604     }
7605
7606   return ptr;
7607 }
7608
7609 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
7610    non NULL instead of computing a new fake type based on WFL. The new
7611    dependency is inserted in the current type dependency list, in FIFO
7612    manner.  */
7613
7614 static tree
7615 register_incomplete_type (kind, wfl, decl, ptr)
7616      int kind;
7617      tree wfl, decl, ptr;
7618 {
7619   jdep *new = (jdep *)xmalloc (sizeof (jdep));
7620
7621   if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
7622     ptr = obtain_incomplete_type (wfl);
7623
7624   JDEP_KIND (new) = kind;
7625   JDEP_DECL (new) = decl;
7626   JDEP_SOLV (new) = ptr;
7627   JDEP_WFL (new) = wfl;
7628   JDEP_CHAIN (new) = NULL;
7629   JDEP_MISC (new) = NULL_TREE;
7630   if ((kind == JDEP_SUPER || kind == JDEP_INTERFACE)
7631       && GET_ENCLOSING_CPC ())
7632     JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
7633   else
7634     JDEP_ENCLOSING (new) = GET_CPC ();
7635   JDEP_GET_PATCH (new) = (tree *)NULL;
7636
7637   JDEP_INSERT (ctxp->classd_list, new);
7638
7639   return ptr;
7640 }
7641
7642 void
7643 java_check_circular_reference ()
7644 {
7645   tree current;
7646   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7647     {
7648       tree type = TREE_TYPE (current);
7649       if (CLASS_INTERFACE (current))
7650         {
7651           /* Check all interfaces this class extends */
7652           tree basetype_vec = TYPE_BINFO_BASETYPES (type);
7653           int n, i;
7654
7655           if (!basetype_vec)
7656             return;
7657           n = TREE_VEC_LENGTH (basetype_vec);
7658           for (i = 0; i < n; i++)
7659             {
7660               tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7661               if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node 
7662                   && interface_of_p (type, BINFO_TYPE (vec_elt)))
7663                 parse_error_context (lookup_cl (current),
7664                                      "Cyclic interface inheritance");
7665             }
7666         }
7667       else
7668         if (inherits_from_p (CLASSTYPE_SUPER (type), type))
7669           parse_error_context (lookup_cl (current), 
7670                                "Cyclic class inheritance%s",
7671                                (cyclic_inheritance_report ?
7672                                 cyclic_inheritance_report : ""));
7673     }
7674 }
7675
7676 /* Augment the parameter list PARM with parameters crafted to
7677    initialize outer context locals aliases. Through ARTIFICIAL, a
7678    count is kept of the number of crafted parameters. MODE governs
7679    what eventually gets created: something suitable for a function
7680    creation or a function invocation, either the constructor or
7681    $finit$.  */
7682
7683 static tree
7684 build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
7685     int mode;
7686     tree class_type, parm;
7687     int *artificial;
7688 {
7689   tree field;
7690   for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
7691     if (FIELD_LOCAL_ALIAS (field))
7692       {
7693         char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
7694         tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
7695
7696         switch (mode)
7697           {
7698           case AIPL_FUNCTION_DECLARATION:
7699             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7700             purpose = build_wfl_node (get_identifier (buffer));
7701             if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
7702               value = build_wfl_node (TYPE_NAME (TREE_TYPE (field)));
7703             else
7704               value = TREE_TYPE (field);
7705             break;
7706
7707           case AIPL_FUNCTION_CREATION:
7708             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7709             purpose = get_identifier (buffer);
7710             value = TREE_TYPE (field);
7711             break;
7712
7713           case AIPL_FUNCTION_FINIT_INVOCATION:
7714             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7715             /* Now, this is wrong. purpose should always be the NAME
7716                of something and value its matching value (decl, type,
7717                etc...) FIXME -- but there is a lot to fix. */
7718
7719             /* When invoked for this kind of operation, we already
7720                know whether a field is used or not. */
7721             purpose = TREE_TYPE (field);
7722             value = build_wfl_node (get_identifier (buffer));
7723             break;
7724
7725           case AIPL_FUNCTION_CTOR_INVOCATION:
7726             /* There are two case: the constructor invokation happends
7727                outside the local inner, in which case, locales from the outer
7728                context are directly used.
7729
7730                Otherwise, we fold to using the alias directly. */
7731             if (class_type == current_class)
7732               value = field;
7733             else
7734               {
7735                 name = get_identifier (&buffer[4]);
7736                 value = IDENTIFIER_LOCAL_VALUE (name);
7737               }
7738             break;
7739           }
7740         parm = tree_cons (purpose, value, parm);
7741         if (artificial)
7742           *artificial +=1;
7743       }
7744   return parm;
7745 }
7746
7747 /* Craft a constructor for CLASS_DECL -- what we should do when none
7748    where found. ARGS is non NULL when a special signature must be
7749    enforced. This is the case for anonymous classes.  */
7750
7751 static void
7752 craft_constructor (class_decl, args)
7753      tree class_decl, args;
7754 {
7755   tree class_type = TREE_TYPE (class_decl);
7756   tree parm = NULL_TREE;
7757   int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7758                ACC_PUBLIC : 0);
7759   int i = 0, artificial = 0;
7760   tree decl, ctor_name;
7761   char buffer [80];
7762   
7763   push_obstacks (&permanent_obstack, &permanent_obstack);
7764
7765   /* The constructor name is <init> unless we're dealing with an
7766      anonymous class, in which case the name will be fixed after having
7767      be expanded. */
7768   if (ANONYMOUS_CLASS_P (class_type))
7769     ctor_name = DECL_NAME (class_decl);
7770   else
7771     ctor_name = init_identifier_node;
7772
7773   /* If we're dealing with an inner class constructor, we hide the
7774      this$<n> decl in the name field of its parameter declaration. */
7775   if (PURE_INNER_CLASS_TYPE_P (class_type))
7776     {
7777       tree type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_type)));
7778       parm = tree_cons (build_current_thisn (class_type),
7779                         build_pointer_type (type), parm);
7780
7781       /* Some more arguments to be hidden here. The values of the local
7782          variables of the outer context that the inner class needs to see. */
7783       parm = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
7784                                                      class_type, parm, 
7785                                                      &artificial);
7786     }
7787
7788   /* Then if there are any args to be enforced, enforce them now */
7789   for (; args && args != end_params_node; args = TREE_CHAIN (args))
7790     {
7791       sprintf (buffer, "parm%d", i++);
7792       parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
7793     }
7794
7795   CRAFTED_PARAM_LIST_FIXUP (parm);
7796   decl = create_artificial_method (class_type, flags, void_type_node, 
7797                                    ctor_name, parm);
7798   fix_method_argument_names (parm, decl);
7799   /* Now, mark the artificial parameters. */
7800   DECL_FUNCTION_NAP (decl) = artificial;
7801
7802   pop_obstacks ();
7803   DECL_CONSTRUCTOR_P (decl) = 1;
7804 }
7805
7806
7807 /* Fix the constructors. This will be called right after circular
7808    references have been checked. It is necessary to fix constructors
7809    early even if no code generation will take place for that class:
7810    some generated constructor might be required by the class whose
7811    compilation triggered this one to be simply loaded.  */
7812
7813 void
7814 java_fix_constructors ()
7815 {
7816   tree current;
7817
7818   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7819     {
7820       tree class_type = TREE_TYPE (current);
7821       int saw_ctor = 0;
7822       tree decl;
7823
7824       if (CLASS_INTERFACE (TYPE_NAME (class_type)))
7825         continue;
7826
7827       for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
7828         {
7829           if (DECL_CONSTRUCTOR_P (decl))
7830             {
7831               fix_constructors (decl);
7832               saw_ctor = 1;
7833             }
7834         }
7835
7836       /* Anonymous class constructor can't be generated that early. */
7837       if (!saw_ctor && !ANONYMOUS_CLASS_P (class_type))
7838         craft_constructor (current, NULL_TREE);
7839     }
7840 }
7841
7842 /* safe_layout_class just makes sure that we can load a class without
7843    disrupting the current_class, input_file, lineno, etc, information
7844    about the class processed currently.  */
7845
7846 void
7847 safe_layout_class (class)
7848      tree class;
7849 {
7850   tree save_current_class = current_class;
7851   char *save_input_filename = input_filename;
7852   int save_lineno = lineno;
7853
7854   push_obstacks (&permanent_obstack, &permanent_obstack);
7855
7856   layout_class (class);
7857   pop_obstacks ();
7858
7859   current_class = save_current_class;
7860   input_filename = save_input_filename;
7861   lineno = save_lineno;
7862   CLASS_LOADED_P (class) = 1;
7863 }
7864
7865 static tree
7866 jdep_resolve_class (dep)
7867      jdep *dep;
7868 {
7869   tree decl;
7870
7871   if (JDEP_RESOLVED_P (dep))
7872     decl = JDEP_RESOLVED_DECL (dep);
7873   else
7874     {
7875       decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
7876                             JDEP_DECL (dep), JDEP_WFL (dep));
7877       JDEP_RESOLVED (dep, decl);
7878     }
7879     
7880   if (!decl)
7881     complete_class_report_errors (dep);
7882
7883   return decl;
7884 }
7885
7886 /* Complete unsatisfied class declaration and their dependencies */
7887
7888 void
7889 java_complete_class ()
7890 {
7891   tree cclass;
7892   jdeplist *cclassd;
7893   int error_found;
7894   tree type;
7895
7896   push_obstacks (&permanent_obstack, &permanent_obstack);
7897
7898   /* Process imports and reverse the import on demand list */
7899   process_imports ();
7900   if (ctxp->import_demand_list)
7901     ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
7902
7903   /* Rever things so we have the right order */
7904   ctxp->class_list = nreverse (ctxp->class_list);
7905   ctxp->classd_list = reverse_jdep_list (ctxp);
7906
7907   for (cclassd = ctxp->classd_list, cclass = ctxp->class_list; 
7908        cclass && cclassd; 
7909        cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
7910     {
7911       jdep *dep;
7912       for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
7913         {
7914           tree decl;
7915           if (!(decl = jdep_resolve_class (dep)))
7916             continue;
7917
7918           /* Now it's time to patch */
7919           switch (JDEP_KIND (dep))
7920             {
7921             case JDEP_SUPER:
7922               /* Simply patch super */
7923               if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
7924                 continue;
7925               BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO 
7926                 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
7927               break;
7928
7929             case JDEP_FIELD:
7930               {
7931                 /* We do part of the job done in add_field */
7932                 tree field_decl = JDEP_DECL (dep);
7933                 tree field_type = TREE_TYPE (decl);
7934                 push_obstacks (&permanent_obstack, &permanent_obstack);
7935                 if (TREE_CODE (field_type) == RECORD_TYPE)
7936                   field_type = promote_type (field_type);
7937                 pop_obstacks ();
7938                 TREE_TYPE (field_decl) = field_type;
7939                 DECL_ALIGN (field_decl) = 0;
7940                 layout_decl (field_decl, 0);
7941                 SOURCE_FRONTEND_DEBUG 
7942                   (("Completed field/var decl `%s' with `%s'",
7943                     IDENTIFIER_POINTER (DECL_NAME (field_decl)),
7944                     IDENTIFIER_POINTER (DECL_NAME (decl))));
7945                 break;
7946               }
7947             case JDEP_METHOD:   /* We start patching a method */
7948             case JDEP_METHOD_RETURN:
7949               error_found = 0;
7950               while (1)
7951                 {
7952                   if (decl)
7953                     {
7954                       type = TREE_TYPE(decl);
7955                       if (TREE_CODE (type) == RECORD_TYPE)
7956                         type = promote_type (type);
7957                       JDEP_APPLY_PATCH (dep, type);
7958                       SOURCE_FRONTEND_DEBUG 
7959                         (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
7960                            "Completing fct `%s' with ret type `%s'":
7961                            "Completing arg `%s' with type `%s'"),
7962                           IDENTIFIER_POINTER (EXPR_WFL_NODE 
7963                                               (JDEP_DECL_WFL (dep))),
7964                           IDENTIFIER_POINTER (DECL_NAME (decl))));
7965                     }
7966                   else
7967                     error_found = 1;
7968                   dep = JDEP_CHAIN (dep);
7969                   if (JDEP_KIND (dep) == JDEP_METHOD_END)
7970                     break;
7971                   else
7972                     decl = jdep_resolve_class (dep);
7973                 }
7974               if (!error_found)
7975                 {
7976                   tree mdecl = JDEP_DECL (dep), signature;
7977                   push_obstacks (&permanent_obstack, &permanent_obstack);
7978                   /* Recompute and reset the signature, check first that
7979                      all types are now defined. If they're not,
7980                      dont build the signature. */
7981                   if (check_method_types_complete (mdecl))
7982                     {
7983                       signature = build_java_signature (TREE_TYPE (mdecl));
7984                       set_java_signature (TREE_TYPE (mdecl), signature);
7985                     }
7986                   pop_obstacks ();
7987                 }
7988               else
7989                 continue;
7990               break;
7991
7992             case JDEP_INTERFACE:
7993               if (parser_check_super_interface (decl, JDEP_DECL (dep),
7994                                                 JDEP_WFL (dep)))
7995                 continue;
7996               parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
7997               break;
7998
7999             case JDEP_PARM:
8000             case JDEP_VARIABLE:
8001               type = TREE_TYPE(decl);
8002               if (TREE_CODE (type) == RECORD_TYPE)
8003                 type = promote_type (type);
8004               JDEP_APPLY_PATCH (dep, type);
8005               break;
8006
8007             case JDEP_TYPE:
8008               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8009               SOURCE_FRONTEND_DEBUG 
8010                 (("Completing a random type dependency on a '%s' node",
8011                   tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
8012               break;
8013
8014             case JDEP_EXCEPTION:
8015               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8016               SOURCE_FRONTEND_DEBUG 
8017                 (("Completing `%s' `throws' argument node",
8018                   IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
8019               break;
8020
8021             case JDEP_ANONYMOUS:
8022               patch_anonymous_class (decl, JDEP_DECL (dep), JDEP_WFL (dep));
8023               break;
8024
8025             default:
8026               fatal ("Can't handle patch code %d - java_complete_class",
8027                      JDEP_KIND (dep));
8028             }
8029         }
8030     }
8031   pop_obstacks ();
8032   return;
8033 }
8034
8035 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
8036    array.  */
8037
8038 static tree
8039 resolve_class (enclosing, class_type, decl, cl)
8040      tree enclosing, class_type, decl, cl;
8041 {
8042   const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
8043   const char *base = name;
8044   tree resolved_type = TREE_TYPE (class_type);
8045   tree resolved_type_decl;
8046   
8047   if (resolved_type != NULL_TREE)
8048     {
8049       tree resolved_type_decl = TYPE_NAME (resolved_type);
8050       if (resolved_type_decl == NULL_TREE
8051           || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
8052         {
8053           resolved_type_decl = build_decl (TYPE_DECL,
8054                                            TYPE_NAME (class_type),
8055                                            resolved_type);
8056         }
8057       return resolved_type_decl;
8058     }
8059
8060   /* 1- Check to see if we have an array. If true, find what we really
8061      want to resolve  */
8062   while (name[0] == '[')
8063     name++;
8064   if (base != name)
8065     TYPE_NAME (class_type) = get_identifier (name);
8066
8067   /* 2- Resolve the bare type */
8068   if (!(resolved_type_decl = do_resolve_class (enclosing, class_type, 
8069                                                decl, cl)))
8070     return NULL_TREE;
8071   resolved_type = TREE_TYPE (resolved_type_decl);
8072
8073   /* 3- If we have and array, reconstruct the array down to its nesting */
8074   if (base != name)
8075     {
8076       while (base != name)
8077         {
8078           if (TREE_CODE (resolved_type) == RECORD_TYPE)
8079             resolved_type  = promote_type (resolved_type);
8080           resolved_type = build_java_array_type (resolved_type, -1);
8081           CLASS_LOADED_P (resolved_type) = 1;
8082           name--;
8083         }
8084       /* Build a fake decl for this, since this is what is expected to
8085          be returned.  */
8086       resolved_type_decl =
8087         build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
8088       /* Figure how those two things are important for error report. FIXME */
8089       DECL_SOURCE_LINE (resolved_type_decl) = 0;
8090       DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
8091       TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
8092     }
8093   TREE_TYPE (class_type) = resolved_type;
8094   return resolved_type_decl;
8095 }
8096
8097 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
8098    are used to report error messages.  */
8099
8100 tree
8101 do_resolve_class (enclosing, class_type, decl, cl)
8102      tree enclosing, class_type, decl, cl;
8103 {
8104   tree new_class_decl;
8105   tree original_name = NULL_TREE;
8106
8107   /* Do not try to replace TYPE_NAME (class_type) by a variable, since
8108      its is changed by find_in_imports{_on_demand} */
8109
8110   /* 0- Search in the current class as an inner class */
8111
8112   /* Maybe some code here should be added to load the class or
8113      something, at least if the class isn't an inner class and ended
8114      being loaded from class file. FIXME. */
8115   while (enclosing)
8116     {
8117       tree name;
8118
8119       if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl)))
8120         return new_class_decl;
8121
8122       /* Now go to the upper classes, bail out if necessary. */
8123       enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing));
8124       if (!enclosing || enclosing == object_type_node)
8125         break;
8126       
8127       if (TREE_CODE (enclosing) == RECORD_TYPE)
8128         {
8129           enclosing = TYPE_NAME (enclosing);
8130           continue;
8131         }
8132
8133       if (TREE_CODE (enclosing) == IDENTIFIER_NODE)
8134         {
8135           BUILD_PTR_FROM_NAME (name, enclosing);
8136         }
8137       else
8138         name = enclosing;
8139       enclosing = do_resolve_class (NULL, name, NULL, NULL);
8140     }
8141
8142   /* 1- Check for the type in single imports */
8143   if (find_in_imports (class_type))
8144     return NULL_TREE;
8145
8146   /* 2- And check for the type in the current compilation unit. If it fails,
8147      try with a name qualified with the package name we've seen so far */
8148   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8149     {
8150       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8151           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8152         load_class (TYPE_NAME (class_type), 0);
8153       return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8154     }
8155
8156   original_name = TYPE_NAME (class_type);
8157   if (!QUALIFIED_P (TYPE_NAME (class_type)))
8158     {
8159       tree package;
8160       for (package = package_list; package; package = TREE_CHAIN (package))
8161         {
8162           tree new_qualified;
8163           
8164           new_qualified = merge_qualified_name (TREE_PURPOSE (package),
8165                                                 original_name);
8166           TYPE_NAME (class_type) = new_qualified;
8167           new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8168           if (!new_class_decl)
8169             load_class (TYPE_NAME (class_type), 0);
8170           new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8171           if (new_class_decl)
8172             {
8173               if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8174                   !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8175                 load_class (TYPE_NAME (class_type), 0);
8176               return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8177             }
8178         }
8179     }
8180
8181   TYPE_NAME (class_type) = original_name;
8182
8183   /* 3- Check an other compilation unit that bears the name of type */
8184   load_class (TYPE_NAME (class_type), 0);
8185   if (check_pkg_class_access (TYPE_NAME (class_type), 
8186                               (cl ? cl : lookup_cl (decl))))
8187     return NULL_TREE;
8188
8189   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8190     return new_class_decl;
8191
8192   /* 4- Check the import on demands. Don't allow bar.baz to be
8193      imported from foo.* */
8194   if (!QUALIFIED_P (TYPE_NAME (class_type)))
8195     if (find_in_imports_on_demand (class_type))
8196       return NULL_TREE;
8197
8198   /* 5- Last call for a resolution */
8199   return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8200 }
8201
8202 /* Resolve NAME and lay it out (if not done and if not the current
8203    parsed class). Return a decl node. This function is meant to be
8204    called when type resolution is necessary during the walk pass.  */
8205
8206 static tree
8207 resolve_and_layout (something, cl)
8208      tree something;
8209      tree cl;
8210 {
8211   tree decl;
8212
8213   /* Don't do that on the current class */
8214   if (something == current_class)
8215     return TYPE_NAME (current_class);
8216
8217   /* Don't do anything for void and other primitive types */
8218   if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8219     return NULL_TREE;
8220
8221   /* Pointer types can be reall pointer types or fake pointers. When
8222      finding a real pointer, recheck for primitive types */
8223   if (TREE_CODE (something) == POINTER_TYPE)
8224     {
8225       if (TREE_TYPE (something))
8226         {
8227           something = TREE_TYPE (something);
8228           if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8229             return NULL_TREE;
8230         }
8231       else
8232         something = TYPE_NAME (something);
8233     }
8234
8235   /* Don't do anything for arrays of primitive types */
8236   if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
8237       && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
8238     return NULL_TREE;
8239
8240   /* Something might be a WFL */
8241   if (TREE_CODE (something) == EXPR_WITH_FILE_LOCATION)
8242     something = EXPR_WFL_NODE (something);
8243
8244   /* Otherwise, if something is not and IDENTIFIER_NODE, it can be a a
8245      TYPE_DECL or a real TYPE */
8246   else if (TREE_CODE (something) != IDENTIFIER_NODE)
8247     something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
8248             DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
8249
8250   if (!(decl = resolve_no_layout (something, cl)))
8251     return NULL_TREE;
8252
8253   /* Resolve and layout if necessary */
8254   layout_class_methods (TREE_TYPE (decl));
8255   /* Check methods, but only once */
8256   if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) 
8257       && !CLASS_LOADED_P (TREE_TYPE (decl)))
8258     CHECK_METHODS (decl);
8259   if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
8260     safe_layout_class (TREE_TYPE (decl));
8261
8262   return decl;
8263 }
8264
8265 /* Resolve a class, returns its decl but doesn't perform any
8266    layout. The current parsing context is saved and restored */
8267
8268 static tree
8269 resolve_no_layout (name, cl)
8270      tree name, cl;
8271 {
8272   tree ptr, decl;
8273   BUILD_PTR_FROM_NAME (ptr, name);
8274   java_parser_context_save_global ();
8275   decl = resolve_class (TYPE_NAME (current_class), ptr, NULL_TREE, cl);
8276   java_parser_context_restore_global ();
8277   
8278   return decl;
8279 }
8280
8281 /* Called when reporting errors. Skip leader '[' in a complex array
8282    type description that failed to be resolved.  */
8283
8284 static const char *
8285 purify_type_name (name)
8286      const char *name;
8287 {
8288   while (*name && *name == '[')
8289     name++;
8290   return name;
8291 }
8292
8293 /* The type CURRENT refers to can't be found. We print error messages.  */
8294
8295 static void
8296 complete_class_report_errors (dep)
8297      jdep *dep;
8298 {
8299   const char *name;
8300
8301   if (!JDEP_WFL (dep))
8302     return;
8303
8304   name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
8305   switch (JDEP_KIND (dep))
8306     {
8307     case JDEP_SUPER:
8308       parse_error_context  
8309         (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
8310          purify_type_name (name),
8311          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8312       break;
8313     case JDEP_FIELD:
8314       parse_error_context
8315         (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
8316          purify_type_name (name),
8317          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8318       break;
8319     case JDEP_METHOD:           /* Covers arguments */
8320       parse_error_context
8321         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
8322          purify_type_name (name),
8323          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
8324          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
8325       break;
8326     case JDEP_METHOD_RETURN:    /* Covers return type */
8327       parse_error_context
8328         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'", 
8329          purify_type_name (name),
8330          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
8331       break;
8332     case JDEP_INTERFACE:
8333       parse_error_context
8334         (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
8335          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
8336          (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
8337          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8338       break;
8339     case JDEP_VARIABLE:
8340       parse_error_context
8341         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'", 
8342          purify_type_name (IDENTIFIER_POINTER 
8343                            (EXPR_WFL_NODE (JDEP_WFL (dep)))),
8344          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8345       break;
8346     case JDEP_EXCEPTION:        /* As specified by `throws' */
8347       parse_error_context 
8348           (JDEP_WFL (dep), "Class `%s' not found in `throws'",
8349          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
8350       break;
8351     default:
8352       /* Fix for -Wall. Just break doing nothing. The error will be
8353          caught later */
8354       break;
8355     }
8356 }
8357
8358 /* Return a static string containing the DECL prototype string. If
8359    DECL is a constructor, use the class name instead of the form
8360    <init> */
8361
8362 static const char *
8363 get_printable_method_name (decl)
8364      tree decl;
8365 {
8366   const char *to_return;
8367   tree name = NULL_TREE;
8368
8369   if (DECL_CONSTRUCTOR_P (decl))
8370     {
8371       name = DECL_NAME (decl);
8372       DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
8373     }
8374       
8375   to_return = lang_printable_name (decl, 0);
8376   if (DECL_CONSTRUCTOR_P (decl))
8377     DECL_NAME (decl) = name;
8378   
8379   return to_return;
8380 }
8381
8382 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
8383    nevertheless needs to be verfied, 1 otherwise.  */
8384
8385 static int
8386 reset_method_name (method)
8387      tree method;
8388 {
8389   if (!DECL_CLINIT_P (method) && !DECL_FINIT_P (method))
8390     {
8391       /* NAME is just the plain name when Object is being defined */
8392       if (DECL_CONTEXT (method) != object_type_node)
8393         DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ? 
8394                               init_identifier_node : GET_METHOD_NAME (method));
8395       return 0;
8396     }
8397   else 
8398     return 1;
8399 }
8400
8401 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
8402
8403 tree
8404 java_get_real_method_name (method_decl)
8405      tree method_decl;
8406 {
8407   tree method_name = DECL_NAME (method_decl);
8408   if (DECL_CONSTRUCTOR_P (method_decl))
8409     return init_identifier_node;
8410
8411   /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
8412      and still can be a constructor. FIXME */
8413
8414   /* Don't confuse method only bearing the name of their class as
8415      constructors */
8416   else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
8417            && ctxp
8418            && GET_CPC_UN () == EXPR_WFL_NODE (method_name)
8419            && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
8420            && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
8421     return init_identifier_node;
8422   else
8423     return EXPR_WFL_NODE (method_name);
8424 }
8425
8426 /* Track method being redefined inside the same class. As a side
8427    effect, set DECL_NAME to an IDENTIFIER (prior entering this
8428    function it's a FWL, so we can track errors more accurately.)  */
8429
8430 static int
8431 check_method_redefinition (class, method)
8432      tree class, method;
8433 {
8434   tree redef, name;
8435   tree cl = DECL_NAME (method);
8436   tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
8437   /* decl name of artificial <clinit> and $finit$ doesn't need to be
8438      fixed and checked */
8439
8440   /* Reset the method name before running the check. If it returns 1,
8441      the method doesn't need to be verified with respect to method
8442      redeclaration and we return 0 */
8443   if (reset_method_name (method))
8444     return 0;
8445
8446   name = DECL_NAME (method);
8447   for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
8448     {
8449       if (redef == method)
8450         break;
8451       if (DECL_NAME (redef) == name 
8452           && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
8453         {
8454           parse_error_context 
8455             (cl, "Duplicate %s declaration `%s'",
8456              (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
8457              get_printable_method_name (redef));
8458           return 1;
8459         }
8460     }
8461   return 0;
8462 }
8463
8464 static void
8465 check_abstract_method_definitions (do_interface, class_decl, type)
8466      int do_interface;
8467      tree class_decl, type;
8468 {
8469   tree class = TREE_TYPE (class_decl);
8470   tree method, end_type;
8471
8472   end_type = (do_interface ? object_type_node : type);
8473   for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
8474     {
8475       tree other_super, other_method, method_sig, method_name;
8476       int found = 0;
8477       int end_type_reached = 0;
8478       
8479       if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
8480         continue;
8481       
8482       /* Now verify that somewhere in between TYPE and CLASS,
8483          abstract method METHOD gets a non abstract definition
8484          that is inherited by CLASS.  */
8485       
8486       method_sig = build_java_signature (TREE_TYPE (method));
8487       method_name = DECL_NAME (method);
8488       if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
8489         method_name = EXPR_WFL_NODE (method_name);
8490
8491       other_super = class;
8492       do {
8493         if (other_super == end_type)
8494           end_type_reached = 1;
8495         
8496         /* Method search */
8497         for (other_method = TYPE_METHODS (other_super); other_method;
8498             other_method = TREE_CHAIN (other_method))
8499           {
8500             tree s = build_java_signature (TREE_TYPE (other_method));
8501             tree other_name = DECL_NAME (other_method);
8502             
8503             if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
8504               other_name = EXPR_WFL_NODE (other_name);
8505             if (!DECL_CLINIT_P (other_method)
8506                 && !DECL_CONSTRUCTOR_P (other_method)
8507                 && method_name == other_name && method_sig == s)
8508              {
8509                found = 1;
8510                break;
8511              }
8512           }
8513         other_super = CLASSTYPE_SUPER (other_super);
8514       } while (!end_type_reached);
8515  
8516       /* Report that abstract METHOD didn't find an implementation
8517          that CLASS can use. */
8518       if (!found)
8519         {
8520           char *t = xstrdup (lang_printable_name 
8521                             (TREE_TYPE (TREE_TYPE (method)), 0));
8522           tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
8523           tree saved_wfl = NULL_TREE;
8524           
8525           if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION)
8526             {
8527               saved_wfl = DECL_NAME (method);
8528               DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
8529             }
8530           
8531           parse_error_context 
8532             (lookup_cl (class_decl),
8533              "Class `%s' doesn't define the abstract method `%s %s' from %s `%s'. This method must be defined or %s `%s' must be declared abstract",
8534              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8535              t, lang_printable_name (method, 0), 
8536              (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ? 
8537               "interface" : "class"),
8538              IDENTIFIER_POINTER (ccn),
8539              (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
8540              IDENTIFIER_POINTER (DECL_NAME (class_decl)));
8541           
8542           free (t);
8543           
8544           if (saved_wfl)
8545             DECL_NAME (method) = saved_wfl;
8546         }
8547     }
8548 }
8549
8550 /* Check that CLASS_DECL somehow implements all inherited abstract
8551    methods.  */
8552
8553 static void
8554 java_check_abstract_method_definitions (class_decl)
8555      tree class_decl;
8556 {
8557   tree class = TREE_TYPE (class_decl);
8558   tree super, vector;
8559   int i;
8560
8561   if (CLASS_ABSTRACT (class_decl))
8562     return;
8563
8564   /* Check for inherited types */
8565   super = class;
8566   do {
8567     super = CLASSTYPE_SUPER (super);
8568     check_abstract_method_definitions (0, class_decl, super);
8569   } while (super != object_type_node);
8570
8571   /* Check for implemented interfaces. */
8572   vector = TYPE_BINFO_BASETYPES (class);
8573   for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
8574     {
8575       super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
8576       check_abstract_method_definitions (1, class_decl, super);
8577     }
8578 }
8579
8580 /* Check all the types method DECL uses and return 1 if all of them
8581    are now complete, 0 otherwise. This is used to check whether its
8582    safe to build a method signature or not.  */
8583
8584 static int
8585 check_method_types_complete (decl)
8586      tree decl;
8587 {
8588   tree type = TREE_TYPE (decl);
8589   tree args;
8590
8591   if (!INCOMPLETE_TYPE_P (TREE_TYPE (type)))
8592     return 0;
8593   
8594   args = TYPE_ARG_TYPES (type);
8595   if (TREE_CODE (type) == METHOD_TYPE)
8596     args = TREE_CHAIN (args);
8597   for (; args != end_params_node; args = TREE_CHAIN (args))
8598     if (INCOMPLETE_TYPE_P (TREE_VALUE (args)))
8599       return 0;
8600
8601   return 1;
8602 }
8603
8604 /* Check all the methods of CLASS_DECL. Methods are first completed
8605    then checked according to regular method existance rules.  If no
8606    constructor for CLASS_DECL were encountered, then build its
8607    declaration.  */
8608
8609 static void
8610 java_check_regular_methods (class_decl)
8611      tree class_decl;
8612 {
8613   int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
8614   tree method;
8615   tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
8616   tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
8617   tree mthrows;
8618
8619   /* It is not necessary to check methods defined in java.lang.Object */
8620   if (class == object_type_node)
8621     return;
8622
8623   if (!TYPE_NVIRTUALS (class))
8624     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8625
8626   /* Should take interfaces into account. FIXME */
8627   for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
8628     {
8629       tree sig;
8630       tree method_wfl = DECL_NAME (method);
8631       int aflags;
8632
8633       /* If we previously found something and its name was saved,
8634          reinstall it now */
8635       if (found && saved_found_wfl)
8636         {
8637           DECL_NAME (found) = saved_found_wfl;
8638           saved_found_wfl = NULL_TREE;
8639         }
8640
8641       /* Check for redefinitions */
8642       if (check_method_redefinition (class, method))
8643         continue;
8644
8645       /* If we see one constructor a mark so we don't generate the
8646          default one. Also skip other verifications: constructors
8647          can't be inherited hence hiden or overriden */
8648      if (DECL_CONSTRUCTOR_P (method))
8649        {
8650          saw_constructor = 1;
8651          continue;
8652        }
8653
8654       /* We verify things thrown by the method. They must inherits from
8655          java.lang.Throwable */
8656       for (mthrows = DECL_FUNCTION_THROWS (method);
8657            mthrows; mthrows = TREE_CHAIN (mthrows))
8658         {
8659           if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
8660             parse_error_context 
8661               (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
8662                IDENTIFIER_POINTER 
8663                  (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
8664         }
8665
8666       sig = build_java_argument_signature (TREE_TYPE (method));
8667       found = lookup_argument_method2 (class, DECL_NAME (method), sig);
8668
8669       /* Inner class can't declare static methods */
8670       if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
8671         {
8672           char *t = xstrdup (lang_printable_name (class, 0));
8673           parse_error_context 
8674             (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
8675              lang_printable_name (method, 0), t);
8676           free (t);
8677         }
8678
8679       /* Nothing overrides or it's a private method. */
8680       if (!found)
8681         continue;
8682       if (METHOD_PRIVATE (found))
8683         {
8684           found = NULL_TREE;
8685           continue;
8686         }
8687
8688       /* If found wasn't verified, it's DECL_NAME won't be set properly. 
8689          We set it temporarily for the sake of the error report. */
8690       saved_found_wfl = DECL_NAME (found);
8691       reset_method_name (found);
8692
8693       /* If `found' is declared in an interface, make sure the
8694          modifier matches. */
8695       if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found))) 
8696           && clinit_identifier_node != DECL_NAME (found)
8697           && !METHOD_PUBLIC (method))
8698         {
8699           tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
8700           parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
8701                                IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8702                                lang_printable_name (method, 0),
8703                                IDENTIFIER_POINTER (DECL_NAME (found_decl)));
8704         }
8705
8706       /* Can't override a method with the same name and different return
8707          types. */
8708       if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
8709         {
8710           char *t = xstrdup 
8711             (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8712           parse_error_context 
8713             (method_wfl,
8714              "Method `%s' was defined with return type `%s' in class `%s'", 
8715              lang_printable_name (found, 0), t,
8716              IDENTIFIER_POINTER 
8717                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8718           free (t);
8719         }
8720
8721       aflags = get_access_flags_from_decl (found);
8722       /* If the method has default, access in an other package, then
8723          issue a warning that the current method doesn't override the
8724          one that was found elsewhere. Do not issue this warning when
8725          the match was found in java.lang.Object.  */
8726       if (DECL_CONTEXT (found) != object_type_node
8727           && ((aflags & ACC_VISIBILITY) == 0)
8728           && !class_in_current_package (DECL_CONTEXT (found))
8729           && !DECL_CLINIT_P (found)
8730           && flag_not_overriding)
8731         {
8732           parse_warning_context 
8733             (method_wfl, "Method `%s' in class `%s' does not override the corresponding method in class `%s', which is private to a different package",
8734              lang_printable_name (found, 0),
8735              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8736              IDENTIFIER_POINTER (DECL_NAME 
8737                                  (TYPE_NAME (DECL_CONTEXT (found)))));
8738           continue;
8739         }
8740
8741       /* Can't override final. Can't override static. */
8742       if (METHOD_FINAL (found) || METHOD_STATIC (found))
8743         {
8744           /* Static *can* override static */
8745           if (METHOD_STATIC (found) && METHOD_STATIC (method))
8746             continue;
8747           parse_error_context 
8748             (method_wfl,
8749              "%s methods can't be overriden. Method `%s' is %s in class `%s'",
8750              (METHOD_FINAL (found) ? "Final" : "Static"),
8751              lang_printable_name (found, 0),
8752              (METHOD_FINAL (found) ? "final" : "static"),
8753              IDENTIFIER_POINTER
8754                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8755           continue;
8756         }
8757
8758       /* Static method can't override instance method. */
8759       if (METHOD_STATIC (method))
8760         {
8761           parse_error_context 
8762             (method_wfl,
8763              "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'",
8764              lang_printable_name (found, 0),
8765              IDENTIFIER_POINTER
8766                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8767           continue;
8768         }
8769
8770       /* - Overriding/hiding public must be public
8771          - Overriding/hiding protected must be protected or public
8772          - If the overriden or hidden method has default (package)
8773            access, then the overriding or hiding method must not be
8774            private; otherwise, a compile-time error occurs.  If
8775            `found' belongs to an interface, things have been already
8776            taken care of.  */
8777       if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8778           && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
8779               || (METHOD_PROTECTED (found) 
8780                   && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
8781               || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
8782                   && METHOD_PRIVATE (method))))
8783         {
8784           parse_error_context 
8785             (method_wfl,
8786              "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
8787              (METHOD_PUBLIC (method) ? "public" : 
8788               (METHOD_PRIVATE (method) ? "private" : "protected")),
8789              IDENTIFIER_POINTER (DECL_NAME 
8790                                  (TYPE_NAME (DECL_CONTEXT (found)))));
8791           continue;
8792         }
8793
8794       /* Overriding methods must have compatible `throws' clauses on checked
8795          exceptions, if any */
8796       check_throws_clauses (method, method_wfl, found);
8797
8798       /* Inheriting multiple methods with the same signature. FIXME */
8799     }
8800   
8801   /* Don't forget eventual pending found and saved_found_wfl. Take
8802      into account that we might have exited because we saw an
8803      artificial method as the last entry. */
8804
8805   if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
8806     DECL_NAME (found) = saved_found_wfl;
8807
8808   if (!TYPE_NVIRTUALS (class))
8809     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8810
8811   /* Search for inherited abstract method not yet implemented in this
8812      class.  */
8813   java_check_abstract_method_definitions (class_decl);
8814
8815   if (!saw_constructor)
8816     fatal ("No constructor found");
8817 }
8818
8819 /* Return a non zero value if the `throws' clause of METHOD (if any)
8820    is incompatible with the `throws' clause of FOUND (if any).  */
8821
8822 static void
8823 check_throws_clauses (method, method_wfl, found)
8824      tree method, method_wfl, found;
8825 {
8826   tree mthrows, fthrows;
8827
8828   /* Can't check these things with class loaded from bytecode. FIXME */
8829   if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
8830     return;
8831
8832   for (mthrows = DECL_FUNCTION_THROWS (method);
8833        mthrows; mthrows = TREE_CHAIN (mthrows))
8834     {
8835       /* We don't verify unchecked expressions */
8836       if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
8837         continue;
8838       /* Checked expression must be compatible */
8839       for (fthrows = DECL_FUNCTION_THROWS (found); 
8840            fthrows; fthrows = TREE_CHAIN (fthrows))
8841         if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
8842           break;
8843       if (!fthrows)
8844         {
8845           parse_error_context 
8846             (method_wfl, "Invalid checked exception class `%s' in `throws' clause. The exception must be a subclass of an exception thrown by `%s' from class `%s'",
8847              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
8848              lang_printable_name (found, 0),
8849              IDENTIFIER_POINTER 
8850                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8851         }
8852     }
8853 }
8854
8855 /* Check abstract method of interface INTERFACE */
8856
8857 static void
8858 java_check_abstract_methods (interface_decl)
8859      tree interface_decl;
8860 {
8861   int i, n;
8862   tree method, basetype_vec, found;
8863   tree interface = TREE_TYPE (interface_decl);
8864
8865   for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
8866     {
8867       tree method_wfl = DECL_NAME (method);
8868
8869       /* 2- Check for double definition inside the defining interface */
8870       if (check_method_redefinition (interface, method))
8871         continue;
8872
8873       /* 3- Overriding is OK as far as we preserve the return type and
8874          the thrown exceptions (FIXME) */
8875       found = lookup_java_interface_method2 (interface, method);
8876       if (found)
8877         {
8878           char *t;
8879           tree saved_found_wfl = DECL_NAME (found);
8880           reset_method_name (found);
8881           t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8882           parse_error_context 
8883             (method_wfl,
8884              "Method `%s' was defined with return type `%s' in class `%s'",
8885              lang_printable_name (found, 0), t,
8886              IDENTIFIER_POINTER 
8887                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8888           free (t);
8889           DECL_NAME (found) = saved_found_wfl;
8890           continue;
8891         }
8892     }
8893
8894   /* 4- Inherited methods can't differ by their returned types */
8895   if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
8896     return;
8897   n = TREE_VEC_LENGTH (basetype_vec);
8898   for (i = 0; i < n; i++)
8899     {
8900       tree sub_interface_method, sub_interface;
8901       tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
8902       if (!vec_elt)
8903         continue;
8904       sub_interface = BINFO_TYPE (vec_elt);
8905       for (sub_interface_method = TYPE_METHODS (sub_interface); 
8906            sub_interface_method;
8907            sub_interface_method = TREE_CHAIN (sub_interface_method))
8908         {
8909           found = lookup_java_interface_method2 (interface, 
8910                                                  sub_interface_method);
8911           if (found && (found != sub_interface_method))
8912             {
8913               tree saved_found_wfl = DECL_NAME (found);
8914               reset_method_name (found);
8915               parse_error_context 
8916                 (lookup_cl (sub_interface_method),
8917                  "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
8918                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
8919                  lang_printable_name (found, 0),
8920                  IDENTIFIER_POINTER 
8921                    (DECL_NAME (TYPE_NAME 
8922                                (DECL_CONTEXT (sub_interface_method)))),
8923                  IDENTIFIER_POINTER 
8924                    (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8925               DECL_NAME (found) = saved_found_wfl;
8926             }
8927         }
8928     }
8929 }
8930
8931 /* Lookup methods in interfaces using their name and partial
8932    signature. Return a matching method only if their types differ.  */
8933
8934 static tree
8935 lookup_java_interface_method2 (class, method_decl)
8936      tree class, method_decl;
8937 {
8938   int i, n;
8939   tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
8940
8941   if (!basetype_vec)
8942     return NULL_TREE;
8943
8944   n = TREE_VEC_LENGTH (basetype_vec);
8945   for (i = 0; i < n; i++)
8946     {
8947       tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
8948       if ((BINFO_TYPE (vec_elt) != object_type_node)
8949           && (to_return = 
8950               lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
8951         return to_return;
8952     }
8953   for (i = 0; i < n; i++)
8954     {
8955       to_return = lookup_java_interface_method2 
8956         (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
8957       if (to_return)
8958         return to_return;
8959     }
8960
8961   return NULL_TREE;
8962 }
8963
8964 /* Lookup method using their name and partial signature. Return a
8965    matching method only if their types differ.  */
8966
8967 static tree
8968 lookup_java_method2 (clas, method_decl, do_interface)
8969      tree clas, method_decl;
8970      int do_interface;
8971 {
8972   tree method, method_signature, method_name, method_type, name;
8973
8974   method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
8975   name = DECL_NAME (method_decl);
8976   method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ? 
8977                  EXPR_WFL_NODE (name) : name);
8978   method_type = TREE_TYPE (TREE_TYPE (method_decl));
8979
8980   while (clas != NULL_TREE)
8981     {
8982       for (method = TYPE_METHODS (clas);
8983            method != NULL_TREE;  method = TREE_CHAIN (method))
8984         {
8985           tree method_sig = build_java_argument_signature (TREE_TYPE (method));
8986           tree name = DECL_NAME (method);
8987           if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
8988                EXPR_WFL_NODE (name) : name) == method_name
8989               && method_sig == method_signature 
8990               && TREE_TYPE (TREE_TYPE (method)) != method_type)
8991             return method;
8992         }
8993       clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
8994     }
8995   return NULL_TREE;
8996 }
8997
8998 /* Return the line that matches DECL line number, and try its best to
8999    position the column number. Used during error reports.  */
9000
9001 static tree
9002 lookup_cl (decl)
9003      tree decl;
9004 {
9005   static tree cl = NULL_TREE;
9006   char *line, *found;
9007   
9008   if (!decl)
9009     return NULL_TREE;
9010
9011   if (cl == NULL_TREE)
9012     cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
9013
9014   EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
9015   EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
9016
9017   line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
9018                             EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
9019
9020   found = strstr ((const char *)line, 
9021                   (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
9022   if (found)
9023     EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line);
9024
9025   return cl;
9026 }
9027
9028 /* Look for a simple name in the single-type import list */
9029
9030 static tree
9031 find_name_in_single_imports (name)
9032      tree name;
9033 {
9034   tree node;
9035
9036   for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
9037     if (TREE_VALUE (node) == name)
9038       return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
9039
9040   return NULL_TREE;
9041 }
9042
9043 /* Process all single-type import. */
9044
9045 static int
9046 process_imports ()
9047 {
9048   tree import;
9049   int error_found;
9050
9051   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9052     {
9053       tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
9054
9055       /* Don't load twice something already defined. */
9056       if (IDENTIFIER_CLASS_VALUE (to_be_found))
9057         continue;
9058       QUALIFIED_P (to_be_found) = 1;
9059       load_class (to_be_found, 0);
9060       error_found =
9061         check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
9062       if (!IDENTIFIER_CLASS_VALUE (to_be_found))
9063         {
9064           parse_error_context (TREE_PURPOSE (import),
9065                                "Class or interface `%s' not found in import",
9066                                IDENTIFIER_POINTER (to_be_found));
9067           return 1;
9068         }
9069       if (error_found)
9070         return 1;
9071     }
9072   return 0;
9073 }
9074
9075 /* Possibly find a class imported by a single-type import statement. Return
9076    1 if an error occured, 0 otherwise. */
9077
9078 static int
9079 find_in_imports (class_type)
9080      tree class_type;
9081 {
9082   tree import;
9083
9084   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9085     if (TREE_VALUE (import) == TYPE_NAME (class_type))
9086       {
9087         TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
9088         QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9089       }
9090   return 0;
9091 }
9092
9093 static int
9094 note_possible_classname (name, len)
9095      const char *name;
9096      int len;
9097 {
9098   tree node;
9099   if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
9100     len = len - 5;
9101   else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
9102     len = len - 6;
9103   else
9104     return 0;
9105   node = ident_subst (name, len, "", '/', '.', "");
9106   IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
9107   QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
9108   return 1;
9109 }
9110
9111 /* Read a import directory, gathering potential match for further type
9112    references. Indifferently reads a filesystem or a ZIP archive
9113    directory.  */
9114
9115 static void
9116 read_import_dir (wfl)
9117      tree wfl;
9118 {
9119   tree package_id = EXPR_WFL_NODE (wfl);
9120   const char *package_name = IDENTIFIER_POINTER (package_id);
9121   int package_length = IDENTIFIER_LENGTH (package_id);
9122   DIR *dirp = NULL;
9123   JCF *saved_jcf = current_jcf;
9124
9125   int found = 0;
9126   int k;
9127   void *entry;
9128   struct buffer filename[1];
9129
9130
9131   if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
9132     return;
9133   IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
9134
9135   BUFFER_INIT (filename);
9136   buffer_grow (filename, package_length + 100);
9137
9138   for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
9139     {
9140       const char *entry_name = jcf_path_name (entry);
9141       int entry_length = strlen (entry_name);
9142       if (jcf_path_is_zipfile (entry))
9143         {
9144           ZipFile *zipf;
9145           buffer_grow (filename, entry_length);
9146           memcpy (filename->data, entry_name, entry_length - 1);
9147           filename->data[entry_length-1] = '\0';
9148           zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
9149           if (zipf == NULL)
9150             error ("malformed .zip archive in CLASSPATH: %s", entry_name);
9151           else
9152             {
9153               ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
9154               BUFFER_RESET (filename);
9155               for (k = 0; k < package_length; k++)
9156                 {
9157                   char ch = package_name[k];
9158                   *filename->ptr++ = ch == '.' ? '/' : ch;
9159                 }
9160               *filename->ptr++ = '/';
9161
9162               for (k = 0; k < zipf->count;  k++, zipd = ZIPDIR_NEXT (zipd))
9163                 {
9164                   const char *current_entry = ZIPDIR_FILENAME (zipd);
9165                   int current_entry_len = zipd->filename_length;
9166
9167                   if (current_entry_len >= BUFFER_LENGTH (filename)
9168                       && strncmp (filename->data, current_entry, 
9169                                   BUFFER_LENGTH (filename)) != 0)
9170                     continue;
9171                   found |= note_possible_classname (current_entry,
9172                                                     current_entry_len);
9173                 }
9174             }
9175         }
9176       else
9177         {
9178           BUFFER_RESET (filename);
9179           buffer_grow (filename, entry_length + package_length + 4);
9180           strcpy (filename->data, entry_name);
9181           filename->ptr = filename->data + entry_length;
9182           for (k = 0; k < package_length; k++)
9183             {
9184               char ch = package_name[k];
9185               *filename->ptr++ = ch == '.' ? '/' : ch;
9186             }
9187           *filename->ptr = '\0';
9188
9189           dirp = opendir (filename->data);
9190           if (dirp == NULL)
9191             continue;
9192           *filename->ptr++ = '/';
9193           for (;;)
9194             {
9195               int len; 
9196               const char *d_name;
9197               struct dirent *direntp = readdir (dirp);
9198               if (!direntp)
9199                 break;
9200               d_name = direntp->d_name;
9201               len = strlen (direntp->d_name);
9202               buffer_grow (filename, len+1);
9203               strcpy (filename->ptr, d_name);
9204               found |= note_possible_classname (filename->data + entry_length,
9205                                                 package_length+len+1);
9206             }
9207           if (dirp)
9208             closedir (dirp);
9209         }
9210     }
9211
9212   free (filename->data);
9213
9214   /* Here we should have a unified way of retrieving an entry, to be
9215      indexed. */
9216   if (!found)
9217     {
9218       static int first = 1;
9219       if (first)
9220         {
9221           error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives.", package_name);
9222           java_error_count++;
9223           first = 0;
9224         }
9225       else
9226         parse_error_context (wfl, "Package `%s' not found in import",
9227                              package_name);
9228       current_jcf = saved_jcf;
9229       return;
9230     }
9231   current_jcf = saved_jcf;
9232 }
9233
9234 /* Possibly find a type in the import on demands specified
9235    types. Returns 1 if an error occured, 0 otherwise. Run throught the
9236    entire list, to detected potential double definitions.  */
9237                  
9238 static int
9239 find_in_imports_on_demand (class_type)
9240      tree class_type;
9241 {
9242   tree node, import, node_to_use = NULL_TREE;
9243   int seen_once = -1;
9244   tree cl = NULL_TREE;
9245
9246   for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
9247     {
9248       const char *id_name;
9249       obstack_grow (&temporary_obstack, 
9250                     IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
9251                     IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9252       obstack_1grow (&temporary_obstack, '.');
9253       obstack_grow0 (&temporary_obstack, 
9254                      IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9255                      IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
9256       id_name = obstack_finish (&temporary_obstack);
9257               
9258       node = maybe_get_identifier (id_name);
9259       if (node && IS_A_CLASSFILE_NAME (node))
9260         {
9261           if (seen_once < 0)
9262             {
9263               cl = TREE_PURPOSE (import);
9264               seen_once = 1;
9265               node_to_use = node;
9266             }
9267           else
9268             {
9269               seen_once++;
9270               parse_error_context 
9271                 (import, "Type `%s' also potentially defined in package `%s'",
9272                  IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9273                  IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9274             }
9275         }
9276     }
9277
9278   if (seen_once == 1)
9279     {
9280       /* Setup lineno so that it refers to the line of the import (in
9281          case we parse a class file and encounter errors */
9282       tree decl;
9283       int saved_lineno = lineno;
9284       lineno = EXPR_WFL_LINENO (cl);
9285       TYPE_NAME (class_type) = node_to_use;
9286       QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9287       decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
9288       /* If there is no DECL set for the class or if the class isn't
9289          loaded and not seen in source yet, the load */
9290       if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
9291                     && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
9292         load_class (node_to_use, 0);
9293       lineno = saved_lineno;
9294       return check_pkg_class_access (TYPE_NAME (class_type), cl);
9295     }
9296   else
9297     return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
9298 }
9299
9300 static tree
9301 resolve_package (pkg, next)
9302      tree pkg, *next;
9303 {
9304   tree current, acc;
9305   tree type_name = NULL_TREE;
9306   const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
9307
9308   /* The trick is to determine when the package name stops and were
9309      the name of something contained in the package starts. Then we
9310      return a fully qualified name of what we want to get. */
9311
9312   /* Do a quick search on well known package names */
9313   if (!strncmp (name, "java.lang.reflect", 17))
9314     {
9315       *next = 
9316         TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
9317       type_name = lookup_package_type (name, 17);
9318     }
9319   else if (!strncmp (name, "java.lang", 9))
9320     {
9321       *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
9322       type_name = lookup_package_type (name, 9);
9323     }
9324
9325   /* If we found something here, return */
9326   if (type_name)
9327     return type_name; 
9328
9329   *next = EXPR_WFL_QUALIFICATION (pkg);
9330
9331   /* Try the current package. */
9332   if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),  
9333                                  IDENTIFIER_LENGTH (ctxp->package)))
9334     {
9335       type_name = 
9336         lookup_package_type_and_set_next (name, 
9337                                           IDENTIFIER_LENGTH (ctxp->package), 
9338                                           next );
9339       if (type_name)
9340         return type_name;
9341     }
9342
9343   /* Search in imported package */
9344   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
9345     {
9346       tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
9347       int len = IDENTIFIER_LENGTH (current_pkg_name);
9348       if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
9349         {
9350           tree left, dummy;
9351           
9352           breakdown_qualified (&left, &dummy, current_pkg_name);
9353           len = IDENTIFIER_LENGTH (left);
9354           type_name = lookup_package_type_and_set_next (name, len, next);
9355           if (type_name)
9356             break;
9357         }
9358     }
9359
9360   /* Try to progressively construct a type name */
9361   if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
9362     for (acc = NULL_TREE, current = EXPR_WFL_QUALIFICATION (pkg); 
9363          current; current = TREE_CHAIN (current))
9364       {
9365         acc = merge_qualified_name (acc, EXPR_WFL_NODE (QUAL_WFL (current)));
9366         if ((type_name = resolve_no_layout (acc, NULL_TREE)))
9367           {
9368             type_name = acc;
9369             *next = TREE_CHAIN (current);
9370             break;
9371           }
9372       }
9373   return type_name;
9374 }
9375
9376 static tree
9377 lookup_package_type_and_set_next (name, len, next)
9378      const char *name;
9379      int len;
9380      tree *next;
9381 {
9382   const char *ptr;
9383   tree type_name = lookup_package_type (name, len);
9384
9385   if (!type_name)
9386     return NULL;
9387   
9388   ptr = IDENTIFIER_POINTER (type_name);
9389   while (ptr && (ptr = strchr (ptr, '.'))) 
9390     {
9391       *next = TREE_CHAIN (*next);
9392       ptr++;
9393     }
9394   return type_name;
9395 }
9396
9397 static tree
9398 lookup_package_type (name, from)
9399      const char *name;
9400      int from;
9401 {
9402   char subname [128];
9403   const char *sub = &name[from+1];
9404   while (*sub != '.' && *sub)
9405     sub++;
9406   strncpy (subname, name, sub-name);
9407   subname [sub-name] = '\0';
9408   return get_identifier (subname);
9409 }
9410
9411 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
9412    access violations were found, 1 otherwise.  */
9413
9414 static int
9415 check_pkg_class_access (class_name, cl)
9416      tree class_name;
9417      tree cl;
9418 {
9419   tree type;
9420
9421   if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
9422     return 0;
9423
9424   if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
9425     return 0;
9426
9427   if (!CLASS_PUBLIC (TYPE_NAME (type)))
9428     {
9429       /* Access to a private class within the same package is
9430          allowed. */
9431       tree l, r;
9432       breakdown_qualified (&l, &r, class_name);
9433       if (l == ctxp->package)
9434         return 0;
9435
9436       parse_error_context 
9437         (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
9438          (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
9439          IDENTIFIER_POINTER (class_name));
9440       return 1;
9441     }
9442   return 0;
9443 }
9444
9445 /* Local variable declaration. */
9446
9447 static void
9448 declare_local_variables (modifier, type, vlist)
9449      int modifier;
9450      tree type;
9451      tree vlist;
9452 {
9453   tree decl, current, saved_type;
9454   tree type_wfl = NULL_TREE;
9455   int must_chain = 0;
9456   int final_p = 0;
9457
9458   /* Push a new block if statements were seen between the last time we
9459      pushed a block and now. Keep a cound of block to close */
9460   if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
9461     {
9462       tree body = GET_CURRENT_BLOCK (current_function_decl);
9463       tree b = enter_block ();
9464       BLOCK_EXPR_ORIGIN (b) = body;
9465     }
9466
9467   if (modifier)
9468     {
9469       int i;
9470       for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
9471       if (modifier == ACC_FINAL)
9472         final_p = 1;
9473       else 
9474         {
9475           parse_error_context 
9476             (ctxp->modifier_ctx [i], 
9477              "Only `final' is allowed as a local variables modifier");
9478           return;
9479         }
9480     }
9481
9482   /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
9483      hold the TYPE value if a new incomplete has to be created (as
9484      opposed to being found already existing and reused). */
9485   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
9486
9487   /* If TYPE is fully resolved and we don't have a reference, make one */
9488   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9489
9490   /* Go through all the declared variables */
9491   for (current = vlist, saved_type = type; current;
9492        current = TREE_CHAIN (current), type = saved_type)
9493     {
9494       tree other, real_type;
9495       tree wfl  = TREE_PURPOSE (current);
9496       tree name = EXPR_WFL_NODE (wfl);
9497       tree init = TREE_VALUE (current);
9498
9499       /* Process NAME, as it may specify extra dimension(s) for it */
9500       type = build_array_from_name (type, type_wfl, name, &name);
9501
9502       /* Variable redefinition check */
9503       if ((other = lookup_name_in_blocks (name)))
9504         {
9505           variable_redefinition_error (wfl, name, TREE_TYPE (other),
9506                                        DECL_SOURCE_LINE (other));
9507           continue;
9508         }
9509
9510       /* Type adjustment. We may have just readjusted TYPE because
9511          the variable specified more dimensions. Make sure we have
9512          a reference if we can and don't have one already. */
9513       PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9514
9515       real_type = GET_REAL_TYPE (type);
9516       /* Never layout this decl. This will be done when its scope
9517          will be entered */
9518       decl = build_decl (VAR_DECL, name, real_type);
9519       LOCAL_FINAL (decl) = final_p;
9520       BLOCK_CHAIN_DECL (decl);
9521       
9522       /* If doing xreferencing, replace the line number with the WFL
9523          compound value */
9524       if (flag_emit_xref)
9525         DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
9526       
9527       /* Don't try to use an INIT statement when an error was found */
9528       if (init && java_error_count)
9529         init = NULL_TREE;
9530       
9531       /* Add the initialization function to the current function's code */
9532       if (init)
9533         {
9534           /* Name might have been readjusted */
9535           EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
9536           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
9537           java_method_add_stmt (current_function_decl,
9538                                 build_debugable_stmt (EXPR_WFL_LINECOL (init),
9539                                                       init));
9540         }
9541     
9542       /* Setup dependency the type of the decl */
9543       if (must_chain)
9544         {
9545           jdep *dep;
9546           register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
9547           dep = CLASSD_LAST (ctxp->classd_list);
9548           JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
9549         }
9550     }
9551   SOURCE_FRONTEND_DEBUG (("Defined locals"));
9552 }
9553
9554 /* Called during parsing. Build decls from argument list.  */
9555
9556 static void
9557 source_start_java_method (fndecl)
9558      tree fndecl;
9559 {
9560   tree tem;
9561   tree parm_decl;
9562   int i;
9563
9564   if (!fndecl)
9565     return;
9566
9567   current_function_decl = fndecl;
9568
9569   /* New scope for the function */
9570   enter_block ();
9571   for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
9572        tem != end_params_node; tem = TREE_CHAIN (tem), i++)
9573     {
9574       tree type = TREE_VALUE (tem);
9575       tree name = TREE_PURPOSE (tem);
9576       
9577       /* If type is incomplete. Create an incomplete decl and ask for
9578          the decl to be patched later */
9579       if (INCOMPLETE_TYPE_P (type))
9580         {
9581           jdep *jdep;
9582           tree real_type = GET_REAL_TYPE (type);
9583           parm_decl = build_decl (PARM_DECL, name, real_type);
9584           type = obtain_incomplete_type (type);
9585           register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
9586           jdep = CLASSD_LAST (ctxp->classd_list);
9587           JDEP_MISC (jdep) = name;
9588           JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
9589         }
9590       else
9591         parm_decl = build_decl (PARM_DECL, name, type);
9592
9593       /* Remember if a local variable was declared final (via its
9594          TREE_LIST of type/name.) Set LOCAL_FINAL accordingly. */
9595       if (ARG_FINAL_P (tem))
9596         LOCAL_FINAL (parm_decl) = 1;
9597
9598       BLOCK_CHAIN_DECL (parm_decl);
9599     }
9600   tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9601   BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
9602     nreverse (tem);
9603   DECL_ARG_SLOT_COUNT (current_function_decl) = i;
9604   DECL_MAX_LOCALS (current_function_decl) = i;
9605 }
9606
9607 /* Called during parsing. Creates an artificial method declaration.  */
9608
9609 static tree
9610 create_artificial_method (class, flags, type, name, args)
9611      tree class;
9612      int flags;
9613      tree type, name, args;
9614 {
9615   tree mdecl;
9616
9617   java_parser_context_save_global ();
9618   lineno = 0;                                                               
9619   mdecl = make_node (FUNCTION_TYPE);                                
9620   TREE_TYPE (mdecl) = type;
9621   TYPE_ARG_TYPES (mdecl) = args;
9622   mdecl = add_method (class, flags, name, build_java_signature (mdecl)); 
9623   java_parser_context_restore_global ();
9624   DECL_ARTIFICIAL (mdecl) = 1;                                      
9625   return mdecl;
9626 }
9627
9628 /* Starts the body if an artifical method.  */
9629
9630 static void
9631 start_artificial_method_body (mdecl)
9632      tree mdecl;
9633 {
9634   DECL_SOURCE_LINE (mdecl) = 1;
9635   DECL_SOURCE_LINE_MERGE (mdecl, 1);
9636   source_start_java_method (mdecl);
9637   enter_block ();
9638 }
9639
9640 static void
9641 end_artificial_method_body (mdecl)
9642      tree mdecl;
9643 {
9644   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
9645   exit_block ();
9646 }
9647
9648 /* Called during expansion. Push decls formerly built from argument
9649    list so they're usable during expansion. */
9650
9651 static void
9652 expand_start_java_method (fndecl)
9653      tree fndecl;
9654 {
9655   tree tem, *ptr;
9656
9657   current_function_decl = fndecl;
9658
9659   if (! quiet_flag)
9660     fprintf (stderr, " [%s.", lang_printable_name (DECL_CONTEXT (fndecl), 0));
9661   announce_function (fndecl);
9662   if (! quiet_flag)
9663     fprintf (stderr, "]");
9664
9665   pushlevel (1);                /* Prepare for a parameter push */
9666   ptr = &DECL_ARGUMENTS (fndecl);
9667   tem  = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9668   while (tem)
9669     {
9670       tree next = TREE_CHAIN (tem);
9671       tree type = TREE_TYPE (tem);
9672       if (PROMOTE_PROTOTYPES
9673           && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
9674           && INTEGRAL_TYPE_P (type))
9675         type = integer_type_node;
9676       DECL_ARG_TYPE (tem) = type;
9677       layout_decl (tem, 0);
9678       pushdecl (tem);
9679       *ptr = tem;
9680       ptr = &TREE_CHAIN (tem);
9681       tem = next;
9682     }
9683   *ptr = NULL_TREE;
9684   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9685   lineno = DECL_SOURCE_LINE_FIRST (fndecl);
9686 }
9687
9688 /* Terminate a function and expand its body.  */
9689
9690 static void
9691 source_end_java_method ()
9692 {
9693   tree fndecl = current_function_decl;
9694   int flag_asynchronous_exceptions = asynchronous_exceptions;
9695
9696   if (!fndecl)
9697     return;
9698
9699   java_parser_context_save_global ();
9700   lineno = ctxp->last_ccb_indent1;
9701
9702   /* Set EH language codes */
9703   java_set_exception_lang_code ();
9704
9705   /* Turn function bodies with only a NOP expr null, so they don't get
9706      generated at all and we won't get warnings when using the -W
9707      -Wall flags. */
9708   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
9709     BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
9710
9711   /* Generate function's code */
9712   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
9713       && ! flag_emit_class_files
9714       && ! flag_emit_xref)
9715     expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
9716
9717   /* pop out of its parameters */
9718   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9719   poplevel (1, 0, 1);
9720   BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
9721
9722   /* Generate rtl for function exit.  */
9723   if (! flag_emit_class_files && ! flag_emit_xref)
9724     {
9725       lineno = DECL_SOURCE_LINE_LAST (fndecl);
9726       /* Emit catch-finally clauses */
9727       emit_handlers ();
9728       expand_function_end (input_filename, lineno, 0);
9729
9730       /* FIXME: If the current method contains any exception handlers,
9731          force asynchronous_exceptions: this is necessary because signal
9732          handlers in libjava may throw exceptions.  This is far from being
9733          a perfect solution, but it's better than doing nothing at all.*/
9734       if (catch_clauses)
9735         asynchronous_exceptions = 1;
9736
9737       /* Run the optimizers and output assembler code for this function. */
9738       rest_of_compilation (fndecl);
9739     }
9740
9741   current_function_decl = NULL_TREE;
9742   permanent_allocation (1);
9743   java_parser_context_restore_global ();
9744   asynchronous_exceptions = flag_asynchronous_exceptions;
9745 }
9746
9747 /* Record EXPR in the current function block. Complements compound
9748    expression second operand if necessary.  */
9749
9750 tree
9751 java_method_add_stmt (fndecl, expr)
9752      tree fndecl, expr;
9753 {
9754   if (!GET_CURRENT_BLOCK (fndecl))
9755     return NULL_TREE;
9756   return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
9757 }
9758
9759 static tree
9760 add_stmt_to_block (b, type, stmt)
9761      tree b, type, stmt;
9762 {
9763   tree body = BLOCK_EXPR_BODY (b), c;
9764   
9765   if (java_error_count)
9766     return body;
9767     
9768   if ((c = add_stmt_to_compound (body, type, stmt)) == body)
9769     return body;
9770
9771   BLOCK_EXPR_BODY (b) = c;
9772   TREE_SIDE_EFFECTS (c) = 1;
9773   return c;
9774 }
9775
9776 /* Add STMT to EXISTING if possible, otherwise create a new
9777    COMPOUND_EXPR and add STMT to it. */
9778
9779 static tree
9780 add_stmt_to_compound (existing, type, stmt)
9781      tree existing, type, stmt;
9782 {
9783   if (existing)
9784     return build (COMPOUND_EXPR, type, existing, stmt);
9785   else
9786     return stmt;
9787 }
9788
9789 /* Hold THIS for the scope of the current public method decl.  */
9790 static tree current_this;
9791
9792 void java_layout_seen_class_methods ()
9793 {
9794   tree previous_list = all_class_list;
9795   tree end = NULL_TREE;
9796   tree current;
9797
9798   while (1)
9799     {
9800       for (current = previous_list; 
9801            current != end; current = TREE_CHAIN (current))
9802         layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
9803       
9804       if (previous_list != all_class_list)
9805         {
9806           end = previous_list;
9807           previous_list = all_class_list;
9808         }
9809       else
9810         break;
9811     }
9812 }
9813
9814 void
9815 java_reorder_fields ()
9816 {
9817   static tree stop_reordering = NULL_TREE;
9818
9819   tree current;
9820   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9821     {
9822       current_class = TREE_TYPE (TREE_VALUE (current));
9823
9824       if (current_class == stop_reordering)
9825         break;
9826
9827       /* Reverse the fields, but leave the dummy field in front.
9828          Fields are already ordered for Object and Class */
9829       if (TYPE_FIELDS (current_class) && current_class != object_type_node
9830           && current_class != class_type_node)
9831       {
9832         /* If the dummy field is there, reverse the right fields and
9833            just layout the type for proper fields offset */
9834         if (!DECL_NAME (TYPE_FIELDS (current_class)))
9835           {
9836             tree fields = TYPE_FIELDS (current_class);
9837             TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
9838             TYPE_SIZE (current_class) = NULL_TREE;
9839           }
9840         /* We don't have a dummy field, we need to layout the class,
9841            after having reversed the fields */
9842         else
9843           {
9844             TYPE_FIELDS (current_class) = 
9845               nreverse (TYPE_FIELDS (current_class));
9846             TYPE_SIZE (current_class) = NULL_TREE;
9847           }
9848       }
9849     }
9850   stop_reordering = TREE_TYPE (TREE_VALUE (ctxp->gclass_list));
9851 }
9852
9853 /* Layout the methods of all classes loaded in one way on an
9854    other. Check methods of source parsed classes. Then reorder the
9855    fields and layout the classes or the type of all source parsed
9856    classes */
9857
9858 void
9859 java_layout_classes ()
9860 {
9861   tree current;
9862   int save_error_count = java_error_count;
9863
9864   /* Layout the methods of all classes seen so far */
9865   java_layout_seen_class_methods ();
9866   java_parse_abort_on_error ();
9867   all_class_list = NULL_TREE;
9868
9869   /* Then check the methods of all parsed classes */
9870   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9871     if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
9872       CHECK_METHODS (TREE_VALUE (current));
9873   java_parse_abort_on_error ();
9874
9875   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9876     {
9877       current_class = TREE_TYPE (TREE_VALUE (current));
9878       layout_class (current_class);
9879
9880       /* From now on, the class is considered completely loaded */
9881       CLASS_LOADED_P (current_class) = 1;
9882
9883       /* Error reported by the caller */
9884       if (java_error_count)
9885         return;
9886     }
9887
9888   /* We might have reloaded classes durign the process of laying out
9889      classes for code generation. We must layout the methods of those
9890      late additions, as constructor checks might use them */
9891   java_layout_seen_class_methods ();
9892   java_parse_abort_on_error ();
9893 }
9894
9895 /* Expand methods in the current set of classes rememebered for
9896    generation.  */
9897
9898 static void
9899 java_complete_expand_classes ()
9900 {
9901   tree current;
9902
9903   do_not_fold = flag_emit_xref;
9904
9905   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
9906     if (!INNER_CLASS_DECL_P (current))
9907       java_complete_expand_class (current);
9908 }
9909
9910 /* Expand the methods found in OUTER, starting first by OUTER's inner
9911    classes, if any.  */
9912
9913 static void
9914 java_complete_expand_class (outer)
9915      tree outer;
9916 {
9917   tree inner_list;
9918
9919   set_nested_class_simple_name_value (outer, 1); /* Set */
9920
9921   /* We need to go after all inner classes and start expanding them,
9922      starting with most nested ones. We have to do that because nested
9923      classes might add functions to outer classes */
9924
9925   for (inner_list = DECL_INNER_CLASS_LIST (outer);
9926        inner_list; inner_list = TREE_CHAIN (inner_list))
9927     java_complete_expand_class (TREE_PURPOSE (inner_list));
9928
9929   java_complete_expand_methods (outer);
9930   set_nested_class_simple_name_value (outer, 0); /* Reset */
9931 }
9932
9933 /* Expand methods registered in CLASS_DECL. The general idea is that
9934    we expand regular methods first. This allows us get an estimate on
9935    how outer context local alias fields are really used so we can add
9936    to the constructor just enough code to initialize them properly (it
9937    also lets us generate $finit$ correctly.) Then we expand the
9938    constructors and then <clinit>.  */
9939
9940 static void
9941 java_complete_expand_methods (class_decl)
9942      tree class_decl;
9943 {
9944   tree clinit, finit, decl, first_decl;
9945
9946   current_class = TREE_TYPE (class_decl);
9947
9948   /* Initialize a new constant pool */
9949   init_outgoing_cpool ();
9950
9951   /* Pre-expand <clinit> to figure whether we really need it or
9952      not. If we do need it, we pre-expand the static fields so they're
9953      ready to be used somewhere else. <clinit> will be fully expanded
9954      after we processed the constructors. */
9955   first_decl = TYPE_METHODS (current_class);
9956   clinit = maybe_generate_pre_expand_clinit (current_class);
9957
9958   /* Then generate $finit$ (if we need to) because constructor will
9959    try to use it.*/
9960   if (TYPE_FINIT_STMT_LIST (current_class))
9961     {
9962       finit = generate_finit (current_class);
9963       java_complete_expand_method (finit);
9964     }
9965
9966   /* Now do the constructors */
9967   for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
9968     {
9969       int no_body;
9970
9971       if (!DECL_CONSTRUCTOR_P (decl))
9972         continue;
9973       
9974       no_body = !DECL_FUNCTION_BODY (decl);
9975       /* Don't generate debug info on line zero when expanding a
9976          generated constructor. */
9977       if (no_body)
9978         restore_line_number_status (1);
9979
9980       java_complete_expand_method (decl);
9981       
9982       if (no_body)
9983         restore_line_number_status (0);
9984     }
9985
9986   /* First, do the ordinary methods. */
9987   for (decl = first_decl; decl; decl = TREE_CHAIN (decl))
9988     {
9989       /* Skip abstract or native methods */
9990       if (METHOD_ABSTRACT (decl) || METHOD_NATIVE (decl) 
9991           || DECL_CONSTRUCTOR_P (decl) || DECL_CLINIT_P (decl))
9992         continue;
9993       java_complete_expand_method (decl);
9994     }
9995
9996   /* If there is indeed a <clinit>, fully expand it now */
9997   if (clinit)
9998     {
9999       /* Prevent the use of `this' inside <clinit> */
10000       ctxp->explicit_constructor_p = 1;
10001       java_complete_expand_method (clinit);
10002       ctxp->explicit_constructor_p = 0;
10003     }
10004   
10005   /* We might have generated a class$ that we now want to expand */
10006   if (TYPE_DOT_CLASS (current_class))
10007     java_complete_expand_method (TYPE_DOT_CLASS (current_class));
10008
10009   /* Now verify constructor circularity (stop after the first one we
10010      prove wrong.) */
10011   if (!CLASS_INTERFACE (class_decl))
10012     for (decl = TYPE_METHODS (current_class); decl; decl = TREE_CHAIN (decl))
10013       if (DECL_CONSTRUCTOR_P (decl) 
10014           && verify_constructor_circularity (decl, decl))
10015         break;
10016
10017   /* Save the constant pool. We'll need to restore it later. */
10018   TYPE_CPOOL (current_class) = outgoing_cpool;
10019 }
10020
10021 /* Hold a list of catch clauses list. The first element of this list is
10022    the list of the catch clauses of the currently analysed try block. */
10023 static tree currently_caught_type_list;
10024
10025 /* Attempt to create <clinit>. Pre-expand static fields so they can be
10026    safely used in some other methods/constructors.  */
10027
10028 static tree
10029 maybe_generate_pre_expand_clinit (class_type)
10030      tree class_type;
10031 {
10032   tree current, mdecl;
10033
10034   if (!TYPE_CLINIT_STMT_LIST (class_type))
10035     return NULL_TREE;
10036
10037   /* Go through all static fields and pre expand them */
10038   for (current = TYPE_FIELDS (class_type); current; 
10039        current = TREE_CHAIN (current))
10040     if (FIELD_STATIC (current))
10041       build_field_ref (NULL_TREE, class_type, DECL_NAME (current));
10042
10043   /* Then build the <clinit> method */
10044   mdecl = create_artificial_method (class_type, ACC_STATIC, void_type_node,
10045                                     clinit_identifier_node, end_params_node);
10046   layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
10047                        mdecl, NULL_TREE);
10048   start_artificial_method_body (mdecl);
10049
10050   /* We process the list of assignment we produced as the result of
10051      the declaration of initialized static field and add them as
10052      statement to the <clinit> method. */
10053   for (current = TYPE_CLINIT_STMT_LIST (class_type); current;
10054        current = TREE_CHAIN (current))
10055     {
10056       /* We build the assignment expression that will initialize the
10057          field to its value. There are strict rules on static
10058          initializers (8.5). FIXME */
10059       tree stmt = build_debugable_stmt (EXPR_WFL_LINECOL (current), current);
10060       java_method_add_stmt (mdecl, stmt);
10061     }
10062
10063   end_artificial_method_body (mdecl);
10064
10065   /* Now we want to place <clinit> as the last method for interface so
10066      that it doesn't interfere with the dispatch table based
10067      lookup. */
10068   if (CLASS_INTERFACE (TYPE_NAME (class_type))
10069       && TREE_CHAIN (TYPE_METHODS (class_type)))
10070     {
10071       tree current = 
10072         TYPE_METHODS (class_type) = TREE_CHAIN (TYPE_METHODS (class_type));
10073
10074       while (TREE_CHAIN (current))
10075         current = TREE_CHAIN (current);
10076       TREE_CHAIN (current) = mdecl;
10077       TREE_CHAIN (mdecl) = NULL_TREE;
10078     }
10079
10080   return mdecl;
10081 }
10082
10083 /* Complete and expand a method.  */
10084
10085 static void
10086 java_complete_expand_method (mdecl)
10087      tree mdecl;
10088 {
10089   current_function_decl = mdecl;
10090   /* Fix constructors before expanding them */
10091   if (DECL_CONSTRUCTOR_P (mdecl))
10092     fix_constructors (mdecl);
10093   
10094   /* Expand functions that have a body */
10095   if (DECL_FUNCTION_BODY (mdecl))
10096     {
10097       tree fbody = DECL_FUNCTION_BODY (mdecl);
10098       tree block_body = BLOCK_EXPR_BODY (fbody);
10099       tree exception_copy = NULL_TREE;
10100       expand_start_java_method (mdecl);
10101       build_result_decl (mdecl);
10102
10103       current_this 
10104         = (!METHOD_STATIC (mdecl) ? 
10105            BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
10106
10107       /* Purge the `throws' list of unchecked exceptions. If we're
10108          doing xref, save a copy of the list and re-install it
10109          later. */
10110       if (flag_emit_xref)
10111         exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
10112
10113       purge_unchecked_exceptions (mdecl);
10114
10115       /* Install exceptions thrown with `throws' */
10116       PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
10117
10118       if (block_body != NULL_TREE)
10119         {
10120           block_body = java_complete_tree (block_body);
10121
10122           if (!flag_emit_xref)
10123             check_for_initialization (block_body);
10124           ctxp->explicit_constructor_p = 0;
10125         }
10126       BLOCK_EXPR_BODY (fbody) = block_body;
10127
10128       /* If we saw a return but couldn't evaluate it properly, we'll
10129          have an error_mark_node here. */
10130       if (block_body != error_mark_node
10131           && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
10132           && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
10133           && !flag_emit_xref)
10134         missing_return_error (current_function_decl);
10135
10136       complete_start_java_method (mdecl); 
10137
10138       /* Don't go any further if we've found error(s) during the
10139          expansion */
10140       if (!java_error_count)
10141         source_end_java_method ();
10142       else
10143         {
10144           pushdecl_force_head (DECL_ARGUMENTS (mdecl));
10145           poplevel (1, 0, 1);
10146         }
10147
10148       /* Pop the exceptions and sanity check */
10149       POP_EXCEPTIONS();
10150       if (currently_caught_type_list)
10151         fatal ("Exception list non empty - java_complete_expand_method");
10152
10153       if (flag_emit_xref)
10154         DECL_FUNCTION_THROWS (mdecl) = exception_copy;
10155     }
10156 }
10157
10158 \f
10159
10160 /* This section of the code deals with accessing enclosing context
10161    fields either directly by using the relevant access to this$<n> or
10162    by invoking an access method crafted for that purpose.  */
10163
10164 /* Build the necessary access from an inner class to an outer
10165    class. This routine could be optimized to cache previous result
10166    (decl, current_class and returned access).  When an access method
10167    needs to be generated, it always takes the form of a read. It might
10168    be later turned into a write by calling outer_field_access_fix.  */
10169
10170 static tree
10171 build_outer_field_access (id, decl)
10172      tree id, decl;
10173 {
10174   tree access = NULL_TREE;
10175   tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
10176
10177   /* If decl's class is the direct outer class of the current_class,
10178      build the access as `this$<n>.<field>'. Not that we will break
10179      the `private' barrier if we're not emitting bytecodes. */
10180   if (ctx == DECL_CONTEXT (decl) 
10181       && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
10182     {
10183       tree thisn = build_current_thisn (current_class);
10184       access = make_qualified_primary (build_wfl_node (thisn), 
10185                                        id, EXPR_WFL_LINECOL (id));
10186     }
10187   /* Otherwise, generate access methods to outer this and access the
10188      field (either using an access method or by direct access.) */
10189   else
10190     {
10191       int lc = EXPR_WFL_LINECOL (id);
10192
10193       /* Now we chain the required number of calls to the access$0 to
10194          get a hold to the enclosing instance we need, and the we
10195          build the field access. */
10196       access = build_access_to_thisn (ctx, DECL_CONTEXT (decl), lc);
10197
10198       /* If the field is private and we're generating bytecode, then
10199          we generate an access method */
10200       if (FIELD_PRIVATE (decl) && flag_emit_class_files )
10201         {
10202           tree name = build_outer_field_access_methods (decl);
10203           access = build_outer_field_access_expr (lc, DECL_CONTEXT (decl),
10204                                                   name, access, NULL_TREE);
10205         }
10206       /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
10207          Once again we break the `private' access rule from a foreign
10208          class. */
10209       else
10210         access = make_qualified_primary (access, id, lc);
10211     }
10212   return resolve_expression_name (access, NULL);
10213 }
10214
10215 /* Return a non zero value if NODE describes an outer field inner
10216    access.  */
10217
10218 static int
10219 outer_field_access_p (type, decl)
10220     tree type, decl;
10221 {
10222   if (!INNER_CLASS_TYPE_P (type) 
10223       || TREE_CODE (decl) != FIELD_DECL
10224       || DECL_CONTEXT (decl) == type)
10225     return 0;
10226
10227   for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
10228        type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
10229     {
10230       if (type == DECL_CONTEXT (decl))
10231         return 1;
10232       if (!DECL_CONTEXT (TYPE_NAME (type)))
10233         break;
10234     }
10235
10236   return 0;
10237 }
10238
10239 /* Return a non zero value if NODE represents an outer field inner
10240    access that was been already expanded. As a side effect, it returns
10241    the name of the field being accessed and the argument passed to the
10242    access function, suitable for a regeneration of the access method
10243    call if necessary. */
10244
10245 static int
10246 outer_field_expanded_access_p (node, name, arg_type, arg)
10247     tree node, *name, *arg_type, *arg;
10248 {
10249   int identified = 0;
10250
10251   if (TREE_CODE (node) != CALL_EXPR)
10252     return 0;
10253
10254   /* Well, gcj generates slightly different tree nodes when compiling
10255      to native or bytecodes. It's the case for function calls. */
10256
10257   if (flag_emit_class_files 
10258       && TREE_CODE (node) == CALL_EXPR
10259       && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
10260     identified = 1;
10261   else if (!flag_emit_class_files)
10262     {
10263       node = TREE_OPERAND (node, 0);
10264       
10265       if (node && TREE_OPERAND (node, 0)
10266           && TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR)
10267         {
10268           node = TREE_OPERAND (node, 0);
10269           if (TREE_OPERAND (node, 0)
10270               && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
10271               && (OUTER_FIELD_ACCESS_IDENTIFIER_P 
10272                   (DECL_NAME (TREE_OPERAND (node, 0)))))
10273             identified = 1;
10274         }
10275     }
10276
10277   if (identified && name && arg_type && arg)
10278     {
10279       tree argument = TREE_OPERAND (node, 1);
10280       *name = DECL_NAME (TREE_OPERAND (node, 0));
10281       *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
10282       *arg = TREE_VALUE (argument);
10283     }
10284   return identified;
10285 }
10286
10287 /* Detect in NODE an outer field read access from an inner class and
10288    transform it into a write with RHS as an argument. This function is
10289    called from the java_complete_lhs when an assignment to a LHS can
10290    be identified. */
10291
10292 static tree
10293 outer_field_access_fix (wfl, node, rhs)
10294     tree wfl, node, rhs;
10295 {
10296   tree name, arg_type, arg;
10297   
10298   if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
10299     {
10300       /* At any rate, check whether we're trying to assign a value to
10301          a final. */
10302       tree accessed = (JDECL_P (node) ? node : 
10303                        (TREE_CODE (node) == COMPONENT_REF ? 
10304                         TREE_OPERAND (node, 1) : node));
10305       if (check_final_assignment (accessed, wfl))
10306         return error_mark_node;
10307   
10308       node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl), 
10309                                             arg_type, name, arg, rhs);
10310       return java_complete_tree (node);
10311     }
10312   return NULL_TREE;
10313 }
10314
10315 /* Construct the expression that calls an access method:
10316      <type>.access$<n>(<arg1> [, <arg2>]); 
10317
10318    ARG2 can be NULL and will be omitted in that case. It will denote a
10319    read access.  */
10320
10321 static tree
10322 build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
10323     int lc;
10324     tree type, access_method_name, arg1, arg2;
10325 {
10326   tree args, cn, access;
10327
10328   args = arg1 ? arg1 : 
10329     build_wfl_node (build_current_thisn (current_class));
10330   args = build_tree_list (NULL_TREE, args);
10331
10332   if (arg2)
10333     args = tree_cons (NULL_TREE, arg2, args);
10334
10335   access = build_method_invocation (build_wfl_node (access_method_name), args);
10336   cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
10337   return make_qualified_primary (cn, access, lc);
10338 }
10339
10340 static tree
10341 build_new_access_id ()
10342 {
10343   static int access_n_counter = 1;
10344   char buffer [128];
10345
10346   sprintf (buffer, "access$%d", access_n_counter++);
10347   return get_identifier (buffer);
10348 }
10349
10350 /* Create the static access functions for the outer field DECL. We define a
10351    read:
10352      TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
10353        return inst$.field;
10354      }
10355    and a write access:
10356      TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$,
10357                                      TREE_TYPE (<field>) value$) {
10358        return inst$.field = value$;
10359      }
10360    We should have a usage flags on the DECL so we can lazily turn the ones
10361    we're using for code generation. FIXME.
10362 */
10363
10364 static tree
10365 build_outer_field_access_methods (decl)
10366     tree decl;
10367 {
10368   tree id, args, stmt, mdecl;
10369   
10370   /* Check point, to be removed. FIXME */
10371   if (FIELD_INNER_ACCESS (decl) 
10372       && TREE_CODE (FIELD_INNER_ACCESS (decl)) != IDENTIFIER_NODE)
10373     abort ();
10374
10375   if (FIELD_INNER_ACCESS (decl))
10376     return FIELD_INNER_ACCESS (decl);
10377
10378   push_obstacks (&permanent_obstack, &permanent_obstack);
10379
10380   /* Create the identifier and a function named after it. */
10381   id = build_new_access_id ();
10382
10383   /* The identifier is marked as bearing the name of a generated write
10384      access function for outer field accessed from inner classes. */
10385   OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10386
10387   /* Create the read access */
10388   args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10389   TREE_CHAIN (args) = end_params_node;
10390   stmt = make_qualified_primary (build_wfl_node (inst_id),
10391                                  build_wfl_node (DECL_NAME (decl)), 0);
10392   stmt = build_return (0, stmt);
10393   mdecl = build_outer_field_access_method (DECL_CONTEXT (decl), 
10394                                            TREE_TYPE (decl), id, args, stmt);
10395   DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10396
10397   /* Create the write access method */
10398   args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10399   TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
10400   TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
10401   stmt = make_qualified_primary (build_wfl_node (inst_id),
10402                                  build_wfl_node (DECL_NAME (decl)), 0);
10403   stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
10404                                             build_wfl_node (wpv_id)));
10405
10406   mdecl = build_outer_field_access_method (DECL_CONTEXT (decl), 
10407                                            TREE_TYPE (decl), id, args, stmt);
10408   DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10409   pop_obstacks ();
10410
10411   /* Return the access name */
10412   return FIELD_INNER_ACCESS (decl) = id;
10413 }
10414
10415 /* Build an field access method NAME.  */
10416
10417 static tree 
10418 build_outer_field_access_method (class, type, name, args, body)
10419     tree class, type, name, args, body;
10420 {
10421   tree saved_current_function_decl, mdecl;
10422
10423   /* Create the method */
10424   mdecl = create_artificial_method (class, ACC_STATIC, type, name, args);
10425   fix_method_argument_names (args, mdecl);
10426   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10427
10428   /* Attach the method body. */
10429   saved_current_function_decl = current_function_decl;
10430   start_artificial_method_body (mdecl);
10431   java_method_add_stmt (mdecl, body);
10432   end_artificial_method_body (mdecl);
10433   current_function_decl = saved_current_function_decl;
10434
10435   return mdecl;
10436 }
10437
10438 \f
10439 /* This section deals with building access function necessary for
10440    certain kinds of method invocation from inner classes.  */
10441
10442 static tree
10443 build_outer_method_access_method (decl)
10444     tree decl;
10445 {
10446   tree saved_current_function_decl, mdecl;
10447   tree args = NULL_TREE, call_args = NULL_TREE;
10448   tree carg, id, body, class;
10449   char buffer [80];
10450   int parm_id_count = 0;
10451
10452   /* Test this abort with an access to a private field */
10453   if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "access$"))
10454     abort ();
10455
10456   /* Check the cache first */
10457   if (DECL_FUNCTION_INNER_ACCESS (decl))
10458     return DECL_FUNCTION_INNER_ACCESS (decl);
10459
10460   class = DECL_CONTEXT (decl);
10461
10462   /* Obtain an access identifier and mark it */
10463   id = build_new_access_id ();
10464   OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10465
10466   push_obstacks (&permanent_obstack, &permanent_obstack);
10467
10468   carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
10469   /* Create the arguments, as much as the original */
10470   for (; carg && carg != end_params_node; 
10471        carg = TREE_CHAIN (carg))
10472     {
10473       sprintf (buffer, "write_parm_value$%d", parm_id_count++);
10474       args = chainon (args, build_tree_list (get_identifier (buffer), 
10475                                              TREE_VALUE (carg)));
10476     }
10477   args = chainon (args, end_params_node);
10478
10479   /* Create the method */
10480   mdecl = create_artificial_method (class, ACC_STATIC, 
10481                                     TREE_TYPE (TREE_TYPE (decl)), id, args);
10482   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10483   /* There is a potential bug here. We should be able to use
10484      fix_method_argument_names, but then arg names get mixed up and
10485      eventually a constructor will have its this$0 altered and the
10486      outer context won't be assignment properly. The test case is
10487      stub.java FIXME */
10488   TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
10489
10490   /* Attach the method body. */
10491   saved_current_function_decl = current_function_decl;
10492   start_artificial_method_body (mdecl);
10493
10494   /* The actual method invocation uses the same args. When invoking a
10495      static methods that way, we don't want to skip the first
10496      argument. */
10497   carg = args;
10498   if (!METHOD_STATIC (decl))
10499     carg = TREE_CHAIN (carg);
10500   for (; carg && carg != end_params_node; carg = TREE_CHAIN (carg))
10501     call_args = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (carg)),
10502                            call_args);
10503
10504   body = build_method_invocation (build_wfl_node (DECL_NAME (decl)), 
10505                                   call_args);
10506   if (!METHOD_STATIC (decl))
10507     body = make_qualified_primary (build_wfl_node (TREE_PURPOSE (args)), 
10508                                    body, 0);
10509   if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
10510     body = build_return (0, body);
10511   java_method_add_stmt (mdecl,body);
10512   end_artificial_method_body (mdecl);
10513   current_function_decl = saved_current_function_decl;
10514   pop_obstacks ();
10515
10516   /* Back tag the access function so it know what it accesses */
10517   DECL_FUNCTION_ACCESS_DECL (decl) = mdecl;
10518
10519   /* Tag the current method so it knows it has an access generated */
10520   return DECL_FUNCTION_INNER_ACCESS (decl) = mdecl;
10521 }
10522
10523 \f
10524 /* This section of the code deals with building expressions to access
10525    the enclosing instance of an inner class. The enclosing instance is
10526    kept in a generated field called this$<n>, with <n> being the
10527    inner class nesting level (starting from 0.)  */
10528     
10529 /* Build an access to a given this$<n>, possibly by chaining access
10530    call to others. Access methods to this$<n> are build on the fly if
10531    necessary */
10532
10533 static tree
10534 build_access_to_thisn (from, to, lc)
10535      tree from, to;
10536      int lc;
10537 {
10538   tree access = NULL_TREE;
10539
10540   while (from != to)
10541     {
10542       tree access0_wfl, cn;
10543
10544       maybe_build_thisn_access_method (from);
10545       access0_wfl = build_wfl_node (access0_identifier_node);
10546       cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
10547       EXPR_WFL_LINECOL (access0_wfl) = lc;
10548       
10549       if (!access)
10550         {
10551           access = build_current_thisn (current_class);
10552           access = build_wfl_node (access);
10553         }
10554       access = build_tree_list (NULL_TREE, access);
10555       access = build_method_invocation (access0_wfl, access);
10556       access = make_qualified_primary (cn, access, lc);
10557       
10558       from = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (from)));
10559     }
10560   return access;
10561 }
10562
10563 /* Build an access function to the this$<n> local to TYPE. NULL_TREE
10564    is returned if nothing needs to be generated. Otherwise, the method
10565    generated, fully walked and a method decl is returned.  
10566
10567    NOTE: These generated methods should be declared in a class file
10568    attribute so that they can't be referred to directly.  */
10569
10570 static tree
10571 maybe_build_thisn_access_method (type)
10572     tree type;
10573 {
10574   tree mdecl, args, stmt, rtype;
10575   tree saved_current_function_decl;
10576
10577   /* If TYPE is a top-level class, no access method is required.
10578      If there already is such an access method, bail out. */
10579   if (CLASS_ACCESS0_GENERATED_P (type) || !INNER_CLASS_TYPE_P (type))
10580     return NULL_TREE;
10581
10582   /* We generate the method. The method looks like:
10583      static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; }
10584   */
10585   push_obstacks (&permanent_obstack, &permanent_obstack);
10586   args = build_tree_list (inst_id, build_pointer_type (type));
10587   TREE_CHAIN (args) = end_params_node;
10588   rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))));
10589   mdecl = create_artificial_method (type, ACC_STATIC, rtype,
10590                                     access0_identifier_node, args);
10591   fix_method_argument_names (args, mdecl);
10592   layout_class_method (type, NULL_TREE, mdecl, NULL_TREE);
10593   stmt = build_current_thisn (type);
10594   stmt = make_qualified_primary (build_wfl_node (inst_id), 
10595                                  build_wfl_node (stmt), 0);
10596   stmt = build_return (0, stmt);
10597
10598   saved_current_function_decl = current_function_decl;
10599   start_artificial_method_body (mdecl);
10600   java_method_add_stmt (mdecl, stmt);
10601   end_artificial_method_body (mdecl);
10602   current_function_decl = saved_current_function_decl;
10603   pop_obstacks ();
10604
10605   CLASS_ACCESS0_GENERATED_P (type) = 1;
10606
10607   return mdecl;
10608 }
10609
10610 /* Craft an correctly numbered `this$<n>'string. this$0 is used for
10611    the first level of innerclassing. this$1 for the next one, etc...
10612    This function can be invoked with TYPE to NULL, available and then
10613    has to count the parser context.  */
10614
10615 static tree
10616 build_current_thisn (type)
10617     tree type;
10618 {
10619   static int saved_i = -1;
10620   static tree saved_thisn = NULL_TREE;
10621
10622   tree decl;
10623   char buffer [80];
10624   int i = 0;
10625
10626   if (type)
10627     {
10628       static tree saved_type = NULL_TREE;
10629       static int saved_type_i = 0;
10630
10631       if (type == saved_type)
10632         i = saved_type_i;
10633       else
10634         {
10635           for (i = -1, decl = DECL_CONTEXT (TYPE_NAME (type)); 
10636                decl; decl = DECL_CONTEXT (decl), i++)
10637             ;
10638       
10639           saved_type = type;
10640           saved_type_i = i;
10641         }
10642     }
10643   else
10644     i = list_length (GET_CPC_LIST ())-2;
10645
10646   if (i == saved_i)
10647     return saved_thisn;
10648     
10649   sprintf (buffer, "this$%d", i);
10650   saved_i = i;
10651   saved_thisn = get_identifier (buffer);
10652   return saved_thisn;
10653 }
10654
10655 /* Return the assignement to the hidden enclosing context `this$<n>'
10656    by the second incoming parameter to the innerclass constructor. The
10657    form used is `this.this$<n> = this$<n>;'.  */
10658
10659 static tree
10660 build_thisn_assign ()
10661 {
10662   if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
10663     {
10664       tree thisn = build_current_thisn (current_class);
10665       tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
10666                                          build_wfl_node (thisn), 0);
10667       tree rhs = build_wfl_node (thisn);
10668       EXPR_WFL_SET_LINECOL (lhs, lineno, 0);
10669       return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
10670     }
10671   return NULL_TREE;
10672 }
10673
10674 \f
10675 /* Building the synthetic `class$' used to implement the `.class' 1.1
10676    extension for non primitive types. This method looks like:
10677
10678     static Class class$(String type) throws NoClassDefFoundError
10679     {
10680       try {return (java.lang.Class.forName (String));}
10681       catch (ClassNotFoundException e) {
10682         throw new NoClassDefFoundError(e.getMessage());}
10683     } */
10684
10685 static tree
10686 build_dot_class_method (class)
10687      tree class;
10688 {
10689 #define BWF(S) build_wfl_node (get_identifier ((S)))
10690 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
10691   tree args, tmp, saved_current_function_decl, mdecl;
10692   tree stmt, throw_stmt, catch, catch_block, try_block;
10693   tree catch_clause_param;
10694   tree class_not_found_exception, no_class_def_found_error;
10695
10696   static tree get_message_wfl, type_parm_wfl;
10697
10698   if (!get_message_wfl)
10699     {
10700       get_message_wfl = build_wfl_node (get_identifier ("getMessage"));
10701       type_parm_wfl = build_wfl_node (get_identifier ("type$"));
10702     }
10703
10704   /* Build the arguments */
10705   args = build_tree_list (get_identifier ("type$"),
10706                           build_pointer_type (string_type_node));
10707   TREE_CHAIN (args) = end_params_node;
10708
10709   /* Build the qualified name java.lang.Class.forName */
10710   tmp = MQN (MQN (MQN (BWF ("java"), 
10711                        BWF ("lang")), BWF ("Class")), BWF ("forName"));
10712
10713   /* For things we have to catch and throw */
10714   class_not_found_exception = 
10715     lookup_class (get_identifier ("java.lang.ClassNotFoundException"));
10716   no_class_def_found_error = 
10717     lookup_class (get_identifier ("java.lang.NoClassDefFoundError"));
10718   load_class (class_not_found_exception, 1);
10719   load_class (no_class_def_found_error, 1);
10720
10721   /* Create the "class$" function */
10722   mdecl = create_artificial_method (class, ACC_STATIC, 
10723                                     build_pointer_type (class_type_node),
10724                                     get_identifier ("class$"), args);
10725   DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE,
10726                                                   no_class_def_found_error);
10727   
10728   /* We start by building the try block. We need to build:
10729        return (java.lang.Class.forName (type)); */
10730   stmt = build_method_invocation (tmp, 
10731                                   build_tree_list (NULL_TREE, type_parm_wfl));
10732   stmt = build_return (0, stmt);
10733   /* Put it in a block. That's the try block */
10734   try_block = build_expr_block (stmt, NULL_TREE);
10735
10736   /* Now onto the catch block. We start by building the expression
10737      throwing a new exception: 
10738        throw new NoClassDefFoundError (_.getMessage); */
10739   throw_stmt = make_qualified_name (build_wfl_node (wpv_id), 
10740                                     get_message_wfl, 0);
10741   throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
10742   
10743   /* Build new NoClassDefFoundError (_.getMessage) */
10744   throw_stmt = build_new_invocation 
10745     (build_wfl_node (get_identifier ("NoClassDefFoundError")),
10746      build_tree_list (build_pointer_type (string_type_node), throw_stmt));
10747
10748   /* Build the throw, (it's too early to use BUILD_THROW) */
10749   throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
10750
10751   /* Build the catch block to encapsulate all this. We begin by
10752      building an decl for the catch clause parameter and link it to
10753      newly created block, the catch block. */
10754   catch_clause_param = 
10755     build_decl (VAR_DECL, wpv_id, 
10756                 build_pointer_type (class_not_found_exception));
10757   catch_block = build_expr_block (NULL_TREE, catch_clause_param);
10758   
10759   /* We initialize the variable with the exception handler. */
10760   catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
10761                  soft_exceptioninfo_call_node);
10762   add_stmt_to_block (catch_block, NULL_TREE, catch);
10763
10764   /* We add the statement throwing the new exception */
10765   add_stmt_to_block (catch_block, NULL_TREE, throw_stmt);
10766
10767   /* Build a catch expression for all this */
10768   catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
10769
10770   /* Build the try/catch sequence */
10771   stmt = build_try_statement (0, try_block, catch_block);
10772
10773   fix_method_argument_names (args, mdecl);
10774   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10775   saved_current_function_decl = current_function_decl;
10776   start_artificial_method_body (mdecl);
10777   java_method_add_stmt (mdecl, stmt);
10778   end_artificial_method_body (mdecl);
10779   current_function_decl = saved_current_function_decl;
10780   TYPE_DOT_CLASS (class) = mdecl;
10781
10782   return mdecl;
10783 }
10784
10785 static tree
10786 build_dot_class_method_invocation (name)
10787      tree name;
10788 {
10789   tree s = make_node (STRING_CST);
10790   TREE_STRING_LENGTH (s) = IDENTIFIER_LENGTH (name);
10791   TREE_STRING_POINTER (s) = obstack_alloc (expression_obstack,
10792                                            TREE_STRING_LENGTH (s)+1);
10793   strcpy (TREE_STRING_POINTER (s), IDENTIFIER_POINTER (name));
10794   return build_method_invocation (build_wfl_node (get_identifier ("class$")),
10795                                   build_tree_list (NULL_TREE, s));
10796 }
10797
10798 /* This section of the code deals with constructor.  */
10799
10800 /* Craft a body for default constructor. Patch existing constructor
10801    bodies with call to super() and field initialization statements if
10802    necessary.  */
10803
10804 static void
10805 fix_constructors (mdecl)
10806      tree mdecl;
10807 {
10808   tree body = DECL_FUNCTION_BODY (mdecl);
10809   tree thisn_assign, compound = NULL_TREE;
10810   tree class_type = DECL_CONTEXT (mdecl);
10811
10812   if (!body)
10813     {
10814       /* It is an error for the compiler to generate a default
10815          constructor if the superclass doesn't have a constructor that
10816          takes no argument, or the same args for an anonymous class */
10817       if (verify_constructor_super (mdecl))
10818         {
10819           tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (class_type));
10820           tree save = DECL_NAME (mdecl);
10821           const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
10822           DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
10823           parse_error_context
10824             (lookup_cl (TYPE_NAME (class_type)), 
10825              "No constructor matching `%s' found in class `%s'",
10826              lang_printable_name (mdecl, 0), n);
10827           DECL_NAME (mdecl) = save;
10828         }
10829       
10830       /* The constructor body must be crafted by hand. It's the
10831          constructor we defined when we realize we didn't have the
10832          CLASSNAME() constructor */
10833       start_artificial_method_body (mdecl);
10834       
10835       /* We don't generate a super constructor invocation if we're
10836          compiling java.lang.Object. build_super_invocation takes care
10837          of that. */
10838       compound = java_method_add_stmt (mdecl, build_super_invocation (mdecl));
10839
10840       /* Insert the instance initializer block right here, after the
10841          super invocation. */
10842       add_instance_initializer (mdecl);
10843
10844       /* Insert an assignment to the this$<n> hidden field, if
10845          necessary */
10846       if ((thisn_assign = build_thisn_assign ()))
10847         java_method_add_stmt (mdecl, thisn_assign);
10848
10849       end_artificial_method_body (mdecl);
10850     }
10851   /* Search for an explicit constructor invocation */
10852   else 
10853     {
10854       int found = 0;
10855       tree main_block = BLOCK_EXPR_BODY (body);
10856       
10857       while (body)
10858         switch (TREE_CODE (body))
10859           {
10860           case CALL_EXPR:
10861             found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
10862             body = NULL_TREE;
10863             break;
10864           case COMPOUND_EXPR:
10865           case EXPR_WITH_FILE_LOCATION:
10866             body = TREE_OPERAND (body, 0);
10867             break;
10868           case BLOCK:
10869             body = BLOCK_EXPR_BODY (body);
10870             break;
10871           default:
10872             found = 0;
10873             body = NULL_TREE;
10874           }
10875       /* The constructor is missing an invocation of super() */
10876       if (!found)
10877         compound = add_stmt_to_compound (compound, NULL_TREE,
10878                                          build_super_invocation (mdecl));
10879       
10880       /* Insert the instance initializer block right here, after the
10881          super invocation. */
10882       add_instance_initializer (mdecl);
10883
10884       /* Generate the assignment to this$<n>, if necessary */
10885       if ((thisn_assign = build_thisn_assign ()))
10886         compound = add_stmt_to_compound (compound, NULL_TREE, thisn_assign);
10887
10888       /* Fix the constructor main block if we're adding extra stmts */
10889       if (compound)
10890         {
10891           compound = add_stmt_to_compound (compound, NULL_TREE,
10892                                            BLOCK_EXPR_BODY (main_block));
10893           BLOCK_EXPR_BODY (main_block) = compound;
10894         }
10895     }
10896 }
10897
10898 /* Browse constructors in the super class, searching for a constructor
10899    that doesn't take any argument. Return 0 if one is found, 1
10900    otherwise.  If the current class is an anonymous inner class, look
10901    for something that has the same signature. */
10902
10903 static int
10904 verify_constructor_super (mdecl)
10905      tree mdecl;
10906 {
10907   tree class = CLASSTYPE_SUPER (current_class);
10908   tree sdecl;
10909
10910   if (!class)
10911     return 0;
10912
10913   if (ANONYMOUS_CLASS_P (current_class))
10914     {
10915       tree mdecl_arg_type;
10916       SKIP_THIS_AND_ARTIFICIAL_PARMS (mdecl_arg_type, mdecl);
10917       for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10918         if (DECL_CONSTRUCTOR_P (sdecl))
10919           {
10920             tree arg_type;
10921             for (arg_type = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
10922                  arg_type != end_params_node && 
10923                    mdecl_arg_type != end_params_node;
10924                  arg_type = TREE_CHAIN (arg_type), 
10925                  mdecl_arg_type = TREE_CHAIN (mdecl_arg_type))
10926               if (TREE_VALUE (arg_type) != TREE_VALUE (mdecl_arg_type))
10927                 break;
10928
10929             if (arg_type == end_params_node && 
10930                 mdecl_arg_type == end_params_node)
10931               return 0;
10932           }
10933     }
10934   else
10935     {
10936       for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10937         {
10938           if (DECL_CONSTRUCTOR_P (sdecl)
10939               && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl))) 
10940                  == end_params_node)
10941             return 0;
10942         }
10943     }
10944   return 1;
10945 }
10946
10947 /* Generate code for all context remembered for code generation.  */
10948
10949 void
10950 java_expand_classes ()
10951 {
10952   int save_error_count = 0;
10953   static struct parser_ctxt *saved_ctxp = NULL;
10954
10955   java_parse_abort_on_error ();
10956   if (!(ctxp = ctxp_for_generation))
10957     return;
10958   java_layout_classes ();
10959   java_parse_abort_on_error ();
10960
10961   /* The list of packages declaration seen so far needs to be
10962      reversed, so that package declared in a file being compiled gets
10963      priority over packages declared as a side effect of parsing other
10964      files.*/
10965   package_list = nreverse (package_list);
10966
10967   saved_ctxp = ctxp_for_generation;
10968   for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10969     {
10970       ctxp = ctxp_for_generation;
10971       lang_init_source (2);            /* Error msgs have method prototypes */
10972       java_complete_expand_classes (); /* Complete and expand classes */
10973       java_parse_abort_on_error ();
10974     }
10975
10976   /* Find anonymous classes and expand their constructor, now they
10977      have been fixed. */
10978   for (ctxp_for_generation = saved_ctxp;
10979        ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10980     {
10981       tree current;
10982       ctxp = ctxp_for_generation;
10983       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
10984         {
10985           current_class = TREE_TYPE (current);
10986           if (ANONYMOUS_CLASS_P (current_class))
10987             {
10988               tree d;
10989               for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
10990                 {
10991                   if (DECL_CONSTRUCTOR_P (d))
10992                     {
10993                       restore_line_number_status (1);
10994                       reset_method_name (d);
10995                       java_complete_expand_method (d);
10996                       restore_line_number_status (0);
10997                       break;    /* We now there are no other ones */
10998                     }
10999                 }
11000             }
11001         }
11002     }
11003
11004   /* If we've found error at that stage, don't try to generate
11005      anything, unless we're emitting xrefs or checking the syntax only
11006      (but not using -fsyntax-only for the purpose of generating
11007      bytecode. */
11008   if (java_error_count && !flag_emit_xref 
11009       && (!flag_syntax_only && !flag_emit_class_files))
11010     return;
11011
11012   /* Now things are stable, go for generation of the class data. */
11013   for (ctxp_for_generation = saved_ctxp;
11014        ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11015     {
11016       tree current;
11017       ctxp = ctxp_for_generation;
11018       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11019         {
11020           current_class = TREE_TYPE (current);
11021           outgoing_cpool = TYPE_CPOOL (current_class);
11022           if (flag_emit_class_files)
11023             write_classfile (current_class);
11024           if (flag_emit_xref)
11025             expand_xref (current_class);
11026           else if (! flag_syntax_only)
11027             finish_class ();
11028         }
11029     }
11030 }
11031
11032 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
11033    a tree list node containing RIGHT. Fore coming RIGHTs will be
11034    chained to this hook. LOCATION contains the location of the
11035    separating `.' operator.  */
11036
11037 static tree
11038 make_qualified_primary (primary, right, location)
11039      tree primary, right;
11040      int location;
11041 {
11042   tree wfl;
11043
11044   if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
11045     wfl = build_wfl_wrap (primary);
11046   else
11047     {
11048       wfl = primary;
11049       /* If wfl wasn't qualified, we build a first anchor */
11050       if (!EXPR_WFL_QUALIFICATION (wfl))
11051         EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (wfl, NULL_TREE);
11052     }
11053
11054   /* And chain them */
11055   EXPR_WFL_LINECOL (right) = location;
11056   chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
11057   PRIMARY_P (wfl) =  1;
11058   return wfl;
11059 }
11060
11061 /* Simple merge of two name separated by a `.' */
11062
11063 static tree
11064 merge_qualified_name (left, right)
11065      tree left, right;
11066 {
11067   tree node;
11068   if (!left && !right)
11069     return NULL_TREE;
11070
11071   if (!left)
11072     return right;
11073
11074   if (!right)
11075     return left;
11076
11077   obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
11078                 IDENTIFIER_LENGTH (left));
11079   obstack_1grow (&temporary_obstack, '.');
11080   obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
11081                  IDENTIFIER_LENGTH (right));
11082   node =  get_identifier (obstack_base (&temporary_obstack));
11083   obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
11084   QUALIFIED_P (node) = 1;
11085   return node;
11086 }
11087
11088 /* Merge the two parts of a qualified name into LEFT.  Set the
11089    location information of the resulting node to LOCATION, usually
11090    inherited from the location information of the `.' operator. */
11091
11092 static tree
11093 make_qualified_name (left, right, location)
11094      tree left, right;
11095      int location;
11096 {
11097 #ifdef USE_COMPONENT_REF
11098   tree node = build (COMPONENT_REF, NULL_TREE, left, right);
11099   EXPR_WFL_LINECOL (node) = location;
11100   return node;
11101 #else
11102   tree left_id = EXPR_WFL_NODE (left);
11103   tree right_id = EXPR_WFL_NODE (right);
11104   tree wfl, merge;
11105
11106   merge = merge_qualified_name (left_id, right_id);
11107
11108   /* Left wasn't qualified and is now qualified */
11109   if (!QUALIFIED_P (left_id))
11110     {
11111       tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
11112       EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
11113       EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
11114     }
11115   
11116   wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
11117   EXPR_WFL_LINECOL (wfl) = location;
11118   chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
11119
11120   EXPR_WFL_NODE (left) = merge;
11121   return left;
11122 #endif
11123 }
11124
11125 /* Extract the last identifier component of the qualified in WFL. The
11126    last identifier is removed from the linked list */
11127
11128 static tree
11129 cut_identifier_in_qualified (wfl)
11130      tree wfl;
11131 {
11132   tree q;
11133   tree previous = NULL_TREE;
11134   for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
11135     if (!TREE_CHAIN (q))
11136       {
11137         if (!previous)
11138           fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified");
11139         TREE_CHAIN (previous) = NULL_TREE;
11140         return TREE_PURPOSE (q);
11141       }
11142 }
11143
11144 /* Resolve the expression name NAME. Return its decl.  */
11145
11146 static tree
11147 resolve_expression_name (id, orig)
11148      tree id;
11149      tree *orig;
11150 {
11151   tree name = EXPR_WFL_NODE (id);
11152   tree decl;
11153
11154   /* 6.5.5.1: Simple expression names */
11155   if (!PRIMARY_P (id) && !QUALIFIED_P (name))
11156     {
11157       /* 15.13.1: NAME can appear within the scope of a local variable
11158          declaration */
11159       if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
11160         return decl;
11161
11162       /* 15.13.1: NAME can appear within a class declaration */
11163       else 
11164         {
11165           decl = lookup_field_wrapper (current_class, name);
11166           if (decl)
11167             {
11168               tree access = NULL_TREE;
11169               int fs = FIELD_STATIC (decl);
11170
11171               /* If we're accessing an outer scope local alias, make
11172                  sure we change the name of the field we're going to
11173                  build access to. */
11174               if (FIELD_LOCAL_ALIAS_USED (decl))
11175                 name = DECL_NAME (decl);
11176
11177               /* Instance variable (8.3.1.1) can't appear within
11178                  static method, static initializer or initializer for
11179                  a static variable. */
11180               if (!fs && METHOD_STATIC (current_function_decl))
11181                 {
11182                   static_ref_err (id, name, current_class);
11183                   return error_mark_node;
11184                 }
11185               /* Instance variables can't appear as an argument of
11186                  an explicit constructor invocation */
11187               if (!fs && ctxp->explicit_constructor_p)
11188                 {
11189                   parse_error_context
11190                     (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
11191                   return error_mark_node;
11192                 }
11193
11194               /* If we're processing an inner class and we're trying
11195                  to access a field belonging to an outer class, build
11196                  the access to the field */
11197               if (!fs && outer_field_access_p (current_class, decl))
11198                 return build_outer_field_access (id, decl);
11199
11200               /* Otherwise build what it takes to access the field */
11201               access = build_field_ref ((fs ? NULL_TREE : current_this),
11202                                         DECL_CONTEXT (decl), name);
11203               if (fs && !flag_emit_class_files && !flag_emit_xref)
11204                 access = build_class_init (DECL_CONTEXT (access), access);
11205               /* We may be asked to save the real field access node */
11206               if (orig)
11207                 *orig = access;
11208               /* And we return what we got */
11209               return access;
11210             }
11211           /* Fall down to error report on undefined variable */
11212         }
11213     }
11214   /* 6.5.5.2 Qualified Expression Names */
11215   else
11216     {
11217       if (orig)
11218         *orig = NULL_TREE;
11219       qualify_ambiguous_name (id);
11220       /* 15.10.1 Field Access Using a Primary and/or Expression Name */
11221       /* 15.10.2: Accessing Superclass Members using super */
11222       return resolve_field_access (id, orig, NULL);
11223     }
11224
11225   /* We've got an error here */
11226   parse_error_context (id, "Undefined variable `%s'", 
11227                        IDENTIFIER_POINTER (name));
11228
11229   return error_mark_node;
11230 }
11231
11232 static void
11233 static_ref_err (wfl, field_id, class_type)
11234     tree wfl, field_id, class_type;
11235 {
11236   parse_error_context 
11237     (wfl, 
11238      "Can't make a static reference to nonstatic variable `%s' in class `%s'",
11239      IDENTIFIER_POINTER (field_id), 
11240      IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
11241 }
11242
11243 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
11244    We return something suitable to generate the field access. We also
11245    return the field decl in FIELD_DECL and its type in FIELD_TYPE.  If
11246    recipient's address can be null. */
11247
11248 static tree
11249 resolve_field_access (qual_wfl, field_decl, field_type)
11250      tree qual_wfl;
11251      tree *field_decl, *field_type;
11252 {
11253   int is_static = 0;
11254   tree field_ref;
11255   tree decl, where_found, type_found;
11256
11257   if (resolve_qualified_expression_name (qual_wfl, &decl,
11258                                          &where_found, &type_found))
11259     return error_mark_node;
11260
11261   /* Resolve the LENGTH field of an array here */
11262   if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
11263       && ! flag_emit_class_files && ! flag_emit_xref)
11264     {
11265       tree length = build_java_array_length_access (where_found);
11266       field_ref =
11267         build_java_arraynull_check (type_found, length, int_type_node);
11268     }
11269   /* We might have been trying to resolve field.method(). In which
11270      case, the resolution is over and decl is the answer */
11271   else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
11272     field_ref = decl;
11273   else if (JDECL_P (decl))
11274     {
11275       int static_final_found = 0;
11276       if (!type_found)
11277         type_found = DECL_CONTEXT (decl);
11278       is_static = JDECL_P (decl) && FIELD_STATIC (decl);
11279       if (FIELD_FINAL (decl) 
11280           && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
11281           && DECL_LANG_SPECIFIC (decl)
11282           && DECL_INITIAL (decl))
11283         {
11284           field_ref = DECL_INITIAL (decl);
11285           static_final_found = 1;
11286         }
11287       else
11288         field_ref = build_field_ref ((is_static && !flag_emit_xref? 
11289                                       NULL_TREE : where_found), 
11290                                      type_found, DECL_NAME (decl));
11291       if (field_ref == error_mark_node)
11292         return error_mark_node;
11293       if (is_static && !static_final_found 
11294           && !flag_emit_class_files && !flag_emit_xref)
11295         field_ref = build_class_init (type_found, field_ref);
11296     }
11297   else
11298     field_ref = decl;
11299
11300   if (field_decl)
11301     *field_decl = decl;
11302   if (field_type)
11303     *field_type = (QUAL_DECL_TYPE (decl) ? 
11304                    QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
11305   return field_ref;
11306 }
11307
11308 /* If NODE is an access to f static field, strip out the class
11309    initialization part and return the field decl, otherwise, return
11310    NODE. */
11311
11312 static tree
11313 strip_out_static_field_access_decl (node)
11314     tree node;
11315 {
11316   if (TREE_CODE (node) == COMPOUND_EXPR)
11317     {
11318       tree op1 = TREE_OPERAND (node, 1);
11319       if (TREE_CODE (op1) == COMPOUND_EXPR)
11320          {
11321            tree call = TREE_OPERAND (op1, 0);
11322            if (TREE_CODE (call) == CALL_EXPR
11323                && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
11324                && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
11325                == soft_initclass_node)
11326              return TREE_OPERAND (op1, 1);
11327          }
11328       else if (JDECL_P (op1))
11329         return op1;
11330     }
11331   return node;
11332 }
11333
11334 /* 6.5.5.2: Qualified Expression Names */
11335
11336 static int
11337 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
11338      tree wfl;
11339      tree *found_decl, *type_found, *where_found;
11340 {
11341   int from_type = 0;            /* Field search initiated from a type */
11342   int from_super = 0, from_cast = 0, from_qualified_this = 0;
11343   int previous_call_static = 0;
11344   int is_static;
11345   tree decl = NULL_TREE, type = NULL_TREE, q;
11346   /* For certain for of inner class instantiation */
11347   tree saved_current, saved_this;               
11348 #define RESTORE_THIS_AND_CURRENT_CLASS                          \
11349   { current_class = saved_current; current_this = saved_this;}
11350
11351   *type_found = *where_found = NULL_TREE;
11352
11353   for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
11354     {
11355       tree qual_wfl = QUAL_WFL (q);
11356       tree ret_decl;            /* for EH checking */
11357       int location;             /* for EH checking */
11358
11359       /* 15.10.1 Field Access Using a Primary */
11360       switch (TREE_CODE (qual_wfl))
11361         {
11362         case CALL_EXPR:
11363         case NEW_CLASS_EXPR:
11364           /* If the access to the function call is a non static field,
11365              build the code to access it. */
11366           if (JDECL_P (decl) && !FIELD_STATIC (decl))
11367             {
11368               decl = maybe_access_field (decl, *where_found, 
11369                                          DECL_CONTEXT (decl));
11370               if (decl == error_mark_node)
11371                 return 1;
11372             }
11373
11374           /* And code for the function call */
11375           if (complete_function_arguments (qual_wfl))
11376             return 1;
11377
11378           /* We might have to setup a new current class and a new this
11379              for the search of an inner class, relative to the type of
11380              a expression resolved as `decl'. The current values are
11381              saved and restored shortly after */
11382           saved_current = current_class;
11383           saved_this = current_this;
11384           if (decl && TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
11385             {
11386               current_class = type;
11387               current_this = decl;
11388             }
11389
11390           if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
11391             CALL_USING_SUPER (qual_wfl) = 1;
11392           location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
11393                       EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
11394           *where_found = patch_method_invocation (qual_wfl, decl, type, 
11395                                                   &is_static, &ret_decl);
11396           if (*where_found == error_mark_node)
11397             {
11398               RESTORE_THIS_AND_CURRENT_CLASS;
11399               return 1;
11400             }
11401           *type_found = type = QUAL_DECL_TYPE (*where_found);
11402
11403           /* If we're creating an inner class instance, check for that
11404              an enclosing instance is in scope */
11405           if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
11406               && INNER_ENCLOSING_SCOPE_CHECK (type))
11407             {
11408               parse_error_context 
11409                 (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
11410                  lang_printable_name (type, 0),
11411                  (!current_this ? "" :
11412                   "; an explicit one must be provided when creating this inner class"));
11413               RESTORE_THIS_AND_CURRENT_CLASS;
11414               return 1;
11415             }
11416
11417           /* In case we had to change then to resolve a inner class
11418              instantiation using a primary qualified by a `new' */
11419           RESTORE_THIS_AND_CURRENT_CLASS;
11420
11421           /* EH check */
11422           if (location)
11423             check_thrown_exceptions (location, ret_decl);
11424
11425           /* If the previous call was static and this one is too,
11426              build a compound expression to hold the two (because in
11427              that case, previous function calls aren't transported as
11428              forcoming function's argument. */
11429           if (previous_call_static && is_static)
11430             {
11431               decl = build (COMPOUND_EXPR, type, decl, *where_found);
11432               TREE_SIDE_EFFECTS (decl) = 1;
11433             }
11434           else
11435             {
11436               previous_call_static = is_static;
11437               decl = *where_found;
11438             }
11439           from_type = 0;
11440           continue;
11441
11442         case NEW_ARRAY_EXPR:
11443         case NEW_ANONYMOUS_ARRAY_EXPR:
11444           *where_found = decl = java_complete_tree (qual_wfl);
11445           if (decl == error_mark_node)
11446             return 1;
11447           *type_found = type = QUAL_DECL_TYPE (decl);
11448           CLASS_LOADED_P (type) = 1;
11449           continue;
11450
11451         case CONVERT_EXPR:
11452           *where_found = decl = java_complete_tree (qual_wfl);
11453           if (decl == error_mark_node)
11454             return 1;
11455           *type_found = type = QUAL_DECL_TYPE (decl);
11456           from_cast = 1;
11457           continue;
11458
11459         case CONDITIONAL_EXPR:
11460         case STRING_CST:
11461         case MODIFY_EXPR:
11462           *where_found = decl = java_complete_tree (qual_wfl);
11463           if (decl == error_mark_node)
11464             return 1;
11465           *type_found = type = QUAL_DECL_TYPE (decl);
11466           continue;
11467
11468         case ARRAY_REF:
11469           /* If the access to the function call is a non static field,
11470              build the code to access it. */
11471           if (JDECL_P (decl) && !FIELD_STATIC (decl))
11472             {
11473               decl = maybe_access_field (decl, *where_found, type);
11474               if (decl == error_mark_node)
11475                 return 1;
11476             }
11477           /* And code for the array reference expression */
11478           decl = java_complete_tree (qual_wfl);
11479           if (decl == error_mark_node)
11480             return 1;
11481           type = QUAL_DECL_TYPE (decl);
11482           continue;
11483
11484         case PLUS_EXPR:
11485           if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11486             return 1;
11487           if ((type = patch_string (decl)))
11488             decl = type;
11489           *where_found = QUAL_RESOLUTION (q) = decl;
11490           *type_found = type = TREE_TYPE (decl);
11491           break;
11492
11493         case CLASS_LITERAL:
11494           if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11495             return 1;
11496           *where_found = QUAL_RESOLUTION (q) = decl;
11497           *type_found = type = TREE_TYPE (decl);
11498           break;
11499
11500         default:
11501           /* Fix for -Wall Just go to the next statement. Don't
11502              continue */
11503           break;
11504         }
11505
11506       /* If we fall here, we weren't processing a (static) function call. */
11507       previous_call_static = 0;
11508
11509       /* It can be the keyword THIS */
11510       if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
11511         {
11512           if (!current_this)
11513             {
11514               parse_error_context 
11515                 (wfl, "Keyword `this' used outside allowed context");
11516               return 1;
11517             }
11518           if (ctxp->explicit_constructor_p)
11519             {
11520               parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
11521               return 1;
11522             }
11523           /* We have to generate code for intermediate acess */
11524           if (!from_type || TREE_TYPE (TREE_TYPE (current_this)) == type)
11525             {
11526               *where_found = decl = current_this;
11527               *type_found = type = QUAL_DECL_TYPE (decl);
11528             }
11529           /* We're trying to access the this from somewhere else... */
11530           else
11531             {
11532               *where_found = decl = build_current_thisn (type);
11533               from_qualified_this = 1;
11534             }
11535
11536           from_type = 0;
11537           continue;
11538         }
11539
11540       /* 15.10.2 Accessing Superclass Members using SUPER */
11541       if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
11542         {
11543           tree node;
11544           /* Check on the restricted use of SUPER */
11545           if (METHOD_STATIC (current_function_decl)
11546               || current_class == object_type_node)
11547             {
11548               parse_error_context 
11549                 (wfl, "Keyword `super' used outside allowed context");
11550               return 1;
11551             }
11552           /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
11553           node = build_cast (EXPR_WFL_LINECOL (qual_wfl), 
11554                              CLASSTYPE_SUPER (current_class),
11555                              build_this (EXPR_WFL_LINECOL (qual_wfl)));
11556           *where_found = decl = java_complete_tree (node);
11557           if (decl == error_mark_node)
11558             return 1;
11559           *type_found = type = QUAL_DECL_TYPE (decl);
11560           from_super = from_type = 1;
11561           continue;
11562         }
11563
11564       /* 15.13.1: Can't search for field name in packages, so we
11565          assume a variable/class name was meant. */
11566       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
11567         {
11568           tree name = resolve_package (wfl, &q);
11569           if (name)
11570             {
11571               tree list;
11572               *where_found = decl = resolve_no_layout (name, qual_wfl);
11573               /* We wan't to be absolutely that the class is laid
11574                  out. We're going to search something inside it. */
11575               *type_found = type = TREE_TYPE (decl);
11576               layout_class (type);
11577               from_type = 1;
11578
11579               /* Fix them all the way down, if any are left. */
11580               if (q)
11581                 {
11582                   list = TREE_CHAIN (q);
11583                   while (list)
11584                     {
11585                       RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
11586                       RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
11587                       list = TREE_CHAIN (list);
11588                     }
11589                 }
11590             }
11591           else
11592             {
11593               if (from_super || from_cast)
11594                 parse_error_context 
11595                   ((from_cast ? qual_wfl : wfl),
11596                    "No variable `%s' defined in class `%s'",
11597                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11598                    lang_printable_name (type, 0));
11599               else
11600                 parse_error_context
11601                   (qual_wfl, "Undefined variable or class name: `%s'",
11602                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
11603               return 1;
11604             }
11605         }
11606
11607       /* We have a type name. It's been already resolved when the
11608          expression was qualified. */
11609       else if (RESOLVE_TYPE_NAME_P (qual_wfl))
11610         {
11611           if (!(decl = QUAL_RESOLUTION (q)))
11612             return 1;           /* Error reported already */
11613
11614           /* Sneak preview. If next we see a `new', we're facing a
11615              qualification with resulted in a type being selected
11616              instead of a field.  Report the error */
11617           if(TREE_CHAIN (q) 
11618              && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
11619             {
11620               parse_error_context (qual_wfl, "Undefined variable `%s'",
11621                                    IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11622               return 1;
11623             }
11624
11625           if (not_accessible_p (TREE_TYPE (decl), decl, 0))
11626             {
11627               parse_error_context 
11628                 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
11629                  java_accstring_lookup (get_access_flags_from_decl (decl)),
11630                  GET_TYPE_NAME (type),
11631                  IDENTIFIER_POINTER (DECL_NAME (decl)),
11632                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
11633               return 1;
11634             }
11635           check_deprecation (qual_wfl, decl);
11636
11637           type = TREE_TYPE (decl);
11638           from_type = 1;
11639         }
11640       /* We resolve and expression name */
11641       else 
11642         {
11643           tree field_decl = NULL_TREE;
11644
11645           /* If there exists an early resolution, use it. That occurs
11646              only once and we know that there are more things to
11647              come. Don't do that when processing something after SUPER
11648              (we need more thing to be put in place below */
11649           if (!from_super && QUAL_RESOLUTION (q))
11650             {
11651               decl = QUAL_RESOLUTION (q);
11652               if (!type)
11653                 {
11654                   if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
11655                     {
11656                       if (current_this)
11657                         *where_found = current_this;
11658                       else
11659                         {
11660                           static_ref_err (qual_wfl, DECL_NAME (decl),
11661                                           current_class);
11662                           return 1;
11663                         }
11664                     }
11665                   else
11666                     {
11667                       *where_found = TREE_TYPE (decl);
11668                       if (TREE_CODE (*where_found) == POINTER_TYPE)
11669                         *where_found = TREE_TYPE (*where_found);
11670                     }
11671                 }
11672             }
11673
11674           /* We have to search for a field, knowing the type of its
11675              container. The flag FROM_TYPE indicates that we resolved
11676              the last member of the expression as a type name, which
11677              means that for the resolution of this field, we'll look
11678              for other errors than if it was resolved as a member of
11679              an other field. */
11680           else
11681             {
11682               int is_static;
11683               tree field_decl_type; /* For layout */
11684
11685               if (!from_type && !JREFERENCE_TYPE_P (type))
11686                 {
11687                   parse_error_context 
11688                     (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
11689                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11690                      lang_printable_name (type, 0),
11691                      IDENTIFIER_POINTER (DECL_NAME (field_decl)));
11692                   return 1;
11693                 }
11694               
11695               field_decl = lookup_field_wrapper (type,
11696                                                  EXPR_WFL_NODE (qual_wfl));
11697               if (field_decl == NULL_TREE)
11698                 {
11699                   parse_error_context 
11700                     (qual_wfl, "No variable `%s' defined in type `%s'",
11701                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)), 
11702                      GET_TYPE_NAME (type));
11703                   return 1;
11704                 }
11705               if (field_decl == error_mark_node)
11706                 return 1;
11707
11708               /* Layout the type of field_decl, since we may need
11709                  it. Don't do primitive types or loaded classes. The
11710                  situation of non primitive arrays may not handled
11711                  properly here. FIXME */
11712               if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
11713                 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
11714               else
11715                 field_decl_type = TREE_TYPE (field_decl);
11716               if (!JPRIMITIVE_TYPE_P (field_decl_type) 
11717                   && !CLASS_LOADED_P (field_decl_type)
11718                   && !TYPE_ARRAY_P (field_decl_type))
11719                 resolve_and_layout (field_decl_type, NULL_TREE);
11720               if (TYPE_ARRAY_P (field_decl_type))
11721                 CLASS_LOADED_P (field_decl_type) = 1;
11722               
11723               /* Check on accessibility here */
11724               if (not_accessible_p (type, field_decl, from_super))
11725                 {
11726                   parse_error_context 
11727                     (qual_wfl,
11728                      "Can't access %s field `%s.%s' from `%s'",
11729                      java_accstring_lookup 
11730                        (get_access_flags_from_decl (field_decl)),
11731                      GET_TYPE_NAME (type),
11732                      IDENTIFIER_POINTER (DECL_NAME (field_decl)),
11733                      IDENTIFIER_POINTER 
11734                        (DECL_NAME (TYPE_NAME (current_class))));
11735                   return 1;
11736                 }
11737               check_deprecation (qual_wfl, field_decl);
11738               
11739               /* There are things to check when fields are accessed
11740                  from type. There are no restrictions on a static
11741                  declaration of the field when it is accessed from an
11742                  interface */
11743               is_static = FIELD_STATIC (field_decl);
11744               if (!from_super && from_type 
11745                   && !TYPE_INTERFACE_P (type) 
11746                   && !is_static 
11747                   && (current_function_decl 
11748                       && METHOD_STATIC (current_function_decl)))
11749                 {
11750                   static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
11751                   return 1;
11752                 }
11753               from_cast = from_super = 0;
11754
11755               /* It's an access from a type but it isn't static, we
11756                  make it relative to `this'. */
11757               if (!is_static && from_type)
11758                 decl = current_this;
11759
11760               /* If we need to generate something to get a proper
11761                  handle on what this field is accessed from, do it
11762                  now. */
11763               if (!is_static)
11764                 {
11765                   decl = maybe_access_field (decl, *where_found, *type_found);
11766                   if (decl == error_mark_node)
11767                     return 1;
11768                 }
11769
11770               /* We want to keep the location were found it, and the type
11771                  we found. */
11772               *where_found = decl;
11773               *type_found = type;
11774
11775               /* Generate the correct expression for field access from
11776                  qualified this */
11777               if (from_qualified_this)
11778                 {
11779                   field_decl = build_outer_field_access (qual_wfl, field_decl);
11780                   from_qualified_this = 0;
11781                 }
11782
11783               /* This is the decl found and eventually the next one to
11784                  search from */
11785               decl = field_decl;
11786             }
11787           from_type = 0;
11788           type = QUAL_DECL_TYPE (decl);
11789
11790           /* Sneak preview. If decl is qualified by a `new', report
11791              the error here to be accurate on the peculiar construct */
11792           if (TREE_CHAIN (q) 
11793               && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
11794               && !JREFERENCE_TYPE_P (type))
11795             {
11796               parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'", 
11797                                    lang_printable_name (type, 0));
11798               return 1;
11799             }
11800         }
11801       /* `q' might have changed due to a after package resolution
11802          re-qualification */
11803       if (!q)
11804         break;
11805     }
11806   *found_decl = decl;
11807   return 0;
11808 }
11809
11810 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
11811    can't be accessed from REFERENCE (a record type). */
11812
11813 static int
11814 not_accessible_p (reference, member, from_super)
11815      tree reference, member;
11816      int from_super;
11817 {
11818   int access_flag = get_access_flags_from_decl (member);
11819
11820   /* Access always granted for members declared public */
11821   if (access_flag & ACC_PUBLIC)
11822     return 0;
11823   
11824   /* Check access on protected members */
11825   if (access_flag & ACC_PROTECTED)
11826     {
11827       /* Access granted if it occurs from within the package
11828          containing the class in which the protected member is
11829          declared */
11830       if (class_in_current_package (DECL_CONTEXT (member)))
11831         return 0;
11832
11833       /* If accessed with the form `super.member', then access is granted */
11834       if (from_super)
11835         return 0;
11836
11837       /* Otherwise, access is granted if occuring from the class where
11838          member is declared or a subclass of it */
11839       if (inherits_from_p (reference, DECL_CONTEXT (member)))
11840         return 0;
11841       return 1;
11842     }
11843
11844   /* Check access on private members. Access is granted only if it
11845      occurs from within the class in which it is declared. Exceptions
11846      are accesses from inner-classes. This section is probably not
11847      complete. FIXME */
11848   if (access_flag & ACC_PRIVATE)
11849     return (current_class == DECL_CONTEXT (member) ? 0 : 
11850             (INNER_CLASS_TYPE_P (current_class) ? 0 : 1));
11851
11852   /* Default access are permitted only when occuring within the
11853      package in which the type (REFERENCE) is declared. In other words,
11854      REFERENCE is defined in the current package */
11855   if (ctxp->package)
11856     return !class_in_current_package (reference);
11857
11858   /* Otherwise, access is granted */
11859   return 0;
11860 }
11861
11862 /* Test deprecated decl access.  */
11863 static void
11864 check_deprecation (wfl, decl)
11865      tree wfl, decl;
11866 {
11867   const char *file = DECL_SOURCE_FILE (decl);
11868   /* Complain if the field is deprecated and the file it was defined
11869      in isn't compiled at the same time the file which contains its
11870      use is */
11871   if (DECL_DEPRECATED (decl) 
11872       && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
11873     {
11874       char the [20];
11875       switch (TREE_CODE (decl))
11876         {
11877         case FUNCTION_DECL:
11878           strcpy (the, "method");
11879           break;
11880         case FIELD_DECL:
11881           strcpy (the, "field");
11882           break;
11883         case TYPE_DECL:
11884           strcpy (the, "class");
11885           break;
11886         default:
11887           fatal ("unexpected DECL code - check_deprecation");
11888         }
11889       parse_warning_context 
11890         (wfl, "The %s `%s' in class `%s' has been deprecated", 
11891          the, lang_printable_name (decl, 0),
11892          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
11893     }
11894 }
11895
11896 /* Returns 1 if class was declared in the current package, 0 otherwise */
11897
11898 static int
11899 class_in_current_package (class)
11900      tree class;
11901 {
11902   static tree cache = NULL_TREE;
11903   int qualified_flag;
11904   tree left;
11905
11906   if (cache == class)
11907     return 1;
11908
11909   qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
11910
11911   /* If the current package is empty and the name of CLASS is
11912      qualified, class isn't in the current package.  If there is a
11913      current package and the name of the CLASS is not qualified, class
11914      isn't in the current package */
11915   if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
11916     return 0;
11917
11918   /* If there is not package and the name of CLASS isn't qualified,
11919      they belong to the same unnamed package */
11920   if (!ctxp->package && !qualified_flag)
11921     return 1;
11922
11923   /* Compare the left part of the name of CLASS with the package name */
11924   breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
11925   if (ctxp->package == left)
11926     {
11927       cache = class;
11928       return 1;
11929     }
11930   return 0;
11931 }
11932
11933 /* This function may generate code to access DECL from WHERE. This is
11934    done only if certain conditions meet.  */
11935
11936 static tree
11937 maybe_access_field (decl, where, type)
11938   tree decl, where, type;
11939 {
11940   if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
11941       && !FIELD_STATIC (decl))
11942     decl = build_field_ref (where ? where : current_this, 
11943                             (type ? type : DECL_CONTEXT (decl)),
11944                             DECL_NAME (decl));
11945   return decl;
11946 }
11947
11948 /* Build a method invocation, by patching PATCH. If non NULL
11949    and according to the situation, PRIMARY and WHERE may be
11950    used. IS_STATIC is set to 1 if the invoked function is static. */
11951
11952 static tree
11953 patch_method_invocation (patch, primary, where, is_static, ret_decl)
11954      tree patch, primary, where;
11955      int *is_static;
11956      tree *ret_decl;
11957 {
11958   tree wfl = TREE_OPERAND (patch, 0);
11959   tree args = TREE_OPERAND (patch, 1);
11960   tree name = EXPR_WFL_NODE (wfl);
11961   tree list;
11962   int is_static_flag = 0;
11963   int is_super_init = 0;
11964   tree this_arg = NULL_TREE;
11965   
11966   /* Should be overriden if everything goes well. Otherwise, if
11967      something fails, it should keep this value. It stop the
11968      evaluation of a bogus assignment. See java_complete_tree,
11969      MODIFY_EXPR: for the reasons why we sometimes want to keep on
11970      evaluating an assignment */
11971   TREE_TYPE (patch) = error_mark_node;
11972
11973   /* Since lookup functions are messing with line numbers, save the
11974      context now.  */
11975   java_parser_context_save_global ();
11976
11977   /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
11978
11979   /* Resolution of qualified name, excluding constructors */
11980   if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
11981     {
11982       tree identifier, identifier_wfl, type, resolved;
11983       /* Extract the last IDENTIFIER of the qualified
11984          expression. This is a wfl and we will use it's location
11985          data during error report. */
11986       identifier_wfl = cut_identifier_in_qualified (wfl);
11987       identifier = EXPR_WFL_NODE (identifier_wfl);
11988       
11989       /* Given the context, IDENTIFIER is syntactically qualified
11990          as a MethodName. We need to qualify what's before */
11991       qualify_ambiguous_name (wfl);
11992       resolved = resolve_field_access (wfl, NULL, NULL);
11993
11994       if (resolved == error_mark_node)
11995         PATCH_METHOD_RETURN_ERROR ();
11996
11997       type = GET_SKIP_TYPE (resolved);
11998       resolve_and_layout (type, NULL_TREE);
11999       list = lookup_method_invoke (0, identifier_wfl, type, identifier, args);
12000       args = nreverse (args);
12001
12002       /* We're resolving a call from a type */
12003       if (TREE_CODE (resolved) == TYPE_DECL)
12004         {
12005           if (CLASS_INTERFACE (resolved))
12006             {
12007               parse_error_context
12008                 (identifier_wfl,
12009                 "Can't make static reference to method `%s' in interface `%s'",
12010                  IDENTIFIER_POINTER (identifier), 
12011                  IDENTIFIER_POINTER (name));
12012               PATCH_METHOD_RETURN_ERROR ();
12013             }
12014           if (list && !METHOD_STATIC (list))
12015             {
12016               char *fct_name = xstrdup (lang_printable_name (list, 0));
12017               parse_error_context 
12018                 (identifier_wfl,
12019                  "Can't make static reference to method `%s %s' in class `%s'",
12020                  lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
12021                  fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
12022               free (fct_name);
12023               PATCH_METHOD_RETURN_ERROR ();
12024             }
12025         }
12026       else
12027         this_arg = primary = resolved;
12028       
12029       /* IDENTIFIER_WFL will be used to report any problem further */
12030       wfl = identifier_wfl;
12031     }
12032   /* Resolution of simple names, names generated after a primary: or
12033      constructors */
12034   else
12035     {
12036       tree class_to_search = NULL_TREE;
12037       int lc;                   /* Looking for Constructor */
12038       
12039       /* We search constructor in their target class */
12040       if (CALL_CONSTRUCTOR_P (patch))
12041         {
12042           if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12043             class_to_search = EXPR_WFL_NODE (wfl);
12044           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) == 
12045                    this_identifier_node)
12046             class_to_search = NULL_TREE;
12047           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12048                    super_identifier_node)
12049             {
12050               is_super_init = 1;
12051               if (CLASSTYPE_SUPER (current_class))
12052                 class_to_search = 
12053                   DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
12054               else
12055                 {
12056                   parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object");
12057                   PATCH_METHOD_RETURN_ERROR ();
12058                 }
12059             }
12060
12061           /* Class to search is NULL if we're searching the current one */
12062           if (class_to_search)
12063             {
12064               class_to_search = resolve_and_layout (class_to_search, wfl);
12065
12066               if (!class_to_search)
12067                 {
12068                   parse_error_context 
12069                     (wfl, "Class `%s' not found in type declaration",
12070                      IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12071                   PATCH_METHOD_RETURN_ERROR ();
12072                 }
12073               
12074               /* Can't instantiate an abstract class, but we can
12075                  invoke it's constructor. It's use within the `new'
12076                  context is denied here. */
12077               if (CLASS_ABSTRACT (class_to_search) 
12078                   && TREE_CODE (patch) == NEW_CLASS_EXPR)
12079                 {
12080                   parse_error_context 
12081                     (wfl, "Class `%s' is an abstract class. It can't be instantiated",
12082                      IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12083                   PATCH_METHOD_RETURN_ERROR ();
12084                 }
12085
12086               class_to_search = TREE_TYPE (class_to_search);
12087             }
12088           else
12089             class_to_search = current_class;
12090           lc = 1;
12091         }
12092       /* This is a regular search in the local class, unless an
12093          alternate class is specified. */
12094       else
12095         {
12096           class_to_search = (where ? where : current_class);
12097           lc = 0;
12098         }
12099
12100       /* NAME is a simple identifier or comes from a primary. Search
12101          in the class whose declaration contain the method being
12102          invoked. */
12103       resolve_and_layout (class_to_search, NULL_TREE);
12104
12105       list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
12106       /* Don't continue if no method were found, as the next statement
12107          can't be executed then. */
12108       if (!list)
12109         PATCH_METHOD_RETURN_ERROR ();
12110
12111       /* Check for static reference if non static methods */
12112       if (check_for_static_method_reference (wfl, patch, list, 
12113                                              class_to_search, primary))
12114         PATCH_METHOD_RETURN_ERROR ();
12115
12116       /* Check for inner classes creation from illegal contexts */
12117       if (lc && (INNER_CLASS_TYPE_P (class_to_search)
12118                  && !CLASS_STATIC (TYPE_NAME (class_to_search)))
12119           && INNER_ENCLOSING_SCOPE_CHECK (class_to_search))
12120         {
12121           parse_error_context 
12122             (wfl, "No enclosing instance for inner class `%s' is in scope%s",
12123              lang_printable_name (class_to_search, 0),
12124              (!current_this ? "" :
12125               "; an explicit one must be provided when creating this inner class"));
12126           PATCH_METHOD_RETURN_ERROR ();
12127         }
12128
12129       /* Non static methods are called with the current object extra
12130          argument. If patch a `new TYPE()', the argument is the value
12131          returned by the object allocator. If method is resolved as a
12132          primary, use the primary otherwise use the current THIS. */
12133       args = nreverse (args);
12134       if (TREE_CODE (patch) != NEW_CLASS_EXPR)
12135         {
12136           this_arg = primary ? primary : current_this;
12137
12138           /* If we're using an access method, things are different.
12139              There are two familly of cases:
12140
12141              1) We're not generating bytecodes:
12142
12143              - LIST is non static. It's invocation is transformed from
12144                x(a1,...,an) into this$<n>.x(a1,....an).
12145              - LIST is static. It's invocation is transformed from
12146                x(a1,...,an) into TYPE_OF(this$<n>).x(a1,....an)
12147
12148              2) We're generating bytecodes:
12149              
12150              - LIST is non static. It's invocation is transformed from
12151                x(a1,....,an) into access$<n>(this$<n>,a1,...,an).
12152              - LIST is static. It's invocation is transformed from
12153                x(a1,....,an) into TYPEOF(this$<n>).x(a1,....an).
12154
12155              Of course, this$<n> can be abitrary complex, ranging from
12156              this$0 (the immediate outer context) to 
12157              access$0(access$0(...(this$0))). 
12158              
12159              maybe_use_access_method returns a non zero value if the
12160              this_arg has to be moved into the (then generated) stub
12161              argument list. In the mean time, the selected function
12162              might have be replaced by a generated stub. */
12163           if (maybe_use_access_method (is_super_init, &list, &this_arg))
12164             args = tree_cons (NULL_TREE, this_arg, args);
12165         }
12166     }
12167
12168   /* Merge point of all resolution schemes. If we have nothing, this
12169      is an error, already signaled */
12170   if (!list) 
12171     PATCH_METHOD_RETURN_ERROR ();
12172
12173   /* Check accessibility, position the is_static flag, build and
12174      return the call */
12175   if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
12176     {
12177       char *fct_name = xstrdup (lang_printable_name (list, 0));
12178       parse_error_context 
12179         (wfl, "Can't access %s method `%s %s.%s' from `%s'",
12180          java_accstring_lookup (get_access_flags_from_decl (list)),
12181          lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
12182          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))), 
12183          fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
12184       free (fct_name);
12185       PATCH_METHOD_RETURN_ERROR ();
12186     }
12187   check_deprecation (wfl, list);
12188
12189   /* If invoking a innerclass constructor, there are hidden parameters
12190      to pass */
12191   if (TREE_CODE (patch) == NEW_CLASS_EXPR 
12192       && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12193     {
12194       /* And make sure we add the accessed local variables to be saved
12195          in field aliases. */
12196       args = build_alias_initializer_parameter_list
12197         (AIPL_FUNCTION_CTOR_INVOCATION, DECL_CONTEXT (list), args, NULL);
12198
12199       /* We have to reverse things. Find out why. FIXME */
12200       if (ANONYMOUS_CLASS_P (DECL_CONTEXT (list)))
12201         args = nreverse (args);
12202       
12203       /* Secretely pass the current_this/primary as a second argument */
12204       if (primary || current_this)
12205         args = tree_cons (NULL_TREE, (primary ? primary : current_this), args);
12206       else
12207         args = tree_cons (NULL_TREE, integer_zero_node, args);
12208     }
12209
12210   is_static_flag = METHOD_STATIC (list);
12211   if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
12212     args = tree_cons (NULL_TREE, this_arg, args);
12213
12214   /* In the context of an explicit constructor invocation, we can't
12215      invoke any method relying on `this'. Exceptions are: we're
12216      invoking a static function, primary exists and is not the current
12217      this, we're creating a new object. */
12218   if (ctxp->explicit_constructor_p 
12219       && !is_static_flag 
12220       && (!primary || primary == current_this)
12221       && (TREE_CODE (patch) != NEW_CLASS_EXPR))
12222     {
12223       parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
12224       PATCH_METHOD_RETURN_ERROR ();
12225     }
12226   java_parser_context_restore_global ();
12227   if (is_static) 
12228     *is_static = is_static_flag;
12229   /* Sometimes, we want the decl of the selected method. Such as for
12230      EH checking */
12231   if (ret_decl)
12232     *ret_decl = list;
12233   patch = patch_invoke (patch, list, args);
12234   if (is_super_init && CLASS_HAS_FINIT_P (current_class))
12235     {
12236       tree finit_parms, finit_call;
12237       
12238       /* Prepare to pass hidden parameters to $finit$, if any. */
12239       finit_parms = build_alias_initializer_parameter_list 
12240         (AIPL_FUNCTION_FINIT_INVOCATION, current_class, NULL_TREE, NULL);
12241
12242       finit_call = 
12243         build_method_invocation (build_wfl_node (finit_identifier_node),
12244                                  finit_parms);
12245
12246       /* Generate the code used to initialize fields declared with an
12247          initialization statement and build a compound statement along
12248          with the super constructor invocation. */
12249       patch = build (COMPOUND_EXPR, void_type_node, patch,
12250                      java_complete_tree (finit_call));
12251       CAN_COMPLETE_NORMALLY (patch) = 1;
12252     }
12253   return patch;
12254 }
12255
12256 /* Check that we're not trying to do a static reference to a method in
12257    non static method. Return 1 if it's the case, 0 otherwise. */
12258
12259 static int
12260 check_for_static_method_reference (wfl, node, method, where, primary)
12261      tree wfl, node, method, where, primary;
12262 {
12263   if (METHOD_STATIC (current_function_decl) 
12264       && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
12265     {
12266       char *fct_name = xstrdup (lang_printable_name (method, 0));
12267       parse_error_context 
12268         (wfl, "Can't make static reference to method `%s %s' in class `%s'", 
12269          lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
12270          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
12271       free (fct_name);
12272       return 1;
12273     }
12274   return 0;
12275 }
12276
12277 /* Fix the invocation of *MDECL if necessary in the case of a
12278    invocation from an inner class. *THIS_ARG might be modified
12279    appropriately and an alternative access to *MDECL might be
12280    returned.  */
12281
12282 static int
12283 maybe_use_access_method (is_super_init, mdecl, this_arg)
12284      int is_super_init;
12285      tree *mdecl, *this_arg;
12286 {
12287   tree ctx;
12288   tree md = *mdecl, ta = *this_arg;
12289   int to_return = 0;
12290   int non_static_context = !METHOD_STATIC (md);
12291
12292   if (is_super_init 
12293       || DECL_CONTEXT (md) == current_class
12294       || !PURE_INNER_CLASS_TYPE_P (current_class) 
12295       || DECL_FINIT_P (md))
12296     return 0;
12297   
12298   /* If we're calling a method found in an enclosing class, generate
12299      what it takes to retrieve the right this. Don't do that if we're
12300      invoking a static method. */
12301
12302   if (non_static_context)
12303     {
12304       ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
12305       if (ctx == DECL_CONTEXT (md))
12306         {
12307           ta = build_current_thisn (current_class);
12308           ta = build_wfl_node (ta);
12309         }
12310       else
12311         {
12312           tree type = ctx;
12313           while (type)
12314             {
12315               maybe_build_thisn_access_method (type);
12316               if (type == DECL_CONTEXT (md))
12317                 {
12318                   ta = build_access_to_thisn (ctx, type, 0);
12319                   break;
12320                 }
12321               type = (DECL_CONTEXT (TYPE_NAME (type)) ? 
12322                       TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))) : NULL_TREE);
12323             }
12324         }
12325       ta = java_complete_tree (ta);
12326     }
12327
12328   /* We might have to use an access method to get to MD. We can
12329      break the method access rule as far as we're not generating
12330      bytecode */
12331   if (METHOD_PRIVATE (md) && flag_emit_class_files)
12332     {
12333       md = build_outer_method_access_method (md);
12334       to_return = 1;
12335     }
12336
12337   *mdecl = md;
12338   *this_arg = ta;
12339
12340   /* Returnin a non zero value indicates we were doing a non static
12341      method invokation that is now a static invocation. It will have
12342      callee displace `this' to insert it in the regular argument
12343      list. */
12344   return (non_static_context && to_return);
12345 }
12346
12347 /* Patch an invoke expression METHOD and ARGS, based on its invocation
12348    mode.  */
12349
12350 static tree
12351 patch_invoke (patch, method, args)
12352      tree patch, method, args;
12353 {
12354   tree dtable, func;
12355   tree original_call, t, ta;
12356
12357   /* Last step for args: convert build-in types. If we're dealing with
12358      a new TYPE() type call, the first argument to the constructor
12359      isn't found in the incomming argument list, but delivered by
12360      `new' */
12361   t = TYPE_ARG_TYPES (TREE_TYPE (method));
12362   if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12363     t = TREE_CHAIN (t);
12364   for (ta = args; t != end_params_node && ta; 
12365        t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
12366     if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
12367         TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
12368       TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
12369
12370   /* Resolve unresolved returned type isses */
12371   t = TREE_TYPE (TREE_TYPE (method));
12372   if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
12373     resolve_and_layout (TREE_TYPE (t), NULL);
12374
12375   if (flag_emit_class_files || flag_emit_xref)
12376     func = method;
12377   else
12378     {
12379       tree signature = build_java_signature (TREE_TYPE (method));
12380       switch (invocation_mode (method, CALL_USING_SUPER (patch)))
12381         {
12382         case INVOKE_VIRTUAL:
12383           dtable = invoke_build_dtable (0, args);
12384           func = build_invokevirtual (dtable, method);
12385           break;
12386
12387         case INVOKE_SUPER:
12388         case INVOKE_STATIC:
12389           func = build_known_method_ref (method, TREE_TYPE (method),
12390                                          DECL_CONTEXT (method),
12391                                          signature, args);
12392           break;
12393
12394         case INVOKE_INTERFACE:
12395           dtable = invoke_build_dtable (1, args);
12396           func = build_invokeinterface (dtable, method);
12397           break;
12398
12399         default:
12400           fatal ("internal error - unknown invocation_mode result");
12401         }
12402
12403       /* Ensure self_type is initialized, (invokestatic). FIXME */
12404       func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
12405     }
12406
12407   TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
12408   TREE_OPERAND (patch, 0) = func;
12409   TREE_OPERAND (patch, 1) = args;
12410   original_call = patch;
12411
12412   /* We're processing a `new TYPE ()' form. New is called an its
12413      returned value is the first argument to the constructor. We build
12414      a COMPOUND_EXPR and use saved expression so that the overall NEW
12415      expression value is a pointer to a newly created and initialized
12416      class. */
12417   if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
12418     {
12419       tree class = DECL_CONTEXT (method);
12420       tree c1, saved_new, size, new;
12421       if (flag_emit_class_files || flag_emit_xref)
12422         {
12423           TREE_TYPE (patch) = build_pointer_type (class);
12424           return patch;
12425         }
12426       if (!TYPE_SIZE (class))
12427         safe_layout_class (class);
12428       size = size_in_bytes (class);
12429       new = build (CALL_EXPR, promote_type (class),
12430                    build_address_of (alloc_object_node),
12431                    tree_cons (NULL_TREE, build_class_ref (class),
12432                               build_tree_list (NULL_TREE, 
12433                                                size_in_bytes (class))),
12434                    NULL_TREE);
12435       saved_new = save_expr (new);
12436       c1 = build_tree_list (NULL_TREE, saved_new);
12437       TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
12438       TREE_OPERAND (original_call, 1) = c1;
12439       TREE_SET_CODE (original_call, CALL_EXPR);
12440       patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
12441     }
12442   return patch;
12443 }
12444
12445 static int
12446 invocation_mode (method, super)
12447      tree method;
12448      int super;
12449 {
12450   int access = get_access_flags_from_decl (method);
12451
12452   if (super)
12453     return INVOKE_SUPER;
12454
12455   if (access & ACC_STATIC || access & ACC_FINAL || access & ACC_PRIVATE)
12456     return INVOKE_STATIC;
12457
12458   if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
12459     return INVOKE_STATIC;
12460   
12461   if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
12462     return INVOKE_INTERFACE;
12463   
12464   if (DECL_CONSTRUCTOR_P (method))
12465     return INVOKE_STATIC;
12466
12467   return INVOKE_VIRTUAL;
12468 }
12469
12470 /* Retrieve a refined list of matching methods. It covers the step
12471    15.11.2 (Compile-Time Step 2) */
12472
12473 static tree
12474 lookup_method_invoke (lc, cl, class, name, arg_list)
12475      int lc;
12476      tree cl;
12477      tree class, name, arg_list;
12478 {
12479   tree atl = end_params_node;           /* Arg Type List */
12480   tree method, signature, list, node;
12481   const char *candidates;               /* Used for error report */
12482   char *dup;
12483
12484   /* Fix the arguments */
12485   for (node = arg_list; node; node = TREE_CHAIN (node))
12486     {
12487       tree current_arg = TREE_TYPE (TREE_VALUE (node));
12488       /* Non primitive type may have to be resolved */
12489       if (!JPRIMITIVE_TYPE_P (current_arg))
12490         resolve_and_layout (current_arg, NULL_TREE);
12491       /* And promoted */
12492       if (TREE_CODE (current_arg) == RECORD_TYPE)
12493         current_arg = promote_type (current_arg);
12494       atl = tree_cons (NULL_TREE, current_arg, atl);
12495     }
12496
12497   /* Presto. If we're dealing with an anonymous class and a
12498      constructor call, generate the right constructor now, since we
12499      know the arguments' types. */
12500
12501   if (lc && ANONYMOUS_CLASS_P (class))
12502     craft_constructor (TYPE_NAME (class), atl);
12503
12504   /* Find all candidates and then refine the list, searching for the
12505      most specific method. */
12506   list = find_applicable_accessible_methods_list (lc, class, name, atl);
12507   list = find_most_specific_methods_list (list);
12508   if (list && !TREE_CHAIN (list))
12509     return TREE_VALUE (list);
12510
12511   /* Issue an error. List candidates if any. Candidates are listed
12512      only if accessible (non accessible methods may end-up here for
12513      the sake of a better error report). */
12514   candidates = NULL;
12515   if (list)
12516     {
12517       tree current;
12518       obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
12519       for (current = list; current; current = TREE_CHAIN (current))
12520         {
12521           tree cm = TREE_VALUE (current);
12522           char string [4096];
12523           if (!cm || not_accessible_p (class, cm, 0))
12524             continue;
12525           sprintf 
12526             (string, "  `%s' in `%s'%s",
12527              get_printable_method_name (cm),
12528              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
12529              (TREE_CHAIN (current) ? "\n" : ""));
12530           obstack_grow (&temporary_obstack, string, strlen (string));
12531         }
12532       obstack_1grow (&temporary_obstack, '\0');
12533       candidates = obstack_finish (&temporary_obstack);
12534     }
12535   /* Issue the error message */
12536   method = make_node (FUNCTION_TYPE);
12537   TYPE_ARG_TYPES (method) = atl;
12538   signature = build_java_argument_signature (method);
12539   dup = xstrdup (lang_printable_name (class, 0));
12540   parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
12541                        (lc ? "constructor" : "method"),
12542                        (lc ? dup : IDENTIFIER_POINTER (name)),
12543                        IDENTIFIER_POINTER (signature), dup,
12544                        (candidates ? candidates : ""));
12545   free (dup);
12546   return NULL_TREE;
12547 }
12548
12549 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
12550    when we're looking for a constructor. */
12551
12552 static tree
12553 find_applicable_accessible_methods_list (lc, class, name, arglist)
12554      int lc;
12555      tree class, name, arglist;
12556 {
12557   static int object_done = 0;
12558   tree list = NULL_TREE, all_list = NULL_TREE;
12559
12560   if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
12561     {
12562       load_class (class, 1);
12563       safe_layout_class (class);
12564     }
12565
12566   /* Search interfaces */
12567   if (CLASS_INTERFACE (TYPE_NAME (class)))
12568     {
12569       static struct hash_table t, *searched_interfaces = NULL;
12570       static int search_not_done = 0;
12571       int i, n;
12572       tree basetype_vec = TYPE_BINFO_BASETYPES (class);
12573
12574       /* Search in the hash table, otherwise create a new one if
12575          necessary and insert the new entry. */
12576
12577       if (searched_interfaces)
12578         {
12579           if (hash_lookup (searched_interfaces, 
12580                            (const hash_table_key) class, FALSE, NULL))
12581             return NULL;
12582         }
12583       else
12584         {
12585           hash_table_init (&t, hash_newfunc, java_hash_hash_tree_node,
12586                            java_hash_compare_tree_node);
12587           searched_interfaces = &t;
12588         }
12589
12590       hash_lookup (searched_interfaces, 
12591                    (const hash_table_key) class, TRUE, NULL);
12592
12593       search_applicable_methods_list (lc, TYPE_METHODS (class), 
12594                                       name, arglist, &list, &all_list);
12595       n = TREE_VEC_LENGTH (basetype_vec);
12596       for (i = 1; i < n; i++)
12597         {
12598           tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12599           tree rlist;
12600
12601           search_not_done++;
12602           rlist = find_applicable_accessible_methods_list (lc,  t, name, 
12603                                                            arglist);
12604           list = chainon (rlist, list);
12605           search_not_done--;
12606         }
12607
12608       /* We're done. Reset the searched interfaces list and finally search
12609          java.lang.Object */
12610       if (!search_not_done)
12611         {  
12612           if (!object_done)
12613             search_applicable_methods_list (lc, 
12614                                             TYPE_METHODS (object_type_node),
12615                                             name, arglist, &list, &all_list);
12616           hash_table_free (searched_interfaces);
12617           searched_interfaces = NULL;  
12618         }
12619     }
12620   /* Search classes */
12621   else
12622     {
12623       tree sc = class;
12624       int seen_inner_class = 0;
12625       search_applicable_methods_list (lc, TYPE_METHODS (class), 
12626                                       name, arglist, &list, &all_list);
12627
12628       /* We must search all interfaces of this class */
12629       if (!lc)
12630       {
12631         tree basetype_vec = TYPE_BINFO_BASETYPES (sc);
12632         int n = TREE_VEC_LENGTH (basetype_vec), i;
12633         object_done = 1;
12634         for (i = 1; i < n; i++)
12635           {
12636             tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12637             tree rlist;
12638             if (t != object_type_node)
12639               rlist = find_applicable_accessible_methods_list (lc, t,
12640                                                                name, arglist);
12641             list = chainon (rlist, list);
12642           }
12643         object_done = 0;
12644       }
12645
12646       /* Search enclosing context of inner classes before looking
12647          ancestors up. */
12648       while (!lc && INNER_CLASS_TYPE_P (class))
12649         {
12650           tree rlist;
12651           seen_inner_class = 1;
12652           class = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
12653           rlist = find_applicable_accessible_methods_list (lc, class, 
12654                                                            name, arglist);
12655           list = chainon (rlist, list);
12656         }
12657
12658       if (!lc && seen_inner_class 
12659           && TREE_TYPE (DECL_CONTEXT (TYPE_NAME (sc))) == CLASSTYPE_SUPER (sc))
12660         class = CLASSTYPE_SUPER (sc);
12661       else
12662         class = sc;
12663
12664       for (class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class)); 
12665         class; class = CLASSTYPE_SUPER (class))
12666        search_applicable_methods_list (lc, TYPE_METHODS (class), 
12667                                        name, arglist, &list, &all_list);
12668     }
12669
12670   /* Either return the list obtained or all selected (but
12671      inaccessible) methods for better error report. */
12672   return (!list ? all_list : list);
12673 }
12674
12675 /* Effectively search for the approriate method in method */
12676
12677 static void 
12678 search_applicable_methods_list (lc, method, name, arglist, list, all_list)
12679      int lc;
12680      tree method, name, arglist;
12681      tree *list, *all_list;
12682 {
12683   for (; method; method = TREE_CHAIN (method))
12684     {
12685       /* When dealing with constructor, stop here, otherwise search
12686          other classes */
12687       if (lc && !DECL_CONSTRUCTOR_P (method))
12688         continue;
12689       else if (!lc && (DECL_CONSTRUCTOR_P (method) 
12690                        || (GET_METHOD_NAME (method) != name)))
12691         continue;
12692           
12693       if (argument_types_convertible (method, arglist))
12694         {
12695           /* Retain accessible methods only */
12696           if (!not_accessible_p (DECL_CONTEXT (current_function_decl), 
12697                                  method, 0))
12698             *list = tree_cons (NULL_TREE, method, *list);
12699           else
12700             /* Also retain all selected method here */
12701             *all_list = tree_cons (NULL_TREE, method, *list);
12702         }
12703     }
12704 }    
12705
12706 /* 15.11.2.2 Choose the Most Specific Method */
12707
12708 static tree
12709 find_most_specific_methods_list (list)
12710      tree list;
12711 {
12712   int max = 0;
12713   tree current, new_list = NULL_TREE;
12714   for (current = list; current; current = TREE_CHAIN (current))
12715     {
12716       tree method;
12717       DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
12718
12719       for (method = list; method; method = TREE_CHAIN (method))
12720         {
12721           /* Don't test a method against itself */
12722           if (method == current)
12723             continue;
12724
12725           /* Compare arguments and location where method where declared */
12726           if (argument_types_convertible (TREE_VALUE (method), 
12727                                           TREE_VALUE (current))
12728               && valid_method_invocation_conversion_p 
12729                    (DECL_CONTEXT (TREE_VALUE (method)), 
12730                     DECL_CONTEXT (TREE_VALUE (current))))
12731             {
12732               int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
12733               max = (v > max ? v : max);
12734             }
12735         }
12736     }
12737
12738   /* Review the list and select the maximally specific methods */
12739   for (current = list; current; current = TREE_CHAIN (current))
12740     if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12741       new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12742
12743   /* If we have several and they're all abstract, just pick the
12744      closest one. */
12745
12746   if (new_list && TREE_CHAIN (new_list))
12747     {
12748       tree c;
12749       for (c = new_list; c && METHOD_ABSTRACT (TREE_VALUE (c)); 
12750            c = TREE_CHAIN (c))
12751         ;
12752       if (!c)
12753         {
12754           new_list = nreverse (new_list);
12755           TREE_CHAIN (new_list) = NULL_TREE;
12756         }
12757     }
12758
12759   /* If we can't find one, lower expectations and try to gather multiple
12760      maximally specific methods */
12761   while (!new_list && max)
12762     {
12763       while (--max > 0)
12764         {
12765           if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12766             new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12767         }
12768     }
12769
12770   return new_list;
12771 }
12772
12773 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
12774    converted by method invocation conversion (5.3) to the type of the
12775    corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
12776    to change less often than M1. */
12777
12778 static int
12779 argument_types_convertible (m1, m2_or_arglist)
12780     tree m1, m2_or_arglist;
12781 {
12782   static tree m2_arg_value = NULL_TREE;
12783   static tree m2_arg_cache = NULL_TREE;
12784
12785   register tree m1_arg, m2_arg;
12786
12787   SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
12788
12789   if (m2_arg_value == m2_or_arglist)
12790     m2_arg = m2_arg_cache;
12791   else
12792     {
12793       /* M2_OR_ARGLIST can be a function DECL or a raw list of
12794          argument types */
12795       if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
12796         {
12797           m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
12798           if (!METHOD_STATIC (m2_or_arglist))
12799             m2_arg = TREE_CHAIN (m2_arg);
12800         }
12801       else
12802         m2_arg = m2_or_arglist;
12803
12804       m2_arg_value = m2_or_arglist;
12805       m2_arg_cache = m2_arg;
12806     }
12807
12808   while (m1_arg != end_params_node && m2_arg != end_params_node)
12809     {
12810       resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
12811       if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
12812                                                  TREE_VALUE (m2_arg)))
12813         break;
12814       m1_arg = TREE_CHAIN (m1_arg);
12815       m2_arg = TREE_CHAIN (m2_arg);
12816     }
12817   return m1_arg == end_params_node && m2_arg == end_params_node;
12818 }
12819
12820 /* Qualification routines */
12821
12822 static void
12823 qualify_ambiguous_name (id)
12824      tree id;
12825 {
12826   tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
12827     saved_current_class;
12828   int again, super_found = 0, this_found = 0, new_array_found = 0;
12829   int code;
12830
12831   /* We first qualify the first element, then derive qualification of
12832      others based on the first one. If the first element is qualified
12833      by a resolution (field or type), this resolution is stored in the
12834      QUAL_RESOLUTION of the qual element being examined. We need to
12835      save the current_class since the use of SUPER might change the
12836      its value. */
12837   saved_current_class = current_class;
12838   qual = EXPR_WFL_QUALIFICATION (id);
12839   do {
12840
12841     /* Simple qualified expression feature a qual_wfl that is a
12842        WFL. Expression derived from a primary feature more complicated
12843        things like a CALL_EXPR. Expression from primary need to be
12844        worked out to extract the part on which the qualification will
12845        take place. */
12846     qual_wfl = QUAL_WFL (qual);
12847     switch (TREE_CODE (qual_wfl))
12848       {
12849       case CALL_EXPR:
12850         qual_wfl = TREE_OPERAND (qual_wfl, 0);
12851         if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
12852           {
12853             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
12854             qual_wfl = QUAL_WFL (qual);
12855           }
12856         break;
12857       case NEW_ARRAY_EXPR:
12858       case NEW_ANONYMOUS_ARRAY_EXPR:
12859         qual = TREE_CHAIN (qual);
12860         again = new_array_found = 1;
12861         continue;
12862       case CONVERT_EXPR:
12863         break;
12864       case NEW_CLASS_EXPR:
12865         qual_wfl = TREE_OPERAND (qual_wfl, 0);
12866         break;
12867       case ARRAY_REF:
12868         while (TREE_CODE (qual_wfl) == ARRAY_REF)
12869           qual_wfl = TREE_OPERAND (qual_wfl, 0);
12870         break;
12871       case STRING_CST:
12872         qual = TREE_CHAIN (qual);
12873         qual_wfl = QUAL_WFL (qual);
12874         break;
12875       case CLASS_LITERAL:
12876         qual = TREE_CHAIN (qual);
12877         qual_wfl = QUAL_WFL (qual);
12878       break;
12879       default:
12880         /* Fix for -Wall. Just break doing nothing */
12881         break;
12882       }
12883
12884     ptr_type = current_class;
12885     again = 0;
12886     code = TREE_CODE (qual_wfl);
12887
12888     /* Pos evaluation: non WFL leading expression nodes */
12889     if (code == CONVERT_EXPR
12890         && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
12891       name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
12892
12893     else if (code == INTEGER_CST)
12894       name = qual_wfl;
12895     
12896     else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
12897              TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
12898       name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
12899
12900     else if (code == TREE_LIST)
12901       name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
12902
12903     else if (code == STRING_CST || code == CONDITIONAL_EXPR 
12904              || code == PLUS_EXPR)
12905       {
12906         qual = TREE_CHAIN (qual);
12907         qual_wfl = QUAL_WFL (qual);
12908         again = 1;
12909       }
12910     else 
12911       {
12912         name = EXPR_WFL_NODE (qual_wfl);
12913         if (!name)
12914           {
12915             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
12916             again = 1;
12917           }
12918       }
12919
12920     /* If we have a THIS (from a primary), we set the context accordingly */
12921     if (name == this_identifier_node)
12922       {
12923         qual = TREE_CHAIN (qual);
12924         qual_wfl = QUAL_WFL (qual);
12925         if (TREE_CODE (qual_wfl) == CALL_EXPR)
12926           again = 1;
12927         else
12928           name = EXPR_WFL_NODE (qual_wfl);
12929         this_found = 1;
12930       }
12931     /* If we have a SUPER, we set the context accordingly */
12932     if (name == super_identifier_node)
12933       {
12934         current_class = CLASSTYPE_SUPER (ptr_type);
12935         /* Check that there is such a thing as a super class. If not,
12936            return.  The error will be caught later on, during the
12937            resolution */
12938         if (!current_class)
12939           {
12940             current_class = saved_current_class;
12941             return;
12942           }
12943         qual = TREE_CHAIN (qual);
12944         /* Do one more interation to set things up */
12945         super_found = again = 1;
12946       }
12947   } while (again);
12948   
12949   /* If name appears within the scope of a local variable declaration
12950      or parameter declaration, then it is an expression name. We don't
12951      carry this test out if we're in the context of the use of SUPER
12952      or THIS */
12953   if (!this_found && !super_found 
12954       && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
12955       && (decl = IDENTIFIER_LOCAL_VALUE (name)))
12956     {
12957       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12958       QUAL_RESOLUTION (qual) = decl;
12959     }
12960
12961   /* If within the class/interface NAME was found to be used there
12962      exists a (possibly inherited) field named NAME, then this is an
12963      expression name. If we saw a NEW_ARRAY_EXPR before and want to
12964      address length, it is OK. */
12965   else if ((decl = lookup_field_wrapper (ptr_type, name))
12966            || (new_array_found && name == length_identifier_node))
12967     {
12968       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12969       QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
12970     }
12971
12972   /* We reclassify NAME as yielding to a type name resolution if:
12973      - NAME is a class/interface declared within the compilation
12974        unit containing NAME,
12975      - NAME is imported via a single-type-import declaration,
12976      - NAME is declared in an another compilation unit of the package
12977        of the compilation unit containing NAME,
12978      - NAME is declared by exactly on type-import-on-demand declaration
12979      of the compilation unit containing NAME. 
12980      - NAME is actually a STRING_CST. */
12981   else if (TREE_CODE (name) == STRING_CST || TREE_CODE (name) == INTEGER_CST
12982            || (decl = resolve_and_layout (name, NULL_TREE)))
12983     {
12984       RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
12985       QUAL_RESOLUTION (qual) = decl;
12986     }
12987
12988   /* Method call, array references and cast are expression name */
12989   else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
12990            || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
12991            || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
12992     RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12993
12994   /* Check here that NAME isn't declared by more than one
12995      type-import-on-demand declaration of the compilation unit
12996      containing NAME. FIXME */
12997
12998   /* Otherwise, NAME is reclassified as a package name */
12999   else 
13000     RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
13001
13002   /* Propagate the qualification accross other components of the
13003      qualified name */
13004   for (qual = TREE_CHAIN (qual); qual;
13005        qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
13006     {
13007       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13008         RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
13009       else 
13010         RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
13011     }
13012
13013   /* Store the global qualification for the ambiguous part of ID back
13014      into ID fields */
13015   if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
13016     RESOLVE_EXPRESSION_NAME_P (id) = 1;
13017   else if (RESOLVE_TYPE_NAME_P (qual_wfl))
13018     RESOLVE_TYPE_NAME_P (id) = 1;
13019   else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13020     RESOLVE_PACKAGE_NAME_P (id) = 1;
13021
13022   /* Restore the current class */
13023   current_class = saved_current_class;
13024 }
13025
13026 static int
13027 breakdown_qualified (left, right, source)
13028     tree *left, *right, source;
13029 {
13030   char *p = IDENTIFIER_POINTER (source), *base;
13031   int   l = IDENTIFIER_LENGTH (source);
13032
13033   /* Breakdown NAME into REMAINDER . IDENTIFIER */
13034   base = p;
13035   p += (l-1);
13036   while (*p != '.' && p != base)
13037     p--;
13038
13039   /* We didn't find a '.'. Return an error */
13040   if (p == base)
13041     return 1;
13042
13043   *p = '\0';
13044   if (right)
13045     *right = get_identifier (p+1);
13046   *left = get_identifier (IDENTIFIER_POINTER (source));
13047   *p = '.';
13048   
13049   return 0;
13050 }
13051
13052 /* Patch tree nodes in a function body. When a BLOCK is found, push
13053    local variable decls if present.
13054    Same as java_complete_lhs, but does resolve static finals to values. */
13055
13056 static tree
13057 java_complete_tree (node)
13058      tree node;
13059 {
13060   node = java_complete_lhs (node);
13061   if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
13062       && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
13063       && !flag_emit_xref)
13064     {
13065       tree value = DECL_INITIAL (node);
13066       DECL_INITIAL (node) = NULL_TREE;
13067       push_obstacks (&permanent_obstack, &permanent_obstack);
13068       value = fold_constant_for_init (value, node);
13069       pop_obstacks ();
13070       DECL_INITIAL (node) = value;
13071       if (value != NULL_TREE)
13072         {
13073           /* fold_constant_for_init sometimes widen the original type
13074              of the constant (i.e. byte to int.) It's not desirable,
13075              especially if NODE is a function argument. */
13076           if (TREE_CODE (value) == INTEGER_CST
13077               && TREE_TYPE (node) != TREE_TYPE (value))
13078             return convert (TREE_TYPE (node), value);
13079           else
13080             return value;
13081         }
13082     }
13083   return node;
13084 }
13085
13086 static tree
13087 java_stabilize_reference (node)
13088      tree node;
13089 {
13090   if (TREE_CODE (node) == COMPOUND_EXPR)
13091     {
13092       tree op0 = TREE_OPERAND (node, 0);
13093       tree op1 = TREE_OPERAND (node, 1);
13094       TREE_OPERAND (node, 0) = save_expr (op0);
13095       TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
13096       return node;
13097     }
13098   return stabilize_reference (node);
13099 }
13100
13101 /* Patch tree nodes in a function body. When a BLOCK is found, push
13102    local variable decls if present.
13103    Same as java_complete_tree, but does not resolve static finals to values. */
13104
13105 static tree
13106 java_complete_lhs (node)
13107      tree node;
13108 {
13109   tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
13110   int flag;
13111
13112   /* CONVERT_EXPR always has its type set, even though it needs to be
13113      worked out. */
13114   if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
13115     return node;
13116
13117   /* The switch block implements cases processing container nodes
13118      first.  Contained nodes are always written back. Leaves come
13119      next and return a value. */
13120   switch (TREE_CODE (node))
13121     {
13122     case BLOCK:
13123
13124       /* 1- Block section.
13125          Set the local values on decl names so we can identify them
13126          faster when they're referenced. At that stage, identifiers
13127          are legal so we don't check for declaration errors. */
13128       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13129         {
13130           DECL_CONTEXT (cn) = current_function_decl;
13131           IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
13132         }
13133       if (BLOCK_EXPR_BODY (node) == NULL_TREE)
13134           CAN_COMPLETE_NORMALLY (node) = 1;
13135       else
13136         {
13137           tree stmt = BLOCK_EXPR_BODY (node);
13138           tree *ptr;
13139           int error_seen = 0;
13140           if (TREE_CODE (stmt) == COMPOUND_EXPR)
13141             {
13142               /* Re-order from (((A; B); C); ...; Z) to 
13143                  (A; (B; (C ; (...; Z)))).
13144                  This makes it easier to scan the statements left-to-right
13145                  without using recursion (which might overflow the stack
13146                  if the block has many statements. */
13147               for (;;)
13148                 {
13149                   tree left = TREE_OPERAND (stmt, 0);
13150                   if (TREE_CODE (left) != COMPOUND_EXPR)
13151                     break;
13152                   TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
13153                   TREE_OPERAND (left, 1) = stmt;
13154                   stmt = left;
13155                 }
13156               BLOCK_EXPR_BODY (node) = stmt;
13157             }
13158
13159           /* Now do the actual complete, without deep recursion for
13160              long blocks. */
13161           ptr = &BLOCK_EXPR_BODY (node);
13162           while (TREE_CODE (*ptr) == COMPOUND_EXPR
13163                  && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
13164             {
13165               tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
13166               tree *next = &TREE_OPERAND (*ptr, 1);
13167               TREE_OPERAND (*ptr, 0) = cur;
13168               if (cur == empty_stmt_node)
13169                 {
13170                   /* Optimization;  makes it easier to detect empty bodies.
13171                      Most useful for <clinit> with all-constant initializer. */
13172                   *ptr = *next;
13173                   continue;
13174                 }
13175               if (TREE_CODE (cur) == ERROR_MARK)
13176                 error_seen++;
13177               else if (! CAN_COMPLETE_NORMALLY (cur))
13178                 {
13179                   wfl_op2 = *next;
13180                   for (;;)
13181                     {
13182                       if (TREE_CODE (wfl_op2) == BLOCK)
13183                         wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
13184                       else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
13185                         wfl_op2 = TREE_OPERAND (wfl_op2, 0);
13186                       else
13187                         break;
13188                     }
13189                   if (TREE_CODE (wfl_op2) != CASE_EXPR
13190                       && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
13191                     unreachable_stmt_error (*ptr);
13192                 }
13193               ptr = next;
13194             }
13195           *ptr = java_complete_tree (*ptr);
13196
13197           if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
13198             return error_mark_node;
13199           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
13200         }
13201       /* Turn local bindings to null */
13202       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13203         IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
13204
13205       TREE_TYPE (node) = void_type_node;
13206       break;
13207
13208       /* 2- They are expressions but ultimately deal with statements */
13209
13210     case THROW_EXPR:
13211       wfl_op1 = TREE_OPERAND (node, 0);
13212       COMPLETE_CHECK_OP_0 (node);
13213       /* 14.19 A throw statement cannot complete normally. */
13214       CAN_COMPLETE_NORMALLY (node) = 0;
13215       return patch_throw_statement (node, wfl_op1);
13216
13217     case SYNCHRONIZED_EXPR:
13218       wfl_op1 = TREE_OPERAND (node, 0);
13219       return patch_synchronized_statement (node, wfl_op1);
13220
13221     case TRY_EXPR:
13222       return patch_try_statement (node);
13223
13224     case TRY_FINALLY_EXPR:
13225       COMPLETE_CHECK_OP_0 (node);
13226       COMPLETE_CHECK_OP_1 (node);
13227       CAN_COMPLETE_NORMALLY (node)
13228         = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
13229            && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
13230       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
13231       return node;
13232
13233     case CLEANUP_POINT_EXPR:
13234       COMPLETE_CHECK_OP_0 (node);
13235       TREE_TYPE (node) = void_type_node;
13236       CAN_COMPLETE_NORMALLY (node) = 
13237         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13238       return node;
13239
13240     case WITH_CLEANUP_EXPR:
13241       COMPLETE_CHECK_OP_0 (node);
13242       COMPLETE_CHECK_OP_2 (node);
13243       CAN_COMPLETE_NORMALLY (node) = 
13244         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13245       TREE_TYPE (node) = void_type_node;
13246       return node;
13247
13248     case LABELED_BLOCK_EXPR:
13249       PUSH_LABELED_BLOCK (node);
13250       if (LABELED_BLOCK_BODY (node))
13251         COMPLETE_CHECK_OP_1 (node);
13252       TREE_TYPE (node) = void_type_node;
13253       POP_LABELED_BLOCK ();
13254
13255       if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
13256         {
13257           LABELED_BLOCK_BODY (node) = NULL_TREE;
13258           CAN_COMPLETE_NORMALLY (node) = 1;
13259         }
13260       else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
13261         CAN_COMPLETE_NORMALLY (node) = 1;
13262       return node;
13263
13264     case EXIT_BLOCK_EXPR:
13265       /* We don't complete operand 1, because it's the return value of
13266          the EXIT_BLOCK_EXPR which doesn't exist it Java */
13267       return patch_bc_statement (node);
13268
13269     case CASE_EXPR:
13270       cn = java_complete_tree (TREE_OPERAND (node, 0));
13271       if (cn == error_mark_node)
13272         return cn;
13273
13274       /* First, the case expression must be constant. Values of final
13275          fields are accepted. */
13276       cn = fold (cn);
13277       if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
13278           && JDECL_P (TREE_OPERAND (cn, 1))
13279           && FIELD_FINAL (TREE_OPERAND (cn, 1))
13280           && DECL_INITIAL (TREE_OPERAND (cn, 1)))
13281         {
13282           push_obstacks (&permanent_obstack, &permanent_obstack);
13283           cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
13284                                        TREE_OPERAND (cn, 1));
13285           pop_obstacks ();
13286         }
13287
13288       if (!TREE_CONSTANT (cn) && !flag_emit_xref)
13289         {
13290           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13291           parse_error_context (node, "Constant expression required");
13292           return error_mark_node;
13293         }
13294
13295       nn = ctxp->current_loop;
13296
13297       /* It must be assignable to the type of the switch expression. */
13298       if (!try_builtin_assignconv (NULL_TREE, 
13299                                    TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
13300         {
13301           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13302           parse_error_context 
13303             (wfl_operator,
13304              "Incompatible type for case. Can't convert `%s' to `int'",
13305              lang_printable_name (TREE_TYPE (cn), 0));
13306           return error_mark_node;
13307         }
13308
13309       cn = fold (convert (int_type_node, cn));
13310
13311       /* Multiple instance of a case label bearing the same
13312          value is checked during code generation. The case
13313          expression is allright so far. */
13314       TREE_OPERAND (node, 0) = cn;
13315       TREE_TYPE (node) = void_type_node;
13316       CAN_COMPLETE_NORMALLY (node) = 1;
13317       TREE_SIDE_EFFECTS (node) = 1;
13318       break;
13319
13320     case DEFAULT_EXPR:
13321       nn = ctxp->current_loop;
13322       /* Only one default label is allowed per switch statement */
13323       if (SWITCH_HAS_DEFAULT (nn))
13324         {
13325           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13326           parse_error_context (wfl_operator, 
13327                                "Duplicate case label: `default'");
13328           return error_mark_node;
13329         }
13330       else
13331         SWITCH_HAS_DEFAULT (nn) = 1;
13332       TREE_TYPE (node) = void_type_node;
13333       TREE_SIDE_EFFECTS (node) = 1;
13334       CAN_COMPLETE_NORMALLY (node) = 1;
13335       break;
13336
13337     case SWITCH_EXPR:
13338     case LOOP_EXPR:
13339       PUSH_LOOP (node);
13340       /* Check whether the loop was enclosed in a labeled
13341          statement. If not, create one, insert the loop in it and
13342          return the node */
13343       nn = patch_loop_statement (node);
13344
13345       /* Anyways, walk the body of the loop */
13346       if (TREE_CODE (node) == LOOP_EXPR)
13347         TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13348       /* Switch statement: walk the switch expression and the cases */
13349       else
13350         node = patch_switch_statement (node);
13351
13352       if (TREE_OPERAND (node, 0) == error_mark_node)
13353         nn = error_mark_node;
13354       else
13355         {
13356           TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
13357           /* If we returned something different, that's because we
13358              inserted a label. Pop the label too. */
13359           if (nn != node)
13360             {
13361               if (CAN_COMPLETE_NORMALLY (node))
13362                 CAN_COMPLETE_NORMALLY (nn) = 1;
13363               POP_LABELED_BLOCK ();
13364             }
13365         }
13366       POP_LOOP ();
13367       return nn;
13368
13369     case EXIT_EXPR:
13370       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13371       return patch_exit_expr (node);
13372
13373     case COND_EXPR:
13374       /* Condition */
13375       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13376       if (TREE_OPERAND (node, 0) == error_mark_node)
13377         return error_mark_node;
13378       /* then-else branches */
13379       TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13380       if (TREE_OPERAND (node, 1) == error_mark_node)
13381         return error_mark_node;
13382       TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
13383       if (TREE_OPERAND (node, 2) == error_mark_node)
13384         return error_mark_node;
13385       return patch_if_else_statement (node);
13386       break;
13387
13388     case CONDITIONAL_EXPR:
13389       /* Condition */
13390       wfl_op1 = TREE_OPERAND (node, 0);
13391       COMPLETE_CHECK_OP_0 (node);
13392       wfl_op2 = TREE_OPERAND (node, 1);
13393       COMPLETE_CHECK_OP_1 (node);
13394       wfl_op3 = TREE_OPERAND (node, 2);
13395       COMPLETE_CHECK_OP_2 (node);
13396       return patch_conditional_expr (node, wfl_op1, wfl_op2);
13397
13398       /* 3- Expression section */
13399     case COMPOUND_EXPR:
13400       wfl_op2 = TREE_OPERAND (node, 1);
13401       TREE_OPERAND (node, 0) = nn = 
13402         java_complete_tree (TREE_OPERAND (node, 0));
13403       if (wfl_op2 == empty_stmt_node)
13404         CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
13405       else
13406         {
13407           if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
13408             {
13409               /* An unreachable condition in a do-while statement
13410                  is *not* (technically) an unreachable statement. */
13411               nn = wfl_op2;
13412               if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
13413                 nn = EXPR_WFL_NODE (nn);
13414               if (TREE_CODE (nn) != EXIT_EXPR)
13415                 {
13416                   SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
13417                   parse_error_context (wfl_operator, "Unreachable statement");
13418                 }
13419             }
13420           TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13421           if (TREE_OPERAND (node, 1) == error_mark_node)
13422             return error_mark_node;
13423           CAN_COMPLETE_NORMALLY (node)
13424             = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
13425         }
13426       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
13427       break;
13428
13429     case RETURN_EXPR:
13430       /* CAN_COMPLETE_NORMALLY (node) = 0; */
13431       return patch_return (node);
13432
13433     case EXPR_WITH_FILE_LOCATION:
13434       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
13435           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
13436         {
13437           tree wfl = node;
13438           node = resolve_expression_name (node, NULL);
13439           if (node == error_mark_node)
13440             return node;
13441           /* Keep line number information somewhere were it doesn't
13442              disrupt the completion process. */
13443           if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
13444             {
13445               EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
13446               TREE_OPERAND (node, 1) = wfl;
13447             }
13448           CAN_COMPLETE_NORMALLY (node) = 1;
13449         }
13450       else
13451         {
13452           tree body;
13453           int save_lineno = lineno;
13454           lineno = EXPR_WFL_LINENO (node);
13455           body = java_complete_tree (EXPR_WFL_NODE (node));
13456           lineno = save_lineno;
13457           EXPR_WFL_NODE (node) = body;
13458           TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
13459           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
13460           if (body == empty_stmt_node)
13461             {
13462               /* Optimization;  makes it easier to detect empty bodies. */
13463               return body;
13464             }
13465           if (body == error_mark_node)
13466             {
13467               /* Its important for the evaluation of assignment that
13468                  this mark on the TREE_TYPE is propagated. */
13469               TREE_TYPE (node) = error_mark_node;
13470               return error_mark_node;
13471             }
13472           else
13473             TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
13474           
13475         }
13476       break;
13477
13478     case NEW_ARRAY_EXPR:
13479       /* Patch all the dimensions */
13480       flag = 0;
13481       for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13482         {
13483           int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
13484           tree dim = convert (int_type_node, 
13485                               java_complete_tree (TREE_VALUE (cn)));
13486           if (dim == error_mark_node)
13487             {
13488               flag = 1;
13489               continue;
13490             }
13491           else
13492             {
13493               TREE_VALUE (cn) = dim;
13494               /* Setup the location of the current dimension, for
13495                  later error report. */
13496               TREE_PURPOSE (cn) = 
13497                 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
13498               EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
13499             }
13500         }
13501       /* They complete the array creation expression, if no errors
13502          were found. */
13503       CAN_COMPLETE_NORMALLY (node) = 1;
13504       return (flag ? error_mark_node
13505               : force_evaluation_order (patch_newarray (node)));
13506
13507     case NEW_ANONYMOUS_ARRAY_EXPR:
13508       /* Create the array type if necessary. */
13509       if (ANONYMOUS_ARRAY_DIMS_SIG (node))
13510         {
13511           tree type = ANONYMOUS_ARRAY_BASE_TYPE (node);
13512           if (!(type = resolve_type_during_patch (type)))
13513             return error_mark_node;
13514           type = build_array_from_name (type, NULL_TREE,
13515                                         ANONYMOUS_ARRAY_DIMS_SIG (node), NULL);
13516           ANONYMOUS_ARRAY_BASE_TYPE (node) = build_pointer_type (type);
13517         }
13518       node = patch_new_array_init (ANONYMOUS_ARRAY_BASE_TYPE (node),
13519                                    ANONYMOUS_ARRAY_INITIALIZER (node));
13520       if (node == error_mark_node)
13521         return error_mark_node;
13522       CAN_COMPLETE_NORMALLY (node) = 1;
13523       return node;
13524
13525     case NEW_CLASS_EXPR:
13526     case CALL_EXPR:
13527       /* Complete function's argument(s) first */
13528       if (complete_function_arguments (node))
13529         return error_mark_node;
13530       else
13531         {
13532           tree decl, wfl = TREE_OPERAND (node, 0);
13533           int in_this = CALL_THIS_CONSTRUCTOR_P (node);
13534
13535           node = patch_method_invocation (node, NULL_TREE, 
13536                                           NULL_TREE, 0, &decl);
13537           if (node == error_mark_node)
13538             return error_mark_node;
13539
13540           check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
13541           /* If we call this(...), register signature and positions */
13542           if (in_this)
13543             DECL_CONSTRUCTOR_CALLS (current_function_decl) = 
13544               tree_cons (wfl, decl, 
13545                          DECL_CONSTRUCTOR_CALLS (current_function_decl));
13546           CAN_COMPLETE_NORMALLY (node) = 1;
13547           return force_evaluation_order (node);
13548         }
13549
13550     case MODIFY_EXPR:
13551       /* Save potential wfls */
13552       wfl_op1 = TREE_OPERAND (node, 0);
13553       TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
13554       
13555       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
13556           && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
13557           && DECL_INITIAL (nn) != NULL_TREE)
13558         {
13559           tree value;
13560           
13561           push_obstacks (&permanent_obstack, &permanent_obstack);
13562           value = fold_constant_for_init (nn, nn);
13563           pop_obstacks ();
13564
13565           if (value != NULL_TREE)
13566             {
13567               tree type = TREE_TYPE (value);
13568               if (JPRIMITIVE_TYPE_P (type) || 
13569                   (type == string_ptr_type_node && ! flag_emit_class_files))
13570                 return empty_stmt_node;
13571             }
13572           DECL_INITIAL (nn) = NULL_TREE;
13573         }
13574       wfl_op2 = TREE_OPERAND (node, 1);
13575
13576       if (TREE_OPERAND (node, 0) == error_mark_node)
13577         return error_mark_node;
13578
13579       flag = COMPOUND_ASSIGN_P (wfl_op2);
13580       if (flag)
13581         {
13582           /* This might break when accessing outer field from inner
13583              class. TESTME, FIXME */
13584           tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0)); 
13585
13586           /* Hand stablize the lhs on both places */
13587           TREE_OPERAND (node, 0) = lvalue;
13588           TREE_OPERAND (TREE_OPERAND (node, 1), 0) = 
13589             (flag_emit_class_files ? lvalue : save_expr (lvalue));
13590
13591           /* 15.25.2.a: Left hand is not an array access. FIXME */
13592           /* Now complete the RHS. We write it back later on. */
13593           nn = java_complete_tree (TREE_OPERAND (node, 1));
13594
13595           if ((cn = patch_string (nn)))
13596             nn = cn;
13597
13598           /* The last part of the rewrite for E1 op= E2 is to have 
13599              E1 = (T)(E1 op E2), with T being the type of E1. */
13600           nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2), 
13601                                                TREE_TYPE (lvalue), nn));
13602
13603           /* 15.25.2.b: Left hand is an array access. FIXME */
13604         }
13605
13606       /* If we're about to patch a NEW_ARRAY_INIT, we call a special
13607          function to complete this RHS. Note that a NEW_ARRAY_INIT
13608          might have been already fully expanded if created as a result
13609          of processing an anonymous array initializer. We avoid doing
13610          the operation twice by testing whether the node already bears
13611          a type. */
13612       else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT && !TREE_TYPE (wfl_op2))
13613         nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
13614                                    TREE_OPERAND (node, 1));
13615       /* Otherwise we simply complete the RHS */
13616       else
13617         nn = java_complete_tree (TREE_OPERAND (node, 1));
13618
13619       if (nn == error_mark_node)
13620         return error_mark_node;
13621
13622       /* Write back the RHS as we evaluated it. */
13623       TREE_OPERAND (node, 1) = nn;
13624
13625       /* In case we're handling = with a String as a RHS, we need to
13626          produce a String out of the RHS (it might still be a
13627          STRING_CST or a StringBuffer at this stage */
13628       if ((nn = patch_string (TREE_OPERAND (node, 1))))
13629         TREE_OPERAND (node, 1) = nn;
13630
13631       if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
13632                                         TREE_OPERAND (node, 1))))
13633         {
13634           /* We return error_mark_node if outer_field_access_fix
13635              detects we write into a final. */
13636           if (nn == error_mark_node)
13637             return error_mark_node;
13638           node = nn;
13639         }
13640       else
13641         {
13642           node = patch_assignment (node, wfl_op1, wfl_op2);
13643           /* Reorganize the tree if necessary. */
13644           if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node)) 
13645                        || JSTRING_P (TREE_TYPE (node))))
13646             node = java_refold (node);
13647         }
13648       
13649       CAN_COMPLETE_NORMALLY (node) = 1;
13650       return node;
13651
13652     case MULT_EXPR:
13653     case PLUS_EXPR:
13654     case MINUS_EXPR:
13655     case LSHIFT_EXPR:
13656     case RSHIFT_EXPR:
13657     case URSHIFT_EXPR:
13658     case BIT_AND_EXPR:
13659     case BIT_XOR_EXPR:
13660     case BIT_IOR_EXPR:
13661     case TRUNC_MOD_EXPR:
13662     case TRUNC_DIV_EXPR:
13663     case RDIV_EXPR:
13664     case TRUTH_ANDIF_EXPR:
13665     case TRUTH_ORIF_EXPR:
13666     case EQ_EXPR: 
13667     case NE_EXPR:
13668     case GT_EXPR:
13669     case GE_EXPR:
13670     case LT_EXPR:
13671     case LE_EXPR:
13672       /* Operands 0 and 1 are WFL in certain cases only. patch_binop
13673          knows how to handle those cases. */
13674       wfl_op1 = TREE_OPERAND (node, 0);
13675       wfl_op2 = TREE_OPERAND (node, 1);
13676
13677       CAN_COMPLETE_NORMALLY (node) = 1;
13678       /* Don't complete string nodes if dealing with the PLUS operand. */
13679       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
13680         {
13681           nn = java_complete_tree (wfl_op1);
13682           if (nn == error_mark_node)
13683             return error_mark_node;
13684
13685           TREE_OPERAND (node, 0) = nn;
13686         }
13687       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
13688         {
13689           nn = java_complete_tree (wfl_op2);
13690           if (nn == error_mark_node)
13691             return error_mark_node;
13692
13693           TREE_OPERAND (node, 1) = nn;
13694         }
13695       return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
13696
13697     case INSTANCEOF_EXPR:
13698       wfl_op1 = TREE_OPERAND (node, 0);
13699       COMPLETE_CHECK_OP_0 (node);
13700       if (flag_emit_xref)
13701         {
13702           TREE_TYPE (node) = boolean_type_node;
13703           return node;
13704         }
13705       return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
13706
13707     case UNARY_PLUS_EXPR:
13708     case NEGATE_EXPR:
13709     case TRUTH_NOT_EXPR:
13710     case BIT_NOT_EXPR:
13711     case PREDECREMENT_EXPR:
13712     case PREINCREMENT_EXPR:
13713     case POSTDECREMENT_EXPR:
13714     case POSTINCREMENT_EXPR:
13715     case CONVERT_EXPR:
13716       /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
13717          how to handle those cases. */
13718       wfl_op1 = TREE_OPERAND (node, 0);
13719       CAN_COMPLETE_NORMALLY (node) = 1;
13720       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13721       if (TREE_OPERAND (node, 0) == error_mark_node)
13722         return error_mark_node;
13723       node = patch_unaryop (node, wfl_op1);
13724       CAN_COMPLETE_NORMALLY (node) = 1;
13725       break;
13726
13727     case ARRAY_REF:
13728       /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
13729          how to handle those cases. */
13730       wfl_op1 = TREE_OPERAND (node, 0);
13731       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13732       if (TREE_OPERAND (node, 0) == error_mark_node)
13733         return error_mark_node;
13734       if (!flag_emit_class_files && !flag_emit_xref)
13735         TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
13736       /* The same applies to wfl_op2 */
13737       wfl_op2 = TREE_OPERAND (node, 1);
13738       TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
13739       if (TREE_OPERAND (node, 1) == error_mark_node)
13740         return error_mark_node;
13741       if (!flag_emit_class_files && !flag_emit_xref)
13742         TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
13743       return patch_array_ref (node);
13744
13745     case RECORD_TYPE:
13746       return node;;
13747
13748     case COMPONENT_REF:
13749       /* The first step in the re-write of qualified name handling.  FIXME.
13750          So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
13751       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13752       if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
13753         {
13754           tree name = TREE_OPERAND (node, 1);
13755           tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
13756           if (field == NULL_TREE)
13757             {
13758               error ("missing static field `%s'", IDENTIFIER_POINTER (name));
13759               return error_mark_node;
13760             }
13761           if (! FIELD_STATIC (field))
13762             {
13763               error ("not a static field `%s'", IDENTIFIER_POINTER (name));
13764               return error_mark_node;
13765             }
13766           return field;
13767         }
13768       else
13769         fatal ("unimplemented java_complete_tree for COMPONENT_REF");
13770       break;
13771
13772     case THIS_EXPR:
13773       /* Can't use THIS in a static environment */
13774       if (!current_this)
13775         {
13776           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13777           parse_error_context (wfl_operator,
13778                                "Keyword `this' used outside allowed context");
13779           TREE_TYPE (node) = error_mark_node;
13780           return error_mark_node;
13781         }
13782       if (ctxp->explicit_constructor_p)
13783         {
13784           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13785           parse_error_context 
13786             (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
13787           TREE_TYPE (node) = error_mark_node;
13788           return error_mark_node;
13789         }
13790       return current_this;
13791       
13792     case CLASS_LITERAL:
13793       CAN_COMPLETE_NORMALLY (node) = 1;
13794       node = patch_incomplete_class_ref (node);
13795       if (node == error_mark_node)
13796         return error_mark_node;
13797       break;
13798
13799     case INSTANCE_INITIALIZERS_EXPR:
13800       in_instance_initializer++;
13801       node = java_complete_tree (TREE_OPERAND (node, 0));
13802       in_instance_initializer--;
13803       if (node != error_mark_node)
13804         TREE_TYPE (node) = void_type_node;
13805       else
13806         return error_mark_node;
13807       break;
13808
13809     default:
13810       CAN_COMPLETE_NORMALLY (node) = 1;
13811       /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
13812          and it's time to turn it into the appropriate String object */
13813       if ((nn = patch_string (node)))
13814         node = nn;
13815       else
13816         fatal ("No case for tree code `%s' - java_complete_tree\n",
13817                tree_code_name [TREE_CODE (node)]);
13818     }
13819   return node;
13820 }
13821
13822 /* Complete function call's argument. Return a non zero value is an
13823    error was found.  */
13824
13825 static int
13826 complete_function_arguments (node)
13827      tree node;
13828 {
13829   int flag = 0;
13830   tree cn;
13831
13832   ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13833   for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13834     {
13835       tree wfl = TREE_VALUE (cn), parm, temp;
13836       parm = java_complete_tree (wfl);
13837
13838       if (parm == error_mark_node)
13839         {
13840           flag = 1;
13841           continue;
13842         }
13843       /* If have a string literal that we haven't transformed yet or a
13844          crafted string buffer, as a result of use of the the String
13845          `+' operator. Build `parm.toString()' and expand it. */
13846       if ((temp = patch_string (parm)))
13847         parm = temp;
13848       /* Inline PRIMTYPE.TYPE read access */
13849       parm = maybe_build_primttype_type_ref (parm, wfl);
13850
13851       TREE_VALUE (cn) = parm;
13852     }
13853   ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13854   return flag;
13855 }
13856
13857 /* Sometimes (for loops and variable initialized during their
13858    declaration), we want to wrap a statement around a WFL and turn it
13859    debugable.  */
13860
13861 static tree
13862 build_debugable_stmt (location, stmt)
13863     int location;
13864     tree stmt;
13865 {
13866   if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
13867     {
13868       stmt = build_expr_wfl (stmt, input_filename, 0, 0);
13869       EXPR_WFL_LINECOL (stmt) = location;
13870     }
13871   JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
13872   return stmt;
13873 }
13874
13875 static tree
13876 build_expr_block (body, decls)
13877      tree body, decls;
13878 {
13879   tree node = make_node (BLOCK);
13880   BLOCK_EXPR_DECLS (node) = decls;
13881   BLOCK_EXPR_BODY (node) = body;
13882   if (body)
13883     TREE_TYPE (node) = TREE_TYPE (body);
13884   TREE_SIDE_EFFECTS (node) = 1;
13885   return node;
13886 }
13887
13888 /* Create a new function block and link it approriately to current
13889    function block chain */
13890
13891 static tree
13892 enter_block ()
13893 {
13894   return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
13895 }
13896
13897 /* Link block B supercontext to the previous block. The current
13898    function DECL is used as supercontext when enter_a_block is called
13899    for the first time for a given function. The current function body
13900    (DECL_FUNCTION_BODY) is set to be block B.  */
13901
13902 static tree
13903 enter_a_block (b)
13904      tree b;
13905 {
13906   tree fndecl = current_function_decl; 
13907
13908   if (!fndecl) {
13909     BLOCK_SUPERCONTEXT (b) = current_static_block;
13910     current_static_block = b;
13911   }
13912
13913   else if (!DECL_FUNCTION_BODY (fndecl))
13914     {
13915       BLOCK_SUPERCONTEXT (b) = fndecl;
13916       DECL_FUNCTION_BODY (fndecl) = b;
13917     }
13918   else
13919     {
13920       BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
13921       DECL_FUNCTION_BODY (fndecl) = b;
13922     }
13923   return b;
13924 }
13925
13926 /* Exit a block by changing the current function body
13927    (DECL_FUNCTION_BODY) to the current block super context, only if
13928    the block being exited isn't the method's top level one.  */
13929
13930 static tree
13931 exit_block ()
13932 {
13933   tree b;
13934   if (current_function_decl)
13935     {
13936       b = DECL_FUNCTION_BODY (current_function_decl);
13937       if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
13938         DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
13939     }
13940   else
13941     {
13942       b = current_static_block;
13943
13944       if (BLOCK_SUPERCONTEXT (b))
13945         current_static_block = BLOCK_SUPERCONTEXT (b);
13946     }
13947   return b;
13948 }
13949
13950 /* Lookup for NAME in the nested function's blocks, all the way up to
13951    the current toplevel one. It complies with Java's local variable
13952    scoping rules.  */
13953
13954 static tree
13955 lookup_name_in_blocks (name)
13956      tree name;
13957 {
13958   tree b = GET_CURRENT_BLOCK (current_function_decl);
13959
13960   while (b != current_function_decl)
13961     {
13962       tree current;
13963
13964       /* Paranoid sanity check. To be removed */
13965       if (TREE_CODE (b) != BLOCK)
13966         fatal ("non block expr function body - lookup_name_in_blocks");
13967
13968       for (current = BLOCK_EXPR_DECLS (b); current; 
13969            current = TREE_CHAIN (current))
13970         if (DECL_NAME (current) == name)
13971           return current;
13972       b = BLOCK_SUPERCONTEXT (b);
13973     }
13974   return NULL_TREE;
13975 }
13976
13977 static void
13978 maybe_absorb_scoping_blocks ()
13979 {
13980   while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
13981     {
13982       tree b = exit_block ();
13983       java_method_add_stmt (current_function_decl, b);
13984       SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
13985     }
13986 }
13987
13988 \f
13989 /* This section of the source is reserved to build_* functions that
13990    are building incomplete tree nodes and the patch_* functions that
13991    are completing them.  */
13992
13993 /* Wrap a non WFL node around a WFL.  */
13994 static tree
13995 build_wfl_wrap (node)
13996     tree node;
13997 {
13998   tree wfl, node_to_insert = node;
13999   
14000   /* We want to process THIS . xxx symbolicaly, to keep it consistent
14001      with the way we're processing SUPER. A THIS from a primary as a
14002      different form than a SUPER. Turn THIS into something symbolic */
14003   if (TREE_CODE (node) == THIS_EXPR)
14004     node_to_insert = wfl = build_wfl_node (this_identifier_node);
14005   else
14006     wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
14007
14008   EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (node);
14009   EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
14010   return wfl;
14011 }
14012
14013
14014 /* Build a super() constructor invocation. Returns empty_stmt_node if
14015    we're currently dealing with the class java.lang.Object. */
14016
14017 static tree
14018 build_super_invocation (mdecl)
14019      tree mdecl;
14020 {
14021   if (DECL_CONTEXT (mdecl) == object_type_node)
14022     return empty_stmt_node;
14023   else
14024     {
14025       tree super_wfl = build_wfl_node (super_identifier_node);
14026       tree a = NULL_TREE, t;
14027       /* If we're dealing with an anonymous class, pass the arguments
14028          of the crafted constructor along. */
14029       if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
14030         {
14031           SKIP_THIS_AND_ARTIFICIAL_PARMS (t, mdecl);
14032           for (; t != end_params_node; t = TREE_CHAIN (t))
14033             a = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (t)), a);
14034         }
14035       return build_method_invocation (super_wfl, a);
14036     }
14037 }
14038
14039 /* Build a SUPER/THIS qualified method invocation.  */
14040
14041 static tree
14042 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
14043      int use_this;
14044      tree name, args;
14045      int lloc, rloc;
14046 {
14047   tree invok;
14048   tree wfl = 
14049     build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
14050   EXPR_WFL_LINECOL (wfl) = lloc;
14051   invok = build_method_invocation (name, args);
14052   return make_qualified_primary (wfl, invok, rloc);
14053 }
14054
14055 /* Build an incomplete CALL_EXPR node. */
14056
14057 static tree
14058 build_method_invocation (name, args)
14059     tree name;
14060     tree args;
14061 {
14062   tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
14063   TREE_SIDE_EFFECTS (call) = 1;
14064   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14065   return call;
14066 }
14067
14068 /* Build an incomplete new xxx(...) node. */
14069
14070 static tree
14071 build_new_invocation (name, args)
14072     tree name, args;
14073 {
14074   tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
14075   TREE_SIDE_EFFECTS (call) = 1;
14076   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14077   return call;
14078 }
14079
14080 /* Build an incomplete assignment expression. */
14081
14082 static tree
14083 build_assignment (op, op_location, lhs, rhs)
14084      int op, op_location;
14085      tree lhs, rhs;
14086 {
14087   tree assignment;
14088   /* Build the corresponding binop if we deal with a Compound
14089      Assignment operator. Mark the binop sub-tree as part of a
14090      Compound Assignment expression */
14091   if (op != ASSIGN_TK)
14092     {
14093       rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
14094       COMPOUND_ASSIGN_P (rhs) = 1;
14095     }
14096   assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
14097   TREE_SIDE_EFFECTS (assignment) = 1;
14098   EXPR_WFL_LINECOL (assignment) = op_location;
14099   return assignment;
14100 }
14101
14102 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
14103
14104 char *
14105 print_int_node (node)
14106     tree node;
14107 {
14108   static char buffer [80];
14109   if (TREE_CONSTANT_OVERFLOW (node))
14110     sprintf (buffer, "<overflow>");
14111     
14112   if (TREE_INT_CST_HIGH (node) == 0)
14113     sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
14114              TREE_INT_CST_LOW (node));
14115   else if (TREE_INT_CST_HIGH (node) == -1
14116            && TREE_INT_CST_LOW (node) != 0)
14117     {
14118       buffer [0] = '-';
14119       sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
14120                -TREE_INT_CST_LOW (node));
14121     }
14122   else
14123     sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
14124              TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
14125
14126   return buffer;
14127 }
14128
14129 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
14130    context.  */
14131
14132 static int
14133 check_final_assignment (lvalue, wfl)
14134      tree lvalue, wfl;
14135 {
14136   if (TREE_CODE (lvalue) == COMPOUND_EXPR 
14137       && JDECL_P (TREE_OPERAND (lvalue, 1)))
14138     lvalue = TREE_OPERAND (lvalue, 1);
14139
14140   /* When generating class files, references to the `length' field
14141      look a bit different.  */
14142   if ((flag_emit_class_files
14143        && TREE_CODE (lvalue) == COMPONENT_REF
14144        && TYPE_ARRAY_P (TREE_TYPE (TREE_OPERAND (lvalue, 0)))
14145        && FIELD_FINAL (TREE_OPERAND (lvalue, 1)))
14146       || (TREE_CODE (lvalue) == FIELD_DECL
14147           && FIELD_FINAL (lvalue)
14148           && !DECL_CLINIT_P (current_function_decl)
14149           && !DECL_FINIT_P (current_function_decl)))
14150     {
14151       parse_error_context 
14152         (wfl, "Can't assign a value to the final variable `%s'",
14153          IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
14154       return 1;
14155     }
14156   return 0;
14157 }
14158
14159 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
14160    read. This is needed to avoid circularities in the implementation
14161    of these fields in libjava. */
14162
14163 static tree
14164 maybe_build_primttype_type_ref (rhs, wfl)
14165     tree rhs, wfl;
14166 {
14167   tree to_return = NULL_TREE;
14168   tree rhs_type = TREE_TYPE (rhs);
14169   if (TREE_CODE (rhs) == COMPOUND_EXPR)
14170     {
14171       tree n = TREE_OPERAND (rhs, 1);
14172       if (TREE_CODE (n) == VAR_DECL 
14173           && DECL_NAME (n) == TYPE_identifier_node
14174           && rhs_type == class_ptr_type)
14175         {
14176           const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
14177           if (!strncmp (self_name, "java.lang.", 10))
14178             to_return = build_primtype_type_ref (self_name);
14179         }
14180     }
14181   return (to_return ? to_return : rhs );
14182 }
14183
14184 /* 15.25 Assignment operators. */
14185
14186 static tree
14187 patch_assignment (node, wfl_op1, wfl_op2)
14188      tree node;
14189      tree wfl_op1;
14190      tree wfl_op2;
14191 {
14192   tree rhs = TREE_OPERAND (node, 1);
14193   tree lvalue = TREE_OPERAND (node, 0), llvalue;
14194   tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
14195   int error_found = 0;
14196   int lvalue_from_array = 0;
14197
14198   /* Can't assign to a (blank) final. */
14199   if (check_final_assignment (lvalue, wfl_op1))
14200     error_found = 1;
14201
14202   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14203
14204   /* Lhs can be a named variable */
14205   if (JDECL_P (lvalue))
14206     {
14207       lhs_type = TREE_TYPE (lvalue);
14208     }
14209   /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
14210      comment on reason why */
14211   else if (TREE_CODE (wfl_op1) == ARRAY_REF)
14212     {
14213       lhs_type = TREE_TYPE (lvalue);
14214       lvalue_from_array = 1;
14215     }
14216   /* Or a field access */
14217   else if (TREE_CODE (lvalue) == COMPONENT_REF)
14218     lhs_type = TREE_TYPE (lvalue);
14219   /* Or a function return slot */
14220   else if (TREE_CODE (lvalue) == RESULT_DECL)
14221     lhs_type = TREE_TYPE (lvalue);
14222   /* Otherwise, we might want to try to write into an optimized static
14223      final, this is an of a different nature, reported further on. */
14224   else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
14225            && resolve_expression_name (wfl_op1, &llvalue))
14226     {
14227       if (!error_found && check_final_assignment (llvalue, wfl_op1))
14228         {
14229           /* What we should do instead is resetting the all the flags
14230              previously set, exchange lvalue for llvalue and continue. */
14231           error_found = 1;
14232           return error_mark_node;
14233         }
14234       else 
14235         lhs_type = TREE_TYPE (lvalue);
14236     }
14237   else 
14238     {
14239       parse_error_context (wfl_op1, "Invalid left hand side of assignment");
14240       error_found = 1;
14241     }
14242
14243   rhs_type = TREE_TYPE (rhs);
14244   /* 5.1 Try the assignment conversion for builtin type. */
14245   new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
14246
14247   /* 5.2 If it failed, try a reference conversion */
14248   if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
14249     lhs_type = promote_type (rhs_type);
14250
14251   /* 15.25.2 If we have a compound assignment, convert RHS into the
14252      type of the LHS */
14253   else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14254     new_rhs = convert (lhs_type, rhs);
14255
14256   /* Explicit cast required. This is an error */
14257   if (!new_rhs)
14258     {
14259       char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
14260       char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
14261       tree wfl;
14262       char operation [32];      /* Max size known */
14263
14264       /* If the assignment is part of a declaration, we use the WFL of
14265          the declared variable to point out the error and call it a
14266          declaration problem. If the assignment is a genuine =
14267          operator, we call is a operator `=' problem, otherwise we
14268          call it an assignment problem. In both of these last cases,
14269          we use the WFL of the operator to indicate the error. */
14270
14271       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
14272         {
14273           wfl = wfl_op1;
14274           strcpy (operation, "declaration");
14275         }
14276       else
14277         {
14278           wfl = wfl_operator;
14279           if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14280             strcpy (operation, "assignment");
14281           else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
14282             strcpy (operation, "`return'");
14283           else
14284             strcpy (operation, "`='");
14285         }
14286
14287       if (!valid_cast_to_p (rhs_type, lhs_type))
14288         parse_error_context
14289           (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
14290            operation, t1, t2);
14291       else
14292         parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
14293                              operation, t1, t2);
14294       free (t1); free (t2);
14295       error_found = 1;
14296     }
14297
14298   /* Inline read access to java.lang.PRIMTYPE.TYPE */
14299   if (new_rhs)
14300     new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
14301
14302   if (error_found)
14303     return error_mark_node;
14304
14305   /* 10.10: Array Store Exception runtime check */
14306   if (!flag_emit_class_files
14307       && !flag_emit_xref
14308       && lvalue_from_array 
14309       && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
14310     {
14311       tree check;
14312       tree base = lvalue;
14313
14314       /* We need to retrieve the right argument for _Jv_CheckArrayStore */
14315       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14316         base = TREE_OPERAND (lvalue, 0);
14317       else
14318         {
14319           if (flag_bounds_check)
14320             base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
14321           else
14322             base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
14323         }
14324
14325       /* Build the invocation of _Jv_CheckArrayStore */
14326       new_rhs = save_expr (new_rhs);
14327       check = build (CALL_EXPR, void_type_node,
14328                      build_address_of (soft_checkarraystore_node),
14329                      tree_cons (NULL_TREE, base,
14330                                 build_tree_list (NULL_TREE, new_rhs)),
14331                      NULL_TREE);
14332       TREE_SIDE_EFFECTS (check) = 1;
14333
14334       /* We have to decide on an insertion point */
14335       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14336         {
14337           tree t;
14338           if (flag_bounds_check)
14339             {
14340               t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
14341               TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
14342                 build (COMPOUND_EXPR, void_type_node, t, check);
14343             }
14344           else
14345             TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
14346                                               check, TREE_OPERAND (lvalue, 1));
14347         }
14348       else 
14349         {
14350           /* Make sure the bound check will happen before the store check */
14351           if (flag_bounds_check)
14352             TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
14353               build (COMPOUND_EXPR, void_type_node,
14354                      TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
14355           else
14356             lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
14357         }
14358     }
14359
14360   TREE_OPERAND (node, 0) = lvalue;
14361   TREE_OPERAND (node, 1) = new_rhs;
14362   TREE_TYPE (node) = lhs_type;
14363   return node;
14364 }
14365
14366 /* Check that type SOURCE can be cast into type DEST. If the cast
14367    can't occur at all, return 0 otherwise 1. This function is used to
14368    produce accurate error messages on the reasons why an assignment
14369    failed. */
14370
14371 static tree
14372 try_reference_assignconv (lhs_type, rhs)
14373      tree lhs_type, rhs;
14374 {
14375   tree new_rhs = NULL_TREE;
14376   tree rhs_type = TREE_TYPE (rhs);
14377
14378   if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
14379     {
14380       /* `null' may be assigned to any reference type */
14381       if (rhs == null_pointer_node)
14382         new_rhs = null_pointer_node;
14383       /* Try the reference assignment conversion */
14384       else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
14385         new_rhs = rhs;
14386       /* This is a magic assignment that we process differently */
14387       else if (rhs == soft_exceptioninfo_call_node)
14388         new_rhs = rhs;
14389     }
14390   return new_rhs;
14391 }
14392
14393 /* Check that RHS can be converted into LHS_TYPE by the assignment
14394    conversion (5.2), for the cases of RHS being a builtin type. Return
14395    NULL_TREE if the conversion fails or if because RHS isn't of a
14396    builtin type. Return a converted RHS if the conversion is possible.  */
14397
14398 static tree
14399 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
14400      tree wfl_op1, lhs_type, rhs;
14401 {
14402   tree new_rhs = NULL_TREE;
14403   tree rhs_type = TREE_TYPE (rhs);
14404
14405   /* Zero accepted everywhere */
14406   if (TREE_CODE (rhs) == INTEGER_CST 
14407       && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
14408       && JPRIMITIVE_TYPE_P (rhs_type))
14409     new_rhs = convert (lhs_type, rhs);
14410
14411   /* 5.1.1 Try Identity Conversion,
14412      5.1.2 Try Widening Primitive Conversion */
14413   else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
14414     new_rhs = convert (lhs_type, rhs);
14415
14416   /* Try a narrowing primitive conversion (5.1.3): 
14417        - expression is a constant expression of type int AND
14418        - variable is byte, short or char AND
14419        - The value of the expression is representable in the type of the 
14420          variable */
14421   else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
14422            && (lhs_type == byte_type_node || lhs_type == char_type_node
14423                || lhs_type == short_type_node))
14424     {
14425       if (int_fits_type_p (rhs, lhs_type))
14426         new_rhs = convert (lhs_type, rhs);
14427       else if (wfl_op1)         /* Might be called with a NULL */
14428         parse_warning_context 
14429           (wfl_op1, "Constant expression `%s' to wide for narrowing primitive conversion to `%s'", 
14430            print_int_node (rhs), lang_printable_name (lhs_type, 0));
14431       /* Reported a warning that will turn into an error further
14432          down, so we don't return */
14433     }
14434
14435   return new_rhs;
14436 }
14437
14438 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
14439    conversion (5.1.1) or widening primitve conversion (5.1.2).  Return
14440    0 is the conversion test fails.  This implements parts the method
14441    invocation convertion (5.3).  */
14442
14443 static int
14444 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
14445      tree lhs_type, rhs_type;
14446 {
14447   /* 5.1.1: This is the identity conversion part. */
14448   if (lhs_type == rhs_type)
14449     return 1;
14450
14451   /* Reject non primitive types */
14452   if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
14453     return 0;
14454
14455   /* 5.1.2: widening primitive conversion. byte, even if it's smaller
14456      than a char can't be converted into a char. Short can't too, but
14457      the < test below takes care of that */
14458   if (lhs_type == char_type_node && rhs_type == byte_type_node)
14459     return 0;
14460
14461   /* Accept all promoted type here. Note, we can't use <= in the test
14462      below, because we still need to bounce out assignments of short
14463      to char and the likes */
14464   if (lhs_type == int_type_node
14465       && (rhs_type == promoted_byte_type_node
14466           || rhs_type == promoted_short_type_node
14467           || rhs_type == promoted_char_type_node
14468           || rhs_type == promoted_boolean_type_node))
14469     return 1;
14470
14471   /* From here, an integral is widened if its precision is smaller
14472      than the precision of the LHS or if the LHS is a floating point
14473      type, or the RHS is a float and the RHS a double. */
14474   if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type) 
14475        && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
14476       || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
14477       || (rhs_type == float_type_node && lhs_type == double_type_node))
14478     return 1;
14479
14480   return 0;
14481 }
14482
14483 /* Check that something of SOURCE type can be assigned or cast to
14484    something of DEST type at runtime. Return 1 if the operation is
14485    valid, 0 otherwise. If CAST is set to 1, we're treating the case
14486    were SOURCE is cast into DEST, which borrows a lot of the
14487    assignment check. */
14488
14489 static int
14490 valid_ref_assignconv_cast_p (source, dest, cast)
14491      tree source;
14492      tree dest;
14493      int cast;
14494 {
14495   /* SOURCE or DEST might be null if not from a declared entity. */
14496   if (!source || !dest)
14497     return 0;
14498   if (JNULLP_TYPE_P (source))
14499     return 1;
14500   if (TREE_CODE (source) == POINTER_TYPE)
14501     source = TREE_TYPE (source);
14502   if (TREE_CODE (dest) == POINTER_TYPE)
14503     dest = TREE_TYPE (dest);
14504   /* Case where SOURCE is a class type */
14505   if (TYPE_CLASS_P (source))
14506     {
14507       if (TYPE_CLASS_P (dest))
14508         return  (source == dest 
14509                  || inherits_from_p (source, dest)
14510                  || enclosing_context_p (dest, source /*source, dest*/)
14511                  || (cast && inherits_from_p (dest, source)));
14512       if (TYPE_INTERFACE_P (dest))
14513         {
14514           /* If doing a cast and SOURCE is final, the operation is
14515              always correct a compile time (because even if SOURCE
14516              does not implement DEST, a subclass of SOURCE might). */
14517           if (cast && !CLASS_FINAL (TYPE_NAME (source)))
14518             return 1;
14519           /* Otherwise, SOURCE must implement DEST */
14520           return interface_of_p (dest, source);
14521         }
14522       /* DEST is an array, cast permited if SOURCE is of Object type */
14523       return (cast && source == object_type_node ? 1 : 0);
14524     }
14525   if (TYPE_INTERFACE_P (source))
14526     {
14527       if (TYPE_CLASS_P (dest))
14528         {
14529           /* If not casting, DEST must be the Object type */
14530           if (!cast)
14531             return dest == object_type_node;
14532           /* We're doing a cast. The cast is always valid is class
14533              DEST is not final, otherwise, DEST must implement SOURCE */
14534           else if (!CLASS_FINAL (TYPE_NAME (dest)))
14535             return 1;
14536           else
14537             return interface_of_p (source, dest);
14538         }
14539       if (TYPE_INTERFACE_P (dest))
14540         {
14541           /* If doing a cast, then if SOURCE and DEST contain method
14542              with the same signature but different return type, then
14543              this is a (compile time) error */
14544           if (cast)
14545             {
14546               tree method_source, method_dest;
14547               tree source_type;
14548               tree source_sig;
14549               tree source_name;
14550               for (method_source = TYPE_METHODS (source); method_source; 
14551                    method_source = TREE_CHAIN (method_source))
14552                 {
14553                   source_sig = 
14554                     build_java_argument_signature (TREE_TYPE (method_source));
14555                   source_type = TREE_TYPE (TREE_TYPE (method_source));
14556                   source_name = DECL_NAME (method_source);
14557                   for (method_dest = TYPE_METHODS (dest);
14558                        method_dest; method_dest = TREE_CHAIN (method_dest))
14559                     if (source_sig == 
14560                         build_java_argument_signature (TREE_TYPE (method_dest))
14561                         && source_name == DECL_NAME (method_dest)
14562                         && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
14563                       return 0;
14564                 }
14565               return 1;
14566             }
14567           else
14568             return source == dest || interface_of_p (dest, source);
14569         }
14570       else                      /* Array */
14571         return (cast ? 
14572                 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
14573     }
14574   if (TYPE_ARRAY_P (source))
14575     {
14576       if (TYPE_CLASS_P (dest))
14577         return dest == object_type_node;
14578       /* Can't cast an array to an interface unless the interface is
14579          java.lang.Cloneable */
14580       if (TYPE_INTERFACE_P (dest))
14581         return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
14582       else                      /* Arrays */
14583         {
14584           tree source_element_type = TYPE_ARRAY_ELEMENT (source);
14585           tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
14586           
14587           /* In case of severe errors, they turn out null */
14588           if (!dest_element_type || !source_element_type)
14589             return 0;
14590           if (source_element_type == dest_element_type)
14591             return 1;
14592           return valid_ref_assignconv_cast_p (source_element_type,
14593                                               dest_element_type, cast);
14594         }
14595       return 0;
14596     }
14597   return 0;
14598 }
14599
14600 static int
14601 valid_cast_to_p (source, dest)
14602      tree source;
14603      tree dest;
14604 {
14605   if (TREE_CODE (source) == POINTER_TYPE)
14606     source = TREE_TYPE (source);
14607   if (TREE_CODE (dest) == POINTER_TYPE)
14608     dest = TREE_TYPE (dest);
14609
14610   if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
14611     return valid_ref_assignconv_cast_p (source, dest, 1);
14612
14613   else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
14614     return 1;
14615
14616   return 0;
14617 }
14618
14619 /* Method invocation conversion test. Return 1 if type SOURCE can be
14620    converted to type DEST through the methond invocation conversion
14621    process (5.3) */
14622
14623 static tree
14624 do_unary_numeric_promotion (arg)
14625      tree arg;
14626 {
14627   tree type = TREE_TYPE (arg);
14628   if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
14629       : TREE_CODE (type) == CHAR_TYPE)
14630     arg = convert (int_type_node, arg);
14631   return arg;
14632 }
14633
14634 /* Return a non zero value if SOURCE can be converted into DEST using
14635    the method invocation conversion rule (5.3).  */
14636 static int
14637 valid_method_invocation_conversion_p (dest, source)
14638      tree dest, source;
14639 {
14640   return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
14641            && valid_builtin_assignconv_identity_widening_p (dest, source))
14642           || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
14643               && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
14644               && valid_ref_assignconv_cast_p (source, dest, 0)));
14645 }
14646
14647 /* Build an incomplete binop expression. */
14648
14649 static tree
14650 build_binop (op, op_location, op1, op2)
14651      enum tree_code op;
14652      int op_location;
14653      tree op1, op2;
14654 {
14655   tree binop = build (op, NULL_TREE, op1, op2);
14656   TREE_SIDE_EFFECTS (binop) = 1;
14657   /* Store the location of the operator, for better error report. The
14658      string of the operator will be rebuild based on the OP value. */
14659   EXPR_WFL_LINECOL (binop) = op_location;
14660   return binop;
14661 }
14662
14663 /* Build the string of the operator retained by NODE. If NODE is part
14664    of a compound expression, add an '=' at the end of the string. This
14665    function is called when an error needs to be reported on an
14666    operator. The string is returned as a pointer to a static character
14667    buffer. */
14668
14669 static char *
14670 operator_string (node)
14671      tree node;
14672 {
14673 #define BUILD_OPERATOR_STRING(S)                                        \
14674   {                                                                     \
14675     sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
14676     return buffer;                                                      \
14677   }
14678   
14679   static char buffer [10];
14680   switch (TREE_CODE (node))
14681     {
14682     case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
14683     case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
14684     case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
14685     case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14686     case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
14687     case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
14688     case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
14689     case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
14690     case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
14691     case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
14692     case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
14693     case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
14694     case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
14695     case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
14696     case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
14697     case GT_EXPR: BUILD_OPERATOR_STRING (">");
14698     case GE_EXPR: BUILD_OPERATOR_STRING (">=");
14699     case LT_EXPR: BUILD_OPERATOR_STRING ("<");
14700     case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
14701     case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14702     case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
14703     case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
14704     case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
14705     case PREINCREMENT_EXPR:     /* Fall through */
14706     case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
14707     case PREDECREMENT_EXPR:     /* Fall through */
14708     case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
14709     default:
14710       fatal ("unregistered operator %s - operator_string",
14711              tree_code_name [TREE_CODE (node)]);
14712     }
14713   return NULL;
14714 #undef BUILD_OPERATOR_STRING
14715 }
14716
14717 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2.  */
14718
14719 static int
14720 java_decl_equiv (var_acc1, var_acc2)
14721      tree var_acc1, var_acc2;
14722 {
14723   if (JDECL_P (var_acc1))
14724     return (var_acc1 == var_acc2);
14725   
14726   return (TREE_CODE (var_acc1) == COMPONENT_REF
14727           && TREE_CODE (var_acc2) == COMPONENT_REF
14728           && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
14729              == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
14730           && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
14731 }
14732
14733 /* Return a non zero value if CODE is one of the operators that can be
14734    used in conjunction with the `=' operator in a compound assignment.  */
14735
14736 static int
14737 binop_compound_p (code)
14738     enum tree_code code;
14739 {
14740   int i;
14741   for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
14742     if (binop_lookup [i] == code)
14743       break;
14744
14745   return i < BINOP_COMPOUND_CANDIDATES;
14746 }
14747
14748 /* Reorganize after a fold to get SAVE_EXPR to generate what we want.  */
14749
14750 static tree
14751 java_refold (t)
14752      tree t;
14753 {
14754   tree c, b, ns, decl;
14755
14756   if (TREE_CODE (t) != MODIFY_EXPR)
14757     return t;
14758
14759   c = TREE_OPERAND (t, 1);
14760   if (! (c && TREE_CODE (c) == COMPOUND_EXPR
14761          && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
14762          && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
14763     return t;
14764
14765   /* Now the left branch of the binary operator. */
14766   b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
14767   if (! (b && TREE_CODE (b) == NOP_EXPR 
14768          && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
14769     return t;
14770
14771   ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
14772   if (! (ns && TREE_CODE (ns) == NOP_EXPR
14773          && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
14774     return t;
14775
14776   decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
14777   if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
14778       /* It's got to be the an equivalent decl */
14779       && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
14780     {
14781       /* Shorten the NOP_EXPR/SAVE_EXPR path. */
14782       TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
14783       /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
14784       TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
14785       /* Change the right part of the BINOP_EXPR */
14786       TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
14787     }
14788
14789   return t;
14790 }
14791
14792 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
14793    errors but we modify NODE so that it contains the type computed
14794    according to the expression, when it's fixed. Otherwise, we write
14795    error_mark_node as the type. It allows us to further the analysis
14796    of remaining nodes and detects more errors in certain cases.  */
14797
14798 static tree
14799 patch_binop (node, wfl_op1, wfl_op2)
14800      tree node;
14801      tree wfl_op1;
14802      tree wfl_op2;
14803 {
14804   tree op1 = TREE_OPERAND (node, 0);
14805   tree op2 = TREE_OPERAND (node, 1);
14806   tree op1_type = TREE_TYPE (op1);
14807   tree op2_type = TREE_TYPE (op2);
14808   tree prom_type = NULL_TREE, cn;
14809   int code = TREE_CODE (node);
14810
14811   /* If 1, tell the routine that we have to return error_mark_node
14812      after checking for the initialization of the RHS */
14813   int error_found = 0;
14814
14815   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14816
14817   switch (code)
14818     {
14819     /* 15.16 Multiplicative operators */
14820     case MULT_EXPR:             /* 15.16.1 Multiplication Operator * */
14821     case RDIV_EXPR:             /* 15.16.2 Division Operator / */
14822     case TRUNC_DIV_EXPR:        /* 15.16.2 Integral type Division Operator / */
14823     case TRUNC_MOD_EXPR:        /* 15.16.3 Remainder operator % */
14824       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14825         {
14826           if (!JPRIMITIVE_TYPE_P (op1_type))
14827             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14828           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14829             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14830           TREE_TYPE (node) = error_mark_node;
14831           error_found = 1;
14832           break;
14833         }
14834       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14835       /* Change the division operator if necessary */
14836       if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
14837         TREE_SET_CODE (node, TRUNC_DIV_EXPR);
14838
14839       if (TREE_CODE (prom_type) == INTEGER_TYPE
14840           && flag_use_divide_subroutine
14841           && ! flag_emit_class_files
14842           && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
14843         return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
14844  
14845       /* This one is more complicated. FLOATs are processed by a
14846          function call to soft_fmod. Duplicate the value of the
14847          COMPOUND_ASSIGN_P flag. */
14848       if (code == TRUNC_MOD_EXPR)
14849         {
14850           tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
14851           COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
14852           TREE_SIDE_EFFECTS (mod)
14853             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
14854           return mod;
14855         }
14856       break;
14857
14858     /* 15.17 Additive Operators */
14859     case PLUS_EXPR:             /* 15.17.1 String Concatenation Operator + */
14860
14861       /* Operation is valid if either one argument is a string
14862          constant, a String object or a StringBuffer crafted for the
14863          purpose of the a previous usage of the String concatenation
14864          operator */
14865
14866       if (TREE_CODE (op1) == STRING_CST 
14867           || TREE_CODE (op2) == STRING_CST
14868           || JSTRING_TYPE_P (op1_type)
14869           || JSTRING_TYPE_P (op2_type)
14870           || IS_CRAFTED_STRING_BUFFER_P (op1)
14871           || IS_CRAFTED_STRING_BUFFER_P (op2))
14872         return build_string_concatenation (op1, op2);
14873
14874     case MINUS_EXPR:            /* 15.17.2 Additive Operators (+ and -) for
14875                                    Numeric Types */
14876       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14877         {
14878           if (!JPRIMITIVE_TYPE_P (op1_type))
14879             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14880           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14881             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14882           TREE_TYPE (node) = error_mark_node;
14883           error_found = 1;
14884           break;
14885         }
14886       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14887       break;
14888
14889     /* 15.18 Shift Operators */
14890     case LSHIFT_EXPR:
14891     case RSHIFT_EXPR:
14892     case URSHIFT_EXPR:
14893       if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
14894         {
14895           if (!JINTEGRAL_TYPE_P (op1_type))
14896             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
14897           else
14898             {
14899               if (JPRIMITIVE_TYPE_P (op2_type))
14900                 parse_error_context (wfl_operator,
14901                                      "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
14902                                      operator_string (node),
14903                                      lang_printable_name (op2_type, 0));
14904               else
14905                 parse_error_context (wfl_operator,
14906                                      "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral", 
14907                                      operator_string (node),
14908                                      lang_printable_name (op2_type, 0));
14909             }
14910           TREE_TYPE (node) = error_mark_node;
14911           error_found = 1;
14912           break;
14913         }
14914
14915       /* Unary numeric promotion (5.6.1) is performed on each operand
14916          separatly */
14917       op1 = do_unary_numeric_promotion (op1);
14918       op2 = do_unary_numeric_promotion (op2);
14919
14920       /* The type of the shift expression is the type of the promoted
14921          type of the left-hand operand */
14922       prom_type = TREE_TYPE (op1);
14923
14924       /* Shift int only up to 0x1f and long up to 0x3f */
14925       if (prom_type == int_type_node)
14926         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
14927                            build_int_2 (0x1f, 0)));
14928       else
14929         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
14930                            build_int_2 (0x3f, 0)));
14931
14932       /* The >>> operator is a >> operating on unsigned quantities */
14933       if (code == URSHIFT_EXPR && ! flag_emit_class_files)
14934         {
14935           tree to_return;
14936           tree utype = unsigned_type (prom_type);
14937           op1 = convert (utype, op1);
14938           TREE_SET_CODE (node, RSHIFT_EXPR);
14939           TREE_OPERAND (node, 0) = op1;
14940           TREE_OPERAND (node, 1) = op2;
14941           TREE_TYPE (node) = utype;
14942           to_return = convert (prom_type, node);
14943           /* Copy the original value of the COMPOUND_ASSIGN_P flag */
14944           COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
14945           TREE_SIDE_EFFECTS (to_return)
14946             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
14947           return to_return;
14948         }
14949       break;
14950
14951       /* 15.19.1 Type Comparison Operator instaceof */
14952     case INSTANCEOF_EXPR:
14953
14954       TREE_TYPE (node) = boolean_type_node;
14955
14956       if (!(op2_type = resolve_type_during_patch (op2)))
14957         return error_mark_node;
14958
14959       /* The first operand must be a reference type or the null type */
14960       if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
14961         error_found = 1;        /* Error reported further below */
14962
14963       /* The second operand must be a reference type */
14964       if (!JREFERENCE_TYPE_P (op2_type))
14965         {
14966           SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
14967           parse_error_context
14968             (wfl_operator, "Invalid argument `%s' for `instanceof'",
14969              lang_printable_name (op2_type, 0));
14970           error_found = 1;
14971         }
14972
14973       if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
14974         {
14975           /* If the first operand is null, the result is always false */
14976           if (op1 == null_pointer_node)
14977             return boolean_false_node;
14978           else if (flag_emit_class_files)
14979             {
14980               TREE_OPERAND (node, 1) = op2_type;
14981               TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
14982               return node;
14983             }
14984           /* Otherwise we have to invoke instance of to figure it out */
14985           else
14986             {
14987               tree call =
14988                 build (CALL_EXPR, boolean_type_node,
14989                        build_address_of (soft_instanceof_node),
14990                        tree_cons 
14991                        (NULL_TREE, op1,
14992                         build_tree_list (NULL_TREE,
14993                                          build_class_ref (op2_type))),
14994                        NULL_TREE);
14995               TREE_SIDE_EFFECTS (call) = TREE_SIDE_EFFECTS (op1);
14996               return call;
14997             }
14998         }
14999       /* There is no way the expression operand can be an instance of
15000          the type operand. This is a compile time error. */
15001       else
15002         {
15003           char *t1 = xstrdup (lang_printable_name (op1_type, 0));
15004           SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
15005           parse_error_context 
15006             (wfl_operator, "Impossible for `%s' to be instance of `%s'",
15007              t1, lang_printable_name (op2_type, 0));
15008           free (t1);
15009           error_found = 1;
15010         }
15011       
15012       break;
15013
15014       /* 15.21 Bitwise and Logical Operators */
15015     case BIT_AND_EXPR:
15016     case BIT_XOR_EXPR:
15017     case BIT_IOR_EXPR:
15018       if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
15019         /* Binary numeric promotion is performed on both operand and the
15020            expression retain that type */
15021         prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15022
15023       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE 
15024                && TREE_CODE (op1_type) == BOOLEAN_TYPE)
15025         /* The type of the bitwise operator expression is BOOLEAN */
15026         prom_type = boolean_type_node;
15027       else
15028         {
15029           if (!JINTEGRAL_TYPE_P (op1_type))
15030             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15031           if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
15032             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
15033           TREE_TYPE (node) = error_mark_node;
15034           error_found = 1;
15035           /* Insert a break here if adding thing before the switch's
15036              break for this case */
15037         }
15038       break;
15039
15040       /* 15.22 Conditional-And Operator */
15041     case TRUTH_ANDIF_EXPR:
15042       /* 15.23 Conditional-Or Operator */
15043     case TRUTH_ORIF_EXPR:
15044       /* Operands must be of BOOLEAN type */
15045       if (TREE_CODE (op1_type) != BOOLEAN_TYPE || 
15046           TREE_CODE (op2_type) != BOOLEAN_TYPE)
15047         {
15048           if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
15049             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
15050           if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
15051             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
15052           TREE_TYPE (node) = boolean_type_node;
15053           error_found = 1;
15054           break;
15055         }
15056       /* The type of the conditional operators is BOOLEAN */
15057       prom_type = boolean_type_node;
15058       break;
15059
15060       /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
15061     case LT_EXPR:
15062     case GT_EXPR:
15063     case LE_EXPR:
15064     case GE_EXPR:
15065       /* The type of each of the operands must be a primitive numeric
15066          type */
15067       if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
15068         {
15069           if (!JNUMERIC_TYPE_P (op1_type))
15070             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15071           if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
15072             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15073           TREE_TYPE (node) = boolean_type_node;
15074           error_found = 1;
15075           break;
15076         }
15077       /* Binary numeric promotion is performed on the operands */
15078       binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15079       /* The type of the relation expression is always BOOLEAN */
15080       prom_type = boolean_type_node;
15081       break;
15082
15083       /* 15.20 Equality Operator */
15084     case EQ_EXPR:
15085     case NE_EXPR:
15086       /* It's time for us to patch the strings. */
15087       if ((cn = patch_string (op1))) 
15088        {
15089          op1 = cn;
15090          op1_type = TREE_TYPE (op1);
15091        }
15092       if ((cn = patch_string (op2))) 
15093        {
15094          op2 = cn;
15095          op2_type = TREE_TYPE (op2);
15096        }
15097       
15098       /* 15.20.1 Numerical Equality Operators == and != */
15099       /* Binary numeric promotion is performed on the operands */
15100       if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
15101         binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15102       
15103       /* 15.20.2 Boolean Equality Operators == and != */
15104       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
15105           TREE_CODE (op2_type) == BOOLEAN_TYPE)
15106         ;                       /* Nothing to do here */
15107       
15108       /* 15.20.3 Reference Equality Operators == and != */
15109       /* Types have to be either references or the null type. If
15110          they're references, it must be possible to convert either
15111          type to the other by casting conversion. */
15112       else if (op1 == null_pointer_node || op2 == null_pointer_node 
15113                || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
15114                    && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
15115                        || valid_ref_assignconv_cast_p (op2_type, 
15116                                                        op1_type, 1))))
15117         ;                       /* Nothing to do here */
15118           
15119       /* Else we have an error figure what can't be converted into
15120          what and report the error */
15121       else
15122         {
15123           char *t1;
15124           t1 = xstrdup (lang_printable_name (op1_type, 0));
15125           parse_error_context 
15126             (wfl_operator,
15127              "Incompatible type for `%s'. Can't convert `%s' to `%s'",
15128              operator_string (node), t1, 
15129              lang_printable_name (op2_type, 0));
15130           free (t1);
15131           TREE_TYPE (node) = boolean_type_node;
15132           error_found = 1;
15133           break;
15134         }
15135       prom_type = boolean_type_node;
15136       break;
15137     }
15138
15139   if (error_found)
15140     return error_mark_node;
15141
15142   TREE_OPERAND (node, 0) = op1;
15143   TREE_OPERAND (node, 1) = op2;
15144   TREE_TYPE (node) = prom_type;
15145   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15146   
15147   if (flag_emit_xref)
15148     return node;
15149
15150   /* fold does not respect side-effect order as required for Java but not C.
15151    * Also, it sometimes create SAVE_EXPRs which are bad when emitting
15152    * bytecode.
15153    */
15154   if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
15155       : ! TREE_SIDE_EFFECTS (node))
15156     node = fold (node);
15157   return node;
15158 }
15159
15160 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
15161    zero value, the value of CSTE comes after the valude of STRING */
15162
15163 static tree
15164 do_merge_string_cste (cste, string, string_len, after)
15165      tree cste;
15166      const char *string;
15167      int string_len, after;
15168 {
15169   int len = TREE_STRING_LENGTH (cste) + string_len;
15170   const char *old = TREE_STRING_POINTER (cste);
15171   TREE_STRING_LENGTH (cste) = len;
15172   TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
15173   if (after)
15174     {
15175       strcpy (TREE_STRING_POINTER (cste), string);
15176       strcat (TREE_STRING_POINTER (cste), old);
15177     }
15178   else
15179     {
15180       strcpy (TREE_STRING_POINTER (cste), old);
15181       strcat (TREE_STRING_POINTER (cste), string);
15182     }
15183   return cste;
15184 }
15185
15186 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
15187    new STRING_CST on success, NULL_TREE on failure */
15188
15189 static tree
15190 merge_string_cste (op1, op2, after)
15191      tree op1, op2;
15192      int after;
15193 {
15194   /* Handle two string constants right away */
15195   if (TREE_CODE (op2) == STRING_CST)
15196     return do_merge_string_cste (op1, TREE_STRING_POINTER (op2), 
15197                                  TREE_STRING_LENGTH (op2), after);
15198   
15199   /* Reasonable integer constant can be treated right away */
15200   if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
15201     {
15202       static const char *boolean_true = "true";
15203       static const char *boolean_false = "false";
15204       static const char *null_pointer = "null";
15205       char ch[3];
15206       const char *string;
15207       
15208       if (op2 == boolean_true_node)
15209         string = boolean_true;
15210       else if (op2 == boolean_false_node)
15211         string = boolean_false;
15212       else if (op2 == null_pointer_node)
15213         string = null_pointer;
15214       else if (TREE_TYPE (op2) == char_type_node)
15215         {
15216           ch[0] = (char )TREE_INT_CST_LOW (op2);
15217           ch[1] = '\0';
15218           string = ch;
15219         }
15220       else
15221           string = print_int_node (op2);
15222       
15223       return do_merge_string_cste (op1, string, strlen (string), after);
15224     }
15225   return NULL_TREE;
15226 }
15227
15228 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
15229    has to be a STRING_CST and the other part must be a STRING_CST or a
15230    INTEGRAL constant. Return a new STRING_CST if the operation
15231    succeed, NULL_TREE otherwise.
15232
15233    If the case we want to optimize for space, we might want to return
15234    NULL_TREE for each invocation of this routine. FIXME */
15235
15236 static tree
15237 string_constant_concatenation (op1, op2)
15238      tree op1, op2;
15239 {
15240   if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
15241     {
15242       tree string, rest;
15243       int invert;
15244       
15245       string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
15246       rest   = (string == op1 ? op2 : op1);
15247       invert = (string == op1 ? 0 : 1 );
15248       
15249       /* Walk REST, only if it looks reasonable */
15250       if (TREE_CODE (rest) != STRING_CST
15251           && !IS_CRAFTED_STRING_BUFFER_P (rest)
15252           && !JSTRING_TYPE_P (TREE_TYPE (rest))
15253           && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
15254         {
15255           rest = java_complete_tree (rest);
15256           if (rest == error_mark_node)
15257             return error_mark_node;
15258           rest = fold (rest);
15259         }
15260       return merge_string_cste (string, rest, invert);
15261     }
15262   return NULL_TREE;
15263 }
15264
15265 /* Implement the `+' operator. Does static optimization if possible,
15266    otherwise create (if necessary) and append elements to a
15267    StringBuffer. The StringBuffer will be carried around until it is
15268    used for a function call or an assignment. Then toString() will be
15269    called on it to turn it into a String object. */
15270
15271 static tree
15272 build_string_concatenation (op1, op2)
15273      tree op1, op2;
15274 {
15275   tree result;
15276   int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15277
15278   if (flag_emit_xref)
15279     return build (PLUS_EXPR, string_type_node, op1, op2);
15280   
15281   /* Try to do some static optimization */
15282   if ((result = string_constant_concatenation (op1, op2)))
15283     return result;
15284
15285   /* Discard empty strings on either side of the expression */
15286   if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
15287     {
15288       op1 = op2;
15289       op2 = NULL_TREE;
15290     }
15291   else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
15292     op2 = NULL_TREE;
15293
15294   /* If operands are string constant, turn then into object references */
15295   if (TREE_CODE (op1) == STRING_CST)
15296     op1 = patch_string_cst (op1);
15297   if (op2 && TREE_CODE (op2) == STRING_CST)
15298     op2 = patch_string_cst (op2);
15299
15300   /* If either one of the constant is null and the other non null
15301      operand is a String object, return it. */
15302   if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
15303     return op1;
15304
15305   /* If OP1 isn't already a StringBuffer, create and
15306      initialize a new one */
15307   if (!IS_CRAFTED_STRING_BUFFER_P (op1))
15308     {
15309       /* Two solutions here: 
15310          1) OP1 is a constant string reference, we call new StringBuffer(OP1)
15311          2) OP1 is something else, we call new StringBuffer().append(OP1).  */
15312       if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1)))
15313         op1 = BUILD_STRING_BUFFER (op1);
15314       else
15315         {
15316           tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
15317           op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
15318         }
15319     }
15320
15321   if (op2)
15322     {
15323       /* OP1 is no longer the last node holding a crafted StringBuffer */
15324       IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
15325       /* Create a node for `{new...,xxx}.append (op2)' */
15326       if (op2)
15327         op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
15328     }
15329
15330   /* Mark the last node holding a crafted StringBuffer */
15331   IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
15332
15333   TREE_SIDE_EFFECTS (op1) = side_effects;
15334   return op1;
15335 }
15336
15337 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
15338    StringBuffer. If no string were found to be patched, return
15339    NULL. */
15340
15341 static tree
15342 patch_string (node)
15343     tree node;
15344 {
15345   if (node == error_mark_node)
15346     return error_mark_node;
15347   if (TREE_CODE (node) == STRING_CST)
15348     return patch_string_cst (node);
15349   else if (IS_CRAFTED_STRING_BUFFER_P (node))
15350     {
15351       int saved = ctxp->explicit_constructor_p;
15352       tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
15353       tree ret;
15354       /* Temporary disable forbid the use of `this'. */
15355       ctxp->explicit_constructor_p = 0;
15356       ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
15357       /* String concatenation arguments must be evaluated in order too. */
15358       ret = force_evaluation_order (ret);
15359       /* Restore it at its previous value */
15360       ctxp->explicit_constructor_p = saved;
15361       return ret;
15362     }
15363   return NULL_TREE;
15364 }
15365
15366 /* Build the internal representation of a string constant.  */
15367
15368 static tree
15369 patch_string_cst (node)
15370      tree node;
15371 {
15372   int location;
15373   if (! flag_emit_class_files)
15374     {
15375       push_obstacks (&permanent_obstack, &permanent_obstack);
15376       node = get_identifier (TREE_STRING_POINTER (node));
15377       location = alloc_name_constant (CONSTANT_String, node);
15378       node = build_ref_from_constant_pool (location);
15379       pop_obstacks ();
15380     }
15381   TREE_TYPE (node) = string_ptr_type_node;
15382   TREE_CONSTANT (node) = 1;
15383   return node;
15384 }
15385
15386 /* Build an incomplete unary operator expression. */
15387
15388 static tree
15389 build_unaryop (op_token, op_location, op1)
15390      int op_token, op_location;
15391      tree op1;
15392 {
15393   enum tree_code op;
15394   tree unaryop;
15395   switch (op_token)
15396     {
15397     case PLUS_TK: op = UNARY_PLUS_EXPR; break;
15398     case MINUS_TK: op = NEGATE_EXPR; break;
15399     case NEG_TK: op = TRUTH_NOT_EXPR; break;
15400     case NOT_TK: op = BIT_NOT_EXPR; break;
15401     default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
15402                     op_token);
15403     }
15404
15405   unaryop = build1 (op, NULL_TREE, op1);
15406   TREE_SIDE_EFFECTS (unaryop) = 1;
15407   /* Store the location of the operator, for better error report. The
15408      string of the operator will be rebuild based on the OP value. */
15409   EXPR_WFL_LINECOL (unaryop) = op_location;
15410   return unaryop;
15411 }
15412
15413 /* Special case for the ++/-- operators, since they require an extra
15414    argument to build, which is set to NULL and patched
15415    later. IS_POST_P is 1 if the operator, 0 otherwise.  */
15416
15417 static tree
15418 build_incdec (op_token, op_location, op1, is_post_p)
15419      int op_token, op_location;
15420      tree op1;
15421      int is_post_p;
15422 {
15423   static enum tree_code lookup [2][2] = 
15424     {
15425       { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
15426       { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
15427     };
15428   tree node = build (lookup [is_post_p][(op_token - DECR_TK)], 
15429                      NULL_TREE, op1, NULL_TREE);
15430   TREE_SIDE_EFFECTS (node) = 1;
15431   /* Store the location of the operator, for better error report. The
15432      string of the operator will be rebuild based on the OP value. */
15433   EXPR_WFL_LINECOL (node) = op_location;
15434   return node;
15435 }     
15436
15437 /* Build an incomplete cast operator, based on the use of the
15438    CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
15439    set. java_complete_tree is trained to walk a CONVERT_EXPR even
15440    though its type is already set.  */
15441
15442 static tree
15443 build_cast (location, type, exp)
15444      int location;
15445      tree type, exp;
15446 {
15447   tree node = build1 (CONVERT_EXPR, type, exp);
15448   EXPR_WFL_LINECOL (node) = location;
15449   return node;
15450 }
15451
15452 /* Build an incomplete class reference operator.  */
15453 static tree
15454 build_incomplete_class_ref (location, class_name)
15455     int location;
15456     tree class_name;
15457 {
15458   tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
15459   EXPR_WFL_LINECOL (node) = location;
15460   return node;
15461 }
15462
15463 /* Complete an incomplete class reference operator.  */
15464 static tree
15465 patch_incomplete_class_ref (node)
15466     tree node;
15467 {
15468   tree type = TREE_OPERAND (node, 0);
15469   tree ref_type;
15470
15471   if (!(ref_type = resolve_type_during_patch (type)))
15472     return error_mark_node;
15473
15474   if (!flag_emit_class_files || JPRIMITIVE_TYPE_P (ref_type))
15475     return build_class_ref (ref_type);
15476
15477   /* If we're emitting class files and we have to deal with non
15478      primitive types, we invoke (and consider generating) the
15479      synthetic static method `class$'. */
15480   if (!TYPE_DOT_CLASS (current_class))
15481       build_dot_class_method (current_class);
15482   ref_type = 
15483     build_dot_class_method_invocation (DECL_NAME (TYPE_NAME (ref_type)));
15484   return java_complete_tree (ref_type);
15485 }
15486
15487 /* 15.14 Unary operators. We return error_mark_node in case of error,
15488    but preserve the type of NODE if the type is fixed.  */
15489
15490 static tree
15491 patch_unaryop (node, wfl_op)
15492      tree node;
15493      tree wfl_op;
15494 {
15495   tree op = TREE_OPERAND (node, 0);
15496   tree op_type = TREE_TYPE (op);
15497   tree prom_type = NULL_TREE, value, decl;
15498   int outer_field_flag = 0;
15499   int code = TREE_CODE (node);
15500   int error_found = 0;
15501
15502   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15503
15504   switch (code)
15505     {
15506       /* 15.13.2 Postfix Increment Operator ++ */
15507     case POSTINCREMENT_EXPR:
15508       /* 15.13.3 Postfix Increment Operator -- */
15509     case POSTDECREMENT_EXPR:
15510       /* 15.14.1 Prefix Increment Operator ++ */
15511     case PREINCREMENT_EXPR:
15512       /* 15.14.2 Prefix Decrement Operator -- */
15513     case PREDECREMENT_EXPR:
15514       op = decl = strip_out_static_field_access_decl (op);
15515       outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
15516       /* We might be trying to change an outer field accessed using
15517          access method. */
15518       if (outer_field_flag)
15519         {
15520           /* Retrieve the decl of the field we're trying to access. We
15521              do that by first retrieving the function we would call to
15522              access the field. It has been already verified that this
15523              field isn't final */
15524           if (flag_emit_class_files)
15525             decl = TREE_OPERAND (op, 0);
15526           else
15527             decl = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (op, 0), 0), 0);
15528           decl = DECL_FUNCTION_ACCESS_DECL (decl);
15529         }
15530       /* We really should have a JAVA_ARRAY_EXPR to avoid this */
15531       else if (!JDECL_P (decl) 
15532           && TREE_CODE (decl) != COMPONENT_REF
15533           && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
15534           && TREE_CODE (decl) != INDIRECT_REF
15535           && !(TREE_CODE (decl) == COMPOUND_EXPR
15536                && TREE_OPERAND (decl, 1)
15537                && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
15538         {
15539           tree lvalue;
15540           /* Before screaming, check that we're not in fact trying to
15541              increment a optimized static final access, in which case
15542              we issue an different error message. */
15543           if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
15544                 && resolve_expression_name (wfl_op, &lvalue)
15545                 && check_final_assignment (lvalue, wfl_op)))
15546             parse_error_context (wfl_operator, "Invalid argument to `%s'",
15547                                  operator_string (node));
15548           TREE_TYPE (node) = error_mark_node;
15549           error_found = 1;
15550         }
15551       
15552       if (check_final_assignment (op, wfl_op))
15553         error_found = 1;
15554
15555       /* From now on, we know that op if a variable and that it has a
15556          valid wfl. We use wfl_op to locate errors related to the
15557          ++/-- operand. */
15558       else if (!JNUMERIC_TYPE_P (op_type))
15559         {
15560           parse_error_context
15561             (wfl_op, "Invalid argument type `%s' to `%s'",
15562              lang_printable_name (op_type, 0), operator_string (node));
15563           TREE_TYPE (node) = error_mark_node;
15564           error_found = 1;
15565         }
15566       else
15567         {
15568           /* Before the addition, binary numeric promotion is performed on
15569              both operands, if really necessary */
15570           if (JINTEGRAL_TYPE_P (op_type))
15571             {
15572               value = build_int_2 (1, 0);
15573               TREE_TYPE (value) = TREE_TYPE (node) = op_type;
15574             }
15575           else
15576             {
15577               value = build_int_2 (1, 0);
15578               TREE_TYPE (node) = 
15579                 binary_numeric_promotion (op_type, 
15580                                           TREE_TYPE (value), &op, &value);
15581             }
15582
15583           /* We remember we might be accessing an outer field */
15584           if (outer_field_flag)
15585             {
15586               /* We re-generate an access to the field */
15587               value = build (PLUS_EXPR, TREE_TYPE (op), 
15588                              build_outer_field_access (wfl_op, decl), value);
15589                                                     
15590               /* And we patch the original access$() into a write 
15591                  with plus_op as a rhs */
15592               return outer_field_access_fix (node, op, value);
15593             }
15594
15595           /* And write back into the node. */
15596           TREE_OPERAND (node, 0) = op;
15597           TREE_OPERAND (node, 1) = value;
15598           /* Convert the overall back into its original type, if
15599              necessary, and return */
15600           if (JINTEGRAL_TYPE_P (op_type))
15601             return fold (node);
15602           else
15603             return fold (convert (op_type, node));
15604         }
15605       break;
15606
15607       /* 15.14.3 Unary Plus Operator + */
15608     case UNARY_PLUS_EXPR:
15609       /* 15.14.4 Unary Minus Operator - */
15610     case NEGATE_EXPR:
15611       if (!JNUMERIC_TYPE_P (op_type))
15612         {
15613           ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
15614           TREE_TYPE (node) = error_mark_node;
15615           error_found = 1;
15616         }
15617       /* Unary numeric promotion is performed on operand */
15618       else
15619         {
15620           op = do_unary_numeric_promotion (op);
15621           prom_type = TREE_TYPE (op);
15622           if (code == UNARY_PLUS_EXPR)
15623             return fold (op);
15624         }
15625       break;
15626
15627       /* 15.14.5 Bitwise Complement Operator ~ */
15628     case BIT_NOT_EXPR:
15629       if (!JINTEGRAL_TYPE_P (op_type))
15630         {
15631           ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
15632           TREE_TYPE (node) = error_mark_node;
15633           error_found = 1;
15634         }
15635       else
15636         {
15637           op = do_unary_numeric_promotion (op);
15638           prom_type = TREE_TYPE (op);
15639         }
15640       break;
15641
15642       /* 15.14.6 Logical Complement Operator ! */
15643     case TRUTH_NOT_EXPR:
15644       if (TREE_CODE (op_type) != BOOLEAN_TYPE)
15645         {
15646           ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
15647           /* But the type is known. We will report an error if further
15648              attempt of a assignment is made with this rhs */
15649           TREE_TYPE (node) = boolean_type_node;
15650           error_found = 1;
15651         }
15652       else
15653         prom_type = boolean_type_node;
15654       break;
15655
15656       /* 15.15 Cast Expression */
15657     case CONVERT_EXPR:
15658       value = patch_cast (node, wfl_operator);
15659       if (value == error_mark_node)
15660         {
15661           /* If this cast is part of an assignment, we tell the code
15662              that deals with it not to complain about a mismatch,
15663              because things have been cast, anyways */
15664           TREE_TYPE (node) = error_mark_node;
15665           error_found = 1;
15666         }
15667       else
15668         {
15669           value = fold (value);
15670           TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
15671           return value;
15672         }
15673       break;
15674     }
15675   
15676   if (error_found)
15677     return error_mark_node;
15678
15679   /* There are cases where node has been replaced by something else
15680      and we don't end up returning here: UNARY_PLUS_EXPR,
15681      CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
15682   TREE_OPERAND (node, 0) = fold (op);
15683   TREE_TYPE (node) = prom_type;
15684   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
15685   return fold (node);
15686 }
15687
15688 /* Generic type resolution that sometimes takes place during node
15689    patching. Returned the resolved type or generate an error
15690    message. Return the resolved type or NULL_TREE.  */
15691
15692 static tree
15693 resolve_type_during_patch (type)
15694      tree type;
15695 {
15696   if (unresolved_type_p (type, NULL))
15697     {
15698       tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
15699       if (!type_decl)
15700         {
15701           parse_error_context (type, 
15702                                "Class `%s' not found in type declaration",
15703                                IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
15704           return NULL_TREE;
15705         }
15706       else
15707         {
15708           CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
15709           return TREE_TYPE (type_decl);
15710         }
15711     }
15712   return type;
15713 }
15714 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
15715    found. Otherwise NODE or something meant to replace it is returned.  */
15716
15717 static tree
15718 patch_cast (node, wfl_operator)
15719      tree node;
15720      tree wfl_operator;
15721 {
15722   tree op = TREE_OPERAND (node, 0);
15723   tree op_type = TREE_TYPE (op);
15724   tree cast_type = TREE_TYPE (node);
15725   char *t1;
15726
15727   /* First resolve OP_TYPE if unresolved */
15728   if (!(cast_type = resolve_type_during_patch (cast_type)))
15729     return error_mark_node;
15730
15731   /* Check on cast that are proven correct at compile time */
15732   if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
15733     {
15734       /* Same type */
15735       if (cast_type == op_type)
15736         return node;
15737
15738       /* float and double type are converted to the original type main
15739          variant and then to the target type. */
15740       if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
15741         op = convert (integer_type_node, op);
15742
15743       /* Try widening/narowwing convertion. Potentially, things need
15744          to be worked out in gcc so we implement the extreme cases
15745          correctly. fold_convert() needs to be fixed. */
15746       return convert (cast_type, op);
15747     }
15748
15749   /* It's also valid to cast a boolean into a boolean */
15750   if (op_type == boolean_type_node && cast_type == boolean_type_node)
15751     return node;
15752
15753   /* null can be casted to references */
15754   if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
15755     return build_null_of_type (cast_type);
15756
15757   /* The remaining legal casts involve conversion between reference
15758      types. Check for their compile time correctness. */
15759   if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type) 
15760       && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
15761     {
15762       TREE_TYPE (node) = promote_type (cast_type);
15763       /* Now, the case can be determined correct at compile time if
15764          OP_TYPE can be converted into CAST_TYPE by assignment
15765          conversion (5.2) */
15766
15767       if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
15768         {
15769           TREE_SET_CODE (node, NOP_EXPR);
15770           return node;
15771         }
15772
15773       if (flag_emit_class_files)
15774         {
15775           TREE_SET_CODE (node, CONVERT_EXPR);
15776           return node;
15777         }
15778
15779       /* The cast requires a run-time check */
15780       return build (CALL_EXPR, promote_type (cast_type),
15781                     build_address_of (soft_checkcast_node),
15782                     tree_cons (NULL_TREE, build_class_ref (cast_type),
15783                                build_tree_list (NULL_TREE, op)),
15784                     NULL_TREE);
15785     }
15786
15787   /* Any other casts are proven incorrect at compile time */
15788   t1 = xstrdup (lang_printable_name (op_type, 0));
15789   parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
15790                        t1, lang_printable_name (cast_type, 0));
15791   free (t1);
15792   return error_mark_node;
15793 }
15794
15795 /* Build a null constant and give it the type TYPE.  */
15796
15797 static tree
15798 build_null_of_type (type)
15799      tree type;
15800 {
15801   tree node = build_int_2 (0, 0);
15802   TREE_TYPE (node) = promote_type (type);
15803   return node;
15804 }
15805
15806 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
15807    a list of indices. */
15808 static tree
15809 build_array_ref (location, array, index)
15810      int location;
15811      tree array, index;
15812 {
15813   tree node = build (ARRAY_REF, NULL_TREE, array, index);
15814   EXPR_WFL_LINECOL (node) = location;
15815   return node;
15816 }
15817
15818 /* 15.12 Array Access Expression */
15819
15820 static tree
15821 patch_array_ref (node)
15822      tree node;
15823 {
15824   tree array = TREE_OPERAND (node, 0);
15825   tree array_type  = TREE_TYPE (array);
15826   tree index = TREE_OPERAND (node, 1);
15827   tree index_type = TREE_TYPE (index);
15828   int error_found = 0;
15829
15830   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15831
15832   if (TREE_CODE (array_type) == POINTER_TYPE)
15833     array_type = TREE_TYPE (array_type);
15834
15835   /* The array reference must be an array */
15836   if (!TYPE_ARRAY_P (array_type))
15837     {
15838       parse_error_context 
15839         (wfl_operator,
15840          "`[]' can only be applied to arrays. It can't be applied to `%s'",
15841          lang_printable_name (array_type, 0));
15842       TREE_TYPE (node) = error_mark_node;
15843       error_found = 1;
15844     }
15845
15846   /* The array index undergoes unary numeric promotion. The promoted
15847      type must be int */
15848   index = do_unary_numeric_promotion (index);
15849   if (TREE_TYPE (index) != int_type_node)
15850     {
15851       if (valid_cast_to_p (index_type, int_type_node))
15852         parse_error_context (wfl_operator,
15853    "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
15854                              lang_printable_name (index_type, 0));
15855       else
15856         parse_error_context (wfl_operator,
15857           "Incompatible type for `[]'. Can't convert `%s' to `int'",
15858                              lang_printable_name (index_type, 0));
15859       TREE_TYPE (node) = error_mark_node;
15860       error_found = 1;
15861     }
15862
15863   if (error_found)
15864     return error_mark_node;
15865
15866   array_type = TYPE_ARRAY_ELEMENT (array_type);
15867
15868   if (flag_emit_class_files || flag_emit_xref)
15869     {
15870       TREE_OPERAND (node, 0) = array;
15871       TREE_OPERAND (node, 1) = index;
15872     }
15873   else
15874     {
15875       /* The save_expr is for correct evaluation order.  It would be cleaner
15876          to use force_evaluation_order (see comment there), but that is
15877          difficult when we also have to deal with bounds checking. */
15878       if (TREE_SIDE_EFFECTS (index))
15879         array = save_expr (array);
15880       node = build_java_arrayaccess (array, array_type, index);
15881       if (TREE_SIDE_EFFECTS (index))
15882         node = build (COMPOUND_EXPR, array_type, array, node);
15883     }
15884   TREE_TYPE (node) = array_type;
15885   return node;
15886 }
15887
15888 /* 15.9 Array Creation Expressions */
15889
15890 static tree
15891 build_newarray_node (type, dims, extra_dims)
15892      tree type;
15893      tree dims;
15894      int extra_dims;
15895 {
15896   tree node =
15897     build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims), 
15898            build_int_2 (extra_dims, 0));
15899   return node;
15900 }
15901
15902 static tree
15903 patch_newarray (node)
15904      tree node;
15905 {
15906   tree type = TREE_OPERAND (node, 0);
15907   tree dims = TREE_OPERAND (node, 1);
15908   tree cdim, array_type;
15909   int error_found = 0;
15910   int ndims = 0;
15911   int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
15912
15913   /* Dimension types are verified. It's better for the types to be
15914      verified in order. */
15915   for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
15916     {
15917       int dim_error = 0;
15918       tree dim = TREE_VALUE (cdim);
15919
15920       /* Dim might have been saved during its evaluation */
15921       dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
15922
15923       /* The type of each specified dimension must be an integral type. */
15924       if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
15925         dim_error = 1;
15926
15927       /* Each expression undergoes an unary numeric promotion (5.6.1) and the
15928          promoted type must be int. */
15929       else
15930         {
15931           dim = do_unary_numeric_promotion (dim);
15932           if (TREE_TYPE (dim) != int_type_node)
15933             dim_error = 1;
15934         }
15935
15936       /* Report errors on types here */
15937       if (dim_error)
15938         {
15939           parse_error_context 
15940             (TREE_PURPOSE (cdim), 
15941              "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'", 
15942              (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
15943               "Explicit cast needed to" : "Can't"),
15944              lang_printable_name (TREE_TYPE (dim), 0));
15945           error_found = 1;
15946         }
15947
15948       TREE_PURPOSE (cdim) = NULL_TREE;
15949     }
15950
15951   /* Resolve array base type if unresolved */
15952   if (!(type = resolve_type_during_patch (type)))
15953     error_found = 1;
15954
15955   if (error_found)
15956     {
15957       /* We don't want further evaluation of this bogus array creation
15958          operation */
15959       TREE_TYPE (node) = error_mark_node;
15960       return error_mark_node;
15961     }
15962
15963   /* Set array_type to the actual (promoted) array type of the result. */
15964   if (TREE_CODE (type) == RECORD_TYPE)
15965     type = build_pointer_type (type);
15966   while (--xdims >= 0)
15967     {
15968       type = promote_type (build_java_array_type (type, -1));
15969     }
15970   dims = nreverse (dims);
15971   array_type = type;
15972   for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
15973     {
15974       type = array_type;
15975       array_type
15976         = build_java_array_type (type,
15977                                  TREE_CODE (cdim) == INTEGER_CST
15978                                  ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim)
15979                                  : -1);
15980       array_type = promote_type (array_type);
15981     }
15982   dims = nreverse (dims);
15983
15984   /* The node is transformed into a function call. Things are done
15985      differently according to the number of dimensions. If the number
15986      of dimension is equal to 1, then the nature of the base type
15987      (primitive or not) matters. */
15988   if (ndims == 1)
15989     return build_new_array (type, TREE_VALUE (dims));
15990   
15991   /* Can't reuse what's already written in expr.c because it uses the
15992      JVM stack representation. Provide a build_multianewarray. FIXME */
15993   return build (CALL_EXPR, array_type,
15994                 build_address_of (soft_multianewarray_node),
15995                 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
15996                            tree_cons (NULL_TREE, 
15997                                       build_int_2 (ndims, 0), dims )),
15998                 NULL_TREE);
15999 }
16000
16001 /* 10.6 Array initializer.  */
16002
16003 /* Build a wfl for array element that don't have one, so we can
16004    pin-point errors.  */
16005
16006 static tree
16007 maybe_build_array_element_wfl (node)
16008      tree node;
16009 {
16010   if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
16011     return build_expr_wfl (NULL_TREE, ctxp->filename,
16012                            ctxp->elc.line, ctxp->elc.prev_col);
16013   else
16014     return NULL_TREE;
16015 }
16016
16017 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
16018    identification of initialized arrays easier to detect during walk
16019    and expansion.  */
16020
16021 static tree
16022 build_new_array_init (location, values)
16023      int location;
16024      tree values;
16025 {
16026   tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
16027   tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
16028   EXPR_WFL_LINECOL (to_return) = location;
16029   return to_return;
16030 }
16031
16032 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
16033    occurred.  Otherwise return NODE after having set its type
16034    appropriately.  */
16035
16036 static tree
16037 patch_new_array_init (type, node)
16038      tree type, node;
16039 {
16040   int error_seen = 0;
16041   tree current, element_type;
16042   HOST_WIDE_INT length;
16043   int all_constant = 1;
16044   tree init = TREE_OPERAND (node, 0);
16045
16046   if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
16047     {
16048       parse_error_context (node,
16049                            "Invalid array initializer for non-array type `%s'",
16050                            lang_printable_name (type, 1));
16051       return error_mark_node;
16052     }
16053   type = TREE_TYPE (type);
16054   element_type = TYPE_ARRAY_ELEMENT (type);
16055
16056   CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
16057
16058   for (length = 0, current = CONSTRUCTOR_ELTS (init);
16059        current;  length++, current = TREE_CHAIN (current))
16060     {
16061       tree elt = TREE_VALUE (current);
16062       if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
16063         {
16064           error_seen |= array_constructor_check_entry (element_type, current);
16065           elt = TREE_VALUE (current);
16066           /* When compiling to native code, STRING_CST is converted to
16067              INDIRECT_REF, but still with a TREE_CONSTANT flag. */
16068           if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
16069             all_constant = 0;
16070         }
16071       else
16072         {
16073           TREE_VALUE (current) = patch_new_array_init (element_type, elt);
16074           TREE_PURPOSE (current) = NULL_TREE;
16075           all_constant = 0;
16076         }
16077       if (elt && TREE_VALUE (elt) == error_mark_node)
16078         error_seen = 1;
16079     }
16080
16081   if (error_seen)
16082     return error_mark_node;
16083
16084   /* Create a new type. We can't reuse the one we have here by
16085      patching its dimension because it originally is of dimension -1
16086      hence reused by gcc. This would prevent triangular arrays. */
16087   type = build_java_array_type (element_type, length);
16088   TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
16089   TREE_TYPE (node) = promote_type (type);
16090   TREE_CONSTANT (init) = all_constant;
16091   TREE_CONSTANT (node) = all_constant;
16092   return node;
16093 }
16094
16095 /* Verify that one entry of the initializer element list can be
16096    assigned to the array base type. Report 1 if an error occurred, 0
16097    otherwise.  */
16098
16099 static int
16100 array_constructor_check_entry (type, entry)
16101      tree type, entry;
16102 {
16103   char *array_type_string = NULL;       /* For error reports */
16104   tree value, type_value, new_value, wfl_value, patched;
16105   int error_seen = 0;
16106
16107   new_value = NULL_TREE;
16108   wfl_value = TREE_VALUE (entry);
16109
16110   push_obstacks (&permanent_obstack, &permanent_obstack);
16111   value = java_complete_tree (TREE_VALUE (entry));
16112   /* patch_string return error_mark_node if arg is error_mark_node */
16113   if ((patched = patch_string (value)))
16114     value = patched;
16115   if (value == error_mark_node)
16116     return 1;
16117   
16118   type_value = TREE_TYPE (value);
16119   
16120   /* At anytime, try_builtin_assignconv can report a warning on
16121      constant overflow during narrowing. */
16122   SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
16123   new_value = try_builtin_assignconv (wfl_operator, type, value);
16124   if (!new_value && (new_value = try_reference_assignconv (type, value)))
16125     type_value = promote_type (type);
16126
16127   pop_obstacks ();
16128   /* Check and report errors */
16129   if (!new_value)
16130     {
16131       const char *msg = (!valid_cast_to_p (type_value, type) ?
16132                    "Can't" : "Explicit cast needed to");
16133       if (!array_type_string)
16134         array_type_string = xstrdup (lang_printable_name (type, 1));
16135       parse_error_context 
16136         (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
16137          msg, lang_printable_name (type_value, 1), array_type_string);
16138       error_seen = 1;
16139     }
16140   
16141   if (new_value)
16142     {
16143       new_value = maybe_build_primttype_type_ref (new_value, wfl_operator);
16144       TREE_VALUE (entry) = new_value;
16145     }
16146
16147   if (array_type_string)
16148     free (array_type_string);
16149
16150   TREE_PURPOSE (entry) = NULL_TREE;
16151   return error_seen;
16152 }
16153
16154 static tree
16155 build_this (location)
16156      int location;
16157 {
16158   tree node = build_wfl_node (this_identifier_node);
16159   TREE_SET_CODE (node, THIS_EXPR);
16160   EXPR_WFL_LINECOL (node) = location;
16161   return node;
16162 }
16163
16164 /* 14.15 The return statement. It builds a modify expression that
16165    assigns the returned value to the RESULT_DECL that hold the value
16166    to be returned. */
16167
16168 static tree
16169 build_return (location, op)
16170      int location;
16171      tree op;
16172 {
16173   tree node = build1 (RETURN_EXPR, NULL_TREE, op);
16174   EXPR_WFL_LINECOL (node) = location;
16175   node = build_debugable_stmt (location, node);
16176   return node;
16177 }
16178
16179 static tree
16180 patch_return (node)
16181      tree node;
16182 {
16183   tree return_exp = TREE_OPERAND (node, 0);
16184   tree meth = current_function_decl;
16185   tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
16186   int error_found = 0;
16187
16188   TREE_TYPE (node) = error_mark_node;
16189   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16190
16191   /* It's invalid to have a return value within a function that is
16192      declared with the keyword void or that is a constructor */
16193   if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
16194     error_found = 1;
16195
16196   /* It's invalid to use a return statement in a static block */
16197   if (DECL_CLINIT_P (current_function_decl))
16198     error_found = 1;
16199
16200   /* It's invalid to have a no return value within a function that
16201      isn't declared with the keyword `void' */
16202   if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
16203     error_found = 2;
16204   
16205   if (in_instance_initializer)
16206     error_found = 1;
16207
16208   if (error_found)
16209     {
16210       if (in_instance_initializer)
16211         parse_error_context (wfl_operator,
16212                              "`return' inside instance initializer");
16213         
16214       else if (DECL_CLINIT_P (current_function_decl))
16215         parse_error_context (wfl_operator,
16216                              "`return' inside static initializer");
16217
16218       else if (!DECL_CONSTRUCTOR_P (meth))
16219         {
16220           char *t = xstrdup (lang_printable_name (mtype, 0));
16221           parse_error_context (wfl_operator, 
16222                                "`return' with%s value from `%s %s'",
16223                                (error_found == 1 ? "" : "out"), 
16224                                t, lang_printable_name (meth, 0));
16225           free (t);
16226         }
16227       else
16228         parse_error_context (wfl_operator, 
16229                              "`return' with value from constructor `%s'",
16230                              lang_printable_name (meth, 0));
16231       return error_mark_node;
16232     }
16233
16234   /* If we have a return_exp, build a modify expression and expand
16235      it. Note: at that point, the assignment is declared valid, but we
16236      may want to carry some more hacks */
16237   if (return_exp)
16238     {
16239       tree exp = java_complete_tree (return_exp);
16240       tree modify, patched;
16241
16242       /* If the function returned value and EXP are booleans, EXP has
16243       to be converted into the type of DECL_RESULT, which is integer
16244       (see complete_start_java_method) */
16245       if (TREE_TYPE (exp) == boolean_type_node &&
16246           TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
16247         exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
16248
16249       /* `null' can be assigned to a function returning a reference */
16250       if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
16251           exp == null_pointer_node)
16252         exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
16253
16254       if ((patched = patch_string (exp)))
16255         exp = patched;
16256       
16257       modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
16258       EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
16259       modify = java_complete_tree (modify);
16260
16261       if (modify != error_mark_node)
16262         {
16263           TREE_SIDE_EFFECTS (modify) = 1;
16264           TREE_OPERAND (node, 0) = modify;
16265         }
16266       else
16267         return error_mark_node;
16268     }
16269   TREE_TYPE (node) = void_type_node;
16270   TREE_SIDE_EFFECTS (node) = 1;
16271   return node;
16272 }
16273
16274 /* 14.8 The if Statement */
16275
16276 static tree
16277 build_if_else_statement (location, expression, if_body, else_body)
16278      int location;
16279      tree expression, if_body, else_body;
16280 {
16281   tree node;
16282   if (!else_body)
16283     else_body = empty_stmt_node;
16284   node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
16285   EXPR_WFL_LINECOL (node) = location;
16286   node = build_debugable_stmt (location, node);
16287   return node;
16288 }
16289
16290 static tree
16291 patch_if_else_statement (node)
16292      tree node;
16293 {
16294   tree expression = TREE_OPERAND (node, 0);
16295
16296   TREE_TYPE (node) = error_mark_node;
16297   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16298
16299   /* The type of expression must be boolean */
16300   if (TREE_TYPE (expression) != boolean_type_node
16301       && TREE_TYPE (expression) != promoted_boolean_type_node)
16302     {
16303       parse_error_context 
16304         (wfl_operator, 
16305          "Incompatible type for `if'. Can't convert `%s' to `boolean'", 
16306          lang_printable_name (TREE_TYPE (expression), 0));
16307       return error_mark_node;
16308     }
16309   
16310   TREE_TYPE (node) = void_type_node;
16311   TREE_SIDE_EFFECTS (node) = 1;
16312   CAN_COMPLETE_NORMALLY (node)
16313     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16314     | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
16315   return node;
16316 }
16317
16318 /* 14.6 Labeled Statements */
16319
16320 /* Action taken when a lableled statement is parsed. a new
16321    LABELED_BLOCK_EXPR is created. No statement is attached to the
16322    label, yet.  LABEL can be NULL_TREE for artificially-generated blocks. */
16323
16324 static tree
16325 build_labeled_block (location, label)
16326      int location;
16327      tree label;
16328 {
16329   tree label_name ;
16330   tree label_decl, node;
16331   if (label == NULL_TREE || label == continue_identifier_node)
16332     label_name = label;
16333   else
16334     {
16335       label_name = merge_qualified_name (label_id, label);
16336       /* Issue an error if we try to reuse a label that was previously
16337          declared */
16338       if (IDENTIFIER_LOCAL_VALUE (label_name))
16339         {
16340           EXPR_WFL_LINECOL (wfl_operator) = location;
16341           parse_error_context (wfl_operator,
16342             "Declaration of `%s' shadows a previous label declaration",
16343                                IDENTIFIER_POINTER (label));
16344           EXPR_WFL_LINECOL (wfl_operator) = 
16345             EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
16346           parse_error_context (wfl_operator,
16347             "This is the location of the previous declaration of label `%s'",
16348                                IDENTIFIER_POINTER (label));
16349           java_error_count--;
16350         }
16351     }
16352
16353   label_decl = create_label_decl (label_name);
16354   node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
16355   EXPR_WFL_LINECOL (node) = location;
16356   TREE_SIDE_EFFECTS (node) = 1;
16357   return node;
16358 }
16359
16360 /* A labeled statement LBE is attached a statement.  */
16361
16362 static tree
16363 finish_labeled_statement (lbe, statement)
16364      tree lbe;                  /* Labeled block expr */
16365      tree statement;
16366 {
16367   /* In anyways, tie the loop to its statement */
16368   LABELED_BLOCK_BODY (lbe) = statement;
16369   pop_labeled_block ();
16370   POP_LABELED_BLOCK ();
16371   return lbe;
16372 }
16373
16374 /* 14.10, 14.11, 14.12 Loop Statements */
16375
16376 /* Create an empty LOOP_EXPR and make it the last in the nested loop
16377    list. */
16378
16379 static tree
16380 build_new_loop (loop_body)
16381      tree loop_body;
16382 {
16383   tree loop =  build (LOOP_EXPR, NULL_TREE, loop_body);
16384   TREE_SIDE_EFFECTS (loop) = 1;
16385   PUSH_LOOP (loop);
16386   return loop;
16387 }
16388
16389 /* Create a loop body according to the following structure:
16390      COMPOUND_EXPR
16391        COMPOUND_EXPR            (loop main body)
16392          EXIT_EXPR              (this order is for while/for loops.
16393          LABELED_BLOCK_EXPR      the order is reversed for do loops)
16394            LABEL_DECL           (a continue occuring here branches at the 
16395            BODY                  end of this labeled block)
16396        INCREMENT                (if any)
16397
16398   REVERSED, if non zero, tells that the loop condition expr comes
16399   after the body, like in the do-while loop.
16400
16401   To obtain a loop, the loop body structure described above is
16402   encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
16403
16404    LABELED_BLOCK_EXPR
16405      LABEL_DECL                   (use this label to exit the loop)
16406      LOOP_EXPR
16407        <structure described above> */
16408
16409 static tree
16410 build_loop_body (location, condition, reversed)
16411      int location;
16412      tree condition;
16413      int reversed;
16414 {
16415   tree first, second, body;
16416
16417   condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
16418   EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
16419   condition = build_debugable_stmt (location, condition);
16420   TREE_SIDE_EFFECTS (condition) = 1;
16421
16422   body = build_labeled_block (0, continue_identifier_node);
16423   first = (reversed ? body : condition);
16424   second = (reversed ? condition : body);
16425   return 
16426     build (COMPOUND_EXPR, NULL_TREE, 
16427            build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
16428 }
16429
16430 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
16431    their order) on the current loop. Unlink the current loop from the
16432    loop list.  */
16433
16434 static tree
16435 finish_loop_body (location, condition, body, reversed)
16436      int location;
16437      tree condition, body;
16438      int reversed;
16439 {
16440   tree to_return = ctxp->current_loop;
16441   tree loop_body = LOOP_EXPR_BODY (to_return);
16442   if (condition)
16443     {
16444       tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
16445       /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
16446          The real EXIT_EXPR is one operand further. */
16447       EXPR_WFL_LINECOL (cnode) = location;
16448       /* This one is for accurate error reports */
16449       EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
16450       TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
16451     }
16452   LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
16453   POP_LOOP ();
16454   return to_return;
16455 }
16456
16457 /* Tailored version of finish_loop_body for FOR loops, when FOR
16458    loops feature the condition part */
16459
16460 static tree
16461 finish_for_loop (location, condition, update, body)
16462     int location;
16463     tree condition, update, body;
16464 {
16465   /* Put the condition and the loop body in place */
16466   tree loop = finish_loop_body (location, condition, body, 0);
16467   /* LOOP is the current loop which has been now popped of the loop
16468      stack. Install the update block */
16469   LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
16470   return loop;
16471 }
16472
16473 /* Try to find the loop a block might be related to. This comprises
16474    the case where the LOOP_EXPR is found as the second operand of a
16475    COMPOUND_EXPR, because the loop happens to have an initialization
16476    part, then expressed as the first operand of the COMPOUND_EXPR. If
16477    the search finds something, 1 is returned. Otherwise, 0 is
16478    returned. The search is assumed to start from a
16479    LABELED_BLOCK_EXPR's block.  */
16480
16481 static tree
16482 search_loop (statement)
16483     tree statement;
16484 {
16485   if (TREE_CODE (statement) == LOOP_EXPR)
16486     return statement;
16487
16488   if (TREE_CODE (statement) == BLOCK)
16489     statement = BLOCK_SUBBLOCKS (statement);
16490   else
16491     return NULL_TREE;
16492
16493   if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16494     while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16495       statement = TREE_OPERAND (statement, 1);
16496
16497   return (TREE_CODE (statement) == LOOP_EXPR
16498           && FOR_LOOP_P (statement) ? statement : NULL_TREE);
16499 }
16500
16501 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
16502    returned otherwise.  */
16503
16504 static int
16505 labeled_block_contains_loop_p (block, loop)
16506     tree block, loop;
16507 {
16508   if (!block)
16509     return 0;
16510
16511   if (LABELED_BLOCK_BODY (block) == loop)
16512     return 1;
16513
16514   if (FOR_LOOP_P (loop) && search_loop (LABELED_BLOCK_BODY (block)) == loop)
16515     return 1;
16516
16517   return 0;
16518 }
16519
16520 /* If the loop isn't surrounded by a labeled statement, create one and
16521    insert LOOP as its body.  */
16522
16523 static tree
16524 patch_loop_statement (loop)
16525      tree loop;
16526 {
16527   tree loop_label;
16528
16529   TREE_TYPE (loop) = void_type_node;
16530   if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
16531     return loop;
16532
16533   loop_label = build_labeled_block (0, NULL_TREE);
16534   /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
16535      that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
16536   LABELED_BLOCK_BODY (loop_label) = loop;
16537   PUSH_LABELED_BLOCK (loop_label);
16538   return loop_label;
16539 }
16540
16541 /* 14.13, 14.14: break and continue Statements */
16542
16543 /* Build a break or a continue statement. a null NAME indicates an
16544    unlabeled break/continue statement.  */
16545
16546 static tree
16547 build_bc_statement (location, is_break, name)
16548      int location, is_break;
16549      tree name;
16550 {
16551   tree break_continue, label_block_expr = NULL_TREE;
16552
16553   if (name)
16554     {
16555       if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE 
16556             (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
16557         /* Null means that we don't have a target for this named
16558            break/continue. In this case, we make the target to be the
16559            label name, so that the error can be reported accuratly in
16560            patch_bc_statement. */
16561         label_block_expr = EXPR_WFL_NODE (name);
16562     }
16563   /* Unlabeled break/continue will be handled during the
16564      break/continue patch operation */
16565   break_continue 
16566     = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
16567
16568   IS_BREAK_STMT_P (break_continue) = is_break;
16569   TREE_SIDE_EFFECTS (break_continue) = 1;
16570   EXPR_WFL_LINECOL (break_continue) = location;
16571   break_continue = build_debugable_stmt (location, break_continue);
16572   return break_continue;
16573 }
16574
16575 /* Verification of a break/continue statement. */
16576
16577 static tree
16578 patch_bc_statement (node)
16579      tree node;
16580 {
16581   tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
16582   tree labeled_block = ctxp->current_labeled_block;
16583   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16584  
16585   /* Having an identifier here means that the target is unknown. */
16586   if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
16587     {
16588       parse_error_context (wfl_operator, "No label definition found for `%s'",
16589                            IDENTIFIER_POINTER (bc_label));
16590       return error_mark_node;
16591     }
16592   if (! IS_BREAK_STMT_P (node))
16593     {
16594       /* It's a continue statement. */
16595       for (;; labeled_block = TREE_CHAIN (labeled_block))
16596         {
16597           if (labeled_block == NULL_TREE)
16598             {
16599               if (bc_label == NULL_TREE)
16600                 parse_error_context (wfl_operator,
16601                                      "`continue' must be in loop");
16602               else
16603                 parse_error_context 
16604                   (wfl_operator, "continue label `%s' does not name a loop",
16605                    IDENTIFIER_POINTER (bc_label));
16606               return error_mark_node;
16607             }
16608           if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
16609                == continue_identifier_node)
16610               && (bc_label == NULL_TREE
16611                   || TREE_CHAIN (labeled_block) == bc_label))
16612             {
16613               bc_label = labeled_block;
16614               break;
16615             }
16616         }
16617     }
16618   else if (!bc_label)
16619     { 
16620       for (;; labeled_block = TREE_CHAIN (labeled_block))
16621         {
16622           if (labeled_block == NULL_TREE)
16623             {
16624               parse_error_context (wfl_operator,
16625                                      "`break' must be in loop or switch");
16626               return error_mark_node;
16627             }
16628           target_stmt = LABELED_BLOCK_BODY (labeled_block);
16629           if (TREE_CODE (target_stmt) == SWITCH_EXPR
16630               || search_loop (target_stmt))
16631             {
16632               bc_label = labeled_block;
16633               break;
16634             }
16635         }
16636     }
16637
16638   EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
16639   CAN_COMPLETE_NORMALLY (bc_label) = 1;
16640
16641   /* Our break/continue don't return values. */
16642   TREE_TYPE (node) = void_type_node;
16643   /* Encapsulate the break within a compound statement so that it's
16644      expanded all the times by expand_expr (and not clobbered
16645      sometimes, like after a if statement) */
16646   node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
16647   TREE_SIDE_EFFECTS (node) = 1;
16648   return node;
16649 }
16650
16651 /* Process the exit expression belonging to a loop. Its type must be
16652    boolean.  */
16653
16654 static tree
16655 patch_exit_expr (node)
16656      tree node;
16657 {
16658   tree expression = TREE_OPERAND (node, 0);
16659   TREE_TYPE (node) = error_mark_node;
16660   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16661
16662   /* The type of expression must be boolean */
16663   if (TREE_TYPE (expression) != boolean_type_node)
16664     {
16665       parse_error_context 
16666         (wfl_operator, 
16667     "Incompatible type for loop conditional. Can't convert `%s' to `boolean'", 
16668          lang_printable_name (TREE_TYPE (expression), 0));
16669       return error_mark_node;
16670     }
16671   /* Now we know things are allright, invert the condition, fold and
16672      return */
16673   TREE_OPERAND (node, 0) = 
16674     fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
16675
16676   if (! integer_zerop (TREE_OPERAND (node, 0))
16677       && ctxp->current_loop != NULL_TREE
16678       && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
16679     CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
16680   if (! integer_onep (TREE_OPERAND (node, 0)))
16681     CAN_COMPLETE_NORMALLY (node) = 1;
16682
16683
16684   TREE_TYPE (node) = void_type_node;
16685   return node;
16686 }
16687
16688 /* 14.9 Switch statement */
16689
16690 static tree
16691 patch_switch_statement (node)
16692      tree node;
16693 {
16694   tree se = TREE_OPERAND (node, 0), se_type;
16695
16696   /* Complete the switch expression */
16697   se = TREE_OPERAND (node, 0) = java_complete_tree (se);
16698   se_type = TREE_TYPE (se);
16699   /* The type of the switch expression must be char, byte, short or
16700      int */
16701   if (!JINTEGRAL_TYPE_P (se_type))
16702     {
16703       EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16704       parse_error_context (wfl_operator,
16705           "Incompatible type for `switch'. Can't convert `%s' to `int'",
16706                            lang_printable_name (se_type, 0));
16707       /* This is what java_complete_tree will check */
16708       TREE_OPERAND (node, 0) = error_mark_node;
16709       return error_mark_node;
16710     }
16711
16712   TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
16713
16714   /* Ready to return */
16715   if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
16716     {
16717       TREE_TYPE (node) = error_mark_node;
16718       return error_mark_node;
16719     }
16720   TREE_TYPE (node) = void_type_node;
16721   TREE_SIDE_EFFECTS (node) = 1;
16722   CAN_COMPLETE_NORMALLY (node)
16723     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)) 
16724       || ! SWITCH_HAS_DEFAULT (node);
16725   return node;
16726 }
16727
16728 /* 14.18 The try/catch statements */
16729
16730 static tree
16731 build_try_statement (location, try_block, catches)
16732      int location;
16733      tree try_block, catches;
16734 {
16735   tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
16736   EXPR_WFL_LINECOL (node) = location;
16737   return node;
16738 }
16739
16740 static tree
16741 build_try_finally_statement (location, try_block, finally)
16742      int location;
16743      tree try_block, finally;
16744 {
16745   tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
16746   EXPR_WFL_LINECOL (node) = location;
16747   return node;
16748 }
16749
16750 static tree
16751 patch_try_statement (node)
16752      tree node;
16753 {
16754   int error_found = 0;
16755   tree try = TREE_OPERAND (node, 0);
16756   /* Exception handlers are considered in left to right order */
16757   tree catch = nreverse (TREE_OPERAND (node, 1));
16758   tree current, caught_type_list = NULL_TREE;
16759
16760   /* Check catch clauses, if any. Every time we find an error, we try
16761      to process the next catch clause. We process the catch clause before
16762      the try block so that when processing the try block we can check thrown
16763      exceptions againts the caught type list. */
16764   for (current = catch; current; current = TREE_CHAIN (current))
16765     {
16766       tree carg_decl, carg_type;
16767       tree sub_current, catch_block, catch_clause;
16768       int unreachable;
16769
16770       /* At this point, the structure of the catch clause is
16771            CATCH_EXPR           (catch node)
16772              BLOCK              (with the decl of the parameter)
16773                COMPOUND_EXPR
16774                  MODIFY_EXPR   (assignment of the catch parameter)
16775                  BLOCK          (catch clause block)
16776        */
16777       catch_clause = TREE_OPERAND (current, 0);
16778       carg_decl = BLOCK_EXPR_DECLS (catch_clause);
16779       carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
16780
16781       /* Catch clauses can't have more than one parameter declared,
16782          but it's already enforced by the grammar. Make sure that the
16783          only parameter of the clause statement in of class Throwable
16784          or a subclass of Throwable, but that was done earlier. The
16785          catch clause parameter type has also been resolved. */
16786       
16787       /* Just make sure that the catch clause parameter type inherits
16788          from java.lang.Throwable */
16789       if (!inherits_from_p (carg_type, throwable_type_node))
16790         {
16791           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16792           parse_error_context (wfl_operator,
16793                                "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
16794                                lang_printable_name (carg_type, 0));
16795           error_found = 1;
16796           continue;
16797         }
16798       
16799       /* Partial check for unreachable catch statement: The catch
16800          clause is reachable iff is no earlier catch block A in
16801          the try statement such that the type of the catch
16802          clause's parameter is the same as or a subclass of the
16803          type of A's parameter */
16804       unreachable = 0;
16805       for (sub_current = catch;
16806            sub_current != current; sub_current = TREE_CHAIN (sub_current))
16807         {
16808           tree sub_catch_clause, decl;
16809           sub_catch_clause = TREE_OPERAND (sub_current, 0);
16810           decl = BLOCK_EXPR_DECLS (sub_catch_clause);
16811
16812           if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
16813             {
16814               EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16815               parse_error_context 
16816                 (wfl_operator,
16817                  "`catch' not reached because of the catch clause at line %d",
16818                  EXPR_WFL_LINENO (sub_current));
16819               unreachable = error_found = 1;
16820               break;
16821             }
16822         }
16823       /* Complete the catch clause block */
16824       catch_block = java_complete_tree (TREE_OPERAND (current, 0));
16825       if (catch_block == error_mark_node)
16826         {
16827           error_found = 1;
16828           continue;
16829         }
16830       if (CAN_COMPLETE_NORMALLY (catch_block))
16831         CAN_COMPLETE_NORMALLY (node) = 1;
16832       TREE_OPERAND (current, 0) = catch_block;
16833
16834       if (unreachable)
16835         continue;
16836
16837       /* Things to do here: the exception must be thrown */
16838
16839       /* Link this type to the caught type list */
16840       caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
16841     }
16842
16843   PUSH_EXCEPTIONS (caught_type_list);
16844   if ((try = java_complete_tree (try)) == error_mark_node)
16845     error_found = 1;
16846   if (CAN_COMPLETE_NORMALLY (try))
16847     CAN_COMPLETE_NORMALLY (node) = 1;
16848   POP_EXCEPTIONS ();
16849
16850   /* Verification ends here */
16851   if (error_found) 
16852     return error_mark_node;
16853
16854   TREE_OPERAND (node, 0) = try;
16855   TREE_OPERAND (node, 1) = catch;
16856   TREE_TYPE (node) = void_type_node;
16857   return node;
16858 }
16859
16860 /* 14.17 The synchronized Statement */
16861
16862 static tree
16863 patch_synchronized_statement (node, wfl_op1)
16864     tree node, wfl_op1;
16865 {
16866   tree expr = java_complete_tree (TREE_OPERAND (node, 0));
16867   tree block = TREE_OPERAND (node, 1);
16868
16869   tree enter, exit, expr_decl, assignment;
16870
16871   if (expr == error_mark_node)
16872     {
16873       block = java_complete_tree (block);
16874       return expr;
16875     }
16876
16877   /* The TYPE of expr must be a reference type */
16878   if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
16879     {
16880       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16881       parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
16882                            lang_printable_name (TREE_TYPE (expr), 0));
16883       return error_mark_node;
16884     }
16885
16886   if (flag_emit_xref)
16887     {
16888       TREE_OPERAND (node, 0) = expr;
16889       TREE_OPERAND (node, 1) = java_complete_tree (block);
16890       CAN_COMPLETE_NORMALLY (node) = 1;
16891       return node;
16892     }
16893
16894   /* Generate a try-finally for the synchronized statement, except
16895      that the handler that catches all throw exception calls
16896      _Jv_MonitorExit and then rethrow the exception.
16897      The synchronized statement is then implemented as:
16898      TRY 
16899        {
16900          _Jv_MonitorEnter (expression)
16901          synchronized_block
16902          _Jv_MonitorExit (expression)
16903        }
16904      CATCH_ALL
16905        {
16906          e = _Jv_exception_info ();
16907          _Jv_MonitorExit (expression)
16908          Throw (e);
16909        } */
16910
16911   expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
16912   BUILD_MONITOR_ENTER (enter, expr_decl);
16913   BUILD_MONITOR_EXIT (exit, expr_decl);
16914   CAN_COMPLETE_NORMALLY (enter) = 1;
16915   CAN_COMPLETE_NORMALLY (exit) = 1;
16916   assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
16917   TREE_SIDE_EFFECTS (assignment) = 1;
16918   node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
16919                  build (COMPOUND_EXPR, NULL_TREE,
16920                         build (WITH_CLEANUP_EXPR, NULL_TREE,
16921                                build (COMPOUND_EXPR, NULL_TREE,
16922                                       assignment, enter),
16923                                NULL_TREE, exit),
16924                         block));
16925   node = build_expr_block (node, expr_decl);
16926
16927   return java_complete_tree (node);
16928 }
16929
16930 /* 14.16 The throw Statement */
16931
16932 static tree
16933 patch_throw_statement (node, wfl_op1)
16934     tree node, wfl_op1;
16935 {
16936   tree expr = TREE_OPERAND (node, 0);
16937   tree type = TREE_TYPE (expr);
16938   int unchecked_ok = 0, tryblock_throws_ok = 0;
16939
16940   /* Thrown expression must be assignable to java.lang.Throwable */
16941   if (!try_reference_assignconv (throwable_type_node, expr))
16942     {
16943       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16944       parse_error_context (wfl_operator,
16945     "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
16946                            lang_printable_name (type, 0));
16947       /* If the thrown expression was a reference, we further the
16948          compile-time check. */
16949       if (!JREFERENCE_TYPE_P (type))
16950         return error_mark_node;
16951     }
16952
16953   /* At least one of the following must be true */
16954
16955   /* The type of the throw expression is a not checked exception,
16956      i.e. is a unchecked expression. */
16957   unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
16958
16959   SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16960   /* An instance can't throw a checked excetion unless that exception
16961      is explicitely declared in the `throws' clause of each
16962      constructor. This doesn't apply to anonymous classes, since they
16963      don't have declared constructors. */
16964   if (!unchecked_ok 
16965       && in_instance_initializer && !ANONYMOUS_CLASS_P (current_class))
16966     {
16967       tree current;
16968       for (current = TYPE_METHODS (current_class); current; 
16969            current = TREE_CHAIN (current))
16970         if (DECL_CONSTRUCTOR_P (current) 
16971             && !check_thrown_exceptions_do (TREE_TYPE (expr)))
16972           {
16973             parse_error_context (wfl_operator, "Checked exception `%s' can't be thrown in instance initializer (not all declared constructor are declaring it in their `throws' clause)", 
16974                                  lang_printable_name (TREE_TYPE (expr), 0));
16975             return error_mark_node;
16976           }
16977     }
16978
16979   /* Throw is contained in a try statement and at least one catch
16980      clause can receive the thrown expression or the current method is
16981      declared to throw such an exception. Or, the throw statement is
16982      contained in a method or constructor declaration and the type of
16983      the Expression is assignable to at least one type listed in the
16984      throws clause the declaration. */
16985   if (!unchecked_ok)
16986     tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
16987   if (!(unchecked_ok || tryblock_throws_ok))
16988     {
16989       /* If there is a surrounding try block that has no matching
16990          clatch clause, report it first. A surrounding try block exits
16991          only if there is something after the list of checked
16992          exception thrown by the current function (if any). */
16993       if (IN_TRY_BLOCK_P ())
16994         parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
16995                              lang_printable_name (type, 0));
16996       /* If we have no surrounding try statement and the method doesn't have
16997          any throws, report it now. FIXME */
16998
16999       /* We report that the exception can't be throw from a try block
17000          in all circumstances but when the `throw' is inside a static
17001          block. */
17002       else if (!EXCEPTIONS_P (currently_caught_type_list) 
17003                && !tryblock_throws_ok)
17004         {
17005           if (DECL_CLINIT_P (current_function_decl))
17006             parse_error_context (wfl_operator,
17007                    "Checked exception `%s' can't be thrown in initializer",
17008                                  lang_printable_name (type, 0));
17009           else
17010             parse_error_context (wfl_operator,
17011                    "Checked exception `%s' isn't thrown from a `try' block", 
17012                                  lang_printable_name (type, 0));
17013         }
17014       /* Otherwise, the current method doesn't have the appropriate
17015          throws declaration */
17016       else
17017         parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)", 
17018                              lang_printable_name (type, 0));
17019       return error_mark_node;
17020     }
17021
17022   if (! flag_emit_class_files && ! flag_emit_xref)
17023     BUILD_THROW (node, expr);
17024
17025   /* If doing xrefs, keep the location where the `throw' was seen. */
17026   if (flag_emit_xref)
17027     EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
17028   return node;
17029 }
17030
17031 /* Check that exception said to be thrown by method DECL can be
17032    effectively caught from where DECL is invoked.  */
17033
17034 static void
17035 check_thrown_exceptions (location, decl)
17036      int location;
17037      tree decl;
17038 {
17039   tree throws;
17040   /* For all the unchecked exceptions thrown by DECL */
17041   for (throws = DECL_FUNCTION_THROWS (decl); throws; 
17042        throws = TREE_CHAIN (throws)) 
17043     if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
17044       {
17045 #if 1
17046         /* Temporary hack to suppresses errors about cloning arrays. FIXME */
17047         if (DECL_NAME (decl) == get_identifier ("clone"))
17048           continue;
17049 #endif
17050         EXPR_WFL_LINECOL (wfl_operator) = location;
17051         if (DECL_FINIT_P (current_function_decl))
17052           parse_error_context
17053             (wfl_operator, "Exception `%s' can't be thrown in initializer",
17054              lang_printable_name (TREE_VALUE (throws), 0));
17055         else 
17056           {
17057             parse_error_context 
17058               (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'", 
17059                lang_printable_name (TREE_VALUE (throws), 0),
17060                (DECL_INIT_P (current_function_decl) ?
17061                 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
17062                 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
17063           }
17064       }
17065 }
17066
17067 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
17068    try-catch blocks, OR is listed in the `throws' clause of the
17069    current method.  */
17070
17071 static int
17072 check_thrown_exceptions_do (exception)
17073      tree exception;
17074 {
17075   tree list = currently_caught_type_list;
17076   resolve_and_layout (exception, NULL_TREE);
17077   /* First, all the nested try-catch-finally at that stage. The
17078      last element contains `throws' clause exceptions, if any. */
17079   if (IS_UNCHECKED_EXCEPTION_P (exception))
17080     return 1;
17081   while (list)
17082     {
17083       tree caught;
17084       for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
17085         if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
17086           return 1;
17087       list = TREE_CHAIN (list);
17088     }
17089   return 0;
17090 }
17091
17092 static void
17093 purge_unchecked_exceptions (mdecl)
17094      tree mdecl;
17095 {
17096   tree throws = DECL_FUNCTION_THROWS (mdecl);
17097   tree new = NULL_TREE;
17098
17099   while (throws)
17100     {
17101       tree next = TREE_CHAIN (throws);
17102       if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
17103         {
17104           TREE_CHAIN (throws) = new;
17105           new = throws;
17106         }
17107       throws = next;
17108     }
17109   /* List is inverted here, but it doesn't matter */
17110   DECL_FUNCTION_THROWS (mdecl) = new;
17111 }
17112
17113 /* 15.24 Conditional Operator ?: */
17114
17115 static tree
17116 patch_conditional_expr (node, wfl_cond, wfl_op1)
17117      tree node, wfl_cond, wfl_op1;
17118 {
17119   tree cond = TREE_OPERAND (node, 0);
17120   tree op1 = TREE_OPERAND (node, 1);
17121   tree op2 = TREE_OPERAND (node, 2);
17122   tree resulting_type = NULL_TREE;
17123   tree t1, t2, patched;
17124   int error_found = 0;
17125
17126   /* Operands of ?: might be StringBuffers crafted as a result of a
17127      string concatenation. Obtain a descent operand here.  */
17128   if ((patched = patch_string (op1)))
17129     TREE_OPERAND (node, 1) = op1 = patched;
17130   if ((patched = patch_string (op2)))
17131     TREE_OPERAND (node, 2) = op2 = patched;
17132
17133   t1 = TREE_TYPE (op1);
17134   t2 = TREE_TYPE (op2);
17135
17136   /* The first expression must be a boolean */
17137   if (TREE_TYPE (cond) != boolean_type_node)
17138     {
17139       SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
17140       parse_error_context (wfl_operator,
17141                "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
17142                            lang_printable_name (TREE_TYPE (cond), 0));
17143       error_found = 1;
17144     }
17145
17146   /* Second and third can be numeric, boolean (i.e. primitive),
17147      references or null. Anything else results in an error */
17148   if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
17149         || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node) 
17150             && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
17151         || (t1 == boolean_type_node && t2 == boolean_type_node)))
17152     error_found = 1;
17153
17154   /* Determine the type of the conditional expression. Same types are
17155      easy to deal with */
17156   else if (t1 == t2)
17157     resulting_type = t1;
17158
17159   /* There are different rules for numeric types */
17160   else if (JNUMERIC_TYPE_P (t1))
17161     {
17162       /* if byte/short found, the resulting type is short */
17163       if ((t1 == byte_type_node && t2 == short_type_node)
17164           || (t1 == short_type_node && t2 == byte_type_node))
17165         resulting_type = short_type_node;
17166
17167       /* If t1 is a constant int and t2 is of type byte, short or char
17168          and t1's value fits in t2, then the resulting type is t2 */
17169       else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
17170           && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
17171         resulting_type = t2;
17172
17173       /* If t2 is a constant int and t1 is of type byte, short or char
17174          and t2's value fits in t1, then the resulting type is t1 */
17175       else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
17176           && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
17177         resulting_type = t1;
17178
17179       /* Otherwise, binary numeric promotion is applied and the
17180          resulting type is the promoted type of operand 1 and 2 */
17181       else 
17182         resulting_type = binary_numeric_promotion (t1, t2, 
17183                                                    &TREE_OPERAND (node, 1), 
17184                                                    &TREE_OPERAND (node, 2));
17185     }
17186
17187   /* Cases of a reference and a null type */
17188   else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
17189     resulting_type = t1;
17190
17191   else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
17192     resulting_type = t2;
17193
17194   /* Last case: different reference types. If a type can be converted
17195      into the other one by assignment conversion, the latter
17196      determines the type of the expression */
17197   else if ((resulting_type = try_reference_assignconv (t1, op2)))
17198     resulting_type = promote_type (t1);
17199
17200   else if ((resulting_type = try_reference_assignconv (t2, op1)))
17201     resulting_type = promote_type (t2);
17202
17203   /* If we don't have any resulting type, we're in trouble */
17204   if (!resulting_type)
17205     {
17206       char *t = xstrdup (lang_printable_name (t1, 0));
17207       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17208       parse_error_context (wfl_operator,
17209                  "Incompatible type for `?:'. Can't convert `%s' to `%s'",
17210                            t, lang_printable_name (t2, 0));
17211       free (t);
17212       error_found = 1;
17213     }
17214
17215   if (error_found)
17216     {
17217       TREE_TYPE (node) = error_mark_node;
17218       return error_mark_node;
17219     }
17220
17221   TREE_TYPE (node) = resulting_type;
17222   TREE_SET_CODE (node, COND_EXPR);
17223   CAN_COMPLETE_NORMALLY (node) = 1;
17224   return node;
17225 }
17226
17227 /* Try to constant fold NODE.
17228    If NODE is not a constant expression, return NULL_EXPR.
17229    CONTEXT is a static final VAR_DECL whose initializer we are folding. */
17230
17231 static tree
17232 fold_constant_for_init (node, context)
17233      tree node;
17234      tree context;
17235 {
17236   tree op0, op1, val;
17237   enum tree_code code = TREE_CODE (node);
17238
17239   if (code == STRING_CST)
17240     return node;
17241
17242   if (code == INTEGER_CST || code == REAL_CST)
17243     return convert (TREE_TYPE (context), node);
17244   if (TREE_TYPE (node) != NULL_TREE && code != VAR_DECL && code != FIELD_DECL)
17245     return NULL_TREE;
17246
17247   switch (code)
17248     {
17249     case PLUS_EXPR:
17250     case MINUS_EXPR:
17251     case MULT_EXPR:
17252     case TRUNC_MOD_EXPR:
17253     case RDIV_EXPR:
17254     case LSHIFT_EXPR:
17255     case RSHIFT_EXPR:
17256     case URSHIFT_EXPR:
17257     case BIT_AND_EXPR:
17258     case BIT_XOR_EXPR:
17259     case BIT_IOR_EXPR:
17260     case TRUTH_ANDIF_EXPR:
17261     case TRUTH_ORIF_EXPR:
17262     case EQ_EXPR: 
17263     case NE_EXPR:
17264     case GT_EXPR:
17265     case GE_EXPR:
17266     case LT_EXPR:
17267     case LE_EXPR:
17268       op0 = TREE_OPERAND (node, 0);
17269       op1 = TREE_OPERAND (node, 1);
17270       val = fold_constant_for_init (op0, context);
17271       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17272         return NULL_TREE;
17273       TREE_OPERAND (node, 0) = val;
17274       val = fold_constant_for_init (op1, context);
17275       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17276         return NULL_TREE;
17277       TREE_OPERAND (node, 1) = val;
17278       return patch_binop (node, op0, op1);
17279
17280     case UNARY_PLUS_EXPR:
17281     case NEGATE_EXPR:
17282     case TRUTH_NOT_EXPR:
17283     case BIT_NOT_EXPR:
17284     case CONVERT_EXPR:
17285       op0 = TREE_OPERAND (node, 0);
17286       val = fold_constant_for_init (op0, context);
17287       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17288         return NULL_TREE;
17289       TREE_OPERAND (node, 0) = val;
17290       return patch_unaryop (node, op0);
17291       break;
17292
17293     case COND_EXPR:
17294       val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
17295       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17296         return NULL_TREE;
17297       TREE_OPERAND (node, 0) = val;
17298       val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
17299       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17300         return NULL_TREE;
17301       TREE_OPERAND (node, 1) = val;
17302       val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
17303       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17304         return NULL_TREE;
17305       TREE_OPERAND (node, 2) = val;
17306       return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
17307         : TREE_OPERAND (node, 2);
17308
17309     case VAR_DECL:
17310     case FIELD_DECL:
17311       if (! FIELD_FINAL (node)
17312           || DECL_INITIAL (node) == NULL_TREE)
17313         return NULL_TREE;
17314       val = DECL_INITIAL (node);
17315       /* Guard against infinite recursion. */
17316       DECL_INITIAL (node) = NULL_TREE;
17317       val = fold_constant_for_init (val, node);
17318       DECL_INITIAL (node) = val;
17319       return val;
17320
17321     case EXPR_WITH_FILE_LOCATION:
17322       /* Compare java_complete_tree and resolve_expression_name. */
17323       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
17324           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
17325         {
17326           tree name = EXPR_WFL_NODE (node);
17327           tree decl;
17328           if (PRIMARY_P (node))
17329             return NULL_TREE;
17330           else if (! QUALIFIED_P (name))
17331             {
17332               decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
17333               if (decl == NULL_TREE 
17334                   || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
17335                 return NULL_TREE;
17336               return fold_constant_for_init (decl, decl);
17337             }
17338           else
17339             {
17340               /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
17341               qualify_ambiguous_name (node);
17342               if (resolve_field_access (node, &decl, NULL)
17343                   && decl != NULL_TREE)
17344                 return fold_constant_for_init (decl, decl);
17345               return NULL_TREE;
17346             }
17347         }
17348       else
17349         {
17350           op0 = TREE_OPERAND (node, 0);
17351           val = fold_constant_for_init (op0, context);
17352           if (val == NULL_TREE || ! TREE_CONSTANT (val))
17353             return NULL_TREE;
17354           TREE_OPERAND (node, 0) = val;
17355           return val;
17356         }
17357
17358 #ifdef USE_COMPONENT_REF
17359     case IDENTIFIER:
17360     case COMPONENT_REF:
17361       ?;
17362 #endif
17363
17364     default:
17365       return NULL_TREE;
17366     }
17367 }
17368
17369 #ifdef USE_COMPONENT_REF
17370 /* Context is 'T' for TypeName, 'P' for PackageName,
17371    'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
17372
17373 tree
17374 resolve_simple_name (name, context)
17375      tree name;
17376      int context;
17377 {
17378 }
17379
17380 tree
17381 resolve_qualified_name (name, context)
17382      tree name;
17383      int context;
17384 {
17385 }
17386 #endif