OSDN Git Service

2000-04-24 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 int maybe_yank_clinit PARAMS ((tree));
215 static void java_complete_expand_method PARAMS ((tree));
216 static int  unresolved_type_p PARAMS ((tree, tree *));
217 static void create_jdep_list PARAMS ((struct parser_ctxt *));
218 static tree build_expr_block PARAMS ((tree, tree));
219 static tree enter_block PARAMS ((void));
220 static tree enter_a_block PARAMS ((tree));
221 static tree exit_block PARAMS ((void));
222 static tree lookup_name_in_blocks PARAMS ((tree));
223 static void maybe_absorb_scoping_blocks PARAMS ((void));
224 static tree build_method_invocation PARAMS ((tree, tree));
225 static tree build_new_invocation PARAMS ((tree, tree));
226 static tree build_assignment PARAMS ((int, int, tree, tree));
227 static tree build_binop PARAMS ((enum tree_code, int, tree, tree));
228 static int check_final_assignment PARAMS ((tree ,tree));
229 static tree patch_assignment PARAMS ((tree, tree, tree ));
230 static tree patch_binop PARAMS ((tree, tree, tree));
231 static tree build_unaryop PARAMS ((int, int, tree));
232 static tree build_incdec PARAMS ((int, int, tree, int));
233 static tree patch_unaryop PARAMS ((tree, tree));
234 static tree build_cast PARAMS ((int, tree, tree));
235 static tree build_null_of_type PARAMS ((tree));
236 static tree patch_cast PARAMS ((tree, tree));
237 static int valid_ref_assignconv_cast_p PARAMS ((tree, tree, int));
238 static int valid_builtin_assignconv_identity_widening_p PARAMS ((tree, tree));
239 static int valid_cast_to_p PARAMS ((tree, tree));
240 static int valid_method_invocation_conversion_p PARAMS ((tree, tree));
241 static tree try_builtin_assignconv PARAMS ((tree, tree, tree));
242 static tree try_reference_assignconv PARAMS ((tree, tree));
243 static tree build_unresolved_array_type PARAMS ((tree));
244 static tree build_array_from_name PARAMS ((tree, tree, tree, tree *));
245 static tree build_array_ref PARAMS ((int, tree, tree));
246 static tree patch_array_ref PARAMS ((tree));
247 static tree make_qualified_name PARAMS ((tree, tree, int));
248 static tree merge_qualified_name PARAMS ((tree, tree));
249 static tree make_qualified_primary PARAMS ((tree, tree, int));
250 static int resolve_qualified_expression_name PARAMS ((tree, tree *, 
251                                                      tree *, tree *));
252 static void qualify_ambiguous_name PARAMS ((tree));
253 static tree resolve_field_access PARAMS ((tree, tree *, tree *));
254 static tree build_newarray_node PARAMS ((tree, tree, int));
255 static tree patch_newarray PARAMS ((tree));
256 static tree resolve_type_during_patch PARAMS ((tree));
257 static tree build_this PARAMS ((int));
258 static tree build_wfl_wrap PARAMS ((tree));
259 static tree build_return PARAMS ((int, tree));
260 static tree patch_return PARAMS ((tree));
261 static tree maybe_access_field PARAMS ((tree, tree, tree));
262 static int complete_function_arguments PARAMS ((tree));
263 static int check_for_static_method_reference PARAMS ((tree, tree, tree, 
264                                                       tree, tree));
265 static int not_accessible_p PARAMS ((tree, tree, int));
266 static void check_deprecation PARAMS ((tree, tree));
267 static int class_in_current_package PARAMS ((tree));
268 static tree build_if_else_statement PARAMS ((int, tree, tree, tree));
269 static tree patch_if_else_statement PARAMS ((tree));
270 static tree add_stmt_to_compound PARAMS ((tree, tree, tree));
271 static tree add_stmt_to_block PARAMS ((tree, tree, tree));
272 static tree patch_exit_expr PARAMS ((tree));
273 static tree build_labeled_block PARAMS ((int, tree));
274 static tree finish_labeled_statement PARAMS ((tree, tree));
275 static tree build_bc_statement PARAMS ((int, int, tree));
276 static tree patch_bc_statement PARAMS ((tree));
277 static tree patch_loop_statement PARAMS ((tree));
278 static tree build_new_loop PARAMS ((tree));
279 static tree build_loop_body PARAMS ((int, tree, int));
280 static tree finish_loop_body PARAMS ((int, tree, tree, int));
281 static tree build_debugable_stmt PARAMS ((int, tree));
282 static tree finish_for_loop PARAMS ((int, tree, tree, tree));
283 static tree patch_switch_statement PARAMS ((tree));
284 static tree string_constant_concatenation PARAMS ((tree, tree));
285 static tree build_string_concatenation PARAMS ((tree, tree));
286 static tree patch_string_cst PARAMS ((tree));
287 static tree patch_string PARAMS ((tree));
288 static tree build_try_statement PARAMS ((int, tree, tree));
289 static tree build_try_finally_statement PARAMS ((int, tree, tree));
290 static tree patch_try_statement PARAMS ((tree));
291 static tree patch_synchronized_statement PARAMS ((tree, tree));
292 static tree patch_throw_statement PARAMS ((tree, tree));
293 static void check_thrown_exceptions PARAMS ((int, tree));
294 static int check_thrown_exceptions_do PARAMS ((tree));
295 static void purge_unchecked_exceptions PARAMS ((tree));
296 static void check_throws_clauses PARAMS ((tree, tree, tree));
297 static void finish_method_declaration PARAMS ((tree));
298 static tree build_super_invocation PARAMS ((tree));
299 static int verify_constructor_circularity PARAMS ((tree, tree));
300 static char *constructor_circularity_msg PARAMS ((tree, tree));
301 static tree build_this_super_qualified_invocation PARAMS ((int, tree, tree,
302                                                           int, int));
303 static const char *get_printable_method_name PARAMS ((tree));
304 static tree patch_conditional_expr PARAMS ((tree, tree, tree));
305 static tree generate_finit PARAMS ((tree));
306 static void add_instance_initializer PARAMS ((tree));
307 static void fix_constructors PARAMS ((tree));
308 static tree build_alias_initializer_parameter_list PARAMS ((int, tree,
309                                                             tree, int *));
310 static void craft_constructor PARAMS ((tree, tree));
311 static int verify_constructor_super PARAMS ((tree));
312 static tree create_artificial_method PARAMS ((tree, int, tree, tree, tree));
313 static void start_artificial_method_body PARAMS ((tree));
314 static void end_artificial_method_body PARAMS ((tree));
315 static int check_method_redefinition PARAMS ((tree, tree));
316 static int reset_method_name PARAMS ((tree));
317 static int check_method_types_complete PARAMS ((tree));
318 static void java_check_regular_methods PARAMS ((tree));
319 static void java_check_abstract_methods PARAMS ((tree));
320 static tree maybe_build_primttype_type_ref PARAMS ((tree, tree));
321 static void unreachable_stmt_error PARAMS ((tree));
322 static tree find_expr_with_wfl PARAMS ((tree));
323 static void missing_return_error PARAMS ((tree));
324 static tree build_new_array_init PARAMS ((int, tree));
325 static tree patch_new_array_init PARAMS ((tree, tree));
326 static tree maybe_build_array_element_wfl PARAMS ((tree));
327 static int array_constructor_check_entry PARAMS ((tree, tree));
328 static const char *purify_type_name PARAMS ((const char *));
329 static tree fold_constant_for_init PARAMS ((tree, tree));
330 static tree strip_out_static_field_access_decl PARAMS ((tree));
331 static jdeplist *reverse_jdep_list PARAMS ((struct parser_ctxt *));
332 static void static_ref_err PARAMS ((tree, tree, tree));
333 static void parser_add_interface PARAMS ((tree, tree, tree));
334 static void add_superinterfaces PARAMS ((tree, tree));
335 static tree jdep_resolve_class PARAMS ((jdep *));
336 static int note_possible_classname PARAMS ((const char *, int));
337 static void java_complete_expand_classes PARAMS ((void));
338 static void java_complete_expand_class PARAMS ((tree));
339 static void java_complete_expand_methods PARAMS ((tree));
340 static tree cut_identifier_in_qualified PARAMS ((tree));
341 static tree java_stabilize_reference PARAMS ((tree));
342 static tree do_unary_numeric_promotion PARAMS ((tree));
343 static char * operator_string PARAMS ((tree));
344 static tree do_merge_string_cste PARAMS ((tree, const char *, int, int));
345 static tree merge_string_cste PARAMS ((tree, tree, int));
346 static tree java_refold PARAMS ((tree));
347 static int java_decl_equiv PARAMS ((tree, tree));
348 static int binop_compound_p PARAMS ((enum tree_code));
349 static tree search_loop PARAMS ((tree));
350 static int labeled_block_contains_loop_p PARAMS ((tree, tree));
351 static void check_abstract_method_definitions PARAMS ((int, tree, tree));
352 static void java_check_abstract_method_definitions PARAMS ((tree));
353 static void java_debug_context_do PARAMS ((int));
354 static void java_parser_context_push_initialized_field PARAMS ((void));
355 static void java_parser_context_pop_initialized_field PARAMS ((void));
356 static tree reorder_static_initialized PARAMS ((tree));
357 static void java_parser_context_suspend PARAMS ((void));
358 static void java_parser_context_resume PARAMS ((void));
359
360 /* JDK 1.1 work. FIXME */
361
362 static tree maybe_make_nested_class_name PARAMS ((tree));
363 static void make_nested_class_name PARAMS ((tree));
364 static void set_nested_class_simple_name_value PARAMS ((tree, int));
365 static void link_nested_class_to_enclosing PARAMS ((void));
366 static tree find_as_inner_class PARAMS ((tree, tree, tree));
367 static tree find_as_inner_class_do PARAMS ((tree, tree));
368 static int check_inner_class_redefinition PARAMS ((tree, tree));
369
370 static tree build_thisn_assign PARAMS ((void));
371 static tree build_current_thisn PARAMS ((tree));
372 static tree build_access_to_thisn PARAMS ((tree, tree, int));
373 static tree maybe_build_thisn_access_method PARAMS ((tree));
374
375 static tree build_outer_field_access PARAMS ((tree, tree));
376 static tree build_outer_field_access_methods PARAMS ((tree));
377 static tree build_outer_field_access_expr PARAMS ((int, tree, tree, 
378                                                   tree, tree));
379 static tree build_outer_method_access_method PARAMS ((tree));
380 static tree build_new_access_id PARAMS ((void));
381 static tree build_outer_field_access_method PARAMS ((tree, tree, tree,
382                                                     tree, tree));
383
384 static int outer_field_access_p PARAMS ((tree, tree));
385 static int outer_field_expanded_access_p PARAMS ((tree, tree *, 
386                                                  tree *, tree *));
387 static tree outer_field_access_fix PARAMS ((tree, tree, tree));
388 static tree build_incomplete_class_ref PARAMS ((int, tree));
389 static tree patch_incomplete_class_ref PARAMS ((tree));
390 static tree create_anonymous_class PARAMS ((int, tree));
391 static void patch_anonymous_class PARAMS ((tree, tree, tree));
392 static void add_inner_class_fields PARAMS ((tree, tree));
393
394 static tree build_dot_class_method PARAMS ((tree));
395 static tree build_dot_class_method_invocation PARAMS ((tree));
396 static void create_new_parser_context PARAMS ((int));
397
398 /* Number of error found so far. */
399 int java_error_count; 
400 /* Number of warning found so far. */
401 int java_warning_count;
402 /* Tell when not to fold, when doing xrefs */
403 int do_not_fold;
404 /* Cyclic inheritance report, as it can be set by layout_class */
405 char *cyclic_inheritance_report;
406
407 /* Tell when we're within an instance initializer */
408 static int in_instance_initializer;
409
410 /* The current parser context */
411 struct parser_ctxt *ctxp;
412
413 /* List of things that were analyzed for which code will be generated */
414 static struct parser_ctxt *ctxp_for_generation = NULL;
415
416 /* binop_lookup maps token to tree_code. It is used where binary
417    operations are involved and required by the parser. RDIV_EXPR
418    covers both integral/floating point division. The code is changed
419    once the type of both operator is worked out.  */
420
421 static enum tree_code binop_lookup[19] = 
422   { 
423     PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
424     LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR, 
425     BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
426     TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
427     EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
428    };
429 #define BINOP_LOOKUP(VALUE)                                             \
430   binop_lookup [((VALUE) - PLUS_TK)%                                    \
431                 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
432
433 /* This is the end index for binary operators that can also be used
434    in compound assignements. */
435 #define BINOP_COMPOUND_CANDIDATES 11
436
437 /* Fake WFL used to report error message. It is initialized once if
438    needed and reused with it's location information is overriden.  */
439 tree wfl_operator = NULL_TREE;
440
441 /* The "$L" identifier we use to create labels.  */
442 static tree label_id = NULL_TREE;
443
444 /* The "StringBuffer" identifier used for the String `+' operator. */
445 static tree wfl_string_buffer = NULL_TREE; 
446
447 /* The "append" identifier used for String `+' operator.  */
448 static tree wfl_append = NULL_TREE;
449
450 /* The "toString" identifier used for String `+' operator. */
451 static tree wfl_to_string = NULL_TREE;
452
453 /* The "java.lang" import qualified name.  */
454 static tree java_lang_id = NULL_TREE;
455
456 /* The generated `inst$' identifier used for generated enclosing
457    instance/field access functions.  */
458 static tree inst_id = NULL_TREE;
459
460 /* The "java.lang.Cloneable" qualified name.  */
461 static tree java_lang_cloneable = NULL_TREE;
462
463 /* Context and flag for static blocks */
464 static tree current_static_block = NULL_TREE;
465
466 /* The generated `write_parm_value$' identifier.  */
467 static tree wpv_id;
468
469 /* The list of all packages we've seen so far */
470 static tree package_list = NULL_TREE;
471  
472 /* Check modifiers. If one doesn't fit, retrieve it in its declaration
473    line and point it out.  */
474 /* Should point out the one that don't fit. ASCII/unicode, going
475    backward. FIXME */
476
477 #define check_modifiers(__message, __value, __mask) do {        \
478   if ((__value) & ~(__mask))                                    \
479     {                                                           \
480       int i, remainder = (__value) & ~(__mask);                 \
481       for (i = 0; i <= 10; i++)                                 \
482         if ((1 << i) & remainder)                               \
483           parse_error_context (ctxp->modifier_ctx [i], (__message), \
484                                java_accstring_lookup (1 << i)); \
485     }                                                           \
486 } while (0)
487
488
489 #line 415 "./parse.y"
490 typedef union {
491   tree node;
492   int sub_token;
493   struct {
494     int token;
495     int location;
496   } operator;
497   int value;
498 } YYSTYPE;
499 #line 425 "./parse.y"
500
501 #include "lex.c"
502 #ifndef YYDEBUG
503 #define YYDEBUG 1
504 #endif
505
506 #include <stdio.h>
507
508 #ifndef __cplusplus
509 #ifndef __STDC__
510 #define const
511 #endif
512 #endif
513
514
515
516 #define YYFINAL         791
517 #define YYFLAG          -32768
518 #define YYNTBASE        110
519
520 #define YYTRANSLATE(x) ((unsigned)(x) <= 363 ? yytranslate[x] : 272)
521
522 static const char yytranslate[] = {     0,
523      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
524      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
525      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
526      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
527      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
528      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
529      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
530      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
531      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
532      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
533      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
534      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
535      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
536      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
537      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
538      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
539      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
540      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
541      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
542      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
543      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
544      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
545      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
546      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
547      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
548      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
549      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
550     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
551     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
552     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
553     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
554     57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
555     67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
556     77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
557     87,    88,    89,    90,    91,    92,    93,    94,    95,    96,
558     97,    98,    99,   100,   101,   102,   103,   104,   105,   106,
559    107,   108,   109
560 };
561
562 #if YYDEBUG != 0
563 static const short yyprhs[] = {     0,
564      0,     2,     4,     6,     8,    10,    12,    14,    16,    18,
565     20,    22,    24,    26,    28,    30,    32,    34,    38,    42,
566     46,    50,    54,    56,    58,    60,    64,    66,    67,    69,
567     71,    73,    76,    79,    82,    86,    88,    91,    93,    96,
568    100,   103,   107,   109,   111,   115,   118,   122,   128,   133,
569    139,   141,   143,   145,   147,   149,   152,   153,   161,   162,
570    169,   173,   176,   180,   185,   186,   189,   193,   196,   197,
571    200,   203,   205,   209,   213,   216,   220,   222,   225,   227,
572    229,   231,   233,   235,   238,   240,   242,   244,   248,   253,
573    255,   259,   263,   265,   269,   273,   278,   280,   284,   287,
574    291,   295,   297,   299,   300,   304,   307,   311,   315,   320,
575    325,   328,   332,   335,   339,   342,   346,   351,   355,   359,
576    363,   365,   369,   373,   376,   380,   383,   387,   389,   390,
577    393,   396,   398,   402,   406,   408,   411,   413,   416,   420,
578    422,   423,   427,   430,   434,   438,   443,   446,   450,   454,
579    459,   461,   464,   469,   475,   483,   490,   492,   494,   495,
580    500,   501,   507,   508,   514,   515,   522,   526,   531,   534,
581    538,   541,   545,   548,   552,   554,   557,   559,   561,   563,
582    565,   567,   570,   573,   576,   580,   585,   587,   591,   595,
583    598,   602,   604,   606,   608,   611,   613,   615,   617,   620,
584    623,   627,   629,   631,   633,   635,   637,   639,   641,   643,
585    645,   647,   649,   651,   653,   655,   657,   659,   661,   663,
586    665,   667,   669,   671,   673,   676,   679,   682,   685,   688,
587    691,   694,   697,   701,   706,   711,   717,   722,   728,   735,
588    743,   750,   752,   754,   756,   758,   760,   762,   764,   770,
589    773,   777,   782,   790,   798,   799,   803,   808,   811,   815,
590    821,   824,   828,   832,   837,   839,   842,   845,   847,   850,
591    854,   857,   860,   864,   867,   872,   875,   878,   882,   887,
592    890,   892,   900,   908,   915,   919,   925,   930,   938,   945,
593    948,   951,   955,   958,   959,   961,   963,   966,   967,   969,
594    971,   975,   979,   982,   986,   989,   993,   996,  1000,  1003,
595   1007,  1010,  1014,  1017,  1021,  1025,  1028,  1032,  1038,  1044,
596   1047,  1052,  1056,  1058,  1062,  1066,  1071,  1074,  1076,  1079,
597   1082,  1087,  1090,  1094,  1099,  1102,  1105,  1107,  1109,  1111,
598   1113,  1117,  1119,  1121,  1123,  1125,  1127,  1131,  1135,  1139,
599   1143,  1147,  1151,  1155,  1159,  1163,  1167,  1171,  1177,  1182,
600   1184,  1189,  1195,  1201,  1208,  1212,  1216,  1221,  1227,  1230,
601   1234,  1235,  1243,  1244,  1251,  1255,  1259,  1261,  1265,  1269,
602   1273,  1277,  1282,  1287,  1292,  1297,  1301,  1305,  1307,  1310,
603   1314,  1318,  1321,  1324,  1328,  1332,  1336,  1340,  1343,  1347,
604   1352,  1358,  1365,  1371,  1378,  1383,  1388,  1393,  1398,  1402,
605   1407,  1411,  1416,  1418,  1420,  1422,  1424,  1427,  1430,  1432,
606   1434,  1437,  1440,  1442,  1445,  1448,  1451,  1454,  1457,  1460,
607   1462,  1465,  1468,  1470,  1473,  1476,  1482,  1487,  1492,  1498,
608   1503,  1506,  1512,  1517,  1523,  1525,  1529,  1533,  1537,  1541,
609   1545,  1549,  1551,  1555,  1559,  1563,  1567,  1569,  1573,  1577,
610   1581,  1585,  1589,  1593,  1595,  1599,  1603,  1607,  1611,  1615,
611   1619,  1623,  1627,  1631,  1635,  1637,  1641,  1645,  1649,  1653,
612   1655,  1659,  1663,  1665,  1669,  1673,  1675,  1679,  1683,  1685,
613   1689,  1693,  1695,  1699,  1703,  1705,  1711,  1716,  1720,  1726,
614   1728,  1730,  1734,  1738,  1740,  1742,  1744,  1746,  1748,  1750
615 };
616
617 static const short yyrhs[] = {   123,
618      0,   104,     0,   105,     0,   108,     0,   103,     0,   102,
619      0,   109,     0,   113,     0,   114,     0,    82,     0,    85,
620      0,    50,     0,   115,     0,   118,     0,   119,     0,   115,
621      0,   115,     0,   113,    97,    98,     0,   119,    97,    98,
622      0,   118,    97,    98,     0,   113,    97,     1,     0,   118,
623     97,     1,     0,   120,     0,   121,     0,   122,     0,   119,
624    101,   122,     0,    86,     0,     0,   126,     0,   124,     0,
625    125,     0,   126,   124,     0,   126,   125,     0,   124,   125,
626      0,   126,   124,   125,     0,   127,     0,   124,   127,     0,
627    130,     0,   125,   130,     0,    75,   119,    99,     0,    75,
628      1,     0,    75,   119,     1,     0,   128,     0,   129,     0,
629     55,   119,    99,     0,    55,     1,     0,    55,   119,     1,
630      0,    55,   119,   101,     5,    99,     0,    55,   119,   101,
631      1,     0,    55,   119,   101,     5,     1,     0,   132,     0,
632    167,     0,    99,     0,     1,     0,    44,     0,   131,    44,
633      0,     0,   131,    67,   122,   135,   136,   133,   138,     0,
634      0,    67,   122,   135,   136,   134,   138,     0,   131,    67,
635      1,     0,    67,     1,     0,    67,   122,     1,     0,   131,
636     67,   122,     1,     0,     0,    63,   116,     0,    63,   116,
637      1,     0,    63,     1,     0,     0,    52,   137,     0,    52,
638      1,     0,   117,     0,   137,   100,   117,     0,   137,   100,
639      1,     0,    95,    96,     0,    95,   139,    96,     0,   140,
640      0,   139,   140,     0,   141,     0,   157,     0,   159,     0,
641    180,     0,   142,     0,   142,    99,     0,   147,     0,   132,
642      0,   167,     0,   112,   143,    99,     0,   131,   112,   143,
643     99,     0,   144,     0,   143,   100,   144,     0,   143,   100,
644      1,     0,   145,     0,   145,    92,   146,     0,   145,    92,
645      1,     0,   145,    92,   146,     1,     0,   122,     0,   145,
646     97,    98,     0,   122,     1,     0,   145,    97,     1,     0,
647    145,    98,     1,     0,   270,     0,   178,     0,     0,   149,
648    148,   156,     0,   149,     1,     0,   112,   150,   154,     0,
649     59,   150,   154,     0,   131,   112,   150,   154,     0,   131,
650     59,   150,   154,     0,   112,     1,     0,   131,   112,     1,
651      0,    59,     1,     0,   131,    59,     1,     0,   131,     1,
652      0,   122,    93,    94,     0,   122,    93,   151,    94,     0,
653    150,    97,    98,     0,   122,    93,     1,     0,   150,    97,
654      1,     0,   152,     0,   151,   100,   152,     0,   151,   100,
655      1,     0,   112,   145,     0,   153,   112,   145,     0,   112,
656      1,     0,   153,   112,     1,     0,   131,     0,     0,    53,
657    155,     0,    53,     1,     0,   116,     0,   155,   100,   116,
658      0,   155,   100,     1,     0,   180,     0,   180,    99,     0,
659     99,     0,   158,   180,     0,   158,   180,    99,     0,   131,
660      0,     0,   161,   160,   163,     0,   162,   154,     0,   131,
661    162,   154,     0,   120,    93,    94,     0,   120,    93,   151,
662     94,     0,   181,   164,     0,   181,   165,   164,     0,   181,
663    183,   164,     0,   181,   165,   183,   164,     0,   182,     0,
664    182,    99,     0,   166,    93,    94,    99,     0,   166,    93,
665    239,    94,    99,     0,   119,   101,    65,    93,   239,    94,
666     99,     0,   119,   101,    65,    93,    94,    99,     0,    76,
667      0,    65,     0,     0,    61,   122,   168,   173,     0,     0,
668    131,    61,   122,   169,   173,     0,     0,    61,   122,   172,
669    170,   173,     0,     0,   131,    61,   122,   172,   171,   173,
670      0,    61,   122,     1,     0,   131,    61,   122,     1,     0,
671     63,   117,     0,   172,   100,   117,     0,    63,     1,     0,
672    172,   100,     1,     0,    95,    96,     0,    95,   174,    96,
673      0,   175,     0,   174,   175,     0,   176,     0,   177,     0,
674    132,     0,   167,     0,   142,     0,   149,    99,     0,   149,
675      1,     0,    95,    96,     0,    95,   179,    96,     0,    95,
676    179,   100,    96,     0,   146,     0,   179,   100,   146,     0,
677    179,   100,     1,     0,    95,    96,     0,   181,   183,   182,
678      0,    95,     0,    96,     0,   184,     0,   183,   184,     0,
679    185,     0,   187,     0,   132,     0,   186,    99,     0,   112,
680    143,     0,   153,   112,   143,     0,   189,     0,   192,     0,
681    196,     0,   197,     0,   208,     0,   212,     0,   189,     0,
682    193,     0,   198,     0,   209,     0,   213,     0,   180,     0,
683    190,     0,   194,     0,   199,     0,   211,     0,   219,     0,
684    220,     0,   221,     0,   223,     0,   222,     0,   225,     0,
685     99,     0,   122,    88,     0,   191,   187,     0,   122,     1,
686      0,   191,   188,     0,   195,    99,     0,     1,    99,     0,
687      1,    95,     0,     1,    96,     0,   166,    93,     1,     0,
688    166,    93,    94,     1,     0,   166,    93,   239,     1,     0,
689    166,    93,   239,    94,     1,     0,   119,   101,    65,     1,
690      0,   119,   101,    65,    93,     1,     0,   119,   101,    65,
691     93,   239,     1,     0,   119,   101,    65,    93,   239,    94,
692      1,     0,   119,   101,    65,    93,    94,     1,     0,   267,
693      0,   251,     0,   252,     0,   248,     0,   249,     0,   245,
694      0,   234,     0,    48,    93,   270,    94,   187,     0,    48,
695      1,     0,    48,    93,     1,     0,    48,    93,   270,     1,
696      0,    48,    93,   270,    94,   188,    56,   187,     0,    48,
697     93,   270,    94,   188,    56,   188,     0,     0,   201,   200,
698    202,     0,    68,    93,   270,    94,     0,    68,     1,     0,
699     68,    93,     1,     0,    68,    93,   270,    94,     1,     0,
700     95,    96,     0,    95,   205,    96,     0,    95,   203,    96,
701      0,    95,   203,   205,    96,     0,   204,     0,   203,   204,
702      0,   205,   183,     0,   206,     0,   205,   206,     0,    62,
703    271,    88,     0,    47,    88,     0,    62,     1,     0,    62,
704    271,     1,     0,    47,     1,     0,    66,    93,   270,    94,
705      0,   207,   187,     0,    66,     1,     0,    66,    93,     1,
706      0,    66,    93,   270,     1,     0,   207,   188,     0,    51,
707      0,   210,   187,    66,    93,   270,    94,    99,     0,   215,
708     99,   270,    99,   217,    94,   187,     0,   215,    99,    99,
709    217,    94,   187,     0,   215,    99,     1,     0,   215,    99,
710    270,    99,     1,     0,   215,    99,    99,     1,     0,   215,
711     99,   270,    99,   217,    94,   188,     0,   215,    99,    99,
712    217,    94,   188,     0,    71,    93,     0,    71,     1,     0,
713     71,    93,     1,     0,   214,   216,     0,     0,   218,     0,
714    186,     0,   218,     1,     0,     0,   218,     0,   195,     0,
715    218,   100,   195,     0,   218,   100,     1,     0,    54,    99,
716      0,    54,   122,    99,     0,    54,     1,     0,    54,   122,
717      1,     0,    73,    99,     0,    73,   122,    99,     0,    73,
718      1,     0,    73,   122,     1,     0,    58,    99,     0,    58,
719    270,    99,     0,    58,     1,     0,    58,   270,     1,     0,
720     49,   270,    99,     0,    49,     1,     0,    49,   270,     1,
721      0,   224,    93,   270,    94,   180,     0,   224,    93,   270,
722     94,     1,     0,   224,     1,     0,   224,    93,     1,    94,
723      0,   224,    93,     1,     0,   131,     0,    70,   180,   226,
724      0,    70,   180,   229,     0,    70,   180,   226,   229,     0,
725     70,     1,     0,   227,     0,   226,   227,     0,   228,   180,
726      0,    60,    93,   152,    94,     0,    60,     1,     0,    60,
727     93,     1,     0,    60,    93,     1,    94,     0,    64,   180,
728      0,    64,     1,     0,   231,     0,   240,     0,   111,     0,
729     76,     0,    93,   270,    94,     0,   234,     0,   244,     0,
730    245,     0,   246,     0,   233,     0,   119,   101,    76,     0,
731     93,   270,     1,     0,   119,   101,     1,     0,   113,   101,
732      1,     0,    59,   101,     1,     0,   113,    97,    98,     0,
733    119,    97,    98,     0,   119,   101,    67,     0,   232,   101,
734     67,     0,   113,   101,    67,     0,    59,   101,    67,     0,
735     72,   116,    93,   239,    94,     0,    72,   116,    93,    94,
736      0,   235,     0,   238,   122,    93,    94,     0,   238,   122,
737     93,    94,   138,     0,   238,   122,    93,   239,    94,     0,
738    238,   122,    93,   239,    94,   138,     0,    72,     1,    99,
739      0,    72,   116,     1,     0,    72,   116,    93,     1,     0,
740     72,   116,    93,   239,     1,     0,   238,     1,     0,   238,
741    122,     1,     0,     0,    72,   116,    93,   239,    94,   236,
742    138,     0,     0,    72,   116,    93,    94,   237,   138,     0,
743    119,   101,    72,     0,   230,   101,    72,     0,   270,     0,
744    239,   100,   270,     0,   239,   100,     1,     0,    72,   113,
745    241,     0,    72,   115,   241,     0,    72,   113,   241,   243,
746      0,    72,   115,   241,   243,     0,    72,   115,   243,   178,
747      0,    72,   113,   243,   178,     0,    72,     1,    98,     0,
748     72,     1,    97,     0,   242,     0,   241,   242,     0,    97,
749    270,    98,     0,    97,   270,     1,     0,    97,     1,     0,
750     97,    98,     0,   243,    97,    98,     0,   243,    97,     1,
751      0,   230,   101,   122,     0,    65,   101,   122,     0,    65,
752      1,     0,   119,    93,    94,     0,   119,    93,   239,    94,
753      0,   230,   101,   122,    93,    94,     0,   230,   101,   122,
754     93,   239,    94,     0,    65,   101,   122,    93,    94,     0,
755     65,   101,   122,    93,   239,    94,     0,    65,   101,     1,
756     94,     0,    65,   101,     1,   101,     0,   119,    97,   270,
757     98,     0,   231,    97,   270,    98,     0,   119,    97,     1,
758      0,   119,    97,   270,     1,     0,   231,    97,     1,     0,
759    231,    97,   270,     1,     0,   230,     0,   119,     0,   248,
760      0,   249,     0,   247,    46,     0,   247,    45,     0,   251,
761      0,   252,     0,     3,   250,     0,     4,   250,     0,   253,
762      0,     3,     1,     0,     4,     1,     0,    46,   250,     0,
763     46,     1,     0,    45,   250,     0,    45,     1,     0,   247,
764      0,    89,   250,     0,    90,   250,     0,   254,     0,    89,
765      1,     0,    90,     1,     0,    93,   113,   243,    94,   250,
766      0,    93,   113,    94,   250,     0,    93,   270,    94,   253,
767      0,    93,   119,   243,    94,   253,     0,    93,   113,    97,
768      1,     0,    93,     1,     0,    93,   113,   243,    94,     1,
769      0,    93,   113,    94,     1,     0,    93,   119,   243,    94,
770      1,     0,   250,     0,   255,     5,   250,     0,   255,     6,
771    250,     0,   255,     7,   250,     0,   255,     5,     1,     0,
772    255,     6,     1,     0,   255,     7,     1,     0,   255,     0,
773    256,     3,   255,     0,   256,     4,   255,     0,   256,     3,
774      1,     0,   256,     4,     1,     0,   256,     0,   257,     8,
775    256,     0,   257,     9,   256,     0,   257,    10,   256,     0,
776    257,     8,     1,     0,   257,     9,     1,     0,   257,    10,
777      1,     0,   257,     0,   258,    20,   257,     0,   258,    18,
778    257,     0,   258,    21,   257,     0,   258,    19,   257,     0,
779    258,    57,   114,     0,   258,    20,     1,     0,   258,    18,
780      1,     0,   258,    21,     1,     0,   258,    19,     1,     0,
781    258,    57,     1,     0,   258,     0,   259,    16,   258,     0,
782    259,    17,   258,     0,   259,    16,     1,     0,   259,    17,
783      1,     0,   259,     0,   260,    11,   259,     0,   260,    11,
784      1,     0,   260,     0,   261,    12,   260,     0,   261,    12,
785      1,     0,   261,     0,   262,    13,   261,     0,   262,    13,
786      1,     0,   262,     0,   263,    14,   262,     0,   263,    14,
787      1,     0,   263,     0,   264,    15,   263,     0,   264,    15,
788      1,     0,   264,     0,   264,    87,   270,    88,   265,     0,
789    264,    87,    88,     1,     0,   264,    87,     1,     0,   264,
790     87,   270,    88,     1,     0,   265,     0,   267,     0,   268,
791    269,   266,     0,   268,   269,     1,     0,   119,     0,   244,
792      0,   246,     0,    91,     0,    92,     0,   266,     0,   270,
793      0
794 };
795
796 #endif
797
798 #if YYDEBUG != 0
799 static const short yyrline[] = { 0,
800    574,   580,   582,   583,   584,   585,   586,   590,   592,   595,
801    597,   598,   601,   603,   606,   610,   614,   618,   624,   626,
802    628,   630,   635,   637,   640,   644,   649,   654,   656,   657,
803    658,   659,   660,   661,   662,   665,   670,   676,   678,   681,
804    687,   689,   693,   695,   698,   725,   727,   731,   744,   746,
805    750,   753,   755,   757,   767,   772,   787,   791,   791,   794,
806    794,   796,   798,   803,   807,   809,   811,   813,   817,   819,
807    821,   828,   834,   839,   843,   852,   862,   864,   867,   869,
808    870,   871,   878,   880,   882,   883,   885,   890,   893,   903,
809    906,   908,   912,   915,   922,   928,   936,   938,   940,   942,
810    944,   948,   950,   954,   965,   966,   970,   973,   975,   977,
811    979,   984,   986,   988,   990,   997,  1003,  1005,  1014,  1016,
812   1020,  1025,  1030,  1034,  1039,  1044,  1049,  1056,  1066,  1068,
813   1070,  1074,  1077,  1079,  1083,  1085,  1086,  1091,  1097,  1104,
814   1120,  1127,  1130,  1133,  1137,  1143,  1147,  1156,  1158,  1160,
815   1164,  1166,  1169,  1176,  1184,  1186,  1190,  1197,  1207,  1211,
816   1211,  1214,  1214,  1217,  1217,  1220,  1220,  1222,  1226,  1232,
817   1237,  1239,  1243,  1246,  1250,  1252,  1255,  1257,  1258,  1260,
818   1264,  1268,  1274,  1279,  1282,  1284,  1288,  1294,  1298,  1303,
819   1312,  1316,  1321,  1335,  1337,  1340,  1342,  1344,  1351,  1355,
820   1358,  1362,  1364,  1365,  1366,  1367,  1368,  1372,  1374,  1375,
821   1376,  1377,  1381,  1383,  1384,  1385,  1386,  1387,  1388,  1389,
822   1390,  1391,  1392,  1395,  1400,  1411,  1414,  1418,  1425,  1435,
823   1441,  1447,  1453,  1455,  1460,  1462,  1467,  1469,  1471,  1473,
824   1475,  1479,  1481,  1482,  1483,  1484,  1485,  1486,  1489,  1495,
825   1497,  1499,  1503,  1508,  1513,  1519,  1529,  1535,  1537,  1539,
826   1546,  1549,  1551,  1553,  1557,  1559,  1562,  1566,  1568,  1571,
827   1578,  1584,  1586,  1588,  1592,  1600,  1603,  1605,  1607,  1611,
828   1616,  1625,  1630,  1633,  1640,  1642,  1644,  1648,  1651,  1660,
829   1667,  1669,  1673,  1686,  1688,  1694,  1700,  1704,  1706,  1710,
830   1713,  1715,  1719,  1722,  1724,  1726,  1730,  1733,  1735,  1737,
831   1741,  1744,  1746,  1748,  1752,  1758,  1760,  1764,  1771,  1773,
832   1775,  1777,  1781,  1793,  1796,  1798,  1803,  1807,  1809,  1816,
833   1824,  1841,  1843,  1848,  1852,  1855,  1860,  1862,  1865,  1867,
834   1869,  1871,  1872,  1873,  1874,  1875,  1879,  1884,  1886,  1888,
835   1890,  1897,  1903,  1912,  1915,  1917,  1919,  1923,  1926,  1928,
836   1932,  1938,  1939,  1945,  1946,  1948,  1950,  1952,  1954,  1956,
837   1965,  1969,  1999,  2002,  2016,  2019,  2023,  2029,  2034,  2038,
838   2041,  2043,  2045,  2049,  2058,  2066,  2068,  2072,  2075,  2079,
839   2085,  2087,  2095,  2122,  2124,  2128,  2133,  2140,  2144,  2147,
840   2149,  2160,  2171,  2176,  2185,  2187,  2191,  2194,  2196,  2201,
841   2206,  2211,  2218,  2220,  2221,  2222,  2225,  2230,  2235,  2237,
842   2238,  2240,  2242,  2243,  2245,  2249,  2252,  2256,  2259,  2263,
843   2265,  2267,  2269,  2270,  2272,  2276,  2285,  2287,  2289,  2302,
844   2304,  2310,  2312,  2314,  2318,  2320,  2325,  2330,  2335,  2337,
845   2339,  2343,  2345,  2350,  2355,  2357,  2361,  2363,  2368,  2373,
846   2378,  2380,  2382,  2386,  2388,  2393,  2398,  2403,  2408,  2410,
847   2412,  2414,  2416,  2418,  2422,  2424,  2429,  2434,  2436,  2440,
848   2442,  2447,  2451,  2453,  2458,  2462,  2464,  2469,  2473,  2475,
849   2480,  2484,  2486,  2491,  2495,  2497,  2502,  2508,  2510,  2514,
850   2516,  2519,  2522,  2530,  2532,  2533,  2536,  2538,  2541,  2545
851 };
852 #endif
853
854
855 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
856
857 static const char * const yytname[] = {   "$","error","$undefined.","PLUS_TK",
858 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
859 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
860 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
861 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
862 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
863 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
864 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
865 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
866 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
867 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
868 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
869 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
870 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
871 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
872 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
873 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
874 "class_type","interface_type","array_type","name","simple_name","qualified_name",
875 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
876 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
877 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
878 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
879 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
880 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
881 "method_declarator","formal_parameter_list","formal_parameter","final","throws",
882 "class_type_list","method_body","static_initializer","static","constructor_declaration",
883 "@4","constructor_header","constructor_declarator","constructor_body","constructor_block_end",
884 "explicit_constructor_invocation","this_or_super","interface_declaration","@5",
885 "@6","@7","@8","extends_interfaces","interface_body","interface_member_declarations",
886 "interface_member_declaration","constant_declaration","abstract_method_declaration",
887 "array_initializer","variable_initializers","block","block_begin","block_end",
888 "block_statements","block_statement","local_variable_declaration_statement",
889 "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement",
890 "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
891 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
892 "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups",
893 "switch_block_statement_group","switch_labels","switch_label","while_expression",
894 "while_statement","while_statement_nsi","do_statement_begin","do_statement",
895 "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update",
896 "statement_expression_list","break_statement","continue_statement","return_statement",
897 "throw_statement","synchronized_statement","synchronized","try_statement","catches",
898 "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array",
899 "array_type_literal","type_literals","class_instance_creation_expression","anonymous_class_creation",
900 "@10","@11","something_dot_new","argument_list","array_creation_expression",
901 "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access",
902 "postfix_expression","post_increment_expression","post_decrement_expression",
903 "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus",
904 "cast_expression","multiplicative_expression","additive_expression","shift_expression",
905 "relational_expression","equality_expression","and_expression","exclusive_or_expression",
906 "inclusive_or_expression","conditional_and_expression","conditional_or_expression",
907 "conditional_expression","assignment_expression","assignment","left_hand_side",
908 "assignment_operator","expression","constant_expression", NULL
909 };
910 #endif
911
912 static const short yyr1[] = {     0,
913    110,   111,   111,   111,   111,   111,   111,   112,   112,   113,
914    113,   113,   114,   114,   115,   116,   117,   118,   118,   118,
915    118,   118,   119,   119,   120,   121,   122,   123,   123,   123,
916    123,   123,   123,   123,   123,   124,   124,   125,   125,   126,
917    126,   126,   127,   127,   128,   128,   128,   129,   129,   129,
918    130,   130,   130,   130,   131,   131,   133,   132,   134,   132,
919    132,   132,   132,   132,   135,   135,   135,   135,   136,   136,
920    136,   137,   137,   137,   138,   138,   139,   139,   140,   140,
921    140,   140,   141,   141,   141,   141,   141,   142,   142,   143,
922    143,   143,   144,   144,   144,   144,   145,   145,   145,   145,
923    145,   146,   146,   148,   147,   147,   149,   149,   149,   149,
924    149,   149,   149,   149,   149,   150,   150,   150,   150,   150,
925    151,   151,   151,   152,   152,   152,   152,   153,   154,   154,
926    154,   155,   155,   155,   156,   156,   156,   157,   157,   158,
927    160,   159,   161,   161,   162,   162,   163,   163,   163,   163,
928    164,   164,   165,   165,   165,   165,   166,   166,   168,   167,
929    169,   167,   170,   167,   171,   167,   167,   167,   172,   172,
930    172,   172,   173,   173,   174,   174,   175,   175,   175,   175,
931    176,   177,   177,   178,   178,   178,   179,   179,   179,   180,
932    180,   181,   182,   183,   183,   184,   184,   184,   185,   186,
933    186,   187,   187,   187,   187,   187,   187,   188,   188,   188,
934    188,   188,   189,   189,   189,   189,   189,   189,   189,   189,
935    189,   189,   189,   190,   191,   192,   192,   193,   194,   194,
936    194,   194,   194,   194,   194,   194,   194,   194,   194,   194,
937    194,   195,   195,   195,   195,   195,   195,   195,   196,   196,
938    196,   196,   197,   198,   200,   199,   201,   201,   201,   201,
939    202,   202,   202,   202,   203,   203,   204,   205,   205,   206,
940    206,   206,   206,   206,   207,   208,   208,   208,   208,   209,
941    210,   211,   212,   212,   212,   212,   212,   213,   213,   214,
942    214,   214,   215,   216,   216,   216,   216,   217,   217,   218,
943    218,   218,   219,   219,   219,   219,   220,   220,   220,   220,
944    221,   221,   221,   221,   222,   222,   222,   223,   223,   223,
945    223,   223,   224,   225,   225,   225,   225,   226,   226,   227,
946    228,   228,   228,   228,   229,   229,   230,   230,   231,   231,
947    231,   231,   231,   231,   231,   231,   231,   231,   231,   231,
948    231,   232,   232,   233,   233,   233,   233,   234,   234,   234,
949    234,   234,   234,   234,   234,   234,   234,   234,   234,   234,
950    236,   235,   237,   235,   238,   238,   239,   239,   239,   240,
951    240,   240,   240,   240,   240,   240,   240,   241,   241,   242,
952    242,   242,   243,   243,   243,   244,   244,   244,   245,   245,
953    245,   245,   245,   245,   245,   245,   246,   246,   246,   246,
954    246,   246,   247,   247,   247,   247,   248,   249,   250,   250,
955    250,   250,   250,   250,   250,   251,   251,   252,   252,   253,
956    253,   253,   253,   253,   253,   254,   254,   254,   254,   254,
957    254,   254,   254,   254,   255,   255,   255,   255,   255,   255,
958    255,   256,   256,   256,   256,   256,   257,   257,   257,   257,
959    257,   257,   257,   258,   258,   258,   258,   258,   258,   258,
960    258,   258,   258,   258,   259,   259,   259,   259,   259,   260,
961    260,   260,   261,   261,   261,   262,   262,   262,   263,   263,
962    263,   264,   264,   264,   265,   265,   265,   265,   265,   266,
963    266,   267,   267,   268,   268,   268,   269,   269,   270,   271
964 };
965
966 static const short yyr2[] = {     0,
967      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
968      1,     1,     1,     1,     1,     1,     1,     3,     3,     3,
969      3,     3,     1,     1,     1,     3,     1,     0,     1,     1,
970      1,     2,     2,     2,     3,     1,     2,     1,     2,     3,
971      2,     3,     1,     1,     3,     2,     3,     5,     4,     5,
972      1,     1,     1,     1,     1,     2,     0,     7,     0,     6,
973      3,     2,     3,     4,     0,     2,     3,     2,     0,     2,
974      2,     1,     3,     3,     2,     3,     1,     2,     1,     1,
975      1,     1,     1,     2,     1,     1,     1,     3,     4,     1,
976      3,     3,     1,     3,     3,     4,     1,     3,     2,     3,
977      3,     1,     1,     0,     3,     2,     3,     3,     4,     4,
978      2,     3,     2,     3,     2,     3,     4,     3,     3,     3,
979      1,     3,     3,     2,     3,     2,     3,     1,     0,     2,
980      2,     1,     3,     3,     1,     2,     1,     2,     3,     1,
981      0,     3,     2,     3,     3,     4,     2,     3,     3,     4,
982      1,     2,     4,     5,     7,     6,     1,     1,     0,     4,
983      0,     5,     0,     5,     0,     6,     3,     4,     2,     3,
984      2,     3,     2,     3,     1,     2,     1,     1,     1,     1,
985      1,     2,     2,     2,     3,     4,     1,     3,     3,     2,
986      3,     1,     1,     1,     2,     1,     1,     1,     2,     2,
987      3,     1,     1,     1,     1,     1,     1,     1,     1,     1,
988      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
989      1,     1,     1,     1,     2,     2,     2,     2,     2,     2,
990      2,     2,     3,     4,     4,     5,     4,     5,     6,     7,
991      6,     1,     1,     1,     1,     1,     1,     1,     5,     2,
992      3,     4,     7,     7,     0,     3,     4,     2,     3,     5,
993      2,     3,     3,     4,     1,     2,     2,     1,     2,     3,
994      2,     2,     3,     2,     4,     2,     2,     3,     4,     2,
995      1,     7,     7,     6,     3,     5,     4,     7,     6,     2,
996      2,     3,     2,     0,     1,     1,     2,     0,     1,     1,
997      3,     3,     2,     3,     2,     3,     2,     3,     2,     3,
998      2,     3,     2,     3,     3,     2,     3,     5,     5,     2,
999      4,     3,     1,     3,     3,     4,     2,     1,     2,     2,
1000      4,     2,     3,     4,     2,     2,     1,     1,     1,     1,
1001      3,     1,     1,     1,     1,     1,     3,     3,     3,     3,
1002      3,     3,     3,     3,     3,     3,     3,     5,     4,     1,
1003      4,     5,     5,     6,     3,     3,     4,     5,     2,     3,
1004      0,     7,     0,     6,     3,     3,     1,     3,     3,     3,
1005      3,     4,     4,     4,     4,     3,     3,     1,     2,     3,
1006      3,     2,     2,     3,     3,     3,     3,     2,     3,     4,
1007      5,     6,     5,     6,     4,     4,     4,     4,     3,     4,
1008      3,     4,     1,     1,     1,     1,     2,     2,     1,     1,
1009      2,     2,     1,     2,     2,     2,     2,     2,     2,     1,
1010      2,     2,     1,     2,     2,     5,     4,     4,     5,     4,
1011      2,     5,     4,     5,     1,     3,     3,     3,     3,     3,
1012      3,     1,     3,     3,     3,     3,     1,     3,     3,     3,
1013      3,     3,     3,     1,     3,     3,     3,     3,     3,     3,
1014      3,     3,     3,     3,     1,     3,     3,     3,     3,     1,
1015      3,     3,     1,     3,     3,     1,     3,     3,     1,     3,
1016      3,     1,     3,     3,     1,     5,     4,     3,     5,     1,
1017      1,     3,     3,     1,     1,     1,     1,     1,     1,     1
1018 };
1019
1020 static const short yydefact[] = {     0,
1021     54,    55,     0,     0,     0,     0,    53,     1,     0,     0,
1022      0,    36,    43,    44,    38,     0,    51,    52,    46,    27,
1023      0,    23,    24,    25,     0,    62,     0,    41,     0,     0,
1024     37,    39,     0,     0,    56,     0,     0,    47,    45,     0,
1025    167,     0,     0,   163,    63,     0,    69,    42,    40,     0,
1026      0,     0,    61,     0,    49,     0,    26,   171,    17,   169,
1027     15,     0,   160,     0,     0,    68,    16,     0,     0,    59,
1028    168,     0,   165,    64,    69,    50,    48,    12,     0,    10,
1029     11,   173,     0,     8,     9,    13,    14,    15,     0,   179,
1030    181,     0,   180,     0,   175,   177,   178,   172,   170,   164,
1031     67,    71,    72,    70,     0,   162,     0,    57,   113,     0,
1032    129,   111,     0,     0,    90,    93,   129,     0,     0,     0,
1033    115,     0,     0,   183,   182,   174,   176,     0,     0,    60,
1034    166,     0,     0,     0,     0,   108,    99,    88,     0,     0,
1035      0,     0,   107,    21,    18,    22,    20,    19,   114,   129,
1036    112,     0,   129,    74,    73,   192,    75,    23,     0,    86,
1037      0,    77,    79,    83,    85,     0,    80,     0,    81,   141,
1038    129,    87,    82,     0,    58,   119,   116,     0,   128,     0,
1039    121,     0,   131,   132,   130,   120,   118,    92,     0,    91,
1040     95,     0,     0,     0,     0,     0,     0,     0,   340,     0,
1041      0,     0,     0,     6,     5,     2,     3,     4,     7,   339,
1042      0,   414,     0,   103,   413,   337,     0,   346,   342,   360,
1043      0,   338,   343,   344,   345,   430,   415,   416,   445,   419,
1044    420,   423,   433,   452,   457,   464,   475,   480,   483,   486,
1045    489,   492,   495,   500,   509,   501,     0,   102,   100,    98,
1046    101,   110,    89,   109,   190,     0,   129,    76,    78,    84,
1047    106,     0,   138,     0,   143,     0,     0,     0,   281,     0,
1048      0,     0,     0,     0,     0,     0,     0,   340,     0,   224,
1049      0,     8,   414,     0,   128,   198,     0,     0,   213,     0,
1050    194,   196,     0,   197,   202,   214,     0,   203,   215,     0,
1051    204,   205,   216,   255,     0,   206,     0,   217,   207,   294,
1052      0,   218,   219,   220,   222,   221,     0,   223,   248,   247,
1053      0,   245,   246,   243,   244,   242,   126,   124,   117,     0,
1054      0,     0,   424,   414,   343,   345,   421,   425,   422,   429,
1055    428,   427,   426,     0,   398,     0,     0,     0,    16,     0,
1056    434,   431,   435,   432,   441,     0,   414,     0,   184,   187,
1057      0,     0,     0,     0,     0,     0,    96,     0,     0,     0,
1058    369,     0,   418,   417,     0,     0,     0,     0,     0,     0,
1059      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1060      0,     0,     0,     0,     0,   507,   508,     0,   145,     0,
1061    144,   137,   105,   135,   139,   192,   142,     0,   231,   232,
1062    230,   250,     0,   316,     0,   305,   303,     0,   313,   311,
1063      0,   277,     0,   258,     0,   327,     0,   291,     0,   309,
1064    307,     0,     0,   200,     0,     0,     0,   227,   225,     0,
1065      0,   193,   191,   195,   199,   414,   323,   226,   229,     0,
1066    276,     0,   414,   296,   300,   293,     0,     0,   320,     0,
1067    123,   122,   127,   125,   134,   133,   351,   357,     0,   397,
1068    387,   386,   365,     0,   380,   388,     0,   381,     0,   366,
1069      0,     0,     0,     0,     0,     0,   348,   341,   185,     0,
1070    352,   350,   356,   399,     0,   377,   409,   353,     0,   349,
1071    354,   375,   347,   376,   396,   411,     0,   355,   370,     0,
1072    449,   446,   450,   447,   451,   448,   455,   453,   456,   454,
1073    461,   458,   462,   459,   463,   460,   471,   466,   473,   468,
1074    470,   465,   472,   467,   474,     0,   469,   478,   476,   479,
1075    477,   482,   481,   485,   484,   488,   487,   491,   490,   494,
1076    493,   498,     0,     0,   503,   502,   146,   136,   414,   147,
1077      0,     0,   151,     0,   251,     0,   317,   315,   306,   304,
1078    314,   312,   278,     0,   259,     0,     0,     0,   324,   328,
1079      0,   325,   292,   310,   308,   341,    18,    19,     0,   201,
1080    233,     0,     0,     0,   256,     0,   297,     0,   285,     0,
1081      0,   322,     0,   405,   406,     0,   392,   393,     0,   389,
1082    382,     0,   385,   383,   384,   367,   359,     0,   443,   437,
1083    440,   393,     0,   393,     0,   438,   189,   186,   188,   400,
1084      0,   410,   407,     0,   412,   408,   361,     0,   497,     0,
1085      0,   148,     0,     0,   152,   149,   252,     0,   279,   275,
1086      0,   332,     0,   336,   335,   329,   326,   330,   237,     0,
1087    234,   235,     0,     0,     0,   261,     0,   265,     0,   268,
1088      0,   302,   301,   287,     0,   299,     0,   321,     0,   403,
1089      0,   391,   390,   395,   394,     0,   368,   358,   442,   436,
1090    444,   439,   379,   378,   401,     0,   362,   363,   499,   496,
1091      0,   150,     0,     0,     0,   249,     0,   202,     0,   209,
1092    210,     0,   211,   212,     0,   260,   333,     0,   238,     0,
1093      0,   236,   274,   271,   272,   510,     0,   263,   266,     0,
1094    262,     0,   269,     0,     0,   286,     0,   319,   318,   404,
1095    374,     0,   402,   364,     0,   153,     0,     0,     0,   228,
1096    280,     0,   334,   331,   241,   239,     0,   273,   270,   264,
1097      0,   284,     0,   372,     0,     0,   154,     0,   253,     0,
1098      0,   240,   282,   283,   156,     0,     0,     0,     0,   155,
1099      0,     0,     0,     0,   289,     0,   254,   288,     0,     0,
1100      0
1101 };
1102
1103 static const short yydefgoto[] = {   789,
1104    210,   281,   211,    85,    86,    68,    60,    87,   212,    22,
1105     23,    24,     8,     9,    10,    11,    12,    13,    14,    15,
1106    447,   286,   132,   105,    47,    70,   104,   130,   161,   162,
1107    163,    91,   114,   115,   116,   213,   165,   262,    92,   111,
1108    180,   181,   287,   136,   185,   403,   167,   168,   169,   264,
1109    170,   171,   407,   560,   561,   288,    18,    43,    72,    65,
1110    107,    44,    63,    94,    95,    96,    97,   214,   361,   289,
1111    174,   563,   732,   291,   292,   293,   294,   707,   295,   296,
1112    297,   298,   710,   299,   300,   301,   302,   711,   303,   450,
1113    304,   595,   667,   668,   669,   670,   305,   306,   713,   307,
1114    308,   309,   714,   310,   311,   456,   675,   676,   312,   313,
1115    314,   315,   316,   317,   318,   579,   580,   581,   582,   215,
1116    216,   217,   218,   219,   220,   742,   686,   221,   495,   222,
1117    475,   476,   477,   223,   224,   225,   226,   227,   228,   229,
1118    230,   231,   232,   233,   234,   235,   236,   237,   238,   239,
1119    240,   241,   242,   243,   244,   245,   246,   247,   398,   496,
1120    727
1121 };
1122
1123 static const short yypact[] = {   356,
1124 -32768,-32768,   158,   -35,   339,   439,-32768,-32768,   433,   247,
1125    473,-32768,-32768,-32768,-32768,    29,-32768,-32768,-32768,-32768,
1126     12,-32768,-32768,-32768,   331,-32768,   491,-32768,    71,   469,
1127 -32768,-32768,   520,   562,-32768,   -35,   510,-32768,-32768,   278,
1128 -32768,   521,   -25,    -8,-32768,   526,   349,-32768,-32768,   -35,
1129    591,   343,-32768,   508,-32768,    25,-32768,-32768,-32768,-32768,
1130      7,  1014,-32768,   568,   -25,-32768,-32768,   346,   594,-32768,
1131 -32768,   -25,    -8,-32768,   349,-32768,-32768,-32768,   597,-32768,
1132 -32768,-32768,   607,   165,-32768,-32768,   315,   181,   676,-32768,
1133 -32768,    30,-32768,  1034,-32768,-32768,-32768,-32768,-32768,-32768,
1134 -32768,-32768,-32768,   328,   354,-32768,   -25,-32768,-32768,   370,
1135     -4,-32768,   449,   733,-32768,   201,    -4,   122,   208,   377,
1136 -32768,   608,   616,-32768,-32768,-32768,-32768,   617,   938,-32768,
1137 -32768,   354,   629,   630,   215,-32768,-32768,-32768,   648,  2189,
1138    227,   489,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    -4,
1139 -32768,   743,    -4,-32768,-32768,   412,-32768,   425,   577,-32768,
1140    943,-32768,-32768,   438,-32768,    47,-32768,   455,-32768,-32768,
1141    506,-32768,-32768,  1916,-32768,-32768,-32768,   655,   569,   321,
1142 -32768,   589,-32768,-32768,   532,-32768,-32768,-32768,   485,-32768,
1143 -32768,  3001,  3052,  3117,  3168,   533,    18,   615,-32768,  3233,
1144   3284,  3349,  5298,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1145    302,   915,    63,-32768,   542,   581,   587,-32768,-32768,-32768,
1146    656,-32768,   766,-32768,   780,   846,-32768,-32768,-32768,-32768,
1147 -32768,-32768,-32768,   879,   896,   937,   893,   880,   697,   701,
1148    717,   741,    74,-32768,-32768,-32768,   841,-32768,-32768,-32768,
1149 -32768,-32768,-32768,-32768,-32768,   774,   506,-32768,-32768,-32768,
1150 -32768,   565,   690,   685,-32768,   600,   172,  3400,-32768,   206,
1151   2240,    17,   311,   342,    82,   426,   211,   700,  5597,-32768,
1152    -35,   651,   837,   229,   522,-32768,   589,   705,-32768,  1848,
1153 -32768,-32768,   702,-32768,-32768,-32768,  1984,-32768,-32768,   709,
1154 -32768,-32768,-32768,-32768,  1984,-32768,  1984,-32768,-32768,  5648,
1155    738,-32768,-32768,-32768,-32768,-32768,   436,-32768,   806,   808,
1156    846,   891,   908,-32768,-32768,-32768,-32768,   869,-32768,   654,
1157    684,   686,-32768,   722,-32768,-32768,-32768,-32768,-32768,-32768,
1158 -32768,-32768,-32768,    27,-32768,   691,   860,   724,   724,   452,
1159 -32768,-32768,-32768,-32768,-32768,   694,  1044,    43,-32768,-32768,
1160    669,   747,   222,  5365,  2305,   538,-32768,   279,  3465,   772,
1161 -32768,   458,-32768,-32768,  3516,  3581,  3632,  3697,  3748,  3813,
1162   3864,  3929,  3980,  4045,  4096,  4161,   721,  4212,  4277,  4328,
1163   4393,  4444,  4509,  4560,  2356,-32768,-32768,  4625,-32768,   368,
1164 -32768,-32768,-32768,   750,-32768,-32768,-32768,  1848,-32768,-32768,
1165 -32768,-32768,  4676,-32768,    35,-32768,-32768,    56,-32768,-32768,
1166     70,-32768,  4741,-32768,  4792,-32768,   718,-32768,  5206,-32768,
1167 -32768,   144,   259,   762,   235,  2421,   652,-32768,-32768,   -35,
1168   2472,-32768,-32768,-32768,-32768,  1096,   569,-32768,-32768,   779,
1169 -32768,   810,  1032,-32768,-32768,-32768,    76,  2537,-32768,  4857,
1170 -32768,-32768,-32768,   869,-32768,-32768,-32768,-32768,   -49,   789,
1171 -32768,-32768,-32768,  2588,   724,-32768,   479,   724,   479,-32768,
1172   2653,  4908,   240,   135,  2704,   657,-32768,  1671,-32768,  2124,
1173 -32768,-32768,-32768,-32768,   547,-32768,-32768,-32768,   244,-32768,
1174 -32768,-32768,-32768,-32768,   801,-32768,   251,-32768,-32768,  5416,
1175 -32768,-32768,-32768,-32768,-32768,-32768,-32768,   879,-32768,   879,
1176 -32768,   896,-32768,   896,-32768,   896,-32768,   937,-32768,   937,
1177 -32768,   937,-32768,   937,-32768,   165,-32768,-32768,   893,-32768,
1178    893,-32768,   880,-32768,   697,-32768,   701,-32768,   717,-32768,
1179    741,-32768,   901,   818,-32768,-32768,-32768,-32768,  1076,-32768,
1180   1848,   815,   811,  1848,-32768,   335,-32768,-32768,-32768,-32768,
1181 -32768,-32768,-32768,   351,-32768,   823,   463,   132,   718,-32768,
1182    455,-32768,-32768,-32768,-32768,-32768,   819,   824,   464,   762,
1183 -32768,   941,    66,    -9,-32768,   851,-32768,  5340,-32768,  5231,
1184    840,   854,   857,-32768,-32768,  5481,-32768,-32768,   272,-32768,
1185    864,   294,-32768,   864,-32768,-32768,   878,    94,-32768,-32768,
1186 -32768,   819,  4973,   824,  1120,-32768,-32768,-32768,-32768,-32768,
1187   5024,-32768,-32768,  5532,-32768,-32768,   354,   548,-32768,  5089,
1188    744,-32768,  1848,  2769,-32768,-32768,-32768,  2050,-32768,-32768,
1189    263,-32768,   681,-32768,-32768,-32768,-32768,-32768,-32768,  2820,
1190 -32768,-32768,   963,   212,  5140,-32768,   419,-32768,  1564,-32768,
1191   5597,-32768,-32768,-32768,   881,   886,  5273,-32768,   268,-32768,
1192    728,-32768,-32768,-32768,-32768,   354,-32768,   903,-32768,-32768,
1193 -32768,-32768,-32768,-32768,-32768,   731,-32768,   354,-32768,-32768,
1194    504,-32768,   173,   121,   509,-32768,   940,   944,  2050,-32768,
1195 -32768,  2050,-32768,-32768,   904,-32768,   923,   925,-32768,  1020,
1196    137,-32768,-32768,-32768,-32768,-32768,   262,-32768,-32768,  1646,
1197 -32768,  1780,-32768,   932,  1984,-32768,   942,-32768,-32768,-32768,
1198 -32768,   354,-32768,-32768,  2885,-32768,   182,  4676,  1984,-32768,
1199 -32768,  2936,-32768,-32768,-32768,-32768,  1029,-32768,-32768,-32768,
1200    945,-32768,  1984,-32768,   210,   177,-32768,   401,-32768,  5231,
1201    946,-32768,-32768,-32768,-32768,   224,  2050,   947,  5273,-32768,
1202    975,  2050,   949,  2050,-32768,  2050,-32768,-32768,  1037,  1040,
1203 -32768
1204 };
1205
1206 static const short yypgoto[] = {-32768,
1207 -32768,   -54,   157,   660,    16,  -122,   582,-32768,    -3,   319,
1208 -32768,    64,-32768,  1038,   413,-32768,    69,-32768,-32768,   734,
1209    106,   409,-32768,-32768,   997,   979,-32768,  -131,-32768,   898,
1210 -32768,   -79,  -116,   918,  -167,  -194,-32768,-32768,   -64,   285,
1211    805,  -325,  -129,   -90,-32768,-32768,-32768,-32768,-32768,-32768,
1212 -32768,   907,-32768,  -544,-32768,   662,   -20,-32768,-32768,-32768,
1213 -32768,  1011,   561,-32768,   978,-32768,-32768,  -176,-32768,  -127,
1214    813,   784,  -168,  -276,-32768,   769,  -251,    93,  -560,-32768,
1215   -528,-32768,-32768,-32768,  -263,-32768,-32768,-32768,-32768,-32768,
1216 -32768,-32768,-32768,   415,   416,  -632,  -527,-32768,-32768,-32768,
1217 -32768,-32768,-32768,-32768,  -516,-32768,  -667,   770,-32768,-32768,
1218 -32768,-32768,-32768,-32768,-32768,-32768,   511,-32768,   513,-32768,
1219 -32768,-32768,-32768,   186,-32768,-32768,-32768,-32768,  -426,-32768,
1220    736,   126,  -324,  1163,   192,  1197,   283,   379,   507,  -171,
1221    583,   704,  -472,-32768,   602,   603,   481,   601,   696,   698,
1222    695,   710,   703,-32768,   454,   706,   745,-32768,-32768,   936,
1223 -32768
1224 };
1225
1226
1227 #define YYLAST          5757
1228
1229
1230 static const short yytable[] = {    21,
1231    175,   173,    29,   182,   462,   290,   152,    83,   360,   737,
1232    328,   184,    38,   444,   593,   626,   642,   345,   345,   646,
1233    337,   339,   341,   343,   479,    76,   143,   467,   352,   354,
1234    124,   484,   486,   173,   123,   567,   733,   664,    61,    83,
1235    263,    93,    61,   487,   604,   448,   455,   261,   134,   164,
1236     20,   605,   665,   451,   618,   452,   569,    59,    88,   252,
1237     61,    67,   254,   367,   166,    61,   662,    25,    27,    62,
1238    571,    48,    35,    93,    83,   350,   597,    31,   178,    59,
1239    265,   164,   426,   638,    59,    88,   666,   708,   394,    36,
1240     88,    64,   135,   468,   687,    37,   166,   733,   702,    52,
1241     54,    31,   778,    57,   123,    16,    83,    50,   172,  -158,
1242     39,   783,    40,    57,    16,    16,    16,   346,   346,   709,
1243    712,   662,   144,    77,    61,    88,   182,   331,   125,    88,
1244     61,   715,   654,   568,   404,    16,   488,   756,    16,    16,
1245    172,  -104,   110,    59,   584,  -104,   113,   427,   708,    67,
1246    611,   708,   692,   614,   570,    88,    16,    88,    19,   663,
1247    395,   -94,   -94,   464,   434,   631,   401,    89,   572,    49,
1248    283,    50,   412,   661,  -295,   598,   156,   756,    88,   681,
1249    709,   712,   722,   709,   712,   110,   113,   688,   334,   334,
1250    334,   334,   715,   631,    61,   715,   334,   334,   357,    89,
1251    182,   178,   189,   512,   514,   516,   416,   696,   146,   466,
1252    755,   430,   723,   349,   747,   186,   708,   704,    84,   145,
1253    631,   708,   492,   708,   772,   708,   156,   249,   623,   438,
1254    757,   612,   440,   721,   159,   144,   631,   284,   179,   564,
1255    621,   189,   585,    20,   632,    84,   -31,     1,   709,   712,
1256     84,   635,    88,   709,   712,   709,   712,   709,   712,   487,
1257    715,   118,   758,   716,   413,   715,   159,   715,   738,   715,
1258    776,   746,   682,   -25,   -25,   178,   631,   120,    55,   285,
1259    767,    50,    56,    88,   372,    84,   283,   444,   493,    84,
1260      2,    20,   140,   446,   684,   629,    20,   141,   142,   724,
1261    613,   446,   615,   446,   417,   147,   453,     4,   775,   431,
1262    620,   422,   187,     5,   -25,    84,   439,    84,   766,   -25,
1263    -25,   -25,   780,   590,   250,   -25,    88,   718,    61,   -25,
1264    282,    41,   587,   418,   673,   647,   455,   622,    84,    26,
1265    432,   633,   424,    71,   189,     7,   101,    67,   636,   759,
1266    504,   649,   586,   284,   348,   -28,     1,  -257,   356,   319,
1267    284,   179,   156,    20,    20,   320,   444,   117,   284,   683,
1268    284,   334,   334,   334,   334,   334,   334,   334,   334,   334,
1269    334,   334,   334,    88,   334,   334,   334,   334,   334,   334,
1270    334,   685,   643,    42,   189,   285,   706,   -66,   362,     2,
1271     69,   647,   363,   423,   559,    42,   150,   153,    17,   470,
1272      3,   119,    84,   455,   329,   179,     4,    17,    17,    17,
1273    330,    30,     5,    34,    20,  -159,   428,   128,   648,    57,
1274      6,   505,   -30,     1,   425,   179,   459,  -161,    17,    28,
1275    -66,    17,    17,    84,   650,    51,   282,   158,   129,   137,
1276    655,   690,   480,   658,     7,   444,   321,   448,   509,    17,
1277    451,   557,   133,   652,   659,   664,   282,   330,   -34,     1,
1278     90,   284,   -29,     1,   148,   319,     2,   158,   334,   158,
1279    665,   320,   319,   762,   334,   137,    84,     3,   320,   251,
1280    319,    45,   319,     4,   777,   319,   320,   769,   320,     5,
1281     57,   320,    90,   189,   659,   697,   455,   255,    74,   412,
1282     53,   774,     2,   285,   728,   455,     2,   256,   429,   -32,
1283      1,    58,  -323,   182,    20,   706,    66,     3,   460,     4,
1284    762,     7,   769,     4,   774,     5,   260,   160,   500,     5,
1285    -97,   133,   -65,   536,   481,   -97,   -97,   -97,   -97,   156,
1286    510,   739,   322,    46,   741,   653,   660,   283,   134,   -65,
1287    283,   -33,     1,     2,   282,    35,   744,     7,    98,   160,
1288     46,     7,   321,   203,     3,   612,   -97,   121,   -97,   321,
1289      4,   -97,   -97,   -97,   -97,   -65,     5,   321,    37,   321,
1290    -35,     1,   321,   319,   102,    20,   745,   109,   178,   320,
1291    610,   748,   -65,   610,   501,     2,    20,   112,   149,   502,
1292    764,    20,    35,   503,  -323,   347,   151,   154,     7,   334,
1293     35,   334,     4,    20,   284,   100,    78,   284,     5,   176,
1294    183,   332,   106,   344,     2,   122,   334,    36,    78,   283,
1295    630,   698,   368,    37,   446,    99,   631,   631,   188,    88,
1296    103,     4,   500,    20,   461,   327,   371,     5,    80,   156,
1297      7,    81,    20,   402,    78,   283,   285,   131,   322,   285,
1298     80,  -140,     2,    81,    20,   322,   121,   369,    78,    20,
1299    323,   717,    20,   322,   463,   322,   465,   370,   322,     7,
1300    321,   469,    20,    20,   409,   410,    80,     2,   411,    81,
1301     20,    20,    20,    78,    57,   446,   284,   390,   446,   155,
1302     80,   284,   391,    81,    20,    20,   589,   282,   501,    35,
1303    282,   535,   177,   502,     2,    78,   283,   503,   283,   392,
1304     78,   446,   284,    20,   122,    80,    36,    20,    81,    20,
1305     20,    20,    37,    32,   500,   446,   319,   435,   285,   319,
1306    625,   363,   320,   612,   393,   320,   324,    80,   179,   446,
1307     81,    20,    80,    32,   489,    81,    20,    32,   490,    20,
1308     78,    20,   284,   446,   285,   284,    20,   577,   446,   406,
1309    446,   578,   446,   319,    32,   319,   322,   482,   405,   320,
1310    483,   320,  -157,   284,   363,   284,   323,   441,   284,   282,
1311    445,   750,    80,   323,   751,    81,    20,   449,   701,    84,
1312    501,   323,   284,   323,   364,   502,   323,     2,   365,   503,
1313    474,   740,   366,    78,   743,   282,   284,   631,   319,    20,
1314    631,   138,   139,   319,   320,   285,   458,   285,   508,   320,
1315    284,   253,   139,   321,   491,   284,   321,   284,   558,   284,
1316   -342,  -342,  -344,  -344,   319,    80,  -505,  -505,    81,    20,
1317    320,   139,   319,   528,   530,   532,   534,   399,   320,   781,
1318   -506,  -506,   324,   594,   785,   596,   787,   325,   788,   324,
1319    321,   606,   321,   375,   376,   377,   282,   324,   282,   324,
1320    373,   374,   324,   634,   319,   388,   389,   319,   378,   379,
1321    320,   639,  -342,   320,  -344,   640,  -342,   644,  -344,   645,
1322    383,   384,   385,   386,   323,   319,   651,   319,   326,  -352,
1323    319,   320,   -15,   320,  -353,   321,   320,  -504,  -504,   364,
1324    321,   396,   397,   436,   319,  -415,  -415,   437,   677,   322,
1325    320,   661,   322,   671,   380,   381,   382,   678,   319,   387,
1326    679,   321,  -416,  -416,   320,   319,   471,   472,   473,   321,
1327    612,   320,   319,   722,   319,   141,   142,   319,   320,   319,
1328    320,   319,  -373,   320,   735,   320,   322,   320,   322,   518,
1329    520,     2,   522,   524,   526,   598,     2,    78,   539,   541,
1330    324,   321,    78,   325,   321,   749,    79,  -371,     4,  -208,
1331    325,    79,   752,     4,     5,  -504,  -504,   364,   325,     5,
1332    325,   365,   321,   325,   321,   366,   753,   321,   754,    80,
1333    755,   322,    81,    20,    80,   761,   322,    81,    20,   772,
1334    784,   321,   156,   157,   326,   763,   790,   156,   258,   791,
1335    782,   326,   786,   773,   779,   321,   537,   322,    33,   326,
1336     75,   326,   321,   108,   326,   322,   190,     2,   259,   321,
1337    400,   321,    73,    78,   321,   257,   321,   323,   321,   562,
1338    323,   127,    79,   443,     4,   248,   408,     2,   454,   457,
1339      5,   729,   730,    78,   478,   543,   547,   322,   545,   656,
1340    322,   657,    79,   700,     4,    80,   551,     0,    81,    20,
1341      5,     0,   549,   556,   323,     0,   323,     0,   322,    82,
1342    322,   325,     0,   322,     0,    80,     0,   -15,    81,    20,
1343    691,     0,  -504,  -504,   364,     0,     0,   322,   436,   126,
1344      0,     0,   366,     0,  -504,  -504,   364,   358,   248,     0,
1345    485,   322,     0,   324,   366,     0,   324,     0,   322,   323,
1346      0,     0,   326,     0,   323,   322,     0,   322,     0,     0,
1347    322,   -15,   322,     0,   322,     0,  -504,  -504,   364,    78,
1348      0,     0,   436,     0,     0,   323,   641,     0,   196,     0,
1349    324,     0,   324,   323,   197,     0,  -504,  -504,   364,     0,
1350      0,   198,   365,     0,     0,   199,   437,     0,     0,     0,
1351      0,    80,     0,   415,    81,    20,   421,     0,   200,   201,
1352      0,     0,   202,     0,   433,   323,     0,     0,   323,     0,
1353      0,   204,   205,   206,   207,   324,     0,   208,   209,     0,
1354    324,     0,     0,     0,     0,     0,   323,     0,   323,     0,
1355      0,   323,     0,     0,     0,     0,     0,     0,     0,     0,
1356      0,   324,     0,     0,     0,   323,     0,     0,     0,   324,
1357      0,     0,     0,     0,   325,     0,     0,   325,     0,   323,
1358      0,     0,     0,     0,     0,     0,   323,     0,     0,     0,
1359      0,     0,     0,   323,     0,   323,     0,     0,   323,     0,
1360    323,   324,   323,     0,   324,     0,     0,     0,     0,     0,
1361    499,   325,     0,   325,   507,   326,     0,     0,   326,     0,
1362      0,     0,   324,     0,   324,     0,     0,   324,     0,     0,
1363      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1364    554,   324,     0,     0,     0,     0,     0,     0,     0,     0,
1365      0,     0,   326,     0,   326,   324,   325,     0,   566,     0,
1366      0,   325,   324,     0,   335,   335,   335,   335,   574,   324,
1367    576,   324,   335,   335,   324,     0,   324,     0,   324,     0,
1368      0,   499,   325,     0,     0,     0,     0,     0,     0,     0,
1369    325,     0,     0,     0,     0,     0,     0,   326,   336,   336,
1370    336,   336,   326,   601,     0,   603,   336,   336,     0,     0,
1371      0,     0,     0,     0,     0,     0,     0,     0,     0,   609,
1372      0,     0,   325,   326,     0,   325,     0,     0,     0,     0,
1373    499,   326,     0,     0,     0,   248,     0,     0,     0,     0,
1374      0,     0,     0,   325,     0,   325,     0,     0,   325,     0,
1375      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1376      0,     0,   325,   326,     0,     0,   326,     0,     0,     0,
1377      0,     0,     0,     0,     0,     0,   325,     0,     0,     0,
1378      0,     0,     0,   325,   326,     0,   326,     0,     0,   326,
1379    325,     0,   325,     0,     0,   325,     0,   325,     0,   325,
1380      0,     0,     0,   326,     0,     0,     0,     0,     0,     0,
1381      0,     0,     0,     0,     0,     0,     0,   326,     0,     0,
1382      0,     0,     0,     0,   326,     0,     0,     0,     0,     0,
1383      0,   326,     0,   326,     0,     0,   326,     0,   326,     0,
1384    326,     0,     0,     0,     0,     0,     0,   335,   335,   335,
1385    335,   335,   335,   335,   335,   335,   335,   335,   335,     0,
1386    335,   335,   335,   335,   335,   335,   335,     0,     0,     0,
1387      0,     0,     0,     0,   266,     0,   694,     0,     0,     0,
1388      0,   336,   336,   336,   336,   336,   336,   336,   336,   336,
1389    336,   336,   336,     0,   336,   336,   336,   336,   336,   336,
1390    336,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1391    726,     0,     0,     0,     0,     0,   734,     2,   194,   195,
1392    664,   267,   268,    78,   269,     0,     0,   270,     0,     0,
1393      0,   271,   196,     0,     0,   665,     0,     0,   272,   273,
1394      5,   274,     0,   275,   276,   198,   277,     0,     0,   278,
1395      0,     0,     0,     0,   335,    80,   266,     0,    81,    20,
1396    335,     0,     0,     0,     0,     0,   279,     0,   156,   731,
1397      0,     0,   280,     0,     0,   204,   205,   206,   207,     0,
1398      0,   208,   209,     0,     0,     0,     0,     0,   336,     0,
1399      0,     0,     0,   768,   336,     0,     0,   771,     0,     2,
1400    194,   195,   664,   267,   268,    78,   269,     0,     0,   270,
1401      0,     0,     0,   271,   196,     0,     0,   665,     0,     0,
1402    272,   273,     5,   274,     0,   275,   276,   198,   277,     0,
1403     78,   278,     0,     0,     0,     0,     0,    80,     0,   196,
1404     81,    20,     0,     0,     0,   197,     0,     0,   279,     0,
1405    156,   760,   198,     0,   280,     0,   199,   204,   205,   206,
1406    207,     0,    80,   208,   209,    81,    20,     0,     0,   200,
1407    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1408      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1409    266,     0,     0,     0,     0,   335,     0,   335,     0,     0,
1410      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1411      0,     0,   335,     0,     0,     0,     0,     0,     0,     0,
1412      0,     0,     0,     0,     0,     0,     0,     0,     0,   336,
1413      0,   336,     0,     2,   194,   195,  -267,   267,   268,    78,
1414    269,     0,     0,   270,     0,     0,   336,   271,   196,     0,
1415      0,  -267,     0,     0,   272,   273,     5,   274,   266,   275,
1416    276,   198,   277,     0,     0,   278,     0,     0,     0,     0,
1417      0,    80,     0,     0,    81,    20,     0,     0,     0,     0,
1418      0,     0,   279,     0,   156,  -267,     0,     0,   280,     0,
1419      0,   204,   205,   206,   207,     0,     0,   208,   209,     0,
1420      0,     2,   194,   195,     0,   267,   268,    78,   269,     0,
1421      0,   270,     0,     0,     0,   271,   196,     0,     0,     0,
1422      0,     0,   272,   273,     5,   274,   266,   275,   276,   198,
1423    277,     0,     0,   278,     0,     0,     0,     0,     0,    80,
1424      0,     0,    81,    20,     0,     0,     0,     0,     0,     0,
1425    279,     0,   156,   442,     0,     0,   280,     0,     0,   204,
1426    205,   206,   207,     0,     0,   208,   209,     0,     0,     2,
1427    194,   195,     0,   267,   268,    78,   269,     0,     0,   270,
1428      0,     0,     0,   271,   196,     0,     0,     0,     0,     0,
1429    272,   273,     5,   274,   266,   275,   276,   198,   277,     0,
1430      0,   278,     0,     0,     0,     0,     0,    80,     0,     0,
1431     81,    20,     0,     0,     0,     0,     0,     0,   279,     0,
1432    156,     0,     0,     0,   280,     0,     0,   204,   205,   206,
1433    207,     0,     0,   208,   209,     0,     0,     2,   194,   195,
1434      0,   267,   268,    78,   269,     0,     0,   270,     0,     0,
1435      0,   271,   196,     0,     0,     0,     0,     0,   272,   273,
1436    266,   274,     0,   275,   276,   198,   277,     0,     0,   278,
1437      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1438      0,     0,     0,     0,     0,     0,   279,     0,   156,     0,
1439      0,     0,   280,     0,     0,   204,   205,   206,   207,     0,
1440      0,   208,   209,     2,   194,   195,     0,   705,   268,    78,
1441    269,     0,     0,   270,     0,     0,     0,   271,   196,     0,
1442      0,     0,     0,     0,   272,   273,     0,   274,     0,   275,
1443    276,   198,   277,     0,   627,   278,   192,   193,     0,     0,
1444      0,    80,     0,     0,    81,    20,     0,     0,     0,     0,
1445      0,     0,   279,     0,   156,     0,     0,     0,   280,     0,
1446      0,   204,   205,   206,   207,     0,     0,   208,   209,     0,
1447      0,     0,     0,     0,     0,     0,     0,     0,   194,   195,
1448      0,     0,     0,    78,     0,     0,     0,     0,     0,     0,
1449      0,     0,   196,     0,     0,     0,     0,     0,   197,   191,
1450      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1451      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1452      0,     0,   200,   201,     0,     0,   202,     0,   203,   628,
1453      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1454      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1455    419,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1456      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1457    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1458     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1459      0,   202,     0,   203,   194,   195,     0,     0,     0,    78,
1460    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1461      0,     0,     0,     0,   197,   497,     0,   192,   193,     0,
1462      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1463      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1464      0,     0,   202,     0,     0,     0,     0,     0,   420,     0,
1465      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1466    195,     0,     0,     0,    78,     0,   552,     0,   192,   193,
1467      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1468      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1469    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1470     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1471    194,   195,   498,     0,     0,    78,   204,   205,   206,   207,
1472      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1473    197,   497,     0,   192,   193,     0,     0,   198,     0,     0,
1474      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1475     81,    20,     0,   553,   200,   201,     0,     0,   202,     0,
1476      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1477    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1478     78,     0,   591,     0,   192,   193,     0,     0,     0,   196,
1479      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1480      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1481      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1482    201,     0,     0,   202,     0,     0,   194,   195,   588,     0,
1483      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1484    196,     0,     0,     0,     0,     0,   197,   599,     0,   192,
1485    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1486      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1487    200,   201,     0,     0,   202,   592,     0,     0,     0,     0,
1488      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1489    209,   194,   195,     0,     0,     0,    78,     0,   607,     0,
1490    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1491      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1492      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1493      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1494      0,     0,   194,   195,     0,   600,     0,    78,   204,   205,
1495    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1496      0,     0,   197,   616,     0,   192,   193,     0,     0,   198,
1497      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1498      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1499    202,     0,     0,     0,     0,   608,     0,     0,     0,   204,
1500    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1501      0,     0,    78,     0,   497,     0,   192,   193,     0,     0,
1502      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1503      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1504      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1505      0,   200,   201,     0,     0,   202,   617,     0,   194,   195,
1506      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1507    208,   209,   196,     0,     0,     0,     0,     0,   197,   591,
1508      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1509      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1510      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1511      0,   624,     0,     0,     0,   204,   205,   206,   207,     0,
1512      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1513    719,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1514      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1515    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1516     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1517      0,   202,   703,     0,   194,   195,     0,     0,     0,    78,
1518    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1519      0,     0,     0,     0,   197,   719,     0,   192,   193,     0,
1520      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1521      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1522      0,     0,   202,   720,     0,     0,     0,     0,     0,     0,
1523      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1524    195,     0,     0,     0,    78,     0,   599,     0,   192,   193,
1525      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1526      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1527    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1528     20,     0,     0,   200,   201,     0,     0,   202,   765,     0,
1529    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1530      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1531    197,   333,     0,   192,   193,     0,     0,   198,     0,     0,
1532      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1533     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1534      0,     0,     0,     0,   770,     0,     0,   204,   205,   206,
1535    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1536     78,     0,   338,     0,   192,   193,     0,     0,     0,   196,
1537      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1538      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1539      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1540    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1541      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1542    196,     0,     0,     0,     0,     0,   197,   340,     0,   192,
1543    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1544      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1545    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1546      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1547    209,   194,   195,     0,     0,     0,    78,     0,   342,     0,
1548    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1549      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1550      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1551      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1552      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1553    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1554      0,     0,   197,   351,     0,   192,   193,     0,     0,   198,
1555      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1556      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1557    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1558    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1559      0,     0,    78,     0,   353,     0,   192,   193,     0,     0,
1560      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1561      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1562      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1563      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1564      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1565    208,   209,   196,     0,     0,     0,     0,     0,   197,   355,
1566      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1567      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1568      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1569      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1570      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1571    414,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1572      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1573    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1574     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1575      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1576    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1577      0,     0,     0,     0,   197,   506,     0,   192,   193,     0,
1578      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1579      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1580      0,     0,   202,     0,     0,     0,     0,     0,     0,     0,
1581      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1582    195,     0,     0,     0,    78,     0,   511,     0,   192,   193,
1583      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1584      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1585    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1586     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1587    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1588      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1589    197,   513,     0,   192,   193,     0,     0,   198,     0,     0,
1590      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1591     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1592      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1593    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1594     78,     0,   515,     0,   192,   193,     0,     0,     0,   196,
1595      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1596      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1597      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1598    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1599      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1600    196,     0,     0,     0,     0,     0,   197,   517,     0,   192,
1601    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1602      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1603    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1604      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1605    209,   194,   195,     0,     0,     0,    78,     0,   519,     0,
1606    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1607      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1608      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1609      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1610      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1611    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1612      0,     0,   197,   521,     0,   192,   193,     0,     0,   198,
1613      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1614      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1615    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1616    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1617      0,     0,    78,     0,   523,     0,   192,   193,     0,     0,
1618      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1619      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1620      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1621      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1622      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1623    208,   209,   196,     0,     0,     0,     0,     0,   197,   525,
1624      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1625      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1626      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1627      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1628      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1629    527,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1630      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1631    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1632     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1633      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1634    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1635      0,     0,     0,     0,   197,   529,     0,   192,   193,     0,
1636      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1637      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1638      0,     0,   202,     0,     0,     0,     0,     0,     0,     0,
1639      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1640    195,     0,     0,     0,    78,     0,   531,     0,   192,   193,
1641      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1642      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1643    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1644     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1645    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1646      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1647    197,   533,     0,   192,   193,     0,     0,   198,     0,     0,
1648      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1649     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1650      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1651    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1652     78,     0,   538,     0,   192,   193,     0,     0,     0,   196,
1653      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1654      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1655      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1656    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1657      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1658    196,     0,     0,     0,     0,     0,   197,   540,     0,   192,
1659    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1660      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1661    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1662      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1663    209,   194,   195,     0,     0,     0,    78,     0,   542,     0,
1664    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1665      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1666      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1667      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1668      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1669    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1670      0,     0,   197,   544,     0,   192,   193,     0,     0,   198,
1671      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1672      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1673    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1674    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1675      0,     0,    78,     0,   546,     0,   192,   193,     0,     0,
1676      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1677      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1678      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1679      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1680      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1681    208,   209,   196,     0,     0,     0,     0,     0,   197,   548,
1682      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1683      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1684      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1685      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1686      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1687    550,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1688      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1689    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1690     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1691      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1692    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1693      0,     0,     0,     0,   197,   555,     0,   192,   193,     0,
1694      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1695      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1696      0,     0,   202,     0,     0,     0,     0,     0,     0,     0,
1697      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1698    195,     0,     0,     0,    78,     0,   565,     0,   192,   193,
1699      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1700      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1701    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1702     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1703    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1704      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1705    197,   573,     0,   192,   193,     0,     0,   198,     0,     0,
1706      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1707     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1708      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1709    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1710     78,     0,   575,     0,   192,   193,     0,     0,     0,   196,
1711      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1712      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1713      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1714    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1715      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1716    196,     0,     0,     0,     0,     0,   197,   602,     0,   192,
1717    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1718      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1719    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1720      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1721    209,   194,   195,     0,     0,     0,    78,     0,   619,     0,
1722    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1723      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1724      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1725      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1726      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1727    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1728      0,     0,   197,   689,     0,   192,   193,     0,     0,   198,
1729      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1730      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1731    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1732    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1733      0,     0,    78,     0,   693,     0,   192,   193,     0,     0,
1734      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1735      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1736      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1737      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1738      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1739    208,   209,   196,     0,     0,     0,     0,     0,   197,   699,
1740      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1741      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1742      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1743      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1744      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1745    725,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1746      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1747    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1748     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1749      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1750    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1751      0,     0,     0,     0,   197,     0,   583,     0,     0,     0,
1752      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1753      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1754      0,   674,   202,     0,     0,     0,     0,     0,     0,     0,
1755      0,   204,   205,   206,   207,     0,     0,   208,   209,  -290,
1756   -290,  -290,     0,     0,     0,  -290,     0,     0,     0,     0,
1757      0,     0,     0,     0,  -290,     0,     0,     0,     0,     0,
1758   -290,     0,     0,   736,     0,   194,   195,  -290,     0,     0,
1759     78,  -290,     0,     0,     0,     0,     0,  -290,     0,   196,
1760   -290,  -290,     0,     0,     0,   197,     0,     0,  -290,     0,
1761    192,   193,   198,     0,  -290,     0,   199,  -290,  -290,  -290,
1762   -290,     0,    80,  -290,  -290,    81,    20,   194,   195,     0,
1763      0,     0,    78,   279,  -298,     0,     0,     0,     0,     0,
1764      0,   196,   204,   205,   206,   207,     0,   197,   208,   209,
1765    672,     0,   194,   195,   198,     0,     0,    78,   199,     0,
1766      0,     0,     0,     0,    80,     0,   196,    81,    20,     0,
1767      0,     0,   197,     0,     0,   279,  -298,   192,   193,   198,
1768      0,     0,     0,   199,   204,   205,   206,   207,     0,    80,
1769    208,   209,    81,    20,   194,   195,   200,   201,     0,    78,
1770    202,     0,   203,   359,     0,     0,     0,     0,   196,   204,
1771    205,   206,   207,     0,   197,   208,   209,     0,     0,   194,
1772    195,   198,     0,     0,    78,   199,     0,     0,   192,   193,
1773      0,    80,     0,   196,    81,    20,     0,     0,     0,   197,
1774      0,     0,   279,     0,     0,     0,   198,     0,     0,     0,
1775    199,   204,   205,   206,   207,     0,    80,   208,   209,    81,
1776     20,     0,     0,   200,   201,     0,     0,   202,   494,     0,
1777    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1778      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1779    197,     0,     0,   192,   193,     0,     0,   198,     0,     0,
1780      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1781     81,    20,     0,     0,   200,   201,     0,     0,   202,   637,
1782      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1783    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1784     78,     0,     0,     0,   192,   193,     0,     0,     0,   196,
1785      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1786      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1787      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1788    201,     0,     0,   202,   680,     0,   194,   195,     0,     0,
1789      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1790    196,     0,     0,     0,     0,     0,   197,     0,     0,   192,
1791    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1792      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1793    200,   201,     0,     0,   202,   695,     0,     0,     0,     0,
1794      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1795    209,   194,   195,     0,     0,     0,    78,     0,     0,     0,
1796      0,     0,     0,     0,     0,   196,     0,     0,     0,     0,
1797      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1798      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1799      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1800      0,     2,   194,   195,     0,     0,     0,    78,   204,   205,
1801    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1802      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1803      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1804      0,     0,    81,    20,     0,     0,     0,     0,     0,     0,
1805    279,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1806    205,   206,   207,     0,     0,   208,   209
1807 };
1808
1809 static const short yycheck[] = {     3,
1810    132,   129,     6,   133,   330,   174,   123,    62,   203,   677,
1811    178,   134,     1,   290,   441,   488,   561,     1,     1,   564,
1812    192,   193,   194,   195,   349,     1,   117,     1,   200,   201,
1813      1,   356,   357,   161,    89,     1,   669,    47,    42,    94,
1814    168,    62,    46,     1,    94,   297,   310,     1,    53,   129,
1815     86,   101,    62,   305,   481,   307,     1,    42,    62,   150,
1816     64,    46,   153,     1,   129,    69,     1,     4,     5,    95,
1817      1,     1,    44,    94,   129,   198,     1,     9,   133,    64,
1818    171,   161,     1,   510,    69,    89,    96,   648,    15,    61,
1819     94,   100,    97,    67,     1,    67,   161,   730,   643,    36,
1820     37,    33,   770,    40,   159,     0,   161,   101,   129,    93,
1821     99,   779,   101,    50,     9,    10,    11,   101,   101,   648,
1822    648,     1,     1,    99,   128,   129,   256,   182,    99,   133,
1823    134,   648,     1,    99,   262,    30,    94,     1,    33,    34,
1824    161,    95,    79,   128,     1,    99,    83,   275,   709,   134,
1825    475,   712,   625,   478,    99,   159,    51,   161,     1,    94,
1826     87,    99,   100,   331,   281,   100,   257,    62,    99,    99,
1827    174,   101,     1,     1,    99,   100,    95,     1,   182,   606,
1828    709,   709,     1,   712,   712,   122,   123,    94,   192,   193,
1829    194,   195,   709,   100,   198,   712,   200,   201,   202,    94,
1830    330,   256,   139,   375,   376,   377,     1,   634,     1,   332,
1831      1,     1,     1,   198,    94,     1,   777,   644,    62,    98,
1832    100,   782,     1,   784,     1,   786,    95,     1,    94,     1,
1833     94,    97,   287,   660,   129,     1,   100,   174,   133,   408,
1834      1,   178,    99,    86,     1,    89,     0,     1,   777,   777,
1835     94,     1,   256,   782,   782,   784,   784,   786,   786,     1,
1836    777,    97,     1,     1,    93,   782,   161,   784,     1,   786,
1837     94,    99,     1,    45,    46,   330,   100,    97,     1,   174,
1838     99,   101,     5,   287,   221,   129,   290,   564,    67,   133,
1839     44,    86,    92,   297,     1,   490,    86,    97,    98,    88,
1840    477,   305,   479,   307,    99,    98,   310,    61,    99,    99,
1841    482,     1,    98,    67,    86,   159,    88,   161,   745,    91,
1842     92,    93,    99,   440,    98,    97,   330,   653,   332,   101,
1843    174,     1,    98,   270,   598,     1,   600,    98,   182,     1,
1844    277,    98,     1,     1,   281,    99,     1,   332,    98,    88,
1845     72,     1,    94,   290,   198,     0,     1,    95,   202,   174,
1846    297,   256,    95,    86,    86,   174,   643,    83,   305,    98,
1847    307,   375,   376,   377,   378,   379,   380,   381,   382,   383,
1848    384,   385,   386,   387,   388,   389,   390,   391,   392,   393,
1849    394,    98,   561,    63,   331,   290,   648,    52,    97,    44,
1850     52,     1,   101,    93,   408,    63,   122,   123,     0,   346,
1851     55,    97,   256,   677,    94,   310,    61,     9,    10,    11,
1852    100,     9,    67,    11,    86,    95,     1,   100,    94,   366,
1853     75,   368,     0,     1,    93,   330,     1,    95,    30,     1,
1854     95,    33,    34,   287,    94,    33,   290,   129,    95,     1,
1855    578,   623,     1,   581,    99,   732,   174,   709,     1,    51,
1856    712,    94,    93,     1,     1,    47,   310,   100,     0,     1,
1857     62,   408,     0,     1,    98,   290,    44,   159,   482,   161,
1858     62,   290,   297,   735,   488,     1,   330,    55,   297,     1,
1859    305,     1,   307,    61,    94,   310,   305,   749,   307,    67,
1860    437,   310,    94,   440,     1,   637,   770,    96,     1,     1,
1861      1,   763,    44,   408,    96,   779,    44,    93,    93,     0,
1862      1,     1,     1,   653,    86,   777,     1,    55,    93,    61,
1863    782,    99,   784,    61,   786,    67,    99,   129,     1,    67,
1864     92,    93,    52,   387,    93,    97,    98,    99,   100,    95,
1865     93,   679,   174,    63,   686,    93,    93,   561,    53,    52,
1866    564,     0,     1,    44,   408,    44,   698,    99,     1,   161,
1867     63,    99,   290,    95,    55,    97,    92,     1,    94,   297,
1868     61,    97,    98,    99,   100,    95,    67,   305,    67,   307,
1869      0,     1,   310,   408,     1,    86,    93,     1,   653,   408,
1870    475,    93,    95,   478,    67,    44,    86,     1,     1,    72,
1871    742,    86,    44,    76,    93,     1,     1,     1,    99,   623,
1872     44,   625,    61,    86,   561,    65,    50,   564,    67,     1,
1873      1,   100,    72,   101,    44,    59,   640,    61,    50,   643,
1874     94,    94,   101,    67,   648,    64,   100,   100,     1,   653,
1875     69,    61,     1,    86,     1,     1,     1,    67,    82,    95,
1876     99,    85,    86,    99,    50,   669,   561,   107,   290,   564,
1877     82,    95,    44,    85,    86,   297,     1,    97,    50,    86,
1878    174,     1,    86,   305,     1,   307,     1,   101,   310,    99,
1879    408,     1,    86,    86,    95,    96,    82,    44,    99,    85,
1880     86,    86,    86,    50,   641,   709,   643,    11,   712,   128,
1881     82,   648,    12,    85,    86,    86,    65,   561,    67,    44,
1882    564,     1,    94,    72,    44,    50,   730,    76,   732,    13,
1883     50,   735,   669,    86,    59,    82,    61,    86,    85,    86,
1884     86,    86,    67,    10,     1,   749,   561,    97,   643,   564,
1885     94,   101,   561,    97,    14,   564,   174,    82,   653,   763,
1886     85,    86,    82,    30,    96,    85,    86,    34,   100,    86,
1887     50,    86,   709,   777,   669,   712,    86,    60,   782,    95,
1888    784,    64,   786,   598,    51,   600,   408,    94,    99,   598,
1889     97,   600,    93,   730,   101,   732,   290,    93,   735,   643,
1890     99,   709,    82,   297,   712,    85,    86,    99,    65,   653,
1891     67,   305,   749,   307,    93,    72,   310,    44,    97,    76,
1892     97,    94,   101,    50,    94,   669,   763,   100,   643,    86,
1893    100,    99,   100,   648,   643,   730,    99,   732,    67,   648,
1894    777,    99,   100,   561,    98,   782,   564,   784,    99,   786,
1895     45,    46,    45,    46,   669,    82,    91,    92,    85,    86,
1896    669,   100,   677,   383,   384,   385,   386,    94,   677,   777,
1897     91,    92,   290,    95,   782,    66,   784,   174,   786,   297,
1898    598,    93,   600,     5,     6,     7,   730,   305,   732,   307,
1899     45,    46,   310,    93,   709,    16,    17,   712,     3,     4,
1900    709,     1,    97,   712,    97,    88,   101,    93,   101,    99,
1901     18,    19,    20,    21,   408,   730,    94,   732,   174,   101,
1902    735,   730,    86,   732,   101,   643,   735,    91,    92,    93,
1903    648,    91,    92,    97,   749,    45,    46,   101,    99,   561,
1904    749,     1,   564,    93,     8,     9,    10,    94,   763,    57,
1905     94,   669,    45,    46,   763,   770,    97,    98,    99,   677,
1906     97,   770,   777,     1,   779,    97,    98,   782,   777,   784,
1907    779,   786,    95,   782,    94,   784,   598,   786,   600,   378,
1908    379,    44,   380,   381,   382,   100,    44,    50,   388,   389,
1909    408,   709,    50,   290,   712,    56,    59,    95,    61,    56,
1910    297,    59,    99,    61,    67,    91,    92,    93,   305,    67,
1911    307,    97,   730,   310,   732,   101,    94,   735,    94,    82,
1912      1,   643,    85,    86,    82,    94,   648,    85,    86,     1,
1913     56,   749,    95,    96,   290,    94,     0,    95,    96,     0,
1914     94,   297,    94,    99,    99,   763,   387,   669,    11,   305,
1915     54,   307,   770,    75,   310,   677,   139,    44,   161,   777,
1916    256,   779,    52,    50,   782,   159,   784,   561,   786,   408,
1917    564,    94,    59,   290,    61,   140,   264,    44,   310,   310,
1918     67,   667,   667,    50,   349,   390,   392,   709,   391,   579,
1919    712,   579,    59,   640,    61,    82,   394,    -1,    85,    86,
1920     67,    -1,   393,   398,   598,    -1,   600,    -1,   730,    96,
1921    732,   408,    -1,   735,    -1,    82,    -1,    86,    85,    86,
1922      1,    -1,    91,    92,    93,    -1,    -1,   749,    97,    96,
1923     -1,    -1,   101,    -1,    91,    92,    93,   202,   203,    -1,
1924     97,   763,    -1,   561,   101,    -1,   564,    -1,   770,   643,
1925     -1,    -1,   408,    -1,   648,   777,    -1,   779,    -1,    -1,
1926    782,    86,   784,    -1,   786,    -1,    91,    92,    93,    50,
1927     -1,    -1,    97,    -1,    -1,   669,   101,    -1,    59,    -1,
1928    598,    -1,   600,   677,    65,    -1,    91,    92,    93,    -1,
1929     -1,    72,    97,    -1,    -1,    76,   101,    -1,    -1,    -1,
1930     -1,    82,    -1,   268,    85,    86,   271,    -1,    89,    90,
1931     -1,    -1,    93,    -1,   279,   709,    -1,    -1,   712,    -1,
1932     -1,   102,   103,   104,   105,   643,    -1,   108,   109,    -1,
1933    648,    -1,    -1,    -1,    -1,    -1,   730,    -1,   732,    -1,
1934     -1,   735,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1935     -1,   669,    -1,    -1,    -1,   749,    -1,    -1,    -1,   677,
1936     -1,    -1,    -1,    -1,   561,    -1,    -1,   564,    -1,   763,
1937     -1,    -1,    -1,    -1,    -1,    -1,   770,    -1,    -1,    -1,
1938     -1,    -1,    -1,   777,    -1,   779,    -1,    -1,   782,    -1,
1939    784,   709,   786,    -1,   712,    -1,    -1,    -1,    -1,    -1,
1940    365,   598,    -1,   600,   369,   561,    -1,    -1,   564,    -1,
1941     -1,    -1,   730,    -1,   732,    -1,    -1,   735,    -1,    -1,
1942     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1943    395,   749,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1944     -1,    -1,   598,    -1,   600,   763,   643,    -1,   413,    -1,
1945     -1,   648,   770,    -1,   192,   193,   194,   195,   423,   777,
1946    425,   779,   200,   201,   782,    -1,   784,    -1,   786,    -1,
1947     -1,   436,   669,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1948    677,    -1,    -1,    -1,    -1,    -1,    -1,   643,   192,   193,
1949    194,   195,   648,   458,    -1,   460,   200,   201,    -1,    -1,
1950     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   474,
1951     -1,    -1,   709,   669,    -1,   712,    -1,    -1,    -1,    -1,
1952    485,   677,    -1,    -1,    -1,   490,    -1,    -1,    -1,    -1,
1953     -1,    -1,    -1,   730,    -1,   732,    -1,    -1,   735,    -1,
1954     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1955     -1,    -1,   749,   709,    -1,    -1,   712,    -1,    -1,    -1,
1956     -1,    -1,    -1,    -1,    -1,    -1,   763,    -1,    -1,    -1,
1957     -1,    -1,    -1,   770,   730,    -1,   732,    -1,    -1,   735,
1958    777,    -1,   779,    -1,    -1,   782,    -1,   784,    -1,   786,
1959     -1,    -1,    -1,   749,    -1,    -1,    -1,    -1,    -1,    -1,
1960     -1,    -1,    -1,    -1,    -1,    -1,    -1,   763,    -1,    -1,
1961     -1,    -1,    -1,    -1,   770,    -1,    -1,    -1,    -1,    -1,
1962     -1,   777,    -1,   779,    -1,    -1,   782,    -1,   784,    -1,
1963    786,    -1,    -1,    -1,    -1,    -1,    -1,   375,   376,   377,
1964    378,   379,   380,   381,   382,   383,   384,   385,   386,    -1,
1965    388,   389,   390,   391,   392,   393,   394,    -1,    -1,    -1,
1966     -1,    -1,    -1,    -1,     1,    -1,   631,    -1,    -1,    -1,
1967     -1,   375,   376,   377,   378,   379,   380,   381,   382,   383,
1968    384,   385,   386,    -1,   388,   389,   390,   391,   392,   393,
1969    394,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1970    665,    -1,    -1,    -1,    -1,    -1,   671,    44,    45,    46,
1971     47,    48,    49,    50,    51,    -1,    -1,    54,    -1,    -1,
1972     -1,    58,    59,    -1,    -1,    62,    -1,    -1,    65,    66,
1973     67,    68,    -1,    70,    71,    72,    73,    -1,    -1,    76,
1974     -1,    -1,    -1,    -1,   482,    82,     1,    -1,    85,    86,
1975    488,    -1,    -1,    -1,    -1,    -1,    93,    -1,    95,    96,
1976     -1,    -1,    99,    -1,    -1,   102,   103,   104,   105,    -1,
1977     -1,   108,   109,    -1,    -1,    -1,    -1,    -1,   482,    -1,
1978     -1,    -1,    -1,   748,   488,    -1,    -1,   752,    -1,    44,
1979     45,    46,    47,    48,    49,    50,    51,    -1,    -1,    54,
1980     -1,    -1,    -1,    58,    59,    -1,    -1,    62,    -1,    -1,
1981     65,    66,    67,    68,    -1,    70,    71,    72,    73,    -1,
1982     50,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    59,
1983     85,    86,    -1,    -1,    -1,    65,    -1,    -1,    93,    -1,
1984     95,    96,    72,    -1,    99,    -1,    76,   102,   103,   104,
1985    105,    -1,    82,   108,   109,    85,    86,    -1,    -1,    89,
1986     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
1987     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
1988      1,    -1,    -1,    -1,    -1,   623,    -1,   625,    -1,    -1,
1989     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1990     -1,    -1,   640,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1991     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   623,
1992     -1,   625,    -1,    44,    45,    46,    47,    48,    49,    50,
1993     51,    -1,    -1,    54,    -1,    -1,   640,    58,    59,    -1,
1994     -1,    62,    -1,    -1,    65,    66,    67,    68,     1,    70,
1995     71,    72,    73,    -1,    -1,    76,    -1,    -1,    -1,    -1,
1996     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,
1997     -1,    -1,    93,    -1,    95,    96,    -1,    -1,    99,    -1,
1998     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    -1,
1999     -1,    44,    45,    46,    -1,    48,    49,    50,    51,    -1,
2000     -1,    54,    -1,    -1,    -1,    58,    59,    -1,    -1,    -1,
2001     -1,    -1,    65,    66,    67,    68,     1,    70,    71,    72,
2002     73,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2003     -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,
2004     93,    -1,    95,    96,    -1,    -1,    99,    -1,    -1,   102,
2005    103,   104,   105,    -1,    -1,   108,   109,    -1,    -1,    44,
2006     45,    46,    -1,    48,    49,    50,    51,    -1,    -1,    54,
2007     -1,    -1,    -1,    58,    59,    -1,    -1,    -1,    -1,    -1,
2008     65,    66,    67,    68,     1,    70,    71,    72,    73,    -1,
2009     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2010     85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    93,    -1,
2011     95,    -1,    -1,    -1,    99,    -1,    -1,   102,   103,   104,
2012    105,    -1,    -1,   108,   109,    -1,    -1,    44,    45,    46,
2013     -1,    48,    49,    50,    51,    -1,    -1,    54,    -1,    -1,
2014     -1,    58,    59,    -1,    -1,    -1,    -1,    -1,    65,    66,
2015      1,    68,    -1,    70,    71,    72,    73,    -1,    -1,    76,
2016     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2017     -1,    -1,    -1,    -1,    -1,    -1,    93,    -1,    95,    -1,
2018     -1,    -1,    99,    -1,    -1,   102,   103,   104,   105,    -1,
2019     -1,   108,   109,    44,    45,    46,    -1,    48,    49,    50,
2020     51,    -1,    -1,    54,    -1,    -1,    -1,    58,    59,    -1,
2021     -1,    -1,    -1,    -1,    65,    66,    -1,    68,    -1,    70,
2022     71,    72,    73,    -1,     1,    76,     3,     4,    -1,    -1,
2023     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,
2024     -1,    -1,    93,    -1,    95,    -1,    -1,    -1,    99,    -1,
2025     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    -1,
2026     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    45,    46,
2027     -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,
2028     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2029     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2030     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2031     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    95,    96,
2032     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2033     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2034      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2035     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2036     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2037     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2038     -1,    93,    -1,    95,    45,    46,    -1,    -1,    -1,    50,
2039    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2040     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2041     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2042     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2043     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    99,    -1,
2044     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2045     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2046     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2047     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2048     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2049     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2050     45,    46,    98,    -1,    -1,    50,   102,   103,   104,   105,
2051     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2052     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2053     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2054     85,    86,    -1,    88,    89,    90,    -1,    -1,    93,    -1,
2055     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2056    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2057     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2058     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2059     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2060     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2061     90,    -1,    -1,    93,    -1,    -1,    45,    46,    98,    -1,
2062     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2063     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2064      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2065     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2066     89,    90,    -1,    -1,    93,    94,    -1,    -1,    -1,    -1,
2067     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2068    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2069      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2070     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2071     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2072     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2073     -1,    -1,    45,    46,    -1,    99,    -1,    50,   102,   103,
2074    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2075     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2076     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2077     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2078     93,    -1,    -1,    -1,    -1,    98,    -1,    -1,    -1,   102,
2079    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2080     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2081     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2082     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2083     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2084     -1,    89,    90,    -1,    -1,    93,    94,    -1,    45,    46,
2085     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2086    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2087     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2088     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2089     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2090     -1,    98,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2091     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2092      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2093     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2094     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2095     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2096     -1,    93,    94,    -1,    45,    46,    -1,    -1,    -1,    50,
2097    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2098     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2099     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2100     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2101     -1,    -1,    93,    94,    -1,    -1,    -1,    -1,    -1,    -1,
2102     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2103     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2104     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2105     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2106     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2107     86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,    -1,
2108     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2109     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2110     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2111     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2112     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2113     -1,    -1,    -1,    -1,    99,    -1,    -1,   102,   103,   104,
2114    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2115     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2116     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2117     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2118     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2119     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2120     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2121     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2122      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2123     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2124     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2125     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2126    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2127      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2128     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2129     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2130     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2131     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2132    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2133     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2134     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2135     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2136     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2137    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2138     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2139     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2140     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2141     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2142     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2143     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2144    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2145     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2146     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2147     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2148     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2149     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2150      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2151     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2152     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2153     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2154     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2155    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2156     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2157     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2158     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2159     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2160     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2161     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2162     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2163     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2164     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2165     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2166     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2167     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2168     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2169     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2170     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2171     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2172    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2173     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2174     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2175     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2176     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2177     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2178     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2179     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2180      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2181     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2182     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2183     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2184    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2185      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2186     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2187     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2188     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2189     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2190    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2191     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2192     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2193     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2194     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2195    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2196     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2197     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2198     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2199     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2200     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2201     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2202    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2203     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2204     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2205     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2206     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2207     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2208      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2209     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2210     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2211     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2212     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2213    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2214     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2215     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2216     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2217     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2218     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2219     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2220     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2221     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2222     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2223     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2224     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2225     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2226     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2227     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2228     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2229     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2230    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2231     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2232     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2233     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2234     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2235     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2236     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2237     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2238      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2239     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2240     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2241     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2242    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2243      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2244     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2245     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2246     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2247     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2248    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2249     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2250     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2251     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2252     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2253    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2254     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2255     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2256     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2257     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2258     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2259     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2260    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2261     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2262     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2263     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2264     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2265     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2266      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2267     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2268     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2269     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2270     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2271    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2272     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2273     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2274     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2275     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2276     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2277     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2278     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2279     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2280     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2281     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2282     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2283     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2284     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2285     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2286     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2287     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2288    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2289     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2290     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2291     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2292     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2293     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2294     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2295     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2296      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2297     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2298     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2299     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2300    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2301      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2302     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2303     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2304     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2305     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2306    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2307     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2308     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2309     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2310     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2311    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2312     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2313     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2314     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2315     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2316     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2317     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2318    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2319     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2320     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2321     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2322     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2323     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2324      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2325     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2326     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2327     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2328     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2329    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2330     -1,    -1,    -1,    -1,    65,    -1,     1,    -1,    -1,    -1,
2331     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2332     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2333     -1,     1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2334     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    44,
2335     45,    46,    -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,
2336     -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
2337     65,    -1,    -1,     1,    -1,    45,    46,    72,    -1,    -1,
2338     50,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    59,
2339     85,    86,    -1,    -1,    -1,    65,    -1,    -1,    93,    -1,
2340      3,     4,    72,    -1,    99,    -1,    76,   102,   103,   104,
2341    105,    -1,    82,   108,   109,    85,    86,    45,    46,    -1,
2342     -1,    -1,    50,    93,    94,    -1,    -1,    -1,    -1,    -1,
2343     -1,    59,   102,   103,   104,   105,    -1,    65,   108,   109,
2344      1,    -1,    45,    46,    72,    -1,    -1,    50,    76,    -1,
2345     -1,    -1,    -1,    -1,    82,    -1,    59,    85,    86,    -1,
2346     -1,    -1,    65,    -1,    -1,    93,    94,     3,     4,    72,
2347     -1,    -1,    -1,    76,   102,   103,   104,   105,    -1,    82,
2348    108,   109,    85,    86,    45,    46,    89,    90,    -1,    50,
2349     93,    -1,    95,    96,    -1,    -1,    -1,    -1,    59,   102,
2350    103,   104,   105,    -1,    65,   108,   109,    -1,    -1,    45,
2351     46,    72,    -1,    -1,    50,    76,    -1,    -1,     3,     4,
2352     -1,    82,    -1,    59,    85,    86,    -1,    -1,    -1,    65,
2353     -1,    -1,    93,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2354     76,   102,   103,   104,   105,    -1,    82,   108,   109,    85,
2355     86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,    -1,
2356     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2357     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2358     65,    -1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2359     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2360     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,
2361     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2362    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2363     50,    -1,    -1,    -1,     3,     4,    -1,    -1,    -1,    59,
2364     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2365     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2366     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2367     90,    -1,    -1,    93,    94,    -1,    45,    46,    -1,    -1,
2368     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2369     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,     3,
2370      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2371     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2372     89,    90,    -1,    -1,    93,    94,    -1,    -1,    -1,    -1,
2373     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2374    109,    45,    46,    -1,    -1,    -1,    50,    -1,    -1,    -1,
2375     -1,    -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2376     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2377     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2378     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2379     -1,    44,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2380    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2381     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
2382     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2383     -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,
2384     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2385    103,   104,   105,    -1,    -1,   108,   109
2386 };
2387 #define YYPURE 1
2388
2389 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
2390 #line 3 "/usr/lib/bison.simple"
2391 /* This file comes from bison-1.28.  */
2392
2393 /* Skeleton output parser for bison,
2394    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2395
2396    This program is free software; you can redistribute it and/or modify
2397    it under the terms of the GNU General Public License as published by
2398    the Free Software Foundation; either version 2, or (at your option)
2399    any later version.
2400
2401    This program is distributed in the hope that it will be useful,
2402    but WITHOUT ANY WARRANTY; without even the implied warranty of
2403    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2404    GNU General Public License for more details.
2405
2406    You should have received a copy of the GNU General Public License
2407    along with this program; if not, write to the Free Software
2408    Foundation, Inc., 59 Temple Place - Suite 330,
2409    Boston, MA 02111-1307, USA.  */
2410
2411 /* As a special exception, when this file is copied by Bison into a
2412    Bison output file, you may use that output file without restriction.
2413    This special exception was added by the Free Software Foundation
2414    in version 1.24 of Bison.  */
2415
2416 /* This is the parser code that is written into each bison parser
2417   when the %semantic_parser declaration is not specified in the grammar.
2418   It was written by Richard Stallman by simplifying the hairy parser
2419   used when %semantic_parser is specified.  */
2420
2421 #ifndef YYSTACK_USE_ALLOCA
2422 #ifdef alloca
2423 #define YYSTACK_USE_ALLOCA
2424 #else /* alloca not defined */
2425 #ifdef __GNUC__
2426 #define YYSTACK_USE_ALLOCA
2427 #define alloca __builtin_alloca
2428 #else /* not GNU C.  */
2429 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2430 #define YYSTACK_USE_ALLOCA
2431 #include <alloca.h>
2432 #else /* not sparc */
2433 /* We think this test detects Watcom and Microsoft C.  */
2434 /* This used to test MSDOS, but that is a bad idea
2435    since that symbol is in the user namespace.  */
2436 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2437 #if 0 /* No need for malloc.h, which pollutes the namespace;
2438          instead, just don't use alloca.  */
2439 #include <malloc.h>
2440 #endif
2441 #else /* not MSDOS, or __TURBOC__ */
2442 #if defined(_AIX)
2443 /* I don't know what this was needed for, but it pollutes the namespace.
2444    So I turned it off.   rms, 2 May 1997.  */
2445 /* #include <malloc.h>  */
2446  #pragma alloca
2447 #define YYSTACK_USE_ALLOCA
2448 #else /* not MSDOS, or __TURBOC__, or _AIX */
2449 #if 0
2450 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2451                  and on HPUX 10.  Eventually we can turn this on.  */
2452 #define YYSTACK_USE_ALLOCA
2453 #define alloca __builtin_alloca
2454 #endif /* __hpux */
2455 #endif
2456 #endif /* not _AIX */
2457 #endif /* not MSDOS, or __TURBOC__ */
2458 #endif /* not sparc */
2459 #endif /* not GNU C */
2460 #endif /* alloca not defined */
2461 #endif /* YYSTACK_USE_ALLOCA not defined */
2462
2463 #ifdef YYSTACK_USE_ALLOCA
2464 #define YYSTACK_ALLOC alloca
2465 #else
2466 #define YYSTACK_ALLOC malloc
2467 #endif
2468
2469 /* Note: there must be only one dollar sign in this file.
2470    It is replaced by the list of actions, each action
2471    as one case of the switch.  */
2472
2473 #define yyerrok         (yyerrstatus = 0)
2474 #define yyclearin       (yychar = YYEMPTY)
2475 #define YYEMPTY         -2
2476 #define YYEOF           0
2477 #define YYACCEPT        goto yyacceptlab
2478 #define YYABORT         goto yyabortlab
2479 #define YYERROR         goto yyerrlab1
2480 /* Like YYERROR except do call yyerror.
2481    This remains here temporarily to ease the
2482    transition to the new meaning of YYERROR, for GCC.
2483    Once GCC version 2 has supplanted version 1, this can go.  */
2484 #define YYFAIL          goto yyerrlab
2485 #define YYRECOVERING()  (!!yyerrstatus)
2486 #define YYBACKUP(token, value) \
2487 do                                                              \
2488   if (yychar == YYEMPTY && yylen == 1)                          \
2489     { yychar = (token), yylval = (value);                       \
2490       yychar1 = YYTRANSLATE (yychar);                           \
2491       YYPOPSTACK;                                               \
2492       goto yybackup;                                            \
2493     }                                                           \
2494   else                                                          \
2495     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
2496 while (0)
2497
2498 #define YYTERROR        1
2499 #define YYERRCODE       256
2500
2501 #ifndef YYPURE
2502 #define YYLEX           yylex()
2503 #endif
2504
2505 #ifdef YYPURE
2506 #ifdef YYLSP_NEEDED
2507 #ifdef YYLEX_PARAM
2508 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
2509 #else
2510 #define YYLEX           yylex(&yylval, &yylloc)
2511 #endif
2512 #else /* not YYLSP_NEEDED */
2513 #ifdef YYLEX_PARAM
2514 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
2515 #else
2516 #define YYLEX           yylex(&yylval)
2517 #endif
2518 #endif /* not YYLSP_NEEDED */
2519 #endif
2520
2521 /* If nonreentrant, generate the variables here */
2522
2523 #ifndef YYPURE
2524
2525 int     yychar;                 /*  the lookahead symbol                */
2526 YYSTYPE yylval;                 /*  the semantic value of the           */
2527                                 /*  lookahead symbol                    */
2528
2529 #ifdef YYLSP_NEEDED
2530 YYLTYPE yylloc;                 /*  location data for the lookahead     */
2531                                 /*  symbol                              */
2532 #endif
2533
2534 int yynerrs;                    /*  number of parse errors so far       */
2535 #endif  /* not YYPURE */
2536
2537 #if YYDEBUG != 0
2538 int yydebug;                    /*  nonzero means print parse trace     */
2539 /* Since this is uninitialized, it does not stop multiple parsers
2540    from coexisting.  */
2541 #endif
2542
2543 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
2544
2545 #ifndef YYINITDEPTH
2546 #define YYINITDEPTH 200
2547 #endif
2548
2549 /*  YYMAXDEPTH is the maximum size the stacks can grow to
2550     (effective only if the built-in stack extension method is used).  */
2551
2552 #if YYMAXDEPTH == 0
2553 #undef YYMAXDEPTH
2554 #endif
2555
2556 #ifndef YYMAXDEPTH
2557 #define YYMAXDEPTH 10000
2558 #endif
2559 \f
2560 /* Define __yy_memcpy.  Note that the size argument
2561    should be passed with type unsigned int, because that is what the non-GCC
2562    definitions require.  With GCC, __builtin_memcpy takes an arg
2563    of type size_t, but it can handle unsigned int.  */
2564
2565 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
2566 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
2567 #else                           /* not GNU C or C++ */
2568 #ifndef __cplusplus
2569
2570 /* This is the most reliable way to avoid incompatibilities
2571    in available built-in functions on various systems.  */
2572 static void
2573 __yy_memcpy (to, from, count)
2574      char *to;
2575      char *from;
2576      unsigned int count;
2577 {
2578   register char *f = from;
2579   register char *t = to;
2580   register int i = count;
2581
2582   while (i-- > 0)
2583     *t++ = *f++;
2584 }
2585
2586 #else /* __cplusplus */
2587
2588 /* This is the most reliable way to avoid incompatibilities
2589    in available built-in functions on various systems.  */
2590 static void
2591 __yy_memcpy (char *to, char *from, unsigned int count)
2592 {
2593   register char *t = to;
2594   register char *f = from;
2595   register int i = count;
2596
2597   while (i-- > 0)
2598     *t++ = *f++;
2599 }
2600
2601 #endif
2602 #endif
2603 \f
2604 #line 217 "/usr/lib/bison.simple"
2605
2606 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2607    into yyparse.  The argument should have type void *.
2608    It should actually point to an object.
2609    Grammar actions can access the variable by casting it
2610    to the proper pointer type.  */
2611
2612 #ifdef YYPARSE_PARAM
2613 #ifdef __cplusplus
2614 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2615 #define YYPARSE_PARAM_DECL
2616 #else /* not __cplusplus */
2617 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2618 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2619 #endif /* not __cplusplus */
2620 #else /* not YYPARSE_PARAM */
2621 #define YYPARSE_PARAM_ARG
2622 #define YYPARSE_PARAM_DECL
2623 #endif /* not YYPARSE_PARAM */
2624
2625 /* Prevent warning if -Wstrict-prototypes.  */
2626 #ifdef __GNUC__
2627 #ifdef YYPARSE_PARAM
2628 int yyparse (void *);
2629 #else
2630 int yyparse (void);
2631 #endif
2632 #endif
2633
2634 int
2635 yyparse(YYPARSE_PARAM_ARG)
2636      YYPARSE_PARAM_DECL
2637 {
2638   register int yystate;
2639   register int yyn;
2640   register short *yyssp;
2641   register YYSTYPE *yyvsp;
2642   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
2643   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
2644
2645   short yyssa[YYINITDEPTH];     /*  the state stack                     */
2646   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
2647
2648   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
2649   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
2650
2651 #ifdef YYLSP_NEEDED
2652   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
2653   YYLTYPE *yyls = yylsa;
2654   YYLTYPE *yylsp;
2655
2656 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
2657 #else
2658 #define YYPOPSTACK   (yyvsp--, yyssp--)
2659 #endif
2660
2661   int yystacksize = YYINITDEPTH;
2662   int yyfree_stacks = 0;
2663
2664 #ifdef YYPURE
2665   int yychar;
2666   YYSTYPE yylval;
2667   int yynerrs;
2668 #ifdef YYLSP_NEEDED
2669   YYLTYPE yylloc;
2670 #endif
2671 #endif
2672
2673   YYSTYPE yyval;                /*  the variable used to return         */
2674                                 /*  semantic values from the action     */
2675                                 /*  routines                            */
2676
2677   int yylen;
2678
2679 #if YYDEBUG != 0
2680   if (yydebug)
2681     fprintf(stderr, "Starting parse\n");
2682 #endif
2683
2684   yystate = 0;
2685   yyerrstatus = 0;
2686   yynerrs = 0;
2687   yychar = YYEMPTY;             /* Cause a token to be read.  */
2688
2689   /* Initialize stack pointers.
2690      Waste one element of value and location stack
2691      so that they stay on the same level as the state stack.
2692      The wasted elements are never initialized.  */
2693
2694   yyssp = yyss - 1;
2695   yyvsp = yyvs;
2696 #ifdef YYLSP_NEEDED
2697   yylsp = yyls;
2698 #endif
2699
2700 /* Push a new state, which is found in  yystate  .  */
2701 /* In all cases, when you get here, the value and location stacks
2702    have just been pushed. so pushing a state here evens the stacks.  */
2703 yynewstate:
2704
2705   *++yyssp = yystate;
2706
2707   if (yyssp >= yyss + yystacksize - 1)
2708     {
2709       /* Give user a chance to reallocate the stack */
2710       /* Use copies of these so that the &'s don't force the real ones into memory. */
2711       YYSTYPE *yyvs1 = yyvs;
2712       short *yyss1 = yyss;
2713 #ifdef YYLSP_NEEDED
2714       YYLTYPE *yyls1 = yyls;
2715 #endif
2716
2717       /* Get the current used size of the three stacks, in elements.  */
2718       int size = yyssp - yyss + 1;
2719
2720 #ifdef yyoverflow
2721       /* Each stack pointer address is followed by the size of
2722          the data in use in that stack, in bytes.  */
2723 #ifdef YYLSP_NEEDED
2724       /* This used to be a conditional around just the two extra args,
2725          but that might be undefined if yyoverflow is a macro.  */
2726       yyoverflow("parser stack overflow",
2727                  &yyss1, size * sizeof (*yyssp),
2728                  &yyvs1, size * sizeof (*yyvsp),
2729                  &yyls1, size * sizeof (*yylsp),
2730                  &yystacksize);
2731 #else
2732       yyoverflow("parser stack overflow",
2733                  &yyss1, size * sizeof (*yyssp),
2734                  &yyvs1, size * sizeof (*yyvsp),
2735                  &yystacksize);
2736 #endif
2737
2738       yyss = yyss1; yyvs = yyvs1;
2739 #ifdef YYLSP_NEEDED
2740       yyls = yyls1;
2741 #endif
2742 #else /* no yyoverflow */
2743       /* Extend the stack our own way.  */
2744       if (yystacksize >= YYMAXDEPTH)
2745         {
2746           yyerror("parser stack overflow");
2747           if (yyfree_stacks)
2748             {
2749               free (yyss);
2750               free (yyvs);
2751 #ifdef YYLSP_NEEDED
2752               free (yyls);
2753 #endif
2754             }
2755           return 2;
2756         }
2757       yystacksize *= 2;
2758       if (yystacksize > YYMAXDEPTH)
2759         yystacksize = YYMAXDEPTH;
2760 #ifndef YYSTACK_USE_ALLOCA
2761       yyfree_stacks = 1;
2762 #endif
2763       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2764       __yy_memcpy ((char *)yyss, (char *)yyss1,
2765                    size * (unsigned int) sizeof (*yyssp));
2766       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2767       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2768                    size * (unsigned int) sizeof (*yyvsp));
2769 #ifdef YYLSP_NEEDED
2770       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2771       __yy_memcpy ((char *)yyls, (char *)yyls1,
2772                    size * (unsigned int) sizeof (*yylsp));
2773 #endif
2774 #endif /* no yyoverflow */
2775
2776       yyssp = yyss + size - 1;
2777       yyvsp = yyvs + size - 1;
2778 #ifdef YYLSP_NEEDED
2779       yylsp = yyls + size - 1;
2780 #endif
2781
2782 #if YYDEBUG != 0
2783       if (yydebug)
2784         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2785 #endif
2786
2787       if (yyssp >= yyss + yystacksize - 1)
2788         YYABORT;
2789     }
2790
2791 #if YYDEBUG != 0
2792   if (yydebug)
2793     fprintf(stderr, "Entering state %d\n", yystate);
2794 #endif
2795
2796   goto yybackup;
2797  yybackup:
2798
2799 /* Do appropriate processing given the current state.  */
2800 /* Read a lookahead token if we need one and don't already have one.  */
2801 /* yyresume: */
2802
2803   /* First try to decide what to do without reference to lookahead token.  */
2804
2805   yyn = yypact[yystate];
2806   if (yyn == YYFLAG)
2807     goto yydefault;
2808
2809   /* Not known => get a lookahead token if don't already have one.  */
2810
2811   /* yychar is either YYEMPTY or YYEOF
2812      or a valid token in external form.  */
2813
2814   if (yychar == YYEMPTY)
2815     {
2816 #if YYDEBUG != 0
2817       if (yydebug)
2818         fprintf(stderr, "Reading a token: ");
2819 #endif
2820       yychar = YYLEX;
2821     }
2822
2823   /* Convert token to internal form (in yychar1) for indexing tables with */
2824
2825   if (yychar <= 0)              /* This means end of input. */
2826     {
2827       yychar1 = 0;
2828       yychar = YYEOF;           /* Don't call YYLEX any more */
2829
2830 #if YYDEBUG != 0
2831       if (yydebug)
2832         fprintf(stderr, "Now at end of input.\n");
2833 #endif
2834     }
2835   else
2836     {
2837       yychar1 = YYTRANSLATE(yychar);
2838
2839 #if YYDEBUG != 0
2840       if (yydebug)
2841         {
2842           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2843           /* Give the individual parser a way to print the precise meaning
2844              of a token, for further debugging info.  */
2845 #ifdef YYPRINT
2846           YYPRINT (stderr, yychar, yylval);
2847 #endif
2848           fprintf (stderr, ")\n");
2849         }
2850 #endif
2851     }
2852
2853   yyn += yychar1;
2854   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2855     goto yydefault;
2856
2857   yyn = yytable[yyn];
2858
2859   /* yyn is what to do for this token type in this state.
2860      Negative => reduce, -yyn is rule number.
2861      Positive => shift, yyn is new state.
2862        New state is final state => don't bother to shift,
2863        just return success.
2864      0, or most negative number => error.  */
2865
2866   if (yyn < 0)
2867     {
2868       if (yyn == YYFLAG)
2869         goto yyerrlab;
2870       yyn = -yyn;
2871       goto yyreduce;
2872     }
2873   else if (yyn == 0)
2874     goto yyerrlab;
2875
2876   if (yyn == YYFINAL)
2877     YYACCEPT;
2878
2879   /* Shift the lookahead token.  */
2880
2881 #if YYDEBUG != 0
2882   if (yydebug)
2883     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2884 #endif
2885
2886   /* Discard the token being shifted unless it is eof.  */
2887   if (yychar != YYEOF)
2888     yychar = YYEMPTY;
2889
2890   *++yyvsp = yylval;
2891 #ifdef YYLSP_NEEDED
2892   *++yylsp = yylloc;
2893 #endif
2894
2895   /* count tokens shifted since error; after three, turn off error status.  */
2896   if (yyerrstatus) yyerrstatus--;
2897
2898   yystate = yyn;
2899   goto yynewstate;
2900
2901 /* Do the default action for the current state.  */
2902 yydefault:
2903
2904   yyn = yydefact[yystate];
2905   if (yyn == 0)
2906     goto yyerrlab;
2907
2908 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
2909 yyreduce:
2910   yylen = yyr2[yyn];
2911   if (yylen > 0)
2912     yyval = yyvsp[1-yylen]; /* implement default value of the action */
2913
2914 #if YYDEBUG != 0
2915   if (yydebug)
2916     {
2917       int i;
2918
2919       fprintf (stderr, "Reducing via rule %d (line %d), ",
2920                yyn, yyrline[yyn]);
2921
2922       /* Print the symbols being reduced, and their result.  */
2923       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2924         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2925       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2926     }
2927 #endif
2928
2929
2930   switch (yyn) {
2931
2932 case 1:
2933 #line 576 "./parse.y"
2934 {;
2935     break;}
2936 case 18:
2937 #line 620 "./parse.y"
2938
2939                   yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2940                   CLASS_LOADED_P (yyval.node) = 1;
2941                 ;
2942     break;}
2943 case 19:
2944 #line 625 "./parse.y"
2945 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2946     break;}
2947 case 20:
2948 #line 627 "./parse.y"
2949 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2950     break;}
2951 case 21:
2952 #line 629 "./parse.y"
2953 {RULE ("']' expected"); RECOVER;;
2954     break;}
2955 case 22:
2956 #line 631 "./parse.y"
2957 {RULE ("']' expected"); RECOVER;;
2958     break;}
2959 case 26:
2960 #line 646 "./parse.y"
2961 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2962     break;}
2963 case 28:
2964 #line 655 "./parse.y"
2965 {yyval.node = NULL;;
2966     break;}
2967 case 36:
2968 #line 667 "./parse.y"
2969 {
2970                   yyval.node = NULL;
2971                 ;
2972     break;}
2973 case 37:
2974 #line 671 "./parse.y"
2975 {
2976                   yyval.node = NULL;
2977                 ;
2978     break;}
2979 case 40:
2980 #line 683 "./parse.y"
2981
2982                   ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node);
2983                   package_list = tree_cons (ctxp->package, NULL, package_list);
2984                 ;
2985     break;}
2986 case 41:
2987 #line 688 "./parse.y"
2988 {yyerror ("Missing name"); RECOVER;;
2989     break;}
2990 case 42:
2991 #line 690 "./parse.y"
2992 {yyerror ("';' expected"); RECOVER;;
2993     break;}
2994 case 45:
2995 #line 700 "./parse.y"
2996 {
2997                   tree name = EXPR_WFL_NODE (yyvsp[-1].node), node, last_name;
2998                   int   i = IDENTIFIER_LENGTH (name)-1;
2999                   const char *last = &IDENTIFIER_POINTER (name)[i];
3000                   while (last != IDENTIFIER_POINTER (name))
3001                     {
3002                       if (last [0] == '.')
3003                         break;
3004                       last--;
3005                     }
3006                   last_name = get_identifier (++last);
3007                   if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
3008                     {
3009                       tree err = find_name_in_single_imports (last_name);
3010                       if (err && err != name)
3011                         parse_error_context
3012                           (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
3013                            IDENTIFIER_POINTER (name), 
3014                            IDENTIFIER_POINTER (err));
3015                       else
3016                         REGISTER_IMPORT (yyvsp[-1].node, last_name)
3017                     }
3018                   else
3019                     REGISTER_IMPORT (yyvsp[-1].node, last_name);
3020                 ;
3021     break;}
3022 case 46:
3023 #line 726 "./parse.y"
3024 {yyerror ("Missing name"); RECOVER;;
3025     break;}
3026 case 47:
3027 #line 728 "./parse.y"
3028 {yyerror ("';' expected"); RECOVER;;
3029     break;}
3030 case 48:
3031 #line 733 "./parse.y"
3032 {
3033                   tree name = EXPR_WFL_NODE (yyvsp[-3].node);
3034                   /* Don't import java.lang.* twice. */
3035                   if (name != java_lang_id)
3036                     {
3037                       tree node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3038                       read_import_dir (yyvsp[-3].node);
3039                       TREE_CHAIN (node) = ctxp->import_demand_list;
3040                       ctxp->import_demand_list = node;
3041                     }
3042                 ;
3043     break;}
3044 case 49:
3045 #line 745 "./parse.y"
3046 {yyerror ("'*' expected"); RECOVER;;
3047     break;}
3048 case 50:
3049 #line 747 "./parse.y"
3050 {yyerror ("';' expected"); RECOVER;;
3051     break;}
3052 case 51:
3053 #line 752 "./parse.y"
3054 { end_class_declaration (0); ;
3055     break;}
3056 case 52:
3057 #line 754 "./parse.y"
3058 { end_class_declaration (0); ;
3059     break;}
3060 case 53:
3061 #line 756 "./parse.y"
3062 { yyval.node = NULL; ;
3063     break;}
3064 case 54:
3065 #line 758 "./parse.y"
3066 {
3067                   YYERROR_NOW;
3068                   yyerror ("Class or interface declaration expected");
3069                 ;
3070     break;}
3071 case 55:
3072 #line 769 "./parse.y"
3073 {
3074                   yyval.value = (1 << yyvsp[0].value);
3075                 ;
3076     break;}
3077 case 56:
3078 #line 773 "./parse.y"
3079 {
3080                   int acc = (1 << yyvsp[0].value);
3081                   if (yyval.value & acc)
3082                     parse_error_context 
3083                       (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
3084                        java_accstring_lookup (acc));
3085                   else
3086                     {
3087                       yyval.value |= acc;
3088                     }
3089                 ;
3090     break;}
3091 case 57:
3092 #line 789 "./parse.y"
3093 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3094     break;}
3095 case 59:
3096 #line 792 "./parse.y"
3097 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3098     break;}
3099 case 61:
3100 #line 795 "./parse.y"
3101 {yyerror ("Missing class name"); RECOVER;;
3102     break;}
3103 case 62:
3104 #line 797 "./parse.y"
3105 {yyerror ("Missing class name"); RECOVER;;
3106     break;}
3107 case 63:
3108 #line 799 "./parse.y"
3109 {
3110                   if (!ctxp->class_err) yyerror ("'{' expected"); 
3111                   DRECOVER(class1);
3112                 ;
3113     break;}
3114 case 64:
3115 #line 804 "./parse.y"
3116 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
3117     break;}
3118 case 65:
3119 #line 808 "./parse.y"
3120 { yyval.node = NULL; ;
3121     break;}
3122 case 66:
3123 #line 810 "./parse.y"
3124 { yyval.node = yyvsp[0].node; ;
3125     break;}
3126 case 67:
3127 #line 812 "./parse.y"
3128 {yyerror ("'{' expected"); ctxp->class_err=1;;
3129     break;}
3130 case 68:
3131 #line 814 "./parse.y"
3132 {yyerror ("Missing super class name"); ctxp->class_err=1;;
3133     break;}
3134 case 69:
3135 #line 818 "./parse.y"
3136 { yyval.node = NULL_TREE; ;
3137     break;}
3138 case 70:
3139 #line 820 "./parse.y"
3140 { yyval.node = yyvsp[0].node; ;
3141     break;}
3142 case 71:
3143 #line 822 "./parse.y"
3144 {
3145                   ctxp->class_err=1;
3146                   yyerror ("Missing interface name"); 
3147                 ;
3148     break;}
3149 case 72:
3150 #line 830 "./parse.y"
3151
3152                   ctxp->interface_number = 1;
3153                   yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3154                 ;
3155     break;}
3156 case 73:
3157 #line 835 "./parse.y"
3158
3159                   ctxp->interface_number++;
3160                   yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3161                 ;
3162     break;}
3163 case 74:
3164 #line 840 "./parse.y"
3165 {yyerror ("Missing interface name"); RECOVER;;
3166     break;}
3167 case 75:
3168 #line 845 "./parse.y"
3169
3170                   /* Store the location of the `}' when doing xrefs */
3171                   if (flag_emit_xref)
3172                     DECL_END_SOURCE_LINE (GET_CPC ()) = 
3173                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3174                   yyval.node = GET_CPC ();
3175                 ;
3176     break;}
3177 case 76:
3178 #line 853 "./parse.y"
3179
3180                   /* Store the location of the `}' when doing xrefs */
3181                   if (flag_emit_xref)
3182                     DECL_END_SOURCE_LINE (GET_CPC ()) = 
3183                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3184                   yyval.node = GET_CPC ();
3185                 ;
3186     break;}
3187 case 82:
3188 #line 872 "./parse.y"
3189 {
3190                   TREE_CHAIN (yyvsp[0].node) = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
3191                   SET_CPC_INSTANCE_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3192                 ;
3193     break;}
3194 case 84:
3195 #line 881 "./parse.y"
3196 { yyval.node = yyvsp[-1].node; ;
3197     break;}
3198 case 86:
3199 #line 884 "./parse.y"
3200 { end_class_declaration (1); ;
3201     break;}
3202 case 87:
3203 #line 886 "./parse.y"
3204 { end_class_declaration (1); ;
3205     break;}
3206 case 88:
3207 #line 892 "./parse.y"
3208 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3209     break;}
3210 case 89:
3211 #line 894 "./parse.y"
3212 {
3213                   check_modifiers 
3214                     ("Illegal modifier `%s' for field declaration",
3215                      yyvsp[-3].value, FIELD_MODIFIERS);
3216                   check_modifiers_consistency (yyvsp[-3].value);
3217                   register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3218                 ;
3219     break;}
3220 case 91:
3221 #line 907 "./parse.y"
3222 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3223     break;}
3224 case 92:
3225 #line 909 "./parse.y"
3226 {yyerror ("Missing term"); RECOVER;;
3227     break;}
3228 case 93:
3229 #line 914 "./parse.y"
3230 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3231     break;}
3232 case 94:
3233 #line 916 "./parse.y"
3234
3235                   if (java_error_count)
3236                     yyvsp[0].node = NULL_TREE;
3237                   yyval.node = build_tree_list 
3238                     (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3239                 ;
3240     break;}
3241 case 95:
3242 #line 923 "./parse.y"
3243 {
3244                   yyerror ("Missing variable initializer");
3245                   yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3246                   RECOVER;
3247                 ;
3248     break;}
3249 case 96:
3250 #line 929 "./parse.y"
3251 {
3252                   yyerror ("';' expected");
3253                   yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3254                   RECOVER;
3255                 ;
3256     break;}
3257 case 98:
3258 #line 939 "./parse.y"
3259 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3260     break;}
3261 case 99:
3262 #line 941 "./parse.y"
3263 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3264     break;}
3265 case 100:
3266 #line 943 "./parse.y"
3267 {yyerror ("']' expected"); DRECOVER(vdi);;
3268     break;}
3269 case 101:
3270 #line 945 "./parse.y"
3271 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3272     break;}
3273 case 104:
3274 #line 956 "./parse.y"
3275 {
3276                   current_function_decl = yyvsp[0].node;
3277                   if (current_function_decl
3278                       && TREE_CODE (current_function_decl) == FUNCTION_DECL)
3279                     source_start_java_method (current_function_decl);
3280                   else
3281                     current_function_decl = NULL_TREE;
3282                 ;
3283     break;}
3284 case 105:
3285 #line 965 "./parse.y"
3286 { finish_method_declaration (yyvsp[0].node); ;
3287     break;}
3288 case 106:
3289 #line 967 "./parse.y"
3290 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3291     break;}
3292 case 107:
3293 #line 972 "./parse.y"
3294 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3295     break;}
3296 case 108:
3297 #line 974 "./parse.y"
3298 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3299     break;}
3300 case 109:
3301 #line 976 "./parse.y"
3302 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3303     break;}
3304 case 110:
3305 #line 978 "./parse.y"
3306 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3307     break;}
3308 case 111:
3309 #line 980 "./parse.y"
3310 {
3311                   yyerror ("Invalid method declaration, method name required");
3312                   RECOVER;
3313                 ;
3314     break;}
3315 case 112:
3316 #line 985 "./parse.y"
3317 {RECOVER;;
3318     break;}
3319 case 113:
3320 #line 987 "./parse.y"
3321 {yyerror ("Identifier expected"); RECOVER;;
3322     break;}
3323 case 114:
3324 #line 989 "./parse.y"
3325 {yyerror ("Identifier expected"); RECOVER;;
3326     break;}
3327 case 115:
3328 #line 991 "./parse.y"
3329 {
3330                   yyerror ("Invalid method declaration, return type required");
3331                   RECOVER;
3332                 ;
3333     break;}
3334 case 116:
3335 #line 999 "./parse.y"
3336
3337                   ctxp->formal_parameter_number = 0;
3338                   yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3339                 ;
3340     break;}
3341 case 117:
3342 #line 1004 "./parse.y"
3343 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3344     break;}
3345 case 118:
3346 #line 1006 "./parse.y"
3347 {
3348                   EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3349                   TREE_PURPOSE (yyvsp[-2].node) = 
3350                     build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3351                   parse_warning_context 
3352                     (wfl_operator, 
3353                      "Discouraged form of returned type specification");
3354                 ;
3355     break;}
3356 case 119:
3357 #line 1015 "./parse.y"
3358 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3359     break;}
3360 case 120:
3361 #line 1017 "./parse.y"
3362 {yyerror ("']' expected"); RECOVER;;
3363     break;}
3364 case 121:
3365 #line 1022 "./parse.y"
3366 {
3367                   ctxp->formal_parameter_number = 1;
3368                 ;
3369     break;}
3370 case 122:
3371 #line 1026 "./parse.y"
3372 {
3373                   ctxp->formal_parameter_number += 1;
3374                   yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3375                 ;
3376     break;}
3377 case 123:
3378 #line 1031 "./parse.y"
3379 { yyerror ("Missing formal parameter term"); RECOVER; ;
3380     break;}
3381 case 124:
3382 #line 1036 "./parse.y"
3383 {
3384                   yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3385                 ;
3386     break;}
3387 case 125:
3388 #line 1040 "./parse.y"
3389
3390                   yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3391                   ARG_FINAL_P (yyval.node) = 1;
3392                 ;
3393     break;}
3394 case 126:
3395 #line 1045 "./parse.y"
3396 {
3397                   yyerror ("Missing identifier"); RECOVER;
3398                   yyval.node = NULL_TREE;
3399                 ;
3400     break;}
3401 case 127:
3402 #line 1050 "./parse.y"
3403 {
3404                   yyerror ("Missing identifier"); RECOVER;
3405                   yyval.node = NULL_TREE;
3406                 ;
3407     break;}
3408 case 128:
3409 #line 1058 "./parse.y"
3410 {
3411                   check_modifiers ("Illegal modifier `%s'. Only `final' was expected here",
3412                                    yyvsp[0].value, ACC_FINAL);
3413                   if (yyvsp[0].value != ACC_FINAL)
3414                     MODIFIER_WFL (FINAL_TK) = build_wfl_node (NULL_TREE);
3415                 ;
3416     break;}
3417 case 129:
3418 #line 1067 "./parse.y"
3419 { yyval.node = NULL_TREE; ;
3420     break;}
3421 case 130:
3422 #line 1069 "./parse.y"
3423 { yyval.node = yyvsp[0].node; ;
3424     break;}
3425 case 131:
3426 #line 1071 "./parse.y"
3427 {yyerror ("Missing class type term"); RECOVER;;
3428     break;}
3429 case 132:
3430 #line 1076 "./parse.y"
3431 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3432     break;}
3433 case 133:
3434 #line 1078 "./parse.y"
3435 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3436     break;}
3437 case 134:
3438 #line 1080 "./parse.y"
3439 {yyerror ("Missing class type term"); RECOVER;;
3440     break;}
3441 case 137:
3442 #line 1087 "./parse.y"
3443 { yyval.node = NULL_TREE; ;
3444     break;}
3445 case 138:
3446 #line 1093 "./parse.y"
3447 {
3448                   TREE_CHAIN (yyvsp[0].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3449                   SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3450                 ;
3451     break;}
3452 case 139:
3453 #line 1098 "./parse.y"
3454 {
3455                   TREE_CHAIN (yyvsp[-1].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3456                   SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[-1].node);
3457                 ;
3458     break;}
3459 case 140:
3460 #line 1106 "./parse.y"
3461 {
3462                   check_modifiers ("Illegal modifier `%s' for static initializer", yyvsp[0].value, ACC_STATIC);
3463                   /* Can't have a static initializer in an innerclass */
3464                   if (yyvsp[0].value | ACC_STATIC &&
3465                       GET_CPC_LIST () && !TOPLEVEL_CLASS_DECL_P (GET_CPC ()))
3466                     parse_error_context 
3467                       (MODIFIER_WFL (STATIC_TK),
3468                        "Can't define static initializer in class `%s'. Static initializer can only be defined in top-level classes",
3469                        IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())));
3470                   SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3471                 ;
3472     break;}
3473 case 141:
3474 #line 1122 "./parse.y"
3475 {
3476                   current_function_decl = yyvsp[0].node;
3477                   source_start_java_method (current_function_decl);
3478                 ;
3479     break;}
3480 case 142:
3481 #line 1127 "./parse.y"
3482 { finish_method_declaration (yyvsp[0].node); ;
3483     break;}
3484 case 143:
3485 #line 1132 "./parse.y"
3486 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3487     break;}
3488 case 144:
3489 #line 1134 "./parse.y"
3490 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3491     break;}
3492 case 145:
3493 #line 1139 "./parse.y"
3494
3495                   ctxp->formal_parameter_number = 0;  
3496                   yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3497                 ;
3498     break;}
3499 case 146:
3500 #line 1144 "./parse.y"
3501 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3502     break;}
3503 case 147:
3504 #line 1152 "./parse.y"
3505
3506                   BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3507                   yyval.node = yyvsp[0].node;
3508                 ;
3509     break;}
3510 case 148:
3511 #line 1157 "./parse.y"
3512 { yyval.node = yyvsp[0].node; ;
3513     break;}
3514 case 149:
3515 #line 1159 "./parse.y"
3516 { yyval.node = yyvsp[0].node; ;
3517     break;}
3518 case 150:
3519 #line 1161 "./parse.y"
3520 { yyval.node = yyvsp[0].node; ;
3521     break;}
3522 case 153:
3523 #line 1171 "./parse.y"
3524
3525                   yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE); 
3526                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3527                   yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3528                 ;
3529     break;}
3530 case 154:
3531 #line 1177 "./parse.y"
3532
3533                   yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node); 
3534                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3535                   yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3536                 ;
3537     break;}
3538 case 155:
3539 #line 1185 "./parse.y"
3540 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3541     break;}
3542 case 156:
3543 #line 1187 "./parse.y"
3544 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3545     break;}
3546 case 157:
3547 #line 1192 "./parse.y"
3548 {
3549                   tree wfl = build_wfl_node (this_identifier_node);
3550                   EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3551                   yyval.node = wfl;
3552                 ;
3553     break;}
3554 case 158:
3555 #line 1198 "./parse.y"
3556 {
3557                   tree wfl = build_wfl_node (super_identifier_node);
3558                   EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3559                   yyval.node = wfl;
3560                 ;
3561     break;}
3562 case 159:
3563 #line 1209 "./parse.y"
3564 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3565     break;}
3566 case 161:
3567 #line 1212 "./parse.y"
3568 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3569     break;}
3570 case 163:
3571 #line 1215 "./parse.y"
3572 { create_interface (0, yyvsp[-1].node, yyvsp[0].node);  ;
3573     break;}
3574 case 165:
3575 #line 1218 "./parse.y"
3576 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3577     break;}
3578 case 167:
3579 #line 1221 "./parse.y"
3580 {yyerror ("'{' expected"); RECOVER;;
3581     break;}
3582 case 168:
3583 #line 1223 "./parse.y"
3584 {yyerror ("'{' expected"); RECOVER;;
3585     break;}
3586 case 169:
3587 #line 1228 "./parse.y"
3588
3589                   ctxp->interface_number = 1;
3590                   yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3591                 ;
3592     break;}
3593 case 170:
3594 #line 1233 "./parse.y"
3595
3596                   ctxp->interface_number++;
3597                   yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3598                 ;
3599     break;}
3600 case 171:
3601 #line 1238 "./parse.y"
3602 {yyerror ("Invalid interface type"); RECOVER;;
3603     break;}
3604 case 172:
3605 #line 1240 "./parse.y"
3606 {yyerror ("Missing term"); RECOVER;;
3607     break;}
3608 case 173:
3609 #line 1245 "./parse.y"
3610 { yyval.node = NULL_TREE; ;
3611     break;}
3612 case 174:
3613 #line 1247 "./parse.y"
3614 { yyval.node = NULL_TREE; ;
3615     break;}
3616 case 179:
3617 #line 1259 "./parse.y"
3618 { end_class_declaration (1); ;
3619     break;}
3620 case 180:
3621 #line 1261 "./parse.y"
3622 { end_class_declaration (1); ;
3623     break;}
3624 case 182:
3625 #line 1270 "./parse.y"
3626
3627                   check_abstract_method_header (yyvsp[-1].node);
3628                   current_function_decl = NULL_TREE; /* FIXME ? */
3629                 ;
3630     break;}
3631 case 183:
3632 #line 1275 "./parse.y"
3633 {yyerror ("';' expected"); RECOVER;;
3634     break;}
3635 case 184:
3636 #line 1281 "./parse.y"
3637 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3638     break;}
3639 case 185:
3640 #line 1283 "./parse.y"
3641 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3642     break;}
3643 case 186:
3644 #line 1285 "./parse.y"
3645 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3646     break;}
3647 case 187:
3648 #line 1290 "./parse.y"
3649
3650                   yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), 
3651                                   yyvsp[0].node, NULL_TREE);
3652                 ;
3653     break;}
3654 case 188:
3655 #line 1295 "./parse.y"
3656 {
3657                   yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3658                 ;
3659     break;}
3660 case 189:
3661 #line 1299 "./parse.y"
3662 {yyerror ("Missing term"); RECOVER;;
3663     break;}
3664 case 190:
3665 #line 1305 "./parse.y"
3666
3667                   /* Store the location of the `}' when doing xrefs */
3668                   if (current_function_decl && flag_emit_xref)
3669                     DECL_END_SOURCE_LINE (current_function_decl) = 
3670                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3671                   yyval.node = empty_stmt_node; 
3672                 ;
3673     break;}
3674 case 191:
3675 #line 1313 "./parse.y"
3676 { yyval.node = yyvsp[0].node; ;
3677     break;}
3678 case 192:
3679 #line 1318 "./parse.y"
3680 { enter_block (); ;
3681     break;}
3682 case 193:
3683 #line 1323 "./parse.y"
3684
3685                   maybe_absorb_scoping_blocks ();
3686                   /* Store the location of the `}' when doing xrefs */
3687                   if (current_function_decl && flag_emit_xref)
3688                     DECL_END_SOURCE_LINE (current_function_decl) = 
3689                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);           
3690                   yyval.node = exit_block ();
3691                   if (!BLOCK_SUBBLOCKS (yyval.node))
3692                     BLOCK_SUBBLOCKS (yyval.node) = empty_stmt_node;
3693                 ;
3694     break;}
3695 case 197:
3696 #line 1343 "./parse.y"
3697 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3698     break;}
3699 case 198:
3700 #line 1345 "./parse.y"
3701
3702                   LOCAL_CLASS_P (TREE_TYPE (GET_CPC ())) = 1;
3703                   end_class_declaration (1);
3704                 ;
3705     break;}
3706 case 200:
3707 #line 1357 "./parse.y"
3708 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3709     break;}
3710 case 201:
3711 #line 1359 "./parse.y"
3712 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3713     break;}
3714 case 207:
3715 #line 1369 "./parse.y"
3716 { yyval.node = exit_block (); ;
3717     break;}
3718 case 212:
3719 #line 1378 "./parse.y"
3720 { yyval.node = exit_block (); ;
3721     break;}
3722 case 224:
3723 #line 1397 "./parse.y"
3724 { yyval.node = empty_stmt_node; ;
3725     break;}
3726 case 225:
3727 #line 1402 "./parse.y"
3728 {
3729                   yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node), 
3730                                             EXPR_WFL_NODE (yyvsp[-1].node));
3731                   pushlevel (2);
3732                   push_labeled_block (yyval.node);
3733                   PUSH_LABELED_BLOCK (yyval.node);
3734                 ;
3735     break;}
3736 case 226:
3737 #line 1413 "./parse.y"
3738 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3739     break;}
3740 case 227:
3741 #line 1415 "./parse.y"
3742 {yyerror ("':' expected"); RECOVER;;
3743     break;}
3744 case 228:
3745 #line 1420 "./parse.y"
3746 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3747     break;}
3748 case 229:
3749 #line 1427 "./parse.y"
3750 {
3751                   /* We have a statement. Generate a WFL around it so
3752                      we can debug it */
3753                   yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3754                   /* We know we have a statement, so set the debug
3755                      info to be eventually generate here. */
3756                   yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3757                 ;
3758     break;}
3759 case 230:
3760 #line 1436 "./parse.y"
3761 {
3762                   if (ctxp->prevent_ese != lineno)
3763                     yyerror ("Invalid expression statement");
3764                   DRECOVER (expr_stmt);
3765                 ;
3766     break;}
3767 case 231:
3768 #line 1442 "./parse.y"
3769 {
3770                   if (ctxp->prevent_ese != lineno)
3771                     yyerror ("Invalid expression statement");
3772                   DRECOVER (expr_stmt);
3773                 ;
3774     break;}
3775 case 232:
3776 #line 1448 "./parse.y"
3777 {
3778                   if (ctxp->prevent_ese != lineno)
3779                     yyerror ("Invalid expression statement");
3780                   DRECOVER (expr_stmt);
3781                 ;
3782     break;}
3783 case 233:
3784 #line 1454 "./parse.y"
3785 {yyerror ("')' expected"); RECOVER;;
3786     break;}
3787 case 234:
3788 #line 1456 "./parse.y"
3789 {
3790                   parse_ctor_invocation_error ();
3791                   RECOVER;
3792                 ;
3793     break;}
3794 case 235:
3795 #line 1461 "./parse.y"
3796 {yyerror ("')' expected"); RECOVER;;
3797     break;}
3798 case 236:
3799 #line 1463 "./parse.y"
3800 {
3801                   parse_ctor_invocation_error ();
3802                   RECOVER;
3803                 ;
3804     break;}
3805 case 237:
3806 #line 1468 "./parse.y"
3807 {yyerror ("'(' expected"); RECOVER;;
3808     break;}
3809 case 238:
3810 #line 1470 "./parse.y"
3811 {yyerror ("')' expected"); RECOVER;;
3812     break;}
3813 case 239:
3814 #line 1472 "./parse.y"
3815 {yyerror ("')' expected"); RECOVER;;
3816     break;}
3817 case 240:
3818 #line 1474 "./parse.y"
3819 {yyerror ("';' expected"); RECOVER;;
3820     break;}
3821 case 241:
3822 #line 1476 "./parse.y"
3823 {yyerror ("';' expected"); RECOVER;;
3824     break;}
3825 case 249:
3826 #line 1491 "./parse.y"
3827
3828                   yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node, 
3829                                                 yyvsp[0].node, NULL_TREE);
3830                 ;
3831     break;}
3832 case 250:
3833 #line 1496 "./parse.y"
3834 {yyerror ("'(' expected"); RECOVER;;
3835     break;}
3836 case 251:
3837 #line 1498 "./parse.y"
3838 {yyerror ("Missing term"); RECOVER;;
3839     break;}
3840 case 252:
3841 #line 1500 "./parse.y"
3842 {yyerror ("')' expected"); RECOVER;;
3843     break;}
3844 case 253:
3845 #line 1505 "./parse.y"
3846 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3847     break;}
3848 case 254:
3849 #line 1510 "./parse.y"
3850 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3851     break;}
3852 case 255:
3853 #line 1515 "./parse.y"
3854 {
3855                   enter_block ();
3856                 ;
3857     break;}
3858 case 256:
3859 #line 1519 "./parse.y"
3860
3861                   /* Make into "proper list" of COMPOUND_EXPRs.
3862                      I.e. make the last statment also have its own
3863                      COMPOUND_EXPR. */
3864                   maybe_absorb_scoping_blocks ();
3865                   TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
3866                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
3867                 ;
3868     break;}
3869 case 257:
3870 #line 1531 "./parse.y"
3871
3872                   yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3873                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3874                 ;
3875     break;}
3876 case 258:
3877 #line 1536 "./parse.y"
3878 {yyerror ("'(' expected"); RECOVER;;
3879     break;}
3880 case 259:
3881 #line 1538 "./parse.y"
3882 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3883     break;}
3884 case 260:
3885 #line 1540 "./parse.y"
3886 {yyerror ("'{' expected"); RECOVER;;
3887     break;}
3888 case 261:
3889 #line 1548 "./parse.y"
3890 { yyval.node = NULL_TREE; ;
3891     break;}
3892 case 262:
3893 #line 1550 "./parse.y"
3894 { yyval.node = NULL_TREE; ;
3895     break;}
3896 case 263:
3897 #line 1552 "./parse.y"
3898 { yyval.node = NULL_TREE; ;
3899     break;}
3900 case 264:
3901 #line 1554 "./parse.y"
3902 { yyval.node = NULL_TREE; ;
3903     break;}
3904 case 270:
3905 #line 1573 "./parse.y"
3906
3907                   tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3908                   EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
3909                   java_method_add_stmt (current_function_decl, lab);
3910                 ;
3911     break;}
3912 case 271:
3913 #line 1579 "./parse.y"
3914
3915                   tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3916                   EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
3917                   java_method_add_stmt (current_function_decl, lab);
3918                 ;
3919     break;}
3920 case 272:
3921 #line 1585 "./parse.y"
3922 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3923     break;}
3924 case 273:
3925 #line 1587 "./parse.y"
3926 {yyerror ("':' expected"); RECOVER;;
3927     break;}
3928 case 274:
3929 #line 1589 "./parse.y"
3930 {yyerror ("':' expected"); RECOVER;;
3931     break;}
3932 case 275:
3933 #line 1594 "./parse.y"
3934
3935                   tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3936                   yyval.node = build_new_loop (body);
3937                 ;
3938     break;}
3939 case 276:
3940 #line 1602 "./parse.y"
3941 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3942     break;}
3943 case 277:
3944 #line 1604 "./parse.y"
3945 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3946     break;}
3947 case 278:
3948 #line 1606 "./parse.y"
3949 {yyerror ("Missing term and ')' expected"); RECOVER;;
3950     break;}
3951 case 279:
3952 #line 1608 "./parse.y"
3953 {yyerror ("')' expected"); RECOVER;;
3954     break;}
3955 case 280:
3956 #line 1613 "./parse.y"
3957 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3958     break;}
3959 case 281:
3960 #line 1618 "./parse.y"
3961
3962                   tree body = build_loop_body (0, NULL_TREE, 1);
3963                   yyval.node = build_new_loop (body);
3964                 ;
3965     break;}
3966 case 282:
3967 #line 1627 "./parse.y"
3968 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3969     break;}
3970 case 283:
3971 #line 1632 "./parse.y"
3972 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3973     break;}
3974 case 284:
3975 #line 1634 "./parse.y"
3976
3977                   yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3978                   /* We have not condition, so we get rid of the EXIT_EXPR */
3979                   LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = 
3980                     empty_stmt_node;
3981                 ;
3982     break;}
3983 case 285:
3984 #line 1641 "./parse.y"
3985 {yyerror ("Invalid control expression"); RECOVER;;
3986     break;}
3987 case 286:
3988 #line 1643 "./parse.y"
3989 {yyerror ("Invalid update expression"); RECOVER;;
3990     break;}
3991 case 287:
3992 #line 1645 "./parse.y"
3993 {yyerror ("Invalid update expression"); RECOVER;;
3994     break;}
3995 case 288:
3996 #line 1650 "./parse.y"
3997 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
3998     break;}
3999 case 289:
4000 #line 1652 "./parse.y"
4001
4002                   yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4003                   /* We have not condition, so we get rid of the EXIT_EXPR */
4004                   LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = 
4005                     empty_stmt_node;
4006                 ;
4007     break;}
4008 case 290:
4009 #line 1662 "./parse.y"
4010
4011                   /* This scope defined for local variable that may be
4012                      defined within the scope of the for loop */
4013                   enter_block (); 
4014                 ;
4015     break;}
4016 case 291:
4017 #line 1668 "./parse.y"
4018 {yyerror ("'(' expected"); DRECOVER(for_1);;
4019     break;}
4020 case 292:
4021 #line 1670 "./parse.y"
4022 {yyerror ("Invalid init statement"); RECOVER;;
4023     break;}
4024 case 293:
4025 #line 1675 "./parse.y"
4026
4027                   /* We now declare the loop body. The loop is
4028                      declared as a for loop. */
4029                   tree body = build_loop_body (0, NULL_TREE, 0);
4030                   yyval.node =  build_new_loop (body);
4031                   FOR_LOOP_P (yyval.node) = 1;
4032                   /* The loop is added to the current block the for
4033                      statement is defined within */
4034                   java_method_add_stmt (current_function_decl, yyval.node);
4035                 ;
4036     break;}
4037 case 294:
4038 #line 1687 "./parse.y"
4039 { yyval.node = empty_stmt_node; ;
4040     break;}
4041 case 295:
4042 #line 1689 "./parse.y"
4043
4044                   /* Init statement recorded within the previously
4045                      defined block scope */
4046                   yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
4047                 ;
4048     break;}
4049 case 296:
4050 #line 1695 "./parse.y"
4051
4052                   /* Local variable are recorded within the previously
4053                      defined block scope */
4054                   yyval.node = NULL_TREE;
4055                 ;
4056     break;}
4057 case 297:
4058 #line 1701 "./parse.y"
4059 {yyerror ("';' expected"); DRECOVER(for_init_1);;
4060     break;}
4061 case 298:
4062 #line 1705 "./parse.y"
4063 {yyval.node = empty_stmt_node;;
4064     break;}
4065 case 299:
4066 #line 1707 "./parse.y"
4067 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
4068     break;}
4069 case 300:
4070 #line 1712 "./parse.y"
4071 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
4072     break;}
4073 case 301:
4074 #line 1714 "./parse.y"
4075 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
4076     break;}
4077 case 302:
4078 #line 1716 "./parse.y"
4079 {yyerror ("Missing term"); RECOVER;;
4080     break;}
4081 case 303:
4082 #line 1721 "./parse.y"
4083 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
4084     break;}
4085 case 304:
4086 #line 1723 "./parse.y"
4087 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
4088     break;}
4089 case 305:
4090 #line 1725 "./parse.y"
4091 {yyerror ("Missing term"); RECOVER;;
4092     break;}
4093 case 306:
4094 #line 1727 "./parse.y"
4095 {yyerror ("';' expected"); RECOVER;;
4096     break;}
4097 case 307:
4098 #line 1732 "./parse.y"
4099 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
4100     break;}
4101 case 308:
4102 #line 1734 "./parse.y"
4103 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
4104     break;}
4105 case 309:
4106 #line 1736 "./parse.y"
4107 {yyerror ("Missing term"); RECOVER;;
4108     break;}
4109 case 310:
4110 #line 1738 "./parse.y"
4111 {yyerror ("';' expected"); RECOVER;;
4112     break;}
4113 case 311:
4114 #line 1743 "./parse.y"
4115 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
4116     break;}
4117 case 312:
4118 #line 1745 "./parse.y"
4119 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
4120     break;}
4121 case 313:
4122 #line 1747 "./parse.y"
4123 {yyerror ("Missing term"); RECOVER;;
4124     break;}
4125 case 314:
4126 #line 1749 "./parse.y"
4127 {yyerror ("';' expected"); RECOVER;;
4128     break;}
4129 case 315:
4130 #line 1754 "./parse.y"
4131
4132                   yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
4133                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
4134                 ;
4135     break;}
4136 case 316:
4137 #line 1759 "./parse.y"
4138 {yyerror ("Missing term"); RECOVER;;
4139     break;}
4140 case 317:
4141 #line 1761 "./parse.y"
4142 {yyerror ("';' expected"); RECOVER;;
4143     break;}
4144 case 318:
4145 #line 1766 "./parse.y"
4146
4147                   yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4148                   EXPR_WFL_LINECOL (yyval.node) = 
4149                     EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
4150                 ;
4151     break;}
4152 case 319:
4153 #line 1772 "./parse.y"
4154 {yyerror ("'{' expected"); RECOVER;;
4155     break;}
4156 case 320:
4157 #line 1774 "./parse.y"
4158 {yyerror ("'(' expected"); RECOVER;;
4159     break;}
4160 case 321:
4161 #line 1776 "./parse.y"
4162 {yyerror ("Missing term"); RECOVER;;
4163     break;}
4164 case 322:
4165 #line 1778 "./parse.y"
4166 {yyerror ("Missing term"); RECOVER;;
4167     break;}
4168 case 323:
4169 #line 1783 "./parse.y"
4170 {
4171                   check_modifiers (
4172              "Illegal modifier `%s'. Only `synchronized' was expected here",
4173                                    yyvsp[0].value, ACC_SYNCHRONIZED);
4174                   if (yyvsp[0].value != ACC_SYNCHRONIZED)
4175                     MODIFIER_WFL (SYNCHRONIZED_TK) = 
4176                       build_wfl_node (NULL_TREE);
4177                 ;
4178     break;}
4179 case 324:
4180 #line 1795 "./parse.y"
4181 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4182     break;}
4183 case 325:
4184 #line 1797 "./parse.y"
4185 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4186     break;}
4187 case 326:
4188 #line 1799 "./parse.y"
4189 { yyval.node = build_try_finally_statement 
4190                     (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
4191                                                        yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
4192                 ;
4193     break;}
4194 case 327:
4195 #line 1804 "./parse.y"
4196 {yyerror ("'{' expected"); DRECOVER (try_statement);;
4197     break;}
4198 case 329:
4199 #line 1810 "./parse.y"
4200
4201                   TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
4202                   yyval.node = yyvsp[0].node;
4203                 ;
4204     break;}
4205 case 330:
4206 #line 1818 "./parse.y"
4207
4208                   java_method_add_stmt (current_function_decl, yyvsp[0].node);
4209                   exit_block ();
4210                   yyval.node = yyvsp[-1].node;
4211                 ;
4212     break;}
4213 case 331:
4214 #line 1826 "./parse.y"
4215
4216                   /* We add a block to define a scope for
4217                      formal_parameter (CCBP). The formal parameter is
4218                      declared initialized by the appropriate function
4219                      call */
4220                   tree ccpb = enter_block ();
4221                   tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location, 
4222                                                 TREE_PURPOSE (yyvsp[-1].node), 
4223                                                 soft_exceptioninfo_call_node);
4224                   declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4225                                            build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
4226                                                             init));
4227                   yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4228                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4229                 ;
4230     break;}
4231 case 332:
4232 #line 1842 "./parse.y"
4233 {yyerror ("'(' expected"); RECOVER; yyval.node = NULL_TREE;;
4234     break;}
4235 case 333:
4236 #line 1844 "./parse.y"
4237 {
4238                   yyerror ("Missing term or ')' expected"); 
4239                   RECOVER; yyval.node = NULL_TREE;
4240                 ;
4241     break;}
4242 case 334:
4243 #line 1849 "./parse.y"
4244 {yyerror ("Missing term"); RECOVER; yyval.node = NULL_TREE;;
4245     break;}
4246 case 335:
4247 #line 1854 "./parse.y"
4248 { yyval.node = yyvsp[0].node; ;
4249     break;}
4250 case 336:
4251 #line 1856 "./parse.y"
4252 {yyerror ("'{' expected"); RECOVER; ;
4253     break;}
4254 case 340:
4255 #line 1868 "./parse.y"
4256 { yyval.node = build_this (yyvsp[0].operator.location); ;
4257     break;}
4258 case 341:
4259 #line 1870 "./parse.y"
4260 {yyval.node = yyvsp[-1].node;;
4261     break;}
4262 case 347:
4263 #line 1880 "./parse.y"
4264
4265                   tree wfl = build_wfl_node (this_identifier_node);
4266                   yyval.node = make_qualified_primary (yyvsp[-2].node, wfl, EXPR_WFL_LINECOL (yyvsp[-2].node));
4267                 ;
4268     break;}
4269 case 348:
4270 #line 1885 "./parse.y"
4271 {yyerror ("')' expected"); RECOVER;;
4272     break;}
4273 case 349:
4274 #line 1887 "./parse.y"
4275 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4276     break;}
4277 case 350:
4278 #line 1889 "./parse.y"
4279 {yyerror ("'class' expected" ); RECOVER;;
4280     break;}
4281 case 351:
4282 #line 1891 "./parse.y"
4283 {yyerror ("'class' expected" ); RECOVER;;
4284     break;}
4285 case 352:
4286 #line 1899 "./parse.y"
4287
4288                   yyval.node = build_java_array_type (yyvsp[-2].node, -1);
4289                   CLASS_LOADED_P (yyval.node) = 1;
4290                 ;
4291     break;}
4292 case 353:
4293 #line 1904 "./parse.y"
4294 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
4295     break;}
4296 case 354:
4297 #line 1914 "./parse.y"
4298 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4299     break;}
4300 case 355:
4301 #line 1916 "./parse.y"
4302 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4303     break;}
4304 case 356:
4305 #line 1918 "./parse.y"
4306 { yyval.node = build_class_ref (yyvsp[-2].node); ;
4307     break;}
4308 case 357:
4309 #line 1920 "./parse.y"
4310 { yyval.node = build_class_ref (void_type_node); ;
4311     break;}
4312 case 358:
4313 #line 1925 "./parse.y"
4314 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4315     break;}
4316 case 359:
4317 #line 1927 "./parse.y"
4318 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4319     break;}
4320 case 361:
4321 #line 1933 "./parse.y"
4322
4323                   tree ctor = build_new_invocation (yyvsp[-2].node, NULL_TREE);
4324                   yyval.node = make_qualified_primary (yyvsp[-3].node, ctor, 
4325                                                EXPR_WFL_LINECOL (yyvsp[-3].node));
4326                 ;
4327     break;}
4328 case 363:
4329 #line 1940 "./parse.y"
4330
4331                   tree ctor = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node);
4332                   yyval.node = make_qualified_primary (yyvsp[-4].node, ctor, 
4333                                                EXPR_WFL_LINECOL (yyvsp[-4].node));
4334                 ;
4335     break;}
4336 case 365:
4337 #line 1947 "./parse.y"
4338 {yyerror ("'(' expected"); DRECOVER(new_1);;
4339     break;}
4340 case 366:
4341 #line 1949 "./parse.y"
4342 {yyerror ("'(' expected"); RECOVER;;
4343     break;}
4344 case 367:
4345 #line 1951 "./parse.y"
4346 {yyerror ("')' or term expected"); RECOVER;;
4347     break;}
4348 case 368:
4349 #line 1953 "./parse.y"
4350 {yyerror ("')' expected"); RECOVER;;
4351     break;}
4352 case 369:
4353 #line 1955 "./parse.y"
4354 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4355     break;}
4356 case 370:
4357 #line 1957 "./parse.y"
4358 {yyerror ("'(' expected"); RECOVER;;
4359     break;}
4360 case 371:
4361 #line 1967 "./parse.y"
4362 { create_anonymous_class (yyvsp[-4].operator.location, yyvsp[-3].node); ;
4363     break;}
4364 case 372:
4365 #line 1969 "./parse.y"
4366
4367                   tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4368                   EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-5].node);
4369
4370                   end_class_declaration (1);
4371
4372                   /* Now we can craft the new expression */
4373                   yyval.node = build_new_invocation (id, yyvsp[-3].node);
4374
4375                   /* Note that we can't possibly be here if
4376                      `class_type' is an interface (in which case the
4377                      anonymous class extends Object and implements
4378                      `class_type', hence its constructor can't have
4379                      arguments.) */
4380
4381                   /* Otherwise, the innerclass must feature a
4382                      constructor matching `argument_list'. Anonymous
4383                      classes are a bit special: it's impossible to
4384                      define constructor for them, hence constructors
4385                      must be generated following the hints provided by
4386                      the `new' expression. Whether a super constructor
4387                      of that nature exists or not is to be verified
4388                      later on in verify_constructor_super. 
4389
4390                      It's during the expansion of a `new' statement
4391                      refering to an anonymous class that a ctor will
4392                      be generated for the anonymous class, with the
4393                      right arguments. */
4394
4395                 ;
4396     break;}
4397 case 373:
4398 #line 2000 "./parse.y"
4399 { create_anonymous_class (yyvsp[-3].operator.location, yyvsp[-2].node); ;
4400     break;}
4401 case 374:
4402 #line 2002 "./parse.y"
4403
4404                   tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4405                   EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-4].node);
4406
4407                   end_class_declaration (1);
4408
4409                   /* Now we can craft the new expression. The
4410                      statement doesn't need to be remember so that a
4411                      constructor can be generated, since its signature
4412                      is already known. */
4413                   yyval.node = build_new_invocation (id, NULL_TREE);
4414                 ;
4415     break;}
4416 case 375:
4417 #line 2018 "./parse.y"
4418 { yyval.node = yyvsp[-2].node; ;
4419     break;}
4420 case 376:
4421 #line 2020 "./parse.y"
4422 { yyval.node = yyvsp[-2].node; ;
4423     break;}
4424 case 377:
4425 #line 2025 "./parse.y"
4426
4427                   yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4428                   ctxp->formal_parameter_number = 1; 
4429                 ;
4430     break;}
4431 case 378:
4432 #line 2030 "./parse.y"
4433 {
4434                   ctxp->formal_parameter_number += 1;
4435                   yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4436                 ;
4437     break;}
4438 case 379:
4439 #line 2035 "./parse.y"
4440 {yyerror ("Missing term"); RECOVER;;
4441     break;}
4442 case 380:
4443 #line 2040 "./parse.y"
4444 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4445     break;}
4446 case 381:
4447 #line 2042 "./parse.y"
4448 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4449     break;}
4450 case 382:
4451 #line 2044 "./parse.y"
4452 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4453     break;}
4454 case 383:
4455 #line 2046 "./parse.y"
4456 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4457     break;}
4458 case 384:
4459 #line 2050 "./parse.y"
4460 {
4461                   char *sig;
4462                   while (CURRENT_OSB (ctxp)--)
4463                     obstack_1grow (&temporary_obstack, '[');
4464                   sig = obstack_finish (&temporary_obstack);
4465                   yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4466                               yyvsp[-2].node, get_identifier (sig), yyvsp[0].node);
4467                 ;
4468     break;}
4469 case 385:
4470 #line 2059 "./parse.y"
4471
4472                   tree type = yyvsp[-2].node;
4473                   while (CURRENT_OSB (ctxp)--)
4474                     type = build_java_array_type (type, -1);
4475                   yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE, 
4476                               build_pointer_type (type), NULL_TREE, yyvsp[0].node);
4477                 ;
4478     break;}
4479 case 386:
4480 #line 2067 "./parse.y"
4481 {yyerror ("'[' expected"); DRECOVER ("]");;
4482     break;}
4483 case 387:
4484 #line 2069 "./parse.y"
4485 {yyerror ("']' expected"); RECOVER;;
4486     break;}
4487 case 388:
4488 #line 2074 "./parse.y"
4489 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4490     break;}
4491 case 389:
4492 #line 2076 "./parse.y"
4493 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4494     break;}
4495 case 390:
4496 #line 2081 "./parse.y"
4497
4498                   EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4499                   yyval.node = yyvsp[-1].node;
4500                 ;
4501     break;}
4502 case 391:
4503 #line 2086 "./parse.y"
4504 {yyerror ("']' expected"); RECOVER;;
4505     break;}
4506 case 392:
4507 #line 2088 "./parse.y"
4508 {
4509                   yyerror ("Missing term");
4510                   yyerror ("']' expected");
4511                   RECOVER;
4512                 ;
4513     break;}
4514 case 393:
4515 #line 2097 "./parse.y"
4516
4517                   int allocate = 0;
4518                   /* If not initialized, allocate memory for the osb
4519                      numbers stack */
4520                   if (!ctxp->osb_limit)
4521                     {
4522                       allocate = ctxp->osb_limit = 32;
4523                       ctxp->osb_depth = -1;
4524                     }
4525                   /* If capacity overflown, reallocate a bigger chunk */
4526                   else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4527                     allocate = ctxp->osb_limit << 1;
4528                   
4529                   if (allocate)
4530                     {
4531                       allocate *= sizeof (int);
4532                       if (ctxp->osb_number)
4533                         ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
4534                                                             allocate);
4535                       else
4536                         ctxp->osb_number = (int *)xmalloc (allocate);
4537                     }
4538                   ctxp->osb_depth++;
4539                   CURRENT_OSB (ctxp) = 1;
4540                 ;
4541     break;}
4542 case 394:
4543 #line 2123 "./parse.y"
4544 { CURRENT_OSB (ctxp)++; ;
4545     break;}
4546 case 395:
4547 #line 2125 "./parse.y"
4548 { yyerror ("']' expected"); RECOVER;;
4549     break;}
4550 case 396:
4551 #line 2130 "./parse.y"
4552 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4553     break;}
4554 case 397:
4555 #line 2134 "./parse.y"
4556 {
4557                   tree super_wfl = 
4558                     build_wfl_node (super_identifier_node);
4559                   EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4560                   yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4561                 ;
4562     break;}
4563 case 398:
4564 #line 2141 "./parse.y"
4565 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4566     break;}
4567 case 399:
4568 #line 2146 "./parse.y"
4569 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4570     break;}
4571 case 400:
4572 #line 2148 "./parse.y"
4573 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4574     break;}
4575 case 401:
4576 #line 2150 "./parse.y"
4577
4578                   if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4579                     yyval.node = build_this_super_qualified_invocation 
4580                       (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4581                   else
4582                     {
4583                       tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4584                       yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4585                     }
4586                 ;
4587     break;}
4588 case 402:
4589 #line 2161 "./parse.y"
4590
4591                   if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4592                     yyval.node = build_this_super_qualified_invocation 
4593                       (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4594                   else
4595                     {
4596                       tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4597                       yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4598                     }
4599                 ;
4600     break;}
4601 case 403:
4602 #line 2172 "./parse.y"
4603
4604                   yyval.node = build_this_super_qualified_invocation 
4605                     (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4606                 ;
4607     break;}
4608 case 404:
4609 #line 2177 "./parse.y"
4610 {
4611                   yyval.node = build_this_super_qualified_invocation 
4612                     (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4613                 ;
4614     break;}
4615 case 405:
4616 #line 2186 "./parse.y"
4617 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4618     break;}
4619 case 406:
4620 #line 2188 "./parse.y"
4621 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4622     break;}
4623 case 407:
4624 #line 2193 "./parse.y"
4625 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4626     break;}
4627 case 408:
4628 #line 2195 "./parse.y"
4629 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4630     break;}
4631 case 409:
4632 #line 2197 "./parse.y"
4633 {
4634                   yyerror ("Missing term and ']' expected");
4635                   DRECOVER(array_access);
4636                 ;
4637     break;}
4638 case 410:
4639 #line 2202 "./parse.y"
4640 {
4641                   yyerror ("']' expected");
4642                   DRECOVER(array_access);
4643                 ;
4644     break;}
4645 case 411:
4646 #line 2207 "./parse.y"
4647 {
4648                   yyerror ("Missing term and ']' expected");
4649                   DRECOVER(array_access);
4650                 ;
4651     break;}
4652 case 412:
4653 #line 2212 "./parse.y"
4654 {
4655                   yyerror ("']' expected");
4656                   DRECOVER(array_access);
4657                 ;
4658     break;}
4659 case 417:
4660 #line 2227 "./parse.y"
4661 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4662     break;}
4663 case 418:
4664 #line 2232 "./parse.y"
4665 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4666     break;}
4667 case 421:
4668 #line 2239 "./parse.y"
4669 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4670     break;}
4671 case 422:
4672 #line 2241 "./parse.y"
4673 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4674     break;}
4675 case 424:
4676 #line 2244 "./parse.y"
4677 {yyerror ("Missing term"); RECOVER;
4678     break;}
4679 case 425:
4680 #line 2246 "./parse.y"
4681 {yyerror ("Missing term"); RECOVER;
4682     break;}
4683 case 426:
4684 #line 2251 "./parse.y"
4685 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4686     break;}
4687 case 427:
4688 #line 2253 "./parse.y"
4689 {yyerror ("Missing term"); RECOVER;
4690     break;}
4691 case 428:
4692 #line 2258 "./parse.y"
4693 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4694     break;}
4695 case 429:
4696 #line 2260 "./parse.y"
4697 {yyerror ("Missing term"); RECOVER;
4698     break;}
4699 case 431:
4700 #line 2266 "./parse.y"
4701 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4702     break;}
4703 case 432:
4704 #line 2268 "./parse.y"
4705 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4706     break;}
4707 case 434:
4708 #line 2271 "./parse.y"
4709 {yyerror ("Missing term"); RECOVER;
4710     break;}
4711 case 435:
4712 #line 2273 "./parse.y"
4713 {yyerror ("Missing term"); RECOVER;
4714     break;}
4715 case 436:
4716 #line 2278 "./parse.y"
4717
4718                   tree type = yyvsp[-3].node;
4719                   while (CURRENT_OSB (ctxp)--)
4720                     type = build_java_array_type (type, -1);
4721                   ctxp->osb_depth--;
4722                   yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node); 
4723                 ;
4724     break;}
4725 case 437:
4726 #line 2286 "./parse.y"
4727 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4728     break;}
4729 case 438:
4730 #line 2288 "./parse.y"
4731 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4732     break;}
4733 case 439:
4734 #line 2290 "./parse.y"
4735
4736                   const char *ptr;
4737                   while (CURRENT_OSB (ctxp)--)
4738                     obstack_1grow (&temporary_obstack, '[');
4739                   ctxp->osb_depth--;
4740                   obstack_grow0 (&temporary_obstack, 
4741                                  IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4742                                  IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4743                   ptr = obstack_finish (&temporary_obstack);
4744                   EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4745                   yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4746                 ;
4747     break;}
4748 case 440:
4749 #line 2303 "./parse.y"
4750 {yyerror ("']' expected, invalid type expression");;
4751     break;}
4752 case 441:
4753 #line 2305 "./parse.y"
4754 {
4755                   if (ctxp->prevent_ese != lineno)
4756                     yyerror ("Invalid type expression"); RECOVER;
4757                   RECOVER;
4758                 ;
4759     break;}
4760 case 442:
4761 #line 2311 "./parse.y"
4762 {yyerror ("Missing term"); RECOVER;;
4763     break;}
4764 case 443:
4765 #line 2313 "./parse.y"
4766 {yyerror ("Missing term"); RECOVER;;
4767     break;}
4768 case 444:
4769 #line 2315 "./parse.y"
4770 {yyerror ("Missing term"); RECOVER;;
4771     break;}
4772 case 446:
4773 #line 2321 "./parse.y"
4774
4775                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), 
4776                                     yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4777                 ;
4778     break;}
4779 case 447:
4780 #line 2326 "./parse.y"
4781 {
4782                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4783                                     yyvsp[-2].node, yyvsp[0].node); 
4784                 ;
4785     break;}
4786 case 448:
4787 #line 2331 "./parse.y"
4788 {
4789                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4790                                     yyvsp[-2].node, yyvsp[0].node); 
4791                 ;
4792     break;}
4793 case 449:
4794 #line 2336 "./parse.y"
4795 {yyerror ("Missing term"); RECOVER;;
4796     break;}
4797 case 450:
4798 #line 2338 "./parse.y"
4799 {yyerror ("Missing term"); RECOVER;;
4800     break;}
4801 case 451:
4802 #line 2340 "./parse.y"
4803 {yyerror ("Missing term"); RECOVER;;
4804     break;}
4805 case 453:
4806 #line 2346 "./parse.y"
4807 {
4808                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4809                                     yyvsp[-2].node, yyvsp[0].node); 
4810                 ;
4811     break;}
4812 case 454:
4813 #line 2351 "./parse.y"
4814 {
4815                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4816                                     yyvsp[-2].node, yyvsp[0].node); 
4817                 ;
4818     break;}
4819 case 455:
4820 #line 2356 "./parse.y"
4821 {yyerror ("Missing term"); RECOVER;;
4822     break;}
4823 case 456:
4824 #line 2358 "./parse.y"
4825 {yyerror ("Missing term"); RECOVER;;
4826     break;}
4827 case 458:
4828 #line 2364 "./parse.y"
4829 {
4830                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4831                                     yyvsp[-2].node, yyvsp[0].node); 
4832                 ;
4833     break;}
4834 case 459:
4835 #line 2369 "./parse.y"
4836 {
4837                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4838                                     yyvsp[-2].node, yyvsp[0].node); 
4839                 ;
4840     break;}
4841 case 460:
4842 #line 2374 "./parse.y"
4843 {
4844                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4845                                     yyvsp[-2].node, yyvsp[0].node); 
4846                 ;
4847     break;}
4848 case 461:
4849 #line 2379 "./parse.y"
4850 {yyerror ("Missing term"); RECOVER;;
4851     break;}
4852 case 462:
4853 #line 2381 "./parse.y"
4854 {yyerror ("Missing term"); RECOVER;;
4855     break;}
4856 case 463:
4857 #line 2383 "./parse.y"
4858 {yyerror ("Missing term"); RECOVER;;
4859     break;}
4860 case 465:
4861 #line 2389 "./parse.y"
4862 {
4863                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4864                                     yyvsp[-2].node, yyvsp[0].node); 
4865                 ;
4866     break;}
4867 case 466:
4868 #line 2394 "./parse.y"
4869 {
4870                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4871                                     yyvsp[-2].node, yyvsp[0].node); 
4872                 ;
4873     break;}
4874 case 467:
4875 #line 2399 "./parse.y"
4876 {
4877                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4878                                     yyvsp[-2].node, yyvsp[0].node); 
4879                 ;
4880     break;}
4881 case 468:
4882 #line 2404 "./parse.y"
4883 {
4884                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4885                                     yyvsp[-2].node, yyvsp[0].node); 
4886                 ;
4887     break;}
4888 case 469:
4889 #line 2409 "./parse.y"
4890 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4891     break;}
4892 case 470:
4893 #line 2411 "./parse.y"
4894 {yyerror ("Missing term"); RECOVER;;
4895     break;}
4896 case 471:
4897 #line 2413 "./parse.y"
4898 {yyerror ("Missing term"); RECOVER;;
4899     break;}
4900 case 472:
4901 #line 2415 "./parse.y"
4902 {yyerror ("Missing term"); RECOVER;;
4903     break;}
4904 case 473:
4905 #line 2417 "./parse.y"
4906 {yyerror ("Missing term"); RECOVER;;
4907     break;}
4908 case 474:
4909 #line 2419 "./parse.y"
4910 {yyerror ("Invalid reference type"); RECOVER;;
4911     break;}
4912 case 476:
4913 #line 2425 "./parse.y"
4914 {
4915                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4916                                     yyvsp[-2].node, yyvsp[0].node); 
4917                 ;
4918     break;}
4919 case 477:
4920 #line 2430 "./parse.y"
4921 {
4922                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4923                                     yyvsp[-2].node, yyvsp[0].node); 
4924                 ;
4925     break;}
4926 case 478:
4927 #line 2435 "./parse.y"
4928 {yyerror ("Missing term"); RECOVER;;
4929     break;}
4930 case 479:
4931 #line 2437 "./parse.y"
4932 {yyerror ("Missing term"); RECOVER;;
4933     break;}
4934 case 481:
4935 #line 2443 "./parse.y"
4936 {
4937                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4938                                     yyvsp[-2].node, yyvsp[0].node); 
4939                 ;
4940     break;}
4941 case 482:
4942 #line 2448 "./parse.y"
4943 {yyerror ("Missing term"); RECOVER;;
4944     break;}
4945 case 484:
4946 #line 2454 "./parse.y"
4947 {
4948                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4949                                     yyvsp[-2].node, yyvsp[0].node); 
4950                 ;
4951     break;}
4952 case 485:
4953 #line 2459 "./parse.y"
4954 {yyerror ("Missing term"); RECOVER;;
4955     break;}
4956 case 487:
4957 #line 2465 "./parse.y"
4958 {
4959                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4960                                     yyvsp[-2].node, yyvsp[0].node); 
4961                 ;
4962     break;}
4963 case 488:
4964 #line 2470 "./parse.y"
4965 {yyerror ("Missing term"); RECOVER;;
4966     break;}
4967 case 490:
4968 #line 2476 "./parse.y"
4969 {
4970                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4971                                     yyvsp[-2].node, yyvsp[0].node); 
4972                 ;
4973     break;}
4974 case 491:
4975 #line 2481 "./parse.y"
4976 {yyerror ("Missing term"); RECOVER;;
4977     break;}
4978 case 493:
4979 #line 2487 "./parse.y"
4980 {
4981                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4982                                     yyvsp[-2].node, yyvsp[0].node); 
4983                 ;
4984     break;}
4985 case 494:
4986 #line 2492 "./parse.y"
4987 {yyerror ("Missing term"); RECOVER;;
4988     break;}
4989 case 496:
4990 #line 2498 "./parse.y"
4991 {
4992                   yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
4993                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4994                 ;
4995     break;}
4996 case 497:
4997 #line 2503 "./parse.y"
4998 {
4999                   YYERROR_NOW;
5000                   yyerror ("Missing term");
5001                   DRECOVER (1);
5002                 ;
5003     break;}
5004 case 498:
5005 #line 2509 "./parse.y"
5006 {yyerror ("Missing term"); DRECOVER (2);;
5007     break;}
5008 case 499:
5009 #line 2511 "./parse.y"
5010 {yyerror ("Missing term"); DRECOVER (3);;
5011     break;}
5012 case 502:
5013 #line 2521 "./parse.y"
5014 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
5015     break;}
5016 case 503:
5017 #line 2523 "./parse.y"
5018 {
5019                   if (ctxp->prevent_ese != lineno)
5020                     yyerror ("Missing term");
5021                   DRECOVER (assign);
5022                 ;
5023     break;}
5024 }
5025    /* the action file gets copied in in place of this dollarsign */
5026 #line 543 "/usr/lib/bison.simple"
5027 \f
5028   yyvsp -= yylen;
5029   yyssp -= yylen;
5030 #ifdef YYLSP_NEEDED
5031   yylsp -= yylen;
5032 #endif
5033
5034 #if YYDEBUG != 0
5035   if (yydebug)
5036     {
5037       short *ssp1 = yyss - 1;
5038       fprintf (stderr, "state stack now");
5039       while (ssp1 != yyssp)
5040         fprintf (stderr, " %d", *++ssp1);
5041       fprintf (stderr, "\n");
5042     }
5043 #endif
5044
5045   *++yyvsp = yyval;
5046
5047 #ifdef YYLSP_NEEDED
5048   yylsp++;
5049   if (yylen == 0)
5050     {
5051       yylsp->first_line = yylloc.first_line;
5052       yylsp->first_column = yylloc.first_column;
5053       yylsp->last_line = (yylsp-1)->last_line;
5054       yylsp->last_column = (yylsp-1)->last_column;
5055       yylsp->text = 0;
5056     }
5057   else
5058     {
5059       yylsp->last_line = (yylsp+yylen-1)->last_line;
5060       yylsp->last_column = (yylsp+yylen-1)->last_column;
5061     }
5062 #endif
5063
5064   /* Now "shift" the result of the reduction.
5065      Determine what state that goes to,
5066      based on the state we popped back to
5067      and the rule number reduced by.  */
5068
5069   yyn = yyr1[yyn];
5070
5071   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5072   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5073     yystate = yytable[yystate];
5074   else
5075     yystate = yydefgoto[yyn - YYNTBASE];
5076
5077   goto yynewstate;
5078
5079 yyerrlab:   /* here on detecting error */
5080
5081   if (! yyerrstatus)
5082     /* If not already recovering from an error, report this error.  */
5083     {
5084       ++yynerrs;
5085
5086 #ifdef YYERROR_VERBOSE
5087       yyn = yypact[yystate];
5088
5089       if (yyn > YYFLAG && yyn < YYLAST)
5090         {
5091           int size = 0;
5092           char *msg;
5093           int x, count;
5094
5095           count = 0;
5096           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
5097           for (x = (yyn < 0 ? -yyn : 0);
5098                x < (sizeof(yytname) / sizeof(char *)); x++)
5099             if (yycheck[x + yyn] == x)
5100               size += strlen(yytname[x]) + 15, count++;
5101           msg = (char *) malloc(size + 15);
5102           if (msg != 0)
5103             {
5104               strcpy(msg, "parse error");
5105
5106               if (count < 5)
5107                 {
5108                   count = 0;
5109                   for (x = (yyn < 0 ? -yyn : 0);
5110                        x < (sizeof(yytname) / sizeof(char *)); x++)
5111                     if (yycheck[x + yyn] == x)
5112                       {
5113                         strcat(msg, count == 0 ? ", expecting `" : " or `");
5114                         strcat(msg, yytname[x]);
5115                         strcat(msg, "'");
5116                         count++;
5117                       }
5118                 }
5119               yyerror(msg);
5120               free(msg);
5121             }
5122           else
5123             yyerror ("parse error; also virtual memory exceeded");
5124         }
5125       else
5126 #endif /* YYERROR_VERBOSE */
5127         yyerror("parse error");
5128     }
5129
5130   goto yyerrlab1;
5131 yyerrlab1:   /* here on error raised explicitly by an action */
5132
5133   if (yyerrstatus == 3)
5134     {
5135       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
5136
5137       /* return failure if at end of input */
5138       if (yychar == YYEOF)
5139         YYABORT;
5140
5141 #if YYDEBUG != 0
5142       if (yydebug)
5143         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5144 #endif
5145
5146       yychar = YYEMPTY;
5147     }
5148
5149   /* Else will try to reuse lookahead token
5150      after shifting the error token.  */
5151
5152   yyerrstatus = 3;              /* Each real token shifted decrements this */
5153
5154   goto yyerrhandle;
5155
5156 yyerrdefault:  /* current state does not do anything special for the error token. */
5157
5158 #if 0
5159   /* This is wrong; only states that explicitly want error tokens
5160      should shift them.  */
5161   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
5162   if (yyn) goto yydefault;
5163 #endif
5164
5165 yyerrpop:   /* pop the current state because it cannot handle the error token */
5166
5167   if (yyssp == yyss) YYABORT;
5168   yyvsp--;
5169   yystate = *--yyssp;
5170 #ifdef YYLSP_NEEDED
5171   yylsp--;
5172 #endif
5173
5174 #if YYDEBUG != 0
5175   if (yydebug)
5176     {
5177       short *ssp1 = yyss - 1;
5178       fprintf (stderr, "Error: state stack now");
5179       while (ssp1 != yyssp)
5180         fprintf (stderr, " %d", *++ssp1);
5181       fprintf (stderr, "\n");
5182     }
5183 #endif
5184
5185 yyerrhandle:
5186
5187   yyn = yypact[yystate];
5188   if (yyn == YYFLAG)
5189     goto yyerrdefault;
5190
5191   yyn += YYTERROR;
5192   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5193     goto yyerrdefault;
5194
5195   yyn = yytable[yyn];
5196   if (yyn < 0)
5197     {
5198       if (yyn == YYFLAG)
5199         goto yyerrpop;
5200       yyn = -yyn;
5201       goto yyreduce;
5202     }
5203   else if (yyn == 0)
5204     goto yyerrpop;
5205
5206   if (yyn == YYFINAL)
5207     YYACCEPT;
5208
5209 #if YYDEBUG != 0
5210   if (yydebug)
5211     fprintf(stderr, "Shifting error token, ");
5212 #endif
5213
5214   *++yyvsp = yylval;
5215 #ifdef YYLSP_NEEDED
5216   *++yylsp = yylloc;
5217 #endif
5218
5219   yystate = yyn;
5220   goto yynewstate;
5221
5222  yyacceptlab:
5223   /* YYACCEPT comes here.  */
5224   if (yyfree_stacks)
5225     {
5226       free (yyss);
5227       free (yyvs);
5228 #ifdef YYLSP_NEEDED
5229       free (yyls);
5230 #endif
5231     }
5232   return 0;
5233
5234  yyabortlab:
5235   /* YYABORT comes here.  */
5236   if (yyfree_stacks)
5237     {
5238       free (yyss);
5239       free (yyvs);
5240 #ifdef YYLSP_NEEDED
5241       free (yyls);
5242 #endif
5243     }
5244   return 1;
5245 }
5246 #line 2549 "./parse.y"
5247
5248 \f
5249
5250 /* This section of the code deal with save/restoring parser contexts.
5251    Add mode documentation here. FIXME */
5252
5253 /* Helper function. Create a new parser context. With
5254    COPY_FROM_PREVIOUS set to a non zero value, content of the previous
5255    context is copied, otherwise, the new context is zeroed. The newly
5256    created context becomes the current one.  */
5257
5258 static void
5259 create_new_parser_context (copy_from_previous)
5260     int copy_from_previous;
5261 {
5262   struct parser_ctxt *new;
5263
5264   new =  (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
5265   if (copy_from_previous)
5266     {
5267       memcpy ((PTR)new, (PTR)ctxp, sizeof (struct parser_ctxt));
5268       new->saved_data_ctx = 1;
5269     }
5270   else
5271     bzero ((PTR) new, sizeof (struct parser_ctxt));
5272       
5273   new->next = ctxp;
5274   ctxp = new;
5275 }
5276
5277 /* Create a new parser context and make it the current one. */
5278
5279 void
5280 java_push_parser_context ()
5281 {
5282   create_new_parser_context (0);
5283   if (ctxp->next)
5284     {
5285       ctxp->incomplete_class = ctxp->next->incomplete_class;
5286       ctxp->gclass_list = ctxp->next->gclass_list;
5287     }
5288 }  
5289
5290 void 
5291 java_pop_parser_context (generate)
5292      int generate;
5293 {
5294   tree current;
5295   struct parser_ctxt *toFree, *next;
5296
5297   if (!ctxp)
5298     return;
5299
5300   toFree = ctxp;
5301   next = ctxp->next;
5302   if (next)
5303     {
5304       next->incomplete_class = ctxp->incomplete_class;
5305       next->gclass_list = ctxp->gclass_list;
5306       lineno = ctxp->lineno;
5307       finput = ctxp->finput;
5308       current_class = ctxp->current_class;
5309     }
5310
5311   /* Set the single import class file flag to 0 for the current list
5312      of imported things */
5313   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5314     IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
5315
5316   /* And restore those of the previous context */
5317   if ((ctxp = next))            /* Assignment is really meant here */
5318     for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5319       IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
5320   
5321   /* If we pushed a context to parse a class intended to be generated,
5322      we keep it so we can remember the class. What we could actually
5323      do is to just update a list of class names.  */
5324   if (generate)
5325     {
5326       toFree->next = ctxp_for_generation;
5327       ctxp_for_generation = toFree;
5328     }
5329   else
5330     free (toFree);
5331 }
5332
5333 /* Create a parser context for the use of saving some global
5334    variables.  */
5335
5336 void
5337 java_parser_context_save_global ()
5338 {
5339   if (!ctxp)
5340     {
5341       java_push_parser_context ();
5342       ctxp->saved_data_ctx = 1;
5343     }
5344
5345   /* If this context already stores data, create a new one suitable
5346      for data storage. */
5347   else if (ctxp->saved_data)
5348     create_new_parser_context (1);
5349
5350   ctxp->finput = finput;
5351   ctxp->lineno = lineno;
5352   ctxp->current_class = current_class;
5353   ctxp->filename = input_filename;
5354   ctxp->current_function_decl = current_function_decl;
5355   ctxp->saved_data = 1;
5356 }
5357
5358 /* Restore some global variables from the previous context. Make the
5359    previous context the current one.  */
5360
5361 void
5362 java_parser_context_restore_global ()
5363 {
5364   finput = ctxp->finput;
5365   lineno = ctxp->lineno;
5366   current_class = ctxp->current_class;
5367   input_filename = ctxp->filename;
5368   current_function_decl = ctxp->current_function_decl;
5369   ctxp->saved_data = 0;
5370   if (ctxp->saved_data_ctx)
5371     java_pop_parser_context (0);
5372 }
5373
5374 /* Suspend vital data for the current class/function being parsed so
5375    that an other class can be parsed. Used to let local/anonymous
5376    classes be parsed.  */
5377
5378 static void
5379 java_parser_context_suspend ()
5380 {
5381   /* This makes debugging through java_debug_context easier */
5382   static const char *name = "<inner buffer context>";
5383
5384   /* Duplicate the previous context, use it to save the globals we're
5385      interested in */
5386   create_new_parser_context (1);
5387   ctxp->current_function_decl = current_function_decl;
5388   ctxp->current_class = current_class;
5389
5390   /* Then create a new context which inherits all data from the
5391      previous one. This will be the new current context  */
5392   create_new_parser_context (1);
5393
5394   /* Help debugging */
5395   ctxp->next->filename = name;
5396 }
5397
5398 /* Resume vital data for the current class/function being parsed so
5399    that an other class can be parsed. Used to let local/anonymous
5400    classes be parsed.  The trick is the data storing file position
5401    informations must be restored to their current value, so parsing
5402    can resume as if no context was ever saved. */
5403
5404 static void
5405 java_parser_context_resume ()
5406 {
5407   struct parser_ctxt *old = ctxp;             /* This one is to be discarded */
5408   struct parser_ctxt *saver = old->next;      /* This one contain saved info */
5409   struct parser_ctxt *restored = saver->next; /* This one is the old current */
5410
5411   /* We need to inherit the list of classes to complete/generate */
5412   restored->incomplete_class = old->incomplete_class;
5413   restored->gclass_list = old->gclass_list;
5414   restored->classd_list = old->classd_list;
5415   restored->class_list = old->class_list;
5416
5417   /* Restore the current class and function from the saver */
5418   current_class = saver->current_class;
5419   current_function_decl = saver->current_function_decl;
5420
5421   /* Retrive the restored context */
5422   ctxp = restored;
5423
5424   /* Re-installed the data for the parsing to carry on */
5425   bcopy (&old->marker_begining, &ctxp->marker_begining,
5426          (size_t)(&ctxp->marker_end - &ctxp->marker_begining));
5427
5428   /* Buffer context can now be discarded */
5429   free (saver);
5430   free (old);
5431 }
5432
5433 /* Add a new anchor node to which all statement(s) initializing static
5434    and non static initialized upon declaration field(s) will be
5435    linked.  */
5436
5437 static void
5438 java_parser_context_push_initialized_field ()
5439 {
5440   tree node;
5441
5442   node = build_tree_list (NULL_TREE, NULL_TREE);
5443   TREE_CHAIN (node) = CPC_STATIC_INITIALIZER_LIST (ctxp);
5444   CPC_STATIC_INITIALIZER_LIST (ctxp) = node;
5445
5446   node = build_tree_list (NULL_TREE, NULL_TREE);
5447   TREE_CHAIN (node) = CPC_INITIALIZER_LIST (ctxp);
5448   CPC_INITIALIZER_LIST (ctxp) = node;
5449
5450   node = build_tree_list (NULL_TREE, NULL_TREE);
5451   TREE_CHAIN (node) = CPC_INSTANCE_INITIALIZER_LIST (ctxp);
5452   CPC_INSTANCE_INITIALIZER_LIST (ctxp) = node;
5453 }
5454
5455 /* Pop the lists of initialized field. If this lists aren't empty,
5456    remember them so we can use it to create and populate the $finit$
5457    or <clinit> functions. */
5458
5459 static void
5460 java_parser_context_pop_initialized_field ()
5461 {
5462   tree stmts;
5463   tree class_type = TREE_TYPE (GET_CPC ());
5464
5465   if (CPC_INITIALIZER_LIST (ctxp))
5466     {
5467       stmts = CPC_INITIALIZER_STMT (ctxp);
5468       CPC_INITIALIZER_LIST (ctxp) = TREE_CHAIN (CPC_INITIALIZER_LIST (ctxp));
5469       if (stmts && !java_error_count)
5470         TYPE_FINIT_STMT_LIST (class_type) = reorder_static_initialized (stmts);
5471     }
5472
5473   if (CPC_STATIC_INITIALIZER_LIST (ctxp))
5474     {
5475       stmts = CPC_STATIC_INITIALIZER_STMT (ctxp);
5476       CPC_STATIC_INITIALIZER_LIST (ctxp) = 
5477         TREE_CHAIN (CPC_STATIC_INITIALIZER_LIST (ctxp));
5478       /* Keep initialization in order to enforce 8.5 */
5479       if (stmts && !java_error_count)
5480         TYPE_CLINIT_STMT_LIST (class_type) = nreverse (stmts);
5481     }
5482
5483   /* JDK 1.1 instance initializers */
5484   if (CPC_INSTANCE_INITIALIZER_LIST (ctxp))
5485     {
5486       stmts = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
5487       CPC_INSTANCE_INITIALIZER_LIST (ctxp) = 
5488         TREE_CHAIN (CPC_INSTANCE_INITIALIZER_LIST (ctxp));
5489       if (stmts && !java_error_count)
5490         TYPE_II_STMT_LIST (class_type) = nreverse (stmts);
5491     }
5492 }
5493
5494 static tree
5495 reorder_static_initialized (list)
5496      tree list;
5497 {
5498   /* We have to keep things in order. The alias initializer have to
5499      come first, then the initialized regular field, in reverse to
5500      keep them in lexical order. */
5501   tree marker, previous = NULL_TREE;
5502   for (marker = list; marker; previous = marker, marker = TREE_CHAIN (marker))
5503     if (TREE_CODE (marker) == TREE_LIST 
5504         && !TREE_VALUE (marker) && !TREE_PURPOSE (marker))
5505       break;
5506   
5507   /* No static initialized, the list is fine as is */
5508   if (!previous)
5509     list = TREE_CHAIN (marker);
5510
5511   /* No marker? reverse the whole list */
5512   else if (!marker)
5513     list = nreverse (list);
5514
5515   /* Otherwise, reverse what's after the marker and the new reordered
5516      sublist will replace the marker. */
5517   else
5518     {
5519       TREE_CHAIN (previous) = NULL_TREE;
5520       list = nreverse (list);
5521       list = chainon (TREE_CHAIN (marker), list);
5522     }
5523   return list;
5524 }
5525
5526 /* Helper functions to dump the parser context stack.  */
5527
5528 #define TAB_CONTEXT(C) \
5529   {int i; for (i = 0; i < (C); i++) fputc (' ', stderr);}
5530
5531 static void
5532 java_debug_context_do (tab)
5533      int tab;
5534 {
5535   struct parser_ctxt *copy = ctxp;
5536   while (copy)
5537     {
5538       TAB_CONTEXT (tab);
5539       fprintf (stderr, "ctxt: 0x%0lX\n", (unsigned long)copy);
5540       TAB_CONTEXT (tab);
5541       fprintf (stderr, "filename: %s\n", copy->filename);
5542       TAB_CONTEXT (tab);
5543       fprintf (stderr, "lineno: %d\n", copy->lineno);
5544       TAB_CONTEXT (tab);
5545       fprintf (stderr, "package: %s\n",
5546                (copy->package ? 
5547                 IDENTIFIER_POINTER (copy->package) : "<none>"));
5548       TAB_CONTEXT (tab);
5549       fprintf (stderr, "context for saving: %d\n", copy->saved_data_ctx);
5550       TAB_CONTEXT (tab);
5551       fprintf (stderr, "saved data: %d\n", copy->saved_data);
5552       copy = copy->next;
5553       tab += 2;
5554     }
5555 }
5556
5557 /* Dump the stacked up parser contexts. Intended to be called from a
5558    debugger.  */
5559
5560 void
5561 java_debug_context ()
5562 {
5563   java_debug_context_do (0);
5564 }
5565
5566 \f
5567
5568 /* Flag for the error report routine to issue the error the first time
5569    it's called (overriding the default behavior which is to drop the
5570    first invocation and honor the second one, taking advantage of a
5571    richer context.  */
5572 static int force_error = 0;
5573
5574 /* Reporting an constructor invocation error.  */
5575 static void
5576 parse_ctor_invocation_error ()
5577 {
5578   if (DECL_CONSTRUCTOR_P (current_function_decl))
5579     yyerror ("Constructor invocation must be first thing in a constructor"); 
5580   else
5581     yyerror ("Only constructors can invoke constructors");
5582 }
5583
5584 /* Reporting JDK1.1 features not implemented.  */
5585
5586 static tree
5587 parse_jdk1_1_error (msg)
5588     const char *msg;
5589 {
5590   sorry (": `%s' JDK1.1(TM) feature", msg);
5591   java_error_count++;
5592   return empty_stmt_node;
5593 }
5594
5595 static int do_warning = 0;
5596
5597 void
5598 yyerror (msg)
5599      const char *msg;
5600 {
5601   static java_lc elc;
5602   static int  prev_lineno;
5603   static const char *prev_msg;
5604
5605   int save_lineno;
5606   char *remainder, *code_from_source;
5607   extern struct obstack temporary_obstack;
5608   
5609   if (!force_error && prev_lineno == lineno)
5610     return;
5611
5612   /* Save current error location but report latter, when the context is
5613      richer.  */
5614   if (ctxp->java_error_flag == 0)
5615     {
5616       ctxp->java_error_flag = 1;
5617       elc = ctxp->elc;
5618       /* Do something to use the previous line if we're reaching the
5619          end of the file... */
5620 #ifdef VERBOSE_SKELETON
5621       printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5622 #endif
5623       return;
5624     }
5625
5626   /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5627   if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5628     return;
5629
5630   ctxp->java_error_flag = 0;
5631   if (do_warning)
5632     java_warning_count++;
5633   else
5634     java_error_count++;
5635   
5636   if (elc.col == 0 && msg && msg[1] == ';')
5637     {
5638       elc.col  = ctxp->p_line->char_col-1;
5639       elc.line = ctxp->p_line->lineno;
5640     }
5641
5642   save_lineno = lineno;
5643   prev_lineno = lineno = elc.line;
5644   prev_msg = msg;
5645
5646   code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5647   obstack_grow0 (&temporary_obstack, 
5648                  code_from_source, strlen (code_from_source));
5649   remainder = obstack_finish (&temporary_obstack);
5650   if (do_warning)
5651     warning ("%s.\n%s", msg, remainder);
5652   else
5653     error ("%s.\n%s", msg, remainder);
5654
5655   /* This allow us to cheaply avoid an extra 'Invalid expression
5656      statement' error report when errors have been already reported on
5657      the same line. This occurs when we report an error but don't have
5658      a synchronization point other than ';', which
5659      expression_statement is the only one to take care of.  */
5660   ctxp->prevent_ese = lineno = save_lineno;
5661 }
5662
5663 static void
5664 issue_warning_error_from_context (cl, msg, ap)
5665      tree cl;
5666      const char *msg;
5667      va_list ap;
5668 {
5669   const char *saved, *saved_input_filename;
5670   char buffer [4096];
5671   vsprintf (buffer, msg, ap);
5672   force_error = 1;
5673
5674   ctxp->elc.line = EXPR_WFL_LINENO (cl);
5675   ctxp->elc.col  = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 : 
5676                     (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5677
5678   /* We have a CL, that's a good reason for using it if it contains data */
5679   saved = ctxp->filename;
5680   if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5681     ctxp->filename = EXPR_WFL_FILENAME (cl);
5682   saved_input_filename = input_filename;
5683   input_filename = ctxp->filename;
5684   java_error (NULL);
5685   java_error (buffer);
5686   ctxp->filename = saved;
5687   input_filename = saved_input_filename;
5688   force_error = 0;
5689 }
5690
5691 /* Issue an error message at a current source line CL */
5692
5693 void
5694 parse_error_context VPARAMS ((tree cl, const char *msg, ...))
5695 {
5696 #ifndef ANSI_PROTOTYPES
5697   tree cl;
5698   const char *msg;
5699 #endif
5700   va_list ap;
5701
5702   VA_START (ap, msg);
5703 #ifndef ANSI_PROTOTYPES
5704   cl = va_arg (ap, tree);
5705   msg = va_arg (ap, const char *);
5706 #endif
5707   issue_warning_error_from_context (cl, msg, ap);
5708   va_end (ap);
5709 }
5710
5711 /* Issue a warning at a current source line CL */
5712
5713 static void
5714 parse_warning_context VPARAMS ((tree cl, const char *msg, ...))
5715 {
5716 #ifndef ANSI_PROTOTYPES
5717   tree cl;
5718   const char *msg;
5719 #endif
5720   va_list ap;
5721
5722   VA_START (ap, msg);
5723 #ifndef ANSI_PROTOTYPES
5724   cl = va_arg (ap, tree);
5725   msg = va_arg (ap, const char *);
5726 #endif
5727
5728   force_error = do_warning = 1;
5729   issue_warning_error_from_context (cl, msg, ap);
5730   do_warning = force_error = 0;
5731   va_end (ap);
5732 }
5733
5734 static tree
5735 find_expr_with_wfl (node)
5736      tree node;
5737 {
5738   while (node)
5739     {
5740       char code;
5741       tree to_return;
5742
5743       switch (TREE_CODE (node))
5744         {
5745         case BLOCK:
5746           node = BLOCK_EXPR_BODY (node);
5747           continue;
5748
5749         case COMPOUND_EXPR:
5750           to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
5751           if (to_return)
5752             return to_return;
5753           node = TREE_OPERAND (node, 1);
5754           continue;
5755
5756         case LOOP_EXPR:
5757           node = TREE_OPERAND (node, 0);
5758           continue;
5759           
5760         case LABELED_BLOCK_EXPR:
5761           node = TREE_OPERAND (node, 1);
5762           continue;
5763
5764         default:
5765           code = TREE_CODE_CLASS (TREE_CODE (node));
5766           if (((code == '1') || (code == '2') || (code == 'e'))
5767               && EXPR_WFL_LINECOL (node))
5768             return node;
5769           return NULL_TREE;
5770         }
5771     }
5772   return NULL_TREE;
5773 }
5774
5775 /* Issue a missing return statement error. Uses METHOD to figure the
5776    last line of the method the error occurs in.  */
5777
5778 static void
5779 missing_return_error (method)
5780      tree method;
5781 {
5782   EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
5783   parse_error_context (wfl_operator, "Missing return statement");
5784 }
5785
5786 /* Issue an unreachable statement error. From NODE, find the next
5787    statement to report appropriately.  */
5788 static void
5789 unreachable_stmt_error (node)
5790      tree node;
5791 {
5792   /* Browse node to find the next expression node that has a WFL. Use
5793      the location to report the error */
5794   if (TREE_CODE (node) == COMPOUND_EXPR)
5795     node = find_expr_with_wfl (TREE_OPERAND (node, 1));
5796   else
5797     node = find_expr_with_wfl (node);
5798
5799   if (node)
5800     {
5801       EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
5802       parse_error_context (wfl_operator, "Unreachable statement");
5803     }
5804   else
5805     fatal ("Can't get valid statement - unreachable_stmt_error");
5806 }
5807
5808 int
5809 java_report_errors ()
5810 {
5811   if (java_error_count)
5812     fprintf (stderr, "%d error%s", 
5813              java_error_count, (java_error_count == 1 ? "" : "s"));
5814   if (java_warning_count)
5815     fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
5816              java_warning_count, (java_warning_count == 1 ? "" : "s"));
5817   if (java_error_count || java_warning_count)
5818     putc ('\n', stderr);
5819   return java_error_count;
5820 }
5821
5822 static char *
5823 java_accstring_lookup (flags)
5824      int flags;
5825 {
5826   static char buffer [80];
5827 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
5828
5829   /* Access modifier looked-up first for easier report on forbidden
5830      access. */
5831   if (flags & ACC_PUBLIC) COPY_RETURN ("public");
5832   if (flags & ACC_PRIVATE) COPY_RETURN ("private");
5833   if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
5834   if (flags & ACC_STATIC) COPY_RETURN ("static");
5835   if (flags & ACC_FINAL) COPY_RETURN ("final");
5836   if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
5837   if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
5838   if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
5839   if (flags & ACC_NATIVE) COPY_RETURN ("native");
5840   if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
5841   if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
5842
5843   buffer [0] = '\0';
5844   return buffer;
5845 #undef COPY_RETURN
5846 }
5847
5848 /* Issuing error messages upon redefinition of classes, interfaces or
5849    variables. */
5850
5851 static void
5852 classitf_redefinition_error (context, id, decl, cl)
5853      const char *context;
5854      tree id, decl, cl;
5855 {
5856   parse_error_context (cl, "%s `%s' already defined in %s:%d", 
5857                        context, IDENTIFIER_POINTER (id), 
5858                        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5859   /* Here we should point out where its redefined. It's a unicode. FIXME */
5860 }
5861
5862 static void
5863 variable_redefinition_error (context, name, type, line)
5864      tree context, name, type;
5865      int line;
5866 {
5867   const char *type_name;
5868
5869   /* Figure a proper name for type. We might haven't resolved it */
5870   if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
5871     type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
5872   else
5873     type_name = lang_printable_name (type, 0);
5874
5875   parse_error_context (context,
5876                        "Variable `%s' is already defined in this method and was declared `%s %s' at line %d", 
5877                        IDENTIFIER_POINTER (name),
5878                        type_name, IDENTIFIER_POINTER (name), line);
5879 }
5880
5881 static tree
5882 build_array_from_name (type, type_wfl, name, ret_name)
5883      tree type, type_wfl, name, *ret_name;
5884 {
5885   int more_dims = 0;
5886   const char *string;
5887
5888   /* Eventually get more dims */
5889   string = IDENTIFIER_POINTER (name);
5890   while (string [more_dims] == '[')
5891     more_dims++;
5892   
5893   /* If we have, then craft a new type for this variable */
5894   if (more_dims)
5895     {
5896       name = get_identifier (&string [more_dims]);
5897
5898       /* If we have a pointer, use its type */
5899       if (TREE_CODE (type) == POINTER_TYPE)
5900         type = TREE_TYPE (type);
5901
5902       /* Building the first dimension of a primitive type uses this
5903          function */
5904       if (JPRIMITIVE_TYPE_P (type))
5905         {
5906           type = build_java_array_type (type, -1);
5907           CLASS_LOADED_P (type) = 1;
5908           more_dims--;
5909         }
5910       /* Otherwise, if we have a WFL for this type, use it (the type
5911          is already an array on an unresolved type, and we just keep
5912          on adding dimensions) */
5913       else if (type_wfl)
5914         type = type_wfl;
5915
5916       /* Add all the dimensions */
5917       while (more_dims--)
5918         type = build_unresolved_array_type (type);
5919
5920       /* The type may have been incomplete in the first place */
5921       if (type_wfl)
5922         type = obtain_incomplete_type (type);
5923     }
5924
5925   if (ret_name)
5926     *ret_name = name;
5927   return type;
5928 }
5929
5930 /* Build something that the type identifier resolver will identify as
5931    being an array to an unresolved type. TYPE_WFL is a WFL on a
5932    identifier. */
5933
5934 static tree
5935 build_unresolved_array_type (type_or_wfl)
5936      tree type_or_wfl;
5937 {
5938   const char *ptr;
5939
5940   /* TYPE_OR_WFL might be an array on a resolved type. In this case,
5941      just create a array type */
5942   if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5943     {
5944       tree type = build_java_array_type (type_or_wfl, -1);
5945       CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5946       return type;
5947     }
5948
5949   obstack_1grow (&temporary_obstack, '[');
5950   obstack_grow0 (&temporary_obstack,
5951                  IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5952                  IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5953   ptr = obstack_finish (&temporary_obstack);
5954   return build_expr_wfl (get_identifier (ptr),
5955                          EXPR_WFL_FILENAME (type_or_wfl),
5956                          EXPR_WFL_LINENO (type_or_wfl),
5957                          EXPR_WFL_COLNO (type_or_wfl));
5958 }
5959
5960 static void
5961 parser_add_interface (class_decl, interface_decl, wfl)
5962      tree class_decl, interface_decl, wfl;
5963 {
5964   if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5965     parse_error_context (wfl, "Interface `%s' repeated",
5966                          IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5967 }
5968
5969 /* Bulk of common class/interface checks. Return 1 if an error was
5970    encountered. TAG is 0 for a class, 1 for an interface.  */
5971
5972 static int
5973 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5974      int is_interface, flags;
5975      tree raw_name, qualified_name, decl, cl;
5976 {
5977   tree node;
5978   int sca = 0;                  /* Static class allowed */
5979   int icaf = 0;                 /* Inner class allowed flags */
5980   int uaaf = CLASS_MODIFIERS;   /* Usually allowed access flags */
5981
5982   if (!quiet_flag)
5983     fprintf (stderr, " %s%s %s", 
5984              (CPC_INNER_P () ? "inner" : ""),
5985              (is_interface ? "interface" : "class"), 
5986              IDENTIFIER_POINTER (qualified_name));
5987
5988   /* Scope of an interface/class type name:
5989        - Can't be imported by a single type import
5990        - Can't already exists in the package */
5991   if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5992       && (node = find_name_in_single_imports (raw_name)))
5993     {
5994       parse_error_context 
5995         (cl, "%s name `%s' clashes with imported type `%s'",
5996          (is_interface ? "Interface" : "Class"),
5997          IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
5998       return 1;
5999     }
6000   if (decl && CLASS_COMPLETE_P (decl))
6001     {
6002       classitf_redefinition_error ((is_interface ? "Interface" : "Class"), 
6003                                    qualified_name, decl, cl);
6004       return 1;
6005     }
6006
6007   if (check_inner_class_redefinition (raw_name, cl))
6008     return 1;
6009
6010   /* If public, file name should match class/interface name, except
6011      when dealing with an inner class */
6012   if (!CPC_INNER_P () && (flags & ACC_PUBLIC ))
6013     {
6014       const char *f;
6015
6016       /* Contains OS dependent assumption on path separator. FIXME */
6017       for (f = &input_filename [strlen (input_filename)]; 
6018            f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR;
6019            f--)
6020         ;
6021       if (f[0] == '/' || f[0] == DIR_SEPARATOR)
6022         f++;
6023       if (strncmp (IDENTIFIER_POINTER (raw_name), 
6024                    f , IDENTIFIER_LENGTH (raw_name)) ||
6025           f [IDENTIFIER_LENGTH (raw_name)] != '.')
6026         parse_error_context
6027           (cl, "Public %s `%s' must be defined in a file called `%s.java'", 
6028                              (is_interface ? "interface" : "class"),
6029                              IDENTIFIER_POINTER (qualified_name),
6030                              IDENTIFIER_POINTER (raw_name));
6031     }
6032
6033   /* Static classes can be declared only in top level classes. Note:
6034      once static, a inner class is a top level class. */
6035   if (flags & ACC_STATIC)
6036     {
6037       /* Catch the specific error of declaring an class inner class
6038          with no toplevel enclosing class. Prevent check_modifiers from
6039          complaining a second time */
6040       if (CPC_INNER_P () && !TOPLEVEL_CLASS_DECL_P (GET_CPC()))
6041         {
6042           parse_error_context (cl, "Inner class `%s' can't be static. Static classes can only occur in interfaces and top-level classes", 
6043                                IDENTIFIER_POINTER (qualified_name));
6044           sca = ACC_STATIC;
6045         }
6046       /* Else, in the context of a top-level class declaration, let
6047          `check_modifiers' do its job, otherwise, give it a go */
6048       else
6049         sca = (GET_CPC_LIST () ? ACC_STATIC : 0);
6050     }
6051
6052   /* Inner classes can be declared private or protected
6053      within their enclosing classes. */
6054   if (CPC_INNER_P ())
6055     {
6056       /* A class which is local to a block can't be public, private,
6057          protected or static. But it is created final, so allow this
6058          one. */
6059       if (current_function_decl)
6060         icaf = sca = uaaf = ACC_FINAL;
6061       else
6062         {
6063           check_modifiers_consistency (flags);
6064           icaf = ACC_PRIVATE|ACC_PROTECTED;
6065         }
6066     }
6067
6068   if (is_interface) 
6069     {
6070       if (CPC_INNER_P ())
6071         uaaf = INTERFACE_INNER_MODIFIERS;
6072       else
6073         uaaf = INTERFACE_MODIFIERS;
6074       
6075       check_modifiers ("Illegal modifier `%s' for interface declaration", 
6076                        flags, uaaf);
6077     }
6078   else
6079     check_modifiers ((current_function_decl ?
6080                       "Illegal modifier `%s' for local class declaration" :
6081                       "Illegal modifier `%s' for class declaration"),
6082                      flags, uaaf|sca|icaf);
6083   return 0;
6084 }
6085
6086 static void
6087 make_nested_class_name (cpc_list)
6088      tree cpc_list;
6089 {
6090   tree name;
6091
6092   if (!cpc_list)
6093     return;
6094   else
6095     make_nested_class_name (TREE_CHAIN (cpc_list));
6096
6097   /* Pick the qualified name when dealing with the first upmost
6098      enclosing class */
6099   name = (TREE_CHAIN (cpc_list) ? 
6100           TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
6101   obstack_grow (&temporary_obstack,
6102                 IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
6103   /* Why is NO_DOLLAR_IN_LABEL defined? */
6104 #if 0
6105 #ifdef NO_DOLLAR_IN_LABEL
6106   fatal ("make_nested_class_name: Can't use '$' as a separator "
6107          "for inner classes");
6108 #endif
6109 #endif
6110   obstack_1grow (&temporary_obstack, '$');
6111 }
6112
6113 /* Can't redefine a class already defined in an earlier scope. */
6114
6115 static int
6116 check_inner_class_redefinition (raw_name, cl)
6117      tree raw_name, cl;
6118 {
6119   tree scope_list;
6120
6121   for (scope_list = GET_CPC_LIST (); scope_list; 
6122        scope_list = GET_NEXT_ENCLOSING_CPC (scope_list))
6123     if (raw_name == GET_CPC_UN_NODE (scope_list))
6124       {
6125         parse_error_context 
6126           (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",
6127            IDENTIFIER_POINTER (raw_name));
6128         return 1;
6129       }
6130   return 0;
6131 }
6132
6133 static tree
6134 find_as_inner_class (enclosing, name, cl)
6135      tree enclosing, name, cl;
6136 {
6137   tree qual, to_return;
6138   if (!enclosing)
6139     return NULL_TREE;
6140
6141   name = TYPE_NAME (name);
6142
6143   /* First search: within the scope of `enclosing', search for name */
6144   if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6145     qual = EXPR_WFL_QUALIFICATION (cl);
6146   else if (cl)
6147     qual = build_tree_list (cl, NULL_TREE);
6148   else
6149     qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6150   
6151   if ((to_return = find_as_inner_class_do (qual, enclosing)))
6152     return to_return;
6153
6154   /* We're dealing with a qualified name. Try to resolve thing until
6155      we get something that is an enclosing class. */
6156   if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6157     {
6158       tree acc = NULL_TREE, decl = NULL_TREE, ptr;
6159
6160       for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl; 
6161           qual = TREE_CHAIN (qual))
6162         {
6163           acc = merge_qualified_name (acc, 
6164                                       EXPR_WFL_NODE (TREE_PURPOSE (qual)));
6165           BUILD_PTR_FROM_NAME (ptr, acc);
6166           decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
6167         }
6168
6169       /* A NULL qual and a decl means that the search ended
6170          successfully?!? We have to do something then. FIXME */
6171       
6172       if (decl)
6173         enclosing = decl;
6174       else
6175         qual = EXPR_WFL_QUALIFICATION (cl);
6176     }
6177   /* Otherwise, create a qual for the other part of the resolution. */
6178   else
6179     qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6180
6181   return find_as_inner_class_do (qual, enclosing);
6182 }
6183
6184 /* We go inside the list of sub classes and try to find a way
6185    through. */
6186
6187 static tree
6188 find_as_inner_class_do (qual, enclosing)
6189      tree qual, enclosing;
6190 {
6191   if (!qual)
6192     return NULL_TREE;
6193
6194   for (; qual && enclosing; qual = TREE_CHAIN (qual))
6195     {
6196       tree name_to_match = EXPR_WFL_NODE (TREE_PURPOSE (qual));
6197       tree next_enclosing = NULL_TREE;
6198       tree inner_list;
6199
6200       for (inner_list = DECL_INNER_CLASS_LIST (enclosing);
6201            inner_list; inner_list = TREE_CHAIN (inner_list))
6202         {
6203           if (TREE_VALUE (inner_list) == name_to_match)
6204             {
6205               next_enclosing = TREE_PURPOSE (inner_list);
6206               break;
6207             }
6208         }
6209       enclosing = next_enclosing;
6210     }
6211
6212   return (!qual && enclosing ? enclosing : NULL_TREE);
6213 }
6214
6215 /* Reach all inner classes and tie their unqualified name to a
6216    DECL. */
6217
6218 static void
6219 set_nested_class_simple_name_value (outer, set)
6220      tree outer;
6221      int set;
6222 {
6223   tree l;
6224
6225   for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
6226     IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ? 
6227                                                 TREE_PURPOSE (l) : NULL_TREE);
6228 }
6229
6230 static void
6231 link_nested_class_to_enclosing ()
6232 {
6233   if (GET_ENCLOSING_CPC ())
6234     {
6235       tree enclosing = GET_ENCLOSING_CPC_CONTEXT ();
6236       DECL_INNER_CLASS_LIST (enclosing) = 
6237         tree_cons (GET_CPC (), GET_CPC_UN (),
6238                    DECL_INNER_CLASS_LIST (enclosing));
6239       enclosing = enclosing;
6240     }
6241 }
6242
6243 static tree
6244 maybe_make_nested_class_name (name)
6245      tree name;
6246 {
6247   tree id = NULL_TREE;
6248
6249   if (CPC_INNER_P ())
6250     {
6251       make_nested_class_name (GET_CPC_LIST ());
6252       obstack_grow0 (&temporary_obstack,
6253                      IDENTIFIER_POINTER (name), 
6254                      IDENTIFIER_LENGTH (name));
6255       id = get_identifier (obstack_finish (&temporary_obstack));
6256       if (ctxp->package)
6257         QUALIFIED_P (id) = 1;
6258     }
6259   return id;
6260 }
6261
6262 /* If DECL is NULL, create and push a new DECL, record the current
6263    line CL and do other maintenance things.  */
6264
6265 static tree
6266 maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
6267      tree decl, raw_name, qualified_name, cl;
6268 {
6269   if (!decl)
6270     decl = push_class (make_class (), qualified_name);
6271
6272   /* Take care of the file and line business */
6273   DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
6274   /* If we're emiting xrefs, store the line/col number information */
6275   if (flag_emit_xref)
6276     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
6277   else
6278     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
6279   CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
6280   CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
6281     IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
6282
6283   PUSH_CPC (decl, raw_name);
6284   DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
6285
6286   /* Link the declaration to the already seen ones */
6287   TREE_CHAIN (decl) = ctxp->class_list;
6288   ctxp->class_list = decl;
6289
6290   /* Create a new nodes in the global lists */
6291   ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
6292   all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
6293
6294   /* Install a new dependency list element */
6295   create_jdep_list (ctxp);
6296
6297   SOURCE_FRONTEND_DEBUG (("Defining class/interface %s", 
6298                           IDENTIFIER_POINTER (qualified_name)));
6299   return decl;
6300 }
6301
6302 static void
6303 add_superinterfaces (decl, interface_list)
6304      tree decl, interface_list;
6305 {
6306   tree node;
6307   /* Superinterface(s): if present and defined, parser_check_super_interface ()
6308      takes care of ensuring that:
6309        - This is an accessible interface type,
6310        - Circularity detection.
6311    parser_add_interface is then called. If present but not defined,
6312    the check operation is delayed until the super interface gets
6313    defined.  */
6314   for (node = interface_list; node; node = TREE_CHAIN (node))
6315     {
6316       tree current = TREE_PURPOSE (node);
6317       tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
6318       if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
6319         {
6320           if (!parser_check_super_interface (idecl, decl, current))
6321             parser_add_interface (decl, idecl, current);
6322         }
6323       else
6324         register_incomplete_type (JDEP_INTERFACE,
6325                                   current, decl, NULL_TREE);
6326     }
6327 }
6328
6329 /* Create an interface in pass1 and return its decl. Return the
6330    interface's decl in pass 2.  */
6331
6332 static tree
6333 create_interface (flags, id, super)
6334      int flags;
6335      tree id, super;
6336 {
6337   tree raw_name = EXPR_WFL_NODE (id);
6338   tree q_name = parser_qualified_classname (flags & ACC_STATIC, raw_name);
6339   tree decl = IDENTIFIER_CLASS_VALUE (q_name);
6340
6341   EXPR_WFL_NODE (id) = q_name;  /* Keep source location, even if refined. */
6342
6343   /* Basic checks: scope, redefinition, modifiers */ 
6344   if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
6345     {
6346       PUSH_ERROR ();
6347       return NULL_TREE;
6348     }
6349
6350   /* Suspend the current parsing context if we're parsing an inner
6351      interface */
6352   if (CPC_INNER_P ())
6353     java_parser_context_suspend ();
6354
6355   /* Push a new context for (static) initialized upon declaration fields */
6356   java_parser_context_push_initialized_field ();
6357
6358   /* Interface modifiers check
6359        - public/abstract allowed (already done at that point)
6360        - abstract is obsolete (comes first, it's a warning, or should be)
6361        - Can't use twice the same (checked in the modifier rule) */
6362   if ((flags & ACC_ABSTRACT) && flag_redundant)
6363     parse_warning_context 
6364       (MODIFIER_WFL (ABSTRACT_TK),
6365        "Redundant use of `abstract' modifier. Interface `%s' is implicitely abstract", IDENTIFIER_POINTER (raw_name));
6366
6367   /* Create a new decl if DECL is NULL, otherwise fix it */
6368   decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
6369
6370   /* Set super info and mark the class a complete */
6371   set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl), 
6372                   object_type_node, ctxp->interface_number);
6373   ctxp->interface_number = 0;
6374   CLASS_COMPLETE_P (decl) = 1;
6375   add_superinterfaces (decl, super);
6376
6377   return decl;
6378 }
6379
6380 /* Anonymous class counter. Will be reset to 1 every time a non
6381    anonymous class gets created. */
6382 static int anonymous_class_counter = 1;
6383
6384 /* Patch anonymous class CLASS, by either extending or implementing
6385    DEP.  */
6386
6387 static void
6388 patch_anonymous_class (type_decl, class_decl, wfl)
6389     tree type_decl, class_decl, wfl;
6390 {
6391   tree class = TREE_TYPE (class_decl);
6392   tree type =  TREE_TYPE (type_decl);
6393   tree binfo = TYPE_BINFO (class);
6394
6395   /* If it's an interface, implement it */
6396   if (CLASS_INTERFACE (type_decl))
6397     {
6398       tree s_binfo;
6399       int length;
6400
6401       if (parser_check_super_interface (type_decl, class_decl, wfl))
6402         return;
6403
6404       s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
6405       length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
6406       TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
6407       TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
6408       /* And add the interface */
6409       parser_add_interface (class_decl, type_decl, wfl);
6410     }
6411   /* Otherwise, it's a type we want to extend */
6412   else
6413     {
6414       if (parser_check_super (type_decl, class_decl, wfl))
6415         return;
6416       BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
6417     }
6418 }
6419
6420 static tree
6421 create_anonymous_class (location, type_name)
6422     int location;
6423     tree type_name;
6424 {
6425   char buffer [80];
6426   tree super = NULL_TREE, itf = NULL_TREE;
6427   tree id, type_decl, class;
6428
6429   /* The unqualified name of the anonymous class. It's just a number. */
6430   sprintf (buffer, "%d", anonymous_class_counter++);
6431   id = build_wfl_node (get_identifier (buffer));
6432   EXPR_WFL_LINECOL (id) = location;
6433
6434   /* We know about the type to extend/implement. We go ahead */
6435   if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
6436     {
6437       /* Create a class which either implements on extends the designated
6438          class. The class bears an innacessible name. */
6439       if (CLASS_INTERFACE (type_decl))
6440         {
6441           /* It's OK to modify it here. It's been already used and
6442              shouldn't be reused */
6443           ctxp->interface_number = 1;
6444           /* Interfaces should presented as a list of WFLs */
6445           itf = build_tree_list (type_name, NULL_TREE);
6446         }
6447       else
6448         super = type_name;
6449     }
6450
6451   class = create_class (ACC_FINAL, id, super, itf);
6452
6453   /* We didn't know anything about the stuff. We register a dependence. */
6454   if (!type_decl)
6455     register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);
6456
6457   ANONYMOUS_CLASS_P (TREE_TYPE (class)) = 1;
6458   return class;
6459 }
6460
6461 /* Create a class in pass1 and return its decl. Return class
6462    interface's decl in pass 2.  */
6463
6464 static tree
6465 create_class (flags, id, super, interfaces)
6466      int flags;
6467      tree id, super, interfaces;
6468 {
6469   tree raw_name = EXPR_WFL_NODE (id);
6470   tree class_id, decl;
6471   tree super_decl_type;
6472
6473   class_id = parser_qualified_classname (0, raw_name);
6474   decl = IDENTIFIER_CLASS_VALUE (class_id);
6475   EXPR_WFL_NODE (id) = class_id;
6476
6477   /* Basic check: scope, redefinition, modifiers */
6478   if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
6479     {
6480       PUSH_ERROR ();
6481       return NULL_TREE;
6482     }
6483   
6484   /* Suspend the current parsing context if we're parsing an inner
6485      class or an anonymous class. */
6486   if (CPC_INNER_P ())
6487     java_parser_context_suspend ();
6488   /* Push a new context for (static) initialized upon declaration fields */
6489   java_parser_context_push_initialized_field ();
6490
6491   /* Class modifier check: 
6492        - Allowed modifier (already done at that point)
6493        - abstract AND final forbidden 
6494        - Public classes defined in the correct file */
6495   if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
6496     parse_error_context
6497       (id, "Class `%s' can't be declared both abstract and final",
6498        IDENTIFIER_POINTER (raw_name));
6499
6500   /* Create a new decl if DECL is NULL, otherwise fix it */
6501   decl = maybe_create_class_interface_decl (decl, raw_name, class_id, id);
6502
6503   /* If SUPER exists, use it, otherwise use Object */
6504   if (super)
6505     {
6506       /* Can't extend java.lang.Object */
6507       if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
6508         {
6509           parse_error_context (id, "Can't extend `java.lang.Object'");
6510           return NULL_TREE;
6511         }
6512
6513       super_decl_type = 
6514         register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
6515     }
6516   else if (TREE_TYPE (decl) != object_type_node)
6517     super_decl_type = object_type_node;
6518   /* We're defining java.lang.Object */
6519   else
6520     super_decl_type = NULL_TREE;
6521
6522   /* Set super info and mark the class a complete */
6523   set_super_info (flags, TREE_TYPE (decl), super_decl_type, 
6524                   ctxp->interface_number);
6525   ctxp->interface_number = 0;
6526   CLASS_COMPLETE_P (decl) = 1;
6527   add_superinterfaces (decl, interfaces);
6528
6529   /* If the class is a top level inner class, install an alias. */
6530   if (INNER_CLASS_DECL_P (decl) && CLASS_STATIC (decl))
6531     {
6532       tree alias = parser_qualified_classname (1, raw_name);
6533       IDENTIFIER_GLOBAL_VALUE (alias) = decl;
6534     }
6535
6536   /* Add the private this$<n> field, Replicate final locals still in
6537      scope as private final fields mangled like val$<local_name>.
6538      This doesn't not occur for top level (static) inner classes. */
6539   if (PURE_INNER_CLASS_DECL_P (decl))
6540     add_inner_class_fields (decl, current_function_decl);
6541
6542   /* If doing xref, store the location at which the inherited class
6543      (if any) was seen. */
6544   if (flag_emit_xref && super)
6545     DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
6546
6547   /* Eventually sets the @deprecated tag flag */
6548   CHECK_DEPRECATED (decl);
6549
6550   /* Reset the anonymous class counter when declaring non inner classes */
6551   if (!INNER_CLASS_DECL_P (decl))
6552     anonymous_class_counter = 1;
6553
6554   return decl;
6555 }
6556
6557 /* End a class declaration: register the statements used to create
6558    $finit$ and <clinit>, pop the current class and resume the prior
6559    parser context if necessary.  */
6560
6561 static void
6562 end_class_declaration (resume)
6563      int resume;
6564 {
6565   /* If an error occured, context weren't pushed and won't need to be
6566      popped by a resume. */
6567   int no_error_occured = ctxp->next && GET_CPC () != error_mark_node;
6568
6569   java_parser_context_pop_initialized_field ();
6570   POP_CPC ();
6571   if (resume && no_error_occured)
6572     java_parser_context_resume ();
6573
6574   /* We're ending a class declaration, this is a good time to reset
6575      the interface cout. Note that might have been already done in
6576      create_interface, but if at that time an inner class was being
6577      dealt with, the interface count was reset in a context created
6578      for the sake of handling inner classes declaration. */
6579   ctxp->interface_number = 0;
6580 }
6581
6582 static void
6583 add_inner_class_fields (class_decl, fct_decl)
6584      tree class_decl;
6585      tree fct_decl;
6586 {
6587   tree block, marker, f;
6588
6589   f = add_field (TREE_TYPE (class_decl),
6590                  build_current_thisn (TREE_TYPE (class_decl)),
6591                  build_pointer_type (TREE_TYPE (DECL_CONTEXT (class_decl))), 
6592                  ACC_PRIVATE);
6593   FIELD_THISN (f) = 1;
6594
6595   if (!fct_decl)
6596     return;
6597     
6598   for (block = GET_CURRENT_BLOCK (fct_decl); 
6599        block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block))
6600     {
6601       tree decl;
6602       for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl))
6603         {
6604           char *name, *pname;
6605           tree wfl, init, list;
6606           
6607           /* Avoid non final arguments. */
6608           if (!LOCAL_FINAL (decl))
6609             continue;
6610           
6611           MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl));
6612           MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl));
6613           wfl = build_wfl_node (get_identifier (name));
6614           init = build_wfl_node (get_identifier (pname));
6615           /* Build an initialization for the field: it will be
6616              initialized by a parameter added to $finit$, bearing a
6617              mangled name of the field itself (param$<n>.) The
6618              parameter is provided to $finit$ by the constructor
6619              invoking it (hence the constructor will also feature a
6620              hidden parameter, set to the value of the outer context
6621              local at the time the inner class is created.)
6622              
6623              Note: we take into account all possible locals that can
6624              be accessed by the inner class. It's actually not trivial
6625              to minimize these aliases down to the ones really
6626              used. One way to do that would be to expand all regular
6627              methods first, then $finit$ to get a picture of what's
6628              used.  It works with the exception that we would have to
6629              go back on all constructor invoked in regular methods to
6630              have their invokation reworked (to include the right amount
6631              of alias initializer parameters.)
6632
6633              The only real way around, I think, is a first pass to
6634              identify locals really used in the inner class. We leave
6635              the flag FIELD_LOCAL_ALIAS_USED around for that future
6636              use.
6637              
6638              On the other hand, it only affect local inner classes,
6639              whose constructors (and $finit$ call) will be featuring
6640              unecessary arguments. It's easy for a developper to keep
6641              this number of parameter down by using the `final'
6642              keyword only when necessary. For the time being, we can
6643              issue a warning on unecessary finals. FIXME */
6644           init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl), 
6645                                    wfl, init);
6646
6647           /* Register the field. The TREE_LIST holding the part
6648              initialized/initializer will be marked ARG_FINAL_P so
6649              that the created field can be marked
6650              FIELD_LOCAL_ALIAS. */
6651           list = build_tree_list (wfl, init);
6652           ARG_FINAL_P (list) = 1;
6653           register_fields (ACC_PRIVATE | ACC_FINAL, TREE_TYPE (decl), list);
6654         }
6655     }
6656
6657   if (!CPC_INITIALIZER_STMT (ctxp))
6658     return;
6659
6660   /* If we ever registered an alias field, insert and marker to
6661      remeber where the list ends. The second part of the list (the one
6662      featuring initialized fields) so it can be later reversed to
6663      enforce 8.5. The marker will be removed during that operation. */
6664   marker = build_tree_list (NULL_TREE, NULL_TREE);
6665   TREE_CHAIN (marker) = CPC_INITIALIZER_STMT (ctxp);
6666   SET_CPC_INITIALIZER_STMT (ctxp, marker);
6667 }
6668
6669 /* Can't use lookup_field () since we don't want to load the class and
6670    can't set the CLASS_LOADED_P flag */
6671
6672 static tree
6673 find_field (class, name)
6674      tree class;
6675      tree name;
6676 {
6677   tree decl;
6678   for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
6679     {
6680       if (DECL_NAME (decl) == name)
6681         return decl;
6682     }
6683   return NULL_TREE;
6684 }
6685
6686 /* Wrap around lookup_field that doesn't potentially upset the value
6687    of CLASS */
6688
6689 static tree
6690 lookup_field_wrapper (class, name)
6691      tree class, name;
6692 {
6693   tree type = class;
6694   tree decl;
6695   java_parser_context_save_global ();
6696   decl = lookup_field (&type, name);
6697
6698   /* Last chance: if we're within the context of an inner class, we
6699      might be trying to access a local variable defined in an outer
6700      context. We try to look for it now. */
6701   if (INNER_CLASS_TYPE_P (class) && (!decl || decl == error_mark_node))
6702     {
6703       char *alias_buffer;
6704       MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
6705       name = get_identifier (alias_buffer);
6706       type = class;
6707       decl = lookup_field (&type, name);
6708       if (decl && decl != error_mark_node)
6709         FIELD_LOCAL_ALIAS_USED (decl) = 1;
6710     }
6711
6712   java_parser_context_restore_global ();
6713   return decl == error_mark_node ? NULL : decl;
6714 }
6715
6716 /* Find duplicate field within the same class declarations and report
6717    the error. Returns 1 if a duplicated field was found, 0
6718    otherwise.  */
6719
6720 static int
6721 duplicate_declaration_error_p (new_field_name, new_type, cl)
6722      tree new_field_name, new_type, cl;
6723 {
6724   /* This might be modified to work with method decl as well */
6725   tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
6726   if (decl)
6727     {
6728       char *t1 = xstrdup (purify_type_name
6729                          ((TREE_CODE (new_type) == POINTER_TYPE 
6730                            && TREE_TYPE (new_type) == NULL_TREE) ?
6731                           IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
6732                           lang_printable_name (new_type, 1)));
6733       /* The type may not have been completed by the time we report
6734          the error */
6735       char *t2 = xstrdup (purify_type_name
6736                          ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE 
6737                            && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
6738                           IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
6739                           lang_printable_name (TREE_TYPE (decl), 1)));
6740       parse_error_context 
6741         (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)", 
6742          t1, IDENTIFIER_POINTER (new_field_name),
6743          t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
6744          DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
6745       free (t1);
6746       free (t2);
6747       return 1;
6748     }
6749   return 0;
6750 }
6751
6752 /* Field registration routine. If TYPE doesn't exist, field
6753    declarations are linked to the undefined TYPE dependency list, to
6754    be later resolved in java_complete_class () */
6755
6756 static void
6757 register_fields (flags, type, variable_list)
6758      int flags;
6759      tree type, variable_list;
6760 {
6761   tree current, saved_type;
6762   tree class_type = NULL_TREE;
6763   int saved_lineno = lineno;
6764   int must_chain = 0;
6765   tree wfl = NULL_TREE;
6766
6767   if (GET_CPC ())
6768     class_type = TREE_TYPE (GET_CPC ());
6769
6770   if (!class_type || class_type == error_mark_node)
6771     return;
6772
6773   /* If we're adding fields to interfaces, those fields are public,
6774      static, final */
6775   if (CLASS_INTERFACE (TYPE_NAME (class_type)))
6776     {
6777       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
6778                                  flags, ACC_PUBLIC, "interface field(s)");
6779       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
6780                                  flags, ACC_STATIC, "interface field(s)");
6781       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
6782                                  flags, ACC_FINAL, "interface field(s)");
6783       check_modifiers ("Illegal interface member modifier `%s'", flags,
6784                        INTERFACE_FIELD_MODIFIERS);
6785       flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
6786     }
6787
6788   /* Obtain a suitable type for resolution, if necessary */
6789   SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
6790
6791   /* If TYPE is fully resolved and we don't have a reference, make one */
6792   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6793
6794   for (current = variable_list, saved_type = type; current; 
6795        current = TREE_CHAIN (current), type = saved_type)
6796     {
6797       tree real_type;
6798       tree field_decl;
6799       tree cl = TREE_PURPOSE (current);
6800       tree init = TREE_VALUE (current);
6801       tree current_name = EXPR_WFL_NODE (cl);
6802
6803       /* Can't declare static fields in inner classes */
6804       if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
6805           && !CLASS_INTERFACE (TYPE_NAME (class_type)))
6806         parse_error_context 
6807           (cl, "Field `%s' can't be static in innerclass `%s'. Only members of interfaces and top-level classes can be static",
6808            IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
6809            lang_printable_name (class_type, 0));
6810
6811       /* Process NAME, as it may specify extra dimension(s) for it */
6812       type = build_array_from_name (type, wfl, current_name, &current_name);
6813
6814       /* Type adjustment. We may have just readjusted TYPE because
6815          the variable specified more dimensions. Make sure we have
6816          a reference if we can and don't have one already. Also
6817          change the name if we have an init. */
6818       if (type != saved_type)
6819         {
6820           PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6821           if (init)
6822             EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
6823         }
6824
6825       real_type = GET_REAL_TYPE (type);
6826       /* Check for redeclarations */
6827       if (duplicate_declaration_error_p (current_name, real_type, cl))
6828         continue;
6829
6830       /* Set lineno to the line the field was found and create a
6831          declaration for it. Eventually sets the @deprecated tag flag. */
6832       if (flag_emit_xref)
6833         lineno = EXPR_WFL_LINECOL (cl);
6834       else
6835         lineno = EXPR_WFL_LINENO (cl);
6836       field_decl = add_field (class_type, current_name, real_type, flags);
6837       CHECK_DEPRECATED (field_decl);
6838
6839       /* If the couple initializer/initialized is marked ARG_FINAL_P, we
6840          mark the created field FIELD_LOCAL_ALIAS, so that we can 
6841          hide parameters to this inner class $finit$ and constructors. */
6842       if (ARG_FINAL_P (current))
6843         FIELD_LOCAL_ALIAS (field_decl) = 1;
6844       
6845       /* Check if we must chain. */
6846       if (must_chain)
6847         register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
6848           
6849       /* If we have an initialization value tied to the field */
6850       if (init)
6851         {
6852           /* The field is declared static */
6853           if (flags & ACC_STATIC)
6854             {
6855               /* We include the field and its initialization part into
6856                  a list used to generate <clinit>. After <clinit> is
6857                  walked, field initializations will be processed and
6858                  fields initialized with known constants will be taken
6859                  out of <clinit> and have their DECL_INITIAL set
6860                  appropriately. */
6861               TREE_CHAIN (init) = CPC_STATIC_INITIALIZER_STMT (ctxp);
6862               SET_CPC_STATIC_INITIALIZER_STMT (ctxp, init);
6863               if (TREE_OPERAND (init, 1) 
6864                   && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
6865                 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
6866             }
6867           /* A non-static field declared with an immediate initialization is
6868              to be initialized in <init>, if any.  This field is remembered
6869              to be processed at the time of the generation of <init>. */
6870           else
6871             {
6872               TREE_CHAIN (init) = CPC_INITIALIZER_STMT (ctxp);
6873               SET_CPC_INITIALIZER_STMT (ctxp, init);
6874             }
6875           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
6876           DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
6877         }
6878     }
6879   lineno = saved_lineno;
6880 }
6881
6882 /* Generate $finit$, using the list of initialized fields to populate
6883    its body. $finit$'s parameter(s) list is adjusted to include the
6884    one(s) used to initialized the field(s) caching outer context
6885    local(s). */
6886
6887 static tree
6888 generate_finit (class_type)
6889      tree class_type;
6890 {
6891   int count = 0;
6892   tree list = TYPE_FINIT_STMT_LIST (class_type);
6893   tree mdecl, current, parms;
6894
6895   parms = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION, 
6896                                                   class_type, NULL_TREE, 
6897                                                   &count);
6898   CRAFTED_PARAM_LIST_FIXUP (parms);
6899   mdecl = create_artificial_method (class_type, ACC_PRIVATE, void_type_node,
6900                                     finit_identifier_node, parms);
6901   fix_method_argument_names (parms, mdecl);
6902   layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
6903                        mdecl, NULL_TREE);
6904   DECL_FUNCTION_NAP (mdecl) = count;
6905   start_artificial_method_body (mdecl);
6906
6907   for (current = list; current; current = TREE_CHAIN (current))
6908     java_method_add_stmt (mdecl, 
6909                           build_debugable_stmt (EXPR_WFL_LINECOL (current), 
6910                                                 current));
6911   end_artificial_method_body (mdecl);
6912   return mdecl;
6913 }
6914
6915 static void
6916 add_instance_initializer (mdecl)
6917      tree mdecl;
6918 {
6919   tree current;
6920   tree stmt_list = TYPE_II_STMT_LIST (DECL_CONTEXT (mdecl));
6921   tree compound = NULL_TREE;
6922
6923   if (stmt_list)
6924     {
6925       for (current = stmt_list; current; current = TREE_CHAIN (current))
6926         compound = add_stmt_to_compound (compound, NULL_TREE, current);
6927
6928       java_method_add_stmt (mdecl, build1 (INSTANCE_INITIALIZERS_EXPR,
6929                                            NULL_TREE, compound));
6930     }
6931 }
6932
6933 /* Shared accros method_declarator and method_header to remember the
6934    patch stage that was reached during the declaration of the method.
6935    A method DECL is built differently is there is no patch
6936    (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
6937    pending on the currently defined method.  */
6938
6939 static int patch_stage;
6940
6941 /* Check the method declaration and add the method to its current
6942    class.  If the argument list is known to contain incomplete types,
6943    the method is partially added and the registration will be resume
6944    once the method arguments resolved. If TYPE is NULL, we're dealing
6945    with a constructor.  */
6946
6947 static tree
6948 method_header (flags, type, mdecl, throws)
6949      int flags;
6950      tree type, mdecl, throws;
6951 {
6952   tree meth = TREE_VALUE (mdecl);
6953   tree id = TREE_PURPOSE (mdecl);
6954   tree type_wfl = NULL_TREE;
6955   tree meth_name = NULL_TREE;
6956   tree current, orig_arg, this_class = NULL;
6957   int saved_lineno;
6958   int constructor_ok = 0, must_chain;
6959   int count;
6960   
6961   check_modifiers_consistency (flags);
6962
6963   if (GET_CPC ())
6964     this_class = TREE_TYPE (GET_CPC ());
6965
6966   if (!this_class || this_class == error_mark_node)
6967     return NULL_TREE;
6968   
6969   /* There are some forbidden modifiers for an abstract method and its
6970      class must be abstract as well.  */
6971   if (type && (flags & ACC_ABSTRACT))
6972     {
6973       ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
6974       ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
6975       ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
6976       ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
6977       ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
6978       if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
6979           && !CLASS_INTERFACE (TYPE_NAME (this_class)))
6980         parse_error_context 
6981           (id, "Class `%s' must be declared abstract to define abstract method `%s'", 
6982            IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
6983            IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6984     }
6985
6986   /* Things to be checked when declaring a constructor */
6987   if (!type)
6988     {
6989       int ec = java_error_count;
6990       /* 8.6: Constructor declarations: we might be trying to define a
6991          method without specifying a return type. */
6992       if (EXPR_WFL_NODE (id) != GET_CPC_UN ())
6993         parse_error_context 
6994           (id, "Invalid method declaration, return type required");
6995       /* 8.6.3: Constructor modifiers */
6996       else
6997         {
6998           JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
6999           JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
7000           JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
7001           JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
7002           JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
7003         }
7004       /* If we found error here, we don't consider it's OK to tread
7005          the method definition as a constructor, for the rest of this
7006          function */
7007       if (ec == java_error_count)
7008         constructor_ok = 1;
7009     }
7010
7011   /* Method declared within the scope of an interface are implicitly
7012      abstract and public. Conflicts with other erroneously provided
7013      modifiers are checked right after. */
7014
7015   if (CLASS_INTERFACE (TYPE_NAME (this_class)))
7016     {
7017       /* If FLAGS isn't set because of a modifier, turn the
7018          corresponding modifier WFL to NULL so we issue a warning on
7019          the obsolete use of the modifier */
7020       if (!(flags & ACC_PUBLIC))
7021         MODIFIER_WFL (PUBLIC_TK) = NULL;
7022       if (!(flags & ACC_ABSTRACT))
7023         MODIFIER_WFL (ABSTRACT_TK) = NULL;
7024       flags |= ACC_PUBLIC;
7025       flags |= ACC_ABSTRACT;
7026     }
7027
7028   /* Inner class can't declare static methods */
7029   if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
7030     {
7031       parse_error_context 
7032         (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
7033          IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
7034          lang_printable_name (this_class, 0));
7035     }
7036
7037   /* Modifiers context reset moved up, so abstract method declaration
7038      modifiers can be later checked.  */
7039
7040   /* Set constructor returned type to void and method name to <init>,
7041      unless we found an error identifier the constructor (in which
7042      case we retain the original name) */
7043   if (!type)
7044     {
7045       type = void_type_node;
7046       if (constructor_ok)
7047         meth_name = init_identifier_node;
7048     }
7049   else
7050     meth_name = EXPR_WFL_NODE (id);
7051
7052   /* Do the returned type resolution and registration if necessary */
7053   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7054
7055   if (meth_name)
7056     type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
7057   EXPR_WFL_NODE (id) = meth_name;
7058   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7059
7060   if (must_chain)
7061     {
7062       patch_stage = JDEP_METHOD_RETURN;
7063       register_incomplete_type (patch_stage, type_wfl, id, type);
7064       TREE_TYPE (meth) = GET_REAL_TYPE (type);
7065     }
7066   else
7067     TREE_TYPE (meth) = type;
7068
7069   saved_lineno = lineno;
7070   /* When defining an abstract or interface method, the curly
7071      bracket at level 1 doesn't exist because there is no function
7072      body */
7073   lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 : 
7074             EXPR_WFL_LINENO (id));
7075
7076   /* Remember the original argument list */
7077   orig_arg = TYPE_ARG_TYPES (meth);
7078
7079   if (patch_stage)              /* includes ret type and/or all args */
7080     {
7081       jdep *jdep;
7082       meth = add_method_1 (this_class, flags, meth_name, meth);
7083       /* Patch for the return type */
7084       if (patch_stage == JDEP_METHOD_RETURN)
7085         {
7086           jdep = CLASSD_LAST (ctxp->classd_list);
7087           JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
7088         }
7089       /* This is the stop JDEP. METH allows the function's signature
7090          to be computed. */
7091       register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
7092     }
7093   else
7094     meth = add_method (this_class, flags, meth_name, 
7095                        build_java_signature (meth));
7096
7097   /* Remember final parameters */
7098   MARK_FINAL_PARMS (meth, orig_arg);
7099
7100   /* Fix the method argument list so we have the argument name
7101      information */
7102   fix_method_argument_names (orig_arg, meth);
7103
7104   /* Register the parameter number and re-install the current line
7105      number */
7106   DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
7107   lineno = saved_lineno;
7108
7109   /* Register exception specified by the `throws' keyword for
7110      resolution and set the method decl appropriate field to the list.
7111      Note: the grammar ensures that what we get here are class
7112      types. */
7113   if (throws)
7114     {
7115       throws = nreverse (throws);
7116       for (current = throws; current; current = TREE_CHAIN (current))
7117         {
7118           register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
7119                                     NULL_TREE, NULL_TREE);
7120           JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) = 
7121             &TREE_VALUE (current);
7122         }
7123       DECL_FUNCTION_THROWS (meth) = throws;
7124     }
7125
7126   /* We set the DECL_NAME to ID so we can track the location where
7127      the function was declared. This allow us to report
7128      redefinition error accurately. When method are verified,
7129      DECL_NAME is reinstalled properly (using the content of the
7130      WFL node ID) (see check_method_redefinition). We don't do that
7131      when Object is being defined. Constructor <init> names will be
7132      reinstalled the same way. */
7133   if (TREE_TYPE (GET_CPC ()) != object_type_node)
7134     DECL_NAME (meth) = id;
7135
7136   /* Set the flag if we correctly processed a constructor */
7137   if (constructor_ok)
7138     {
7139       DECL_CONSTRUCTOR_P (meth) = 1;
7140       /* Compute and store the number of artificial parameters declared
7141          for this constructor */
7142       for (count = 0, current = TYPE_FIELDS (this_class); current; 
7143            current = TREE_CHAIN (current))
7144         if (FIELD_LOCAL_ALIAS (current))
7145           count++;
7146       DECL_FUNCTION_NAP (meth) = count;
7147     }
7148
7149   /* Eventually set the @deprecated tag flag */
7150   CHECK_DEPRECATED (meth);
7151
7152   /* If doing xref, store column and line number information instead
7153      of the line number only. */
7154   if (flag_emit_xref)
7155     DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
7156
7157   return meth;
7158 }
7159
7160 static void
7161 fix_method_argument_names (orig_arg, meth)
7162     tree orig_arg, meth;
7163 {
7164   tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
7165   if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
7166     {
7167       TREE_PURPOSE (arg) = this_identifier_node;
7168       arg = TREE_CHAIN (arg);
7169     }
7170   while (orig_arg != end_params_node)
7171     {
7172       TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
7173       orig_arg = TREE_CHAIN (orig_arg);
7174       arg = TREE_CHAIN (arg);
7175     }
7176 }
7177
7178 /* Complete the method declaration with METHOD_BODY.  */
7179
7180 static void
7181 finish_method_declaration (method_body)
7182      tree method_body;
7183 {
7184   int flags;
7185
7186   if (!current_function_decl)
7187     return;
7188
7189   flags = get_access_flags_from_decl (current_function_decl);
7190
7191   /* 8.4.5 Method Body */
7192   if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
7193     {
7194       tree wfl = DECL_NAME (current_function_decl);
7195       parse_error_context (wfl, 
7196                            "%s method `%s' can't have a body defined",
7197                            (METHOD_NATIVE (current_function_decl) ?
7198                             "Native" : "Abstract"),
7199                            IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7200       method_body = NULL_TREE;
7201     }
7202   else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
7203     {
7204       tree wfl = DECL_NAME (current_function_decl);
7205       parse_error_context
7206         (wfl, 
7207          "Non native and non abstract method `%s' must have a body defined",
7208          IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7209       method_body = NULL_TREE;
7210     }
7211
7212   if (flag_emit_class_files && method_body 
7213       && TREE_CODE (method_body) == NOP_EXPR 
7214       && TREE_TYPE (current_function_decl) 
7215       && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
7216     method_body = build1 (RETURN_EXPR, void_type_node, NULL);
7217
7218   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
7219   maybe_absorb_scoping_blocks ();
7220   /* Exit function's body */
7221   exit_block ();
7222   /* Merge last line of the function with first line, directly in the
7223      function decl. It will be used to emit correct debug info. */
7224   if (!flag_emit_xref)
7225     DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
7226
7227   /* Since function's argument's list are shared, reset the
7228      ARG_FINAL_P parameter that might have been set on some of this
7229      function parameters. */
7230   UNMARK_FINAL_PARMS (current_function_decl);
7231   
7232   /* So we don't have an irrelevant function declaration context for
7233      the next static block we'll see. */
7234   current_function_decl = NULL_TREE;
7235 }
7236
7237 /* Build a an error message for constructor circularity errors.  */
7238
7239 static char *
7240 constructor_circularity_msg (from, to)
7241      tree from, to;
7242 {
7243   static char string [4096];
7244   char *t = xstrdup (lang_printable_name (from, 0));
7245   sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
7246   free (t);
7247   return string;
7248 }
7249
7250 /* Verify a circular call to METH. Return 1 if an error is found, 0
7251    otherwise.  */
7252
7253 static int
7254 verify_constructor_circularity (meth, current)
7255      tree meth, current;
7256 {
7257   static tree list = NULL_TREE;
7258   tree c;
7259   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7260     {
7261       if (TREE_VALUE (c) == meth)
7262         {
7263           char *t;
7264           if (list)
7265             {
7266               tree liste;
7267               list = nreverse (list);
7268               for (liste = list; liste; liste = TREE_CHAIN (liste))
7269                 {
7270                   parse_error_context 
7271                     (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s",
7272                      constructor_circularity_msg
7273                       (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste)))); 
7274                   java_error_count--;
7275                 }
7276             }
7277           t = xstrdup (lang_printable_name (meth, 0));
7278           parse_error_context (TREE_PURPOSE (c), 
7279                                "%s: recursive invocation of constructor `%s'",
7280                                constructor_circularity_msg (current, meth), t);
7281           free (t);
7282           list = NULL_TREE;
7283           return 1;
7284         }
7285     }
7286   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7287     {
7288       list = tree_cons (c, current, list);
7289       if (verify_constructor_circularity (meth, TREE_VALUE (c)))
7290         return 1;
7291       list = TREE_CHAIN (list);
7292     }
7293   return 0;
7294 }
7295
7296 /* Check modifiers that can be declared but exclusively */
7297
7298 static void
7299 check_modifiers_consistency (flags)
7300      int flags;
7301 {
7302   int acc_count = 0;
7303   tree cl = NULL_TREE;
7304
7305   THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, PUBLIC_TK, acc_count, cl);
7306   THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, PRIVATE_TK, acc_count, cl);
7307   THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
7308   if (acc_count > 1)
7309     parse_error_context
7310       (cl, "Inconsistent member declaration.  At most one of `public', `private', or `protected' may be specified");
7311
7312   acc_count = 0;
7313   cl = NULL_TREE;
7314   THIS_MODIFIER_ONLY (flags, ACC_FINAL, FINAL_TK - PUBLIC_TK,
7315                       acc_count, cl);
7316   THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK - PUBLIC_TK,
7317                       acc_count, cl);
7318   if (acc_count > 1)
7319     parse_error_context (cl,
7320                          "Inconsistent member declaration.  At most one of `final' or `volatile' may be specified");
7321 }
7322
7323 /* Check the methode header METH for abstract specifics features */
7324
7325 static void
7326 check_abstract_method_header (meth)
7327      tree meth;
7328 {
7329   int flags = get_access_flags_from_decl (meth);
7330   /* DECL_NAME might still be a WFL node */
7331   tree name = GET_METHOD_NAME (meth);
7332
7333   OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
7334                               ACC_ABSTRACT, "abstract method",
7335                               IDENTIFIER_POINTER (name));
7336   OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags, 
7337                               ACC_PUBLIC, "abstract method",
7338                               IDENTIFIER_POINTER (name));
7339
7340   check_modifiers ("Illegal modifier `%s' for interface method",
7341                   flags, INTERFACE_METHOD_MODIFIERS);
7342 }
7343
7344 /* Create a FUNCTION_TYPE node and start augmenting it with the
7345    declared function arguments. Arguments type that can't be resolved
7346    are left as they are, but the returned node is marked as containing
7347    incomplete types.  */
7348
7349 static tree
7350 method_declarator (id, list)
7351      tree id, list;
7352 {
7353   tree arg_types = NULL_TREE, current, node;
7354   tree meth = make_node (FUNCTION_TYPE);
7355   jdep *jdep;
7356
7357   patch_stage = JDEP_NO_PATCH;
7358
7359   /* If we're dealing with an inner class constructor, we hide the
7360      this$<n> decl in the name field of its parameter declaration.  We
7361      also might have to hide the outer context local alias
7362      initializers. Not done when the class is a toplevel class. */
7363   if (PURE_INNER_CLASS_DECL_P (GET_CPC ()) 
7364       && EXPR_WFL_NODE (id) == GET_CPC_UN ())
7365     {
7366       tree aliases_list, type, thisn;
7367       /* First the aliases, linked to the regular parameters */
7368       aliases_list =
7369         build_alias_initializer_parameter_list (AIPL_FUNCTION_DECLARATION, 
7370                                                 TREE_TYPE (GET_CPC ()),
7371                                                 NULL_TREE, NULL);
7372       list = chainon (nreverse (aliases_list), list);
7373
7374       /* Then this$<n> */
7375       type = TREE_TYPE (DECL_CONTEXT (GET_CPC ()));
7376       thisn = build_current_thisn (TYPE_NAME (GET_CPC ()));
7377       list = tree_cons (build_wfl_node (thisn), build_pointer_type (type),
7378                         list);
7379     }
7380   
7381   for (current = list; current; current = TREE_CHAIN (current))
7382     {
7383       int must_chain = 0;
7384       tree wfl_name = TREE_PURPOSE (current);
7385       tree type = TREE_VALUE (current);
7386       tree name = EXPR_WFL_NODE (wfl_name);
7387       tree already, arg_node;
7388       tree type_wfl = NULL_TREE;
7389       tree real_type;
7390
7391       /* Obtain a suitable type for resolution, if necessary */
7392       SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7393
7394       /* Process NAME, as it may specify extra dimension(s) for it */
7395       type = build_array_from_name (type, type_wfl, name, &name);
7396       EXPR_WFL_NODE (wfl_name) = name;
7397
7398       real_type = GET_REAL_TYPE (type);
7399       if (TREE_CODE (real_type) == RECORD_TYPE)
7400         {
7401           real_type = promote_type (real_type);
7402           if (TREE_CODE (type) == TREE_LIST)
7403             TREE_PURPOSE (type) = real_type;
7404         }
7405
7406       /* Check redefinition */
7407       for (already = arg_types; already; already = TREE_CHAIN (already))
7408         if (TREE_PURPOSE (already) == name)
7409           {
7410             parse_error_context
7411               (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
7412                IDENTIFIER_POINTER (name),
7413                IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7414             break;
7415           }
7416
7417       /* If we've an incomplete argument type, we know there is a location
7418          to patch when the type get resolved, later.  */
7419       jdep = NULL;
7420       if (must_chain)
7421         {
7422           patch_stage = JDEP_METHOD;
7423           type = register_incomplete_type (patch_stage, 
7424                                            type_wfl, wfl_name, type);
7425           jdep = CLASSD_LAST (ctxp->classd_list);
7426           JDEP_MISC (jdep) = id;
7427         }
7428
7429       /* The argument node: a name and a (possibly) incomplete type.  */
7430       arg_node = build_tree_list (name, real_type);
7431       /* Remeber arguments declared final. */
7432       ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
7433       
7434       if (jdep)
7435         JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
7436       TREE_CHAIN (arg_node) = arg_types;
7437       arg_types = arg_node;
7438     }
7439   TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
7440   node = build_tree_list (id, meth);
7441   return node;
7442 }
7443
7444 static int
7445 unresolved_type_p (wfl, returned)
7446      tree wfl;
7447      tree *returned;
7448      
7449 {
7450   if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
7451     {
7452       if (returned)
7453         {
7454           tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
7455           if (decl && current_class && (decl == TYPE_NAME (current_class)))
7456             *returned = TREE_TYPE (decl);
7457           else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
7458             *returned = TREE_TYPE (GET_CPC ());
7459           else
7460             *returned = NULL_TREE;
7461         }
7462       return 1;
7463     }
7464   if (returned)
7465     *returned = wfl;
7466   return 0;
7467 }
7468
7469 /* From NAME, build a qualified identifier node using the
7470    qualification from the current package definition. */
7471
7472 static tree
7473 parser_qualified_classname (is_static, name)
7474      int is_static;
7475      tree name;
7476 {
7477   tree nested_class_name;
7478
7479   if (!is_static 
7480       && (nested_class_name = maybe_make_nested_class_name (name)))
7481     return nested_class_name;
7482
7483   if (ctxp->package)
7484     return merge_qualified_name (ctxp->package, name);
7485   else 
7486     return name;
7487 }
7488
7489 /* Called once the type a interface extends is resolved. Returns 0 if
7490    everything is OK.  */
7491
7492 static int
7493 parser_check_super_interface (super_decl, this_decl, this_wfl)
7494      tree super_decl, this_decl, this_wfl;
7495 {
7496   tree super_type = TREE_TYPE (super_decl);
7497
7498   /* Has to be an interface */
7499   if (!CLASS_INTERFACE (super_decl))
7500     {
7501       parse_error_context 
7502         (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
7503          (TYPE_ARRAY_P (super_type) ? "array" : "class"),
7504          IDENTIFIER_POINTER (DECL_NAME (super_decl)),
7505          (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ? 
7506           "interface" : "class"),
7507          IDENTIFIER_POINTER (DECL_NAME (this_decl)));
7508       return 1;
7509     }
7510
7511   /* Check scope: same package OK, other package: OK if public */
7512   if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
7513     return 1;
7514
7515   SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
7516                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7517                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7518   return 0;
7519 }
7520
7521 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
7522    0 if everthing is OK.  */
7523
7524 static int
7525 parser_check_super (super_decl, this_decl, wfl)
7526      tree super_decl, this_decl, wfl;
7527 {
7528   tree super_type = TREE_TYPE (super_decl);
7529
7530   /* SUPER should be a CLASS (neither an array nor an interface) */
7531   if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
7532     {
7533       parse_error_context 
7534         (wfl, "Class `%s' can't subclass %s `%s'",
7535          IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7536          (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
7537          IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7538       return 1;
7539     }
7540
7541   if (CLASS_FINAL (TYPE_NAME (super_type)))
7542     {
7543       parse_error_context (wfl, "Can't subclass final classes: %s",
7544                            IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7545       return 1;
7546     }
7547
7548   /* Check scope: same package OK, other package: OK if public */
7549   if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
7550     return 1;
7551   
7552   SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
7553                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7554                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7555   return 0;
7556 }
7557
7558 /* Create a new dependency list and link it (in a LIFO manner) to the
7559    CTXP list of type dependency list.  */
7560
7561 static void
7562 create_jdep_list (ctxp)
7563      struct parser_ctxt *ctxp;
7564 {
7565   jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));      
7566   new->first = new->last = NULL;
7567   new->next = ctxp->classd_list;
7568   ctxp->classd_list = new;
7569 }
7570
7571 static jdeplist *
7572 reverse_jdep_list (ctxp)
7573      struct parser_ctxt *ctxp;
7574 {
7575   register jdeplist *prev = NULL, *current, *next;
7576   for (current = ctxp->classd_list; current; current = next)
7577     {
7578       next = current->next;
7579       current->next = prev;
7580       prev = current;
7581     }
7582   return prev;
7583 }
7584
7585 /* Create a fake pointer based on the ID stored in
7586    TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
7587    registered again. */
7588
7589 static tree
7590 obtain_incomplete_type (type_name)
7591      tree type_name;
7592 {
7593   tree ptr, name;
7594
7595   if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
7596     name = EXPR_WFL_NODE (type_name);
7597   else if (INCOMPLETE_TYPE_P (type_name))
7598     name = TYPE_NAME (type_name);
7599   else
7600     fatal ("invalid type name - obtain_incomplete_type");
7601
7602   for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
7603     if (TYPE_NAME (ptr) == name)
7604       break;
7605
7606   if (!ptr)
7607     {
7608       push_obstacks (&permanent_obstack, &permanent_obstack);
7609       BUILD_PTR_FROM_NAME (ptr, name);
7610       layout_type (ptr);
7611       pop_obstacks ();
7612       TREE_CHAIN (ptr) = ctxp->incomplete_class;
7613       ctxp->incomplete_class = ptr;
7614     }
7615
7616   return ptr;
7617 }
7618
7619 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
7620    non NULL instead of computing a new fake type based on WFL. The new
7621    dependency is inserted in the current type dependency list, in FIFO
7622    manner.  */
7623
7624 static tree
7625 register_incomplete_type (kind, wfl, decl, ptr)
7626      int kind;
7627      tree wfl, decl, ptr;
7628 {
7629   jdep *new = (jdep *)xmalloc (sizeof (jdep));
7630
7631   if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
7632     ptr = obtain_incomplete_type (wfl);
7633
7634   JDEP_KIND (new) = kind;
7635   JDEP_DECL (new) = decl;
7636   JDEP_SOLV (new) = ptr;
7637   JDEP_WFL (new) = wfl;
7638   JDEP_CHAIN (new) = NULL;
7639   JDEP_MISC (new) = NULL_TREE;
7640   /* For some dependencies, set the enclosing class of the current
7641      class to be the enclosing context */
7642   if ((kind == JDEP_SUPER || kind == JDEP_INTERFACE || kind == JDEP_ANONYMOUS)
7643       && GET_ENCLOSING_CPC ())
7644     JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
7645   else
7646     JDEP_ENCLOSING (new) = GET_CPC ();
7647   JDEP_GET_PATCH (new) = (tree *)NULL;
7648
7649   JDEP_INSERT (ctxp->classd_list, new);
7650
7651   return ptr;
7652 }
7653
7654 void
7655 java_check_circular_reference ()
7656 {
7657   tree current;
7658   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7659     {
7660       tree type = TREE_TYPE (current);
7661       if (CLASS_INTERFACE (current))
7662         {
7663           /* Check all interfaces this class extends */
7664           tree basetype_vec = TYPE_BINFO_BASETYPES (type);
7665           int n, i;
7666
7667           if (!basetype_vec)
7668             return;
7669           n = TREE_VEC_LENGTH (basetype_vec);
7670           for (i = 0; i < n; i++)
7671             {
7672               tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7673               if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node 
7674                   && interface_of_p (type, BINFO_TYPE (vec_elt)))
7675                 parse_error_context (lookup_cl (current),
7676                                      "Cyclic interface inheritance");
7677             }
7678         }
7679       else
7680         if (inherits_from_p (CLASSTYPE_SUPER (type), type))
7681           parse_error_context (lookup_cl (current), 
7682                                "Cyclic class inheritance%s",
7683                                (cyclic_inheritance_report ?
7684                                 cyclic_inheritance_report : ""));
7685     }
7686 }
7687
7688 /* Augment the parameter list PARM with parameters crafted to
7689    initialize outer context locals aliases. Through ARTIFICIAL, a
7690    count is kept of the number of crafted parameters. MODE governs
7691    what eventually gets created: something suitable for a function
7692    creation or a function invocation, either the constructor or
7693    $finit$.  */
7694
7695 static tree
7696 build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
7697     int mode;
7698     tree class_type, parm;
7699     int *artificial;
7700 {
7701   tree field;
7702   for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
7703     if (FIELD_LOCAL_ALIAS (field))
7704       {
7705         char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
7706         tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
7707
7708         switch (mode)
7709           {
7710           case AIPL_FUNCTION_DECLARATION:
7711             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7712             purpose = build_wfl_node (get_identifier (buffer));
7713             if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
7714               value = build_wfl_node (TYPE_NAME (TREE_TYPE (field)));
7715             else
7716               value = TREE_TYPE (field);
7717             break;
7718
7719           case AIPL_FUNCTION_CREATION:
7720             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7721             purpose = get_identifier (buffer);
7722             value = TREE_TYPE (field);
7723             break;
7724
7725           case AIPL_FUNCTION_FINIT_INVOCATION:
7726             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7727             /* Now, this is wrong. purpose should always be the NAME
7728                of something and value its matching value (decl, type,
7729                etc...) FIXME -- but there is a lot to fix. */
7730
7731             /* When invoked for this kind of operation, we already
7732                know whether a field is used or not. */
7733             purpose = TREE_TYPE (field);
7734             value = build_wfl_node (get_identifier (buffer));
7735             break;
7736
7737           case AIPL_FUNCTION_CTOR_INVOCATION:
7738             /* There are two case: the constructor invokation happends
7739                outside the local inner, in which case, locales from the outer
7740                context are directly used.
7741
7742                Otherwise, we fold to using the alias directly. */
7743             if (class_type == current_class)
7744               value = field;
7745             else
7746               {
7747                 name = get_identifier (&buffer[4]);
7748                 value = IDENTIFIER_LOCAL_VALUE (name);
7749               }
7750             break;
7751           }
7752         parm = tree_cons (purpose, value, parm);
7753         if (artificial)
7754           *artificial +=1;
7755       }
7756   return parm;
7757 }
7758
7759 /* Craft a constructor for CLASS_DECL -- what we should do when none
7760    where found. ARGS is non NULL when a special signature must be
7761    enforced. This is the case for anonymous classes.  */
7762
7763 static void
7764 craft_constructor (class_decl, args)
7765      tree class_decl, args;
7766 {
7767   tree class_type = TREE_TYPE (class_decl);
7768   tree parm = NULL_TREE;
7769   int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7770                ACC_PUBLIC : 0);
7771   int i = 0, artificial = 0;
7772   tree decl, ctor_name;
7773   char buffer [80];
7774   
7775   push_obstacks (&permanent_obstack, &permanent_obstack);
7776
7777   /* The constructor name is <init> unless we're dealing with an
7778      anonymous class, in which case the name will be fixed after having
7779      be expanded. */
7780   if (ANONYMOUS_CLASS_P (class_type))
7781     ctor_name = DECL_NAME (class_decl);
7782   else
7783     ctor_name = init_identifier_node;
7784
7785   /* If we're dealing with an inner class constructor, we hide the
7786      this$<n> decl in the name field of its parameter declaration. */
7787   if (PURE_INNER_CLASS_TYPE_P (class_type))
7788     {
7789       tree type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_type)));
7790       parm = tree_cons (build_current_thisn (class_type),
7791                         build_pointer_type (type), parm);
7792
7793       /* Some more arguments to be hidden here. The values of the local
7794          variables of the outer context that the inner class needs to see. */
7795       parm = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
7796                                                      class_type, parm, 
7797                                                      &artificial);
7798     }
7799
7800   /* Then if there are any args to be enforced, enforce them now */
7801   for (; args && args != end_params_node; args = TREE_CHAIN (args))
7802     {
7803       sprintf (buffer, "parm%d", i++);
7804       parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
7805     }
7806
7807   CRAFTED_PARAM_LIST_FIXUP (parm);
7808   decl = create_artificial_method (class_type, flags, void_type_node, 
7809                                    ctor_name, parm);
7810   fix_method_argument_names (parm, decl);
7811   /* Now, mark the artificial parameters. */
7812   DECL_FUNCTION_NAP (decl) = artificial;
7813
7814   pop_obstacks ();
7815   DECL_CONSTRUCTOR_P (decl) = 1;
7816 }
7817
7818
7819 /* Fix the constructors. This will be called right after circular
7820    references have been checked. It is necessary to fix constructors
7821    early even if no code generation will take place for that class:
7822    some generated constructor might be required by the class whose
7823    compilation triggered this one to be simply loaded.  */
7824
7825 void
7826 java_fix_constructors ()
7827 {
7828   tree current;
7829
7830   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7831     {
7832       tree class_type = TREE_TYPE (current);
7833       int saw_ctor = 0;
7834       tree decl;
7835
7836       if (CLASS_INTERFACE (TYPE_NAME (class_type)))
7837         continue;
7838
7839       for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
7840         {
7841           if (DECL_CONSTRUCTOR_P (decl))
7842             {
7843               fix_constructors (decl);
7844               saw_ctor = 1;
7845             }
7846         }
7847
7848       /* Anonymous class constructor can't be generated that early. */
7849       if (!saw_ctor && !ANONYMOUS_CLASS_P (class_type))
7850         craft_constructor (current, NULL_TREE);
7851     }
7852 }
7853
7854 /* safe_layout_class just makes sure that we can load a class without
7855    disrupting the current_class, input_file, lineno, etc, information
7856    about the class processed currently.  */
7857
7858 void
7859 safe_layout_class (class)
7860      tree class;
7861 {
7862   tree save_current_class = current_class;
7863   const char *save_input_filename = input_filename;
7864   int save_lineno = lineno;
7865
7866   push_obstacks (&permanent_obstack, &permanent_obstack);
7867
7868   layout_class (class);
7869   pop_obstacks ();
7870
7871   current_class = save_current_class;
7872   input_filename = save_input_filename;
7873   lineno = save_lineno;
7874   CLASS_LOADED_P (class) = 1;
7875 }
7876
7877 static tree
7878 jdep_resolve_class (dep)
7879      jdep *dep;
7880 {
7881   tree decl;
7882
7883   if (JDEP_RESOLVED_P (dep))
7884     decl = JDEP_RESOLVED_DECL (dep);
7885   else
7886     {
7887       decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
7888                             JDEP_DECL (dep), JDEP_WFL (dep));
7889       JDEP_RESOLVED (dep, decl);
7890     }
7891     
7892   if (!decl)
7893     complete_class_report_errors (dep);
7894
7895   return decl;
7896 }
7897
7898 /* Complete unsatisfied class declaration and their dependencies */
7899
7900 void
7901 java_complete_class ()
7902 {
7903   tree cclass;
7904   jdeplist *cclassd;
7905   int error_found;
7906   tree type;
7907
7908   push_obstacks (&permanent_obstack, &permanent_obstack);
7909
7910   /* Process imports and reverse the import on demand list */
7911   process_imports ();
7912   if (ctxp->import_demand_list)
7913     ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
7914
7915   /* Rever things so we have the right order */
7916   ctxp->class_list = nreverse (ctxp->class_list);
7917   ctxp->classd_list = reverse_jdep_list (ctxp);
7918
7919   for (cclassd = ctxp->classd_list, cclass = ctxp->class_list; 
7920        cclass && cclassd; 
7921        cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
7922     {
7923       jdep *dep;
7924       for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
7925         {
7926           tree decl;
7927           if (!(decl = jdep_resolve_class (dep)))
7928             continue;
7929
7930           /* Now it's time to patch */
7931           switch (JDEP_KIND (dep))
7932             {
7933             case JDEP_SUPER:
7934               /* Simply patch super */
7935               if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
7936                 continue;
7937               BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO 
7938                 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
7939               break;
7940
7941             case JDEP_FIELD:
7942               {
7943                 /* We do part of the job done in add_field */
7944                 tree field_decl = JDEP_DECL (dep);
7945                 tree field_type = TREE_TYPE (decl);
7946                 push_obstacks (&permanent_obstack, &permanent_obstack);
7947                 if (TREE_CODE (field_type) == RECORD_TYPE)
7948                   field_type = promote_type (field_type);
7949                 pop_obstacks ();
7950                 TREE_TYPE (field_decl) = field_type;
7951                 DECL_ALIGN (field_decl) = 0;
7952                 layout_decl (field_decl, 0);
7953                 SOURCE_FRONTEND_DEBUG 
7954                   (("Completed field/var decl `%s' with `%s'",
7955                     IDENTIFIER_POINTER (DECL_NAME (field_decl)),
7956                     IDENTIFIER_POINTER (DECL_NAME (decl))));
7957                 break;
7958               }
7959             case JDEP_METHOD:   /* We start patching a method */
7960             case JDEP_METHOD_RETURN:
7961               error_found = 0;
7962               while (1)
7963                 {
7964                   if (decl)
7965                     {
7966                       type = TREE_TYPE(decl);
7967                       if (TREE_CODE (type) == RECORD_TYPE)
7968                         type = promote_type (type);
7969                       JDEP_APPLY_PATCH (dep, type);
7970                       SOURCE_FRONTEND_DEBUG 
7971                         (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
7972                            "Completing fct `%s' with ret type `%s'":
7973                            "Completing arg `%s' with type `%s'"),
7974                           IDENTIFIER_POINTER (EXPR_WFL_NODE 
7975                                               (JDEP_DECL_WFL (dep))),
7976                           IDENTIFIER_POINTER (DECL_NAME (decl))));
7977                     }
7978                   else
7979                     error_found = 1;
7980                   dep = JDEP_CHAIN (dep);
7981                   if (JDEP_KIND (dep) == JDEP_METHOD_END)
7982                     break;
7983                   else
7984                     decl = jdep_resolve_class (dep);
7985                 }
7986               if (!error_found)
7987                 {
7988                   tree mdecl = JDEP_DECL (dep), signature;
7989                   push_obstacks (&permanent_obstack, &permanent_obstack);
7990                   /* Recompute and reset the signature, check first that
7991                      all types are now defined. If they're not,
7992                      dont build the signature. */
7993                   if (check_method_types_complete (mdecl))
7994                     {
7995                       signature = build_java_signature (TREE_TYPE (mdecl));
7996                       set_java_signature (TREE_TYPE (mdecl), signature);
7997                     }
7998                   pop_obstacks ();
7999                 }
8000               else
8001                 continue;
8002               break;
8003
8004             case JDEP_INTERFACE:
8005               if (parser_check_super_interface (decl, JDEP_DECL (dep),
8006                                                 JDEP_WFL (dep)))
8007                 continue;
8008               parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
8009               break;
8010
8011             case JDEP_PARM:
8012             case JDEP_VARIABLE:
8013               type = TREE_TYPE(decl);
8014               if (TREE_CODE (type) == RECORD_TYPE)
8015                 type = promote_type (type);
8016               JDEP_APPLY_PATCH (dep, type);
8017               break;
8018
8019             case JDEP_TYPE:
8020               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8021               SOURCE_FRONTEND_DEBUG 
8022                 (("Completing a random type dependency on a '%s' node",
8023                   tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
8024               break;
8025
8026             case JDEP_EXCEPTION:
8027               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8028               SOURCE_FRONTEND_DEBUG 
8029                 (("Completing `%s' `throws' argument node",
8030                   IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
8031               break;
8032
8033             case JDEP_ANONYMOUS:
8034               patch_anonymous_class (decl, JDEP_DECL (dep), JDEP_WFL (dep));
8035               break;
8036
8037             default:
8038               fatal ("Can't handle patch code %d - java_complete_class",
8039                      JDEP_KIND (dep));
8040             }
8041         }
8042     }
8043   pop_obstacks ();
8044   return;
8045 }
8046
8047 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
8048    array.  */
8049
8050 static tree
8051 resolve_class (enclosing, class_type, decl, cl)
8052      tree enclosing, class_type, decl, cl;
8053 {
8054   const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
8055   const char *base = name;
8056   tree resolved_type = TREE_TYPE (class_type);
8057   tree resolved_type_decl;
8058   
8059   if (resolved_type != NULL_TREE)
8060     {
8061       tree resolved_type_decl = TYPE_NAME (resolved_type);
8062       if (resolved_type_decl == NULL_TREE
8063           || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
8064         {
8065           resolved_type_decl = build_decl (TYPE_DECL,
8066                                            TYPE_NAME (class_type),
8067                                            resolved_type);
8068         }
8069       return resolved_type_decl;
8070     }
8071
8072   /* 1- Check to see if we have an array. If true, find what we really
8073      want to resolve  */
8074   while (name[0] == '[')
8075     name++;
8076   if (base != name)
8077     TYPE_NAME (class_type) = get_identifier (name);
8078
8079   /* 2- Resolve the bare type */
8080   if (!(resolved_type_decl = do_resolve_class (enclosing, class_type, 
8081                                                decl, cl)))
8082     return NULL_TREE;
8083   resolved_type = TREE_TYPE (resolved_type_decl);
8084
8085   /* 3- If we have and array, reconstruct the array down to its nesting */
8086   if (base != name)
8087     {
8088       while (base != name)
8089         {
8090           if (TREE_CODE (resolved_type) == RECORD_TYPE)
8091             resolved_type  = promote_type (resolved_type);
8092           resolved_type = build_java_array_type (resolved_type, -1);
8093           CLASS_LOADED_P (resolved_type) = 1;
8094           name--;
8095         }
8096       /* Build a fake decl for this, since this is what is expected to
8097          be returned.  */
8098       resolved_type_decl =
8099         build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
8100       /* Figure how those two things are important for error report. FIXME */
8101       DECL_SOURCE_LINE (resolved_type_decl) = 0;
8102       DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
8103       TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
8104     }
8105   TREE_TYPE (class_type) = resolved_type;
8106   return resolved_type_decl;
8107 }
8108
8109 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
8110    are used to report error messages.  */
8111
8112 tree
8113 do_resolve_class (enclosing, class_type, decl, cl)
8114      tree enclosing, class_type, decl, cl;
8115 {
8116   tree new_class_decl;
8117   tree original_name = NULL_TREE;
8118
8119   /* Do not try to replace TYPE_NAME (class_type) by a variable, since
8120      its is changed by find_in_imports{_on_demand} */
8121
8122   /* 0- Search in the current class as an inner class */
8123
8124   /* Maybe some code here should be added to load the class or
8125      something, at least if the class isn't an inner class and ended
8126      being loaded from class file. FIXME. */
8127   while (enclosing)
8128     {
8129       tree name;
8130
8131       if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl)))
8132         return new_class_decl;
8133
8134       /* Now go to the upper classes, bail out if necessary. */
8135       enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing));
8136       if (!enclosing || enclosing == object_type_node)
8137         break;
8138       
8139       if (TREE_CODE (enclosing) == RECORD_TYPE)
8140         {
8141           enclosing = TYPE_NAME (enclosing);
8142           continue;
8143         }
8144
8145       if (TREE_CODE (enclosing) == IDENTIFIER_NODE)
8146         {
8147           BUILD_PTR_FROM_NAME (name, enclosing);
8148         }
8149       else
8150         name = enclosing;
8151       enclosing = do_resolve_class (NULL, name, NULL, NULL);
8152     }
8153
8154   /* 1- Check for the type in single imports */
8155   if (find_in_imports (class_type))
8156     return NULL_TREE;
8157
8158   /* 2- And check for the type in the current compilation unit. If it fails,
8159      try with a name qualified with the package name we've seen so far */
8160   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8161     {
8162       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8163           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8164         load_class (TYPE_NAME (class_type), 0);
8165       return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8166     }
8167
8168   original_name = TYPE_NAME (class_type);
8169   if (!QUALIFIED_P (TYPE_NAME (class_type)))
8170     {
8171       tree package;
8172       for (package = package_list; package; package = TREE_CHAIN (package))
8173         {
8174           tree new_qualified;
8175           
8176           new_qualified = merge_qualified_name (TREE_PURPOSE (package),
8177                                                 original_name);
8178           TYPE_NAME (class_type) = new_qualified;
8179           new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8180           if (!new_class_decl)
8181             load_class (TYPE_NAME (class_type), 0);
8182           new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8183           if (new_class_decl)
8184             {
8185               if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8186                   !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8187                 load_class (TYPE_NAME (class_type), 0);
8188               return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8189             }
8190         }
8191     }
8192
8193   TYPE_NAME (class_type) = original_name;
8194
8195   /* 3- Check an other compilation unit that bears the name of type */
8196   load_class (TYPE_NAME (class_type), 0);
8197   if (check_pkg_class_access (TYPE_NAME (class_type), 
8198                               (cl ? cl : lookup_cl (decl))))
8199     return NULL_TREE;
8200
8201   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8202     return new_class_decl;
8203
8204   /* 4- Check the import on demands. Don't allow bar.baz to be
8205      imported from foo.* */
8206   if (!QUALIFIED_P (TYPE_NAME (class_type)))
8207     if (find_in_imports_on_demand (class_type))
8208       return NULL_TREE;
8209
8210   /* 5- Last call for a resolution */
8211   return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8212 }
8213
8214 /* Resolve NAME and lay it out (if not done and if not the current
8215    parsed class). Return a decl node. This function is meant to be
8216    called when type resolution is necessary during the walk pass.  */
8217
8218 static tree
8219 resolve_and_layout (something, cl)
8220      tree something;
8221      tree cl;
8222 {
8223   tree decl;
8224
8225   /* Don't do that on the current class */
8226   if (something == current_class)
8227     return TYPE_NAME (current_class);
8228
8229   /* Don't do anything for void and other primitive types */
8230   if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8231     return NULL_TREE;
8232
8233   /* Pointer types can be reall pointer types or fake pointers. When
8234      finding a real pointer, recheck for primitive types */
8235   if (TREE_CODE (something) == POINTER_TYPE)
8236     {
8237       if (TREE_TYPE (something))
8238         {
8239           something = TREE_TYPE (something);
8240           if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8241             return NULL_TREE;
8242         }
8243       else
8244         something = TYPE_NAME (something);
8245     }
8246
8247   /* Don't do anything for arrays of primitive types */
8248   if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
8249       && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
8250     return NULL_TREE;
8251
8252   /* Something might be a WFL */
8253   if (TREE_CODE (something) == EXPR_WITH_FILE_LOCATION)
8254     something = EXPR_WFL_NODE (something);
8255
8256   /* Otherwise, if something is not and IDENTIFIER_NODE, it can be a a
8257      TYPE_DECL or a real TYPE */
8258   else if (TREE_CODE (something) != IDENTIFIER_NODE)
8259     something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
8260             DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
8261
8262   if (!(decl = resolve_no_layout (something, cl)))
8263     return NULL_TREE;
8264
8265   /* Resolve and layout if necessary */
8266   layout_class_methods (TREE_TYPE (decl));
8267   /* Check methods, but only once */
8268   if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) 
8269       && !CLASS_LOADED_P (TREE_TYPE (decl)))
8270     CHECK_METHODS (decl);
8271   if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
8272     safe_layout_class (TREE_TYPE (decl));
8273
8274   return decl;
8275 }
8276
8277 /* Resolve a class, returns its decl but doesn't perform any
8278    layout. The current parsing context is saved and restored */
8279
8280 static tree
8281 resolve_no_layout (name, cl)
8282      tree name, cl;
8283 {
8284   tree ptr, decl;
8285   BUILD_PTR_FROM_NAME (ptr, name);
8286   java_parser_context_save_global ();
8287   decl = resolve_class (TYPE_NAME (current_class), ptr, NULL_TREE, cl);
8288   java_parser_context_restore_global ();
8289   
8290   return decl;
8291 }
8292
8293 /* Called when reporting errors. Skip leader '[' in a complex array
8294    type description that failed to be resolved.  */
8295
8296 static const char *
8297 purify_type_name (name)
8298      const char *name;
8299 {
8300   while (*name && *name == '[')
8301     name++;
8302   return name;
8303 }
8304
8305 /* The type CURRENT refers to can't be found. We print error messages.  */
8306
8307 static void
8308 complete_class_report_errors (dep)
8309      jdep *dep;
8310 {
8311   const char *name;
8312
8313   if (!JDEP_WFL (dep))
8314     return;
8315
8316   name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
8317   switch (JDEP_KIND (dep))
8318     {
8319     case JDEP_SUPER:
8320       parse_error_context  
8321         (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
8322          purify_type_name (name),
8323          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8324       break;
8325     case JDEP_FIELD:
8326       parse_error_context
8327         (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
8328          purify_type_name (name),
8329          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8330       break;
8331     case JDEP_METHOD:           /* Covers arguments */
8332       parse_error_context
8333         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
8334          purify_type_name (name),
8335          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
8336          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
8337       break;
8338     case JDEP_METHOD_RETURN:    /* Covers return type */
8339       parse_error_context
8340         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'", 
8341          purify_type_name (name),
8342          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
8343       break;
8344     case JDEP_INTERFACE:
8345       parse_error_context
8346         (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
8347          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
8348          (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
8349          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8350       break;
8351     case JDEP_VARIABLE:
8352       parse_error_context
8353         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'", 
8354          purify_type_name (IDENTIFIER_POINTER 
8355                            (EXPR_WFL_NODE (JDEP_WFL (dep)))),
8356          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8357       break;
8358     case JDEP_EXCEPTION:        /* As specified by `throws' */
8359       parse_error_context 
8360           (JDEP_WFL (dep), "Class `%s' not found in `throws'",
8361          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
8362       break;
8363     default:
8364       /* Fix for -Wall. Just break doing nothing. The error will be
8365          caught later */
8366       break;
8367     }
8368 }
8369
8370 /* Return a static string containing the DECL prototype string. If
8371    DECL is a constructor, use the class name instead of the form
8372    <init> */
8373
8374 static const char *
8375 get_printable_method_name (decl)
8376      tree decl;
8377 {
8378   const char *to_return;
8379   tree name = NULL_TREE;
8380
8381   if (DECL_CONSTRUCTOR_P (decl))
8382     {
8383       name = DECL_NAME (decl);
8384       DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
8385     }
8386       
8387   to_return = lang_printable_name (decl, 0);
8388   if (DECL_CONSTRUCTOR_P (decl))
8389     DECL_NAME (decl) = name;
8390   
8391   return to_return;
8392 }
8393
8394 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
8395    nevertheless needs to be verfied, 1 otherwise.  */
8396
8397 static int
8398 reset_method_name (method)
8399      tree method;
8400 {
8401   if (!DECL_CLINIT_P (method) && !DECL_FINIT_P (method))
8402     {
8403       /* NAME is just the plain name when Object is being defined */
8404       if (DECL_CONTEXT (method) != object_type_node)
8405         DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ? 
8406                               init_identifier_node : GET_METHOD_NAME (method));
8407       return 0;
8408     }
8409   else 
8410     return 1;
8411 }
8412
8413 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
8414
8415 tree
8416 java_get_real_method_name (method_decl)
8417      tree method_decl;
8418 {
8419   tree method_name = DECL_NAME (method_decl);
8420   if (DECL_CONSTRUCTOR_P (method_decl))
8421     return init_identifier_node;
8422
8423   /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
8424      and still can be a constructor. FIXME */
8425
8426   /* Don't confuse method only bearing the name of their class as
8427      constructors */
8428   else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
8429            && ctxp
8430            && GET_CPC_UN () == EXPR_WFL_NODE (method_name)
8431            && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
8432            && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
8433     return init_identifier_node;
8434   else
8435     return EXPR_WFL_NODE (method_name);
8436 }
8437
8438 /* Track method being redefined inside the same class. As a side
8439    effect, set DECL_NAME to an IDENTIFIER (prior entering this
8440    function it's a FWL, so we can track errors more accurately.)  */
8441
8442 static int
8443 check_method_redefinition (class, method)
8444      tree class, method;
8445 {
8446   tree redef, name;
8447   tree cl = DECL_NAME (method);
8448   tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
8449   /* decl name of artificial <clinit> and $finit$ doesn't need to be
8450      fixed and checked */
8451
8452   /* Reset the method name before running the check. If it returns 1,
8453      the method doesn't need to be verified with respect to method
8454      redeclaration and we return 0 */
8455   if (reset_method_name (method))
8456     return 0;
8457
8458   name = DECL_NAME (method);
8459   for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
8460     {
8461       if (redef == method)
8462         break;
8463       if (DECL_NAME (redef) == name 
8464           && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
8465         {
8466           parse_error_context 
8467             (cl, "Duplicate %s declaration `%s'",
8468              (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
8469              get_printable_method_name (redef));
8470           return 1;
8471         }
8472     }
8473   return 0;
8474 }
8475
8476 static void
8477 check_abstract_method_definitions (do_interface, class_decl, type)
8478      int do_interface;
8479      tree class_decl, type;
8480 {
8481   tree class = TREE_TYPE (class_decl);
8482   tree method, end_type;
8483
8484   end_type = (do_interface ? object_type_node : type);
8485   for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
8486     {
8487       tree other_super, other_method, method_sig, method_name;
8488       int found = 0;
8489       int end_type_reached = 0;
8490       
8491       if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
8492         continue;
8493       
8494       /* Now verify that somewhere in between TYPE and CLASS,
8495          abstract method METHOD gets a non abstract definition
8496          that is inherited by CLASS.  */
8497       
8498       method_sig = build_java_signature (TREE_TYPE (method));
8499       method_name = DECL_NAME (method);
8500       if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
8501         method_name = EXPR_WFL_NODE (method_name);
8502
8503       other_super = class;
8504       do {
8505         if (other_super == end_type)
8506           end_type_reached = 1;
8507         
8508         /* Method search */
8509         for (other_method = TYPE_METHODS (other_super); other_method;
8510             other_method = TREE_CHAIN (other_method))
8511           {
8512             tree s = build_java_signature (TREE_TYPE (other_method));
8513             tree other_name = DECL_NAME (other_method);
8514             
8515             if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
8516               other_name = EXPR_WFL_NODE (other_name);
8517             if (!DECL_CLINIT_P (other_method)
8518                 && !DECL_CONSTRUCTOR_P (other_method)
8519                 && method_name == other_name && method_sig == s)
8520              {
8521                found = 1;
8522                break;
8523              }
8524           }
8525         other_super = CLASSTYPE_SUPER (other_super);
8526       } while (!end_type_reached);
8527  
8528       /* Report that abstract METHOD didn't find an implementation
8529          that CLASS can use. */
8530       if (!found)
8531         {
8532           char *t = xstrdup (lang_printable_name 
8533                             (TREE_TYPE (TREE_TYPE (method)), 0));
8534           tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
8535           tree saved_wfl = NULL_TREE;
8536           
8537           if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION)
8538             {
8539               saved_wfl = DECL_NAME (method);
8540               DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
8541             }
8542           
8543           parse_error_context 
8544             (lookup_cl (class_decl),
8545              "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",
8546              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8547              t, lang_printable_name (method, 0), 
8548              (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ? 
8549               "interface" : "class"),
8550              IDENTIFIER_POINTER (ccn),
8551              (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
8552              IDENTIFIER_POINTER (DECL_NAME (class_decl)));
8553           
8554           free (t);
8555           
8556           if (saved_wfl)
8557             DECL_NAME (method) = saved_wfl;
8558         }
8559     }
8560 }
8561
8562 /* Check that CLASS_DECL somehow implements all inherited abstract
8563    methods.  */
8564
8565 static void
8566 java_check_abstract_method_definitions (class_decl)
8567      tree class_decl;
8568 {
8569   tree class = TREE_TYPE (class_decl);
8570   tree super, vector;
8571   int i;
8572
8573   if (CLASS_ABSTRACT (class_decl))
8574     return;
8575
8576   /* Check for inherited types */
8577   super = class;
8578   do {
8579     super = CLASSTYPE_SUPER (super);
8580     check_abstract_method_definitions (0, class_decl, super);
8581   } while (super != object_type_node);
8582
8583   /* Check for implemented interfaces. */
8584   vector = TYPE_BINFO_BASETYPES (class);
8585   for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
8586     {
8587       super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
8588       check_abstract_method_definitions (1, class_decl, super);
8589     }
8590 }
8591
8592 /* Check all the types method DECL uses and return 1 if all of them
8593    are now complete, 0 otherwise. This is used to check whether its
8594    safe to build a method signature or not.  */
8595
8596 static int
8597 check_method_types_complete (decl)
8598      tree decl;
8599 {
8600   tree type = TREE_TYPE (decl);
8601   tree args;
8602
8603   if (!INCOMPLETE_TYPE_P (TREE_TYPE (type)))
8604     return 0;
8605   
8606   args = TYPE_ARG_TYPES (type);
8607   if (TREE_CODE (type) == METHOD_TYPE)
8608     args = TREE_CHAIN (args);
8609   for (; args != end_params_node; args = TREE_CHAIN (args))
8610     if (INCOMPLETE_TYPE_P (TREE_VALUE (args)))
8611       return 0;
8612
8613   return 1;
8614 }
8615
8616 /* Check all the methods of CLASS_DECL. Methods are first completed
8617    then checked according to regular method existance rules.  If no
8618    constructor for CLASS_DECL were encountered, then build its
8619    declaration.  */
8620
8621 static void
8622 java_check_regular_methods (class_decl)
8623      tree class_decl;
8624 {
8625   int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
8626   tree method;
8627   tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
8628   tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
8629   tree mthrows;
8630
8631   /* It is not necessary to check methods defined in java.lang.Object */
8632   if (class == object_type_node)
8633     return;
8634
8635   if (!TYPE_NVIRTUALS (class))
8636     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8637
8638   /* Should take interfaces into account. FIXME */
8639   for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
8640     {
8641       tree sig;
8642       tree method_wfl = DECL_NAME (method);
8643       int aflags;
8644
8645       /* If we previously found something and its name was saved,
8646          reinstall it now */
8647       if (found && saved_found_wfl)
8648         {
8649           DECL_NAME (found) = saved_found_wfl;
8650           saved_found_wfl = NULL_TREE;
8651         }
8652
8653       /* Check for redefinitions */
8654       if (check_method_redefinition (class, method))
8655         continue;
8656
8657       /* If we see one constructor a mark so we don't generate the
8658          default one. Also skip other verifications: constructors
8659          can't be inherited hence hiden or overriden */
8660      if (DECL_CONSTRUCTOR_P (method))
8661        {
8662          saw_constructor = 1;
8663          continue;
8664        }
8665
8666       /* We verify things thrown by the method. They must inherits from
8667          java.lang.Throwable */
8668       for (mthrows = DECL_FUNCTION_THROWS (method);
8669            mthrows; mthrows = TREE_CHAIN (mthrows))
8670         {
8671           if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
8672             parse_error_context 
8673               (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
8674                IDENTIFIER_POINTER 
8675                  (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
8676         }
8677
8678       sig = build_java_argument_signature (TREE_TYPE (method));
8679       found = lookup_argument_method2 (class, DECL_NAME (method), sig);
8680
8681       /* Inner class can't declare static methods */
8682       if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
8683         {
8684           char *t = xstrdup (lang_printable_name (class, 0));
8685           parse_error_context 
8686             (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
8687              lang_printable_name (method, 0), t);
8688           free (t);
8689         }
8690
8691       /* Nothing overrides or it's a private method. */
8692       if (!found)
8693         continue;
8694       if (METHOD_PRIVATE (found))
8695         {
8696           found = NULL_TREE;
8697           continue;
8698         }
8699
8700       /* If found wasn't verified, it's DECL_NAME won't be set properly. 
8701          We set it temporarily for the sake of the error report. */
8702       saved_found_wfl = DECL_NAME (found);
8703       reset_method_name (found);
8704
8705       /* If `found' is declared in an interface, make sure the
8706          modifier matches. */
8707       if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found))) 
8708           && clinit_identifier_node != DECL_NAME (found)
8709           && !METHOD_PUBLIC (method))
8710         {
8711           tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
8712           parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
8713                                IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8714                                lang_printable_name (method, 0),
8715                                IDENTIFIER_POINTER (DECL_NAME (found_decl)));
8716         }
8717
8718       /* Can't override a method with the same name and different return
8719          types. */
8720       if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
8721         {
8722           char *t = xstrdup 
8723             (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8724           parse_error_context 
8725             (method_wfl,
8726              "Method `%s' was defined with return type `%s' in class `%s'", 
8727              lang_printable_name (found, 0), t,
8728              IDENTIFIER_POINTER 
8729                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8730           free (t);
8731         }
8732
8733       aflags = get_access_flags_from_decl (found);
8734       /* If the method has default, access in an other package, then
8735          issue a warning that the current method doesn't override the
8736          one that was found elsewhere. Do not issue this warning when
8737          the match was found in java.lang.Object.  */
8738       if (DECL_CONTEXT (found) != object_type_node
8739           && ((aflags & ACC_VISIBILITY) == 0)
8740           && !class_in_current_package (DECL_CONTEXT (found))
8741           && !DECL_CLINIT_P (found)
8742           && flag_not_overriding)
8743         {
8744           parse_warning_context 
8745             (method_wfl, "Method `%s' in class `%s' does not override the corresponding method in class `%s', which is private to a different package",
8746              lang_printable_name (found, 0),
8747              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8748              IDENTIFIER_POINTER (DECL_NAME 
8749                                  (TYPE_NAME (DECL_CONTEXT (found)))));
8750           continue;
8751         }
8752
8753       /* Can't override final. Can't override static. */
8754       if (METHOD_FINAL (found) || METHOD_STATIC (found))
8755         {
8756           /* Static *can* override static */
8757           if (METHOD_STATIC (found) && METHOD_STATIC (method))
8758             continue;
8759           parse_error_context 
8760             (method_wfl,
8761              "%s methods can't be overriden. Method `%s' is %s in class `%s'",
8762              (METHOD_FINAL (found) ? "Final" : "Static"),
8763              lang_printable_name (found, 0),
8764              (METHOD_FINAL (found) ? "final" : "static"),
8765              IDENTIFIER_POINTER
8766                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8767           continue;
8768         }
8769
8770       /* Static method can't override instance method. */
8771       if (METHOD_STATIC (method))
8772         {
8773           parse_error_context 
8774             (method_wfl,
8775              "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'",
8776              lang_printable_name (found, 0),
8777              IDENTIFIER_POINTER
8778                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8779           continue;
8780         }
8781
8782       /* - Overriding/hiding public must be public
8783          - Overriding/hiding protected must be protected or public
8784          - If the overriden or hidden method has default (package)
8785            access, then the overriding or hiding method must not be
8786            private; otherwise, a compile-time error occurs.  If
8787            `found' belongs to an interface, things have been already
8788            taken care of.  */
8789       if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8790           && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
8791               || (METHOD_PROTECTED (found) 
8792                   && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
8793               || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
8794                   && METHOD_PRIVATE (method))))
8795         {
8796           parse_error_context 
8797             (method_wfl,
8798              "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
8799              (METHOD_PUBLIC (method) ? "public" : 
8800               (METHOD_PRIVATE (method) ? "private" : "protected")),
8801              IDENTIFIER_POINTER (DECL_NAME 
8802                                  (TYPE_NAME (DECL_CONTEXT (found)))));
8803           continue;
8804         }
8805
8806       /* Overriding methods must have compatible `throws' clauses on checked
8807          exceptions, if any */
8808       check_throws_clauses (method, method_wfl, found);
8809
8810       /* Inheriting multiple methods with the same signature. FIXME */
8811     }
8812   
8813   /* Don't forget eventual pending found and saved_found_wfl. Take
8814      into account that we might have exited because we saw an
8815      artificial method as the last entry. */
8816
8817   if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
8818     DECL_NAME (found) = saved_found_wfl;
8819
8820   if (!TYPE_NVIRTUALS (class))
8821     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8822
8823   /* Search for inherited abstract method not yet implemented in this
8824      class.  */
8825   java_check_abstract_method_definitions (class_decl);
8826
8827   if (!saw_constructor)
8828     fatal ("No constructor found");
8829 }
8830
8831 /* Return a non zero value if the `throws' clause of METHOD (if any)
8832    is incompatible with the `throws' clause of FOUND (if any).  */
8833
8834 static void
8835 check_throws_clauses (method, method_wfl, found)
8836      tree method, method_wfl, found;
8837 {
8838   tree mthrows, fthrows;
8839
8840   /* Can't check these things with class loaded from bytecode. FIXME */
8841   if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
8842     return;
8843
8844   for (mthrows = DECL_FUNCTION_THROWS (method);
8845        mthrows; mthrows = TREE_CHAIN (mthrows))
8846     {
8847       /* We don't verify unchecked expressions */
8848       if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
8849         continue;
8850       /* Checked expression must be compatible */
8851       for (fthrows = DECL_FUNCTION_THROWS (found); 
8852            fthrows; fthrows = TREE_CHAIN (fthrows))
8853         if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
8854           break;
8855       if (!fthrows)
8856         {
8857           parse_error_context 
8858             (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'",
8859              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
8860              lang_printable_name (found, 0),
8861              IDENTIFIER_POINTER 
8862                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8863         }
8864     }
8865 }
8866
8867 /* Check abstract method of interface INTERFACE */
8868
8869 static void
8870 java_check_abstract_methods (interface_decl)
8871      tree interface_decl;
8872 {
8873   int i, n;
8874   tree method, basetype_vec, found;
8875   tree interface = TREE_TYPE (interface_decl);
8876
8877   for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
8878     {
8879       tree method_wfl = DECL_NAME (method);
8880
8881       /* 2- Check for double definition inside the defining interface */
8882       if (check_method_redefinition (interface, method))
8883         continue;
8884
8885       /* 3- Overriding is OK as far as we preserve the return type and
8886          the thrown exceptions (FIXME) */
8887       found = lookup_java_interface_method2 (interface, method);
8888       if (found)
8889         {
8890           char *t;
8891           tree saved_found_wfl = DECL_NAME (found);
8892           reset_method_name (found);
8893           t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8894           parse_error_context 
8895             (method_wfl,
8896              "Method `%s' was defined with return type `%s' in class `%s'",
8897              lang_printable_name (found, 0), t,
8898              IDENTIFIER_POINTER 
8899                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8900           free (t);
8901           DECL_NAME (found) = saved_found_wfl;
8902           continue;
8903         }
8904     }
8905
8906   /* 4- Inherited methods can't differ by their returned types */
8907   if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
8908     return;
8909   n = TREE_VEC_LENGTH (basetype_vec);
8910   for (i = 0; i < n; i++)
8911     {
8912       tree sub_interface_method, sub_interface;
8913       tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
8914       if (!vec_elt)
8915         continue;
8916       sub_interface = BINFO_TYPE (vec_elt);
8917       for (sub_interface_method = TYPE_METHODS (sub_interface); 
8918            sub_interface_method;
8919            sub_interface_method = TREE_CHAIN (sub_interface_method))
8920         {
8921           found = lookup_java_interface_method2 (interface, 
8922                                                  sub_interface_method);
8923           if (found && (found != sub_interface_method))
8924             {
8925               tree saved_found_wfl = DECL_NAME (found);
8926               reset_method_name (found);
8927               parse_error_context 
8928                 (lookup_cl (sub_interface_method),
8929                  "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
8930                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
8931                  lang_printable_name (found, 0),
8932                  IDENTIFIER_POINTER 
8933                    (DECL_NAME (TYPE_NAME 
8934                                (DECL_CONTEXT (sub_interface_method)))),
8935                  IDENTIFIER_POINTER 
8936                    (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8937               DECL_NAME (found) = saved_found_wfl;
8938             }
8939         }
8940     }
8941 }
8942
8943 /* Lookup methods in interfaces using their name and partial
8944    signature. Return a matching method only if their types differ.  */
8945
8946 static tree
8947 lookup_java_interface_method2 (class, method_decl)
8948      tree class, method_decl;
8949 {
8950   int i, n;
8951   tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
8952
8953   if (!basetype_vec)
8954     return NULL_TREE;
8955
8956   n = TREE_VEC_LENGTH (basetype_vec);
8957   for (i = 0; i < n; i++)
8958     {
8959       tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
8960       if ((BINFO_TYPE (vec_elt) != object_type_node)
8961           && (to_return = 
8962               lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
8963         return to_return;
8964     }
8965   for (i = 0; i < n; i++)
8966     {
8967       to_return = lookup_java_interface_method2 
8968         (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
8969       if (to_return)
8970         return to_return;
8971     }
8972
8973   return NULL_TREE;
8974 }
8975
8976 /* Lookup method using their name and partial signature. Return a
8977    matching method only if their types differ.  */
8978
8979 static tree
8980 lookup_java_method2 (clas, method_decl, do_interface)
8981      tree clas, method_decl;
8982      int do_interface;
8983 {
8984   tree method, method_signature, method_name, method_type, name;
8985
8986   method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
8987   name = DECL_NAME (method_decl);
8988   method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ? 
8989                  EXPR_WFL_NODE (name) : name);
8990   method_type = TREE_TYPE (TREE_TYPE (method_decl));
8991
8992   while (clas != NULL_TREE)
8993     {
8994       for (method = TYPE_METHODS (clas);
8995            method != NULL_TREE;  method = TREE_CHAIN (method))
8996         {
8997           tree method_sig = build_java_argument_signature (TREE_TYPE (method));
8998           tree name = DECL_NAME (method);
8999           if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
9000                EXPR_WFL_NODE (name) : name) == method_name
9001               && method_sig == method_signature 
9002               && TREE_TYPE (TREE_TYPE (method)) != method_type)
9003             return method;
9004         }
9005       clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
9006     }
9007   return NULL_TREE;
9008 }
9009
9010 /* Return the line that matches DECL line number, and try its best to
9011    position the column number. Used during error reports.  */
9012
9013 static tree
9014 lookup_cl (decl)
9015      tree decl;
9016 {
9017   static tree cl = NULL_TREE;
9018   char *line, *found;
9019   
9020   if (!decl)
9021     return NULL_TREE;
9022
9023   if (cl == NULL_TREE)
9024     cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
9025
9026   EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
9027   EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
9028
9029   line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
9030                             EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
9031
9032   found = strstr ((const char *)line, 
9033                   (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
9034   if (found)
9035     EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line);
9036
9037   return cl;
9038 }
9039
9040 /* Look for a simple name in the single-type import list */
9041
9042 static tree
9043 find_name_in_single_imports (name)
9044      tree name;
9045 {
9046   tree node;
9047
9048   for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
9049     if (TREE_VALUE (node) == name)
9050       return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
9051
9052   return NULL_TREE;
9053 }
9054
9055 /* Process all single-type import. */
9056
9057 static int
9058 process_imports ()
9059 {
9060   tree import;
9061   int error_found;
9062
9063   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9064     {
9065       tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
9066
9067       /* Don't load twice something already defined. */
9068       if (IDENTIFIER_CLASS_VALUE (to_be_found))
9069         continue;
9070       QUALIFIED_P (to_be_found) = 1;
9071       load_class (to_be_found, 0);
9072       error_found =
9073         check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
9074       if (!IDENTIFIER_CLASS_VALUE (to_be_found))
9075         {
9076           parse_error_context (TREE_PURPOSE (import),
9077                                "Class or interface `%s' not found in import",
9078                                IDENTIFIER_POINTER (to_be_found));
9079           return 1;
9080         }
9081       if (error_found)
9082         return 1;
9083     }
9084   return 0;
9085 }
9086
9087 /* Possibly find a class imported by a single-type import statement. Return
9088    1 if an error occured, 0 otherwise. */
9089
9090 static int
9091 find_in_imports (class_type)
9092      tree class_type;
9093 {
9094   tree import;
9095
9096   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9097     if (TREE_VALUE (import) == TYPE_NAME (class_type))
9098       {
9099         TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
9100         QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9101       }
9102   return 0;
9103 }
9104
9105 static int
9106 note_possible_classname (name, len)
9107      const char *name;
9108      int len;
9109 {
9110   tree node;
9111   if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
9112     len = len - 5;
9113   else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
9114     len = len - 6;
9115   else
9116     return 0;
9117   node = ident_subst (name, len, "", '/', '.', "");
9118   IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
9119   QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
9120   return 1;
9121 }
9122
9123 /* Read a import directory, gathering potential match for further type
9124    references. Indifferently reads a filesystem or a ZIP archive
9125    directory.  */
9126
9127 static void
9128 read_import_dir (wfl)
9129      tree wfl;
9130 {
9131   tree package_id = EXPR_WFL_NODE (wfl);
9132   const char *package_name = IDENTIFIER_POINTER (package_id);
9133   int package_length = IDENTIFIER_LENGTH (package_id);
9134   DIR *dirp = NULL;
9135   JCF *saved_jcf = current_jcf;
9136
9137   int found = 0;
9138   int k;
9139   void *entry;
9140   struct buffer filename[1];
9141
9142
9143   if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
9144     return;
9145   IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
9146
9147   BUFFER_INIT (filename);
9148   buffer_grow (filename, package_length + 100);
9149
9150   for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
9151     {
9152       const char *entry_name = jcf_path_name (entry);
9153       int entry_length = strlen (entry_name);
9154       if (jcf_path_is_zipfile (entry))
9155         {
9156           ZipFile *zipf;
9157           buffer_grow (filename, entry_length);
9158           memcpy (filename->data, entry_name, entry_length - 1);
9159           filename->data[entry_length-1] = '\0';
9160           zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
9161           if (zipf == NULL)
9162             error ("malformed .zip archive in CLASSPATH: %s", entry_name);
9163           else
9164             {
9165               ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
9166               BUFFER_RESET (filename);
9167               for (k = 0; k < package_length; k++)
9168                 {
9169                   char ch = package_name[k];
9170                   *filename->ptr++ = ch == '.' ? '/' : ch;
9171                 }
9172               *filename->ptr++ = '/';
9173
9174               for (k = 0; k < zipf->count;  k++, zipd = ZIPDIR_NEXT (zipd))
9175                 {
9176                   const char *current_entry = ZIPDIR_FILENAME (zipd);
9177                   int current_entry_len = zipd->filename_length;
9178
9179                   if (current_entry_len >= BUFFER_LENGTH (filename)
9180                       && strncmp (filename->data, current_entry, 
9181                                   BUFFER_LENGTH (filename)) != 0)
9182                     continue;
9183                   found |= note_possible_classname (current_entry,
9184                                                     current_entry_len);
9185                 }
9186             }
9187         }
9188       else
9189         {
9190           BUFFER_RESET (filename);
9191           buffer_grow (filename, entry_length + package_length + 4);
9192           strcpy (filename->data, entry_name);
9193           filename->ptr = filename->data + entry_length;
9194           for (k = 0; k < package_length; k++)
9195             {
9196               char ch = package_name[k];
9197               *filename->ptr++ = ch == '.' ? '/' : ch;
9198             }
9199           *filename->ptr = '\0';
9200
9201           dirp = opendir (filename->data);
9202           if (dirp == NULL)
9203             continue;
9204           *filename->ptr++ = '/';
9205           for (;;)
9206             {
9207               int len; 
9208               const char *d_name;
9209               struct dirent *direntp = readdir (dirp);
9210               if (!direntp)
9211                 break;
9212               d_name = direntp->d_name;
9213               len = strlen (direntp->d_name);
9214               buffer_grow (filename, len+1);
9215               strcpy (filename->ptr, d_name);
9216               found |= note_possible_classname (filename->data + entry_length,
9217                                                 package_length+len+1);
9218             }
9219           if (dirp)
9220             closedir (dirp);
9221         }
9222     }
9223
9224   free (filename->data);
9225
9226   /* Here we should have a unified way of retrieving an entry, to be
9227      indexed. */
9228   if (!found)
9229     {
9230       static int first = 1;
9231       if (first)
9232         {
9233           error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives.", package_name);
9234           java_error_count++;
9235           first = 0;
9236         }
9237       else
9238         parse_error_context (wfl, "Package `%s' not found in import",
9239                              package_name);
9240       current_jcf = saved_jcf;
9241       return;
9242     }
9243   current_jcf = saved_jcf;
9244 }
9245
9246 /* Possibly find a type in the import on demands specified
9247    types. Returns 1 if an error occured, 0 otherwise. Run throught the
9248    entire list, to detected potential double definitions.  */
9249                  
9250 static int
9251 find_in_imports_on_demand (class_type)
9252      tree class_type;
9253 {
9254   tree node, import, node_to_use = NULL_TREE;
9255   int seen_once = -1;
9256   tree cl = NULL_TREE;
9257
9258   for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
9259     {
9260       const char *id_name;
9261       obstack_grow (&temporary_obstack, 
9262                     IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
9263                     IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9264       obstack_1grow (&temporary_obstack, '.');
9265       obstack_grow0 (&temporary_obstack, 
9266                      IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9267                      IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
9268       id_name = obstack_finish (&temporary_obstack);
9269               
9270       node = maybe_get_identifier (id_name);
9271       if (node && IS_A_CLASSFILE_NAME (node))
9272         {
9273           if (seen_once < 0)
9274             {
9275               cl = TREE_PURPOSE (import);
9276               seen_once = 1;
9277               node_to_use = node;
9278             }
9279           else
9280             {
9281               seen_once++;
9282               parse_error_context 
9283                 (import, "Type `%s' also potentially defined in package `%s'",
9284                  IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9285                  IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9286             }
9287         }
9288     }
9289
9290   if (seen_once == 1)
9291     {
9292       /* Setup lineno so that it refers to the line of the import (in
9293          case we parse a class file and encounter errors */
9294       tree decl;
9295       int saved_lineno = lineno;
9296       lineno = EXPR_WFL_LINENO (cl);
9297       TYPE_NAME (class_type) = node_to_use;
9298       QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9299       decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
9300       /* If there is no DECL set for the class or if the class isn't
9301          loaded and not seen in source yet, the load */
9302       if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
9303                     && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
9304         load_class (node_to_use, 0);
9305       lineno = saved_lineno;
9306       return check_pkg_class_access (TYPE_NAME (class_type), cl);
9307     }
9308   else
9309     return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
9310 }
9311
9312 static tree
9313 resolve_package (pkg, next)
9314      tree pkg, *next;
9315 {
9316   tree current, acc;
9317   tree type_name = NULL_TREE;
9318   const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
9319
9320   /* The trick is to determine when the package name stops and were
9321      the name of something contained in the package starts. Then we
9322      return a fully qualified name of what we want to get. */
9323
9324   /* Do a quick search on well known package names */
9325   if (!strncmp (name, "java.lang.reflect", 17))
9326     {
9327       *next = 
9328         TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
9329       type_name = lookup_package_type (name, 17);
9330     }
9331   else if (!strncmp (name, "java.lang", 9))
9332     {
9333       *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
9334       type_name = lookup_package_type (name, 9);
9335     }
9336
9337   /* If we found something here, return */
9338   if (type_name)
9339     return type_name; 
9340
9341   *next = EXPR_WFL_QUALIFICATION (pkg);
9342
9343   /* Try the current package. */
9344   if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),  
9345                                  IDENTIFIER_LENGTH (ctxp->package)))
9346     {
9347       type_name = 
9348         lookup_package_type_and_set_next (name, 
9349                                           IDENTIFIER_LENGTH (ctxp->package), 
9350                                           next );
9351       if (type_name)
9352         return type_name;
9353     }
9354
9355   /* Search in imported package */
9356   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
9357     {
9358       tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
9359       int len = IDENTIFIER_LENGTH (current_pkg_name);
9360       if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
9361         {
9362           tree left, dummy;
9363           
9364           breakdown_qualified (&left, &dummy, current_pkg_name);
9365           len = IDENTIFIER_LENGTH (left);
9366           type_name = lookup_package_type_and_set_next (name, len, next);
9367           if (type_name)
9368             break;
9369         }
9370     }
9371
9372   /* Try to progressively construct a type name */
9373   if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
9374     for (acc = NULL_TREE, current = EXPR_WFL_QUALIFICATION (pkg); 
9375          current; current = TREE_CHAIN (current))
9376       {
9377         acc = merge_qualified_name (acc, EXPR_WFL_NODE (QUAL_WFL (current)));
9378         if ((type_name = resolve_no_layout (acc, NULL_TREE)))
9379           {
9380             type_name = acc;
9381             /* resolve_package should be used in a loop, hence we
9382                point at this one to naturally process the next one at
9383                the next iteration. */
9384             *next = current;
9385             break;
9386           }
9387       }
9388   return type_name;
9389 }
9390
9391 static tree
9392 lookup_package_type_and_set_next (name, len, next)
9393      const char *name;
9394      int len;
9395      tree *next;
9396 {
9397   const char *ptr;
9398   tree type_name = lookup_package_type (name, len);
9399
9400   if (!type_name)
9401     return NULL;
9402   
9403   ptr = IDENTIFIER_POINTER (type_name);
9404   while (ptr && (ptr = strchr (ptr, '.'))) 
9405     {
9406       *next = TREE_CHAIN (*next);
9407       ptr++;
9408     }
9409   return type_name;
9410 }
9411
9412 static tree
9413 lookup_package_type (name, from)
9414      const char *name;
9415      int from;
9416 {
9417   char subname [128];
9418   const char *sub = &name[from+1];
9419   while (*sub != '.' && *sub)
9420     sub++;
9421   strncpy (subname, name, sub-name);
9422   subname [sub-name] = '\0';
9423   return get_identifier (subname);
9424 }
9425
9426 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
9427    access violations were found, 1 otherwise.  */
9428
9429 static int
9430 check_pkg_class_access (class_name, cl)
9431      tree class_name;
9432      tree cl;
9433 {
9434   tree type;
9435
9436   if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
9437     return 0;
9438
9439   if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
9440     return 0;
9441
9442   if (!CLASS_PUBLIC (TYPE_NAME (type)))
9443     {
9444       /* Access to a private class within the same package is
9445          allowed. */
9446       tree l, r;
9447       breakdown_qualified (&l, &r, class_name);
9448       if (l == ctxp->package)
9449         return 0;
9450
9451       parse_error_context 
9452         (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
9453          (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
9454          IDENTIFIER_POINTER (class_name));
9455       return 1;
9456     }
9457   return 0;
9458 }
9459
9460 /* Local variable declaration. */
9461
9462 static void
9463 declare_local_variables (modifier, type, vlist)
9464      int modifier;
9465      tree type;
9466      tree vlist;
9467 {
9468   tree decl, current, saved_type;
9469   tree type_wfl = NULL_TREE;
9470   int must_chain = 0;
9471   int final_p = 0;
9472
9473   /* Push a new block if statements were seen between the last time we
9474      pushed a block and now. Keep a cound of block to close */
9475   if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
9476     {
9477       tree body = GET_CURRENT_BLOCK (current_function_decl);
9478       tree b = enter_block ();
9479       BLOCK_EXPR_ORIGIN (b) = body;
9480     }
9481
9482   if (modifier)
9483     {
9484       int i;
9485       for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
9486       if (modifier == ACC_FINAL)
9487         final_p = 1;
9488       else 
9489         {
9490           parse_error_context 
9491             (ctxp->modifier_ctx [i], 
9492              "Only `final' is allowed as a local variables modifier");
9493           return;
9494         }
9495     }
9496
9497   /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
9498      hold the TYPE value if a new incomplete has to be created (as
9499      opposed to being found already existing and reused). */
9500   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
9501
9502   /* If TYPE is fully resolved and we don't have a reference, make one */
9503   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9504
9505   /* Go through all the declared variables */
9506   for (current = vlist, saved_type = type; current;
9507        current = TREE_CHAIN (current), type = saved_type)
9508     {
9509       tree other, real_type;
9510       tree wfl  = TREE_PURPOSE (current);
9511       tree name = EXPR_WFL_NODE (wfl);
9512       tree init = TREE_VALUE (current);
9513
9514       /* Process NAME, as it may specify extra dimension(s) for it */
9515       type = build_array_from_name (type, type_wfl, name, &name);
9516
9517       /* Variable redefinition check */
9518       if ((other = lookup_name_in_blocks (name)))
9519         {
9520           variable_redefinition_error (wfl, name, TREE_TYPE (other),
9521                                        DECL_SOURCE_LINE (other));
9522           continue;
9523         }
9524
9525       /* Type adjustment. We may have just readjusted TYPE because
9526          the variable specified more dimensions. Make sure we have
9527          a reference if we can and don't have one already. */
9528       PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9529
9530       real_type = GET_REAL_TYPE (type);
9531       /* Never layout this decl. This will be done when its scope
9532          will be entered */
9533       decl = build_decl (VAR_DECL, name, real_type);
9534       LOCAL_FINAL (decl) = final_p;
9535       BLOCK_CHAIN_DECL (decl);
9536       
9537       /* If doing xreferencing, replace the line number with the WFL
9538          compound value */
9539       if (flag_emit_xref)
9540         DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
9541       
9542       /* Don't try to use an INIT statement when an error was found */
9543       if (init && java_error_count)
9544         init = NULL_TREE;
9545       
9546       /* Add the initialization function to the current function's code */
9547       if (init)
9548         {
9549           /* Name might have been readjusted */
9550           EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
9551           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
9552           java_method_add_stmt (current_function_decl,
9553                                 build_debugable_stmt (EXPR_WFL_LINECOL (init),
9554                                                       init));
9555         }
9556     
9557       /* Setup dependency the type of the decl */
9558       if (must_chain)
9559         {
9560           jdep *dep;
9561           register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
9562           dep = CLASSD_LAST (ctxp->classd_list);
9563           JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
9564         }
9565     }
9566   SOURCE_FRONTEND_DEBUG (("Defined locals"));
9567 }
9568
9569 /* Called during parsing. Build decls from argument list.  */
9570
9571 static void
9572 source_start_java_method (fndecl)
9573      tree fndecl;
9574 {
9575   tree tem;
9576   tree parm_decl;
9577   int i;
9578
9579   if (!fndecl)
9580     return;
9581
9582   current_function_decl = fndecl;
9583
9584   /* New scope for the function */
9585   enter_block ();
9586   for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
9587        tem != end_params_node; tem = TREE_CHAIN (tem), i++)
9588     {
9589       tree type = TREE_VALUE (tem);
9590       tree name = TREE_PURPOSE (tem);
9591       
9592       /* If type is incomplete. Create an incomplete decl and ask for
9593          the decl to be patched later */
9594       if (INCOMPLETE_TYPE_P (type))
9595         {
9596           jdep *jdep;
9597           tree real_type = GET_REAL_TYPE (type);
9598           parm_decl = build_decl (PARM_DECL, name, real_type);
9599           type = obtain_incomplete_type (type);
9600           register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
9601           jdep = CLASSD_LAST (ctxp->classd_list);
9602           JDEP_MISC (jdep) = name;
9603           JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
9604         }
9605       else
9606         parm_decl = build_decl (PARM_DECL, name, type);
9607
9608       /* Remember if a local variable was declared final (via its
9609          TREE_LIST of type/name.) Set LOCAL_FINAL accordingly. */
9610       if (ARG_FINAL_P (tem))
9611         LOCAL_FINAL (parm_decl) = 1;
9612
9613       BLOCK_CHAIN_DECL (parm_decl);
9614     }
9615   tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9616   BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
9617     nreverse (tem);
9618   DECL_ARG_SLOT_COUNT (current_function_decl) = i;
9619   DECL_MAX_LOCALS (current_function_decl) = i;
9620 }
9621
9622 /* Called during parsing. Creates an artificial method declaration.  */
9623
9624 static tree
9625 create_artificial_method (class, flags, type, name, args)
9626      tree class;
9627      int flags;
9628      tree type, name, args;
9629 {
9630   tree mdecl;
9631
9632   java_parser_context_save_global ();
9633   lineno = 0;                                                               
9634   mdecl = make_node (FUNCTION_TYPE);                                
9635   TREE_TYPE (mdecl) = type;
9636   TYPE_ARG_TYPES (mdecl) = args;
9637   mdecl = add_method (class, flags, name, build_java_signature (mdecl)); 
9638   java_parser_context_restore_global ();
9639   DECL_ARTIFICIAL (mdecl) = 1;                                      
9640   return mdecl;
9641 }
9642
9643 /* Starts the body if an artifical method.  */
9644
9645 static void
9646 start_artificial_method_body (mdecl)
9647      tree mdecl;
9648 {
9649   DECL_SOURCE_LINE (mdecl) = 1;
9650   DECL_SOURCE_LINE_MERGE (mdecl, 1);
9651   source_start_java_method (mdecl);
9652   enter_block ();
9653 }
9654
9655 static void
9656 end_artificial_method_body (mdecl)
9657      tree mdecl;
9658 {
9659   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
9660   exit_block ();
9661 }
9662
9663 /* Called during expansion. Push decls formerly built from argument
9664    list so they're usable during expansion. */
9665
9666 static void
9667 expand_start_java_method (fndecl)
9668      tree fndecl;
9669 {
9670   tree tem, *ptr;
9671
9672   current_function_decl = fndecl;
9673
9674   if (! quiet_flag)
9675     fprintf (stderr, " [%s.", lang_printable_name (DECL_CONTEXT (fndecl), 0));
9676   announce_function (fndecl);
9677   if (! quiet_flag)
9678     fprintf (stderr, "]");
9679
9680   pushlevel (1);                /* Prepare for a parameter push */
9681   ptr = &DECL_ARGUMENTS (fndecl);
9682   tem  = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9683   while (tem)
9684     {
9685       tree next = TREE_CHAIN (tem);
9686       tree type = TREE_TYPE (tem);
9687       if (PROMOTE_PROTOTYPES
9688           && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
9689           && INTEGRAL_TYPE_P (type))
9690         type = integer_type_node;
9691       DECL_ARG_TYPE (tem) = type;
9692       layout_decl (tem, 0);
9693       pushdecl (tem);
9694       *ptr = tem;
9695       ptr = &TREE_CHAIN (tem);
9696       tem = next;
9697     }
9698   *ptr = NULL_TREE;
9699   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9700   lineno = DECL_SOURCE_LINE_FIRST (fndecl);
9701 }
9702
9703 /* Terminate a function and expand its body.  */
9704
9705 static void
9706 source_end_java_method ()
9707 {
9708   tree fndecl = current_function_decl;
9709   int flag_asynchronous_exceptions = asynchronous_exceptions;
9710
9711   if (!fndecl)
9712     return;
9713
9714   java_parser_context_save_global ();
9715   lineno = ctxp->last_ccb_indent1;
9716
9717   /* Set EH language codes */
9718   java_set_exception_lang_code ();
9719
9720   /* Turn function bodies with only a NOP expr null, so they don't get
9721      generated at all and we won't get warnings when using the -W
9722      -Wall flags. */
9723   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
9724     BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
9725
9726   /* Generate function's code */
9727   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
9728       && ! flag_emit_class_files
9729       && ! flag_emit_xref)
9730     expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
9731
9732   /* pop out of its parameters */
9733   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9734   poplevel (1, 0, 1);
9735   BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
9736
9737   /* Generate rtl for function exit.  */
9738   if (! flag_emit_class_files && ! flag_emit_xref)
9739     {
9740       lineno = DECL_SOURCE_LINE_LAST (fndecl);
9741       /* Emit catch-finally clauses */
9742       emit_handlers ();
9743       expand_function_end (input_filename, lineno, 0);
9744
9745       /* FIXME: If the current method contains any exception handlers,
9746          force asynchronous_exceptions: this is necessary because signal
9747          handlers in libjava may throw exceptions.  This is far from being
9748          a perfect solution, but it's better than doing nothing at all.*/
9749       if (catch_clauses)
9750         asynchronous_exceptions = 1;
9751
9752       /* Run the optimizers and output assembler code for this function. */
9753       rest_of_compilation (fndecl);
9754     }
9755
9756   current_function_decl = NULL_TREE;
9757   permanent_allocation (1);
9758   java_parser_context_restore_global ();
9759   asynchronous_exceptions = flag_asynchronous_exceptions;
9760 }
9761
9762 /* Record EXPR in the current function block. Complements compound
9763    expression second operand if necessary.  */
9764
9765 tree
9766 java_method_add_stmt (fndecl, expr)
9767      tree fndecl, expr;
9768 {
9769   if (!GET_CURRENT_BLOCK (fndecl))
9770     return NULL_TREE;
9771   return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
9772 }
9773
9774 static tree
9775 add_stmt_to_block (b, type, stmt)
9776      tree b, type, stmt;
9777 {
9778   tree body = BLOCK_EXPR_BODY (b), c;
9779   
9780   if (java_error_count)
9781     return body;
9782     
9783   if ((c = add_stmt_to_compound (body, type, stmt)) == body)
9784     return body;
9785
9786   BLOCK_EXPR_BODY (b) = c;
9787   TREE_SIDE_EFFECTS (c) = 1;
9788   return c;
9789 }
9790
9791 /* Add STMT to EXISTING if possible, otherwise create a new
9792    COMPOUND_EXPR and add STMT to it. */
9793
9794 static tree
9795 add_stmt_to_compound (existing, type, stmt)
9796      tree existing, type, stmt;
9797 {
9798   if (existing)
9799     return build (COMPOUND_EXPR, type, existing, stmt);
9800   else
9801     return stmt;
9802 }
9803
9804 /* Hold THIS for the scope of the current public method decl.  */
9805 static tree current_this;
9806
9807 void java_layout_seen_class_methods ()
9808 {
9809   tree previous_list = all_class_list;
9810   tree end = NULL_TREE;
9811   tree current;
9812
9813   while (1)
9814     {
9815       for (current = previous_list; 
9816            current != end; current = TREE_CHAIN (current))
9817         layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
9818       
9819       if (previous_list != all_class_list)
9820         {
9821           end = previous_list;
9822           previous_list = all_class_list;
9823         }
9824       else
9825         break;
9826     }
9827 }
9828
9829 void
9830 java_reorder_fields ()
9831 {
9832   static tree stop_reordering = NULL_TREE;
9833
9834   tree current;
9835   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9836     {
9837       current_class = TREE_TYPE (TREE_VALUE (current));
9838
9839       if (current_class == stop_reordering)
9840         break;
9841
9842       /* Reverse the fields, but leave the dummy field in front.
9843          Fields are already ordered for Object and Class */
9844       if (TYPE_FIELDS (current_class) && current_class != object_type_node
9845           && current_class != class_type_node)
9846       {
9847         /* If the dummy field is there, reverse the right fields and
9848            just layout the type for proper fields offset */
9849         if (!DECL_NAME (TYPE_FIELDS (current_class)))
9850           {
9851             tree fields = TYPE_FIELDS (current_class);
9852             TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
9853             TYPE_SIZE (current_class) = NULL_TREE;
9854           }
9855         /* We don't have a dummy field, we need to layout the class,
9856            after having reversed the fields */
9857         else
9858           {
9859             TYPE_FIELDS (current_class) = 
9860               nreverse (TYPE_FIELDS (current_class));
9861             TYPE_SIZE (current_class) = NULL_TREE;
9862           }
9863       }
9864     }
9865   stop_reordering = TREE_TYPE (TREE_VALUE (ctxp->gclass_list));
9866 }
9867
9868 /* Layout the methods of all classes loaded in one way on an
9869    other. Check methods of source parsed classes. Then reorder the
9870    fields and layout the classes or the type of all source parsed
9871    classes */
9872
9873 void
9874 java_layout_classes ()
9875 {
9876   tree current;
9877   int save_error_count = java_error_count;
9878
9879   /* Layout the methods of all classes seen so far */
9880   java_layout_seen_class_methods ();
9881   java_parse_abort_on_error ();
9882   all_class_list = NULL_TREE;
9883
9884   /* Then check the methods of all parsed classes */
9885   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9886     if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
9887       CHECK_METHODS (TREE_VALUE (current));
9888   java_parse_abort_on_error ();
9889
9890   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9891     {
9892       current_class = TREE_TYPE (TREE_VALUE (current));
9893       layout_class (current_class);
9894
9895       /* From now on, the class is considered completely loaded */
9896       CLASS_LOADED_P (current_class) = 1;
9897
9898       /* Error reported by the caller */
9899       if (java_error_count)
9900         return;
9901     }
9902
9903   /* We might have reloaded classes durign the process of laying out
9904      classes for code generation. We must layout the methods of those
9905      late additions, as constructor checks might use them */
9906   java_layout_seen_class_methods ();
9907   java_parse_abort_on_error ();
9908 }
9909
9910 /* Expand methods in the current set of classes rememebered for
9911    generation.  */
9912
9913 static void
9914 java_complete_expand_classes ()
9915 {
9916   tree current;
9917
9918   do_not_fold = flag_emit_xref;
9919
9920   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
9921     if (!INNER_CLASS_DECL_P (current))
9922       java_complete_expand_class (current);
9923 }
9924
9925 /* Expand the methods found in OUTER, starting first by OUTER's inner
9926    classes, if any.  */
9927
9928 static void
9929 java_complete_expand_class (outer)
9930      tree outer;
9931 {
9932   tree inner_list;
9933
9934   set_nested_class_simple_name_value (outer, 1); /* Set */
9935
9936   /* We need to go after all inner classes and start expanding them,
9937      starting with most nested ones. We have to do that because nested
9938      classes might add functions to outer classes */
9939
9940   for (inner_list = DECL_INNER_CLASS_LIST (outer);
9941        inner_list; inner_list = TREE_CHAIN (inner_list))
9942     java_complete_expand_class (TREE_PURPOSE (inner_list));
9943
9944   java_complete_expand_methods (outer);
9945   set_nested_class_simple_name_value (outer, 0); /* Reset */
9946 }
9947
9948 /* Expand methods registered in CLASS_DECL. The general idea is that
9949    we expand regular methods first. This allows us get an estimate on
9950    how outer context local alias fields are really used so we can add
9951    to the constructor just enough code to initialize them properly (it
9952    also lets us generate $finit$ correctly.) Then we expand the
9953    constructors and then <clinit>.  */
9954
9955 static void
9956 java_complete_expand_methods (class_decl)
9957      tree class_decl;
9958 {
9959   tree clinit, finit, decl, first_decl;
9960
9961   current_class = TREE_TYPE (class_decl);
9962
9963   /* Initialize a new constant pool */
9964   init_outgoing_cpool ();
9965
9966   /* Pre-expand <clinit> to figure whether we really need it or
9967      not. If we do need it, we pre-expand the static fields so they're
9968      ready to be used somewhere else. <clinit> will be fully expanded
9969      after we processed the constructors. */
9970   first_decl = TYPE_METHODS (current_class);
9971   clinit = maybe_generate_pre_expand_clinit (current_class);
9972
9973   /* Then generate $finit$ (if we need to) because constructor will
9974    try to use it.*/
9975   if (TYPE_FINIT_STMT_LIST (current_class))
9976     {
9977       finit = generate_finit (current_class);
9978       java_complete_expand_method (finit);
9979     }
9980
9981   /* Now do the constructors */
9982   for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
9983     {
9984       int no_body;
9985
9986       if (!DECL_CONSTRUCTOR_P (decl))
9987         continue;
9988       
9989       no_body = !DECL_FUNCTION_BODY (decl);
9990       /* Don't generate debug info on line zero when expanding a
9991          generated constructor. */
9992       if (no_body)
9993         restore_line_number_status (1);
9994
9995       java_complete_expand_method (decl);
9996       
9997       if (no_body)
9998         restore_line_number_status (0);
9999     }
10000
10001   /* First, do the ordinary methods. */
10002   for (decl = first_decl; decl; decl = TREE_CHAIN (decl))
10003     {
10004       /* Skip abstract or native methods -- but do handle native
10005          methods when generating JNI stubs.  */
10006       if (METHOD_ABSTRACT (decl)
10007           || (! flag_jni && METHOD_NATIVE (decl))
10008           || DECL_CONSTRUCTOR_P (decl) || DECL_CLINIT_P (decl))
10009         continue;
10010
10011       if (METHOD_NATIVE (decl))
10012         {
10013           tree body = build_jni_stub (decl);
10014           BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl)) = body;
10015         }
10016
10017       java_complete_expand_method (decl);
10018     }
10019
10020   /* If there is indeed a <clinit>, fully expand it now */
10021   if (clinit)
10022     {
10023       /* Prevent the use of `this' inside <clinit> */
10024       ctxp->explicit_constructor_p = 1;
10025       java_complete_expand_method (clinit);
10026       ctxp->explicit_constructor_p = 0;
10027     }
10028   
10029   /* We might have generated a class$ that we now want to expand */
10030   if (TYPE_DOT_CLASS (current_class))
10031     java_complete_expand_method (TYPE_DOT_CLASS (current_class));
10032
10033   /* Now verify constructor circularity (stop after the first one we
10034      prove wrong.) */
10035   if (!CLASS_INTERFACE (class_decl))
10036     for (decl = TYPE_METHODS (current_class); decl; decl = TREE_CHAIN (decl))
10037       if (DECL_CONSTRUCTOR_P (decl) 
10038           && verify_constructor_circularity (decl, decl))
10039         break;
10040
10041   /* Save the constant pool. We'll need to restore it later. */
10042   TYPE_CPOOL (current_class) = outgoing_cpool;
10043 }
10044
10045 /* Hold a list of catch clauses list. The first element of this list is
10046    the list of the catch clauses of the currently analysed try block. */
10047 static tree currently_caught_type_list;
10048
10049 /* Attempt to create <clinit>. Pre-expand static fields so they can be
10050    safely used in some other methods/constructors.  */
10051
10052 static tree
10053 maybe_generate_pre_expand_clinit (class_type)
10054      tree class_type;
10055 {
10056   tree current, mdecl;
10057
10058   if (!TYPE_CLINIT_STMT_LIST (class_type))
10059     return NULL_TREE;
10060
10061   /* Go through all static fields and pre expand them */
10062   for (current = TYPE_FIELDS (class_type); current; 
10063        current = TREE_CHAIN (current))
10064     if (FIELD_STATIC (current))
10065       build_field_ref (NULL_TREE, class_type, DECL_NAME (current));
10066
10067   /* Then build the <clinit> method */
10068   mdecl = create_artificial_method (class_type, ACC_STATIC, void_type_node,
10069                                     clinit_identifier_node, end_params_node);
10070   layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
10071                        mdecl, NULL_TREE);
10072   start_artificial_method_body (mdecl);
10073
10074   /* We process the list of assignment we produced as the result of
10075      the declaration of initialized static field and add them as
10076      statement to the <clinit> method. */
10077   for (current = TYPE_CLINIT_STMT_LIST (class_type); current;
10078        current = TREE_CHAIN (current))
10079     {
10080       /* We build the assignment expression that will initialize the
10081          field to its value. There are strict rules on static
10082          initializers (8.5). FIXME */
10083       tree stmt = build_debugable_stmt (EXPR_WFL_LINECOL (current), current);
10084       java_method_add_stmt (mdecl, stmt);
10085     }
10086
10087   end_artificial_method_body (mdecl);
10088
10089   /* Now we want to place <clinit> as the last method (because we need
10090      it at least for interface so that it doesn't interfere with the
10091      dispatch table based lookup. */
10092   if (TREE_CHAIN (TYPE_METHODS (class_type)))
10093     {
10094       current = TREE_CHAIN (TYPE_METHODS (class_type));
10095       TYPE_METHODS (class_type) = current;
10096
10097       while (TREE_CHAIN (current))
10098         current = TREE_CHAIN (current);
10099
10100       TREE_CHAIN (current) = mdecl;
10101       TREE_CHAIN (mdecl) = NULL_TREE;
10102     }
10103
10104   return mdecl;
10105 }
10106
10107 /* See whether we could get rid of <clinit>. Criteria are: all static
10108    final fields have constant initial values and the body of <clinit>
10109    is empty. Return 1 if <clinit> was discarded, 0 otherwise. */
10110
10111 static int
10112 maybe_yank_clinit (mdecl)
10113      tree mdecl;
10114 {
10115   tree type, current;
10116   tree fbody, bbody;
10117   
10118   if (!DECL_CLINIT_P (mdecl))
10119     return 0;
10120   
10121   /* If the body isn't empty, then we keep <clinit> */
10122   fbody = DECL_FUNCTION_BODY (mdecl);
10123   if ((bbody = BLOCK_EXPR_BODY (fbody)))
10124     bbody = BLOCK_EXPR_BODY (bbody);
10125   if (bbody && bbody != empty_stmt_node)
10126     return 0;
10127   
10128   type = DECL_CONTEXT (mdecl);
10129   current = TYPE_FIELDS (type);
10130
10131   for (current = (current ? TREE_CHAIN (current) : current); 
10132        current; current = TREE_CHAIN (current))
10133     if (!(FIELD_STATIC (current) && FIELD_FINAL (current)
10134           && DECL_INITIAL (current) && TREE_CONSTANT (DECL_INITIAL (current))))
10135       break;
10136
10137   if (current)
10138     return 0;
10139
10140   /* Get rid of <clinit> in the class' list of methods */
10141   if (TYPE_METHODS (type) == mdecl)
10142     TYPE_METHODS (type) = TREE_CHAIN (mdecl);
10143   else
10144     for (current = TYPE_METHODS (type); current; 
10145          current = TREE_CHAIN (current))
10146       if (TREE_CHAIN (current) == mdecl)
10147         {
10148           TREE_CHAIN (current) = TREE_CHAIN (mdecl);
10149           break;
10150         }
10151
10152   return 1;
10153 }
10154
10155
10156 /* Complete and expand a method.  */
10157
10158 static void
10159 java_complete_expand_method (mdecl)
10160      tree mdecl;
10161 {
10162   int yank_clinit = 0;
10163
10164   current_function_decl = mdecl;
10165   /* Fix constructors before expanding them */
10166   if (DECL_CONSTRUCTOR_P (mdecl))
10167     fix_constructors (mdecl);
10168   
10169   /* Expand functions that have a body */
10170   if (DECL_FUNCTION_BODY (mdecl))
10171     {
10172       tree fbody = DECL_FUNCTION_BODY (mdecl);
10173       tree block_body = BLOCK_EXPR_BODY (fbody);
10174       tree exception_copy = NULL_TREE;
10175       expand_start_java_method (mdecl);
10176       build_result_decl (mdecl);
10177
10178       current_this 
10179         = (!METHOD_STATIC (mdecl) ? 
10180            BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
10181
10182       /* Purge the `throws' list of unchecked exceptions. If we're
10183          doing xref, save a copy of the list and re-install it
10184          later. */
10185       if (flag_emit_xref)
10186         exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
10187
10188       purge_unchecked_exceptions (mdecl);
10189
10190       /* Install exceptions thrown with `throws' */
10191       PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
10192
10193       if (block_body != NULL_TREE)
10194         {
10195           block_body = java_complete_tree (block_body);
10196
10197           if (! flag_emit_xref && ! METHOD_NATIVE (mdecl))
10198             check_for_initialization (block_body);
10199           ctxp->explicit_constructor_p = 0;
10200         }
10201
10202       BLOCK_EXPR_BODY (fbody) = block_body;
10203
10204       /* If we saw a return but couldn't evaluate it properly, we'll
10205          have an error_mark_node here. */
10206       if (block_body != error_mark_node
10207           && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
10208           && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
10209           && !flag_emit_xref)
10210         missing_return_error (current_function_decl);
10211
10212       /* Check wether we could just get rid of clinit, now the picture
10213          is complete. */
10214       if (!(yank_clinit = maybe_yank_clinit (mdecl)))
10215         complete_start_java_method (mdecl); 
10216       
10217       /* Don't go any further if we've found error(s) during the
10218          expansion */
10219       if (!java_error_count && !yank_clinit)
10220         source_end_java_method ();
10221       else
10222         {
10223           if (java_error_count)
10224             pushdecl_force_head (DECL_ARGUMENTS (mdecl));
10225           poplevel (1, 0, 1);
10226         }
10227
10228       /* Pop the exceptions and sanity check */
10229       POP_EXCEPTIONS();
10230       if (currently_caught_type_list)
10231         fatal ("Exception list non empty - java_complete_expand_method");
10232
10233       if (flag_emit_xref)
10234         DECL_FUNCTION_THROWS (mdecl) = exception_copy;
10235     }
10236 }
10237
10238 \f
10239
10240 /* This section of the code deals with accessing enclosing context
10241    fields either directly by using the relevant access to this$<n> or
10242    by invoking an access method crafted for that purpose.  */
10243
10244 /* Build the necessary access from an inner class to an outer
10245    class. This routine could be optimized to cache previous result
10246    (decl, current_class and returned access).  When an access method
10247    needs to be generated, it always takes the form of a read. It might
10248    be later turned into a write by calling outer_field_access_fix.  */
10249
10250 static tree
10251 build_outer_field_access (id, decl)
10252      tree id, decl;
10253 {
10254   tree access = NULL_TREE;
10255   tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
10256
10257   /* If decl's class is the direct outer class of the current_class,
10258      build the access as `this$<n>.<field>'. Not that we will break
10259      the `private' barrier if we're not emitting bytecodes. */
10260   if (ctx == DECL_CONTEXT (decl) 
10261       && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
10262     {
10263       tree thisn = build_current_thisn (current_class);
10264       access = make_qualified_primary (build_wfl_node (thisn), 
10265                                        id, EXPR_WFL_LINECOL (id));
10266     }
10267   /* Otherwise, generate access methods to outer this and access the
10268      field (either using an access method or by direct access.) */
10269   else
10270     {
10271       int lc = EXPR_WFL_LINECOL (id);
10272
10273       /* Now we chain the required number of calls to the access$0 to
10274          get a hold to the enclosing instance we need, and the we
10275          build the field access. */
10276       access = build_access_to_thisn (ctx, DECL_CONTEXT (decl), lc);
10277
10278       /* If the field is private and we're generating bytecode, then
10279          we generate an access method */
10280       if (FIELD_PRIVATE (decl) && flag_emit_class_files )
10281         {
10282           tree name = build_outer_field_access_methods (decl);
10283           access = build_outer_field_access_expr (lc, DECL_CONTEXT (decl),
10284                                                   name, access, NULL_TREE);
10285         }
10286       /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
10287          Once again we break the `private' access rule from a foreign
10288          class. */
10289       else
10290         access = make_qualified_primary (access, id, lc);
10291     }
10292   return resolve_expression_name (access, NULL);
10293 }
10294
10295 /* Return a non zero value if NODE describes an outer field inner
10296    access.  */
10297
10298 static int
10299 outer_field_access_p (type, decl)
10300     tree type, decl;
10301 {
10302   if (!INNER_CLASS_TYPE_P (type) 
10303       || TREE_CODE (decl) != FIELD_DECL
10304       || DECL_CONTEXT (decl) == type)
10305     return 0;
10306
10307   for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
10308        type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
10309     {
10310       if (type == DECL_CONTEXT (decl))
10311         return 1;
10312       if (!DECL_CONTEXT (TYPE_NAME (type)))
10313         break;
10314     }
10315
10316   return 0;
10317 }
10318
10319 /* Return a non zero value if NODE represents an outer field inner
10320    access that was been already expanded. As a side effect, it returns
10321    the name of the field being accessed and the argument passed to the
10322    access function, suitable for a regeneration of the access method
10323    call if necessary. */
10324
10325 static int
10326 outer_field_expanded_access_p (node, name, arg_type, arg)
10327     tree node, *name, *arg_type, *arg;
10328 {
10329   int identified = 0;
10330
10331   if (TREE_CODE (node) != CALL_EXPR)
10332     return 0;
10333
10334   /* Well, gcj generates slightly different tree nodes when compiling
10335      to native or bytecodes. It's the case for function calls. */
10336
10337   if (flag_emit_class_files 
10338       && TREE_CODE (node) == CALL_EXPR
10339       && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
10340     identified = 1;
10341   else if (!flag_emit_class_files)
10342     {
10343       node = TREE_OPERAND (node, 0);
10344       
10345       if (node && TREE_OPERAND (node, 0)
10346           && TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR)
10347         {
10348           node = TREE_OPERAND (node, 0);
10349           if (TREE_OPERAND (node, 0)
10350               && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
10351               && (OUTER_FIELD_ACCESS_IDENTIFIER_P 
10352                   (DECL_NAME (TREE_OPERAND (node, 0)))))
10353             identified = 1;
10354         }
10355     }
10356
10357   if (identified && name && arg_type && arg)
10358     {
10359       tree argument = TREE_OPERAND (node, 1);
10360       *name = DECL_NAME (TREE_OPERAND (node, 0));
10361       *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
10362       *arg = TREE_VALUE (argument);
10363     }
10364   return identified;
10365 }
10366
10367 /* Detect in NODE an outer field read access from an inner class and
10368    transform it into a write with RHS as an argument. This function is
10369    called from the java_complete_lhs when an assignment to a LHS can
10370    be identified. */
10371
10372 static tree
10373 outer_field_access_fix (wfl, node, rhs)
10374     tree wfl, node, rhs;
10375 {
10376   tree name, arg_type, arg;
10377   
10378   if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
10379     {
10380       /* At any rate, check whether we're trying to assign a value to
10381          a final. */
10382       tree accessed = (JDECL_P (node) ? node : 
10383                        (TREE_CODE (node) == COMPONENT_REF ? 
10384                         TREE_OPERAND (node, 1) : node));
10385       if (check_final_assignment (accessed, wfl))
10386         return error_mark_node;
10387   
10388       node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl), 
10389                                             arg_type, name, arg, rhs);
10390       return java_complete_tree (node);
10391     }
10392   return NULL_TREE;
10393 }
10394
10395 /* Construct the expression that calls an access method:
10396      <type>.access$<n>(<arg1> [, <arg2>]); 
10397
10398    ARG2 can be NULL and will be omitted in that case. It will denote a
10399    read access.  */
10400
10401 static tree
10402 build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
10403     int lc;
10404     tree type, access_method_name, arg1, arg2;
10405 {
10406   tree args, cn, access;
10407
10408   args = arg1 ? arg1 : 
10409     build_wfl_node (build_current_thisn (current_class));
10410   args = build_tree_list (NULL_TREE, args);
10411
10412   if (arg2)
10413     args = tree_cons (NULL_TREE, arg2, args);
10414
10415   access = build_method_invocation (build_wfl_node (access_method_name), args);
10416   cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
10417   return make_qualified_primary (cn, access, lc);
10418 }
10419
10420 static tree
10421 build_new_access_id ()
10422 {
10423   static int access_n_counter = 1;
10424   char buffer [128];
10425
10426   sprintf (buffer, "access$%d", access_n_counter++);
10427   return get_identifier (buffer);
10428 }
10429
10430 /* Create the static access functions for the outer field DECL. We define a
10431    read:
10432      TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
10433        return inst$.field;
10434      }
10435    and a write access:
10436      TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$,
10437                                      TREE_TYPE (<field>) value$) {
10438        return inst$.field = value$;
10439      }
10440    We should have a usage flags on the DECL so we can lazily turn the ones
10441    we're using for code generation. FIXME.
10442 */
10443
10444 static tree
10445 build_outer_field_access_methods (decl)
10446     tree decl;
10447 {
10448   tree id, args, stmt, mdecl;
10449   
10450   /* Check point, to be removed. FIXME */
10451   if (FIELD_INNER_ACCESS (decl) 
10452       && TREE_CODE (FIELD_INNER_ACCESS (decl)) != IDENTIFIER_NODE)
10453     abort ();
10454
10455   if (FIELD_INNER_ACCESS (decl))
10456     return FIELD_INNER_ACCESS (decl);
10457
10458   push_obstacks (&permanent_obstack, &permanent_obstack);
10459
10460   /* Create the identifier and a function named after it. */
10461   id = build_new_access_id ();
10462
10463   /* The identifier is marked as bearing the name of a generated write
10464      access function for outer field accessed from inner classes. */
10465   OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10466
10467   /* Create the read access */
10468   args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10469   TREE_CHAIN (args) = end_params_node;
10470   stmt = make_qualified_primary (build_wfl_node (inst_id),
10471                                  build_wfl_node (DECL_NAME (decl)), 0);
10472   stmt = build_return (0, stmt);
10473   mdecl = build_outer_field_access_method (DECL_CONTEXT (decl), 
10474                                            TREE_TYPE (decl), id, args, stmt);
10475   DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10476
10477   /* Create the write access method */
10478   args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10479   TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
10480   TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
10481   stmt = make_qualified_primary (build_wfl_node (inst_id),
10482                                  build_wfl_node (DECL_NAME (decl)), 0);
10483   stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
10484                                             build_wfl_node (wpv_id)));
10485
10486   mdecl = build_outer_field_access_method (DECL_CONTEXT (decl), 
10487                                            TREE_TYPE (decl), id, args, stmt);
10488   DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10489   pop_obstacks ();
10490
10491   /* Return the access name */
10492   return FIELD_INNER_ACCESS (decl) = id;
10493 }
10494
10495 /* Build an field access method NAME.  */
10496
10497 static tree 
10498 build_outer_field_access_method (class, type, name, args, body)
10499     tree class, type, name, args, body;
10500 {
10501   tree saved_current_function_decl, mdecl;
10502
10503   /* Create the method */
10504   mdecl = create_artificial_method (class, ACC_STATIC, type, name, args);
10505   fix_method_argument_names (args, mdecl);
10506   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10507
10508   /* Attach the method body. */
10509   saved_current_function_decl = current_function_decl;
10510   start_artificial_method_body (mdecl);
10511   java_method_add_stmt (mdecl, body);
10512   end_artificial_method_body (mdecl);
10513   current_function_decl = saved_current_function_decl;
10514
10515   return mdecl;
10516 }
10517
10518 \f
10519 /* This section deals with building access function necessary for
10520    certain kinds of method invocation from inner classes.  */
10521
10522 static tree
10523 build_outer_method_access_method (decl)
10524     tree decl;
10525 {
10526   tree saved_current_function_decl, mdecl;
10527   tree args = NULL_TREE, call_args = NULL_TREE;
10528   tree carg, id, body, class;
10529   char buffer [80];
10530   int parm_id_count = 0;
10531
10532   /* Test this abort with an access to a private field */
10533   if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "access$"))
10534     abort ();
10535
10536   /* Check the cache first */
10537   if (DECL_FUNCTION_INNER_ACCESS (decl))
10538     return DECL_FUNCTION_INNER_ACCESS (decl);
10539
10540   class = DECL_CONTEXT (decl);
10541
10542   /* Obtain an access identifier and mark it */
10543   id = build_new_access_id ();
10544   OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10545
10546   push_obstacks (&permanent_obstack, &permanent_obstack);
10547
10548   carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
10549   /* Create the arguments, as much as the original */
10550   for (; carg && carg != end_params_node; 
10551        carg = TREE_CHAIN (carg))
10552     {
10553       sprintf (buffer, "write_parm_value$%d", parm_id_count++);
10554       args = chainon (args, build_tree_list (get_identifier (buffer), 
10555                                              TREE_VALUE (carg)));
10556     }
10557   args = chainon (args, end_params_node);
10558
10559   /* Create the method */
10560   mdecl = create_artificial_method (class, ACC_STATIC, 
10561                                     TREE_TYPE (TREE_TYPE (decl)), id, args);
10562   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10563   /* There is a potential bug here. We should be able to use
10564      fix_method_argument_names, but then arg names get mixed up and
10565      eventually a constructor will have its this$0 altered and the
10566      outer context won't be assignment properly. The test case is
10567      stub.java FIXME */
10568   TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
10569
10570   /* Attach the method body. */
10571   saved_current_function_decl = current_function_decl;
10572   start_artificial_method_body (mdecl);
10573
10574   /* The actual method invocation uses the same args. When invoking a
10575      static methods that way, we don't want to skip the first
10576      argument. */
10577   carg = args;
10578   if (!METHOD_STATIC (decl))
10579     carg = TREE_CHAIN (carg);
10580   for (; carg && carg != end_params_node; carg = TREE_CHAIN (carg))
10581     call_args = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (carg)),
10582                            call_args);
10583
10584   body = build_method_invocation (build_wfl_node (DECL_NAME (decl)), 
10585                                   call_args);
10586   if (!METHOD_STATIC (decl))
10587     body = make_qualified_primary (build_wfl_node (TREE_PURPOSE (args)), 
10588                                    body, 0);
10589   if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
10590     body = build_return (0, body);
10591   java_method_add_stmt (mdecl,body);
10592   end_artificial_method_body (mdecl);
10593   current_function_decl = saved_current_function_decl;
10594   pop_obstacks ();
10595
10596   /* Back tag the access function so it know what it accesses */
10597   DECL_FUNCTION_ACCESS_DECL (decl) = mdecl;
10598
10599   /* Tag the current method so it knows it has an access generated */
10600   return DECL_FUNCTION_INNER_ACCESS (decl) = mdecl;
10601 }
10602
10603 \f
10604 /* This section of the code deals with building expressions to access
10605    the enclosing instance of an inner class. The enclosing instance is
10606    kept in a generated field called this$<n>, with <n> being the
10607    inner class nesting level (starting from 0.)  */
10608     
10609 /* Build an access to a given this$<n>, possibly by chaining access
10610    call to others. Access methods to this$<n> are build on the fly if
10611    necessary */
10612
10613 static tree
10614 build_access_to_thisn (from, to, lc)
10615      tree from, to;
10616      int lc;
10617 {
10618   tree access = NULL_TREE;
10619
10620   while (from != to)
10621     {
10622       tree access0_wfl, cn;
10623
10624       maybe_build_thisn_access_method (from);
10625       access0_wfl = build_wfl_node (access0_identifier_node);
10626       cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
10627       EXPR_WFL_LINECOL (access0_wfl) = lc;
10628       
10629       if (!access)
10630         {
10631           access = build_current_thisn (current_class);
10632           access = build_wfl_node (access);
10633         }
10634       access = build_tree_list (NULL_TREE, access);
10635       access = build_method_invocation (access0_wfl, access);
10636       access = make_qualified_primary (cn, access, lc);
10637       
10638       from = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (from)));
10639     }
10640   return access;
10641 }
10642
10643 /* Build an access function to the this$<n> local to TYPE. NULL_TREE
10644    is returned if nothing needs to be generated. Otherwise, the method
10645    generated and a method decl is returned.  
10646
10647    NOTE: These generated methods should be declared in a class file
10648    attribute so that they can't be referred to directly.  */
10649
10650 static tree
10651 maybe_build_thisn_access_method (type)
10652     tree type;
10653 {
10654   tree mdecl, args, stmt, rtype;
10655   tree saved_current_function_decl;
10656
10657   /* If TYPE is a top-level class, no access method is required.
10658      If there already is such an access method, bail out. */
10659   if (CLASS_ACCESS0_GENERATED_P (type) || !INNER_CLASS_TYPE_P (type))
10660     return NULL_TREE;
10661
10662   /* We generate the method. The method looks like:
10663      static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; }
10664   */
10665   push_obstacks (&permanent_obstack, &permanent_obstack);
10666   args = build_tree_list (inst_id, build_pointer_type (type));
10667   TREE_CHAIN (args) = end_params_node;
10668   rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))));
10669   mdecl = create_artificial_method (type, ACC_STATIC, rtype,
10670                                     access0_identifier_node, args);
10671   fix_method_argument_names (args, mdecl);
10672   layout_class_method (type, NULL_TREE, mdecl, NULL_TREE);
10673   stmt = build_current_thisn (type);
10674   stmt = make_qualified_primary (build_wfl_node (inst_id), 
10675                                  build_wfl_node (stmt), 0);
10676   stmt = build_return (0, stmt);
10677
10678   saved_current_function_decl = current_function_decl;
10679   start_artificial_method_body (mdecl);
10680   java_method_add_stmt (mdecl, stmt);
10681   end_artificial_method_body (mdecl);
10682   current_function_decl = saved_current_function_decl;
10683   pop_obstacks ();
10684
10685   CLASS_ACCESS0_GENERATED_P (type) = 1;
10686
10687   return mdecl;
10688 }
10689
10690 /* Craft an correctly numbered `this$<n>'string. this$0 is used for
10691    the first level of innerclassing. this$1 for the next one, etc...
10692    This function can be invoked with TYPE to NULL, available and then
10693    has to count the parser context.  */
10694
10695 static tree
10696 build_current_thisn (type)
10697     tree type;
10698 {
10699   static int saved_i = -1;
10700   static tree saved_thisn = NULL_TREE;
10701
10702   tree decl;
10703   char buffer [80];
10704   int i = 0;
10705
10706   if (type)
10707     {
10708       static tree saved_type = NULL_TREE;
10709       static int saved_type_i = 0;
10710
10711       if (type == saved_type)
10712         i = saved_type_i;
10713       else
10714         {
10715           for (i = -1, decl = DECL_CONTEXT (TYPE_NAME (type)); 
10716                decl; decl = DECL_CONTEXT (decl), i++)
10717             ;
10718       
10719           saved_type = type;
10720           saved_type_i = i;
10721         }
10722     }
10723   else
10724     i = list_length (GET_CPC_LIST ())-2;
10725
10726   if (i == saved_i)
10727     return saved_thisn;
10728     
10729   sprintf (buffer, "this$%d", i);
10730   saved_i = i;
10731   saved_thisn = get_identifier (buffer);
10732   return saved_thisn;
10733 }
10734
10735 /* Return the assignement to the hidden enclosing context `this$<n>'
10736    by the second incoming parameter to the innerclass constructor. The
10737    form used is `this.this$<n> = this$<n>;'.  */
10738
10739 static tree
10740 build_thisn_assign ()
10741 {
10742   if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
10743     {
10744       tree thisn = build_current_thisn (current_class);
10745       tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
10746                                          build_wfl_node (thisn), 0);
10747       tree rhs = build_wfl_node (thisn);
10748       EXPR_WFL_SET_LINECOL (lhs, lineno, 0);
10749       return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
10750     }
10751   return NULL_TREE;
10752 }
10753
10754 \f
10755 /* Building the synthetic `class$' used to implement the `.class' 1.1
10756    extension for non primitive types. This method looks like:
10757
10758     static Class class$(String type) throws NoClassDefFoundError
10759     {
10760       try {return (java.lang.Class.forName (String));}
10761       catch (ClassNotFoundException e) {
10762         throw new NoClassDefFoundError(e.getMessage());}
10763     } */
10764
10765 static tree
10766 build_dot_class_method (class)
10767      tree class;
10768 {
10769 #define BWF(S) build_wfl_node (get_identifier ((S)))
10770 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
10771   tree args, tmp, saved_current_function_decl, mdecl;
10772   tree stmt, throw_stmt, catch, catch_block, try_block;
10773   tree catch_clause_param;
10774   tree class_not_found_exception, no_class_def_found_error;
10775
10776   static tree get_message_wfl, type_parm_wfl;
10777
10778   if (!get_message_wfl)
10779     {
10780       get_message_wfl = build_wfl_node (get_identifier ("getMessage"));
10781       type_parm_wfl = build_wfl_node (get_identifier ("type$"));
10782     }
10783
10784   /* Build the arguments */
10785   args = build_tree_list (get_identifier ("type$"),
10786                           build_pointer_type (string_type_node));
10787   TREE_CHAIN (args) = end_params_node;
10788
10789   /* Build the qualified name java.lang.Class.forName */
10790   tmp = MQN (MQN (MQN (BWF ("java"), 
10791                        BWF ("lang")), BWF ("Class")), BWF ("forName"));
10792
10793   /* For things we have to catch and throw */
10794   class_not_found_exception = 
10795     lookup_class (get_identifier ("java.lang.ClassNotFoundException"));
10796   no_class_def_found_error = 
10797     lookup_class (get_identifier ("java.lang.NoClassDefFoundError"));
10798   load_class (class_not_found_exception, 1);
10799   load_class (no_class_def_found_error, 1);
10800
10801   /* Create the "class$" function */
10802   mdecl = create_artificial_method (class, ACC_STATIC, 
10803                                     build_pointer_type (class_type_node),
10804                                     get_identifier ("class$"), args);
10805   DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE,
10806                                                   no_class_def_found_error);
10807   
10808   /* We start by building the try block. We need to build:
10809        return (java.lang.Class.forName (type)); */
10810   stmt = build_method_invocation (tmp, 
10811                                   build_tree_list (NULL_TREE, type_parm_wfl));
10812   stmt = build_return (0, stmt);
10813   /* Put it in a block. That's the try block */
10814   try_block = build_expr_block (stmt, NULL_TREE);
10815
10816   /* Now onto the catch block. We start by building the expression
10817      throwing a new exception: 
10818        throw new NoClassDefFoundError (_.getMessage); */
10819   throw_stmt = make_qualified_name (build_wfl_node (wpv_id), 
10820                                     get_message_wfl, 0);
10821   throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
10822   
10823   /* Build new NoClassDefFoundError (_.getMessage) */
10824   throw_stmt = build_new_invocation 
10825     (build_wfl_node (get_identifier ("NoClassDefFoundError")),
10826      build_tree_list (build_pointer_type (string_type_node), throw_stmt));
10827
10828   /* Build the throw, (it's too early to use BUILD_THROW) */
10829   throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
10830
10831   /* Build the catch block to encapsulate all this. We begin by
10832      building an decl for the catch clause parameter and link it to
10833      newly created block, the catch block. */
10834   catch_clause_param = 
10835     build_decl (VAR_DECL, wpv_id, 
10836                 build_pointer_type (class_not_found_exception));
10837   catch_block = build_expr_block (NULL_TREE, catch_clause_param);
10838   
10839   /* We initialize the variable with the exception handler. */
10840   catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
10841                  soft_exceptioninfo_call_node);
10842   add_stmt_to_block (catch_block, NULL_TREE, catch);
10843
10844   /* We add the statement throwing the new exception */
10845   add_stmt_to_block (catch_block, NULL_TREE, throw_stmt);
10846
10847   /* Build a catch expression for all this */
10848   catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
10849
10850   /* Build the try/catch sequence */
10851   stmt = build_try_statement (0, try_block, catch_block);
10852
10853   fix_method_argument_names (args, mdecl);
10854   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10855   saved_current_function_decl = current_function_decl;
10856   start_artificial_method_body (mdecl);
10857   java_method_add_stmt (mdecl, stmt);
10858   end_artificial_method_body (mdecl);
10859   current_function_decl = saved_current_function_decl;
10860   TYPE_DOT_CLASS (class) = mdecl;
10861
10862   return mdecl;
10863 }
10864
10865 static tree
10866 build_dot_class_method_invocation (name)
10867      tree name;
10868 {
10869   tree s = make_node (STRING_CST);
10870   TREE_STRING_LENGTH (s) = IDENTIFIER_LENGTH (name);
10871   TREE_STRING_POINTER (s) = obstack_alloc (expression_obstack,
10872                                            TREE_STRING_LENGTH (s)+1);
10873   strcpy (TREE_STRING_POINTER (s), IDENTIFIER_POINTER (name));
10874   return build_method_invocation (build_wfl_node (get_identifier ("class$")),
10875                                   build_tree_list (NULL_TREE, s));
10876 }
10877
10878 /* This section of the code deals with constructor.  */
10879
10880 /* Craft a body for default constructor. Patch existing constructor
10881    bodies with call to super() and field initialization statements if
10882    necessary.  */
10883
10884 static void
10885 fix_constructors (mdecl)
10886      tree mdecl;
10887 {
10888   tree body = DECL_FUNCTION_BODY (mdecl);
10889   tree thisn_assign, compound = NULL_TREE;
10890   tree class_type = DECL_CONTEXT (mdecl);
10891
10892   if (!body)
10893     {
10894       /* It is an error for the compiler to generate a default
10895          constructor if the superclass doesn't have a constructor that
10896          takes no argument, or the same args for an anonymous class */
10897       if (verify_constructor_super (mdecl))
10898         {
10899           tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (class_type));
10900           tree save = DECL_NAME (mdecl);
10901           const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
10902           DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
10903           parse_error_context
10904             (lookup_cl (TYPE_NAME (class_type)), 
10905              "No constructor matching `%s' found in class `%s'",
10906              lang_printable_name (mdecl, 0), n);
10907           DECL_NAME (mdecl) = save;
10908         }
10909       
10910       /* The constructor body must be crafted by hand. It's the
10911          constructor we defined when we realize we didn't have the
10912          CLASSNAME() constructor */
10913       start_artificial_method_body (mdecl);
10914       
10915       /* We don't generate a super constructor invocation if we're
10916          compiling java.lang.Object. build_super_invocation takes care
10917          of that. */
10918       compound = java_method_add_stmt (mdecl, build_super_invocation (mdecl));
10919
10920       /* Insert the instance initializer block right here, after the
10921          super invocation. */
10922       add_instance_initializer (mdecl);
10923
10924       /* Insert an assignment to the this$<n> hidden field, if
10925          necessary */
10926       if ((thisn_assign = build_thisn_assign ()))
10927         java_method_add_stmt (mdecl, thisn_assign);
10928
10929       end_artificial_method_body (mdecl);
10930     }
10931   /* Search for an explicit constructor invocation */
10932   else 
10933     {
10934       int found = 0;
10935       tree main_block = BLOCK_EXPR_BODY (body);
10936       
10937       while (body)
10938         switch (TREE_CODE (body))
10939           {
10940           case CALL_EXPR:
10941             found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
10942             body = NULL_TREE;
10943             break;
10944           case COMPOUND_EXPR:
10945           case EXPR_WITH_FILE_LOCATION:
10946             body = TREE_OPERAND (body, 0);
10947             break;
10948           case BLOCK:
10949             body = BLOCK_EXPR_BODY (body);
10950             break;
10951           default:
10952             found = 0;
10953             body = NULL_TREE;
10954           }
10955       /* The constructor is missing an invocation of super() */
10956       if (!found)
10957         compound = add_stmt_to_compound (compound, NULL_TREE,
10958                                          build_super_invocation (mdecl));
10959       
10960       /* Insert the instance initializer block right here, after the
10961          super invocation. */
10962       add_instance_initializer (mdecl);
10963
10964       /* Generate the assignment to this$<n>, if necessary */
10965       if ((thisn_assign = build_thisn_assign ()))
10966         compound = add_stmt_to_compound (compound, NULL_TREE, thisn_assign);
10967
10968       /* Fix the constructor main block if we're adding extra stmts */
10969       if (compound)
10970         {
10971           compound = add_stmt_to_compound (compound, NULL_TREE,
10972                                            BLOCK_EXPR_BODY (main_block));
10973           BLOCK_EXPR_BODY (main_block) = compound;
10974         }
10975     }
10976 }
10977
10978 /* Browse constructors in the super class, searching for a constructor
10979    that doesn't take any argument. Return 0 if one is found, 1
10980    otherwise.  If the current class is an anonymous inner class, look
10981    for something that has the same signature. */
10982
10983 static int
10984 verify_constructor_super (mdecl)
10985      tree mdecl;
10986 {
10987   tree class = CLASSTYPE_SUPER (current_class);
10988   int super_inner = PURE_INNER_CLASS_TYPE_P (class);
10989   tree sdecl;
10990
10991   if (!class)
10992     return 0;
10993
10994   if (ANONYMOUS_CLASS_P (current_class))
10995     {
10996       tree mdecl_arg_type;
10997       SKIP_THIS_AND_ARTIFICIAL_PARMS (mdecl_arg_type, mdecl);
10998       for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10999         if (DECL_CONSTRUCTOR_P (sdecl))
11000           {
11001             tree arg_type = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
11002             if (super_inner)
11003               arg_type = TREE_CHAIN (arg_type);
11004             for (; (arg_type != end_params_node 
11005                     && mdecl_arg_type != end_params_node);
11006                  arg_type = TREE_CHAIN (arg_type), 
11007                  mdecl_arg_type = TREE_CHAIN (mdecl_arg_type))
11008               if (TREE_VALUE (arg_type) != TREE_VALUE (mdecl_arg_type))
11009                 break;
11010
11011             if (arg_type == end_params_node && 
11012                 mdecl_arg_type == end_params_node)
11013               return 0;
11014           }
11015     }
11016   else
11017     {
11018       for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
11019         {
11020           tree arg = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
11021           if (super_inner)
11022             arg = TREE_CHAIN (arg);
11023           if (DECL_CONSTRUCTOR_P (sdecl) && arg == end_params_node)
11024             return 0;
11025         }
11026     }
11027   return 1;
11028 }
11029
11030 /* Generate code for all context remembered for code generation.  */
11031
11032 void
11033 java_expand_classes ()
11034 {
11035   int save_error_count = 0;
11036   static struct parser_ctxt *saved_ctxp = NULL;
11037
11038   java_parse_abort_on_error ();
11039   if (!(ctxp = ctxp_for_generation))
11040     return;
11041   java_layout_classes ();
11042   java_parse_abort_on_error ();
11043
11044   /* The list of packages declaration seen so far needs to be
11045      reversed, so that package declared in a file being compiled gets
11046      priority over packages declared as a side effect of parsing other
11047      files.*/
11048   package_list = nreverse (package_list);
11049
11050   saved_ctxp = ctxp_for_generation;
11051   for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11052     {
11053       ctxp = ctxp_for_generation;
11054       lang_init_source (2);            /* Error msgs have method prototypes */
11055       java_complete_expand_classes (); /* Complete and expand classes */
11056       java_parse_abort_on_error ();
11057     }
11058
11059   /* Find anonymous classes and expand their constructor, now they
11060      have been fixed. */
11061   for (ctxp_for_generation = saved_ctxp;
11062        ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11063     {
11064       tree current;
11065       ctxp = ctxp_for_generation;
11066       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11067         {
11068           current_class = TREE_TYPE (current);
11069           if (ANONYMOUS_CLASS_P (current_class))
11070             {
11071               tree d;
11072               for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
11073                 {
11074                   if (DECL_CONSTRUCTOR_P (d))
11075                     {
11076                       restore_line_number_status (1);
11077                       reset_method_name (d);
11078                       java_complete_expand_method (d);
11079                       restore_line_number_status (0);
11080                       break;    /* We now there are no other ones */
11081                     }
11082                 }
11083             }
11084         }
11085     }
11086
11087   /* If we've found error at that stage, don't try to generate
11088      anything, unless we're emitting xrefs or checking the syntax only
11089      (but not using -fsyntax-only for the purpose of generating
11090      bytecode. */
11091   if (java_error_count && !flag_emit_xref 
11092       && (!flag_syntax_only && !flag_emit_class_files))
11093     return;
11094
11095   /* Now things are stable, go for generation of the class data. */
11096   for (ctxp_for_generation = saved_ctxp;
11097        ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11098     {
11099       tree current;
11100       ctxp = ctxp_for_generation;
11101       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11102         {
11103           current_class = TREE_TYPE (current);
11104           outgoing_cpool = TYPE_CPOOL (current_class);
11105           if (flag_emit_class_files)
11106             write_classfile (current_class);
11107           if (flag_emit_xref)
11108             expand_xref (current_class);
11109           else if (! flag_syntax_only)
11110             finish_class ();
11111         }
11112     }
11113 }
11114
11115 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
11116    a tree list node containing RIGHT. Fore coming RIGHTs will be
11117    chained to this hook. LOCATION contains the location of the
11118    separating `.' operator.  */
11119
11120 static tree
11121 make_qualified_primary (primary, right, location)
11122      tree primary, right;
11123      int location;
11124 {
11125   tree wfl;
11126
11127   if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
11128     wfl = build_wfl_wrap (primary);
11129   else
11130     {
11131       wfl = primary;
11132       /* If wfl wasn't qualified, we build a first anchor */
11133       if (!EXPR_WFL_QUALIFICATION (wfl))
11134         EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (wfl, NULL_TREE);
11135     }
11136
11137   /* And chain them */
11138   EXPR_WFL_LINECOL (right) = location;
11139   chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
11140   PRIMARY_P (wfl) =  1;
11141   return wfl;
11142 }
11143
11144 /* Simple merge of two name separated by a `.' */
11145
11146 static tree
11147 merge_qualified_name (left, right)
11148      tree left, right;
11149 {
11150   tree node;
11151   if (!left && !right)
11152     return NULL_TREE;
11153
11154   if (!left)
11155     return right;
11156
11157   if (!right)
11158     return left;
11159
11160   obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
11161                 IDENTIFIER_LENGTH (left));
11162   obstack_1grow (&temporary_obstack, '.');
11163   obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
11164                  IDENTIFIER_LENGTH (right));
11165   node =  get_identifier (obstack_base (&temporary_obstack));
11166   obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
11167   QUALIFIED_P (node) = 1;
11168   return node;
11169 }
11170
11171 /* Merge the two parts of a qualified name into LEFT.  Set the
11172    location information of the resulting node to LOCATION, usually
11173    inherited from the location information of the `.' operator. */
11174
11175 static tree
11176 make_qualified_name (left, right, location)
11177      tree left, right;
11178      int location;
11179 {
11180 #ifdef USE_COMPONENT_REF
11181   tree node = build (COMPONENT_REF, NULL_TREE, left, right);
11182   EXPR_WFL_LINECOL (node) = location;
11183   return node;
11184 #else
11185   tree left_id = EXPR_WFL_NODE (left);
11186   tree right_id = EXPR_WFL_NODE (right);
11187   tree wfl, merge;
11188
11189   merge = merge_qualified_name (left_id, right_id);
11190
11191   /* Left wasn't qualified and is now qualified */
11192   if (!QUALIFIED_P (left_id))
11193     {
11194       tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
11195       EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
11196       EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
11197     }
11198   
11199   wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
11200   EXPR_WFL_LINECOL (wfl) = location;
11201   chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
11202
11203   EXPR_WFL_NODE (left) = merge;
11204   return left;
11205 #endif
11206 }
11207
11208 /* Extract the last identifier component of the qualified in WFL. The
11209    last identifier is removed from the linked list */
11210
11211 static tree
11212 cut_identifier_in_qualified (wfl)
11213      tree wfl;
11214 {
11215   tree q;
11216   tree previous = NULL_TREE;
11217   for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
11218     if (!TREE_CHAIN (q))
11219       {
11220         if (!previous)
11221           fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified");
11222         TREE_CHAIN (previous) = NULL_TREE;
11223         return TREE_PURPOSE (q);
11224       }
11225 }
11226
11227 /* Resolve the expression name NAME. Return its decl.  */
11228
11229 static tree
11230 resolve_expression_name (id, orig)
11231      tree id;
11232      tree *orig;
11233 {
11234   tree name = EXPR_WFL_NODE (id);
11235   tree decl;
11236
11237   /* 6.5.5.1: Simple expression names */
11238   if (!PRIMARY_P (id) && !QUALIFIED_P (name))
11239     {
11240       /* 15.13.1: NAME can appear within the scope of a local variable
11241          declaration */
11242       if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
11243         return decl;
11244
11245       /* 15.13.1: NAME can appear within a class declaration */
11246       else 
11247         {
11248           decl = lookup_field_wrapper (current_class, name);
11249           if (decl)
11250             {
11251               tree access = NULL_TREE;
11252               int fs = FIELD_STATIC (decl);
11253
11254               /* If we're accessing an outer scope local alias, make
11255                  sure we change the name of the field we're going to
11256                  build access to. */
11257               if (FIELD_LOCAL_ALIAS_USED (decl))
11258                 name = DECL_NAME (decl);
11259
11260               /* Instance variable (8.3.1.1) can't appear within
11261                  static method, static initializer or initializer for
11262                  a static variable. */
11263               if (!fs && METHOD_STATIC (current_function_decl))
11264                 {
11265                   static_ref_err (id, name, current_class);
11266                   return error_mark_node;
11267                 }
11268               /* Instance variables can't appear as an argument of
11269                  an explicit constructor invocation */
11270               if (!fs && ctxp->explicit_constructor_p)
11271                 {
11272                   parse_error_context
11273                     (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
11274                   return error_mark_node;
11275                 }
11276
11277               /* If we're processing an inner class and we're trying
11278                  to access a field belonging to an outer class, build
11279                  the access to the field */
11280               if (!fs && outer_field_access_p (current_class, decl))
11281                 return build_outer_field_access (id, decl);
11282
11283               /* Otherwise build what it takes to access the field */
11284               access = build_field_ref ((fs ? NULL_TREE : current_this),
11285                                         DECL_CONTEXT (decl), name);
11286               if (fs && !flag_emit_class_files && !flag_emit_xref)
11287                 access = build_class_init (DECL_CONTEXT (access), access);
11288               /* We may be asked to save the real field access node */
11289               if (orig)
11290                 *orig = access;
11291               /* And we return what we got */
11292               return access;
11293             }
11294           /* Fall down to error report on undefined variable */
11295         }
11296     }
11297   /* 6.5.5.2 Qualified Expression Names */
11298   else
11299     {
11300       if (orig)
11301         *orig = NULL_TREE;
11302       qualify_ambiguous_name (id);
11303       /* 15.10.1 Field Access Using a Primary and/or Expression Name */
11304       /* 15.10.2: Accessing Superclass Members using super */
11305       return resolve_field_access (id, orig, NULL);
11306     }
11307
11308   /* We've got an error here */
11309   parse_error_context (id, "Undefined variable `%s'", 
11310                        IDENTIFIER_POINTER (name));
11311
11312   return error_mark_node;
11313 }
11314
11315 static void
11316 static_ref_err (wfl, field_id, class_type)
11317     tree wfl, field_id, class_type;
11318 {
11319   parse_error_context 
11320     (wfl, 
11321      "Can't make a static reference to nonstatic variable `%s' in class `%s'",
11322      IDENTIFIER_POINTER (field_id), 
11323      IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
11324 }
11325
11326 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
11327    We return something suitable to generate the field access. We also
11328    return the field decl in FIELD_DECL and its type in FIELD_TYPE.  If
11329    recipient's address can be null. */
11330
11331 static tree
11332 resolve_field_access (qual_wfl, field_decl, field_type)
11333      tree qual_wfl;
11334      tree *field_decl, *field_type;
11335 {
11336   int is_static = 0;
11337   tree field_ref;
11338   tree decl, where_found, type_found;
11339
11340   if (resolve_qualified_expression_name (qual_wfl, &decl,
11341                                          &where_found, &type_found))
11342     return error_mark_node;
11343
11344   /* Resolve the LENGTH field of an array here */
11345   if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
11346       && ! flag_emit_class_files && ! flag_emit_xref)
11347     {
11348       tree length = build_java_array_length_access (where_found);
11349       field_ref =
11350         build_java_arraynull_check (type_found, length, int_type_node);
11351     }
11352   /* We might have been trying to resolve field.method(). In which
11353      case, the resolution is over and decl is the answer */
11354   else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
11355     field_ref = decl;
11356   else if (JDECL_P (decl))
11357     {
11358       int static_final_found = 0;
11359       if (!type_found)
11360         type_found = DECL_CONTEXT (decl);
11361       is_static = JDECL_P (decl) && FIELD_STATIC (decl);
11362       if (FIELD_FINAL (decl) 
11363           && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
11364           && DECL_INITIAL (decl))
11365         {
11366           field_ref = java_complete_tree (DECL_INITIAL (decl));
11367           static_final_found = 1;
11368         }
11369       else
11370         field_ref = build_field_ref ((is_static && !flag_emit_xref? 
11371                                       NULL_TREE : where_found), 
11372                                      type_found, DECL_NAME (decl));
11373       if (field_ref == error_mark_node)
11374         return error_mark_node;
11375       if (is_static && !static_final_found 
11376           && !flag_emit_class_files && !flag_emit_xref)
11377         field_ref = build_class_init (DECL_CONTEXT (decl), field_ref);
11378     }
11379   else
11380     field_ref = decl;
11381
11382   if (field_decl)
11383     *field_decl = decl;
11384   if (field_type)
11385     *field_type = (QUAL_DECL_TYPE (decl) ? 
11386                    QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
11387   return field_ref;
11388 }
11389
11390 /* If NODE is an access to f static field, strip out the class
11391    initialization part and return the field decl, otherwise, return
11392    NODE. */
11393
11394 static tree
11395 strip_out_static_field_access_decl (node)
11396     tree node;
11397 {
11398   if (TREE_CODE (node) == COMPOUND_EXPR)
11399     {
11400       tree op1 = TREE_OPERAND (node, 1);
11401       if (TREE_CODE (op1) == COMPOUND_EXPR)
11402          {
11403            tree call = TREE_OPERAND (op1, 0);
11404            if (TREE_CODE (call) == CALL_EXPR
11405                && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
11406                && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
11407                == soft_initclass_node)
11408              return TREE_OPERAND (op1, 1);
11409          }
11410       else if (JDECL_P (op1))
11411         return op1;
11412     }
11413   return node;
11414 }
11415
11416 /* 6.5.5.2: Qualified Expression Names */
11417
11418 static int
11419 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
11420      tree wfl;
11421      tree *found_decl, *type_found, *where_found;
11422 {
11423   int from_type = 0;            /* Field search initiated from a type */
11424   int from_super = 0, from_cast = 0, from_qualified_this = 0;
11425   int previous_call_static = 0;
11426   int is_static;
11427   tree decl = NULL_TREE, type = NULL_TREE, q;
11428   /* For certain for of inner class instantiation */
11429   tree saved_current, saved_this;               
11430 #define RESTORE_THIS_AND_CURRENT_CLASS                          \
11431   { current_class = saved_current; current_this = saved_this;}
11432
11433   *type_found = *where_found = NULL_TREE;
11434
11435   for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
11436     {
11437       tree qual_wfl = QUAL_WFL (q);
11438       tree ret_decl;            /* for EH checking */
11439       int location;             /* for EH checking */
11440
11441       /* 15.10.1 Field Access Using a Primary */
11442       switch (TREE_CODE (qual_wfl))
11443         {
11444         case CALL_EXPR:
11445         case NEW_CLASS_EXPR:
11446           /* If the access to the function call is a non static field,
11447              build the code to access it. */
11448           if (JDECL_P (decl) && !FIELD_STATIC (decl))
11449             {
11450               decl = maybe_access_field (decl, *where_found, 
11451                                          DECL_CONTEXT (decl));
11452               if (decl == error_mark_node)
11453                 return 1;
11454             }
11455
11456           /* And code for the function call */
11457           if (complete_function_arguments (qual_wfl))
11458             return 1;
11459
11460           /* We might have to setup a new current class and a new this
11461              for the search of an inner class, relative to the type of
11462              a expression resolved as `decl'. The current values are
11463              saved and restored shortly after */
11464           saved_current = current_class;
11465           saved_this = current_this;
11466           if (decl && TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
11467             {
11468               current_class = type;
11469               current_this = decl;
11470             }
11471
11472           if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
11473             CALL_USING_SUPER (qual_wfl) = 1;
11474           location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
11475                       EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
11476           *where_found = patch_method_invocation (qual_wfl, decl, type, 
11477                                                   &is_static, &ret_decl);
11478           if (*where_found == error_mark_node)
11479             {
11480               RESTORE_THIS_AND_CURRENT_CLASS;
11481               return 1;
11482             }
11483           *type_found = type = QUAL_DECL_TYPE (*where_found);
11484
11485           /* If we're creating an inner class instance, check for that
11486              an enclosing instance is in scope */
11487           if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
11488               && INNER_ENCLOSING_SCOPE_CHECK (type))
11489             {
11490               parse_error_context 
11491                 (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
11492                  lang_printable_name (type, 0),
11493                  (!current_this ? "" :
11494                   "; an explicit one must be provided when creating this inner class"));
11495               RESTORE_THIS_AND_CURRENT_CLASS;
11496               return 1;
11497             }
11498
11499           /* In case we had to change then to resolve a inner class
11500              instantiation using a primary qualified by a `new' */
11501           RESTORE_THIS_AND_CURRENT_CLASS;
11502
11503           /* EH check */
11504           if (location)
11505             check_thrown_exceptions (location, ret_decl);
11506
11507           /* If the previous call was static and this one is too,
11508              build a compound expression to hold the two (because in
11509              that case, previous function calls aren't transported as
11510              forcoming function's argument. */
11511           if (previous_call_static && is_static)
11512             {
11513               decl = build (COMPOUND_EXPR, type, decl, *where_found);
11514               TREE_SIDE_EFFECTS (decl) = 1;
11515             }
11516           else
11517             {
11518               previous_call_static = is_static;
11519               decl = *where_found;
11520             }
11521           from_type = 0;
11522           continue;
11523
11524         case NEW_ARRAY_EXPR:
11525         case NEW_ANONYMOUS_ARRAY_EXPR:
11526           *where_found = decl = java_complete_tree (qual_wfl);
11527           if (decl == error_mark_node)
11528             return 1;
11529           *type_found = type = QUAL_DECL_TYPE (decl);
11530           CLASS_LOADED_P (type) = 1;
11531           continue;
11532
11533         case CONVERT_EXPR:
11534           *where_found = decl = java_complete_tree (qual_wfl);
11535           if (decl == error_mark_node)
11536             return 1;
11537           *type_found = type = QUAL_DECL_TYPE (decl);
11538           from_cast = 1;
11539           continue;
11540
11541         case CONDITIONAL_EXPR:
11542         case STRING_CST:
11543         case MODIFY_EXPR:
11544           *where_found = decl = java_complete_tree (qual_wfl);
11545           if (decl == error_mark_node)
11546             return 1;
11547           *type_found = type = QUAL_DECL_TYPE (decl);
11548           continue;
11549
11550         case ARRAY_REF:
11551           /* If the access to the function call is a non static field,
11552              build the code to access it. */
11553           if (JDECL_P (decl) && !FIELD_STATIC (decl))
11554             {
11555               decl = maybe_access_field (decl, *where_found, type);
11556               if (decl == error_mark_node)
11557                 return 1;
11558             }
11559           /* And code for the array reference expression */
11560           decl = java_complete_tree (qual_wfl);
11561           if (decl == error_mark_node)
11562             return 1;
11563           type = QUAL_DECL_TYPE (decl);
11564           continue;
11565
11566         case PLUS_EXPR:
11567           if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11568             return 1;
11569           if ((type = patch_string (decl)))
11570             decl = type;
11571           *where_found = QUAL_RESOLUTION (q) = decl;
11572           *type_found = type = TREE_TYPE (decl);
11573           break;
11574
11575         case CLASS_LITERAL:
11576           if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11577             return 1;
11578           *where_found = QUAL_RESOLUTION (q) = decl;
11579           *type_found = type = TREE_TYPE (decl);
11580           break;
11581
11582         default:
11583           /* Fix for -Wall Just go to the next statement. Don't
11584              continue */
11585           break;
11586         }
11587
11588       /* If we fall here, we weren't processing a (static) function call. */
11589       previous_call_static = 0;
11590
11591       /* It can be the keyword THIS */
11592       if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
11593         {
11594           if (!current_this)
11595             {
11596               parse_error_context 
11597                 (wfl, "Keyword `this' used outside allowed context");
11598               return 1;
11599             }
11600           if (ctxp->explicit_constructor_p)
11601             {
11602               parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
11603               return 1;
11604             }
11605           /* We have to generate code for intermediate acess */
11606           if (!from_type || TREE_TYPE (TREE_TYPE (current_this)) == type)
11607             {
11608               *where_found = decl = current_this;
11609               *type_found = type = QUAL_DECL_TYPE (decl);
11610             }
11611           /* We're trying to access the this from somewhere else... */
11612           else
11613             {
11614               *where_found = decl = build_current_thisn (type);
11615               from_qualified_this = 1;
11616             }
11617
11618           from_type = 0;
11619           continue;
11620         }
11621
11622       /* 15.10.2 Accessing Superclass Members using SUPER */
11623       if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
11624         {
11625           tree node;
11626           /* Check on the restricted use of SUPER */
11627           if (METHOD_STATIC (current_function_decl)
11628               || current_class == object_type_node)
11629             {
11630               parse_error_context 
11631                 (wfl, "Keyword `super' used outside allowed context");
11632               return 1;
11633             }
11634           /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
11635           node = build_cast (EXPR_WFL_LINECOL (qual_wfl), 
11636                              CLASSTYPE_SUPER (current_class),
11637                              build_this (EXPR_WFL_LINECOL (qual_wfl)));
11638           *where_found = decl = java_complete_tree (node);
11639           if (decl == error_mark_node)
11640             return 1;
11641           *type_found = type = QUAL_DECL_TYPE (decl);
11642           from_super = from_type = 1;
11643           continue;
11644         }
11645
11646       /* 15.13.1: Can't search for field name in packages, so we
11647          assume a variable/class name was meant. */
11648       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
11649         {
11650           tree name = resolve_package (wfl, &q);
11651           if (name)
11652             {
11653               tree list;
11654               *where_found = decl = resolve_no_layout (name, qual_wfl);
11655               /* We want to be absolutely sure that the class is laid
11656                  out. We're going to search something inside it. */
11657               *type_found = type = TREE_TYPE (decl);
11658               layout_class (type);
11659               from_type = 1;
11660
11661               /* Fix them all the way down, if any are left. */
11662               if (q)
11663                 {
11664                   list = TREE_CHAIN (q);
11665                   while (list)
11666                     {
11667                       RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
11668                       RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
11669                       list = TREE_CHAIN (list);
11670                     }
11671                 }
11672             }
11673           else
11674             {
11675               if (from_super || from_cast)
11676                 parse_error_context 
11677                   ((from_cast ? qual_wfl : wfl),
11678                    "No variable `%s' defined in class `%s'",
11679                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11680                    lang_printable_name (type, 0));
11681               else
11682                 parse_error_context
11683                   (qual_wfl, "Undefined variable or class name: `%s'",
11684                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
11685               return 1;
11686             }
11687         }
11688
11689       /* We have a type name. It's been already resolved when the
11690          expression was qualified. */
11691       else if (RESOLVE_TYPE_NAME_P (qual_wfl))
11692         {
11693           if (!(decl = QUAL_RESOLUTION (q)))
11694             return 1;           /* Error reported already */
11695
11696           /* Sneak preview. If next we see a `new', we're facing a
11697              qualification with resulted in a type being selected
11698              instead of a field.  Report the error */
11699           if(TREE_CHAIN (q) 
11700              && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
11701             {
11702               parse_error_context (qual_wfl, "Undefined variable `%s'",
11703                                    IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11704               return 1;
11705             }
11706
11707           if (not_accessible_p (TREE_TYPE (decl), decl, 0))
11708             {
11709               parse_error_context 
11710                 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
11711                  java_accstring_lookup (get_access_flags_from_decl (decl)),
11712                  GET_TYPE_NAME (type),
11713                  IDENTIFIER_POINTER (DECL_NAME (decl)),
11714                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
11715               return 1;
11716             }
11717           check_deprecation (qual_wfl, decl);
11718
11719           type = TREE_TYPE (decl);
11720           from_type = 1;
11721         }
11722       /* We resolve and expression name */
11723       else 
11724         {
11725           tree field_decl = NULL_TREE;
11726
11727           /* If there exists an early resolution, use it. That occurs
11728              only once and we know that there are more things to
11729              come. Don't do that when processing something after SUPER
11730              (we need more thing to be put in place below */
11731           if (!from_super && QUAL_RESOLUTION (q))
11732             {
11733               decl = QUAL_RESOLUTION (q);
11734               if (!type)
11735                 {
11736                   if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
11737                     {
11738                       if (current_this)
11739                         *where_found = current_this;
11740                       else
11741                         {
11742                           static_ref_err (qual_wfl, DECL_NAME (decl),
11743                                           current_class);
11744                           return 1;
11745                         }
11746                     }
11747                   else
11748                     {
11749                       *where_found = TREE_TYPE (decl);
11750                       if (TREE_CODE (*where_found) == POINTER_TYPE)
11751                         *where_found = TREE_TYPE (*where_found);
11752                     }
11753                 }
11754             }
11755
11756           /* We have to search for a field, knowing the type of its
11757              container. The flag FROM_TYPE indicates that we resolved
11758              the last member of the expression as a type name, which
11759              means that for the resolution of this field, we'll look
11760              for other errors than if it was resolved as a member of
11761              an other field. */
11762           else
11763             {
11764               int is_static;
11765               tree field_decl_type; /* For layout */
11766
11767               if (!from_type && !JREFERENCE_TYPE_P (type))
11768                 {
11769                   parse_error_context 
11770                     (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
11771                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11772                      lang_printable_name (type, 0),
11773                      IDENTIFIER_POINTER (DECL_NAME (field_decl)));
11774                   return 1;
11775                 }
11776               
11777               field_decl = lookup_field_wrapper (type,
11778                                                  EXPR_WFL_NODE (qual_wfl));
11779               if (field_decl == NULL_TREE)
11780                 {
11781                   parse_error_context 
11782                     (qual_wfl, "No variable `%s' defined in type `%s'",
11783                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)), 
11784                      GET_TYPE_NAME (type));
11785                   return 1;
11786                 }
11787               if (field_decl == error_mark_node)
11788                 return 1;
11789
11790               /* Layout the type of field_decl, since we may need
11791                  it. Don't do primitive types or loaded classes. The
11792                  situation of non primitive arrays may not handled
11793                  properly here. FIXME */
11794               if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
11795                 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
11796               else
11797                 field_decl_type = TREE_TYPE (field_decl);
11798               if (!JPRIMITIVE_TYPE_P (field_decl_type) 
11799                   && !CLASS_LOADED_P (field_decl_type)
11800                   && !TYPE_ARRAY_P (field_decl_type))
11801                 resolve_and_layout (field_decl_type, NULL_TREE);
11802               if (TYPE_ARRAY_P (field_decl_type))
11803                 CLASS_LOADED_P (field_decl_type) = 1;
11804               
11805               /* Check on accessibility here */
11806               if (not_accessible_p (type, field_decl, from_super))
11807                 {
11808                   parse_error_context 
11809                     (qual_wfl,
11810                      "Can't access %s field `%s.%s' from `%s'",
11811                      java_accstring_lookup 
11812                        (get_access_flags_from_decl (field_decl)),
11813                      GET_TYPE_NAME (type),
11814                      IDENTIFIER_POINTER (DECL_NAME (field_decl)),
11815                      IDENTIFIER_POINTER 
11816                        (DECL_NAME (TYPE_NAME (current_class))));
11817                   return 1;
11818                 }
11819               check_deprecation (qual_wfl, field_decl);
11820               
11821               /* There are things to check when fields are accessed
11822                  from type. There are no restrictions on a static
11823                  declaration of the field when it is accessed from an
11824                  interface */
11825               is_static = FIELD_STATIC (field_decl);
11826               if (!from_super && from_type 
11827                   && !TYPE_INTERFACE_P (type) 
11828                   && !is_static 
11829                   && (current_function_decl 
11830                       && METHOD_STATIC (current_function_decl)))
11831                 {
11832                   static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
11833                   return 1;
11834                 }
11835               from_cast = from_super = 0;
11836
11837               /* It's an access from a type but it isn't static, we
11838                  make it relative to `this'. */
11839               if (!is_static && from_type)
11840                 decl = current_this;
11841
11842               /* If we need to generate something to get a proper
11843                  handle on what this field is accessed from, do it
11844                  now. */
11845               if (!is_static)
11846                 {
11847                   decl = maybe_access_field (decl, *where_found, *type_found);
11848                   if (decl == error_mark_node)
11849                     return 1;
11850                 }
11851
11852               /* We want to keep the location were found it, and the type
11853                  we found. */
11854               *where_found = decl;
11855               *type_found = type;
11856
11857               /* Generate the correct expression for field access from
11858                  qualified this */
11859               if (from_qualified_this)
11860                 {
11861                   field_decl = build_outer_field_access (qual_wfl, field_decl);
11862                   from_qualified_this = 0;
11863                 }
11864
11865               /* This is the decl found and eventually the next one to
11866                  search from */
11867               decl = field_decl;
11868             }
11869           from_type = 0;
11870           type = QUAL_DECL_TYPE (decl);
11871
11872           /* Sneak preview. If decl is qualified by a `new', report
11873              the error here to be accurate on the peculiar construct */
11874           if (TREE_CHAIN (q) 
11875               && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
11876               && !JREFERENCE_TYPE_P (type))
11877             {
11878               parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'", 
11879                                    lang_printable_name (type, 0));
11880               return 1;
11881             }
11882         }
11883       /* `q' might have changed due to a after package resolution
11884          re-qualification */
11885       if (!q)
11886         break;
11887     }
11888   *found_decl = decl;
11889   return 0;
11890 }
11891
11892 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
11893    can't be accessed from REFERENCE (a record type). */
11894
11895 static int
11896 not_accessible_p (reference, member, from_super)
11897      tree reference, member;
11898      int from_super;
11899 {
11900   int access_flag = get_access_flags_from_decl (member);
11901
11902   /* Access always granted for members declared public */
11903   if (access_flag & ACC_PUBLIC)
11904     return 0;
11905   
11906   /* Check access on protected members */
11907   if (access_flag & ACC_PROTECTED)
11908     {
11909       /* Access granted if it occurs from within the package
11910          containing the class in which the protected member is
11911          declared */
11912       if (class_in_current_package (DECL_CONTEXT (member)))
11913         return 0;
11914
11915       /* If accessed with the form `super.member', then access is granted */
11916       if (from_super)
11917         return 0;
11918
11919       /* Otherwise, access is granted if occuring from the class where
11920          member is declared or a subclass of it */
11921       if (inherits_from_p (reference, DECL_CONTEXT (member)))
11922         return 0;
11923       return 1;
11924     }
11925
11926   /* Check access on private members. Access is granted only if it
11927      occurs from within the class in which it is declared. Exceptions
11928      are accesses from inner-classes. This section is probably not
11929      complete. FIXME */
11930   if (access_flag & ACC_PRIVATE)
11931     return (current_class == DECL_CONTEXT (member) ? 0 : 
11932             (INNER_CLASS_TYPE_P (current_class) ? 0 : 1));
11933
11934   /* Default access are permitted only when occuring within the
11935      package in which the type (REFERENCE) is declared. In other words,
11936      REFERENCE is defined in the current package */
11937   if (ctxp->package)
11938     return !class_in_current_package (reference);
11939
11940   /* Otherwise, access is granted */
11941   return 0;
11942 }
11943
11944 /* Test deprecated decl access.  */
11945 static void
11946 check_deprecation (wfl, decl)
11947      tree wfl, decl;
11948 {
11949   const char *file = DECL_SOURCE_FILE (decl);
11950   /* Complain if the field is deprecated and the file it was defined
11951      in isn't compiled at the same time the file which contains its
11952      use is */
11953   if (DECL_DEPRECATED (decl) 
11954       && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
11955     {
11956       char the [20];
11957       switch (TREE_CODE (decl))
11958         {
11959         case FUNCTION_DECL:
11960           strcpy (the, "method");
11961           break;
11962         case FIELD_DECL:
11963           strcpy (the, "field");
11964           break;
11965         case TYPE_DECL:
11966           strcpy (the, "class");
11967           break;
11968         default:
11969           fatal ("unexpected DECL code - check_deprecation");
11970         }
11971       parse_warning_context 
11972         (wfl, "The %s `%s' in class `%s' has been deprecated", 
11973          the, lang_printable_name (decl, 0),
11974          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
11975     }
11976 }
11977
11978 /* Returns 1 if class was declared in the current package, 0 otherwise */
11979
11980 static int
11981 class_in_current_package (class)
11982      tree class;
11983 {
11984   static tree cache = NULL_TREE;
11985   int qualified_flag;
11986   tree left;
11987
11988   if (cache == class)
11989     return 1;
11990
11991   qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
11992
11993   /* If the current package is empty and the name of CLASS is
11994      qualified, class isn't in the current package.  If there is a
11995      current package and the name of the CLASS is not qualified, class
11996      isn't in the current package */
11997   if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
11998     return 0;
11999
12000   /* If there is not package and the name of CLASS isn't qualified,
12001      they belong to the same unnamed package */
12002   if (!ctxp->package && !qualified_flag)
12003     return 1;
12004
12005   /* Compare the left part of the name of CLASS with the package name */
12006   breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
12007   if (ctxp->package == left)
12008     {
12009       cache = class;
12010       return 1;
12011     }
12012   return 0;
12013 }
12014
12015 /* This function may generate code to access DECL from WHERE. This is
12016    done only if certain conditions meet.  */
12017
12018 static tree
12019 maybe_access_field (decl, where, type)
12020   tree decl, where, type;
12021 {
12022   if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
12023       && !FIELD_STATIC (decl))
12024     decl = build_field_ref (where ? where : current_this, 
12025                             (type ? type : DECL_CONTEXT (decl)),
12026                             DECL_NAME (decl));
12027   return decl;
12028 }
12029
12030 /* Build a method invocation, by patching PATCH. If non NULL
12031    and according to the situation, PRIMARY and WHERE may be
12032    used. IS_STATIC is set to 1 if the invoked function is static. */
12033
12034 static tree
12035 patch_method_invocation (patch, primary, where, is_static, ret_decl)
12036      tree patch, primary, where;
12037      int *is_static;
12038      tree *ret_decl;
12039 {
12040   tree wfl = TREE_OPERAND (patch, 0);
12041   tree args = TREE_OPERAND (patch, 1);
12042   tree name = EXPR_WFL_NODE (wfl);
12043   tree list;
12044   int is_static_flag = 0;
12045   int is_super_init = 0;
12046   tree this_arg = NULL_TREE;
12047   
12048   /* Should be overriden if everything goes well. Otherwise, if
12049      something fails, it should keep this value. It stop the
12050      evaluation of a bogus assignment. See java_complete_tree,
12051      MODIFY_EXPR: for the reasons why we sometimes want to keep on
12052      evaluating an assignment */
12053   TREE_TYPE (patch) = error_mark_node;
12054
12055   /* Since lookup functions are messing with line numbers, save the
12056      context now.  */
12057   java_parser_context_save_global ();
12058
12059   /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
12060
12061   /* Resolution of qualified name, excluding constructors */
12062   if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
12063     {
12064       tree identifier, identifier_wfl, type, resolved;
12065       /* Extract the last IDENTIFIER of the qualified
12066          expression. This is a wfl and we will use it's location
12067          data during error report. */
12068       identifier_wfl = cut_identifier_in_qualified (wfl);
12069       identifier = EXPR_WFL_NODE (identifier_wfl);
12070       
12071       /* Given the context, IDENTIFIER is syntactically qualified
12072          as a MethodName. We need to qualify what's before */
12073       qualify_ambiguous_name (wfl);
12074       resolved = resolve_field_access (wfl, NULL, NULL);
12075
12076       if (resolved == error_mark_node)
12077         PATCH_METHOD_RETURN_ERROR ();
12078
12079       type = GET_SKIP_TYPE (resolved);
12080       resolve_and_layout (type, NULL_TREE);
12081       list = lookup_method_invoke (0, identifier_wfl, type, identifier, args);
12082       args = nreverse (args);
12083
12084       /* We're resolving a call from a type */
12085       if (TREE_CODE (resolved) == TYPE_DECL)
12086         {
12087           if (CLASS_INTERFACE (resolved))
12088             {
12089               parse_error_context
12090                 (identifier_wfl,
12091                 "Can't make static reference to method `%s' in interface `%s'",
12092                  IDENTIFIER_POINTER (identifier), 
12093                  IDENTIFIER_POINTER (name));
12094               PATCH_METHOD_RETURN_ERROR ();
12095             }
12096           if (list && !METHOD_STATIC (list))
12097             {
12098               char *fct_name = xstrdup (lang_printable_name (list, 0));
12099               parse_error_context 
12100                 (identifier_wfl,
12101                  "Can't make static reference to method `%s %s' in class `%s'",
12102                  lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
12103                  fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
12104               free (fct_name);
12105               PATCH_METHOD_RETURN_ERROR ();
12106             }
12107         }
12108       else
12109         this_arg = primary = resolved;
12110       
12111       /* IDENTIFIER_WFL will be used to report any problem further */
12112       wfl = identifier_wfl;
12113     }
12114   /* Resolution of simple names, names generated after a primary: or
12115      constructors */
12116   else
12117     {
12118       tree class_to_search = NULL_TREE;
12119       int lc;                   /* Looking for Constructor */
12120       
12121       /* We search constructor in their target class */
12122       if (CALL_CONSTRUCTOR_P (patch))
12123         {
12124           if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12125             class_to_search = EXPR_WFL_NODE (wfl);
12126           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) == 
12127                    this_identifier_node)
12128             class_to_search = NULL_TREE;
12129           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12130                    super_identifier_node)
12131             {
12132               is_super_init = 1;
12133               if (CLASSTYPE_SUPER (current_class))
12134                 class_to_search = 
12135                   DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
12136               else
12137                 {
12138                   parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object");
12139                   PATCH_METHOD_RETURN_ERROR ();
12140                 }
12141             }
12142
12143           /* Class to search is NULL if we're searching the current one */
12144           if (class_to_search)
12145             {
12146               class_to_search = resolve_and_layout (class_to_search, wfl);
12147
12148               if (!class_to_search)
12149                 {
12150                   parse_error_context 
12151                     (wfl, "Class `%s' not found in type declaration",
12152                      IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12153                   PATCH_METHOD_RETURN_ERROR ();
12154                 }
12155               
12156               /* Can't instantiate an abstract class, but we can
12157                  invoke it's constructor. It's use within the `new'
12158                  context is denied here. */
12159               if (CLASS_ABSTRACT (class_to_search) 
12160                   && TREE_CODE (patch) == NEW_CLASS_EXPR)
12161                 {
12162                   parse_error_context 
12163                     (wfl, "Class `%s' is an abstract class. It can't be instantiated",
12164                      IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12165                   PATCH_METHOD_RETURN_ERROR ();
12166                 }
12167
12168               class_to_search = TREE_TYPE (class_to_search);
12169             }
12170           else
12171             class_to_search = current_class;
12172           lc = 1;
12173         }
12174       /* This is a regular search in the local class, unless an
12175          alternate class is specified. */
12176       else
12177         {
12178           class_to_search = (where ? where : current_class);
12179           lc = 0;
12180         }
12181
12182       /* NAME is a simple identifier or comes from a primary. Search
12183          in the class whose declaration contain the method being
12184          invoked. */
12185       resolve_and_layout (class_to_search, NULL_TREE);
12186
12187       list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
12188       /* Don't continue if no method were found, as the next statement
12189          can't be executed then. */
12190       if (!list)
12191         PATCH_METHOD_RETURN_ERROR ();
12192
12193       /* Check for static reference if non static methods */
12194       if (check_for_static_method_reference (wfl, patch, list, 
12195                                              class_to_search, primary))
12196         PATCH_METHOD_RETURN_ERROR ();
12197
12198       /* Check for inner classes creation from illegal contexts */
12199       if (lc && (INNER_CLASS_TYPE_P (class_to_search)
12200                  && !CLASS_STATIC (TYPE_NAME (class_to_search)))
12201           && INNER_ENCLOSING_SCOPE_CHECK (class_to_search))
12202         {
12203           parse_error_context 
12204             (wfl, "No enclosing instance for inner class `%s' is in scope%s",
12205              lang_printable_name (class_to_search, 0),
12206              (!current_this ? "" :
12207               "; an explicit one must be provided when creating this inner class"));
12208           PATCH_METHOD_RETURN_ERROR ();
12209         }
12210
12211       /* Non static methods are called with the current object extra
12212          argument. If patch a `new TYPE()', the argument is the value
12213          returned by the object allocator. If method is resolved as a
12214          primary, use the primary otherwise use the current THIS. */
12215       args = nreverse (args);
12216       if (TREE_CODE (patch) != NEW_CLASS_EXPR)
12217         {
12218           this_arg = primary ? primary : current_this;
12219
12220           /* If we're using an access method, things are different.
12221              There are two familly of cases:
12222
12223              1) We're not generating bytecodes:
12224
12225              - LIST is non static. It's invocation is transformed from
12226                x(a1,...,an) into this$<n>.x(a1,....an).
12227              - LIST is static. It's invocation is transformed from
12228                x(a1,...,an) into TYPE_OF(this$<n>).x(a1,....an)
12229
12230              2) We're generating bytecodes:
12231              
12232              - LIST is non static. It's invocation is transformed from
12233                x(a1,....,an) into access$<n>(this$<n>,a1,...,an).
12234              - LIST is static. It's invocation is transformed from
12235                x(a1,....,an) into TYPEOF(this$<n>).x(a1,....an).
12236
12237              Of course, this$<n> can be abitrary complex, ranging from
12238              this$0 (the immediate outer context) to 
12239              access$0(access$0(...(this$0))). 
12240              
12241              maybe_use_access_method returns a non zero value if the
12242              this_arg has to be moved into the (then generated) stub
12243              argument list. In the mean time, the selected function
12244              might have be replaced by a generated stub. */
12245           if (maybe_use_access_method (is_super_init, &list, &this_arg))
12246             args = tree_cons (NULL_TREE, this_arg, args);
12247         }
12248     }
12249
12250   /* Merge point of all resolution schemes. If we have nothing, this
12251      is an error, already signaled */
12252   if (!list) 
12253     PATCH_METHOD_RETURN_ERROR ();
12254
12255   /* Check accessibility, position the is_static flag, build and
12256      return the call */
12257   if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
12258     {
12259       char *fct_name = xstrdup (lang_printable_name (list, 0));
12260       parse_error_context 
12261         (wfl, "Can't access %s method `%s %s.%s' from `%s'",
12262          java_accstring_lookup (get_access_flags_from_decl (list)),
12263          lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
12264          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))), 
12265          fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
12266       free (fct_name);
12267       PATCH_METHOD_RETURN_ERROR ();
12268     }
12269   check_deprecation (wfl, list);
12270
12271   /* If invoking a innerclass constructor, there are hidden parameters
12272      to pass */
12273   if (TREE_CODE (patch) == NEW_CLASS_EXPR 
12274       && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12275     {
12276       /* And make sure we add the accessed local variables to be saved
12277          in field aliases. */
12278       args = build_alias_initializer_parameter_list
12279         (AIPL_FUNCTION_CTOR_INVOCATION, DECL_CONTEXT (list), args, NULL);
12280
12281       /* We have to reverse things. Find out why. FIXME */
12282       if (ANONYMOUS_CLASS_P (DECL_CONTEXT (list)))
12283         args = nreverse (args);
12284       
12285       /* Secretely pass the current_this/primary as a second argument */
12286       if (primary || current_this)
12287         args = tree_cons (NULL_TREE, (primary ? primary : current_this), args);
12288       else
12289         args = tree_cons (NULL_TREE, integer_zero_node, args);
12290     }
12291
12292   /* This handles the situation where a constructor invocation needs
12293      to have an enclosing context passed as a second parameter (the
12294      constructor is one of an inner class. We extract it from the
12295      current function.  */
12296   if (is_super_init && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12297     {
12298       tree enclosing_decl = DECL_CONTEXT (TYPE_NAME (current_class));
12299       tree extra_arg;
12300
12301       if (ANONYMOUS_CLASS_P (current_class) || !DECL_CONTEXT (enclosing_decl))
12302         {
12303           extra_arg = DECL_FUNCTION_BODY (current_function_decl);
12304           extra_arg = TREE_CHAIN (BLOCK_EXPR_DECLS (extra_arg));
12305         }
12306       else
12307         {
12308           tree dest = TREE_TYPE (DECL_CONTEXT (enclosing_decl));
12309           extra_arg = 
12310             build_access_to_thisn (TREE_TYPE (enclosing_decl), dest, 0);
12311           extra_arg = java_complete_tree (extra_arg);
12312         }
12313       args = tree_cons (NULL_TREE, extra_arg, args);
12314     }
12315
12316   is_static_flag = METHOD_STATIC (list);
12317   if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
12318     args = tree_cons (NULL_TREE, this_arg, args);
12319
12320   /* In the context of an explicit constructor invocation, we can't
12321      invoke any method relying on `this'. Exceptions are: we're
12322      invoking a static function, primary exists and is not the current
12323      this, we're creating a new object. */
12324   if (ctxp->explicit_constructor_p 
12325       && !is_static_flag 
12326       && (!primary || primary == current_this)
12327       && (TREE_CODE (patch) != NEW_CLASS_EXPR))
12328     {
12329       parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
12330       PATCH_METHOD_RETURN_ERROR ();
12331     }
12332   java_parser_context_restore_global ();
12333   if (is_static) 
12334     *is_static = is_static_flag;
12335   /* Sometimes, we want the decl of the selected method. Such as for
12336      EH checking */
12337   if (ret_decl)
12338     *ret_decl = list;
12339   patch = patch_invoke (patch, list, args);
12340   if (is_super_init && CLASS_HAS_FINIT_P (current_class))
12341     {
12342       tree finit_parms, finit_call;
12343       
12344       /* Prepare to pass hidden parameters to $finit$, if any. */
12345       finit_parms = build_alias_initializer_parameter_list 
12346         (AIPL_FUNCTION_FINIT_INVOCATION, current_class, NULL_TREE, NULL);
12347
12348       finit_call = 
12349         build_method_invocation (build_wfl_node (finit_identifier_node),
12350                                  finit_parms);
12351
12352       /* Generate the code used to initialize fields declared with an
12353          initialization statement and build a compound statement along
12354          with the super constructor invocation. */
12355       patch = build (COMPOUND_EXPR, void_type_node, patch,
12356                      java_complete_tree (finit_call));
12357       CAN_COMPLETE_NORMALLY (patch) = 1;
12358     }
12359   return patch;
12360 }
12361
12362 /* Check that we're not trying to do a static reference to a method in
12363    non static method. Return 1 if it's the case, 0 otherwise. */
12364
12365 static int
12366 check_for_static_method_reference (wfl, node, method, where, primary)
12367      tree wfl, node, method, where, primary;
12368 {
12369   if (METHOD_STATIC (current_function_decl) 
12370       && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
12371     {
12372       char *fct_name = xstrdup (lang_printable_name (method, 0));
12373       parse_error_context 
12374         (wfl, "Can't make static reference to method `%s %s' in class `%s'", 
12375          lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
12376          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
12377       free (fct_name);
12378       return 1;
12379     }
12380   return 0;
12381 }
12382
12383 /* Fix the invocation of *MDECL if necessary in the case of a
12384    invocation from an inner class. *THIS_ARG might be modified
12385    appropriately and an alternative access to *MDECL might be
12386    returned.  */
12387
12388 static int
12389 maybe_use_access_method (is_super_init, mdecl, this_arg)
12390      int is_super_init;
12391      tree *mdecl, *this_arg;
12392 {
12393   tree ctx;
12394   tree md = *mdecl, ta = *this_arg;
12395   int to_return = 0;
12396   int non_static_context = !METHOD_STATIC (md);
12397
12398   if (is_super_init 
12399       || DECL_CONTEXT (md) == current_class
12400       || !PURE_INNER_CLASS_TYPE_P (current_class) 
12401       || DECL_FINIT_P (md))
12402     return 0;
12403   
12404   /* If we're calling a method found in an enclosing class, generate
12405      what it takes to retrieve the right this. Don't do that if we're
12406      invoking a static method. */
12407
12408   if (non_static_context)
12409     {
12410       ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
12411       if (ctx == DECL_CONTEXT (md))
12412         {
12413           ta = build_current_thisn (current_class);
12414           ta = build_wfl_node (ta);
12415         }
12416       else
12417         {
12418           tree type = ctx;
12419           while (type)
12420             {
12421               maybe_build_thisn_access_method (type);
12422               if (type == DECL_CONTEXT (md))
12423                 {
12424                   ta = build_access_to_thisn (ctx, type, 0);
12425                   break;
12426                 }
12427               type = (DECL_CONTEXT (TYPE_NAME (type)) ? 
12428                       TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))) : NULL_TREE);
12429             }
12430         }
12431       ta = java_complete_tree (ta);
12432     }
12433
12434   /* We might have to use an access method to get to MD. We can
12435      break the method access rule as far as we're not generating
12436      bytecode */
12437   if (METHOD_PRIVATE (md) && flag_emit_class_files)
12438     {
12439       md = build_outer_method_access_method (md);
12440       to_return = 1;
12441     }
12442
12443   *mdecl = md;
12444   *this_arg = ta;
12445
12446   /* Returnin a non zero value indicates we were doing a non static
12447      method invokation that is now a static invocation. It will have
12448      callee displace `this' to insert it in the regular argument
12449      list. */
12450   return (non_static_context && to_return);
12451 }
12452
12453 /* Patch an invoke expression METHOD and ARGS, based on its invocation
12454    mode.  */
12455
12456 static tree
12457 patch_invoke (patch, method, args)
12458      tree patch, method, args;
12459 {
12460   tree dtable, func;
12461   tree original_call, t, ta;
12462   tree cond = NULL_TREE;
12463
12464   /* Last step for args: convert build-in types. If we're dealing with
12465      a new TYPE() type call, the first argument to the constructor
12466      isn't found in the incoming argument list, but delivered by
12467      `new' */
12468   t = TYPE_ARG_TYPES (TREE_TYPE (method));
12469   if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12470     t = TREE_CHAIN (t);
12471   for (ta = args; t != end_params_node && ta; 
12472        t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
12473     if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
12474         TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
12475       TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
12476
12477   /* Resolve unresolved returned type isses */
12478   t = TREE_TYPE (TREE_TYPE (method));
12479   if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
12480     resolve_and_layout (TREE_TYPE (t), NULL);
12481
12482   if (flag_emit_class_files || flag_emit_xref)
12483     func = method;
12484   else
12485     {
12486       tree signature = build_java_signature (TREE_TYPE (method));
12487       switch (invocation_mode (method, CALL_USING_SUPER (patch)))
12488         {
12489         case INVOKE_VIRTUAL:
12490           dtable = invoke_build_dtable (0, args);
12491           func = build_invokevirtual (dtable, method);
12492           break;
12493
12494         case INVOKE_NONVIRTUAL:
12495           /* If the object for the method call is null, we throw an
12496              exception.  We don't do this if the object is the current
12497              method's `this'.  In other cases we just rely on an
12498              optimization pass to eliminate redundant checks.  */
12499           if (TREE_VALUE (args) != current_this)
12500             {
12501               /* We use a SAVE_EXPR here to make sure we only evaluate
12502                  the new `self' expression once.  */
12503               tree save_arg = save_expr (TREE_VALUE (args));
12504               TREE_VALUE (args) = save_arg;
12505               cond = build (EQ_EXPR, boolean_type_node, save_arg,
12506                             null_pointer_node);
12507             }
12508           /* Fall through.  */
12509
12510         case INVOKE_SUPER:
12511         case INVOKE_STATIC:
12512           func = build_known_method_ref (method, TREE_TYPE (method),
12513                                          DECL_CONTEXT (method),
12514                                          signature, args);
12515           break;
12516
12517         case INVOKE_INTERFACE:
12518           dtable = invoke_build_dtable (1, args);
12519           func = build_invokeinterface (dtable, method);
12520           break;
12521
12522         default:
12523           fatal ("internal error - unknown invocation_mode result");
12524         }
12525
12526       /* Ensure self_type is initialized, (invokestatic). FIXME */
12527       func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
12528     }
12529
12530   TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
12531   TREE_OPERAND (patch, 0) = func;
12532   TREE_OPERAND (patch, 1) = args;
12533   original_call = patch;
12534
12535   /* We're processing a `new TYPE ()' form. New is called and its
12536      returned value is the first argument to the constructor. We build
12537      a COMPOUND_EXPR and use saved expression so that the overall NEW
12538      expression value is a pointer to a newly created and initialized
12539      class. */
12540   if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
12541     {
12542       tree class = DECL_CONTEXT (method);
12543       tree c1, saved_new, size, new;
12544       if (flag_emit_class_files || flag_emit_xref)
12545         {
12546           TREE_TYPE (patch) = build_pointer_type (class);
12547           return patch;
12548         }
12549       if (!TYPE_SIZE (class))
12550         safe_layout_class (class);
12551       size = size_in_bytes (class);
12552       new = build (CALL_EXPR, promote_type (class),
12553                    build_address_of (alloc_object_node),
12554                    tree_cons (NULL_TREE, build_class_ref (class),
12555                               build_tree_list (NULL_TREE, 
12556                                                size_in_bytes (class))),
12557                    NULL_TREE);
12558       saved_new = save_expr (new);
12559       c1 = build_tree_list (NULL_TREE, saved_new);
12560       TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
12561       TREE_OPERAND (original_call, 1) = c1;
12562       TREE_SET_CODE (original_call, CALL_EXPR);
12563       patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
12564     }
12565
12566   /* If COND is set, then we are building a check to see if the object
12567      is NULL.  */
12568   if (cond != NULL_TREE)
12569     {
12570       /* We have to make the `then' branch a compound expression to
12571          make the types turn out right.  This seems bizarre.  */
12572       patch = build (COND_EXPR, TREE_TYPE (patch), cond,
12573                      build (COMPOUND_EXPR, TREE_TYPE (patch),
12574                             build (CALL_EXPR, void_type_node,
12575                                    build_address_of (soft_nullpointer_node),
12576                                    NULL_TREE, NULL_TREE),
12577                             (FLOAT_TYPE_P (TREE_TYPE (patch))
12578                              ? build_real (TREE_TYPE (patch), dconst0)
12579                              : build1 (CONVERT_EXPR, TREE_TYPE (patch),
12580                                        integer_zero_node))),
12581                      patch);
12582       TREE_SIDE_EFFECTS (patch) = 1;
12583     }
12584
12585   return patch;
12586 }
12587
12588 static int
12589 invocation_mode (method, super)
12590      tree method;
12591      int super;
12592 {
12593   int access = get_access_flags_from_decl (method);
12594
12595   if (super)
12596     return INVOKE_SUPER;
12597
12598   if (access & ACC_STATIC)
12599     return INVOKE_STATIC;
12600
12601   /* We have to look for a constructor before we handle nonvirtual
12602      calls; otherwise the constructor will look nonvirtual.  */
12603   if (DECL_CONSTRUCTOR_P (method))
12604     return INVOKE_STATIC;
12605
12606   if (access & ACC_FINAL || access & ACC_PRIVATE)
12607     return INVOKE_NONVIRTUAL;
12608
12609   if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
12610     return INVOKE_NONVIRTUAL;
12611
12612   if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
12613     return INVOKE_INTERFACE;
12614
12615   return INVOKE_VIRTUAL;
12616 }
12617
12618 /* Retrieve a refined list of matching methods. It covers the step
12619    15.11.2 (Compile-Time Step 2) */
12620
12621 static tree
12622 lookup_method_invoke (lc, cl, class, name, arg_list)
12623      int lc;
12624      tree cl;
12625      tree class, name, arg_list;
12626 {
12627   tree atl = end_params_node;           /* Arg Type List */
12628   tree method, signature, list, node;
12629   const char *candidates;               /* Used for error report */
12630   char *dup;
12631
12632   /* Fix the arguments */
12633   for (node = arg_list; node; node = TREE_CHAIN (node))
12634     {
12635       tree current_arg = TREE_TYPE (TREE_VALUE (node));
12636       /* Non primitive type may have to be resolved */
12637       if (!JPRIMITIVE_TYPE_P (current_arg))
12638         resolve_and_layout (current_arg, NULL_TREE);
12639       /* And promoted */
12640       if (TREE_CODE (current_arg) == RECORD_TYPE)
12641         current_arg = promote_type (current_arg);
12642       atl = tree_cons (NULL_TREE, current_arg, atl);
12643     }
12644
12645   /* Presto. If we're dealing with an anonymous class and a
12646      constructor call, generate the right constructor now, since we
12647      know the arguments' types. */
12648
12649   if (lc && ANONYMOUS_CLASS_P (class))
12650     craft_constructor (TYPE_NAME (class), atl);
12651
12652   /* Find all candidates and then refine the list, searching for the
12653      most specific method. */
12654   list = find_applicable_accessible_methods_list (lc, class, name, atl);
12655   list = find_most_specific_methods_list (list);
12656   if (list && !TREE_CHAIN (list))
12657     return TREE_VALUE (list);
12658
12659   /* Issue an error. List candidates if any. Candidates are listed
12660      only if accessible (non accessible methods may end-up here for
12661      the sake of a better error report). */
12662   candidates = NULL;
12663   if (list)
12664     {
12665       tree current;
12666       obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
12667       for (current = list; current; current = TREE_CHAIN (current))
12668         {
12669           tree cm = TREE_VALUE (current);
12670           char string [4096];
12671           if (!cm || not_accessible_p (class, cm, 0))
12672             continue;
12673           sprintf 
12674             (string, "  `%s' in `%s'%s",
12675              get_printable_method_name (cm),
12676              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
12677              (TREE_CHAIN (current) ? "\n" : ""));
12678           obstack_grow (&temporary_obstack, string, strlen (string));
12679         }
12680       obstack_1grow (&temporary_obstack, '\0');
12681       candidates = obstack_finish (&temporary_obstack);
12682     }
12683   /* Issue the error message */
12684   method = make_node (FUNCTION_TYPE);
12685   TYPE_ARG_TYPES (method) = atl;
12686   signature = build_java_argument_signature (method);
12687   dup = xstrdup (lang_printable_name (class, 0));
12688   parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
12689                        (lc ? "constructor" : "method"),
12690                        (lc ? dup : IDENTIFIER_POINTER (name)),
12691                        IDENTIFIER_POINTER (signature), dup,
12692                        (candidates ? candidates : ""));
12693   free (dup);
12694   return NULL_TREE;
12695 }
12696
12697 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
12698    when we're looking for a constructor. */
12699
12700 static tree
12701 find_applicable_accessible_methods_list (lc, class, name, arglist)
12702      int lc;
12703      tree class, name, arglist;
12704 {
12705   static int object_done = 0;
12706   tree list = NULL_TREE, all_list = NULL_TREE;
12707
12708   if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
12709     {
12710       load_class (class, 1);
12711       safe_layout_class (class);
12712     }
12713
12714   /* Search interfaces */
12715   if (CLASS_INTERFACE (TYPE_NAME (class)))
12716     {
12717       static struct hash_table t, *searched_interfaces = NULL;
12718       static int search_not_done = 0;
12719       int i, n;
12720       tree basetype_vec = TYPE_BINFO_BASETYPES (class);
12721
12722       /* Search in the hash table, otherwise create a new one if
12723          necessary and insert the new entry. */
12724
12725       if (searched_interfaces)
12726         {
12727           if (hash_lookup (searched_interfaces, 
12728                            (const hash_table_key) class, FALSE, NULL))
12729             return NULL;
12730         }
12731       else
12732         {
12733           hash_table_init (&t, hash_newfunc, java_hash_hash_tree_node,
12734                            java_hash_compare_tree_node);
12735           searched_interfaces = &t;
12736         }
12737
12738       hash_lookup (searched_interfaces, 
12739                    (const hash_table_key) class, TRUE, NULL);
12740
12741       search_applicable_methods_list (lc, TYPE_METHODS (class), 
12742                                       name, arglist, &list, &all_list);
12743       n = TREE_VEC_LENGTH (basetype_vec);
12744       for (i = 1; i < n; i++)
12745         {
12746           tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12747           tree rlist;
12748
12749           search_not_done++;
12750           rlist = find_applicable_accessible_methods_list (lc,  t, name, 
12751                                                            arglist);
12752           list = chainon (rlist, list);
12753           search_not_done--;
12754         }
12755
12756       /* We're done. Reset the searched interfaces list and finally search
12757          java.lang.Object */
12758       if (!search_not_done)
12759         {  
12760           if (!object_done)
12761             search_applicable_methods_list (lc, 
12762                                             TYPE_METHODS (object_type_node),
12763                                             name, arglist, &list, &all_list);
12764           hash_table_free (searched_interfaces);
12765           searched_interfaces = NULL;  
12766         }
12767     }
12768   /* Search classes */
12769   else
12770     {
12771       tree sc = class;
12772       int seen_inner_class = 0;
12773       search_applicable_methods_list (lc, TYPE_METHODS (class), 
12774                                       name, arglist, &list, &all_list);
12775
12776       /* We must search all interfaces of this class */
12777       if (!lc)
12778       {
12779         tree basetype_vec = TYPE_BINFO_BASETYPES (sc);
12780         int n = TREE_VEC_LENGTH (basetype_vec), i;
12781         object_done = 1;
12782         for (i = 1; i < n; i++)
12783           {
12784             tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12785             if (t != object_type_node)
12786               {
12787                 tree rlist
12788                   = find_applicable_accessible_methods_list (lc, t,
12789                                                              name, arglist);
12790                 list = chainon (rlist, list);
12791               }
12792           }
12793         object_done = 0;
12794       }
12795
12796       /* Search enclosing context of inner classes before looking
12797          ancestors up. */
12798       while (!lc && INNER_CLASS_TYPE_P (class))
12799         {
12800           tree rlist;
12801           seen_inner_class = 1;
12802           class = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
12803           rlist = find_applicable_accessible_methods_list (lc, class, 
12804                                                            name, arglist);
12805           list = chainon (rlist, list);
12806         }
12807
12808       if (!lc && seen_inner_class 
12809           && TREE_TYPE (DECL_CONTEXT (TYPE_NAME (sc))) == CLASSTYPE_SUPER (sc))
12810         class = CLASSTYPE_SUPER (sc);
12811       else
12812         class = sc;
12813
12814       for (class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class)); 
12815         class; class = CLASSTYPE_SUPER (class))
12816        search_applicable_methods_list (lc, TYPE_METHODS (class), 
12817                                        name, arglist, &list, &all_list);
12818     }
12819
12820   /* Either return the list obtained or all selected (but
12821      inaccessible) methods for better error report. */
12822   return (!list ? all_list : list);
12823 }
12824
12825 /* Effectively search for the approriate method in method */
12826
12827 static void 
12828 search_applicable_methods_list (lc, method, name, arglist, list, all_list)
12829      int lc;
12830      tree method, name, arglist;
12831      tree *list, *all_list;
12832 {
12833   for (; method; method = TREE_CHAIN (method))
12834     {
12835       /* When dealing with constructor, stop here, otherwise search
12836          other classes */
12837       if (lc && !DECL_CONSTRUCTOR_P (method))
12838         continue;
12839       else if (!lc && (DECL_CONSTRUCTOR_P (method) 
12840                        || (GET_METHOD_NAME (method) != name)))
12841         continue;
12842           
12843       if (argument_types_convertible (method, arglist))
12844         {
12845           /* Retain accessible methods only */
12846           if (!not_accessible_p (DECL_CONTEXT (current_function_decl), 
12847                                  method, 0))
12848             *list = tree_cons (NULL_TREE, method, *list);
12849           else
12850             /* Also retain all selected method here */
12851             *all_list = tree_cons (NULL_TREE, method, *list);
12852         }
12853     }
12854 }    
12855
12856 /* 15.11.2.2 Choose the Most Specific Method */
12857
12858 static tree
12859 find_most_specific_methods_list (list)
12860      tree list;
12861 {
12862   int max = 0;
12863   tree current, new_list = NULL_TREE;
12864   for (current = list; current; current = TREE_CHAIN (current))
12865     {
12866       tree method;
12867       DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
12868
12869       for (method = list; method; method = TREE_CHAIN (method))
12870         {
12871           /* Don't test a method against itself */
12872           if (method == current)
12873             continue;
12874
12875           /* Compare arguments and location where method where declared */
12876           if (argument_types_convertible (TREE_VALUE (method), 
12877                                           TREE_VALUE (current))
12878               && valid_method_invocation_conversion_p 
12879                    (DECL_CONTEXT (TREE_VALUE (method)), 
12880                     DECL_CONTEXT (TREE_VALUE (current))))
12881             {
12882               int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
12883               max = (v > max ? v : max);
12884             }
12885         }
12886     }
12887
12888   /* Review the list and select the maximally specific methods */
12889   for (current = list; current; current = TREE_CHAIN (current))
12890     if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12891       new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12892
12893   /* If we have several and they're all abstract, just pick the
12894      closest one. */
12895
12896   if (new_list && TREE_CHAIN (new_list))
12897     {
12898       tree c;
12899       for (c = new_list; c && METHOD_ABSTRACT (TREE_VALUE (c)); 
12900            c = TREE_CHAIN (c))
12901         ;
12902       if (!c)
12903         {
12904           new_list = nreverse (new_list);
12905           TREE_CHAIN (new_list) = NULL_TREE;
12906         }
12907     }
12908
12909   /* If we can't find one, lower expectations and try to gather multiple
12910      maximally specific methods */
12911   while (!new_list && max)
12912     {
12913       while (--max > 0)
12914         {
12915           if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12916             new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12917         }
12918     }
12919
12920   return new_list;
12921 }
12922
12923 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
12924    converted by method invocation conversion (5.3) to the type of the
12925    corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
12926    to change less often than M1. */
12927
12928 static int
12929 argument_types_convertible (m1, m2_or_arglist)
12930     tree m1, m2_or_arglist;
12931 {
12932   static tree m2_arg_value = NULL_TREE;
12933   static tree m2_arg_cache = NULL_TREE;
12934
12935   register tree m1_arg, m2_arg;
12936
12937   SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
12938
12939   if (m2_arg_value == m2_or_arglist)
12940     m2_arg = m2_arg_cache;
12941   else
12942     {
12943       /* M2_OR_ARGLIST can be a function DECL or a raw list of
12944          argument types */
12945       if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
12946         {
12947           m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
12948           if (!METHOD_STATIC (m2_or_arglist))
12949             m2_arg = TREE_CHAIN (m2_arg);
12950         }
12951       else
12952         m2_arg = m2_or_arglist;
12953
12954       m2_arg_value = m2_or_arglist;
12955       m2_arg_cache = m2_arg;
12956     }
12957
12958   while (m1_arg != end_params_node && m2_arg != end_params_node)
12959     {
12960       resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
12961       if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
12962                                                  TREE_VALUE (m2_arg)))
12963         break;
12964       m1_arg = TREE_CHAIN (m1_arg);
12965       m2_arg = TREE_CHAIN (m2_arg);
12966     }
12967   return m1_arg == end_params_node && m2_arg == end_params_node;
12968 }
12969
12970 /* Qualification routines */
12971
12972 static void
12973 qualify_ambiguous_name (id)
12974      tree id;
12975 {
12976   tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
12977     saved_current_class;
12978   int again, super_found = 0, this_found = 0, new_array_found = 0;
12979   int code;
12980
12981   /* We first qualify the first element, then derive qualification of
12982      others based on the first one. If the first element is qualified
12983      by a resolution (field or type), this resolution is stored in the
12984      QUAL_RESOLUTION of the qual element being examined. We need to
12985      save the current_class since the use of SUPER might change the
12986      its value. */
12987   saved_current_class = current_class;
12988   qual = EXPR_WFL_QUALIFICATION (id);
12989   do {
12990
12991     /* Simple qualified expression feature a qual_wfl that is a
12992        WFL. Expression derived from a primary feature more complicated
12993        things like a CALL_EXPR. Expression from primary need to be
12994        worked out to extract the part on which the qualification will
12995        take place. */
12996     qual_wfl = QUAL_WFL (qual);
12997     switch (TREE_CODE (qual_wfl))
12998       {
12999       case CALL_EXPR:
13000         qual_wfl = TREE_OPERAND (qual_wfl, 0);
13001         if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
13002           {
13003             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
13004             qual_wfl = QUAL_WFL (qual);
13005           }
13006         break;
13007       case NEW_ARRAY_EXPR:
13008       case NEW_ANONYMOUS_ARRAY_EXPR:
13009         qual = TREE_CHAIN (qual);
13010         again = new_array_found = 1;
13011         continue;
13012       case CONVERT_EXPR:
13013         break;
13014       case NEW_CLASS_EXPR:
13015         qual_wfl = TREE_OPERAND (qual_wfl, 0);
13016         break;
13017       case ARRAY_REF:
13018         while (TREE_CODE (qual_wfl) == ARRAY_REF)
13019           qual_wfl = TREE_OPERAND (qual_wfl, 0);
13020         break;
13021       case STRING_CST:
13022         qual = TREE_CHAIN (qual);
13023         qual_wfl = QUAL_WFL (qual);
13024         break;
13025       case CLASS_LITERAL:
13026         qual = TREE_CHAIN (qual);
13027         qual_wfl = QUAL_WFL (qual);
13028       break;
13029       default:
13030         /* Fix for -Wall. Just break doing nothing */
13031         break;
13032       }
13033
13034     ptr_type = current_class;
13035     again = 0;
13036     code = TREE_CODE (qual_wfl);
13037
13038     /* Pos evaluation: non WFL leading expression nodes */
13039     if (code == CONVERT_EXPR
13040         && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
13041       name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
13042
13043     else if (code == INTEGER_CST)
13044       name = qual_wfl;
13045     
13046     else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
13047              TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
13048       name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
13049
13050     else if (code == TREE_LIST)
13051       name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
13052
13053     else if (code == STRING_CST || code == CONDITIONAL_EXPR 
13054              || code == PLUS_EXPR)
13055       {
13056         qual = TREE_CHAIN (qual);
13057         qual_wfl = QUAL_WFL (qual);
13058         again = 1;
13059       }
13060     else 
13061       {
13062         name = EXPR_WFL_NODE (qual_wfl);
13063         if (!name)
13064           {
13065             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
13066             again = 1;
13067           }
13068       }
13069
13070     /* If we have a THIS (from a primary), we set the context accordingly */
13071     if (name == this_identifier_node)
13072       {
13073         qual = TREE_CHAIN (qual);
13074         qual_wfl = QUAL_WFL (qual);
13075         if (TREE_CODE (qual_wfl) == CALL_EXPR)
13076           again = 1;
13077         else
13078           name = EXPR_WFL_NODE (qual_wfl);
13079         this_found = 1;
13080       }
13081     /* If we have a SUPER, we set the context accordingly */
13082     if (name == super_identifier_node)
13083       {
13084         current_class = CLASSTYPE_SUPER (ptr_type);
13085         /* Check that there is such a thing as a super class. If not,
13086            return.  The error will be caught later on, during the
13087            resolution */
13088         if (!current_class)
13089           {
13090             current_class = saved_current_class;
13091             return;
13092           }
13093         qual = TREE_CHAIN (qual);
13094         /* Do one more interation to set things up */
13095         super_found = again = 1;
13096       }
13097   } while (again);
13098   
13099   /* If name appears within the scope of a local variable declaration
13100      or parameter declaration, then it is an expression name. We don't
13101      carry this test out if we're in the context of the use of SUPER
13102      or THIS */
13103   if (!this_found && !super_found 
13104       && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
13105       && (decl = IDENTIFIER_LOCAL_VALUE (name)))
13106     {
13107       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13108       QUAL_RESOLUTION (qual) = decl;
13109     }
13110
13111   /* If within the class/interface NAME was found to be used there
13112      exists a (possibly inherited) field named NAME, then this is an
13113      expression name. If we saw a NEW_ARRAY_EXPR before and want to
13114      address length, it is OK. */
13115   else if ((decl = lookup_field_wrapper (ptr_type, name))
13116            || (new_array_found && name == length_identifier_node))
13117     {
13118       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13119       QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
13120     }
13121
13122   /* We reclassify NAME as yielding to a type name resolution if:
13123      - NAME is a class/interface declared within the compilation
13124        unit containing NAME,
13125      - NAME is imported via a single-type-import declaration,
13126      - NAME is declared in an another compilation unit of the package
13127        of the compilation unit containing NAME,
13128      - NAME is declared by exactly on type-import-on-demand declaration
13129      of the compilation unit containing NAME. 
13130      - NAME is actually a STRING_CST. */
13131   else if (TREE_CODE (name) == STRING_CST || TREE_CODE (name) == INTEGER_CST
13132            || (decl = resolve_and_layout (name, NULL_TREE)))
13133     {
13134       RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
13135       QUAL_RESOLUTION (qual) = decl;
13136     }
13137
13138   /* Method call, array references and cast are expression name */
13139   else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
13140            || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
13141            || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
13142     RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13143
13144   /* Check here that NAME isn't declared by more than one
13145      type-import-on-demand declaration of the compilation unit
13146      containing NAME. FIXME */
13147
13148   /* Otherwise, NAME is reclassified as a package name */
13149   else 
13150     RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
13151
13152   /* Propagate the qualification accross other components of the
13153      qualified name */
13154   for (qual = TREE_CHAIN (qual); qual;
13155        qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
13156     {
13157       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13158         RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
13159       else 
13160         RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
13161     }
13162
13163   /* Store the global qualification for the ambiguous part of ID back
13164      into ID fields */
13165   if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
13166     RESOLVE_EXPRESSION_NAME_P (id) = 1;
13167   else if (RESOLVE_TYPE_NAME_P (qual_wfl))
13168     RESOLVE_TYPE_NAME_P (id) = 1;
13169   else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13170     RESOLVE_PACKAGE_NAME_P (id) = 1;
13171
13172   /* Restore the current class */
13173   current_class = saved_current_class;
13174 }
13175
13176 static int
13177 breakdown_qualified (left, right, source)
13178     tree *left, *right, source;
13179 {
13180   char *p = IDENTIFIER_POINTER (source), *base;
13181   int   l = IDENTIFIER_LENGTH (source);
13182
13183   /* Breakdown NAME into REMAINDER . IDENTIFIER */
13184   base = p;
13185   p += (l-1);
13186   while (*p != '.' && p != base)
13187     p--;
13188
13189   /* We didn't find a '.'. Return an error */
13190   if (p == base)
13191     return 1;
13192
13193   *p = '\0';
13194   if (right)
13195     *right = get_identifier (p+1);
13196   *left = get_identifier (IDENTIFIER_POINTER (source));
13197   *p = '.';
13198   
13199   return 0;
13200 }
13201
13202 /* Patch tree nodes in a function body. When a BLOCK is found, push
13203    local variable decls if present.
13204    Same as java_complete_lhs, but does resolve static finals to values. */
13205
13206 static tree
13207 java_complete_tree (node)
13208      tree node;
13209 {
13210   node = java_complete_lhs (node);
13211   if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
13212       && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
13213       && !flag_emit_xref)
13214     {
13215       tree value = DECL_INITIAL (node);
13216       DECL_INITIAL (node) = NULL_TREE;
13217       push_obstacks (&permanent_obstack, &permanent_obstack);
13218       value = fold_constant_for_init (value, node);
13219       pop_obstacks ();
13220       DECL_INITIAL (node) = value;
13221       if (value != NULL_TREE)
13222         {
13223           /* fold_constant_for_init sometimes widen the original type
13224              of the constant (i.e. byte to int.) It's not desirable,
13225              especially if NODE is a function argument. */
13226           if (TREE_CODE (value) == INTEGER_CST
13227               && TREE_TYPE (node) != TREE_TYPE (value))
13228             return convert (TREE_TYPE (node), value);
13229           else
13230             return value;
13231         }
13232     }
13233   return node;
13234 }
13235
13236 static tree
13237 java_stabilize_reference (node)
13238      tree node;
13239 {
13240   if (TREE_CODE (node) == COMPOUND_EXPR)
13241     {
13242       tree op0 = TREE_OPERAND (node, 0);
13243       tree op1 = TREE_OPERAND (node, 1);
13244       TREE_OPERAND (node, 0) = save_expr (op0);
13245       TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
13246       return node;
13247     }
13248   return stabilize_reference (node);
13249 }
13250
13251 /* Patch tree nodes in a function body. When a BLOCK is found, push
13252    local variable decls if present.
13253    Same as java_complete_tree, but does not resolve static finals to values. */
13254
13255 static tree
13256 java_complete_lhs (node)
13257      tree node;
13258 {
13259   tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
13260   int flag;
13261
13262   /* CONVERT_EXPR always has its type set, even though it needs to be
13263      worked out. */
13264   if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
13265     return node;
13266
13267   /* The switch block implements cases processing container nodes
13268      first.  Contained nodes are always written back. Leaves come
13269      next and return a value. */
13270   switch (TREE_CODE (node))
13271     {
13272     case BLOCK:
13273
13274       /* 1- Block section.
13275          Set the local values on decl names so we can identify them
13276          faster when they're referenced. At that stage, identifiers
13277          are legal so we don't check for declaration errors. */
13278       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13279         {
13280           DECL_CONTEXT (cn) = current_function_decl;
13281           IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
13282         }
13283       if (BLOCK_EXPR_BODY (node) == NULL_TREE)
13284           CAN_COMPLETE_NORMALLY (node) = 1;
13285       else
13286         {
13287           tree stmt = BLOCK_EXPR_BODY (node);
13288           tree *ptr;
13289           int error_seen = 0;
13290           if (TREE_CODE (stmt) == COMPOUND_EXPR)
13291             {
13292               /* Re-order from (((A; B); C); ...; Z) to 
13293                  (A; (B; (C ; (...; Z)))).
13294                  This makes it easier to scan the statements left-to-right
13295                  without using recursion (which might overflow the stack
13296                  if the block has many statements. */
13297               for (;;)
13298                 {
13299                   tree left = TREE_OPERAND (stmt, 0);
13300                   if (TREE_CODE (left) != COMPOUND_EXPR)
13301                     break;
13302                   TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
13303                   TREE_OPERAND (left, 1) = stmt;
13304                   stmt = left;
13305                 }
13306               BLOCK_EXPR_BODY (node) = stmt;
13307             }
13308
13309           /* Now do the actual complete, without deep recursion for
13310              long blocks. */
13311           ptr = &BLOCK_EXPR_BODY (node);
13312           while (TREE_CODE (*ptr) == COMPOUND_EXPR
13313                  && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
13314             {
13315               tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
13316               tree *next = &TREE_OPERAND (*ptr, 1);
13317               TREE_OPERAND (*ptr, 0) = cur;
13318               if (cur == empty_stmt_node)
13319                 {
13320                   /* Optimization;  makes it easier to detect empty bodies.
13321                      Most useful for <clinit> with all-constant initializer. */
13322                   *ptr = *next;
13323                   continue;
13324                 }
13325               if (TREE_CODE (cur) == ERROR_MARK)
13326                 error_seen++;
13327               else if (! CAN_COMPLETE_NORMALLY (cur))
13328                 {
13329                   wfl_op2 = *next;
13330                   for (;;)
13331                     {
13332                       if (TREE_CODE (wfl_op2) == BLOCK)
13333                         wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
13334                       else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
13335                         wfl_op2 = TREE_OPERAND (wfl_op2, 0);
13336                       else
13337                         break;
13338                     }
13339                   if (TREE_CODE (wfl_op2) != CASE_EXPR
13340                       && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
13341                     unreachable_stmt_error (*ptr);
13342                 }
13343               ptr = next;
13344             }
13345           *ptr = java_complete_tree (*ptr);
13346
13347           if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
13348             return error_mark_node;
13349           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
13350         }
13351       /* Turn local bindings to null */
13352       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13353         IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
13354
13355       TREE_TYPE (node) = void_type_node;
13356       break;
13357
13358       /* 2- They are expressions but ultimately deal with statements */
13359
13360     case THROW_EXPR:
13361       wfl_op1 = TREE_OPERAND (node, 0);
13362       COMPLETE_CHECK_OP_0 (node);
13363       /* 14.19 A throw statement cannot complete normally. */
13364       CAN_COMPLETE_NORMALLY (node) = 0;
13365       return patch_throw_statement (node, wfl_op1);
13366
13367     case SYNCHRONIZED_EXPR:
13368       wfl_op1 = TREE_OPERAND (node, 0);
13369       return patch_synchronized_statement (node, wfl_op1);
13370
13371     case TRY_EXPR:
13372       return patch_try_statement (node);
13373
13374     case TRY_FINALLY_EXPR:
13375       COMPLETE_CHECK_OP_0 (node);
13376       COMPLETE_CHECK_OP_1 (node);
13377       CAN_COMPLETE_NORMALLY (node)
13378         = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
13379            && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
13380       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
13381       return node;
13382
13383     case CLEANUP_POINT_EXPR:
13384       COMPLETE_CHECK_OP_0 (node);
13385       TREE_TYPE (node) = void_type_node;
13386       CAN_COMPLETE_NORMALLY (node) = 
13387         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13388       return node;
13389
13390     case WITH_CLEANUP_EXPR:
13391       COMPLETE_CHECK_OP_0 (node);
13392       COMPLETE_CHECK_OP_2 (node);
13393       CAN_COMPLETE_NORMALLY (node) = 
13394         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13395       TREE_TYPE (node) = void_type_node;
13396       return node;
13397
13398     case LABELED_BLOCK_EXPR:
13399       PUSH_LABELED_BLOCK (node);
13400       if (LABELED_BLOCK_BODY (node))
13401         COMPLETE_CHECK_OP_1 (node);
13402       TREE_TYPE (node) = void_type_node;
13403       POP_LABELED_BLOCK ();
13404
13405       if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
13406         {
13407           LABELED_BLOCK_BODY (node) = NULL_TREE;
13408           CAN_COMPLETE_NORMALLY (node) = 1;
13409         }
13410       else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
13411         CAN_COMPLETE_NORMALLY (node) = 1;
13412       return node;
13413
13414     case EXIT_BLOCK_EXPR:
13415       /* We don't complete operand 1, because it's the return value of
13416          the EXIT_BLOCK_EXPR which doesn't exist it Java */
13417       return patch_bc_statement (node);
13418
13419     case CASE_EXPR:
13420       cn = java_complete_tree (TREE_OPERAND (node, 0));
13421       if (cn == error_mark_node)
13422         return cn;
13423
13424       /* First, the case expression must be constant. Values of final
13425          fields are accepted. */
13426       cn = fold (cn);
13427       if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
13428           && JDECL_P (TREE_OPERAND (cn, 1))
13429           && FIELD_FINAL (TREE_OPERAND (cn, 1))
13430           && DECL_INITIAL (TREE_OPERAND (cn, 1)))
13431         {
13432           push_obstacks (&permanent_obstack, &permanent_obstack);
13433           cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
13434                                        TREE_OPERAND (cn, 1));
13435           pop_obstacks ();
13436         }
13437
13438       if (!TREE_CONSTANT (cn) && !flag_emit_xref)
13439         {
13440           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13441           parse_error_context (node, "Constant expression required");
13442           return error_mark_node;
13443         }
13444
13445       nn = ctxp->current_loop;
13446
13447       /* It must be assignable to the type of the switch expression. */
13448       if (!try_builtin_assignconv (NULL_TREE, 
13449                                    TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
13450         {
13451           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13452           parse_error_context 
13453             (wfl_operator,
13454              "Incompatible type for case. Can't convert `%s' to `int'",
13455              lang_printable_name (TREE_TYPE (cn), 0));
13456           return error_mark_node;
13457         }
13458
13459       cn = fold (convert (int_type_node, cn));
13460
13461       /* Multiple instance of a case label bearing the same
13462          value is checked during code generation. The case
13463          expression is allright so far. */
13464       TREE_OPERAND (node, 0) = cn;
13465       TREE_TYPE (node) = void_type_node;
13466       CAN_COMPLETE_NORMALLY (node) = 1;
13467       TREE_SIDE_EFFECTS (node) = 1;
13468       break;
13469
13470     case DEFAULT_EXPR:
13471       nn = ctxp->current_loop;
13472       /* Only one default label is allowed per switch statement */
13473       if (SWITCH_HAS_DEFAULT (nn))
13474         {
13475           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13476           parse_error_context (wfl_operator, 
13477                                "Duplicate case label: `default'");
13478           return error_mark_node;
13479         }
13480       else
13481         SWITCH_HAS_DEFAULT (nn) = 1;
13482       TREE_TYPE (node) = void_type_node;
13483       TREE_SIDE_EFFECTS (node) = 1;
13484       CAN_COMPLETE_NORMALLY (node) = 1;
13485       break;
13486
13487     case SWITCH_EXPR:
13488     case LOOP_EXPR:
13489       PUSH_LOOP (node);
13490       /* Check whether the loop was enclosed in a labeled
13491          statement. If not, create one, insert the loop in it and
13492          return the node */
13493       nn = patch_loop_statement (node);
13494
13495       /* Anyways, walk the body of the loop */
13496       if (TREE_CODE (node) == LOOP_EXPR)
13497         TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13498       /* Switch statement: walk the switch expression and the cases */
13499       else
13500         node = patch_switch_statement (node);
13501
13502       if (TREE_OPERAND (node, 0) == error_mark_node)
13503         nn = error_mark_node;
13504       else
13505         {
13506           TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
13507           /* If we returned something different, that's because we
13508              inserted a label. Pop the label too. */
13509           if (nn != node)
13510             {
13511               if (CAN_COMPLETE_NORMALLY (node))
13512                 CAN_COMPLETE_NORMALLY (nn) = 1;
13513               POP_LABELED_BLOCK ();
13514             }
13515         }
13516       POP_LOOP ();
13517       return nn;
13518
13519     case EXIT_EXPR:
13520       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13521       return patch_exit_expr (node);
13522
13523     case COND_EXPR:
13524       /* Condition */
13525       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13526       if (TREE_OPERAND (node, 0) == error_mark_node)
13527         return error_mark_node;
13528       /* then-else branches */
13529       TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13530       if (TREE_OPERAND (node, 1) == error_mark_node)
13531         return error_mark_node;
13532       TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
13533       if (TREE_OPERAND (node, 2) == error_mark_node)
13534         return error_mark_node;
13535       return patch_if_else_statement (node);
13536       break;
13537
13538     case CONDITIONAL_EXPR:
13539       /* Condition */
13540       wfl_op1 = TREE_OPERAND (node, 0);
13541       COMPLETE_CHECK_OP_0 (node);
13542       wfl_op2 = TREE_OPERAND (node, 1);
13543       COMPLETE_CHECK_OP_1 (node);
13544       wfl_op3 = TREE_OPERAND (node, 2);
13545       COMPLETE_CHECK_OP_2 (node);
13546       return patch_conditional_expr (node, wfl_op1, wfl_op2);
13547
13548       /* 3- Expression section */
13549     case COMPOUND_EXPR:
13550       wfl_op2 = TREE_OPERAND (node, 1);
13551       TREE_OPERAND (node, 0) = nn = 
13552         java_complete_tree (TREE_OPERAND (node, 0));
13553       if (wfl_op2 == empty_stmt_node)
13554         CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
13555       else
13556         {
13557           if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
13558             {
13559               /* An unreachable condition in a do-while statement
13560                  is *not* (technically) an unreachable statement. */
13561               nn = wfl_op2;
13562               if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
13563                 nn = EXPR_WFL_NODE (nn);
13564               if (TREE_CODE (nn) != EXIT_EXPR)
13565                 {
13566                   SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
13567                   parse_error_context (wfl_operator, "Unreachable statement");
13568                 }
13569             }
13570           TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13571           if (TREE_OPERAND (node, 1) == error_mark_node)
13572             return error_mark_node;
13573           CAN_COMPLETE_NORMALLY (node)
13574             = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
13575         }
13576       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
13577       break;
13578
13579     case RETURN_EXPR:
13580       /* CAN_COMPLETE_NORMALLY (node) = 0; */
13581       return patch_return (node);
13582
13583     case EXPR_WITH_FILE_LOCATION:
13584       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
13585           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
13586         {
13587           tree wfl = node;
13588           node = resolve_expression_name (node, NULL);
13589           if (node == error_mark_node)
13590             return node;
13591           /* Keep line number information somewhere were it doesn't
13592              disrupt the completion process. */
13593           if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
13594             {
13595               EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
13596               TREE_OPERAND (node, 1) = wfl;
13597             }
13598           CAN_COMPLETE_NORMALLY (node) = 1;
13599         }
13600       else
13601         {
13602           tree body;
13603           int save_lineno = lineno;
13604           lineno = EXPR_WFL_LINENO (node);
13605           body = java_complete_tree (EXPR_WFL_NODE (node));
13606           lineno = save_lineno;
13607           EXPR_WFL_NODE (node) = body;
13608           TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
13609           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
13610           if (body == empty_stmt_node)
13611             {
13612               /* Optimization;  makes it easier to detect empty bodies. */
13613               return body;
13614             }
13615           if (body == error_mark_node)
13616             {
13617               /* Its important for the evaluation of assignment that
13618                  this mark on the TREE_TYPE is propagated. */
13619               TREE_TYPE (node) = error_mark_node;
13620               return error_mark_node;
13621             }
13622           else
13623             TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
13624           
13625         }
13626       break;
13627
13628     case NEW_ARRAY_EXPR:
13629       /* Patch all the dimensions */
13630       flag = 0;
13631       for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13632         {
13633           int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
13634           tree dim = convert (int_type_node, 
13635                               java_complete_tree (TREE_VALUE (cn)));
13636           if (dim == error_mark_node)
13637             {
13638               flag = 1;
13639               continue;
13640             }
13641           else
13642             {
13643               TREE_VALUE (cn) = dim;
13644               /* Setup the location of the current dimension, for
13645                  later error report. */
13646               TREE_PURPOSE (cn) = 
13647                 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
13648               EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
13649             }
13650         }
13651       /* They complete the array creation expression, if no errors
13652          were found. */
13653       CAN_COMPLETE_NORMALLY (node) = 1;
13654       return (flag ? error_mark_node
13655               : force_evaluation_order (patch_newarray (node)));
13656
13657     case NEW_ANONYMOUS_ARRAY_EXPR:
13658       /* Create the array type if necessary. */
13659       if (ANONYMOUS_ARRAY_DIMS_SIG (node))
13660         {
13661           tree type = ANONYMOUS_ARRAY_BASE_TYPE (node);
13662           if (!(type = resolve_type_during_patch (type)))
13663             return error_mark_node;
13664           type = build_array_from_name (type, NULL_TREE,
13665                                         ANONYMOUS_ARRAY_DIMS_SIG (node), NULL);
13666           ANONYMOUS_ARRAY_BASE_TYPE (node) = build_pointer_type (type);
13667         }
13668       node = patch_new_array_init (ANONYMOUS_ARRAY_BASE_TYPE (node),
13669                                    ANONYMOUS_ARRAY_INITIALIZER (node));
13670       if (node == error_mark_node)
13671         return error_mark_node;
13672       CAN_COMPLETE_NORMALLY (node) = 1;
13673       return node;
13674
13675     case NEW_CLASS_EXPR:
13676     case CALL_EXPR:
13677       /* Complete function's argument(s) first */
13678       if (complete_function_arguments (node))
13679         return error_mark_node;
13680       else
13681         {
13682           tree decl, wfl = TREE_OPERAND (node, 0);
13683           int in_this = CALL_THIS_CONSTRUCTOR_P (node);
13684
13685           node = patch_method_invocation (node, NULL_TREE, 
13686                                           NULL_TREE, 0, &decl);
13687           if (node == error_mark_node)
13688             return error_mark_node;
13689
13690           check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
13691           /* If we call this(...), register signature and positions */
13692           if (in_this)
13693             DECL_CONSTRUCTOR_CALLS (current_function_decl) = 
13694               tree_cons (wfl, decl, 
13695                          DECL_CONSTRUCTOR_CALLS (current_function_decl));
13696           CAN_COMPLETE_NORMALLY (node) = 1;
13697           return force_evaluation_order (node);
13698         }
13699
13700     case MODIFY_EXPR:
13701       /* Save potential wfls */
13702       wfl_op1 = TREE_OPERAND (node, 0);
13703       TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
13704       
13705       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
13706           && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
13707           && DECL_INITIAL (nn) != NULL_TREE)
13708         {
13709           tree value;
13710           
13711           push_obstacks (&permanent_obstack, &permanent_obstack);
13712           value = fold_constant_for_init (nn, nn);
13713           pop_obstacks ();
13714
13715           if (value != NULL_TREE)
13716             {
13717               tree type = TREE_TYPE (value);
13718               if (JPRIMITIVE_TYPE_P (type) || 
13719                   (type == string_ptr_type_node && ! flag_emit_class_files))
13720                 return empty_stmt_node;
13721             }
13722           DECL_INITIAL (nn) = NULL_TREE;
13723         }
13724       wfl_op2 = TREE_OPERAND (node, 1);
13725
13726       if (TREE_OPERAND (node, 0) == error_mark_node)
13727         return error_mark_node;
13728
13729       flag = COMPOUND_ASSIGN_P (wfl_op2);
13730       if (flag)
13731         {
13732           /* This might break when accessing outer field from inner
13733              class. TESTME, FIXME */
13734           tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0)); 
13735
13736           /* Hand stablize the lhs on both places */
13737           TREE_OPERAND (node, 0) = lvalue;
13738           TREE_OPERAND (TREE_OPERAND (node, 1), 0) = 
13739             (flag_emit_class_files ? lvalue : save_expr (lvalue));
13740
13741           /* 15.25.2.a: Left hand is not an array access. FIXME */
13742           /* Now complete the RHS. We write it back later on. */
13743           nn = java_complete_tree (TREE_OPERAND (node, 1));
13744
13745           if ((cn = patch_string (nn)))
13746             nn = cn;
13747
13748           /* The last part of the rewrite for E1 op= E2 is to have 
13749              E1 = (T)(E1 op E2), with T being the type of E1. */
13750           nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2), 
13751                                                TREE_TYPE (lvalue), nn));
13752
13753           /* 15.25.2.b: Left hand is an array access. FIXME */
13754         }
13755
13756       /* If we're about to patch a NEW_ARRAY_INIT, we call a special
13757          function to complete this RHS. Note that a NEW_ARRAY_INIT
13758          might have been already fully expanded if created as a result
13759          of processing an anonymous array initializer. We avoid doing
13760          the operation twice by testing whether the node already bears
13761          a type. */
13762       else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT && !TREE_TYPE (wfl_op2))
13763         nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
13764                                    TREE_OPERAND (node, 1));
13765       /* Otherwise we simply complete the RHS */
13766       else
13767         nn = java_complete_tree (TREE_OPERAND (node, 1));
13768
13769       if (nn == error_mark_node)
13770         return error_mark_node;
13771
13772       /* Write back the RHS as we evaluated it. */
13773       TREE_OPERAND (node, 1) = nn;
13774
13775       /* In case we're handling = with a String as a RHS, we need to
13776          produce a String out of the RHS (it might still be a
13777          STRING_CST or a StringBuffer at this stage */
13778       if ((nn = patch_string (TREE_OPERAND (node, 1))))
13779         TREE_OPERAND (node, 1) = nn;
13780
13781       if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
13782                                         TREE_OPERAND (node, 1))))
13783         {
13784           /* We return error_mark_node if outer_field_access_fix
13785              detects we write into a final. */
13786           if (nn == error_mark_node)
13787             return error_mark_node;
13788           node = nn;
13789         }
13790       else
13791         {
13792           node = patch_assignment (node, wfl_op1, wfl_op2);
13793           /* Reorganize the tree if necessary. */
13794           if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node)) 
13795                        || JSTRING_P (TREE_TYPE (node))))
13796             node = java_refold (node);
13797         }
13798       
13799       CAN_COMPLETE_NORMALLY (node) = 1;
13800       return node;
13801
13802     case MULT_EXPR:
13803     case PLUS_EXPR:
13804     case MINUS_EXPR:
13805     case LSHIFT_EXPR:
13806     case RSHIFT_EXPR:
13807     case URSHIFT_EXPR:
13808     case BIT_AND_EXPR:
13809     case BIT_XOR_EXPR:
13810     case BIT_IOR_EXPR:
13811     case TRUNC_MOD_EXPR:
13812     case TRUNC_DIV_EXPR:
13813     case RDIV_EXPR:
13814     case TRUTH_ANDIF_EXPR:
13815     case TRUTH_ORIF_EXPR:
13816     case EQ_EXPR: 
13817     case NE_EXPR:
13818     case GT_EXPR:
13819     case GE_EXPR:
13820     case LT_EXPR:
13821     case LE_EXPR:
13822       /* Operands 0 and 1 are WFL in certain cases only. patch_binop
13823          knows how to handle those cases. */
13824       wfl_op1 = TREE_OPERAND (node, 0);
13825       wfl_op2 = TREE_OPERAND (node, 1);
13826
13827       CAN_COMPLETE_NORMALLY (node) = 1;
13828       /* Don't complete string nodes if dealing with the PLUS operand. */
13829       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
13830         {
13831           nn = java_complete_tree (wfl_op1);
13832           if (nn == error_mark_node)
13833             return error_mark_node;
13834
13835           TREE_OPERAND (node, 0) = nn;
13836         }
13837       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
13838         {
13839           nn = java_complete_tree (wfl_op2);
13840           if (nn == error_mark_node)
13841             return error_mark_node;
13842
13843           TREE_OPERAND (node, 1) = nn;
13844         }
13845       return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
13846
13847     case INSTANCEOF_EXPR:
13848       wfl_op1 = TREE_OPERAND (node, 0);
13849       COMPLETE_CHECK_OP_0 (node);
13850       if (flag_emit_xref)
13851         {
13852           TREE_TYPE (node) = boolean_type_node;
13853           return node;
13854         }
13855       return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
13856
13857     case UNARY_PLUS_EXPR:
13858     case NEGATE_EXPR:
13859     case TRUTH_NOT_EXPR:
13860     case BIT_NOT_EXPR:
13861     case PREDECREMENT_EXPR:
13862     case PREINCREMENT_EXPR:
13863     case POSTDECREMENT_EXPR:
13864     case POSTINCREMENT_EXPR:
13865     case CONVERT_EXPR:
13866       /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
13867          how to handle those cases. */
13868       wfl_op1 = TREE_OPERAND (node, 0);
13869       CAN_COMPLETE_NORMALLY (node) = 1;
13870       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13871       if (TREE_OPERAND (node, 0) == error_mark_node)
13872         return error_mark_node;
13873       node = patch_unaryop (node, wfl_op1);
13874       CAN_COMPLETE_NORMALLY (node) = 1;
13875       break;
13876
13877     case ARRAY_REF:
13878       /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
13879          how to handle those cases. */
13880       wfl_op1 = TREE_OPERAND (node, 0);
13881       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13882       if (TREE_OPERAND (node, 0) == error_mark_node)
13883         return error_mark_node;
13884       if (!flag_emit_class_files && !flag_emit_xref)
13885         TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
13886       /* The same applies to wfl_op2 */
13887       wfl_op2 = TREE_OPERAND (node, 1);
13888       TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
13889       if (TREE_OPERAND (node, 1) == error_mark_node)
13890         return error_mark_node;
13891       if (!flag_emit_class_files && !flag_emit_xref)
13892         TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
13893       return patch_array_ref (node);
13894
13895     case RECORD_TYPE:
13896       return node;;
13897
13898     case COMPONENT_REF:
13899       /* The first step in the re-write of qualified name handling.  FIXME.
13900          So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
13901       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13902       if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
13903         {
13904           tree name = TREE_OPERAND (node, 1);
13905           tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
13906           if (field == NULL_TREE)
13907             {
13908               error ("missing static field `%s'", IDENTIFIER_POINTER (name));
13909               return error_mark_node;
13910             }
13911           if (! FIELD_STATIC (field))
13912             {
13913               error ("not a static field `%s'", IDENTIFIER_POINTER (name));
13914               return error_mark_node;
13915             }
13916           return field;
13917         }
13918       else
13919         fatal ("unimplemented java_complete_tree for COMPONENT_REF");
13920       break;
13921
13922     case THIS_EXPR:
13923       /* Can't use THIS in a static environment */
13924       if (!current_this)
13925         {
13926           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13927           parse_error_context (wfl_operator,
13928                                "Keyword `this' used outside allowed context");
13929           TREE_TYPE (node) = error_mark_node;
13930           return error_mark_node;
13931         }
13932       if (ctxp->explicit_constructor_p)
13933         {
13934           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13935           parse_error_context 
13936             (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
13937           TREE_TYPE (node) = error_mark_node;
13938           return error_mark_node;
13939         }
13940       return current_this;
13941       
13942     case CLASS_LITERAL:
13943       CAN_COMPLETE_NORMALLY (node) = 1;
13944       node = patch_incomplete_class_ref (node);
13945       if (node == error_mark_node)
13946         return error_mark_node;
13947       break;
13948
13949     case INSTANCE_INITIALIZERS_EXPR:
13950       in_instance_initializer++;
13951       node = java_complete_tree (TREE_OPERAND (node, 0));
13952       in_instance_initializer--;
13953       if (node != error_mark_node)
13954         TREE_TYPE (node) = void_type_node;
13955       else
13956         return error_mark_node;
13957       break;
13958
13959     default:
13960       CAN_COMPLETE_NORMALLY (node) = 1;
13961       /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
13962          and it's time to turn it into the appropriate String object */
13963       if ((nn = patch_string (node)))
13964         node = nn;
13965       else
13966         fatal ("No case for tree code `%s' - java_complete_tree\n",
13967                tree_code_name [TREE_CODE (node)]);
13968     }
13969   return node;
13970 }
13971
13972 /* Complete function call's argument. Return a non zero value is an
13973    error was found.  */
13974
13975 static int
13976 complete_function_arguments (node)
13977      tree node;
13978 {
13979   int flag = 0;
13980   tree cn;
13981
13982   ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13983   for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13984     {
13985       tree wfl = TREE_VALUE (cn), parm, temp;
13986       parm = java_complete_tree (wfl);
13987
13988       if (parm == error_mark_node)
13989         {
13990           flag = 1;
13991           continue;
13992         }
13993       /* If have a string literal that we haven't transformed yet or a
13994          crafted string buffer, as a result of use of the the String
13995          `+' operator. Build `parm.toString()' and expand it. */
13996       if ((temp = patch_string (parm)))
13997         parm = temp;
13998       /* Inline PRIMTYPE.TYPE read access */
13999       parm = maybe_build_primttype_type_ref (parm, wfl);
14000
14001       TREE_VALUE (cn) = parm;
14002     }
14003   ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
14004   return flag;
14005 }
14006
14007 /* Sometimes (for loops and variable initialized during their
14008    declaration), we want to wrap a statement around a WFL and turn it
14009    debugable.  */
14010
14011 static tree
14012 build_debugable_stmt (location, stmt)
14013     int location;
14014     tree stmt;
14015 {
14016   if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
14017     {
14018       stmt = build_expr_wfl (stmt, input_filename, 0, 0);
14019       EXPR_WFL_LINECOL (stmt) = location;
14020     }
14021   JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
14022   return stmt;
14023 }
14024
14025 static tree
14026 build_expr_block (body, decls)
14027      tree body, decls;
14028 {
14029   tree node = make_node (BLOCK);
14030   BLOCK_EXPR_DECLS (node) = decls;
14031   BLOCK_EXPR_BODY (node) = body;
14032   if (body)
14033     TREE_TYPE (node) = TREE_TYPE (body);
14034   TREE_SIDE_EFFECTS (node) = 1;
14035   return node;
14036 }
14037
14038 /* Create a new function block and link it approriately to current
14039    function block chain */
14040
14041 static tree
14042 enter_block ()
14043 {
14044   return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
14045 }
14046
14047 /* Link block B supercontext to the previous block. The current
14048    function DECL is used as supercontext when enter_a_block is called
14049    for the first time for a given function. The current function body
14050    (DECL_FUNCTION_BODY) is set to be block B.  */
14051
14052 static tree
14053 enter_a_block (b)
14054      tree b;
14055 {
14056   tree fndecl = current_function_decl; 
14057
14058   if (!fndecl) {
14059     BLOCK_SUPERCONTEXT (b) = current_static_block;
14060     current_static_block = b;
14061   }
14062
14063   else if (!DECL_FUNCTION_BODY (fndecl))
14064     {
14065       BLOCK_SUPERCONTEXT (b) = fndecl;
14066       DECL_FUNCTION_BODY (fndecl) = b;
14067     }
14068   else
14069     {
14070       BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
14071       DECL_FUNCTION_BODY (fndecl) = b;
14072     }
14073   return b;
14074 }
14075
14076 /* Exit a block by changing the current function body
14077    (DECL_FUNCTION_BODY) to the current block super context, only if
14078    the block being exited isn't the method's top level one.  */
14079
14080 static tree
14081 exit_block ()
14082 {
14083   tree b;
14084   if (current_function_decl)
14085     {
14086       b = DECL_FUNCTION_BODY (current_function_decl);
14087       if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
14088         DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
14089     }
14090   else
14091     {
14092       b = current_static_block;
14093
14094       if (BLOCK_SUPERCONTEXT (b))
14095         current_static_block = BLOCK_SUPERCONTEXT (b);
14096     }
14097   return b;
14098 }
14099
14100 /* Lookup for NAME in the nested function's blocks, all the way up to
14101    the current toplevel one. It complies with Java's local variable
14102    scoping rules.  */
14103
14104 static tree
14105 lookup_name_in_blocks (name)
14106      tree name;
14107 {
14108   tree b = GET_CURRENT_BLOCK (current_function_decl);
14109
14110   while (b != current_function_decl)
14111     {
14112       tree current;
14113
14114       /* Paranoid sanity check. To be removed */
14115       if (TREE_CODE (b) != BLOCK)
14116         fatal ("non block expr function body - lookup_name_in_blocks");
14117
14118       for (current = BLOCK_EXPR_DECLS (b); current; 
14119            current = TREE_CHAIN (current))
14120         if (DECL_NAME (current) == name)
14121           return current;
14122       b = BLOCK_SUPERCONTEXT (b);
14123     }
14124   return NULL_TREE;
14125 }
14126
14127 static void
14128 maybe_absorb_scoping_blocks ()
14129 {
14130   while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
14131     {
14132       tree b = exit_block ();
14133       java_method_add_stmt (current_function_decl, b);
14134       SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
14135     }
14136 }
14137
14138 \f
14139 /* This section of the source is reserved to build_* functions that
14140    are building incomplete tree nodes and the patch_* functions that
14141    are completing them.  */
14142
14143 /* Wrap a non WFL node around a WFL.  */
14144 static tree
14145 build_wfl_wrap (node)
14146     tree node;
14147 {
14148   tree wfl, node_to_insert = node;
14149   
14150   /* We want to process THIS . xxx symbolicaly, to keep it consistent
14151      with the way we're processing SUPER. A THIS from a primary as a
14152      different form than a SUPER. Turn THIS into something symbolic */
14153   if (TREE_CODE (node) == THIS_EXPR)
14154     node_to_insert = wfl = build_wfl_node (this_identifier_node);
14155   else
14156     wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
14157
14158   EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (node);
14159   EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
14160   return wfl;
14161 }
14162
14163
14164 /* Build a super() constructor invocation. Returns empty_stmt_node if
14165    we're currently dealing with the class java.lang.Object. */
14166
14167 static tree
14168 build_super_invocation (mdecl)
14169      tree mdecl;
14170 {
14171   if (DECL_CONTEXT (mdecl) == object_type_node)
14172     return empty_stmt_node;
14173   else
14174     {
14175       tree super_wfl = build_wfl_node (super_identifier_node);
14176       tree a = NULL_TREE, t;
14177       /* If we're dealing with an anonymous class, pass the arguments
14178          of the crafted constructor along. */
14179       if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
14180         {
14181           SKIP_THIS_AND_ARTIFICIAL_PARMS (t, mdecl);
14182           for (; t != end_params_node; t = TREE_CHAIN (t))
14183             a = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (t)), a);
14184         }
14185       return build_method_invocation (super_wfl, a);
14186     }
14187 }
14188
14189 /* Build a SUPER/THIS qualified method invocation.  */
14190
14191 static tree
14192 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
14193      int use_this;
14194      tree name, args;
14195      int lloc, rloc;
14196 {
14197   tree invok;
14198   tree wfl = 
14199     build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
14200   EXPR_WFL_LINECOL (wfl) = lloc;
14201   invok = build_method_invocation (name, args);
14202   return make_qualified_primary (wfl, invok, rloc);
14203 }
14204
14205 /* Build an incomplete CALL_EXPR node. */
14206
14207 static tree
14208 build_method_invocation (name, args)
14209     tree name;
14210     tree args;
14211 {
14212   tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
14213   TREE_SIDE_EFFECTS (call) = 1;
14214   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14215   return call;
14216 }
14217
14218 /* Build an incomplete new xxx(...) node. */
14219
14220 static tree
14221 build_new_invocation (name, args)
14222     tree name, args;
14223 {
14224   tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
14225   TREE_SIDE_EFFECTS (call) = 1;
14226   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14227   return call;
14228 }
14229
14230 /* Build an incomplete assignment expression. */
14231
14232 static tree
14233 build_assignment (op, op_location, lhs, rhs)
14234      int op, op_location;
14235      tree lhs, rhs;
14236 {
14237   tree assignment;
14238   /* Build the corresponding binop if we deal with a Compound
14239      Assignment operator. Mark the binop sub-tree as part of a
14240      Compound Assignment expression */
14241   if (op != ASSIGN_TK)
14242     {
14243       rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
14244       COMPOUND_ASSIGN_P (rhs) = 1;
14245     }
14246   assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
14247   TREE_SIDE_EFFECTS (assignment) = 1;
14248   EXPR_WFL_LINECOL (assignment) = op_location;
14249   return assignment;
14250 }
14251
14252 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
14253
14254 char *
14255 print_int_node (node)
14256     tree node;
14257 {
14258   static char buffer [80];
14259   if (TREE_CONSTANT_OVERFLOW (node))
14260     sprintf (buffer, "<overflow>");
14261     
14262   if (TREE_INT_CST_HIGH (node) == 0)
14263     sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
14264              TREE_INT_CST_LOW (node));
14265   else if (TREE_INT_CST_HIGH (node) == -1
14266            && TREE_INT_CST_LOW (node) != 0)
14267     {
14268       buffer [0] = '-';
14269       sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
14270                -TREE_INT_CST_LOW (node));
14271     }
14272   else
14273     sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
14274              TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
14275
14276   return buffer;
14277 }
14278
14279 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
14280    context.  */
14281
14282 static int
14283 check_final_assignment (lvalue, wfl)
14284      tree lvalue, wfl;
14285 {
14286   if (TREE_CODE (lvalue) == COMPOUND_EXPR 
14287       && JDECL_P (TREE_OPERAND (lvalue, 1)))
14288     lvalue = TREE_OPERAND (lvalue, 1);
14289
14290   /* When generating class files, references to the `length' field
14291      look a bit different.  */
14292   if ((flag_emit_class_files
14293        && TREE_CODE (lvalue) == COMPONENT_REF
14294        && TYPE_ARRAY_P (TREE_TYPE (TREE_OPERAND (lvalue, 0)))
14295        && FIELD_FINAL (TREE_OPERAND (lvalue, 1)))
14296       || (TREE_CODE (lvalue) == FIELD_DECL
14297           && FIELD_FINAL (lvalue)
14298           && !DECL_CLINIT_P (current_function_decl)
14299           && !DECL_FINIT_P (current_function_decl)))
14300     {
14301       parse_error_context 
14302         (wfl, "Can't assign a value to the final variable `%s'",
14303          IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
14304       return 1;
14305     }
14306   return 0;
14307 }
14308
14309 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
14310    read. This is needed to avoid circularities in the implementation
14311    of these fields in libjava. */
14312
14313 static tree
14314 maybe_build_primttype_type_ref (rhs, wfl)
14315     tree rhs, wfl;
14316 {
14317   tree to_return = NULL_TREE;
14318   tree rhs_type = TREE_TYPE (rhs);
14319   if (TREE_CODE (rhs) == COMPOUND_EXPR)
14320     {
14321       tree n = TREE_OPERAND (rhs, 1);
14322       if (TREE_CODE (n) == VAR_DECL 
14323           && DECL_NAME (n) == TYPE_identifier_node
14324           && rhs_type == class_ptr_type)
14325         {
14326           const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
14327           if (!strncmp (self_name, "java.lang.", 10))
14328             to_return = build_primtype_type_ref (self_name);
14329         }
14330     }
14331   return (to_return ? to_return : rhs );
14332 }
14333
14334 /* 15.25 Assignment operators. */
14335
14336 static tree
14337 patch_assignment (node, wfl_op1, wfl_op2)
14338      tree node;
14339      tree wfl_op1;
14340      tree wfl_op2;
14341 {
14342   tree rhs = TREE_OPERAND (node, 1);
14343   tree lvalue = TREE_OPERAND (node, 0), llvalue;
14344   tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
14345   int error_found = 0;
14346   int lvalue_from_array = 0;
14347
14348   /* Can't assign to a (blank) final. */
14349   if (check_final_assignment (lvalue, wfl_op1))
14350     error_found = 1;
14351
14352   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14353
14354   /* Lhs can be a named variable */
14355   if (JDECL_P (lvalue))
14356     {
14357       lhs_type = TREE_TYPE (lvalue);
14358     }
14359   /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
14360      comment on reason why */
14361   else if (TREE_CODE (wfl_op1) == ARRAY_REF)
14362     {
14363       lhs_type = TREE_TYPE (lvalue);
14364       lvalue_from_array = 1;
14365     }
14366   /* Or a field access */
14367   else if (TREE_CODE (lvalue) == COMPONENT_REF)
14368     lhs_type = TREE_TYPE (lvalue);
14369   /* Or a function return slot */
14370   else if (TREE_CODE (lvalue) == RESULT_DECL)
14371     lhs_type = TREE_TYPE (lvalue);
14372   /* Otherwise, we might want to try to write into an optimized static
14373      final, this is an of a different nature, reported further on. */
14374   else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
14375            && resolve_expression_name (wfl_op1, &llvalue))
14376     {
14377       if (!error_found && check_final_assignment (llvalue, wfl_op1))
14378         {
14379           /* What we should do instead is resetting the all the flags
14380              previously set, exchange lvalue for llvalue and continue. */
14381           error_found = 1;
14382           return error_mark_node;
14383         }
14384       else 
14385         lhs_type = TREE_TYPE (lvalue);
14386     }
14387   else 
14388     {
14389       parse_error_context (wfl_op1, "Invalid left hand side of assignment");
14390       error_found = 1;
14391     }
14392
14393   rhs_type = TREE_TYPE (rhs);
14394   /* 5.1 Try the assignment conversion for builtin type. */
14395   new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
14396
14397   /* 5.2 If it failed, try a reference conversion */
14398   if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
14399     lhs_type = promote_type (rhs_type);
14400
14401   /* 15.25.2 If we have a compound assignment, convert RHS into the
14402      type of the LHS */
14403   else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14404     new_rhs = convert (lhs_type, rhs);
14405
14406   /* Explicit cast required. This is an error */
14407   if (!new_rhs)
14408     {
14409       char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
14410       char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
14411       tree wfl;
14412       char operation [32];      /* Max size known */
14413
14414       /* If the assignment is part of a declaration, we use the WFL of
14415          the declared variable to point out the error and call it a
14416          declaration problem. If the assignment is a genuine =
14417          operator, we call is a operator `=' problem, otherwise we
14418          call it an assignment problem. In both of these last cases,
14419          we use the WFL of the operator to indicate the error. */
14420
14421       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
14422         {
14423           wfl = wfl_op1;
14424           strcpy (operation, "declaration");
14425         }
14426       else
14427         {
14428           wfl = wfl_operator;
14429           if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14430             strcpy (operation, "assignment");
14431           else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
14432             strcpy (operation, "`return'");
14433           else
14434             strcpy (operation, "`='");
14435         }
14436
14437       if (!valid_cast_to_p (rhs_type, lhs_type))
14438         parse_error_context
14439           (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
14440            operation, t1, t2);
14441       else
14442         parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
14443                              operation, t1, t2);
14444       free (t1); free (t2);
14445       error_found = 1;
14446     }
14447
14448   /* Inline read access to java.lang.PRIMTYPE.TYPE */
14449   if (new_rhs)
14450     new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
14451
14452   if (error_found)
14453     return error_mark_node;
14454
14455   /* 10.10: Array Store Exception runtime check */
14456   if (!flag_emit_class_files
14457       && !flag_emit_xref
14458       && lvalue_from_array 
14459       && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
14460     {
14461       tree check;
14462       tree base = lvalue;
14463
14464       /* We need to retrieve the right argument for _Jv_CheckArrayStore */
14465       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14466         base = TREE_OPERAND (lvalue, 0);
14467       else
14468         {
14469           if (flag_bounds_check)
14470             base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
14471           else
14472             base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
14473         }
14474
14475       /* Build the invocation of _Jv_CheckArrayStore */
14476       new_rhs = save_expr (new_rhs);
14477       check = build (CALL_EXPR, void_type_node,
14478                      build_address_of (soft_checkarraystore_node),
14479                      tree_cons (NULL_TREE, base,
14480                                 build_tree_list (NULL_TREE, new_rhs)),
14481                      NULL_TREE);
14482       TREE_SIDE_EFFECTS (check) = 1;
14483
14484       /* We have to decide on an insertion point */
14485       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14486         {
14487           tree t;
14488           if (flag_bounds_check)
14489             {
14490               t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
14491               TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
14492                 build (COMPOUND_EXPR, void_type_node, t, check);
14493             }
14494           else
14495             TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
14496                                               check, TREE_OPERAND (lvalue, 1));
14497         }
14498       else 
14499         {
14500           /* Make sure the bound check will happen before the store check */
14501           if (flag_bounds_check)
14502             TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
14503               build (COMPOUND_EXPR, void_type_node,
14504                      TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
14505           else
14506             lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
14507         }
14508     }
14509
14510   TREE_OPERAND (node, 0) = lvalue;
14511   TREE_OPERAND (node, 1) = new_rhs;
14512   TREE_TYPE (node) = lhs_type;
14513   return node;
14514 }
14515
14516 /* Check that type SOURCE can be cast into type DEST. If the cast
14517    can't occur at all, return 0 otherwise 1. This function is used to
14518    produce accurate error messages on the reasons why an assignment
14519    failed. */
14520
14521 static tree
14522 try_reference_assignconv (lhs_type, rhs)
14523      tree lhs_type, rhs;
14524 {
14525   tree new_rhs = NULL_TREE;
14526   tree rhs_type = TREE_TYPE (rhs);
14527
14528   if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
14529     {
14530       /* `null' may be assigned to any reference type */
14531       if (rhs == null_pointer_node)
14532         new_rhs = null_pointer_node;
14533       /* Try the reference assignment conversion */
14534       else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
14535         new_rhs = rhs;
14536       /* This is a magic assignment that we process differently */
14537       else if (rhs == soft_exceptioninfo_call_node)
14538         new_rhs = rhs;
14539     }
14540   return new_rhs;
14541 }
14542
14543 /* Check that RHS can be converted into LHS_TYPE by the assignment
14544    conversion (5.2), for the cases of RHS being a builtin type. Return
14545    NULL_TREE if the conversion fails or if because RHS isn't of a
14546    builtin type. Return a converted RHS if the conversion is possible.  */
14547
14548 static tree
14549 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
14550      tree wfl_op1, lhs_type, rhs;
14551 {
14552   tree new_rhs = NULL_TREE;
14553   tree rhs_type = TREE_TYPE (rhs);
14554
14555   /* Zero accepted everywhere */
14556   if (TREE_CODE (rhs) == INTEGER_CST 
14557       && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
14558       && JPRIMITIVE_TYPE_P (rhs_type))
14559     new_rhs = convert (lhs_type, rhs);
14560
14561   /* 5.1.1 Try Identity Conversion,
14562      5.1.2 Try Widening Primitive Conversion */
14563   else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
14564     new_rhs = convert (lhs_type, rhs);
14565
14566   /* Try a narrowing primitive conversion (5.1.3): 
14567        - expression is a constant expression of type int AND
14568        - variable is byte, short or char AND
14569        - The value of the expression is representable in the type of the 
14570          variable */
14571   else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
14572            && (lhs_type == byte_type_node || lhs_type == char_type_node
14573                || lhs_type == short_type_node))
14574     {
14575       if (int_fits_type_p (rhs, lhs_type))
14576         new_rhs = convert (lhs_type, rhs);
14577       else if (wfl_op1)         /* Might be called with a NULL */
14578         parse_warning_context 
14579           (wfl_op1, "Constant expression `%s' to wide for narrowing primitive conversion to `%s'", 
14580            print_int_node (rhs), lang_printable_name (lhs_type, 0));
14581       /* Reported a warning that will turn into an error further
14582          down, so we don't return */
14583     }
14584
14585   return new_rhs;
14586 }
14587
14588 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
14589    conversion (5.1.1) or widening primitve conversion (5.1.2).  Return
14590    0 is the conversion test fails.  This implements parts the method
14591    invocation convertion (5.3).  */
14592
14593 static int
14594 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
14595      tree lhs_type, rhs_type;
14596 {
14597   /* 5.1.1: This is the identity conversion part. */
14598   if (lhs_type == rhs_type)
14599     return 1;
14600
14601   /* Reject non primitive types */
14602   if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
14603     return 0;
14604
14605   /* 5.1.2: widening primitive conversion. byte, even if it's smaller
14606      than a char can't be converted into a char. Short can't too, but
14607      the < test below takes care of that */
14608   if (lhs_type == char_type_node && rhs_type == byte_type_node)
14609     return 0;
14610
14611   /* Accept all promoted type here. Note, we can't use <= in the test
14612      below, because we still need to bounce out assignments of short
14613      to char and the likes */
14614   if (lhs_type == int_type_node
14615       && (rhs_type == promoted_byte_type_node
14616           || rhs_type == promoted_short_type_node
14617           || rhs_type == promoted_char_type_node
14618           || rhs_type == promoted_boolean_type_node))
14619     return 1;
14620
14621   /* From here, an integral is widened if its precision is smaller
14622      than the precision of the LHS or if the LHS is a floating point
14623      type, or the RHS is a float and the RHS a double. */
14624   if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type) 
14625        && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
14626       || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
14627       || (rhs_type == float_type_node && lhs_type == double_type_node))
14628     return 1;
14629
14630   return 0;
14631 }
14632
14633 /* Check that something of SOURCE type can be assigned or cast to
14634    something of DEST type at runtime. Return 1 if the operation is
14635    valid, 0 otherwise. If CAST is set to 1, we're treating the case
14636    were SOURCE is cast into DEST, which borrows a lot of the
14637    assignment check. */
14638
14639 static int
14640 valid_ref_assignconv_cast_p (source, dest, cast)
14641      tree source;
14642      tree dest;
14643      int cast;
14644 {
14645   /* SOURCE or DEST might be null if not from a declared entity. */
14646   if (!source || !dest)
14647     return 0;
14648   if (JNULLP_TYPE_P (source))
14649     return 1;
14650   if (TREE_CODE (source) == POINTER_TYPE)
14651     source = TREE_TYPE (source);
14652   if (TREE_CODE (dest) == POINTER_TYPE)
14653     dest = TREE_TYPE (dest);
14654   /* Case where SOURCE is a class type */
14655   if (TYPE_CLASS_P (source))
14656     {
14657       if (TYPE_CLASS_P (dest))
14658         return  (source == dest 
14659                  || inherits_from_p (source, dest)
14660                  || enclosing_context_p (dest, source /*source, dest*/)
14661                  || (cast && inherits_from_p (dest, source)));
14662       if (TYPE_INTERFACE_P (dest))
14663         {
14664           /* If doing a cast and SOURCE is final, the operation is
14665              always correct a compile time (because even if SOURCE
14666              does not implement DEST, a subclass of SOURCE might). */
14667           if (cast && !CLASS_FINAL (TYPE_NAME (source)))
14668             return 1;
14669           /* Otherwise, SOURCE must implement DEST */
14670           return interface_of_p (dest, source);
14671         }
14672       /* DEST is an array, cast permited if SOURCE is of Object type */
14673       return (cast && source == object_type_node ? 1 : 0);
14674     }
14675   if (TYPE_INTERFACE_P (source))
14676     {
14677       if (TYPE_CLASS_P (dest))
14678         {
14679           /* If not casting, DEST must be the Object type */
14680           if (!cast)
14681             return dest == object_type_node;
14682           /* We're doing a cast. The cast is always valid is class
14683              DEST is not final, otherwise, DEST must implement SOURCE */
14684           else if (!CLASS_FINAL (TYPE_NAME (dest)))
14685             return 1;
14686           else
14687             return interface_of_p (source, dest);
14688         }
14689       if (TYPE_INTERFACE_P (dest))
14690         {
14691           /* If doing a cast, then if SOURCE and DEST contain method
14692              with the same signature but different return type, then
14693              this is a (compile time) error */
14694           if (cast)
14695             {
14696               tree method_source, method_dest;
14697               tree source_type;
14698               tree source_sig;
14699               tree source_name;
14700               for (method_source = TYPE_METHODS (source); method_source; 
14701                    method_source = TREE_CHAIN (method_source))
14702                 {
14703                   source_sig = 
14704                     build_java_argument_signature (TREE_TYPE (method_source));
14705                   source_type = TREE_TYPE (TREE_TYPE (method_source));
14706                   source_name = DECL_NAME (method_source);
14707                   for (method_dest = TYPE_METHODS (dest);
14708                        method_dest; method_dest = TREE_CHAIN (method_dest))
14709                     if (source_sig == 
14710                         build_java_argument_signature (TREE_TYPE (method_dest))
14711                         && source_name == DECL_NAME (method_dest)
14712                         && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
14713                       return 0;
14714                 }
14715               return 1;
14716             }
14717           else
14718             return source == dest || interface_of_p (dest, source);
14719         }
14720       else                      /* Array */
14721         return (cast ? 
14722                 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
14723     }
14724   if (TYPE_ARRAY_P (source))
14725     {
14726       if (TYPE_CLASS_P (dest))
14727         return dest == object_type_node;
14728       /* Can't cast an array to an interface unless the interface is
14729          java.lang.Cloneable */
14730       if (TYPE_INTERFACE_P (dest))
14731         return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
14732       else                      /* Arrays */
14733         {
14734           tree source_element_type = TYPE_ARRAY_ELEMENT (source);
14735           tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
14736           
14737           /* In case of severe errors, they turn out null */
14738           if (!dest_element_type || !source_element_type)
14739             return 0;
14740           if (source_element_type == dest_element_type)
14741             return 1;
14742           return valid_ref_assignconv_cast_p (source_element_type,
14743                                               dest_element_type, cast);
14744         }
14745       return 0;
14746     }
14747   return 0;
14748 }
14749
14750 static int
14751 valid_cast_to_p (source, dest)
14752      tree source;
14753      tree dest;
14754 {
14755   if (TREE_CODE (source) == POINTER_TYPE)
14756     source = TREE_TYPE (source);
14757   if (TREE_CODE (dest) == POINTER_TYPE)
14758     dest = TREE_TYPE (dest);
14759
14760   if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
14761     return valid_ref_assignconv_cast_p (source, dest, 1);
14762
14763   else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
14764     return 1;
14765
14766   return 0;
14767 }
14768
14769 /* Method invocation conversion test. Return 1 if type SOURCE can be
14770    converted to type DEST through the methond invocation conversion
14771    process (5.3) */
14772
14773 static tree
14774 do_unary_numeric_promotion (arg)
14775      tree arg;
14776 {
14777   tree type = TREE_TYPE (arg);
14778   if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
14779       : TREE_CODE (type) == CHAR_TYPE)
14780     arg = convert (int_type_node, arg);
14781   return arg;
14782 }
14783
14784 /* Return a non zero value if SOURCE can be converted into DEST using
14785    the method invocation conversion rule (5.3).  */
14786 static int
14787 valid_method_invocation_conversion_p (dest, source)
14788      tree dest, source;
14789 {
14790   return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
14791            && valid_builtin_assignconv_identity_widening_p (dest, source))
14792           || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
14793               && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
14794               && valid_ref_assignconv_cast_p (source, dest, 0)));
14795 }
14796
14797 /* Build an incomplete binop expression. */
14798
14799 static tree
14800 build_binop (op, op_location, op1, op2)
14801      enum tree_code op;
14802      int op_location;
14803      tree op1, op2;
14804 {
14805   tree binop = build (op, NULL_TREE, op1, op2);
14806   TREE_SIDE_EFFECTS (binop) = 1;
14807   /* Store the location of the operator, for better error report. The
14808      string of the operator will be rebuild based on the OP value. */
14809   EXPR_WFL_LINECOL (binop) = op_location;
14810   return binop;
14811 }
14812
14813 /* Build the string of the operator retained by NODE. If NODE is part
14814    of a compound expression, add an '=' at the end of the string. This
14815    function is called when an error needs to be reported on an
14816    operator. The string is returned as a pointer to a static character
14817    buffer. */
14818
14819 static char *
14820 operator_string (node)
14821      tree node;
14822 {
14823 #define BUILD_OPERATOR_STRING(S)                                        \
14824   {                                                                     \
14825     sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
14826     return buffer;                                                      \
14827   }
14828   
14829   static char buffer [10];
14830   switch (TREE_CODE (node))
14831     {
14832     case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
14833     case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
14834     case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
14835     case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14836     case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
14837     case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
14838     case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
14839     case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
14840     case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
14841     case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
14842     case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
14843     case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
14844     case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
14845     case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
14846     case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
14847     case GT_EXPR: BUILD_OPERATOR_STRING (">");
14848     case GE_EXPR: BUILD_OPERATOR_STRING (">=");
14849     case LT_EXPR: BUILD_OPERATOR_STRING ("<");
14850     case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
14851     case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14852     case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
14853     case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
14854     case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
14855     case PREINCREMENT_EXPR:     /* Fall through */
14856     case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
14857     case PREDECREMENT_EXPR:     /* Fall through */
14858     case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
14859     default:
14860       fatal ("unregistered operator %s - operator_string",
14861              tree_code_name [TREE_CODE (node)]);
14862     }
14863   return NULL;
14864 #undef BUILD_OPERATOR_STRING
14865 }
14866
14867 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2.  */
14868
14869 static int
14870 java_decl_equiv (var_acc1, var_acc2)
14871      tree var_acc1, var_acc2;
14872 {
14873   if (JDECL_P (var_acc1))
14874     return (var_acc1 == var_acc2);
14875   
14876   return (TREE_CODE (var_acc1) == COMPONENT_REF
14877           && TREE_CODE (var_acc2) == COMPONENT_REF
14878           && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
14879              == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
14880           && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
14881 }
14882
14883 /* Return a non zero value if CODE is one of the operators that can be
14884    used in conjunction with the `=' operator in a compound assignment.  */
14885
14886 static int
14887 binop_compound_p (code)
14888     enum tree_code code;
14889 {
14890   int i;
14891   for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
14892     if (binop_lookup [i] == code)
14893       break;
14894
14895   return i < BINOP_COMPOUND_CANDIDATES;
14896 }
14897
14898 /* Reorganize after a fold to get SAVE_EXPR to generate what we want.  */
14899
14900 static tree
14901 java_refold (t)
14902      tree t;
14903 {
14904   tree c, b, ns, decl;
14905
14906   if (TREE_CODE (t) != MODIFY_EXPR)
14907     return t;
14908
14909   c = TREE_OPERAND (t, 1);
14910   if (! (c && TREE_CODE (c) == COMPOUND_EXPR
14911          && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
14912          && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
14913     return t;
14914
14915   /* Now the left branch of the binary operator. */
14916   b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
14917   if (! (b && TREE_CODE (b) == NOP_EXPR 
14918          && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
14919     return t;
14920
14921   ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
14922   if (! (ns && TREE_CODE (ns) == NOP_EXPR
14923          && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
14924     return t;
14925
14926   decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
14927   if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
14928       /* It's got to be the an equivalent decl */
14929       && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
14930     {
14931       /* Shorten the NOP_EXPR/SAVE_EXPR path. */
14932       TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
14933       /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
14934       TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
14935       /* Change the right part of the BINOP_EXPR */
14936       TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
14937     }
14938
14939   return t;
14940 }
14941
14942 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
14943    errors but we modify NODE so that it contains the type computed
14944    according to the expression, when it's fixed. Otherwise, we write
14945    error_mark_node as the type. It allows us to further the analysis
14946    of remaining nodes and detects more errors in certain cases.  */
14947
14948 static tree
14949 patch_binop (node, wfl_op1, wfl_op2)
14950      tree node;
14951      tree wfl_op1;
14952      tree wfl_op2;
14953 {
14954   tree op1 = TREE_OPERAND (node, 0);
14955   tree op2 = TREE_OPERAND (node, 1);
14956   tree op1_type = TREE_TYPE (op1);
14957   tree op2_type = TREE_TYPE (op2);
14958   tree prom_type = NULL_TREE, cn;
14959   int code = TREE_CODE (node);
14960
14961   /* If 1, tell the routine that we have to return error_mark_node
14962      after checking for the initialization of the RHS */
14963   int error_found = 0;
14964
14965   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14966
14967   switch (code)
14968     {
14969     /* 15.16 Multiplicative operators */
14970     case MULT_EXPR:             /* 15.16.1 Multiplication Operator * */
14971     case RDIV_EXPR:             /* 15.16.2 Division Operator / */
14972     case TRUNC_DIV_EXPR:        /* 15.16.2 Integral type Division Operator / */
14973     case TRUNC_MOD_EXPR:        /* 15.16.3 Remainder operator % */
14974       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14975         {
14976           if (!JPRIMITIVE_TYPE_P (op1_type))
14977             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14978           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14979             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14980           TREE_TYPE (node) = error_mark_node;
14981           error_found = 1;
14982           break;
14983         }
14984       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14985       /* Change the division operator if necessary */
14986       if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
14987         TREE_SET_CODE (node, TRUNC_DIV_EXPR);
14988
14989       if (TREE_CODE (prom_type) == INTEGER_TYPE
14990           && flag_use_divide_subroutine
14991           && ! flag_emit_class_files
14992           && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
14993         return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
14994  
14995       /* This one is more complicated. FLOATs are processed by a
14996          function call to soft_fmod. Duplicate the value of the
14997          COMPOUND_ASSIGN_P flag. */
14998       if (code == TRUNC_MOD_EXPR)
14999         {
15000           tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
15001           COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
15002           TREE_SIDE_EFFECTS (mod)
15003             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15004           return mod;
15005         }
15006       break;
15007
15008     /* 15.17 Additive Operators */
15009     case PLUS_EXPR:             /* 15.17.1 String Concatenation Operator + */
15010
15011       /* Operation is valid if either one argument is a string
15012          constant, a String object or a StringBuffer crafted for the
15013          purpose of the a previous usage of the String concatenation
15014          operator */
15015
15016       if (TREE_CODE (op1) == STRING_CST 
15017           || TREE_CODE (op2) == STRING_CST
15018           || JSTRING_TYPE_P (op1_type)
15019           || JSTRING_TYPE_P (op2_type)
15020           || IS_CRAFTED_STRING_BUFFER_P (op1)
15021           || IS_CRAFTED_STRING_BUFFER_P (op2))
15022         return build_string_concatenation (op1, op2);
15023
15024     case MINUS_EXPR:            /* 15.17.2 Additive Operators (+ and -) for
15025                                    Numeric Types */
15026       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
15027         {
15028           if (!JPRIMITIVE_TYPE_P (op1_type))
15029             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15030           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
15031             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15032           TREE_TYPE (node) = error_mark_node;
15033           error_found = 1;
15034           break;
15035         }
15036       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15037       break;
15038
15039     /* 15.18 Shift Operators */
15040     case LSHIFT_EXPR:
15041     case RSHIFT_EXPR:
15042     case URSHIFT_EXPR:
15043       if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
15044         {
15045           if (!JINTEGRAL_TYPE_P (op1_type))
15046             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15047           else
15048             {
15049               if (JPRIMITIVE_TYPE_P (op2_type))
15050                 parse_error_context (wfl_operator,
15051                                      "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
15052                                      operator_string (node),
15053                                      lang_printable_name (op2_type, 0));
15054               else
15055                 parse_error_context (wfl_operator,
15056                                      "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral", 
15057                                      operator_string (node),
15058                                      lang_printable_name (op2_type, 0));
15059             }
15060           TREE_TYPE (node) = error_mark_node;
15061           error_found = 1;
15062           break;
15063         }
15064
15065       /* Unary numeric promotion (5.6.1) is performed on each operand
15066          separatly */
15067       op1 = do_unary_numeric_promotion (op1);
15068       op2 = do_unary_numeric_promotion (op2);
15069
15070       /* The type of the shift expression is the type of the promoted
15071          type of the left-hand operand */
15072       prom_type = TREE_TYPE (op1);
15073
15074       /* Shift int only up to 0x1f and long up to 0x3f */
15075       if (prom_type == int_type_node)
15076         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
15077                            build_int_2 (0x1f, 0)));
15078       else
15079         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
15080                            build_int_2 (0x3f, 0)));
15081
15082       /* The >>> operator is a >> operating on unsigned quantities */
15083       if (code == URSHIFT_EXPR && ! flag_emit_class_files)
15084         {
15085           tree to_return;
15086           tree utype = unsigned_type (prom_type);
15087           op1 = convert (utype, op1);
15088           TREE_SET_CODE (node, RSHIFT_EXPR);
15089           TREE_OPERAND (node, 0) = op1;
15090           TREE_OPERAND (node, 1) = op2;
15091           TREE_TYPE (node) = utype;
15092           to_return = convert (prom_type, node);
15093           /* Copy the original value of the COMPOUND_ASSIGN_P flag */
15094           COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
15095           TREE_SIDE_EFFECTS (to_return)
15096             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15097           return to_return;
15098         }
15099       break;
15100
15101       /* 15.19.1 Type Comparison Operator instaceof */
15102     case INSTANCEOF_EXPR:
15103
15104       TREE_TYPE (node) = boolean_type_node;
15105
15106       if (!(op2_type = resolve_type_during_patch (op2)))
15107         return error_mark_node;
15108
15109       /* The first operand must be a reference type or the null type */
15110       if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
15111         error_found = 1;        /* Error reported further below */
15112
15113       /* The second operand must be a reference type */
15114       if (!JREFERENCE_TYPE_P (op2_type))
15115         {
15116           SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
15117           parse_error_context
15118             (wfl_operator, "Invalid argument `%s' for `instanceof'",
15119              lang_printable_name (op2_type, 0));
15120           error_found = 1;
15121         }
15122
15123       if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
15124         {
15125           /* If the first operand is null, the result is always false */
15126           if (op1 == null_pointer_node)
15127             return boolean_false_node;
15128           else if (flag_emit_class_files)
15129             {
15130               TREE_OPERAND (node, 1) = op2_type;
15131               TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
15132               return node;
15133             }
15134           /* Otherwise we have to invoke instance of to figure it out */
15135           else
15136             return build_instanceof (op1, op2_type);
15137         }
15138       /* There is no way the expression operand can be an instance of
15139          the type operand. This is a compile time error. */
15140       else
15141         {
15142           char *t1 = xstrdup (lang_printable_name (op1_type, 0));
15143           SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
15144           parse_error_context 
15145             (wfl_operator, "Impossible for `%s' to be instance of `%s'",
15146              t1, lang_printable_name (op2_type, 0));
15147           free (t1);
15148           error_found = 1;
15149         }
15150       
15151       break;
15152
15153       /* 15.21 Bitwise and Logical Operators */
15154     case BIT_AND_EXPR:
15155     case BIT_XOR_EXPR:
15156     case BIT_IOR_EXPR:
15157       if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
15158         /* Binary numeric promotion is performed on both operand and the
15159            expression retain that type */
15160         prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15161
15162       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE 
15163                && TREE_CODE (op1_type) == BOOLEAN_TYPE)
15164         /* The type of the bitwise operator expression is BOOLEAN */
15165         prom_type = boolean_type_node;
15166       else
15167         {
15168           if (!JINTEGRAL_TYPE_P (op1_type))
15169             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15170           if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
15171             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
15172           TREE_TYPE (node) = error_mark_node;
15173           error_found = 1;
15174           /* Insert a break here if adding thing before the switch's
15175              break for this case */
15176         }
15177       break;
15178
15179       /* 15.22 Conditional-And Operator */
15180     case TRUTH_ANDIF_EXPR:
15181       /* 15.23 Conditional-Or Operator */
15182     case TRUTH_ORIF_EXPR:
15183       /* Operands must be of BOOLEAN type */
15184       if (TREE_CODE (op1_type) != BOOLEAN_TYPE || 
15185           TREE_CODE (op2_type) != BOOLEAN_TYPE)
15186         {
15187           if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
15188             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
15189           if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
15190             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
15191           TREE_TYPE (node) = boolean_type_node;
15192           error_found = 1;
15193           break;
15194         }
15195       /* The type of the conditional operators is BOOLEAN */
15196       prom_type = boolean_type_node;
15197       break;
15198
15199       /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
15200     case LT_EXPR:
15201     case GT_EXPR:
15202     case LE_EXPR:
15203     case GE_EXPR:
15204       /* The type of each of the operands must be a primitive numeric
15205          type */
15206       if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
15207         {
15208           if (!JNUMERIC_TYPE_P (op1_type))
15209             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15210           if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
15211             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15212           TREE_TYPE (node) = boolean_type_node;
15213           error_found = 1;
15214           break;
15215         }
15216       /* Binary numeric promotion is performed on the operands */
15217       binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15218       /* The type of the relation expression is always BOOLEAN */
15219       prom_type = boolean_type_node;
15220       break;
15221
15222       /* 15.20 Equality Operator */
15223     case EQ_EXPR:
15224     case NE_EXPR:
15225       /* It's time for us to patch the strings. */
15226       if ((cn = patch_string (op1))) 
15227        {
15228          op1 = cn;
15229          op1_type = TREE_TYPE (op1);
15230        }
15231       if ((cn = patch_string (op2))) 
15232        {
15233          op2 = cn;
15234          op2_type = TREE_TYPE (op2);
15235        }
15236       
15237       /* 15.20.1 Numerical Equality Operators == and != */
15238       /* Binary numeric promotion is performed on the operands */
15239       if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
15240         binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15241       
15242       /* 15.20.2 Boolean Equality Operators == and != */
15243       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
15244           TREE_CODE (op2_type) == BOOLEAN_TYPE)
15245         ;                       /* Nothing to do here */
15246       
15247       /* 15.20.3 Reference Equality Operators == and != */
15248       /* Types have to be either references or the null type. If
15249          they're references, it must be possible to convert either
15250          type to the other by casting conversion. */
15251       else if (op1 == null_pointer_node || op2 == null_pointer_node 
15252                || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
15253                    && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
15254                        || valid_ref_assignconv_cast_p (op2_type, 
15255                                                        op1_type, 1))))
15256         ;                       /* Nothing to do here */
15257           
15258       /* Else we have an error figure what can't be converted into
15259          what and report the error */
15260       else
15261         {
15262           char *t1;
15263           t1 = xstrdup (lang_printable_name (op1_type, 0));
15264           parse_error_context 
15265             (wfl_operator,
15266              "Incompatible type for `%s'. Can't convert `%s' to `%s'",
15267              operator_string (node), t1, 
15268              lang_printable_name (op2_type, 0));
15269           free (t1);
15270           TREE_TYPE (node) = boolean_type_node;
15271           error_found = 1;
15272           break;
15273         }
15274       prom_type = boolean_type_node;
15275       break;
15276     }
15277
15278   if (error_found)
15279     return error_mark_node;
15280
15281   TREE_OPERAND (node, 0) = op1;
15282   TREE_OPERAND (node, 1) = op2;
15283   TREE_TYPE (node) = prom_type;
15284   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15285   
15286   if (flag_emit_xref)
15287     return node;
15288
15289   /* fold does not respect side-effect order as required for Java but not C.
15290    * Also, it sometimes create SAVE_EXPRs which are bad when emitting
15291    * bytecode.
15292    */
15293   if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
15294       : ! TREE_SIDE_EFFECTS (node))
15295     node = fold (node);
15296   return node;
15297 }
15298
15299 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
15300    zero value, the value of CSTE comes after the valude of STRING */
15301
15302 static tree
15303 do_merge_string_cste (cste, string, string_len, after)
15304      tree cste;
15305      const char *string;
15306      int string_len, after;
15307 {
15308   int len = TREE_STRING_LENGTH (cste) + string_len;
15309   const char *old = TREE_STRING_POINTER (cste);
15310   TREE_STRING_LENGTH (cste) = len;
15311   TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
15312   if (after)
15313     {
15314       strcpy (TREE_STRING_POINTER (cste), string);
15315       strcat (TREE_STRING_POINTER (cste), old);
15316     }
15317   else
15318     {
15319       strcpy (TREE_STRING_POINTER (cste), old);
15320       strcat (TREE_STRING_POINTER (cste), string);
15321     }
15322   return cste;
15323 }
15324
15325 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
15326    new STRING_CST on success, NULL_TREE on failure */
15327
15328 static tree
15329 merge_string_cste (op1, op2, after)
15330      tree op1, op2;
15331      int after;
15332 {
15333   /* Handle two string constants right away */
15334   if (TREE_CODE (op2) == STRING_CST)
15335     return do_merge_string_cste (op1, TREE_STRING_POINTER (op2), 
15336                                  TREE_STRING_LENGTH (op2), after);
15337   
15338   /* Reasonable integer constant can be treated right away */
15339   if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
15340     {
15341       static const char *boolean_true = "true";
15342       static const char *boolean_false = "false";
15343       static const char *null_pointer = "null";
15344       char ch[3];
15345       const char *string;
15346       
15347       if (op2 == boolean_true_node)
15348         string = boolean_true;
15349       else if (op2 == boolean_false_node)
15350         string = boolean_false;
15351       else if (op2 == null_pointer_node)
15352         string = null_pointer;
15353       else if (TREE_TYPE (op2) == char_type_node)
15354         {
15355           ch[0] = (char )TREE_INT_CST_LOW (op2);
15356           ch[1] = '\0';
15357           string = ch;
15358         }
15359       else
15360           string = print_int_node (op2);
15361       
15362       return do_merge_string_cste (op1, string, strlen (string), after);
15363     }
15364   return NULL_TREE;
15365 }
15366
15367 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
15368    has to be a STRING_CST and the other part must be a STRING_CST or a
15369    INTEGRAL constant. Return a new STRING_CST if the operation
15370    succeed, NULL_TREE otherwise.
15371
15372    If the case we want to optimize for space, we might want to return
15373    NULL_TREE for each invocation of this routine. FIXME */
15374
15375 static tree
15376 string_constant_concatenation (op1, op2)
15377      tree op1, op2;
15378 {
15379   if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
15380     {
15381       tree string, rest;
15382       int invert;
15383       
15384       string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
15385       rest   = (string == op1 ? op2 : op1);
15386       invert = (string == op1 ? 0 : 1 );
15387       
15388       /* Walk REST, only if it looks reasonable */
15389       if (TREE_CODE (rest) != STRING_CST
15390           && !IS_CRAFTED_STRING_BUFFER_P (rest)
15391           && !JSTRING_TYPE_P (TREE_TYPE (rest))
15392           && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
15393         {
15394           rest = java_complete_tree (rest);
15395           if (rest == error_mark_node)
15396             return error_mark_node;
15397           rest = fold (rest);
15398         }
15399       return merge_string_cste (string, rest, invert);
15400     }
15401   return NULL_TREE;
15402 }
15403
15404 /* Implement the `+' operator. Does static optimization if possible,
15405    otherwise create (if necessary) and append elements to a
15406    StringBuffer. The StringBuffer will be carried around until it is
15407    used for a function call or an assignment. Then toString() will be
15408    called on it to turn it into a String object. */
15409
15410 static tree
15411 build_string_concatenation (op1, op2)
15412      tree op1, op2;
15413 {
15414   tree result;
15415   int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15416
15417   if (flag_emit_xref)
15418     return build (PLUS_EXPR, string_type_node, op1, op2);
15419   
15420   /* Try to do some static optimization */
15421   if ((result = string_constant_concatenation (op1, op2)))
15422     return result;
15423
15424   /* Discard empty strings on either side of the expression */
15425   if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
15426     {
15427       op1 = op2;
15428       op2 = NULL_TREE;
15429     }
15430   else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
15431     op2 = NULL_TREE;
15432
15433   /* If operands are string constant, turn then into object references */
15434   if (TREE_CODE (op1) == STRING_CST)
15435     op1 = patch_string_cst (op1);
15436   if (op2 && TREE_CODE (op2) == STRING_CST)
15437     op2 = patch_string_cst (op2);
15438
15439   /* If either one of the constant is null and the other non null
15440      operand is a String object, return it. */
15441   if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
15442     return op1;
15443
15444   /* If OP1 isn't already a StringBuffer, create and
15445      initialize a new one */
15446   if (!IS_CRAFTED_STRING_BUFFER_P (op1))
15447     {
15448       /* Two solutions here: 
15449          1) OP1 is a constant string reference, we call new StringBuffer(OP1)
15450          2) OP1 is something else, we call new StringBuffer().append(OP1).  */
15451       if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1)))
15452         op1 = BUILD_STRING_BUFFER (op1);
15453       else
15454         {
15455           tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
15456           op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
15457         }
15458     }
15459
15460   if (op2)
15461     {
15462       /* OP1 is no longer the last node holding a crafted StringBuffer */
15463       IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
15464       /* Create a node for `{new...,xxx}.append (op2)' */
15465       if (op2)
15466         op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
15467     }
15468
15469   /* Mark the last node holding a crafted StringBuffer */
15470   IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
15471
15472   TREE_SIDE_EFFECTS (op1) = side_effects;
15473   return op1;
15474 }
15475
15476 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
15477    StringBuffer. If no string were found to be patched, return
15478    NULL. */
15479
15480 static tree
15481 patch_string (node)
15482     tree node;
15483 {
15484   if (node == error_mark_node)
15485     return error_mark_node;
15486   if (TREE_CODE (node) == STRING_CST)
15487     return patch_string_cst (node);
15488   else if (IS_CRAFTED_STRING_BUFFER_P (node))
15489     {
15490       int saved = ctxp->explicit_constructor_p;
15491       tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
15492       tree ret;
15493       /* Temporary disable forbid the use of `this'. */
15494       ctxp->explicit_constructor_p = 0;
15495       ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
15496       /* String concatenation arguments must be evaluated in order too. */
15497       ret = force_evaluation_order (ret);
15498       /* Restore it at its previous value */
15499       ctxp->explicit_constructor_p = saved;
15500       return ret;
15501     }
15502   return NULL_TREE;
15503 }
15504
15505 /* Build the internal representation of a string constant.  */
15506
15507 static tree
15508 patch_string_cst (node)
15509      tree node;
15510 {
15511   int location;
15512   if (! flag_emit_class_files)
15513     {
15514       push_obstacks (&permanent_obstack, &permanent_obstack);
15515       node = get_identifier (TREE_STRING_POINTER (node));
15516       location = alloc_name_constant (CONSTANT_String, node);
15517       node = build_ref_from_constant_pool (location);
15518       pop_obstacks ();
15519     }
15520   TREE_TYPE (node) = string_ptr_type_node;
15521   TREE_CONSTANT (node) = 1;
15522   return node;
15523 }
15524
15525 /* Build an incomplete unary operator expression. */
15526
15527 static tree
15528 build_unaryop (op_token, op_location, op1)
15529      int op_token, op_location;
15530      tree op1;
15531 {
15532   enum tree_code op;
15533   tree unaryop;
15534   switch (op_token)
15535     {
15536     case PLUS_TK: op = UNARY_PLUS_EXPR; break;
15537     case MINUS_TK: op = NEGATE_EXPR; break;
15538     case NEG_TK: op = TRUTH_NOT_EXPR; break;
15539     case NOT_TK: op = BIT_NOT_EXPR; break;
15540     default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
15541                     op_token);
15542     }
15543
15544   unaryop = build1 (op, NULL_TREE, op1);
15545   TREE_SIDE_EFFECTS (unaryop) = 1;
15546   /* Store the location of the operator, for better error report. The
15547      string of the operator will be rebuild based on the OP value. */
15548   EXPR_WFL_LINECOL (unaryop) = op_location;
15549   return unaryop;
15550 }
15551
15552 /* Special case for the ++/-- operators, since they require an extra
15553    argument to build, which is set to NULL and patched
15554    later. IS_POST_P is 1 if the operator, 0 otherwise.  */
15555
15556 static tree
15557 build_incdec (op_token, op_location, op1, is_post_p)
15558      int op_token, op_location;
15559      tree op1;
15560      int is_post_p;
15561 {
15562   static enum tree_code lookup [2][2] = 
15563     {
15564       { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
15565       { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
15566     };
15567   tree node = build (lookup [is_post_p][(op_token - DECR_TK)], 
15568                      NULL_TREE, op1, NULL_TREE);
15569   TREE_SIDE_EFFECTS (node) = 1;
15570   /* Store the location of the operator, for better error report. The
15571      string of the operator will be rebuild based on the OP value. */
15572   EXPR_WFL_LINECOL (node) = op_location;
15573   return node;
15574 }     
15575
15576 /* Build an incomplete cast operator, based on the use of the
15577    CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
15578    set. java_complete_tree is trained to walk a CONVERT_EXPR even
15579    though its type is already set.  */
15580
15581 static tree
15582 build_cast (location, type, exp)
15583      int location;
15584      tree type, exp;
15585 {
15586   tree node = build1 (CONVERT_EXPR, type, exp);
15587   EXPR_WFL_LINECOL (node) = location;
15588   return node;
15589 }
15590
15591 /* Build an incomplete class reference operator.  */
15592 static tree
15593 build_incomplete_class_ref (location, class_name)
15594     int location;
15595     tree class_name;
15596 {
15597   tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
15598   EXPR_WFL_LINECOL (node) = location;
15599   return node;
15600 }
15601
15602 /* Complete an incomplete class reference operator.  */
15603 static tree
15604 patch_incomplete_class_ref (node)
15605     tree node;
15606 {
15607   tree type = TREE_OPERAND (node, 0);
15608   tree ref_type;
15609
15610   if (!(ref_type = resolve_type_during_patch (type)))
15611     return error_mark_node;
15612
15613   if (!flag_emit_class_files || JPRIMITIVE_TYPE_P (ref_type))
15614     return build_class_ref (ref_type);
15615
15616   /* If we're emitting class files and we have to deal with non
15617      primitive types, we invoke (and consider generating) the
15618      synthetic static method `class$'. */
15619   if (!TYPE_DOT_CLASS (current_class))
15620       build_dot_class_method (current_class);
15621   ref_type = 
15622     build_dot_class_method_invocation (DECL_NAME (TYPE_NAME (ref_type)));
15623   return java_complete_tree (ref_type);
15624 }
15625
15626 /* 15.14 Unary operators. We return error_mark_node in case of error,
15627    but preserve the type of NODE if the type is fixed.  */
15628
15629 static tree
15630 patch_unaryop (node, wfl_op)
15631      tree node;
15632      tree wfl_op;
15633 {
15634   tree op = TREE_OPERAND (node, 0);
15635   tree op_type = TREE_TYPE (op);
15636   tree prom_type = NULL_TREE, value, decl;
15637   int outer_field_flag = 0;
15638   int code = TREE_CODE (node);
15639   int error_found = 0;
15640
15641   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15642
15643   switch (code)
15644     {
15645       /* 15.13.2 Postfix Increment Operator ++ */
15646     case POSTINCREMENT_EXPR:
15647       /* 15.13.3 Postfix Increment Operator -- */
15648     case POSTDECREMENT_EXPR:
15649       /* 15.14.1 Prefix Increment Operator ++ */
15650     case PREINCREMENT_EXPR:
15651       /* 15.14.2 Prefix Decrement Operator -- */
15652     case PREDECREMENT_EXPR:
15653       op = decl = strip_out_static_field_access_decl (op);
15654       outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
15655       /* We might be trying to change an outer field accessed using
15656          access method. */
15657       if (outer_field_flag)
15658         {
15659           /* Retrieve the decl of the field we're trying to access. We
15660              do that by first retrieving the function we would call to
15661              access the field. It has been already verified that this
15662              field isn't final */
15663           if (flag_emit_class_files)
15664             decl = TREE_OPERAND (op, 0);
15665           else
15666             decl = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (op, 0), 0), 0);
15667           decl = DECL_FUNCTION_ACCESS_DECL (decl);
15668         }
15669       /* We really should have a JAVA_ARRAY_EXPR to avoid this */
15670       else if (!JDECL_P (decl) 
15671           && TREE_CODE (decl) != COMPONENT_REF
15672           && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
15673           && TREE_CODE (decl) != INDIRECT_REF
15674           && !(TREE_CODE (decl) == COMPOUND_EXPR
15675                && TREE_OPERAND (decl, 1)
15676                && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
15677         {
15678           tree lvalue;
15679           /* Before screaming, check that we're not in fact trying to
15680              increment a optimized static final access, in which case
15681              we issue an different error message. */
15682           if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
15683                 && resolve_expression_name (wfl_op, &lvalue)
15684                 && check_final_assignment (lvalue, wfl_op)))
15685             parse_error_context (wfl_operator, "Invalid argument to `%s'",
15686                                  operator_string (node));
15687           TREE_TYPE (node) = error_mark_node;
15688           error_found = 1;
15689         }
15690       
15691       if (check_final_assignment (op, wfl_op))
15692         error_found = 1;
15693
15694       /* From now on, we know that op if a variable and that it has a
15695          valid wfl. We use wfl_op to locate errors related to the
15696          ++/-- operand. */
15697       else if (!JNUMERIC_TYPE_P (op_type))
15698         {
15699           parse_error_context
15700             (wfl_op, "Invalid argument type `%s' to `%s'",
15701              lang_printable_name (op_type, 0), operator_string (node));
15702           TREE_TYPE (node) = error_mark_node;
15703           error_found = 1;
15704         }
15705       else
15706         {
15707           /* Before the addition, binary numeric promotion is performed on
15708              both operands, if really necessary */
15709           if (JINTEGRAL_TYPE_P (op_type))
15710             {
15711               value = build_int_2 (1, 0);
15712               TREE_TYPE (value) = TREE_TYPE (node) = op_type;
15713             }
15714           else
15715             {
15716               value = build_int_2 (1, 0);
15717               TREE_TYPE (node) = 
15718                 binary_numeric_promotion (op_type, 
15719                                           TREE_TYPE (value), &op, &value);
15720             }
15721
15722           /* We remember we might be accessing an outer field */
15723           if (outer_field_flag)
15724             {
15725               /* We re-generate an access to the field */
15726               value = build (PLUS_EXPR, TREE_TYPE (op), 
15727                              build_outer_field_access (wfl_op, decl), value);
15728                                                     
15729               /* And we patch the original access$() into a write 
15730                  with plus_op as a rhs */
15731               return outer_field_access_fix (node, op, value);
15732             }
15733
15734           /* And write back into the node. */
15735           TREE_OPERAND (node, 0) = op;
15736           TREE_OPERAND (node, 1) = value;
15737           /* Convert the overall back into its original type, if
15738              necessary, and return */
15739           if (JINTEGRAL_TYPE_P (op_type))
15740             return fold (node);
15741           else
15742             return fold (convert (op_type, node));
15743         }
15744       break;
15745
15746       /* 15.14.3 Unary Plus Operator + */
15747     case UNARY_PLUS_EXPR:
15748       /* 15.14.4 Unary Minus Operator - */
15749     case NEGATE_EXPR:
15750       if (!JNUMERIC_TYPE_P (op_type))
15751         {
15752           ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
15753           TREE_TYPE (node) = error_mark_node;
15754           error_found = 1;
15755         }
15756       /* Unary numeric promotion is performed on operand */
15757       else
15758         {
15759           op = do_unary_numeric_promotion (op);
15760           prom_type = TREE_TYPE (op);
15761           if (code == UNARY_PLUS_EXPR)
15762             return fold (op);
15763         }
15764       break;
15765
15766       /* 15.14.5 Bitwise Complement Operator ~ */
15767     case BIT_NOT_EXPR:
15768       if (!JINTEGRAL_TYPE_P (op_type))
15769         {
15770           ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
15771           TREE_TYPE (node) = error_mark_node;
15772           error_found = 1;
15773         }
15774       else
15775         {
15776           op = do_unary_numeric_promotion (op);
15777           prom_type = TREE_TYPE (op);
15778         }
15779       break;
15780
15781       /* 15.14.6 Logical Complement Operator ! */
15782     case TRUTH_NOT_EXPR:
15783       if (TREE_CODE (op_type) != BOOLEAN_TYPE)
15784         {
15785           ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
15786           /* But the type is known. We will report an error if further
15787              attempt of a assignment is made with this rhs */
15788           TREE_TYPE (node) = boolean_type_node;
15789           error_found = 1;
15790         }
15791       else
15792         prom_type = boolean_type_node;
15793       break;
15794
15795       /* 15.15 Cast Expression */
15796     case CONVERT_EXPR:
15797       value = patch_cast (node, wfl_operator);
15798       if (value == error_mark_node)
15799         {
15800           /* If this cast is part of an assignment, we tell the code
15801              that deals with it not to complain about a mismatch,
15802              because things have been cast, anyways */
15803           TREE_TYPE (node) = error_mark_node;
15804           error_found = 1;
15805         }
15806       else
15807         {
15808           value = fold (value);
15809           TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
15810           return value;
15811         }
15812       break;
15813     }
15814   
15815   if (error_found)
15816     return error_mark_node;
15817
15818   /* There are cases where node has been replaced by something else
15819      and we don't end up returning here: UNARY_PLUS_EXPR,
15820      CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
15821   TREE_OPERAND (node, 0) = fold (op);
15822   TREE_TYPE (node) = prom_type;
15823   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
15824   return fold (node);
15825 }
15826
15827 /* Generic type resolution that sometimes takes place during node
15828    patching. Returned the resolved type or generate an error
15829    message. Return the resolved type or NULL_TREE.  */
15830
15831 static tree
15832 resolve_type_during_patch (type)
15833      tree type;
15834 {
15835   if (unresolved_type_p (type, NULL))
15836     {
15837       tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
15838       if (!type_decl)
15839         {
15840           parse_error_context (type, 
15841                                "Class `%s' not found in type declaration",
15842                                IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
15843           return NULL_TREE;
15844         }
15845       else
15846         {
15847           CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
15848           return TREE_TYPE (type_decl);
15849         }
15850     }
15851   return type;
15852 }
15853 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
15854    found. Otherwise NODE or something meant to replace it is returned.  */
15855
15856 static tree
15857 patch_cast (node, wfl_operator)
15858      tree node;
15859      tree wfl_operator;
15860 {
15861   tree op = TREE_OPERAND (node, 0);
15862   tree op_type = TREE_TYPE (op);
15863   tree cast_type = TREE_TYPE (node);
15864   char *t1;
15865
15866   /* First resolve OP_TYPE if unresolved */
15867   if (!(cast_type = resolve_type_during_patch (cast_type)))
15868     return error_mark_node;
15869
15870   /* Check on cast that are proven correct at compile time */
15871   if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
15872     {
15873       /* Same type */
15874       if (cast_type == op_type)
15875         return node;
15876
15877       /* float and double type are converted to the original type main
15878          variant and then to the target type. */
15879       if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
15880         op = convert (integer_type_node, op);
15881
15882       /* Try widening/narowwing convertion. Potentially, things need
15883          to be worked out in gcc so we implement the extreme cases
15884          correctly. fold_convert() needs to be fixed. */
15885       return convert (cast_type, op);
15886     }
15887
15888   /* It's also valid to cast a boolean into a boolean */
15889   if (op_type == boolean_type_node && cast_type == boolean_type_node)
15890     return node;
15891
15892   /* null can be casted to references */
15893   if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
15894     return build_null_of_type (cast_type);
15895
15896   /* The remaining legal casts involve conversion between reference
15897      types. Check for their compile time correctness. */
15898   if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type) 
15899       && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
15900     {
15901       TREE_TYPE (node) = promote_type (cast_type);
15902       /* Now, the case can be determined correct at compile time if
15903          OP_TYPE can be converted into CAST_TYPE by assignment
15904          conversion (5.2) */
15905
15906       if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
15907         {
15908           TREE_SET_CODE (node, NOP_EXPR);
15909           return node;
15910         }
15911
15912       if (flag_emit_class_files)
15913         {
15914           TREE_SET_CODE (node, CONVERT_EXPR);
15915           return node;
15916         }
15917
15918       /* The cast requires a run-time check */
15919       return build (CALL_EXPR, promote_type (cast_type),
15920                     build_address_of (soft_checkcast_node),
15921                     tree_cons (NULL_TREE, build_class_ref (cast_type),
15922                                build_tree_list (NULL_TREE, op)),
15923                     NULL_TREE);
15924     }
15925
15926   /* Any other casts are proven incorrect at compile time */
15927   t1 = xstrdup (lang_printable_name (op_type, 0));
15928   parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
15929                        t1, lang_printable_name (cast_type, 0));
15930   free (t1);
15931   return error_mark_node;
15932 }
15933
15934 /* Build a null constant and give it the type TYPE.  */
15935
15936 static tree
15937 build_null_of_type (type)
15938      tree type;
15939 {
15940   tree node = build_int_2 (0, 0);
15941   TREE_TYPE (node) = promote_type (type);
15942   return node;
15943 }
15944
15945 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
15946    a list of indices. */
15947 static tree
15948 build_array_ref (location, array, index)
15949      int location;
15950      tree array, index;
15951 {
15952   tree node = build (ARRAY_REF, NULL_TREE, array, index);
15953   EXPR_WFL_LINECOL (node) = location;
15954   return node;
15955 }
15956
15957 /* 15.12 Array Access Expression */
15958
15959 static tree
15960 patch_array_ref (node)
15961      tree node;
15962 {
15963   tree array = TREE_OPERAND (node, 0);
15964   tree array_type  = TREE_TYPE (array);
15965   tree index = TREE_OPERAND (node, 1);
15966   tree index_type = TREE_TYPE (index);
15967   int error_found = 0;
15968
15969   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15970
15971   if (TREE_CODE (array_type) == POINTER_TYPE)
15972     array_type = TREE_TYPE (array_type);
15973
15974   /* The array reference must be an array */
15975   if (!TYPE_ARRAY_P (array_type))
15976     {
15977       parse_error_context 
15978         (wfl_operator,
15979          "`[]' can only be applied to arrays. It can't be applied to `%s'",
15980          lang_printable_name (array_type, 0));
15981       TREE_TYPE (node) = error_mark_node;
15982       error_found = 1;
15983     }
15984
15985   /* The array index undergoes unary numeric promotion. The promoted
15986      type must be int */
15987   index = do_unary_numeric_promotion (index);
15988   if (TREE_TYPE (index) != int_type_node)
15989     {
15990       if (valid_cast_to_p (index_type, int_type_node))
15991         parse_error_context (wfl_operator,
15992    "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
15993                              lang_printable_name (index_type, 0));
15994       else
15995         parse_error_context (wfl_operator,
15996           "Incompatible type for `[]'. Can't convert `%s' to `int'",
15997                              lang_printable_name (index_type, 0));
15998       TREE_TYPE (node) = error_mark_node;
15999       error_found = 1;
16000     }
16001
16002   if (error_found)
16003     return error_mark_node;
16004
16005   array_type = TYPE_ARRAY_ELEMENT (array_type);
16006
16007   if (flag_emit_class_files || flag_emit_xref)
16008     {
16009       TREE_OPERAND (node, 0) = array;
16010       TREE_OPERAND (node, 1) = index;
16011     }
16012   else
16013     {
16014       /* The save_expr is for correct evaluation order.  It would be cleaner
16015          to use force_evaluation_order (see comment there), but that is
16016          difficult when we also have to deal with bounds checking. */
16017       if (TREE_SIDE_EFFECTS (index))
16018         array = save_expr (array);
16019       node = build_java_arrayaccess (array, array_type, index);
16020       if (TREE_SIDE_EFFECTS (index))
16021         node = build (COMPOUND_EXPR, array_type, array, node);
16022     }
16023   TREE_TYPE (node) = array_type;
16024   return node;
16025 }
16026
16027 /* 15.9 Array Creation Expressions */
16028
16029 static tree
16030 build_newarray_node (type, dims, extra_dims)
16031      tree type;
16032      tree dims;
16033      int extra_dims;
16034 {
16035   tree node =
16036     build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims), 
16037            build_int_2 (extra_dims, 0));
16038   return node;
16039 }
16040
16041 static tree
16042 patch_newarray (node)
16043      tree node;
16044 {
16045   tree type = TREE_OPERAND (node, 0);
16046   tree dims = TREE_OPERAND (node, 1);
16047   tree cdim, array_type;
16048   int error_found = 0;
16049   int ndims = 0;
16050   int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
16051
16052   /* Dimension types are verified. It's better for the types to be
16053      verified in order. */
16054   for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
16055     {
16056       int dim_error = 0;
16057       tree dim = TREE_VALUE (cdim);
16058
16059       /* Dim might have been saved during its evaluation */
16060       dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
16061
16062       /* The type of each specified dimension must be an integral type. */
16063       if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
16064         dim_error = 1;
16065
16066       /* Each expression undergoes an unary numeric promotion (5.6.1) and the
16067          promoted type must be int. */
16068       else
16069         {
16070           dim = do_unary_numeric_promotion (dim);
16071           if (TREE_TYPE (dim) != int_type_node)
16072             dim_error = 1;
16073         }
16074
16075       /* Report errors on types here */
16076       if (dim_error)
16077         {
16078           parse_error_context 
16079             (TREE_PURPOSE (cdim), 
16080              "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'", 
16081              (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
16082               "Explicit cast needed to" : "Can't"),
16083              lang_printable_name (TREE_TYPE (dim), 0));
16084           error_found = 1;
16085         }
16086
16087       TREE_PURPOSE (cdim) = NULL_TREE;
16088     }
16089
16090   /* Resolve array base type if unresolved */
16091   if (!(type = resolve_type_during_patch (type)))
16092     error_found = 1;
16093
16094   if (error_found)
16095     {
16096       /* We don't want further evaluation of this bogus array creation
16097          operation */
16098       TREE_TYPE (node) = error_mark_node;
16099       return error_mark_node;
16100     }
16101
16102   /* Set array_type to the actual (promoted) array type of the result. */
16103   if (TREE_CODE (type) == RECORD_TYPE)
16104     type = build_pointer_type (type);
16105   while (--xdims >= 0)
16106     {
16107       type = promote_type (build_java_array_type (type, -1));
16108     }
16109   dims = nreverse (dims);
16110   array_type = type;
16111   for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
16112     {
16113       type = array_type;
16114       array_type
16115         = build_java_array_type (type,
16116                                  TREE_CODE (cdim) == INTEGER_CST
16117                                  ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim)
16118                                  : -1);
16119       array_type = promote_type (array_type);
16120     }
16121   dims = nreverse (dims);
16122
16123   /* The node is transformed into a function call. Things are done
16124      differently according to the number of dimensions. If the number
16125      of dimension is equal to 1, then the nature of the base type
16126      (primitive or not) matters. */
16127   if (ndims == 1)
16128     return build_new_array (type, TREE_VALUE (dims));
16129   
16130   /* Can't reuse what's already written in expr.c because it uses the
16131      JVM stack representation. Provide a build_multianewarray. FIXME */
16132   return build (CALL_EXPR, array_type,
16133                 build_address_of (soft_multianewarray_node),
16134                 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
16135                            tree_cons (NULL_TREE, 
16136                                       build_int_2 (ndims, 0), dims )),
16137                 NULL_TREE);
16138 }
16139
16140 /* 10.6 Array initializer.  */
16141
16142 /* Build a wfl for array element that don't have one, so we can
16143    pin-point errors.  */
16144
16145 static tree
16146 maybe_build_array_element_wfl (node)
16147      tree node;
16148 {
16149   if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
16150     return build_expr_wfl (NULL_TREE, ctxp->filename,
16151                            ctxp->elc.line, ctxp->elc.prev_col);
16152   else
16153     return NULL_TREE;
16154 }
16155
16156 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
16157    identification of initialized arrays easier to detect during walk
16158    and expansion.  */
16159
16160 static tree
16161 build_new_array_init (location, values)
16162      int location;
16163      tree values;
16164 {
16165   tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
16166   tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
16167   EXPR_WFL_LINECOL (to_return) = location;
16168   return to_return;
16169 }
16170
16171 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
16172    occurred.  Otherwise return NODE after having set its type
16173    appropriately.  */
16174
16175 static tree
16176 patch_new_array_init (type, node)
16177      tree type, node;
16178 {
16179   int error_seen = 0;
16180   tree current, element_type;
16181   HOST_WIDE_INT length;
16182   int all_constant = 1;
16183   tree init = TREE_OPERAND (node, 0);
16184
16185   if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
16186     {
16187       parse_error_context (node,
16188                            "Invalid array initializer for non-array type `%s'",
16189                            lang_printable_name (type, 1));
16190       return error_mark_node;
16191     }
16192   type = TREE_TYPE (type);
16193   element_type = TYPE_ARRAY_ELEMENT (type);
16194
16195   CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
16196
16197   for (length = 0, current = CONSTRUCTOR_ELTS (init);
16198        current;  length++, current = TREE_CHAIN (current))
16199     {
16200       tree elt = TREE_VALUE (current);
16201       if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
16202         {
16203           error_seen |= array_constructor_check_entry (element_type, current);
16204           elt = TREE_VALUE (current);
16205           /* When compiling to native code, STRING_CST is converted to
16206              INDIRECT_REF, but still with a TREE_CONSTANT flag. */
16207           if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
16208             all_constant = 0;
16209         }
16210       else
16211         {
16212           TREE_VALUE (current) = patch_new_array_init (element_type, elt);
16213           TREE_PURPOSE (current) = NULL_TREE;
16214           all_constant = 0;
16215         }
16216       if (elt && TREE_VALUE (elt) == error_mark_node)
16217         error_seen = 1;
16218     }
16219
16220   if (error_seen)
16221     return error_mark_node;
16222
16223   /* Create a new type. We can't reuse the one we have here by
16224      patching its dimension because it originally is of dimension -1
16225      hence reused by gcc. This would prevent triangular arrays. */
16226   type = build_java_array_type (element_type, length);
16227   TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
16228   TREE_TYPE (node) = promote_type (type);
16229   TREE_CONSTANT (init) = all_constant;
16230   TREE_CONSTANT (node) = all_constant;
16231   return node;
16232 }
16233
16234 /* Verify that one entry of the initializer element list can be
16235    assigned to the array base type. Report 1 if an error occurred, 0
16236    otherwise.  */
16237
16238 static int
16239 array_constructor_check_entry (type, entry)
16240      tree type, entry;
16241 {
16242   char *array_type_string = NULL;       /* For error reports */
16243   tree value, type_value, new_value, wfl_value, patched;
16244   int error_seen = 0;
16245
16246   new_value = NULL_TREE;
16247   wfl_value = TREE_VALUE (entry);
16248
16249   push_obstacks (&permanent_obstack, &permanent_obstack);
16250   value = java_complete_tree (TREE_VALUE (entry));
16251   /* patch_string return error_mark_node if arg is error_mark_node */
16252   if ((patched = patch_string (value)))
16253     value = patched;
16254   if (value == error_mark_node)
16255     return 1;
16256   
16257   type_value = TREE_TYPE (value);
16258   
16259   /* At anytime, try_builtin_assignconv can report a warning on
16260      constant overflow during narrowing. */
16261   SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
16262   new_value = try_builtin_assignconv (wfl_operator, type, value);
16263   if (!new_value && (new_value = try_reference_assignconv (type, value)))
16264     type_value = promote_type (type);
16265
16266   pop_obstacks ();
16267   /* Check and report errors */
16268   if (!new_value)
16269     {
16270       const char *msg = (!valid_cast_to_p (type_value, type) ?
16271                    "Can't" : "Explicit cast needed to");
16272       if (!array_type_string)
16273         array_type_string = xstrdup (lang_printable_name (type, 1));
16274       parse_error_context 
16275         (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
16276          msg, lang_printable_name (type_value, 1), array_type_string);
16277       error_seen = 1;
16278     }
16279   
16280   if (new_value)
16281     {
16282       new_value = maybe_build_primttype_type_ref (new_value, wfl_value);
16283       TREE_VALUE (entry) = new_value;
16284     }
16285
16286   if (array_type_string)
16287     free (array_type_string);
16288
16289   TREE_PURPOSE (entry) = NULL_TREE;
16290   return error_seen;
16291 }
16292
16293 static tree
16294 build_this (location)
16295      int location;
16296 {
16297   tree node = build_wfl_node (this_identifier_node);
16298   TREE_SET_CODE (node, THIS_EXPR);
16299   EXPR_WFL_LINECOL (node) = location;
16300   return node;
16301 }
16302
16303 /* 14.15 The return statement. It builds a modify expression that
16304    assigns the returned value to the RESULT_DECL that hold the value
16305    to be returned. */
16306
16307 static tree
16308 build_return (location, op)
16309      int location;
16310      tree op;
16311 {
16312   tree node = build1 (RETURN_EXPR, NULL_TREE, op);
16313   EXPR_WFL_LINECOL (node) = location;
16314   node = build_debugable_stmt (location, node);
16315   return node;
16316 }
16317
16318 static tree
16319 patch_return (node)
16320      tree node;
16321 {
16322   tree return_exp = TREE_OPERAND (node, 0);
16323   tree meth = current_function_decl;
16324   tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
16325   int error_found = 0;
16326
16327   TREE_TYPE (node) = error_mark_node;
16328   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16329
16330   /* It's invalid to have a return value within a function that is
16331      declared with the keyword void or that is a constructor */
16332   if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
16333     error_found = 1;
16334
16335   /* It's invalid to use a return statement in a static block */
16336   if (DECL_CLINIT_P (current_function_decl))
16337     error_found = 1;
16338
16339   /* It's invalid to have a no return value within a function that
16340      isn't declared with the keyword `void' */
16341   if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
16342     error_found = 2;
16343   
16344   if (in_instance_initializer)
16345     error_found = 1;
16346
16347   if (error_found)
16348     {
16349       if (in_instance_initializer)
16350         parse_error_context (wfl_operator,
16351                              "`return' inside instance initializer");
16352         
16353       else if (DECL_CLINIT_P (current_function_decl))
16354         parse_error_context (wfl_operator,
16355                              "`return' inside static initializer");
16356
16357       else if (!DECL_CONSTRUCTOR_P (meth))
16358         {
16359           char *t = xstrdup (lang_printable_name (mtype, 0));
16360           parse_error_context (wfl_operator, 
16361                                "`return' with%s value from `%s %s'",
16362                                (error_found == 1 ? "" : "out"), 
16363                                t, lang_printable_name (meth, 0));
16364           free (t);
16365         }
16366       else
16367         parse_error_context (wfl_operator, 
16368                              "`return' with value from constructor `%s'",
16369                              lang_printable_name (meth, 0));
16370       return error_mark_node;
16371     }
16372
16373   /* If we have a return_exp, build a modify expression and expand
16374      it. Note: at that point, the assignment is declared valid, but we
16375      may want to carry some more hacks */
16376   if (return_exp)
16377     {
16378       tree exp = java_complete_tree (return_exp);
16379       tree modify, patched;
16380
16381       /* If the function returned value and EXP are booleans, EXP has
16382       to be converted into the type of DECL_RESULT, which is integer
16383       (see complete_start_java_method) */
16384       if (TREE_TYPE (exp) == boolean_type_node &&
16385           TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
16386         exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
16387
16388       /* `null' can be assigned to a function returning a reference */
16389       if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
16390           exp == null_pointer_node)
16391         exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
16392
16393       if ((patched = patch_string (exp)))
16394         exp = patched;
16395       
16396       modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
16397       EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
16398       modify = java_complete_tree (modify);
16399
16400       if (modify != error_mark_node)
16401         {
16402           TREE_SIDE_EFFECTS (modify) = 1;
16403           TREE_OPERAND (node, 0) = modify;
16404         }
16405       else
16406         return error_mark_node;
16407     }
16408   TREE_TYPE (node) = void_type_node;
16409   TREE_SIDE_EFFECTS (node) = 1;
16410   return node;
16411 }
16412
16413 /* 14.8 The if Statement */
16414
16415 static tree
16416 build_if_else_statement (location, expression, if_body, else_body)
16417      int location;
16418      tree expression, if_body, else_body;
16419 {
16420   tree node;
16421   if (!else_body)
16422     else_body = empty_stmt_node;
16423   node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
16424   EXPR_WFL_LINECOL (node) = location;
16425   node = build_debugable_stmt (location, node);
16426   return node;
16427 }
16428
16429 static tree
16430 patch_if_else_statement (node)
16431      tree node;
16432 {
16433   tree expression = TREE_OPERAND (node, 0);
16434
16435   TREE_TYPE (node) = error_mark_node;
16436   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16437
16438   /* The type of expression must be boolean */
16439   if (TREE_TYPE (expression) != boolean_type_node
16440       && TREE_TYPE (expression) != promoted_boolean_type_node)
16441     {
16442       parse_error_context 
16443         (wfl_operator, 
16444          "Incompatible type for `if'. Can't convert `%s' to `boolean'", 
16445          lang_printable_name (TREE_TYPE (expression), 0));
16446       return error_mark_node;
16447     }
16448   
16449   TREE_TYPE (node) = void_type_node;
16450   TREE_SIDE_EFFECTS (node) = 1;
16451   CAN_COMPLETE_NORMALLY (node)
16452     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16453     | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
16454   return node;
16455 }
16456
16457 /* 14.6 Labeled Statements */
16458
16459 /* Action taken when a lableled statement is parsed. a new
16460    LABELED_BLOCK_EXPR is created. No statement is attached to the
16461    label, yet.  LABEL can be NULL_TREE for artificially-generated blocks. */
16462
16463 static tree
16464 build_labeled_block (location, label)
16465      int location;
16466      tree label;
16467 {
16468   tree label_name ;
16469   tree label_decl, node;
16470   if (label == NULL_TREE || label == continue_identifier_node)
16471     label_name = label;
16472   else
16473     {
16474       label_name = merge_qualified_name (label_id, label);
16475       /* Issue an error if we try to reuse a label that was previously
16476          declared */
16477       if (IDENTIFIER_LOCAL_VALUE (label_name))
16478         {
16479           EXPR_WFL_LINECOL (wfl_operator) = location;
16480           parse_error_context (wfl_operator,
16481             "Declaration of `%s' shadows a previous label declaration",
16482                                IDENTIFIER_POINTER (label));
16483           EXPR_WFL_LINECOL (wfl_operator) = 
16484             EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
16485           parse_error_context (wfl_operator,
16486             "This is the location of the previous declaration of label `%s'",
16487                                IDENTIFIER_POINTER (label));
16488           java_error_count--;
16489         }
16490     }
16491
16492   label_decl = create_label_decl (label_name);
16493   node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
16494   EXPR_WFL_LINECOL (node) = location;
16495   TREE_SIDE_EFFECTS (node) = 1;
16496   return node;
16497 }
16498
16499 /* A labeled statement LBE is attached a statement.  */
16500
16501 static tree
16502 finish_labeled_statement (lbe, statement)
16503      tree lbe;                  /* Labeled block expr */
16504      tree statement;
16505 {
16506   /* In anyways, tie the loop to its statement */
16507   LABELED_BLOCK_BODY (lbe) = statement;
16508   pop_labeled_block ();
16509   POP_LABELED_BLOCK ();
16510   return lbe;
16511 }
16512
16513 /* 14.10, 14.11, 14.12 Loop Statements */
16514
16515 /* Create an empty LOOP_EXPR and make it the last in the nested loop
16516    list. */
16517
16518 static tree
16519 build_new_loop (loop_body)
16520      tree loop_body;
16521 {
16522   tree loop =  build (LOOP_EXPR, NULL_TREE, loop_body);
16523   TREE_SIDE_EFFECTS (loop) = 1;
16524   PUSH_LOOP (loop);
16525   return loop;
16526 }
16527
16528 /* Create a loop body according to the following structure:
16529      COMPOUND_EXPR
16530        COMPOUND_EXPR            (loop main body)
16531          EXIT_EXPR              (this order is for while/for loops.
16532          LABELED_BLOCK_EXPR      the order is reversed for do loops)
16533            LABEL_DECL           (a continue occuring here branches at the 
16534            BODY                  end of this labeled block)
16535        INCREMENT                (if any)
16536
16537   REVERSED, if non zero, tells that the loop condition expr comes
16538   after the body, like in the do-while loop.
16539
16540   To obtain a loop, the loop body structure described above is
16541   encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
16542
16543    LABELED_BLOCK_EXPR
16544      LABEL_DECL                   (use this label to exit the loop)
16545      LOOP_EXPR
16546        <structure described above> */
16547
16548 static tree
16549 build_loop_body (location, condition, reversed)
16550      int location;
16551      tree condition;
16552      int reversed;
16553 {
16554   tree first, second, body;
16555
16556   condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
16557   EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
16558   condition = build_debugable_stmt (location, condition);
16559   TREE_SIDE_EFFECTS (condition) = 1;
16560
16561   body = build_labeled_block (0, continue_identifier_node);
16562   first = (reversed ? body : condition);
16563   second = (reversed ? condition : body);
16564   return 
16565     build (COMPOUND_EXPR, NULL_TREE, 
16566            build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
16567 }
16568
16569 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
16570    their order) on the current loop. Unlink the current loop from the
16571    loop list.  */
16572
16573 static tree
16574 finish_loop_body (location, condition, body, reversed)
16575      int location;
16576      tree condition, body;
16577      int reversed;
16578 {
16579   tree to_return = ctxp->current_loop;
16580   tree loop_body = LOOP_EXPR_BODY (to_return);
16581   if (condition)
16582     {
16583       tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
16584       /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
16585          The real EXIT_EXPR is one operand further. */
16586       EXPR_WFL_LINECOL (cnode) = location;
16587       /* This one is for accurate error reports */
16588       EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
16589       TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
16590     }
16591   LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
16592   POP_LOOP ();
16593   return to_return;
16594 }
16595
16596 /* Tailored version of finish_loop_body for FOR loops, when FOR
16597    loops feature the condition part */
16598
16599 static tree
16600 finish_for_loop (location, condition, update, body)
16601     int location;
16602     tree condition, update, body;
16603 {
16604   /* Put the condition and the loop body in place */
16605   tree loop = finish_loop_body (location, condition, body, 0);
16606   /* LOOP is the current loop which has been now popped of the loop
16607      stack. Install the update block */
16608   LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
16609   return loop;
16610 }
16611
16612 /* Try to find the loop a block might be related to. This comprises
16613    the case where the LOOP_EXPR is found as the second operand of a
16614    COMPOUND_EXPR, because the loop happens to have an initialization
16615    part, then expressed as the first operand of the COMPOUND_EXPR. If
16616    the search finds something, 1 is returned. Otherwise, 0 is
16617    returned. The search is assumed to start from a
16618    LABELED_BLOCK_EXPR's block.  */
16619
16620 static tree
16621 search_loop (statement)
16622     tree statement;
16623 {
16624   if (TREE_CODE (statement) == LOOP_EXPR)
16625     return statement;
16626
16627   if (TREE_CODE (statement) == BLOCK)
16628     statement = BLOCK_SUBBLOCKS (statement);
16629   else
16630     return NULL_TREE;
16631
16632   if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16633     while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16634       statement = TREE_OPERAND (statement, 1);
16635
16636   return (TREE_CODE (statement) == LOOP_EXPR
16637           && FOR_LOOP_P (statement) ? statement : NULL_TREE);
16638 }
16639
16640 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
16641    returned otherwise.  */
16642
16643 static int
16644 labeled_block_contains_loop_p (block, loop)
16645     tree block, loop;
16646 {
16647   if (!block)
16648     return 0;
16649
16650   if (LABELED_BLOCK_BODY (block) == loop)
16651     return 1;
16652
16653   if (FOR_LOOP_P (loop) && search_loop (LABELED_BLOCK_BODY (block)) == loop)
16654     return 1;
16655
16656   return 0;
16657 }
16658
16659 /* If the loop isn't surrounded by a labeled statement, create one and
16660    insert LOOP as its body.  */
16661
16662 static tree
16663 patch_loop_statement (loop)
16664      tree loop;
16665 {
16666   tree loop_label;
16667
16668   TREE_TYPE (loop) = void_type_node;
16669   if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
16670     return loop;
16671
16672   loop_label = build_labeled_block (0, NULL_TREE);
16673   /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
16674      that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
16675   LABELED_BLOCK_BODY (loop_label) = loop;
16676   PUSH_LABELED_BLOCK (loop_label);
16677   return loop_label;
16678 }
16679
16680 /* 14.13, 14.14: break and continue Statements */
16681
16682 /* Build a break or a continue statement. a null NAME indicates an
16683    unlabeled break/continue statement.  */
16684
16685 static tree
16686 build_bc_statement (location, is_break, name)
16687      int location, is_break;
16688      tree name;
16689 {
16690   tree break_continue, label_block_expr = NULL_TREE;
16691
16692   if (name)
16693     {
16694       if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE 
16695             (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
16696         /* Null means that we don't have a target for this named
16697            break/continue. In this case, we make the target to be the
16698            label name, so that the error can be reported accuratly in
16699            patch_bc_statement. */
16700         label_block_expr = EXPR_WFL_NODE (name);
16701     }
16702   /* Unlabeled break/continue will be handled during the
16703      break/continue patch operation */
16704   break_continue 
16705     = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
16706
16707   IS_BREAK_STMT_P (break_continue) = is_break;
16708   TREE_SIDE_EFFECTS (break_continue) = 1;
16709   EXPR_WFL_LINECOL (break_continue) = location;
16710   break_continue = build_debugable_stmt (location, break_continue);
16711   return break_continue;
16712 }
16713
16714 /* Verification of a break/continue statement. */
16715
16716 static tree
16717 patch_bc_statement (node)
16718      tree node;
16719 {
16720   tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
16721   tree labeled_block = ctxp->current_labeled_block;
16722   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16723  
16724   /* Having an identifier here means that the target is unknown. */
16725   if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
16726     {
16727       parse_error_context (wfl_operator, "No label definition found for `%s'",
16728                            IDENTIFIER_POINTER (bc_label));
16729       return error_mark_node;
16730     }
16731   if (! IS_BREAK_STMT_P (node))
16732     {
16733       /* It's a continue statement. */
16734       for (;; labeled_block = TREE_CHAIN (labeled_block))
16735         {
16736           if (labeled_block == NULL_TREE)
16737             {
16738               if (bc_label == NULL_TREE)
16739                 parse_error_context (wfl_operator,
16740                                      "`continue' must be in loop");
16741               else
16742                 parse_error_context 
16743                   (wfl_operator, "continue label `%s' does not name a loop",
16744                    IDENTIFIER_POINTER (bc_label));
16745               return error_mark_node;
16746             }
16747           if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
16748                == continue_identifier_node)
16749               && (bc_label == NULL_TREE
16750                   || TREE_CHAIN (labeled_block) == bc_label))
16751             {
16752               bc_label = labeled_block;
16753               break;
16754             }
16755         }
16756     }
16757   else if (!bc_label)
16758     { 
16759       for (;; labeled_block = TREE_CHAIN (labeled_block))
16760         {
16761           if (labeled_block == NULL_TREE)
16762             {
16763               parse_error_context (wfl_operator,
16764                                      "`break' must be in loop or switch");
16765               return error_mark_node;
16766             }
16767           target_stmt = LABELED_BLOCK_BODY (labeled_block);
16768           if (TREE_CODE (target_stmt) == SWITCH_EXPR
16769               || search_loop (target_stmt))
16770             {
16771               bc_label = labeled_block;
16772               break;
16773             }
16774         }
16775     }
16776
16777   EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
16778   CAN_COMPLETE_NORMALLY (bc_label) = 1;
16779
16780   /* Our break/continue don't return values. */
16781   TREE_TYPE (node) = void_type_node;
16782   /* Encapsulate the break within a compound statement so that it's
16783      expanded all the times by expand_expr (and not clobbered
16784      sometimes, like after a if statement) */
16785   node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
16786   TREE_SIDE_EFFECTS (node) = 1;
16787   return node;
16788 }
16789
16790 /* Process the exit expression belonging to a loop. Its type must be
16791    boolean.  */
16792
16793 static tree
16794 patch_exit_expr (node)
16795      tree node;
16796 {
16797   tree expression = TREE_OPERAND (node, 0);
16798   TREE_TYPE (node) = error_mark_node;
16799   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16800
16801   /* The type of expression must be boolean */
16802   if (TREE_TYPE (expression) != boolean_type_node)
16803     {
16804       parse_error_context 
16805         (wfl_operator, 
16806     "Incompatible type for loop conditional. Can't convert `%s' to `boolean'", 
16807          lang_printable_name (TREE_TYPE (expression), 0));
16808       return error_mark_node;
16809     }
16810   /* Now we know things are allright, invert the condition, fold and
16811      return */
16812   TREE_OPERAND (node, 0) = 
16813     fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
16814
16815   if (! integer_zerop (TREE_OPERAND (node, 0))
16816       && ctxp->current_loop != NULL_TREE
16817       && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
16818     CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
16819   if (! integer_onep (TREE_OPERAND (node, 0)))
16820     CAN_COMPLETE_NORMALLY (node) = 1;
16821
16822
16823   TREE_TYPE (node) = void_type_node;
16824   return node;
16825 }
16826
16827 /* 14.9 Switch statement */
16828
16829 static tree
16830 patch_switch_statement (node)
16831      tree node;
16832 {
16833   tree se = TREE_OPERAND (node, 0), se_type;
16834
16835   /* Complete the switch expression */
16836   se = TREE_OPERAND (node, 0) = java_complete_tree (se);
16837   se_type = TREE_TYPE (se);
16838   /* The type of the switch expression must be char, byte, short or
16839      int */
16840   if (!JINTEGRAL_TYPE_P (se_type))
16841     {
16842       EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16843       parse_error_context (wfl_operator,
16844           "Incompatible type for `switch'. Can't convert `%s' to `int'",
16845                            lang_printable_name (se_type, 0));
16846       /* This is what java_complete_tree will check */
16847       TREE_OPERAND (node, 0) = error_mark_node;
16848       return error_mark_node;
16849     }
16850
16851   TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
16852
16853   /* Ready to return */
16854   if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
16855     {
16856       TREE_TYPE (node) = error_mark_node;
16857       return error_mark_node;
16858     }
16859   TREE_TYPE (node) = void_type_node;
16860   TREE_SIDE_EFFECTS (node) = 1;
16861   CAN_COMPLETE_NORMALLY (node)
16862     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)) 
16863       || ! SWITCH_HAS_DEFAULT (node);
16864   return node;
16865 }
16866
16867 /* 14.18 The try/catch statements */
16868
16869 static tree
16870 build_try_statement (location, try_block, catches)
16871      int location;
16872      tree try_block, catches;
16873 {
16874   tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
16875   EXPR_WFL_LINECOL (node) = location;
16876   return node;
16877 }
16878
16879 static tree
16880 build_try_finally_statement (location, try_block, finally)
16881      int location;
16882      tree try_block, finally;
16883 {
16884   tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
16885   EXPR_WFL_LINECOL (node) = location;
16886   return node;
16887 }
16888
16889 static tree
16890 patch_try_statement (node)
16891      tree node;
16892 {
16893   int error_found = 0;
16894   tree try = TREE_OPERAND (node, 0);
16895   /* Exception handlers are considered in left to right order */
16896   tree catch = nreverse (TREE_OPERAND (node, 1));
16897   tree current, caught_type_list = NULL_TREE;
16898
16899   /* Check catch clauses, if any. Every time we find an error, we try
16900      to process the next catch clause. We process the catch clause before
16901      the try block so that when processing the try block we can check thrown
16902      exceptions againts the caught type list. */
16903   for (current = catch; current; current = TREE_CHAIN (current))
16904     {
16905       tree carg_decl, carg_type;
16906       tree sub_current, catch_block, catch_clause;
16907       int unreachable;
16908
16909       /* At this point, the structure of the catch clause is
16910            CATCH_EXPR           (catch node)
16911              BLOCK              (with the decl of the parameter)
16912                COMPOUND_EXPR
16913                  MODIFY_EXPR   (assignment of the catch parameter)
16914                  BLOCK          (catch clause block)
16915        */
16916       catch_clause = TREE_OPERAND (current, 0);
16917       carg_decl = BLOCK_EXPR_DECLS (catch_clause);
16918       carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
16919
16920       /* Catch clauses can't have more than one parameter declared,
16921          but it's already enforced by the grammar. Make sure that the
16922          only parameter of the clause statement in of class Throwable
16923          or a subclass of Throwable, but that was done earlier. The
16924          catch clause parameter type has also been resolved. */
16925       
16926       /* Just make sure that the catch clause parameter type inherits
16927          from java.lang.Throwable */
16928       if (!inherits_from_p (carg_type, throwable_type_node))
16929         {
16930           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16931           parse_error_context (wfl_operator,
16932                                "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
16933                                lang_printable_name (carg_type, 0));
16934           error_found = 1;
16935           continue;
16936         }
16937       
16938       /* Partial check for unreachable catch statement: The catch
16939          clause is reachable iff is no earlier catch block A in
16940          the try statement such that the type of the catch
16941          clause's parameter is the same as or a subclass of the
16942          type of A's parameter */
16943       unreachable = 0;
16944       for (sub_current = catch;
16945            sub_current != current; sub_current = TREE_CHAIN (sub_current))
16946         {
16947           tree sub_catch_clause, decl;
16948           sub_catch_clause = TREE_OPERAND (sub_current, 0);
16949           decl = BLOCK_EXPR_DECLS (sub_catch_clause);
16950
16951           if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
16952             {
16953               EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16954               parse_error_context 
16955                 (wfl_operator,
16956                  "`catch' not reached because of the catch clause at line %d",
16957                  EXPR_WFL_LINENO (sub_current));
16958               unreachable = error_found = 1;
16959               break;
16960             }
16961         }
16962       /* Complete the catch clause block */
16963       catch_block = java_complete_tree (TREE_OPERAND (current, 0));
16964       if (catch_block == error_mark_node)
16965         {
16966           error_found = 1;
16967           continue;
16968         }
16969       if (CAN_COMPLETE_NORMALLY (catch_block))
16970         CAN_COMPLETE_NORMALLY (node) = 1;
16971       TREE_OPERAND (current, 0) = catch_block;
16972
16973       if (unreachable)
16974         continue;
16975
16976       /* Things to do here: the exception must be thrown */
16977
16978       /* Link this type to the caught type list */
16979       caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
16980     }
16981
16982   PUSH_EXCEPTIONS (caught_type_list);
16983   if ((try = java_complete_tree (try)) == error_mark_node)
16984     error_found = 1;
16985   if (CAN_COMPLETE_NORMALLY (try))
16986     CAN_COMPLETE_NORMALLY (node) = 1;
16987   POP_EXCEPTIONS ();
16988
16989   /* Verification ends here */
16990   if (error_found) 
16991     return error_mark_node;
16992
16993   TREE_OPERAND (node, 0) = try;
16994   TREE_OPERAND (node, 1) = catch;
16995   TREE_TYPE (node) = void_type_node;
16996   return node;
16997 }
16998
16999 /* 14.17 The synchronized Statement */
17000
17001 static tree
17002 patch_synchronized_statement (node, wfl_op1)
17003     tree node, wfl_op1;
17004 {
17005   tree expr = java_complete_tree (TREE_OPERAND (node, 0));
17006   tree block = TREE_OPERAND (node, 1);
17007
17008   tree enter, exit, expr_decl, assignment;
17009
17010   if (expr == error_mark_node)
17011     {
17012       block = java_complete_tree (block);
17013       return expr;
17014     }
17015
17016   /* The TYPE of expr must be a reference type */
17017   if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
17018     {
17019       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17020       parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
17021                            lang_printable_name (TREE_TYPE (expr), 0));
17022       return error_mark_node;
17023     }
17024
17025   if (flag_emit_xref)
17026     {
17027       TREE_OPERAND (node, 0) = expr;
17028       TREE_OPERAND (node, 1) = java_complete_tree (block);
17029       CAN_COMPLETE_NORMALLY (node) = 1;
17030       return node;
17031     }
17032
17033   /* Generate a try-finally for the synchronized statement, except
17034      that the handler that catches all throw exception calls
17035      _Jv_MonitorExit and then rethrow the exception.
17036      The synchronized statement is then implemented as:
17037      TRY 
17038        {
17039          _Jv_MonitorEnter (expression)
17040          synchronized_block
17041          _Jv_MonitorExit (expression)
17042        }
17043      CATCH_ALL
17044        {
17045          e = _Jv_exception_info ();
17046          _Jv_MonitorExit (expression)
17047          Throw (e);
17048        } */
17049
17050   expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
17051   BUILD_MONITOR_ENTER (enter, expr_decl);
17052   BUILD_MONITOR_EXIT (exit, expr_decl);
17053   CAN_COMPLETE_NORMALLY (enter) = 1;
17054   CAN_COMPLETE_NORMALLY (exit) = 1;
17055   assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
17056   TREE_SIDE_EFFECTS (assignment) = 1;
17057   node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
17058                  build (COMPOUND_EXPR, NULL_TREE,
17059                         build (WITH_CLEANUP_EXPR, NULL_TREE,
17060                                build (COMPOUND_EXPR, NULL_TREE,
17061                                       assignment, enter),
17062                                NULL_TREE, exit),
17063                         block));
17064   node = build_expr_block (node, expr_decl);
17065
17066   return java_complete_tree (node);
17067 }
17068
17069 /* 14.16 The throw Statement */
17070
17071 static tree
17072 patch_throw_statement (node, wfl_op1)
17073     tree node, wfl_op1;
17074 {
17075   tree expr = TREE_OPERAND (node, 0);
17076   tree type = TREE_TYPE (expr);
17077   int unchecked_ok = 0, tryblock_throws_ok = 0;
17078
17079   /* Thrown expression must be assignable to java.lang.Throwable */
17080   if (!try_reference_assignconv (throwable_type_node, expr))
17081     {
17082       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17083       parse_error_context (wfl_operator,
17084     "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
17085                            lang_printable_name (type, 0));
17086       /* If the thrown expression was a reference, we further the
17087          compile-time check. */
17088       if (!JREFERENCE_TYPE_P (type))
17089         return error_mark_node;
17090     }
17091
17092   /* At least one of the following must be true */
17093
17094   /* The type of the throw expression is a not checked exception,
17095      i.e. is a unchecked expression. */
17096   unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
17097
17098   SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17099   /* An instance can't throw a checked excetion unless that exception
17100      is explicitely declared in the `throws' clause of each
17101      constructor. This doesn't apply to anonymous classes, since they
17102      don't have declared constructors. */
17103   if (!unchecked_ok 
17104       && in_instance_initializer && !ANONYMOUS_CLASS_P (current_class))
17105     {
17106       tree current;
17107       for (current = TYPE_METHODS (current_class); current; 
17108            current = TREE_CHAIN (current))
17109         if (DECL_CONSTRUCTOR_P (current) 
17110             && !check_thrown_exceptions_do (TREE_TYPE (expr)))
17111           {
17112             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)", 
17113                                  lang_printable_name (TREE_TYPE (expr), 0));
17114             return error_mark_node;
17115           }
17116     }
17117
17118   /* Throw is contained in a try statement and at least one catch
17119      clause can receive the thrown expression or the current method is
17120      declared to throw such an exception. Or, the throw statement is
17121      contained in a method or constructor declaration and the type of
17122      the Expression is assignable to at least one type listed in the
17123      throws clause the declaration. */
17124   if (!unchecked_ok)
17125     tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
17126   if (!(unchecked_ok || tryblock_throws_ok))
17127     {
17128       /* If there is a surrounding try block that has no matching
17129          clatch clause, report it first. A surrounding try block exits
17130          only if there is something after the list of checked
17131          exception thrown by the current function (if any). */
17132       if (IN_TRY_BLOCK_P ())
17133         parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
17134                              lang_printable_name (type, 0));
17135       /* If we have no surrounding try statement and the method doesn't have
17136          any throws, report it now. FIXME */
17137
17138       /* We report that the exception can't be throw from a try block
17139          in all circumstances but when the `throw' is inside a static
17140          block. */
17141       else if (!EXCEPTIONS_P (currently_caught_type_list) 
17142                && !tryblock_throws_ok)
17143         {
17144           if (DECL_CLINIT_P (current_function_decl))
17145             parse_error_context (wfl_operator,
17146                    "Checked exception `%s' can't be thrown in initializer",
17147                                  lang_printable_name (type, 0));
17148           else
17149             parse_error_context (wfl_operator,
17150                    "Checked exception `%s' isn't thrown from a `try' block", 
17151                                  lang_printable_name (type, 0));
17152         }
17153       /* Otherwise, the current method doesn't have the appropriate
17154          throws declaration */
17155       else
17156         parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)", 
17157                              lang_printable_name (type, 0));
17158       return error_mark_node;
17159     }
17160
17161   if (! flag_emit_class_files && ! flag_emit_xref)
17162     BUILD_THROW (node, expr);
17163
17164   /* If doing xrefs, keep the location where the `throw' was seen. */
17165   if (flag_emit_xref)
17166     EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
17167   return node;
17168 }
17169
17170 /* Check that exception said to be thrown by method DECL can be
17171    effectively caught from where DECL is invoked.  */
17172
17173 static void
17174 check_thrown_exceptions (location, decl)
17175      int location;
17176      tree decl;
17177 {
17178   tree throws;
17179   /* For all the unchecked exceptions thrown by DECL */
17180   for (throws = DECL_FUNCTION_THROWS (decl); throws; 
17181        throws = TREE_CHAIN (throws)) 
17182     if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
17183       {
17184 #if 1
17185         /* Temporary hack to suppresses errors about cloning arrays. FIXME */
17186         if (DECL_NAME (decl) == get_identifier ("clone"))
17187           continue;
17188 #endif
17189         EXPR_WFL_LINECOL (wfl_operator) = location;
17190         if (DECL_FINIT_P (current_function_decl))
17191           parse_error_context
17192             (wfl_operator, "Exception `%s' can't be thrown in initializer",
17193              lang_printable_name (TREE_VALUE (throws), 0));
17194         else 
17195           {
17196             parse_error_context 
17197               (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'", 
17198                lang_printable_name (TREE_VALUE (throws), 0),
17199                (DECL_INIT_P (current_function_decl) ?
17200                 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
17201                 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
17202           }
17203       }
17204 }
17205
17206 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
17207    try-catch blocks, OR is listed in the `throws' clause of the
17208    current method.  */
17209
17210 static int
17211 check_thrown_exceptions_do (exception)
17212      tree exception;
17213 {
17214   tree list = currently_caught_type_list;
17215   resolve_and_layout (exception, NULL_TREE);
17216   /* First, all the nested try-catch-finally at that stage. The
17217      last element contains `throws' clause exceptions, if any. */
17218   if (IS_UNCHECKED_EXCEPTION_P (exception))
17219     return 1;
17220   while (list)
17221     {
17222       tree caught;
17223       for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
17224         if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
17225           return 1;
17226       list = TREE_CHAIN (list);
17227     }
17228   return 0;
17229 }
17230
17231 static void
17232 purge_unchecked_exceptions (mdecl)
17233      tree mdecl;
17234 {
17235   tree throws = DECL_FUNCTION_THROWS (mdecl);
17236   tree new = NULL_TREE;
17237
17238   while (throws)
17239     {
17240       tree next = TREE_CHAIN (throws);
17241       if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
17242         {
17243           TREE_CHAIN (throws) = new;
17244           new = throws;
17245         }
17246       throws = next;
17247     }
17248   /* List is inverted here, but it doesn't matter */
17249   DECL_FUNCTION_THROWS (mdecl) = new;
17250 }
17251
17252 /* 15.24 Conditional Operator ?: */
17253
17254 static tree
17255 patch_conditional_expr (node, wfl_cond, wfl_op1)
17256      tree node, wfl_cond, wfl_op1;
17257 {
17258   tree cond = TREE_OPERAND (node, 0);
17259   tree op1 = TREE_OPERAND (node, 1);
17260   tree op2 = TREE_OPERAND (node, 2);
17261   tree resulting_type = NULL_TREE;
17262   tree t1, t2, patched;
17263   int error_found = 0;
17264
17265   /* Operands of ?: might be StringBuffers crafted as a result of a
17266      string concatenation. Obtain a descent operand here.  */
17267   if ((patched = patch_string (op1)))
17268     TREE_OPERAND (node, 1) = op1 = patched;
17269   if ((patched = patch_string (op2)))
17270     TREE_OPERAND (node, 2) = op2 = patched;
17271
17272   t1 = TREE_TYPE (op1);
17273   t2 = TREE_TYPE (op2);
17274
17275   /* The first expression must be a boolean */
17276   if (TREE_TYPE (cond) != boolean_type_node)
17277     {
17278       SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
17279       parse_error_context (wfl_operator,
17280                "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
17281                            lang_printable_name (TREE_TYPE (cond), 0));
17282       error_found = 1;
17283     }
17284
17285   /* Second and third can be numeric, boolean (i.e. primitive),
17286      references or null. Anything else results in an error */
17287   if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
17288         || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node) 
17289             && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
17290         || (t1 == boolean_type_node && t2 == boolean_type_node)))
17291     error_found = 1;
17292
17293   /* Determine the type of the conditional expression. Same types are
17294      easy to deal with */
17295   else if (t1 == t2)
17296     resulting_type = t1;
17297
17298   /* There are different rules for numeric types */
17299   else if (JNUMERIC_TYPE_P (t1))
17300     {
17301       /* if byte/short found, the resulting type is short */
17302       if ((t1 == byte_type_node && t2 == short_type_node)
17303           || (t1 == short_type_node && t2 == byte_type_node))
17304         resulting_type = short_type_node;
17305
17306       /* If t1 is a constant int and t2 is of type byte, short or char
17307          and t1's value fits in t2, then the resulting type is t2 */
17308       else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
17309           && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
17310         resulting_type = t2;
17311
17312       /* If t2 is a constant int and t1 is of type byte, short or char
17313          and t2's value fits in t1, then the resulting type is t1 */
17314       else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
17315           && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
17316         resulting_type = t1;
17317
17318       /* Otherwise, binary numeric promotion is applied and the
17319          resulting type is the promoted type of operand 1 and 2 */
17320       else 
17321         resulting_type = binary_numeric_promotion (t1, t2, 
17322                                                    &TREE_OPERAND (node, 1), 
17323                                                    &TREE_OPERAND (node, 2));
17324     }
17325
17326   /* Cases of a reference and a null type */
17327   else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
17328     resulting_type = t1;
17329
17330   else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
17331     resulting_type = t2;
17332
17333   /* Last case: different reference types. If a type can be converted
17334      into the other one by assignment conversion, the latter
17335      determines the type of the expression */
17336   else if ((resulting_type = try_reference_assignconv (t1, op2)))
17337     resulting_type = promote_type (t1);
17338
17339   else if ((resulting_type = try_reference_assignconv (t2, op1)))
17340     resulting_type = promote_type (t2);
17341
17342   /* If we don't have any resulting type, we're in trouble */
17343   if (!resulting_type)
17344     {
17345       char *t = xstrdup (lang_printable_name (t1, 0));
17346       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17347       parse_error_context (wfl_operator,
17348                  "Incompatible type for `?:'. Can't convert `%s' to `%s'",
17349                            t, lang_printable_name (t2, 0));
17350       free (t);
17351       error_found = 1;
17352     }
17353
17354   if (error_found)
17355     {
17356       TREE_TYPE (node) = error_mark_node;
17357       return error_mark_node;
17358     }
17359
17360   TREE_TYPE (node) = resulting_type;
17361   TREE_SET_CODE (node, COND_EXPR);
17362   CAN_COMPLETE_NORMALLY (node) = 1;
17363   return node;
17364 }
17365
17366 /* Try to constant fold NODE.
17367    If NODE is not a constant expression, return NULL_EXPR.
17368    CONTEXT is a static final VAR_DECL whose initializer we are folding. */
17369
17370 static tree
17371 fold_constant_for_init (node, context)
17372      tree node;
17373      tree context;
17374 {
17375   tree op0, op1, val;
17376   enum tree_code code = TREE_CODE (node);
17377
17378   if (code == STRING_CST)
17379     return node;
17380
17381   if (code == INTEGER_CST || code == REAL_CST)
17382     return convert (TREE_TYPE (context), node);
17383
17384   switch (code)
17385     {
17386     case PLUS_EXPR:
17387     case MINUS_EXPR:
17388     case MULT_EXPR:
17389     case TRUNC_MOD_EXPR:
17390     case RDIV_EXPR:
17391     case LSHIFT_EXPR:
17392     case RSHIFT_EXPR:
17393     case URSHIFT_EXPR:
17394     case BIT_AND_EXPR:
17395     case BIT_XOR_EXPR:
17396     case BIT_IOR_EXPR:
17397     case TRUTH_ANDIF_EXPR:
17398     case TRUTH_ORIF_EXPR:
17399     case EQ_EXPR: 
17400     case NE_EXPR:
17401     case GT_EXPR:
17402     case GE_EXPR:
17403     case LT_EXPR:
17404     case LE_EXPR:
17405       op0 = TREE_OPERAND (node, 0);
17406       op1 = TREE_OPERAND (node, 1);
17407       val = fold_constant_for_init (op0, context);
17408       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17409         return NULL_TREE;
17410       TREE_OPERAND (node, 0) = val;
17411       val = fold_constant_for_init (op1, context);
17412       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17413         return NULL_TREE;
17414       TREE_OPERAND (node, 1) = val;
17415       return patch_binop (node, op0, op1);
17416
17417     case UNARY_PLUS_EXPR:
17418     case NEGATE_EXPR:
17419     case TRUTH_NOT_EXPR:
17420     case BIT_NOT_EXPR:
17421     case CONVERT_EXPR:
17422       op0 = TREE_OPERAND (node, 0);
17423       val = fold_constant_for_init (op0, context);
17424       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17425         return NULL_TREE;
17426       TREE_OPERAND (node, 0) = val;
17427       return patch_unaryop (node, op0);
17428       break;
17429
17430     case COND_EXPR:
17431       val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
17432       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17433         return NULL_TREE;
17434       TREE_OPERAND (node, 0) = val;
17435       val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
17436       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17437         return NULL_TREE;
17438       TREE_OPERAND (node, 1) = val;
17439       val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
17440       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17441         return NULL_TREE;
17442       TREE_OPERAND (node, 2) = val;
17443       return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
17444         : TREE_OPERAND (node, 2);
17445
17446     case VAR_DECL:
17447     case FIELD_DECL:
17448       if (! FIELD_FINAL (node)
17449           || DECL_INITIAL (node) == NULL_TREE)
17450         return NULL_TREE;
17451       val = DECL_INITIAL (node);
17452       /* Guard against infinite recursion. */
17453       DECL_INITIAL (node) = NULL_TREE;
17454       val = fold_constant_for_init (val, node);
17455       DECL_INITIAL (node) = val;
17456       return val;
17457
17458     case EXPR_WITH_FILE_LOCATION:
17459       /* Compare java_complete_tree and resolve_expression_name. */
17460       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
17461           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
17462         {
17463           tree name = EXPR_WFL_NODE (node);
17464           tree decl;
17465           if (PRIMARY_P (node))
17466             return NULL_TREE;
17467           else if (! QUALIFIED_P (name))
17468             {
17469               decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
17470               if (decl == NULL_TREE 
17471                   || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
17472                 return NULL_TREE;
17473               return fold_constant_for_init (decl, decl);
17474             }
17475           else
17476             {
17477               /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
17478               qualify_ambiguous_name (node);
17479               if (resolve_field_access (node, &decl, NULL)
17480                   && decl != NULL_TREE)
17481                 return fold_constant_for_init (decl, decl);
17482               return NULL_TREE;
17483             }
17484         }
17485       else
17486         {
17487           op0 = TREE_OPERAND (node, 0);
17488           val = fold_constant_for_init (op0, context);
17489           if (val == NULL_TREE || ! TREE_CONSTANT (val))
17490             return NULL_TREE;
17491           TREE_OPERAND (node, 0) = val;
17492           return val;
17493         }
17494
17495 #ifdef USE_COMPONENT_REF
17496     case IDENTIFIER:
17497     case COMPONENT_REF:
17498       ?;
17499 #endif
17500
17501     default:
17502       return NULL_TREE;
17503     }
17504 }
17505
17506 #ifdef USE_COMPONENT_REF
17507 /* Context is 'T' for TypeName, 'P' for PackageName,
17508    'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
17509
17510 tree
17511 resolve_simple_name (name, context)
17512      tree name;
17513      int context;
17514 {
17515 }
17516
17517 tree
17518 resolve_qualified_name (name, context)
17519      tree name;
17520      int context;
17521 {
17522 }
17523 #endif