OSDN Git Service

2000-06-25 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 void find_in_imports PARAMS ((tree));
178 static int check_pkg_class_access PARAMS ((tree, tree));
179 static void register_package PARAMS ((tree));
180 static tree resolve_package PARAMS ((tree, tree *));
181 static tree lookup_package_type PARAMS ((const char *, int));
182 static tree lookup_package_type_and_set_next PARAMS ((const char *, int, tree *));
183 static tree resolve_class PARAMS ((tree, tree, tree, tree));
184 static void declare_local_variables PARAMS ((int, tree, tree));
185 static void source_start_java_method PARAMS ((tree));
186 static void source_end_java_method PARAMS ((void));
187 static void expand_start_java_method PARAMS ((tree));
188 static tree find_name_in_single_imports PARAMS ((tree));
189 static void check_abstract_method_header PARAMS ((tree));
190 static tree lookup_java_interface_method2 PARAMS ((tree, tree));
191 static tree resolve_expression_name PARAMS ((tree, tree *));
192 static tree maybe_create_class_interface_decl PARAMS ((tree, tree, tree, tree));
193 static int check_class_interface_creation PARAMS ((int, int, tree, 
194                                                   tree, tree, tree));
195 static tree patch_method_invocation PARAMS ((tree, tree, tree, 
196                                             int *, tree *));
197 static int breakdown_qualified PARAMS ((tree *, tree *, tree));
198 static tree resolve_and_layout PARAMS ((tree, tree));
199 static tree qualify_and_find PARAMS ((tree, tree, tree));
200 static tree resolve_no_layout PARAMS ((tree, tree));
201 static int invocation_mode PARAMS ((tree, int));
202 static tree find_applicable_accessible_methods_list PARAMS ((int, tree, 
203                                                             tree, tree));
204 static void search_applicable_methods_list PARAMS ((int, tree, tree, tree, 
205                                                    tree *, tree *));
206 static tree find_most_specific_methods_list PARAMS ((tree));
207 static int argument_types_convertible PARAMS ((tree, tree));
208 static tree patch_invoke PARAMS ((tree, tree, tree));
209 static int maybe_use_access_method PARAMS ((int, tree *, tree *));
210 static tree lookup_method_invoke PARAMS ((int, tree, tree, tree, tree));
211 static tree register_incomplete_type PARAMS ((int, tree, tree, tree));
212 static tree obtain_incomplete_type PARAMS ((tree));
213 static tree java_complete_lhs PARAMS ((tree));
214 static tree java_complete_tree PARAMS ((tree));
215 static tree maybe_generate_pre_expand_clinit PARAMS ((tree));
216 static int maybe_yank_clinit PARAMS ((tree));
217 static void java_complete_expand_method PARAMS ((tree));
218 static int  unresolved_type_p PARAMS ((tree, tree *));
219 static void create_jdep_list PARAMS ((struct parser_ctxt *));
220 static tree build_expr_block PARAMS ((tree, tree));
221 static tree enter_block PARAMS ((void));
222 static tree enter_a_block PARAMS ((tree));
223 static tree exit_block PARAMS ((void));
224 static tree lookup_name_in_blocks PARAMS ((tree));
225 static void maybe_absorb_scoping_blocks PARAMS ((void));
226 static tree build_method_invocation PARAMS ((tree, tree));
227 static tree build_new_invocation PARAMS ((tree, tree));
228 static tree build_assignment PARAMS ((int, int, tree, tree));
229 static tree build_binop PARAMS ((enum tree_code, int, tree, tree));
230 static int check_final_assignment PARAMS ((tree ,tree));
231 static tree patch_assignment PARAMS ((tree, tree, tree ));
232 static tree patch_binop PARAMS ((tree, tree, tree));
233 static tree build_unaryop PARAMS ((int, int, tree));
234 static tree build_incdec PARAMS ((int, int, tree, int));
235 static tree patch_unaryop PARAMS ((tree, tree));
236 static tree build_cast PARAMS ((int, tree, tree));
237 static tree build_null_of_type PARAMS ((tree));
238 static tree patch_cast PARAMS ((tree, tree));
239 static int valid_ref_assignconv_cast_p PARAMS ((tree, tree, int));
240 static int valid_builtin_assignconv_identity_widening_p PARAMS ((tree, tree));
241 static int valid_cast_to_p PARAMS ((tree, tree));
242 static int valid_method_invocation_conversion_p PARAMS ((tree, tree));
243 static tree try_builtin_assignconv PARAMS ((tree, tree, tree));
244 static tree try_reference_assignconv PARAMS ((tree, tree));
245 static tree build_unresolved_array_type PARAMS ((tree));
246 static tree build_array_from_name PARAMS ((tree, tree, tree, tree *));
247 static tree build_array_ref PARAMS ((int, tree, tree));
248 static tree patch_array_ref PARAMS ((tree));
249 static tree make_qualified_name PARAMS ((tree, tree, int));
250 static tree merge_qualified_name PARAMS ((tree, tree));
251 static tree make_qualified_primary PARAMS ((tree, tree, int));
252 static int resolve_qualified_expression_name PARAMS ((tree, tree *, 
253                                                      tree *, tree *));
254 static void qualify_ambiguous_name PARAMS ((tree));
255 static tree resolve_field_access PARAMS ((tree, tree *, tree *));
256 static tree build_newarray_node PARAMS ((tree, tree, int));
257 static tree patch_newarray PARAMS ((tree));
258 static tree resolve_type_during_patch PARAMS ((tree));
259 static tree build_this PARAMS ((int));
260 static tree build_wfl_wrap PARAMS ((tree, int));
261 static tree build_return PARAMS ((int, tree));
262 static tree patch_return PARAMS ((tree));
263 static tree maybe_access_field PARAMS ((tree, tree, tree));
264 static int complete_function_arguments PARAMS ((tree));
265 static int check_for_static_method_reference PARAMS ((tree, tree, tree, 
266                                                       tree, tree));
267 static int not_accessible_p PARAMS ((tree, tree, int));
268 static void check_deprecation PARAMS ((tree, tree));
269 static int class_in_current_package PARAMS ((tree));
270 static tree build_if_else_statement PARAMS ((int, tree, tree, tree));
271 static tree patch_if_else_statement PARAMS ((tree));
272 static tree add_stmt_to_compound PARAMS ((tree, tree, tree));
273 static tree add_stmt_to_block PARAMS ((tree, tree, tree));
274 static tree patch_exit_expr PARAMS ((tree));
275 static tree build_labeled_block PARAMS ((int, tree));
276 static tree finish_labeled_statement PARAMS ((tree, tree));
277 static tree build_bc_statement PARAMS ((int, int, tree));
278 static tree patch_bc_statement PARAMS ((tree));
279 static tree patch_loop_statement PARAMS ((tree));
280 static tree build_new_loop PARAMS ((tree));
281 static tree build_loop_body PARAMS ((int, tree, int));
282 static tree finish_loop_body PARAMS ((int, tree, tree, int));
283 static tree build_debugable_stmt PARAMS ((int, tree));
284 static tree finish_for_loop PARAMS ((int, tree, tree, tree));
285 static tree patch_switch_statement PARAMS ((tree));
286 static tree string_constant_concatenation PARAMS ((tree, tree));
287 static tree build_string_concatenation PARAMS ((tree, tree));
288 static tree patch_string_cst PARAMS ((tree));
289 static tree patch_string PARAMS ((tree));
290 static tree build_try_statement PARAMS ((int, tree, tree));
291 static tree build_try_finally_statement PARAMS ((int, tree, tree));
292 static tree patch_try_statement PARAMS ((tree));
293 static tree patch_synchronized_statement PARAMS ((tree, tree));
294 static tree patch_throw_statement PARAMS ((tree, tree));
295 static void check_thrown_exceptions PARAMS ((int, tree));
296 static int check_thrown_exceptions_do PARAMS ((tree));
297 static void purge_unchecked_exceptions PARAMS ((tree));
298 static void check_throws_clauses PARAMS ((tree, tree, tree));
299 static void finish_method_declaration PARAMS ((tree));
300 static tree build_super_invocation PARAMS ((tree));
301 static int verify_constructor_circularity PARAMS ((tree, tree));
302 static char *constructor_circularity_msg PARAMS ((tree, tree));
303 static tree build_this_super_qualified_invocation PARAMS ((int, tree, tree,
304                                                           int, int));
305 static const char *get_printable_method_name PARAMS ((tree));
306 static tree patch_conditional_expr PARAMS ((tree, tree, tree));
307 static tree generate_finit PARAMS ((tree));
308 static void add_instance_initializer PARAMS ((tree));
309 static void fix_constructors PARAMS ((tree));
310 static tree build_alias_initializer_parameter_list PARAMS ((int, tree,
311                                                             tree, int *));
312 static void craft_constructor PARAMS ((tree, tree));
313 static int verify_constructor_super PARAMS ((tree));
314 static tree create_artificial_method PARAMS ((tree, int, tree, tree, tree));
315 static void start_artificial_method_body PARAMS ((tree));
316 static void end_artificial_method_body PARAMS ((tree));
317 static int check_method_redefinition PARAMS ((tree, tree));
318 static int reset_method_name PARAMS ((tree));
319 static int check_method_types_complete PARAMS ((tree));
320 static void java_check_regular_methods PARAMS ((tree));
321 static void java_check_abstract_methods PARAMS ((tree));
322 static tree maybe_build_primttype_type_ref PARAMS ((tree, tree));
323 static void unreachable_stmt_error PARAMS ((tree));
324 static tree find_expr_with_wfl PARAMS ((tree));
325 static void missing_return_error PARAMS ((tree));
326 static tree build_new_array_init PARAMS ((int, tree));
327 static tree patch_new_array_init PARAMS ((tree, tree));
328 static tree maybe_build_array_element_wfl PARAMS ((tree));
329 static int array_constructor_check_entry PARAMS ((tree, tree));
330 static const char *purify_type_name PARAMS ((const char *));
331 static tree fold_constant_for_init PARAMS ((tree, tree));
332 static tree strip_out_static_field_access_decl PARAMS ((tree));
333 static jdeplist *reverse_jdep_list PARAMS ((struct parser_ctxt *));
334 static void static_ref_err PARAMS ((tree, tree, tree));
335 static void parser_add_interface PARAMS ((tree, tree, tree));
336 static void add_superinterfaces PARAMS ((tree, tree));
337 static tree jdep_resolve_class PARAMS ((jdep *));
338 static int note_possible_classname PARAMS ((const char *, int));
339 static void java_complete_expand_classes PARAMS ((void));
340 static void java_complete_expand_class PARAMS ((tree));
341 static void java_complete_expand_methods PARAMS ((tree));
342 static tree cut_identifier_in_qualified PARAMS ((tree));
343 static tree java_stabilize_reference PARAMS ((tree));
344 static tree do_unary_numeric_promotion PARAMS ((tree));
345 static char * operator_string PARAMS ((tree));
346 static tree do_merge_string_cste PARAMS ((tree, const char *, int, int));
347 static tree merge_string_cste PARAMS ((tree, tree, int));
348 static tree java_refold PARAMS ((tree));
349 static int java_decl_equiv PARAMS ((tree, tree));
350 static int binop_compound_p PARAMS ((enum tree_code));
351 static tree search_loop PARAMS ((tree));
352 static int labeled_block_contains_loop_p PARAMS ((tree, tree));
353 static void check_abstract_method_definitions PARAMS ((int, tree, tree));
354 static void java_check_abstract_method_definitions PARAMS ((tree));
355 static void java_debug_context_do PARAMS ((int));
356 static void java_parser_context_push_initialized_field PARAMS ((void));
357 static void java_parser_context_pop_initialized_field PARAMS ((void));
358 static tree reorder_static_initialized PARAMS ((tree));
359 static void java_parser_context_suspend PARAMS ((void));
360 static void java_parser_context_resume PARAMS ((void));
361
362 /* JDK 1.1 work. FIXME */
363
364 static tree maybe_make_nested_class_name PARAMS ((tree));
365 static void make_nested_class_name PARAMS ((tree));
366 static void set_nested_class_simple_name_value PARAMS ((tree, int));
367 static void link_nested_class_to_enclosing PARAMS ((void));
368 static tree find_as_inner_class PARAMS ((tree, tree, tree));
369 static tree find_as_inner_class_do PARAMS ((tree, tree));
370 static int check_inner_class_redefinition PARAMS ((tree, tree));
371
372 static tree build_thisn_assign PARAMS ((void));
373 static tree build_current_thisn PARAMS ((tree));
374 static tree build_access_to_thisn PARAMS ((tree, tree, int));
375 static tree maybe_build_thisn_access_method PARAMS ((tree));
376
377 static tree build_outer_field_access PARAMS ((tree, tree));
378 static tree build_outer_field_access_methods PARAMS ((tree));
379 static tree build_outer_field_access_expr PARAMS ((int, tree, tree, 
380                                                   tree, tree));
381 static tree build_outer_method_access_method PARAMS ((tree));
382 static tree build_new_access_id PARAMS ((void));
383 static tree build_outer_field_access_method PARAMS ((tree, tree, tree,
384                                                     tree, tree));
385
386 static int outer_field_access_p PARAMS ((tree, tree));
387 static int outer_field_expanded_access_p PARAMS ((tree, tree *, 
388                                                  tree *, tree *));
389 static tree outer_field_access_fix PARAMS ((tree, tree, tree));
390 static tree build_incomplete_class_ref PARAMS ((int, tree));
391 static tree patch_incomplete_class_ref PARAMS ((tree));
392 static tree create_anonymous_class PARAMS ((int, tree));
393 static void patch_anonymous_class PARAMS ((tree, tree, tree));
394 static void add_inner_class_fields PARAMS ((tree, tree));
395
396 static tree build_dot_class_method PARAMS ((tree));
397 static tree build_dot_class_method_invocation PARAMS ((tree));
398 static void create_new_parser_context PARAMS ((int));
399
400 /* Number of error found so far. */
401 int java_error_count; 
402 /* Number of warning found so far. */
403 int java_warning_count;
404 /* Tell when not to fold, when doing xrefs */
405 int do_not_fold;
406 /* Cyclic inheritance report, as it can be set by layout_class */
407 char *cyclic_inheritance_report;
408
409 /* Tell when we're within an instance initializer */
410 static int in_instance_initializer;
411
412 /* The current parser context */
413 struct parser_ctxt *ctxp;
414
415 /* List of things that were analyzed for which code will be generated */
416 static struct parser_ctxt *ctxp_for_generation = NULL;
417
418 /* binop_lookup maps token to tree_code. It is used where binary
419    operations are involved and required by the parser. RDIV_EXPR
420    covers both integral/floating point division. The code is changed
421    once the type of both operator is worked out.  */
422
423 static enum tree_code binop_lookup[19] = 
424   { 
425     PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
426     LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR, 
427     BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
428     TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
429     EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
430    };
431 #define BINOP_LOOKUP(VALUE)                                             \
432   binop_lookup [((VALUE) - PLUS_TK)%                                    \
433                 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
434
435 /* This is the end index for binary operators that can also be used
436    in compound assignements. */
437 #define BINOP_COMPOUND_CANDIDATES 11
438
439 /* Fake WFL used to report error message. It is initialized once if
440    needed and reused with it's location information is overriden.  */
441 tree wfl_operator = NULL_TREE;
442
443 /* The "$L" identifier we use to create labels.  */
444 static tree label_id = NULL_TREE;
445
446 /* The "StringBuffer" identifier used for the String `+' operator. */
447 static tree wfl_string_buffer = NULL_TREE; 
448
449 /* The "append" identifier used for String `+' operator.  */
450 static tree wfl_append = NULL_TREE;
451
452 /* The "toString" identifier used for String `+' operator. */
453 static tree wfl_to_string = NULL_TREE;
454
455 /* The "java.lang" import qualified name.  */
456 static tree java_lang_id = NULL_TREE;
457
458 /* The generated `inst$' identifier used for generated enclosing
459    instance/field access functions.  */
460 static tree inst_id = NULL_TREE;
461
462 /* The "java.lang.Cloneable" qualified name.  */
463 static tree java_lang_cloneable = NULL_TREE;
464
465 /* Context and flag for static blocks */
466 static tree current_static_block = NULL_TREE;
467
468 /* The generated `write_parm_value$' identifier.  */
469 static tree wpv_id;
470
471 /* The list of all packages we've seen so far */
472 static tree package_list = NULL_TREE;
473  
474 /* Check modifiers. If one doesn't fit, retrieve it in its declaration
475    line and point it out.  */
476 /* Should point out the one that don't fit. ASCII/unicode, going
477    backward. FIXME */
478
479 #define check_modifiers(__message, __value, __mask) do {        \
480   if ((__value) & ~(__mask))                                    \
481     {                                                           \
482       int i, remainder = (__value) & ~(__mask);                 \
483       for (i = 0; i <= 10; i++)                                 \
484         if ((1 << i) & remainder)                               \
485           parse_error_context (ctxp->modifier_ctx [i], (__message), \
486                                java_accstring_lookup (1 << i)); \
487     }                                                           \
488 } while (0)
489
490
491 #line 417 "./parse.y"
492 typedef union {
493   tree node;
494   int sub_token;
495   struct {
496     int token;
497     int location;
498   } operator;
499   int value;
500 } YYSTYPE;
501 #line 427 "./parse.y"
502
503 #include "lex.c"
504 #ifndef YYDEBUG
505 #define YYDEBUG 1
506 #endif
507
508 #include <stdio.h>
509
510 #ifndef __cplusplus
511 #ifndef __STDC__
512 #define const
513 #endif
514 #endif
515
516
517
518 #define YYFINAL         791
519 #define YYFLAG          -32768
520 #define YYNTBASE        110
521
522 #define YYTRANSLATE(x) ((unsigned)(x) <= 363 ? yytranslate[x] : 272)
523
524 static const char yytranslate[] = {     0,
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,     2,     2,     2,     2,     2,
549      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
550      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
551      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
552     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
553     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
554     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
555     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
556     57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
557     67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
558     77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
559     87,    88,    89,    90,    91,    92,    93,    94,    95,    96,
560     97,    98,    99,   100,   101,   102,   103,   104,   105,   106,
561    107,   108,   109
562 };
563
564 #if YYDEBUG != 0
565 static const short yyprhs[] = {     0,
566      0,     2,     4,     6,     8,    10,    12,    14,    16,    18,
567     20,    22,    24,    26,    28,    30,    32,    34,    38,    42,
568     46,    50,    54,    56,    58,    60,    64,    66,    67,    69,
569     71,    73,    76,    79,    82,    86,    88,    91,    93,    96,
570    100,   103,   107,   109,   111,   115,   118,   122,   128,   133,
571    139,   141,   143,   145,   147,   149,   152,   153,   161,   162,
572    169,   173,   176,   180,   185,   186,   189,   193,   196,   197,
573    200,   203,   205,   209,   213,   216,   220,   222,   225,   227,
574    229,   231,   233,   235,   238,   240,   242,   244,   248,   253,
575    255,   259,   263,   265,   269,   273,   278,   280,   284,   287,
576    291,   295,   297,   299,   300,   304,   307,   311,   315,   320,
577    325,   328,   332,   335,   339,   342,   346,   351,   355,   359,
578    363,   365,   369,   373,   376,   380,   383,   387,   389,   390,
579    393,   396,   398,   402,   406,   408,   411,   413,   416,   420,
580    422,   423,   427,   430,   434,   438,   443,   446,   450,   454,
581    459,   461,   464,   469,   475,   483,   490,   492,   494,   495,
582    500,   501,   507,   508,   514,   515,   522,   526,   531,   534,
583    538,   541,   545,   548,   552,   554,   557,   559,   561,   563,
584    565,   567,   570,   573,   576,   580,   585,   587,   591,   595,
585    598,   602,   604,   606,   608,   611,   613,   615,   617,   620,
586    623,   627,   629,   631,   633,   635,   637,   639,   641,   643,
587    645,   647,   649,   651,   653,   655,   657,   659,   661,   663,
588    665,   667,   669,   671,   673,   676,   679,   682,   685,   688,
589    691,   694,   697,   701,   706,   711,   717,   722,   728,   735,
590    743,   750,   752,   754,   756,   758,   760,   762,   764,   770,
591    773,   777,   782,   790,   798,   799,   803,   808,   811,   815,
592    821,   824,   828,   832,   837,   839,   842,   845,   847,   850,
593    854,   857,   860,   864,   867,   872,   875,   878,   882,   887,
594    890,   892,   900,   908,   915,   919,   925,   930,   938,   945,
595    948,   951,   955,   958,   959,   961,   963,   966,   967,   969,
596    971,   975,   979,   982,   986,   989,   993,   996,  1000,  1003,
597   1007,  1010,  1014,  1017,  1021,  1025,  1028,  1032,  1038,  1044,
598   1047,  1052,  1056,  1058,  1062,  1066,  1071,  1074,  1076,  1079,
599   1082,  1087,  1090,  1094,  1099,  1102,  1105,  1107,  1109,  1111,
600   1113,  1117,  1119,  1121,  1123,  1125,  1127,  1131,  1135,  1139,
601   1143,  1147,  1151,  1155,  1159,  1163,  1167,  1171,  1177,  1182,
602   1184,  1189,  1195,  1201,  1208,  1212,  1216,  1221,  1227,  1230,
603   1234,  1235,  1243,  1244,  1251,  1255,  1259,  1261,  1265,  1269,
604   1273,  1277,  1282,  1287,  1292,  1297,  1301,  1305,  1307,  1310,
605   1314,  1318,  1321,  1324,  1328,  1332,  1336,  1340,  1343,  1347,
606   1352,  1358,  1365,  1371,  1378,  1383,  1388,  1393,  1398,  1402,
607   1407,  1411,  1416,  1418,  1420,  1422,  1424,  1427,  1430,  1432,
608   1434,  1437,  1440,  1442,  1445,  1448,  1451,  1454,  1457,  1460,
609   1462,  1465,  1468,  1470,  1473,  1476,  1482,  1487,  1492,  1498,
610   1503,  1506,  1512,  1517,  1523,  1525,  1529,  1533,  1537,  1541,
611   1545,  1549,  1551,  1555,  1559,  1563,  1567,  1569,  1573,  1577,
612   1581,  1585,  1589,  1593,  1595,  1599,  1603,  1607,  1611,  1615,
613   1619,  1623,  1627,  1631,  1635,  1637,  1641,  1645,  1649,  1653,
614   1655,  1659,  1663,  1665,  1669,  1673,  1675,  1679,  1683,  1685,
615   1689,  1693,  1695,  1699,  1703,  1705,  1711,  1716,  1720,  1726,
616   1728,  1730,  1734,  1738,  1740,  1742,  1744,  1746,  1748,  1750
617 };
618
619 static const short yyrhs[] = {   123,
620      0,   104,     0,   105,     0,   108,     0,   103,     0,   102,
621      0,   109,     0,   113,     0,   114,     0,    82,     0,    85,
622      0,    50,     0,   115,     0,   118,     0,   119,     0,   115,
623      0,   115,     0,   113,    97,    98,     0,   119,    97,    98,
624      0,   118,    97,    98,     0,   113,    97,     1,     0,   118,
625     97,     1,     0,   120,     0,   121,     0,   122,     0,   119,
626    101,   122,     0,    86,     0,     0,   126,     0,   124,     0,
627    125,     0,   126,   124,     0,   126,   125,     0,   124,   125,
628      0,   126,   124,   125,     0,   127,     0,   124,   127,     0,
629    130,     0,   125,   130,     0,    75,   119,    99,     0,    75,
630      1,     0,    75,   119,     1,     0,   128,     0,   129,     0,
631     55,   119,    99,     0,    55,     1,     0,    55,   119,     1,
632      0,    55,   119,   101,     5,    99,     0,    55,   119,   101,
633      1,     0,    55,   119,   101,     5,     1,     0,   132,     0,
634    167,     0,    99,     0,     1,     0,    44,     0,   131,    44,
635      0,     0,   131,    67,   122,   135,   136,   133,   138,     0,
636      0,    67,   122,   135,   136,   134,   138,     0,   131,    67,
637      1,     0,    67,     1,     0,    67,   122,     1,     0,   131,
638     67,   122,     1,     0,     0,    63,   116,     0,    63,   116,
639      1,     0,    63,     1,     0,     0,    52,   137,     0,    52,
640      1,     0,   117,     0,   137,   100,   117,     0,   137,   100,
641      1,     0,    95,    96,     0,    95,   139,    96,     0,   140,
642      0,   139,   140,     0,   141,     0,   157,     0,   159,     0,
643    180,     0,   142,     0,   142,    99,     0,   147,     0,   132,
644      0,   167,     0,   112,   143,    99,     0,   131,   112,   143,
645     99,     0,   144,     0,   143,   100,   144,     0,   143,   100,
646      1,     0,   145,     0,   145,    92,   146,     0,   145,    92,
647      1,     0,   145,    92,   146,     1,     0,   122,     0,   145,
648     97,    98,     0,   122,     1,     0,   145,    97,     1,     0,
649    145,    98,     1,     0,   270,     0,   178,     0,     0,   149,
650    148,   156,     0,   149,     1,     0,   112,   150,   154,     0,
651     59,   150,   154,     0,   131,   112,   150,   154,     0,   131,
652     59,   150,   154,     0,   112,     1,     0,   131,   112,     1,
653      0,    59,     1,     0,   131,    59,     1,     0,   131,     1,
654      0,   122,    93,    94,     0,   122,    93,   151,    94,     0,
655    150,    97,    98,     0,   122,    93,     1,     0,   150,    97,
656      1,     0,   152,     0,   151,   100,   152,     0,   151,   100,
657      1,     0,   112,   145,     0,   153,   112,   145,     0,   112,
658      1,     0,   153,   112,     1,     0,   131,     0,     0,    53,
659    155,     0,    53,     1,     0,   116,     0,   155,   100,   116,
660      0,   155,   100,     1,     0,   180,     0,   180,    99,     0,
661     99,     0,   158,   180,     0,   158,   180,    99,     0,   131,
662      0,     0,   161,   160,   163,     0,   162,   154,     0,   131,
663    162,   154,     0,   120,    93,    94,     0,   120,    93,   151,
664     94,     0,   181,   164,     0,   181,   165,   164,     0,   181,
665    183,   164,     0,   181,   165,   183,   164,     0,   182,     0,
666    182,    99,     0,   166,    93,    94,    99,     0,   166,    93,
667    239,    94,    99,     0,   119,   101,    65,    93,   239,    94,
668     99,     0,   119,   101,    65,    93,    94,    99,     0,    76,
669      0,    65,     0,     0,    61,   122,   168,   173,     0,     0,
670    131,    61,   122,   169,   173,     0,     0,    61,   122,   172,
671    170,   173,     0,     0,   131,    61,   122,   172,   171,   173,
672      0,    61,   122,     1,     0,   131,    61,   122,     1,     0,
673     63,   117,     0,   172,   100,   117,     0,    63,     1,     0,
674    172,   100,     1,     0,    95,    96,     0,    95,   174,    96,
675      0,   175,     0,   174,   175,     0,   176,     0,   177,     0,
676    132,     0,   167,     0,   142,     0,   149,    99,     0,   149,
677      1,     0,    95,    96,     0,    95,   179,    96,     0,    95,
678    179,   100,    96,     0,   146,     0,   179,   100,   146,     0,
679    179,   100,     1,     0,    95,    96,     0,   181,   183,   182,
680      0,    95,     0,    96,     0,   184,     0,   183,   184,     0,
681    185,     0,   187,     0,   132,     0,   186,    99,     0,   112,
682    143,     0,   153,   112,   143,     0,   189,     0,   192,     0,
683    196,     0,   197,     0,   208,     0,   212,     0,   189,     0,
684    193,     0,   198,     0,   209,     0,   213,     0,   180,     0,
685    190,     0,   194,     0,   199,     0,   211,     0,   219,     0,
686    220,     0,   221,     0,   223,     0,   222,     0,   225,     0,
687     99,     0,   122,    88,     0,   191,   187,     0,   122,     1,
688      0,   191,   188,     0,   195,    99,     0,     1,    99,     0,
689      1,    95,     0,     1,    96,     0,   166,    93,     1,     0,
690    166,    93,    94,     1,     0,   166,    93,   239,     1,     0,
691    166,    93,   239,    94,     1,     0,   119,   101,    65,     1,
692      0,   119,   101,    65,    93,     1,     0,   119,   101,    65,
693     93,   239,     1,     0,   119,   101,    65,    93,   239,    94,
694      1,     0,   119,   101,    65,    93,    94,     1,     0,   267,
695      0,   251,     0,   252,     0,   248,     0,   249,     0,   245,
696      0,   234,     0,    48,    93,   270,    94,   187,     0,    48,
697      1,     0,    48,    93,     1,     0,    48,    93,   270,     1,
698      0,    48,    93,   270,    94,   188,    56,   187,     0,    48,
699     93,   270,    94,   188,    56,   188,     0,     0,   201,   200,
700    202,     0,    68,    93,   270,    94,     0,    68,     1,     0,
701     68,    93,     1,     0,    68,    93,   270,    94,     1,     0,
702     95,    96,     0,    95,   205,    96,     0,    95,   203,    96,
703      0,    95,   203,   205,    96,     0,   204,     0,   203,   204,
704      0,   205,   183,     0,   206,     0,   205,   206,     0,    62,
705    271,    88,     0,    47,    88,     0,    62,     1,     0,    62,
706    271,     1,     0,    47,     1,     0,    66,    93,   270,    94,
707      0,   207,   187,     0,    66,     1,     0,    66,    93,     1,
708      0,    66,    93,   270,     1,     0,   207,   188,     0,    51,
709      0,   210,   187,    66,    93,   270,    94,    99,     0,   215,
710     99,   270,    99,   217,    94,   187,     0,   215,    99,    99,
711    217,    94,   187,     0,   215,    99,     1,     0,   215,    99,
712    270,    99,     1,     0,   215,    99,    99,     1,     0,   215,
713     99,   270,    99,   217,    94,   188,     0,   215,    99,    99,
714    217,    94,   188,     0,    71,    93,     0,    71,     1,     0,
715     71,    93,     1,     0,   214,   216,     0,     0,   218,     0,
716    186,     0,   218,     1,     0,     0,   218,     0,   195,     0,
717    218,   100,   195,     0,   218,   100,     1,     0,    54,    99,
718      0,    54,   122,    99,     0,    54,     1,     0,    54,   122,
719      1,     0,    73,    99,     0,    73,   122,    99,     0,    73,
720      1,     0,    73,   122,     1,     0,    58,    99,     0,    58,
721    270,    99,     0,    58,     1,     0,    58,   270,     1,     0,
722     49,   270,    99,     0,    49,     1,     0,    49,   270,     1,
723      0,   224,    93,   270,    94,   180,     0,   224,    93,   270,
724     94,     1,     0,   224,     1,     0,   224,    93,     1,    94,
725      0,   224,    93,     1,     0,   131,     0,    70,   180,   226,
726      0,    70,   180,   229,     0,    70,   180,   226,   229,     0,
727     70,     1,     0,   227,     0,   226,   227,     0,   228,   180,
728      0,    60,    93,   152,    94,     0,    60,     1,     0,    60,
729     93,     1,     0,    60,    93,     1,    94,     0,    64,   180,
730      0,    64,     1,     0,   231,     0,   240,     0,   111,     0,
731     76,     0,    93,   270,    94,     0,   234,     0,   244,     0,
732    245,     0,   246,     0,   233,     0,   119,   101,    76,     0,
733     93,   270,     1,     0,   119,   101,     1,     0,   113,   101,
734      1,     0,    59,   101,     1,     0,   113,    97,    98,     0,
735    119,    97,    98,     0,   119,   101,    67,     0,   232,   101,
736     67,     0,   113,   101,    67,     0,    59,   101,    67,     0,
737     72,   116,    93,   239,    94,     0,    72,   116,    93,    94,
738      0,   235,     0,   238,   122,    93,    94,     0,   238,   122,
739     93,    94,   138,     0,   238,   122,    93,   239,    94,     0,
740    238,   122,    93,   239,    94,   138,     0,    72,     1,    99,
741      0,    72,   116,     1,     0,    72,   116,    93,     1,     0,
742     72,   116,    93,   239,     1,     0,   238,     1,     0,   238,
743    122,     1,     0,     0,    72,   116,    93,   239,    94,   236,
744    138,     0,     0,    72,   116,    93,    94,   237,   138,     0,
745    119,   101,    72,     0,   230,   101,    72,     0,   270,     0,
746    239,   100,   270,     0,   239,   100,     1,     0,    72,   113,
747    241,     0,    72,   115,   241,     0,    72,   113,   241,   243,
748      0,    72,   115,   241,   243,     0,    72,   115,   243,   178,
749      0,    72,   113,   243,   178,     0,    72,     1,    98,     0,
750     72,     1,    97,     0,   242,     0,   241,   242,     0,    97,
751    270,    98,     0,    97,   270,     1,     0,    97,     1,     0,
752     97,    98,     0,   243,    97,    98,     0,   243,    97,     1,
753      0,   230,   101,   122,     0,    65,   101,   122,     0,    65,
754      1,     0,   119,    93,    94,     0,   119,    93,   239,    94,
755      0,   230,   101,   122,    93,    94,     0,   230,   101,   122,
756     93,   239,    94,     0,    65,   101,   122,    93,    94,     0,
757     65,   101,   122,    93,   239,    94,     0,    65,   101,     1,
758     94,     0,    65,   101,     1,   101,     0,   119,    97,   270,
759     98,     0,   231,    97,   270,    98,     0,   119,    97,     1,
760      0,   119,    97,   270,     1,     0,   231,    97,     1,     0,
761    231,    97,   270,     1,     0,   230,     0,   119,     0,   248,
762      0,   249,     0,   247,    46,     0,   247,    45,     0,   251,
763      0,   252,     0,     3,   250,     0,     4,   250,     0,   253,
764      0,     3,     1,     0,     4,     1,     0,    46,   250,     0,
765     46,     1,     0,    45,   250,     0,    45,     1,     0,   247,
766      0,    89,   250,     0,    90,   250,     0,   254,     0,    89,
767      1,     0,    90,     1,     0,    93,   113,   243,    94,   250,
768      0,    93,   113,    94,   250,     0,    93,   270,    94,   253,
769      0,    93,   119,   243,    94,   253,     0,    93,   113,    97,
770      1,     0,    93,     1,     0,    93,   113,   243,    94,     1,
771      0,    93,   113,    94,     1,     0,    93,   119,   243,    94,
772      1,     0,   250,     0,   255,     5,   250,     0,   255,     6,
773    250,     0,   255,     7,   250,     0,   255,     5,     1,     0,
774    255,     6,     1,     0,   255,     7,     1,     0,   255,     0,
775    256,     3,   255,     0,   256,     4,   255,     0,   256,     3,
776      1,     0,   256,     4,     1,     0,   256,     0,   257,     8,
777    256,     0,   257,     9,   256,     0,   257,    10,   256,     0,
778    257,     8,     1,     0,   257,     9,     1,     0,   257,    10,
779      1,     0,   257,     0,   258,    20,   257,     0,   258,    18,
780    257,     0,   258,    21,   257,     0,   258,    19,   257,     0,
781    258,    57,   114,     0,   258,    20,     1,     0,   258,    18,
782      1,     0,   258,    21,     1,     0,   258,    19,     1,     0,
783    258,    57,     1,     0,   258,     0,   259,    16,   258,     0,
784    259,    17,   258,     0,   259,    16,     1,     0,   259,    17,
785      1,     0,   259,     0,   260,    11,   259,     0,   260,    11,
786      1,     0,   260,     0,   261,    12,   260,     0,   261,    12,
787      1,     0,   261,     0,   262,    13,   261,     0,   262,    13,
788      1,     0,   262,     0,   263,    14,   262,     0,   263,    14,
789      1,     0,   263,     0,   264,    15,   263,     0,   264,    15,
790      1,     0,   264,     0,   264,    87,   270,    88,   265,     0,
791    264,    87,    88,     1,     0,   264,    87,     1,     0,   264,
792     87,   270,    88,     1,     0,   265,     0,   267,     0,   268,
793    269,   266,     0,   268,   269,     1,     0,   119,     0,   244,
794      0,   246,     0,    91,     0,    92,     0,   266,     0,   270,
795      0
796 };
797
798 #endif
799
800 #if YYDEBUG != 0
801 static const short yyrline[] = { 0,
802    576,   582,   584,   585,   586,   587,   588,   592,   594,   597,
803    599,   600,   603,   605,   608,   612,   616,   620,   626,   628,
804    630,   632,   637,   639,   642,   646,   651,   656,   658,   659,
805    660,   661,   662,   663,   664,   667,   672,   678,   680,   683,
806    689,   691,   695,   697,   700,   727,   729,   733,   746,   748,
807    752,   755,   757,   759,   769,   774,   789,   793,   793,   796,
808    796,   798,   800,   805,   809,   811,   813,   815,   819,   821,
809    823,   830,   836,   841,   845,   854,   864,   866,   869,   871,
810    872,   873,   880,   882,   884,   885,   887,   892,   895,   905,
811    908,   910,   914,   917,   924,   930,   938,   940,   942,   944,
812    946,   950,   952,   956,   967,   968,   972,   975,   977,   979,
813    981,   986,   988,   990,   992,   999,  1005,  1007,  1016,  1018,
814   1022,  1027,  1032,  1036,  1041,  1046,  1051,  1058,  1068,  1070,
815   1072,  1076,  1079,  1081,  1085,  1087,  1088,  1093,  1099,  1106,
816   1122,  1129,  1132,  1135,  1139,  1145,  1149,  1158,  1160,  1162,
817   1166,  1168,  1171,  1178,  1186,  1188,  1192,  1199,  1209,  1213,
818   1213,  1216,  1216,  1219,  1219,  1222,  1222,  1224,  1228,  1234,
819   1239,  1241,  1245,  1248,  1252,  1254,  1257,  1259,  1260,  1262,
820   1266,  1270,  1276,  1281,  1284,  1286,  1290,  1296,  1300,  1305,
821   1314,  1318,  1323,  1337,  1339,  1342,  1344,  1346,  1353,  1357,
822   1360,  1364,  1366,  1367,  1368,  1369,  1370,  1374,  1376,  1377,
823   1378,  1379,  1383,  1385,  1386,  1387,  1388,  1389,  1390,  1391,
824   1392,  1393,  1394,  1397,  1402,  1413,  1416,  1420,  1427,  1437,
825   1443,  1449,  1455,  1457,  1462,  1464,  1469,  1471,  1473,  1475,
826   1477,  1481,  1483,  1484,  1485,  1486,  1487,  1488,  1491,  1497,
827   1499,  1501,  1505,  1510,  1515,  1521,  1531,  1537,  1539,  1541,
828   1548,  1551,  1553,  1555,  1559,  1561,  1564,  1568,  1570,  1573,
829   1580,  1586,  1588,  1590,  1594,  1602,  1605,  1607,  1609,  1613,
830   1618,  1627,  1632,  1635,  1642,  1644,  1646,  1650,  1653,  1662,
831   1669,  1671,  1675,  1688,  1690,  1696,  1702,  1706,  1708,  1712,
832   1715,  1717,  1721,  1724,  1726,  1728,  1732,  1735,  1737,  1739,
833   1743,  1746,  1748,  1750,  1754,  1760,  1762,  1766,  1773,  1775,
834   1777,  1779,  1783,  1795,  1798,  1800,  1805,  1809,  1811,  1818,
835   1826,  1843,  1845,  1850,  1854,  1857,  1862,  1864,  1867,  1869,
836   1871,  1873,  1874,  1875,  1876,  1877,  1881,  1886,  1888,  1890,
837   1892,  1899,  1905,  1914,  1917,  1919,  1921,  1925,  1928,  1930,
838   1934,  1940,  1941,  1947,  1948,  1950,  1952,  1954,  1956,  1958,
839   1967,  1971,  2001,  2004,  2018,  2021,  2025,  2031,  2036,  2040,
840   2043,  2045,  2047,  2051,  2060,  2068,  2070,  2074,  2077,  2081,
841   2092,  2094,  2102,  2129,  2131,  2135,  2140,  2147,  2151,  2154,
842   2156,  2167,  2178,  2183,  2192,  2194,  2198,  2201,  2203,  2208,
843   2213,  2218,  2225,  2227,  2228,  2229,  2232,  2237,  2242,  2244,
844   2245,  2247,  2249,  2250,  2252,  2256,  2259,  2263,  2266,  2270,
845   2272,  2274,  2276,  2277,  2279,  2283,  2292,  2294,  2296,  2309,
846   2311,  2317,  2319,  2321,  2325,  2327,  2332,  2337,  2342,  2344,
847   2346,  2350,  2352,  2357,  2362,  2364,  2368,  2370,  2375,  2380,
848   2385,  2387,  2389,  2393,  2395,  2400,  2405,  2410,  2415,  2417,
849   2419,  2421,  2423,  2425,  2429,  2431,  2436,  2441,  2443,  2447,
850   2449,  2454,  2458,  2460,  2465,  2469,  2471,  2476,  2480,  2482,
851   2487,  2491,  2493,  2498,  2502,  2504,  2509,  2515,  2517,  2521,
852   2523,  2526,  2529,  2537,  2539,  2540,  2543,  2545,  2548,  2552
853 };
854 #endif
855
856
857 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
858
859 static const char * const yytname[] = {   "$","error","$undefined.","PLUS_TK",
860 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
861 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
862 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
863 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
864 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
865 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
866 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
867 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
868 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
869 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
870 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
871 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
872 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
873 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
874 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
875 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
876 "class_type","interface_type","array_type","name","simple_name","qualified_name",
877 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
878 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
879 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
880 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
881 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
882 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
883 "method_declarator","formal_parameter_list","formal_parameter","final","throws",
884 "class_type_list","method_body","static_initializer","static","constructor_declaration",
885 "@4","constructor_header","constructor_declarator","constructor_body","constructor_block_end",
886 "explicit_constructor_invocation","this_or_super","interface_declaration","@5",
887 "@6","@7","@8","extends_interfaces","interface_body","interface_member_declarations",
888 "interface_member_declaration","constant_declaration","abstract_method_declaration",
889 "array_initializer","variable_initializers","block","block_begin","block_end",
890 "block_statements","block_statement","local_variable_declaration_statement",
891 "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement",
892 "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
893 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
894 "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups",
895 "switch_block_statement_group","switch_labels","switch_label","while_expression",
896 "while_statement","while_statement_nsi","do_statement_begin","do_statement",
897 "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update",
898 "statement_expression_list","break_statement","continue_statement","return_statement",
899 "throw_statement","synchronized_statement","synchronized","try_statement","catches",
900 "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array",
901 "array_type_literal","type_literals","class_instance_creation_expression","anonymous_class_creation",
902 "@10","@11","something_dot_new","argument_list","array_creation_expression",
903 "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access",
904 "postfix_expression","post_increment_expression","post_decrement_expression",
905 "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus",
906 "cast_expression","multiplicative_expression","additive_expression","shift_expression",
907 "relational_expression","equality_expression","and_expression","exclusive_or_expression",
908 "inclusive_or_expression","conditional_and_expression","conditional_or_expression",
909 "conditional_expression","assignment_expression","assignment","left_hand_side",
910 "assignment_operator","expression","constant_expression", NULL
911 };
912 #endif
913
914 static const short yyr1[] = {     0,
915    110,   111,   111,   111,   111,   111,   111,   112,   112,   113,
916    113,   113,   114,   114,   115,   116,   117,   118,   118,   118,
917    118,   118,   119,   119,   120,   121,   122,   123,   123,   123,
918    123,   123,   123,   123,   123,   124,   124,   125,   125,   126,
919    126,   126,   127,   127,   128,   128,   128,   129,   129,   129,
920    130,   130,   130,   130,   131,   131,   133,   132,   134,   132,
921    132,   132,   132,   132,   135,   135,   135,   135,   136,   136,
922    136,   137,   137,   137,   138,   138,   139,   139,   140,   140,
923    140,   140,   141,   141,   141,   141,   141,   142,   142,   143,
924    143,   143,   144,   144,   144,   144,   145,   145,   145,   145,
925    145,   146,   146,   148,   147,   147,   149,   149,   149,   149,
926    149,   149,   149,   149,   149,   150,   150,   150,   150,   150,
927    151,   151,   151,   152,   152,   152,   152,   153,   154,   154,
928    154,   155,   155,   155,   156,   156,   156,   157,   157,   158,
929    160,   159,   161,   161,   162,   162,   163,   163,   163,   163,
930    164,   164,   165,   165,   165,   165,   166,   166,   168,   167,
931    169,   167,   170,   167,   171,   167,   167,   167,   172,   172,
932    172,   172,   173,   173,   174,   174,   175,   175,   175,   175,
933    176,   177,   177,   178,   178,   178,   179,   179,   179,   180,
934    180,   181,   182,   183,   183,   184,   184,   184,   185,   186,
935    186,   187,   187,   187,   187,   187,   187,   188,   188,   188,
936    188,   188,   189,   189,   189,   189,   189,   189,   189,   189,
937    189,   189,   189,   190,   191,   192,   192,   193,   194,   194,
938    194,   194,   194,   194,   194,   194,   194,   194,   194,   194,
939    194,   195,   195,   195,   195,   195,   195,   195,   196,   196,
940    196,   196,   197,   198,   200,   199,   201,   201,   201,   201,
941    202,   202,   202,   202,   203,   203,   204,   205,   205,   206,
942    206,   206,   206,   206,   207,   208,   208,   208,   208,   209,
943    210,   211,   212,   212,   212,   212,   212,   213,   213,   214,
944    214,   214,   215,   216,   216,   216,   216,   217,   217,   218,
945    218,   218,   219,   219,   219,   219,   220,   220,   220,   220,
946    221,   221,   221,   221,   222,   222,   222,   223,   223,   223,
947    223,   223,   224,   225,   225,   225,   225,   226,   226,   227,
948    228,   228,   228,   228,   229,   229,   230,   230,   231,   231,
949    231,   231,   231,   231,   231,   231,   231,   231,   231,   231,
950    231,   232,   232,   233,   233,   233,   233,   234,   234,   234,
951    234,   234,   234,   234,   234,   234,   234,   234,   234,   234,
952    236,   235,   237,   235,   238,   238,   239,   239,   239,   240,
953    240,   240,   240,   240,   240,   240,   240,   241,   241,   242,
954    242,   242,   243,   243,   243,   244,   244,   244,   245,   245,
955    245,   245,   245,   245,   245,   245,   246,   246,   246,   246,
956    246,   246,   247,   247,   247,   247,   248,   249,   250,   250,
957    250,   250,   250,   250,   250,   251,   251,   252,   252,   253,
958    253,   253,   253,   253,   253,   254,   254,   254,   254,   254,
959    254,   254,   254,   254,   255,   255,   255,   255,   255,   255,
960    255,   256,   256,   256,   256,   256,   257,   257,   257,   257,
961    257,   257,   257,   258,   258,   258,   258,   258,   258,   258,
962    258,   258,   258,   258,   259,   259,   259,   259,   259,   260,
963    260,   260,   261,   261,   261,   262,   262,   262,   263,   263,
964    263,   264,   264,   264,   265,   265,   265,   265,   265,   266,
965    266,   267,   267,   268,   268,   268,   269,   269,   270,   271
966 };
967
968 static const short yyr2[] = {     0,
969      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
970      1,     1,     1,     1,     1,     1,     1,     3,     3,     3,
971      3,     3,     1,     1,     1,     3,     1,     0,     1,     1,
972      1,     2,     2,     2,     3,     1,     2,     1,     2,     3,
973      2,     3,     1,     1,     3,     2,     3,     5,     4,     5,
974      1,     1,     1,     1,     1,     2,     0,     7,     0,     6,
975      3,     2,     3,     4,     0,     2,     3,     2,     0,     2,
976      2,     1,     3,     3,     2,     3,     1,     2,     1,     1,
977      1,     1,     1,     2,     1,     1,     1,     3,     4,     1,
978      3,     3,     1,     3,     3,     4,     1,     3,     2,     3,
979      3,     1,     1,     0,     3,     2,     3,     3,     4,     4,
980      2,     3,     2,     3,     2,     3,     4,     3,     3,     3,
981      1,     3,     3,     2,     3,     2,     3,     1,     0,     2,
982      2,     1,     3,     3,     1,     2,     1,     2,     3,     1,
983      0,     3,     2,     3,     3,     4,     2,     3,     3,     4,
984      1,     2,     4,     5,     7,     6,     1,     1,     0,     4,
985      0,     5,     0,     5,     0,     6,     3,     4,     2,     3,
986      2,     3,     2,     3,     1,     2,     1,     1,     1,     1,
987      1,     2,     2,     2,     3,     4,     1,     3,     3,     2,
988      3,     1,     1,     1,     2,     1,     1,     1,     2,     2,
989      3,     1,     1,     1,     1,     1,     1,     1,     1,     1,
990      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
991      1,     1,     1,     1,     2,     2,     2,     2,     2,     2,
992      2,     2,     3,     4,     4,     5,     4,     5,     6,     7,
993      6,     1,     1,     1,     1,     1,     1,     1,     5,     2,
994      3,     4,     7,     7,     0,     3,     4,     2,     3,     5,
995      2,     3,     3,     4,     1,     2,     2,     1,     2,     3,
996      2,     2,     3,     2,     4,     2,     2,     3,     4,     2,
997      1,     7,     7,     6,     3,     5,     4,     7,     6,     2,
998      2,     3,     2,     0,     1,     1,     2,     0,     1,     1,
999      3,     3,     2,     3,     2,     3,     2,     3,     2,     3,
1000      2,     3,     2,     3,     3,     2,     3,     5,     5,     2,
1001      4,     3,     1,     3,     3,     4,     2,     1,     2,     2,
1002      4,     2,     3,     4,     2,     2,     1,     1,     1,     1,
1003      3,     1,     1,     1,     1,     1,     3,     3,     3,     3,
1004      3,     3,     3,     3,     3,     3,     3,     5,     4,     1,
1005      4,     5,     5,     6,     3,     3,     4,     5,     2,     3,
1006      0,     7,     0,     6,     3,     3,     1,     3,     3,     3,
1007      3,     4,     4,     4,     4,     3,     3,     1,     2,     3,
1008      3,     2,     2,     3,     3,     3,     3,     2,     3,     4,
1009      5,     6,     5,     6,     4,     4,     4,     4,     3,     4,
1010      3,     4,     1,     1,     1,     1,     2,     2,     1,     1,
1011      2,     2,     1,     2,     2,     2,     2,     2,     2,     1,
1012      2,     2,     1,     2,     2,     5,     4,     4,     5,     4,
1013      2,     5,     4,     5,     1,     3,     3,     3,     3,     3,
1014      3,     1,     3,     3,     3,     3,     1,     3,     3,     3,
1015      3,     3,     3,     1,     3,     3,     3,     3,     3,     3,
1016      3,     3,     3,     3,     1,     3,     3,     3,     3,     1,
1017      3,     3,     1,     3,     3,     1,     3,     3,     1,     3,
1018      3,     1,     3,     3,     1,     5,     4,     3,     5,     1,
1019      1,     3,     3,     1,     1,     1,     1,     1,     1,     1
1020 };
1021
1022 static const short yydefact[] = {     0,
1023     54,    55,     0,     0,     0,     0,    53,     1,     0,     0,
1024      0,    36,    43,    44,    38,     0,    51,    52,    46,    27,
1025      0,    23,    24,    25,     0,    62,     0,    41,     0,     0,
1026     37,    39,     0,     0,    56,     0,     0,    47,    45,     0,
1027    167,     0,     0,   163,    63,     0,    69,    42,    40,     0,
1028      0,     0,    61,     0,    49,     0,    26,   171,    17,   169,
1029     15,     0,   160,     0,     0,    68,    16,     0,     0,    59,
1030    168,     0,   165,    64,    69,    50,    48,    12,     0,    10,
1031     11,   173,     0,     8,     9,    13,    14,    15,     0,   179,
1032    181,     0,   180,     0,   175,   177,   178,   172,   170,   164,
1033     67,    71,    72,    70,     0,   162,     0,    57,   113,     0,
1034    129,   111,     0,     0,    90,    93,   129,     0,     0,     0,
1035    115,     0,     0,   183,   182,   174,   176,     0,     0,    60,
1036    166,     0,     0,     0,     0,   108,    99,    88,     0,     0,
1037      0,     0,   107,    21,    18,    22,    20,    19,   114,   129,
1038    112,     0,   129,    74,    73,   192,    75,    23,     0,    86,
1039      0,    77,    79,    83,    85,     0,    80,     0,    81,   141,
1040    129,    87,    82,     0,    58,   119,   116,     0,   128,     0,
1041    121,     0,   131,   132,   130,   120,   118,    92,     0,    91,
1042     95,     0,     0,     0,     0,     0,     0,     0,   340,     0,
1043      0,     0,     0,     6,     5,     2,     3,     4,     7,   339,
1044      0,   414,     0,   103,   413,   337,     0,   346,   342,   360,
1045      0,   338,   343,   344,   345,   430,   415,   416,   445,   419,
1046    420,   423,   433,   452,   457,   464,   475,   480,   483,   486,
1047    489,   492,   495,   500,   509,   501,     0,   102,   100,    98,
1048    101,   110,    89,   109,   190,     0,   129,    76,    78,    84,
1049    106,     0,   138,     0,   143,     0,     0,     0,   281,     0,
1050      0,     0,     0,     0,     0,     0,     0,   340,     0,   224,
1051      0,     8,   414,     0,   128,   198,     0,     0,   213,     0,
1052    194,   196,     0,   197,   202,   214,     0,   203,   215,     0,
1053    204,   205,   216,   255,     0,   206,     0,   217,   207,   294,
1054      0,   218,   219,   220,   222,   221,     0,   223,   248,   247,
1055      0,   245,   246,   243,   244,   242,   126,   124,   117,     0,
1056      0,     0,   424,   414,   343,   345,   421,   425,   422,   429,
1057    428,   427,   426,     0,   398,     0,     0,     0,    16,     0,
1058    434,   431,   435,   432,   441,     0,   414,     0,   184,   187,
1059      0,     0,     0,     0,     0,     0,    96,     0,     0,     0,
1060    369,     0,   418,   417,     0,     0,     0,     0,     0,     0,
1061      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1062      0,     0,     0,     0,     0,   507,   508,     0,   145,     0,
1063    144,   137,   105,   135,   139,   192,   142,     0,   231,   232,
1064    230,   250,     0,   316,     0,   305,   303,     0,   313,   311,
1065      0,   277,     0,   258,     0,   327,     0,   291,     0,   309,
1066    307,     0,     0,   200,     0,     0,     0,   227,   225,     0,
1067      0,   193,   191,   195,   199,   414,   323,   226,   229,     0,
1068    276,     0,   414,   296,   300,   293,     0,     0,   320,     0,
1069    123,   122,   127,   125,   134,   133,   351,   357,     0,   397,
1070    387,   386,   365,     0,   380,   388,     0,   381,     0,   366,
1071      0,     0,     0,     0,     0,     0,   348,   341,   185,     0,
1072    352,   350,   356,   399,     0,   377,   409,   353,     0,   349,
1073    354,   375,   347,   376,   396,   411,     0,   355,   370,     0,
1074    449,   446,   450,   447,   451,   448,   455,   453,   456,   454,
1075    461,   458,   462,   459,   463,   460,   471,   466,   473,   468,
1076    470,   465,   472,   467,   474,     0,   469,   478,   476,   479,
1077    477,   482,   481,   485,   484,   488,   487,   491,   490,   494,
1078    493,   498,     0,     0,   503,   502,   146,   136,   414,   147,
1079      0,     0,   151,     0,   251,     0,   317,   315,   306,   304,
1080    314,   312,   278,     0,   259,     0,     0,     0,   324,   328,
1081      0,   325,   292,   310,   308,   341,    18,    19,     0,   201,
1082    233,     0,     0,     0,   256,     0,   297,     0,   285,     0,
1083      0,   322,     0,   405,   406,     0,   392,   393,     0,   389,
1084    382,     0,   385,   383,   384,   367,   359,     0,   443,   437,
1085    440,   393,     0,   393,     0,   438,   189,   186,   188,   400,
1086      0,   410,   407,     0,   412,   408,   361,     0,   497,     0,
1087      0,   148,     0,     0,   152,   149,   252,     0,   279,   275,
1088      0,   332,     0,   336,   335,   329,   326,   330,   237,     0,
1089    234,   235,     0,     0,     0,   261,     0,   265,     0,   268,
1090      0,   302,   301,   287,     0,   299,     0,   321,     0,   403,
1091      0,   391,   390,   395,   394,     0,   368,   358,   442,   436,
1092    444,   439,   379,   378,   401,     0,   362,   363,   499,   496,
1093      0,   150,     0,     0,     0,   249,     0,   202,     0,   209,
1094    210,     0,   211,   212,     0,   260,   333,     0,   238,     0,
1095      0,   236,   274,   271,   272,   510,     0,   263,   266,     0,
1096    262,     0,   269,     0,     0,   286,     0,   319,   318,   404,
1097    374,     0,   402,   364,     0,   153,     0,     0,     0,   228,
1098    280,     0,   334,   331,   241,   239,     0,   273,   270,   264,
1099      0,   284,     0,   372,     0,     0,   154,     0,   253,     0,
1100      0,   240,   282,   283,   156,     0,     0,     0,     0,   155,
1101      0,     0,     0,     0,   289,     0,   254,   288,     0,     0,
1102      0
1103 };
1104
1105 static const short yydefgoto[] = {   789,
1106    210,   281,   211,    85,    86,    68,    60,    87,   212,    22,
1107     23,    24,     8,     9,    10,    11,    12,    13,    14,    15,
1108    447,   286,   132,   105,    47,    70,   104,   130,   161,   162,
1109    163,    91,   114,   115,   116,   213,   165,   262,    92,   111,
1110    180,   181,   287,   136,   185,   403,   167,   168,   169,   264,
1111    170,   171,   407,   560,   561,   288,    18,    43,    72,    65,
1112    107,    44,    63,    94,    95,    96,    97,   214,   361,   289,
1113    174,   563,   732,   291,   292,   293,   294,   707,   295,   296,
1114    297,   298,   710,   299,   300,   301,   302,   711,   303,   450,
1115    304,   595,   667,   668,   669,   670,   305,   306,   713,   307,
1116    308,   309,   714,   310,   311,   456,   675,   676,   312,   313,
1117    314,   315,   316,   317,   318,   579,   580,   581,   582,   215,
1118    216,   217,   218,   219,   220,   742,   686,   221,   495,   222,
1119    475,   476,   477,   223,   224,   225,   226,   227,   228,   229,
1120    230,   231,   232,   233,   234,   235,   236,   237,   238,   239,
1121    240,   241,   242,   243,   244,   245,   246,   247,   398,   496,
1122    727
1123 };
1124
1125 static const short yypact[] = {   356,
1126 -32768,-32768,   158,   -35,   339,   439,-32768,-32768,   433,   247,
1127    473,-32768,-32768,-32768,-32768,    29,-32768,-32768,-32768,-32768,
1128     12,-32768,-32768,-32768,   331,-32768,   491,-32768,    71,   469,
1129 -32768,-32768,   520,   562,-32768,   -35,   510,-32768,-32768,   278,
1130 -32768,   521,   -25,    -8,-32768,   526,   349,-32768,-32768,   -35,
1131    591,   343,-32768,   508,-32768,    25,-32768,-32768,-32768,-32768,
1132      7,  1014,-32768,   568,   -25,-32768,-32768,   346,   594,-32768,
1133 -32768,   -25,    -8,-32768,   349,-32768,-32768,-32768,   597,-32768,
1134 -32768,-32768,   607,   165,-32768,-32768,   315,   181,   676,-32768,
1135 -32768,    30,-32768,  1034,-32768,-32768,-32768,-32768,-32768,-32768,
1136 -32768,-32768,-32768,   328,   354,-32768,   -25,-32768,-32768,   370,
1137     -4,-32768,   449,   733,-32768,   201,    -4,   122,   208,   377,
1138 -32768,   608,   616,-32768,-32768,-32768,-32768,   617,   938,-32768,
1139 -32768,   354,   629,   630,   215,-32768,-32768,-32768,   648,  2189,
1140    227,   489,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    -4,
1141 -32768,   743,    -4,-32768,-32768,   412,-32768,   425,   577,-32768,
1142    943,-32768,-32768,   438,-32768,    47,-32768,   455,-32768,-32768,
1143    506,-32768,-32768,  1916,-32768,-32768,-32768,   655,   569,   321,
1144 -32768,   589,-32768,-32768,   532,-32768,-32768,-32768,   485,-32768,
1145 -32768,  3001,  3052,  3117,  3168,   533,    18,   615,-32768,  3233,
1146   3284,  3349,  5298,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1147    302,   915,    63,-32768,   542,   581,   587,-32768,-32768,-32768,
1148    656,-32768,   766,-32768,   780,   846,-32768,-32768,-32768,-32768,
1149 -32768,-32768,-32768,   879,   896,   937,   893,   880,   697,   701,
1150    717,   741,    74,-32768,-32768,-32768,   841,-32768,-32768,-32768,
1151 -32768,-32768,-32768,-32768,-32768,   774,   506,-32768,-32768,-32768,
1152 -32768,   565,   690,   685,-32768,   600,   172,  3400,-32768,   206,
1153   2240,    17,   311,   342,    82,   426,   211,   700,  5597,-32768,
1154    -35,   651,   837,   229,   522,-32768,   589,   705,-32768,  1848,
1155 -32768,-32768,   702,-32768,-32768,-32768,  1984,-32768,-32768,   709,
1156 -32768,-32768,-32768,-32768,  1984,-32768,  1984,-32768,-32768,  5648,
1157    738,-32768,-32768,-32768,-32768,-32768,   436,-32768,   806,   808,
1158    846,   891,   908,-32768,-32768,-32768,-32768,   869,-32768,   654,
1159    684,   686,-32768,   722,-32768,-32768,-32768,-32768,-32768,-32768,
1160 -32768,-32768,-32768,    27,-32768,   691,   860,   724,   724,   452,
1161 -32768,-32768,-32768,-32768,-32768,   694,  1044,    43,-32768,-32768,
1162    669,   747,   222,  5365,  2305,   538,-32768,   279,  3465,   772,
1163 -32768,   458,-32768,-32768,  3516,  3581,  3632,  3697,  3748,  3813,
1164   3864,  3929,  3980,  4045,  4096,  4161,   721,  4212,  4277,  4328,
1165   4393,  4444,  4509,  4560,  2356,-32768,-32768,  4625,-32768,   368,
1166 -32768,-32768,-32768,   750,-32768,-32768,-32768,  1848,-32768,-32768,
1167 -32768,-32768,  4676,-32768,    35,-32768,-32768,    56,-32768,-32768,
1168     70,-32768,  4741,-32768,  4792,-32768,   718,-32768,  5206,-32768,
1169 -32768,   144,   259,   762,   235,  2421,   652,-32768,-32768,   -35,
1170   2472,-32768,-32768,-32768,-32768,  1096,   569,-32768,-32768,   779,
1171 -32768,   810,  1032,-32768,-32768,-32768,    76,  2537,-32768,  4857,
1172 -32768,-32768,-32768,   869,-32768,-32768,-32768,-32768,   -49,   789,
1173 -32768,-32768,-32768,  2588,   724,-32768,   479,   724,   479,-32768,
1174   2653,  4908,   240,   135,  2704,   657,-32768,  1671,-32768,  2124,
1175 -32768,-32768,-32768,-32768,   547,-32768,-32768,-32768,   244,-32768,
1176 -32768,-32768,-32768,-32768,   801,-32768,   251,-32768,-32768,  5416,
1177 -32768,-32768,-32768,-32768,-32768,-32768,-32768,   879,-32768,   879,
1178 -32768,   896,-32768,   896,-32768,   896,-32768,   937,-32768,   937,
1179 -32768,   937,-32768,   937,-32768,   165,-32768,-32768,   893,-32768,
1180    893,-32768,   880,-32768,   697,-32768,   701,-32768,   717,-32768,
1181    741,-32768,   901,   818,-32768,-32768,-32768,-32768,  1076,-32768,
1182   1848,   815,   811,  1848,-32768,   335,-32768,-32768,-32768,-32768,
1183 -32768,-32768,-32768,   351,-32768,   823,   463,   132,   718,-32768,
1184    455,-32768,-32768,-32768,-32768,-32768,   819,   824,   464,   762,
1185 -32768,   941,    66,    -9,-32768,   851,-32768,  5340,-32768,  5231,
1186    840,   854,   857,-32768,-32768,  5481,-32768,-32768,   272,-32768,
1187    864,   294,-32768,   864,-32768,-32768,   878,    94,-32768,-32768,
1188 -32768,   819,  4973,   824,  1120,-32768,-32768,-32768,-32768,-32768,
1189   5024,-32768,-32768,  5532,-32768,-32768,   354,   548,-32768,  5089,
1190    744,-32768,  1848,  2769,-32768,-32768,-32768,  2050,-32768,-32768,
1191    263,-32768,   681,-32768,-32768,-32768,-32768,-32768,-32768,  2820,
1192 -32768,-32768,   963,   212,  5140,-32768,   419,-32768,  1564,-32768,
1193   5597,-32768,-32768,-32768,   881,   886,  5273,-32768,   268,-32768,
1194    728,-32768,-32768,-32768,-32768,   354,-32768,   903,-32768,-32768,
1195 -32768,-32768,-32768,-32768,-32768,   731,-32768,   354,-32768,-32768,
1196    504,-32768,   173,   121,   509,-32768,   940,   944,  2050,-32768,
1197 -32768,  2050,-32768,-32768,   904,-32768,   923,   925,-32768,  1020,
1198    137,-32768,-32768,-32768,-32768,-32768,   262,-32768,-32768,  1646,
1199 -32768,  1780,-32768,   932,  1984,-32768,   942,-32768,-32768,-32768,
1200 -32768,   354,-32768,-32768,  2885,-32768,   182,  4676,  1984,-32768,
1201 -32768,  2936,-32768,-32768,-32768,-32768,  1029,-32768,-32768,-32768,
1202    945,-32768,  1984,-32768,   210,   177,-32768,   401,-32768,  5231,
1203    946,-32768,-32768,-32768,-32768,   224,  2050,   947,  5273,-32768,
1204    975,  2050,   949,  2050,-32768,  2050,-32768,-32768,  1037,  1040,
1205 -32768
1206 };
1207
1208 static const short yypgoto[] = {-32768,
1209 -32768,   -54,   157,   660,    16,  -122,   582,-32768,    -3,   319,
1210 -32768,    64,-32768,  1038,   413,-32768,    69,-32768,-32768,   734,
1211    106,   409,-32768,-32768,   997,   979,-32768,  -131,-32768,   898,
1212 -32768,   -79,  -116,   918,  -167,  -194,-32768,-32768,   -64,   285,
1213    805,  -325,  -129,   -90,-32768,-32768,-32768,-32768,-32768,-32768,
1214 -32768,   907,-32768,  -544,-32768,   662,   -20,-32768,-32768,-32768,
1215 -32768,  1011,   561,-32768,   978,-32768,-32768,  -176,-32768,  -127,
1216    813,   784,  -168,  -276,-32768,   769,  -251,    93,  -560,-32768,
1217   -528,-32768,-32768,-32768,  -263,-32768,-32768,-32768,-32768,-32768,
1218 -32768,-32768,-32768,   415,   416,  -632,  -527,-32768,-32768,-32768,
1219 -32768,-32768,-32768,-32768,  -516,-32768,  -667,   770,-32768,-32768,
1220 -32768,-32768,-32768,-32768,-32768,-32768,   511,-32768,   513,-32768,
1221 -32768,-32768,-32768,   186,-32768,-32768,-32768,-32768,  -426,-32768,
1222    736,   126,  -324,  1163,   192,  1197,   283,   379,   507,  -171,
1223    583,   704,  -472,-32768,   602,   603,   481,   601,   696,   698,
1224    695,   710,   703,-32768,   454,   706,   745,-32768,-32768,   936,
1225 -32768
1226 };
1227
1228
1229 #define YYLAST          5757
1230
1231
1232 static const short yytable[] = {    21,
1233    175,   173,    29,   182,   462,   290,   152,    83,   360,   737,
1234    328,   184,    38,   444,   593,   626,   642,   345,   345,   646,
1235    337,   339,   341,   343,   479,    76,   143,   467,   352,   354,
1236    124,   484,   486,   173,   123,   567,   733,   664,    61,    83,
1237    263,    93,    61,   487,   604,   448,   455,   261,   134,   164,
1238     20,   605,   665,   451,   618,   452,   569,    59,    88,   252,
1239     61,    67,   254,   367,   166,    61,   662,    25,    27,    62,
1240    571,    48,    35,    93,    83,   350,   597,    31,   178,    59,
1241    265,   164,   426,   638,    59,    88,   666,   708,   394,    36,
1242     88,    64,   135,   468,   687,    37,   166,   733,   702,    52,
1243     54,    31,   778,    57,   123,    16,    83,    50,   172,  -158,
1244     39,   783,    40,    57,    16,    16,    16,   346,   346,   709,
1245    712,   662,   144,    77,    61,    88,   182,   331,   125,    88,
1246     61,   715,   654,   568,   404,    16,   488,   756,    16,    16,
1247    172,  -104,   110,    59,   584,  -104,   113,   427,   708,    67,
1248    611,   708,   692,   614,   570,    88,    16,    88,    19,   663,
1249    395,   -94,   -94,   464,   434,   631,   401,    89,   572,    49,
1250    283,    50,   412,   661,  -295,   598,   156,   756,    88,   681,
1251    709,   712,   722,   709,   712,   110,   113,   688,   334,   334,
1252    334,   334,   715,   631,    61,   715,   334,   334,   357,    89,
1253    182,   178,   189,   512,   514,   516,   416,   696,   146,   466,
1254    755,   430,   723,   349,   747,   186,   708,   704,    84,   145,
1255    631,   708,   492,   708,   772,   708,   156,   249,   623,   438,
1256    757,   612,   440,   721,   159,   144,   631,   284,   179,   564,
1257    621,   189,   585,    20,   632,    84,   -31,     1,   709,   712,
1258     84,   635,    88,   709,   712,   709,   712,   709,   712,   487,
1259    715,   118,   758,   716,   413,   715,   159,   715,   738,   715,
1260    776,   746,   682,   -25,   -25,   178,   631,   120,    55,   285,
1261    767,    50,    56,    88,   372,    84,   283,   444,   493,    84,
1262      2,    20,   140,   446,   684,   629,    20,   141,   142,   724,
1263    613,   446,   615,   446,   417,   147,   453,     4,   775,   431,
1264    620,   422,   187,     5,   -25,    84,   439,    84,   766,   -25,
1265    -25,   -25,   780,   590,   250,   -25,    88,   718,    61,   -25,
1266    282,    41,   587,   418,   673,   647,   455,   622,    84,    26,
1267    432,   633,   424,    71,   189,     7,   101,    67,   636,   759,
1268    504,   649,   586,   284,   348,   -28,     1,  -257,   356,   319,
1269    284,   179,   156,    20,    20,   320,   444,   117,   284,   683,
1270    284,   334,   334,   334,   334,   334,   334,   334,   334,   334,
1271    334,   334,   334,    88,   334,   334,   334,   334,   334,   334,
1272    334,   685,   643,    42,   189,   285,   706,   -66,   362,     2,
1273     69,   647,   363,   423,   559,    42,   150,   153,    17,   470,
1274      3,   119,    84,   455,   329,   179,     4,    17,    17,    17,
1275    330,    30,     5,    34,    20,  -159,   428,   128,   648,    57,
1276      6,   505,   -30,     1,   425,   179,   459,  -161,    17,    28,
1277    -66,    17,    17,    84,   650,    51,   282,   158,   129,   137,
1278    655,   690,   480,   658,     7,   444,   321,   448,   509,    17,
1279    451,   557,   133,   652,   659,   664,   282,   330,   -34,     1,
1280     90,   284,   -29,     1,   148,   319,     2,   158,   334,   158,
1281    665,   320,   319,   762,   334,   137,    84,     3,   320,   251,
1282    319,    45,   319,     4,   777,   319,   320,   769,   320,     5,
1283     57,   320,    90,   189,   659,   697,   455,   255,    74,   412,
1284     53,   774,     2,   285,   728,   455,     2,   256,   429,   -32,
1285      1,    58,  -323,   182,    20,   706,    66,     3,   460,     4,
1286    762,     7,   769,     4,   774,     5,   260,   160,   500,     5,
1287    -97,   133,   -65,   536,   481,   -97,   -97,   -97,   -97,   156,
1288    510,   739,   322,    46,   741,   653,   660,   283,   134,   -65,
1289    283,   -33,     1,     2,   282,    35,   744,     7,    98,   160,
1290     46,     7,   321,   203,     3,   612,   -97,   121,   -97,   321,
1291      4,   -97,   -97,   -97,   -97,   -65,     5,   321,    37,   321,
1292    -35,     1,   321,   319,   102,    20,   745,   109,   178,   320,
1293    610,   748,   -65,   610,   501,     2,    20,   112,   149,   502,
1294    764,    20,    35,   503,  -323,   347,   151,   154,     7,   334,
1295     35,   334,     4,    20,   284,   100,    78,   284,     5,   176,
1296    183,   332,   106,   344,     2,   122,   334,    36,    78,   283,
1297    630,   698,   368,    37,   446,    99,   631,   631,   188,    88,
1298    103,     4,   500,    20,   461,   327,   371,     5,    80,   156,
1299      7,    81,    20,   402,    78,   283,   285,   131,   322,   285,
1300     80,  -140,     2,    81,    20,   322,   121,   369,    78,    20,
1301    323,   717,    20,   322,   463,   322,   465,   370,   322,     7,
1302    321,   469,    20,    20,   409,   410,    80,     2,   411,    81,
1303     20,    20,    20,    78,    57,   446,   284,   390,   446,   155,
1304     80,   284,   391,    81,    20,    20,   589,   282,   501,    35,
1305    282,   535,   177,   502,     2,    78,   283,   503,   283,   392,
1306     78,   446,   284,    20,   122,    80,    36,    20,    81,    20,
1307     20,    20,    37,    32,   500,   446,   319,   435,   285,   319,
1308    625,   363,   320,   612,   393,   320,   324,    80,   179,   446,
1309     81,    20,    80,    32,   489,    81,    20,    32,   490,    20,
1310     78,    20,   284,   446,   285,   284,    20,   577,   446,   406,
1311    446,   578,   446,   319,    32,   319,   322,   482,   405,   320,
1312    483,   320,  -157,   284,   363,   284,   323,   441,   284,   282,
1313    445,   750,    80,   323,   751,    81,    20,   449,   701,    84,
1314    501,   323,   284,   323,   364,   502,   323,     2,   365,   503,
1315    474,   740,   366,    78,   743,   282,   284,   631,   319,    20,
1316    631,   138,   139,   319,   320,   285,   458,   285,   508,   320,
1317    284,   253,   139,   321,   491,   284,   321,   284,   558,   284,
1318   -342,  -342,  -344,  -344,   319,    80,  -505,  -505,    81,    20,
1319    320,   139,   319,   528,   530,   532,   534,   399,   320,   781,
1320   -506,  -506,   324,   594,   785,   596,   787,   325,   788,   324,
1321    321,   606,   321,   375,   376,   377,   282,   324,   282,   324,
1322    373,   374,   324,   634,   319,   388,   389,   319,   378,   379,
1323    320,   639,  -342,   320,  -344,   640,  -342,   644,  -344,   645,
1324    383,   384,   385,   386,   323,   319,   651,   319,   326,  -352,
1325    319,   320,   -15,   320,  -353,   321,   320,  -504,  -504,   364,
1326    321,   396,   397,   436,   319,  -415,  -415,   437,   677,   322,
1327    320,   661,   322,   671,   380,   381,   382,   678,   319,   387,
1328    679,   321,  -416,  -416,   320,   319,   471,   472,   473,   321,
1329    612,   320,   319,   722,   319,   141,   142,   319,   320,   319,
1330    320,   319,  -373,   320,   735,   320,   322,   320,   322,   518,
1331    520,     2,   522,   524,   526,   598,     2,    78,   539,   541,
1332    324,   321,    78,   325,   321,   749,    79,  -371,     4,  -208,
1333    325,    79,   752,     4,     5,  -504,  -504,   364,   325,     5,
1334    325,   365,   321,   325,   321,   366,   753,   321,   754,    80,
1335    755,   322,    81,    20,    80,   761,   322,    81,    20,   772,
1336    784,   321,   156,   157,   326,   763,   790,   156,   258,   791,
1337    782,   326,   786,   773,   779,   321,   537,   322,    33,   326,
1338     75,   326,   321,   108,   326,   322,   190,     2,   259,   321,
1339    400,   321,    73,    78,   321,   257,   321,   323,   321,   562,
1340    323,   127,    79,   443,     4,   248,   408,     2,   454,   457,
1341      5,   729,   730,    78,   478,   543,   547,   322,   545,   656,
1342    322,   657,    79,   700,     4,    80,   551,     0,    81,    20,
1343      5,     0,   549,   556,   323,     0,   323,     0,   322,    82,
1344    322,   325,     0,   322,     0,    80,     0,   -15,    81,    20,
1345    691,     0,  -504,  -504,   364,     0,     0,   322,   436,   126,
1346      0,     0,   366,     0,  -504,  -504,   364,   358,   248,     0,
1347    485,   322,     0,   324,   366,     0,   324,     0,   322,   323,
1348      0,     0,   326,     0,   323,   322,     0,   322,     0,     0,
1349    322,   -15,   322,     0,   322,     0,  -504,  -504,   364,    78,
1350      0,     0,   436,     0,     0,   323,   641,     0,   196,     0,
1351    324,     0,   324,   323,   197,     0,  -504,  -504,   364,     0,
1352      0,   198,   365,     0,     0,   199,   437,     0,     0,     0,
1353      0,    80,     0,   415,    81,    20,   421,     0,   200,   201,
1354      0,     0,   202,     0,   433,   323,     0,     0,   323,     0,
1355      0,   204,   205,   206,   207,   324,     0,   208,   209,     0,
1356    324,     0,     0,     0,     0,     0,   323,     0,   323,     0,
1357      0,   323,     0,     0,     0,     0,     0,     0,     0,     0,
1358      0,   324,     0,     0,     0,   323,     0,     0,     0,   324,
1359      0,     0,     0,     0,   325,     0,     0,   325,     0,   323,
1360      0,     0,     0,     0,     0,     0,   323,     0,     0,     0,
1361      0,     0,     0,   323,     0,   323,     0,     0,   323,     0,
1362    323,   324,   323,     0,   324,     0,     0,     0,     0,     0,
1363    499,   325,     0,   325,   507,   326,     0,     0,   326,     0,
1364      0,     0,   324,     0,   324,     0,     0,   324,     0,     0,
1365      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1366    554,   324,     0,     0,     0,     0,     0,     0,     0,     0,
1367      0,     0,   326,     0,   326,   324,   325,     0,   566,     0,
1368      0,   325,   324,     0,   335,   335,   335,   335,   574,   324,
1369    576,   324,   335,   335,   324,     0,   324,     0,   324,     0,
1370      0,   499,   325,     0,     0,     0,     0,     0,     0,     0,
1371    325,     0,     0,     0,     0,     0,     0,   326,   336,   336,
1372    336,   336,   326,   601,     0,   603,   336,   336,     0,     0,
1373      0,     0,     0,     0,     0,     0,     0,     0,     0,   609,
1374      0,     0,   325,   326,     0,   325,     0,     0,     0,     0,
1375    499,   326,     0,     0,     0,   248,     0,     0,     0,     0,
1376      0,     0,     0,   325,     0,   325,     0,     0,   325,     0,
1377      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1378      0,     0,   325,   326,     0,     0,   326,     0,     0,     0,
1379      0,     0,     0,     0,     0,     0,   325,     0,     0,     0,
1380      0,     0,     0,   325,   326,     0,   326,     0,     0,   326,
1381    325,     0,   325,     0,     0,   325,     0,   325,     0,   325,
1382      0,     0,     0,   326,     0,     0,     0,     0,     0,     0,
1383      0,     0,     0,     0,     0,     0,     0,   326,     0,     0,
1384      0,     0,     0,     0,   326,     0,     0,     0,     0,     0,
1385      0,   326,     0,   326,     0,     0,   326,     0,   326,     0,
1386    326,     0,     0,     0,     0,     0,     0,   335,   335,   335,
1387    335,   335,   335,   335,   335,   335,   335,   335,   335,     0,
1388    335,   335,   335,   335,   335,   335,   335,     0,     0,     0,
1389      0,     0,     0,     0,   266,     0,   694,     0,     0,     0,
1390      0,   336,   336,   336,   336,   336,   336,   336,   336,   336,
1391    336,   336,   336,     0,   336,   336,   336,   336,   336,   336,
1392    336,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1393    726,     0,     0,     0,     0,     0,   734,     2,   194,   195,
1394    664,   267,   268,    78,   269,     0,     0,   270,     0,     0,
1395      0,   271,   196,     0,     0,   665,     0,     0,   272,   273,
1396      5,   274,     0,   275,   276,   198,   277,     0,     0,   278,
1397      0,     0,     0,     0,   335,    80,   266,     0,    81,    20,
1398    335,     0,     0,     0,     0,     0,   279,     0,   156,   731,
1399      0,     0,   280,     0,     0,   204,   205,   206,   207,     0,
1400      0,   208,   209,     0,     0,     0,     0,     0,   336,     0,
1401      0,     0,     0,   768,   336,     0,     0,   771,     0,     2,
1402    194,   195,   664,   267,   268,    78,   269,     0,     0,   270,
1403      0,     0,     0,   271,   196,     0,     0,   665,     0,     0,
1404    272,   273,     5,   274,     0,   275,   276,   198,   277,     0,
1405     78,   278,     0,     0,     0,     0,     0,    80,     0,   196,
1406     81,    20,     0,     0,     0,   197,     0,     0,   279,     0,
1407    156,   760,   198,     0,   280,     0,   199,   204,   205,   206,
1408    207,     0,    80,   208,   209,    81,    20,     0,     0,   200,
1409    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1410      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1411    266,     0,     0,     0,     0,   335,     0,   335,     0,     0,
1412      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1413      0,     0,   335,     0,     0,     0,     0,     0,     0,     0,
1414      0,     0,     0,     0,     0,     0,     0,     0,     0,   336,
1415      0,   336,     0,     2,   194,   195,  -267,   267,   268,    78,
1416    269,     0,     0,   270,     0,     0,   336,   271,   196,     0,
1417      0,  -267,     0,     0,   272,   273,     5,   274,   266,   275,
1418    276,   198,   277,     0,     0,   278,     0,     0,     0,     0,
1419      0,    80,     0,     0,    81,    20,     0,     0,     0,     0,
1420      0,     0,   279,     0,   156,  -267,     0,     0,   280,     0,
1421      0,   204,   205,   206,   207,     0,     0,   208,   209,     0,
1422      0,     2,   194,   195,     0,   267,   268,    78,   269,     0,
1423      0,   270,     0,     0,     0,   271,   196,     0,     0,     0,
1424      0,     0,   272,   273,     5,   274,   266,   275,   276,   198,
1425    277,     0,     0,   278,     0,     0,     0,     0,     0,    80,
1426      0,     0,    81,    20,     0,     0,     0,     0,     0,     0,
1427    279,     0,   156,   442,     0,     0,   280,     0,     0,   204,
1428    205,   206,   207,     0,     0,   208,   209,     0,     0,     2,
1429    194,   195,     0,   267,   268,    78,   269,     0,     0,   270,
1430      0,     0,     0,   271,   196,     0,     0,     0,     0,     0,
1431    272,   273,     5,   274,   266,   275,   276,   198,   277,     0,
1432      0,   278,     0,     0,     0,     0,     0,    80,     0,     0,
1433     81,    20,     0,     0,     0,     0,     0,     0,   279,     0,
1434    156,     0,     0,     0,   280,     0,     0,   204,   205,   206,
1435    207,     0,     0,   208,   209,     0,     0,     2,   194,   195,
1436      0,   267,   268,    78,   269,     0,     0,   270,     0,     0,
1437      0,   271,   196,     0,     0,     0,     0,     0,   272,   273,
1438    266,   274,     0,   275,   276,   198,   277,     0,     0,   278,
1439      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1440      0,     0,     0,     0,     0,     0,   279,     0,   156,     0,
1441      0,     0,   280,     0,     0,   204,   205,   206,   207,     0,
1442      0,   208,   209,     2,   194,   195,     0,   705,   268,    78,
1443    269,     0,     0,   270,     0,     0,     0,   271,   196,     0,
1444      0,     0,     0,     0,   272,   273,     0,   274,     0,   275,
1445    276,   198,   277,     0,   627,   278,   192,   193,     0,     0,
1446      0,    80,     0,     0,    81,    20,     0,     0,     0,     0,
1447      0,     0,   279,     0,   156,     0,     0,     0,   280,     0,
1448      0,   204,   205,   206,   207,     0,     0,   208,   209,     0,
1449      0,     0,     0,     0,     0,     0,     0,     0,   194,   195,
1450      0,     0,     0,    78,     0,     0,     0,     0,     0,     0,
1451      0,     0,   196,     0,     0,     0,     0,     0,   197,   191,
1452      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1453      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1454      0,     0,   200,   201,     0,     0,   202,     0,   203,   628,
1455      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1456      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1457    419,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1458      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1459    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1460     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1461      0,   202,     0,   203,   194,   195,     0,     0,     0,    78,
1462    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1463      0,     0,     0,     0,   197,   497,     0,   192,   193,     0,
1464      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1465      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1466      0,     0,   202,     0,     0,     0,     0,     0,   420,     0,
1467      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1468    195,     0,     0,     0,    78,     0,   552,     0,   192,   193,
1469      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1470      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1471    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1472     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1473    194,   195,   498,     0,     0,    78,   204,   205,   206,   207,
1474      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1475    197,   497,     0,   192,   193,     0,     0,   198,     0,     0,
1476      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1477     81,    20,     0,   553,   200,   201,     0,     0,   202,     0,
1478      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1479    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1480     78,     0,   591,     0,   192,   193,     0,     0,     0,   196,
1481      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1482      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1483      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1484    201,     0,     0,   202,     0,     0,   194,   195,   588,     0,
1485      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1486    196,     0,     0,     0,     0,     0,   197,   599,     0,   192,
1487    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1488      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1489    200,   201,     0,     0,   202,   592,     0,     0,     0,     0,
1490      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1491    209,   194,   195,     0,     0,     0,    78,     0,   607,     0,
1492    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1493      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1494      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1495      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1496      0,     0,   194,   195,     0,   600,     0,    78,   204,   205,
1497    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1498      0,     0,   197,   616,     0,   192,   193,     0,     0,   198,
1499      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1500      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1501    202,     0,     0,     0,     0,   608,     0,     0,     0,   204,
1502    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1503      0,     0,    78,     0,   497,     0,   192,   193,     0,     0,
1504      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1505      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1506      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1507      0,   200,   201,     0,     0,   202,   617,     0,   194,   195,
1508      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1509    208,   209,   196,     0,     0,     0,     0,     0,   197,   591,
1510      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1511      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1512      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1513      0,   624,     0,     0,     0,   204,   205,   206,   207,     0,
1514      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1515    719,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1516      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1517    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1518     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1519      0,   202,   703,     0,   194,   195,     0,     0,     0,    78,
1520    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1521      0,     0,     0,     0,   197,   719,     0,   192,   193,     0,
1522      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1523      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1524      0,     0,   202,   720,     0,     0,     0,     0,     0,     0,
1525      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1526    195,     0,     0,     0,    78,     0,   599,     0,   192,   193,
1527      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1528      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1529    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1530     20,     0,     0,   200,   201,     0,     0,   202,   765,     0,
1531    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1532      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1533    197,   333,     0,   192,   193,     0,     0,   198,     0,     0,
1534      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1535     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1536      0,     0,     0,     0,   770,     0,     0,   204,   205,   206,
1537    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1538     78,     0,   338,     0,   192,   193,     0,     0,     0,   196,
1539      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1540      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1541      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1542    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1543      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1544    196,     0,     0,     0,     0,     0,   197,   340,     0,   192,
1545    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1546      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1547    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1548      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1549    209,   194,   195,     0,     0,     0,    78,     0,   342,     0,
1550    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1551      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1552      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1553      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1554      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1555    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1556      0,     0,   197,   351,     0,   192,   193,     0,     0,   198,
1557      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1558      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1559    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1560    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1561      0,     0,    78,     0,   353,     0,   192,   193,     0,     0,
1562      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1563      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1564      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1565      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1566      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1567    208,   209,   196,     0,     0,     0,     0,     0,   197,   355,
1568      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1569      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1570      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1571      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1572      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1573    414,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1574      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1575    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1576     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1577      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1578    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1579      0,     0,     0,     0,   197,   506,     0,   192,   193,     0,
1580      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1581      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1582      0,     0,   202,     0,     0,     0,     0,     0,     0,     0,
1583      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1584    195,     0,     0,     0,    78,     0,   511,     0,   192,   193,
1585      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1586      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1587    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1588     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1589    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1590      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1591    197,   513,     0,   192,   193,     0,     0,   198,     0,     0,
1592      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1593     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1594      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1595    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1596     78,     0,   515,     0,   192,   193,     0,     0,     0,   196,
1597      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1598      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1599      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1600    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1601      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1602    196,     0,     0,     0,     0,     0,   197,   517,     0,   192,
1603    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1604      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1605    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1606      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1607    209,   194,   195,     0,     0,     0,    78,     0,   519,     0,
1608    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1609      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1610      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1611      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1612      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1613    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1614      0,     0,   197,   521,     0,   192,   193,     0,     0,   198,
1615      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1616      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1617    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1618    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1619      0,     0,    78,     0,   523,     0,   192,   193,     0,     0,
1620      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1621      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1622      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1623      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1624      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1625    208,   209,   196,     0,     0,     0,     0,     0,   197,   525,
1626      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1627      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1628      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1629      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1630      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1631    527,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1632      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1633    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1634     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1635      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1636    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1637      0,     0,     0,     0,   197,   529,     0,   192,   193,     0,
1638      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1639      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1640      0,     0,   202,     0,     0,     0,     0,     0,     0,     0,
1641      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1642    195,     0,     0,     0,    78,     0,   531,     0,   192,   193,
1643      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1644      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1645    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1646     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1647    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1648      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1649    197,   533,     0,   192,   193,     0,     0,   198,     0,     0,
1650      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1651     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1652      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1653    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1654     78,     0,   538,     0,   192,   193,     0,     0,     0,   196,
1655      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1656      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1657      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1658    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1659      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1660    196,     0,     0,     0,     0,     0,   197,   540,     0,   192,
1661    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1662      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1663    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1664      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1665    209,   194,   195,     0,     0,     0,    78,     0,   542,     0,
1666    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1667      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1668      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1669      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1670      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1671    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1672      0,     0,   197,   544,     0,   192,   193,     0,     0,   198,
1673      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1674      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1675    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1676    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1677      0,     0,    78,     0,   546,     0,   192,   193,     0,     0,
1678      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1679      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1680      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1681      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1682      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1683    208,   209,   196,     0,     0,     0,     0,     0,   197,   548,
1684      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1685      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1686      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1687      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1688      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1689    550,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1690      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1691    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1692     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1693      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1694    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1695      0,     0,     0,     0,   197,   555,     0,   192,   193,     0,
1696      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1697      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1698      0,     0,   202,     0,     0,     0,     0,     0,     0,     0,
1699      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1700    195,     0,     0,     0,    78,     0,   565,     0,   192,   193,
1701      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1702      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1703    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1704     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1705    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1706      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1707    197,   573,     0,   192,   193,     0,     0,   198,     0,     0,
1708      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1709     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1710      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1711    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1712     78,     0,   575,     0,   192,   193,     0,     0,     0,   196,
1713      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1714      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1715      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1716    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1717      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1718    196,     0,     0,     0,     0,     0,   197,   602,     0,   192,
1719    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1720      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1721    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1722      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1723    209,   194,   195,     0,     0,     0,    78,     0,   619,     0,
1724    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1725      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1726      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1727      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1728      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1729    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1730      0,     0,   197,   689,     0,   192,   193,     0,     0,   198,
1731      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1732      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1733    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1734    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1735      0,     0,    78,     0,   693,     0,   192,   193,     0,     0,
1736      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1737      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1738      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1739      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1740      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1741    208,   209,   196,     0,     0,     0,     0,     0,   197,   699,
1742      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1743      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1744      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1745      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1746      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1747    725,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1748      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1749    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1750     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1751      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1752    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1753      0,     0,     0,     0,   197,     0,   583,     0,     0,     0,
1754      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1755      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1756      0,   674,   202,     0,     0,     0,     0,     0,     0,     0,
1757      0,   204,   205,   206,   207,     0,     0,   208,   209,  -290,
1758   -290,  -290,     0,     0,     0,  -290,     0,     0,     0,     0,
1759      0,     0,     0,     0,  -290,     0,     0,     0,     0,     0,
1760   -290,     0,     0,   736,     0,   194,   195,  -290,     0,     0,
1761     78,  -290,     0,     0,     0,     0,     0,  -290,     0,   196,
1762   -290,  -290,     0,     0,     0,   197,     0,     0,  -290,     0,
1763    192,   193,   198,     0,  -290,     0,   199,  -290,  -290,  -290,
1764   -290,     0,    80,  -290,  -290,    81,    20,   194,   195,     0,
1765      0,     0,    78,   279,  -298,     0,     0,     0,     0,     0,
1766      0,   196,   204,   205,   206,   207,     0,   197,   208,   209,
1767    672,     0,   194,   195,   198,     0,     0,    78,   199,     0,
1768      0,     0,     0,     0,    80,     0,   196,    81,    20,     0,
1769      0,     0,   197,     0,     0,   279,  -298,   192,   193,   198,
1770      0,     0,     0,   199,   204,   205,   206,   207,     0,    80,
1771    208,   209,    81,    20,   194,   195,   200,   201,     0,    78,
1772    202,     0,   203,   359,     0,     0,     0,     0,   196,   204,
1773    205,   206,   207,     0,   197,   208,   209,     0,     0,   194,
1774    195,   198,     0,     0,    78,   199,     0,     0,   192,   193,
1775      0,    80,     0,   196,    81,    20,     0,     0,     0,   197,
1776      0,     0,   279,     0,     0,     0,   198,     0,     0,     0,
1777    199,   204,   205,   206,   207,     0,    80,   208,   209,    81,
1778     20,     0,     0,   200,   201,     0,     0,   202,   494,     0,
1779    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1780      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1781    197,     0,     0,   192,   193,     0,     0,   198,     0,     0,
1782      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1783     81,    20,     0,     0,   200,   201,     0,     0,   202,   637,
1784      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1785    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1786     78,     0,     0,     0,   192,   193,     0,     0,     0,   196,
1787      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1788      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1789      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1790    201,     0,     0,   202,   680,     0,   194,   195,     0,     0,
1791      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1792    196,     0,     0,     0,     0,     0,   197,     0,     0,   192,
1793    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1794      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1795    200,   201,     0,     0,   202,   695,     0,     0,     0,     0,
1796      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1797    209,   194,   195,     0,     0,     0,    78,     0,     0,     0,
1798      0,     0,     0,     0,     0,   196,     0,     0,     0,     0,
1799      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1800      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1801      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1802      0,     2,   194,   195,     0,     0,     0,    78,   204,   205,
1803    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1804      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1805      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1806      0,     0,    81,    20,     0,     0,     0,     0,     0,     0,
1807    279,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1808    205,   206,   207,     0,     0,   208,   209
1809 };
1810
1811 static const short yycheck[] = {     3,
1812    132,   129,     6,   133,   330,   174,   123,    62,   203,   677,
1813    178,   134,     1,   290,   441,   488,   561,     1,     1,   564,
1814    192,   193,   194,   195,   349,     1,   117,     1,   200,   201,
1815      1,   356,   357,   161,    89,     1,   669,    47,    42,    94,
1816    168,    62,    46,     1,    94,   297,   310,     1,    53,   129,
1817     86,   101,    62,   305,   481,   307,     1,    42,    62,   150,
1818     64,    46,   153,     1,   129,    69,     1,     4,     5,    95,
1819      1,     1,    44,    94,   129,   198,     1,     9,   133,    64,
1820    171,   161,     1,   510,    69,    89,    96,   648,    15,    61,
1821     94,   100,    97,    67,     1,    67,   161,   730,   643,    36,
1822     37,    33,   770,    40,   159,     0,   161,   101,   129,    93,
1823     99,   779,   101,    50,     9,    10,    11,   101,   101,   648,
1824    648,     1,     1,    99,   128,   129,   256,   182,    99,   133,
1825    134,   648,     1,    99,   262,    30,    94,     1,    33,    34,
1826    161,    95,    79,   128,     1,    99,    83,   275,   709,   134,
1827    475,   712,   625,   478,    99,   159,    51,   161,     1,    94,
1828     87,    99,   100,   331,   281,   100,   257,    62,    99,    99,
1829    174,   101,     1,     1,    99,   100,    95,     1,   182,   606,
1830    709,   709,     1,   712,   712,   122,   123,    94,   192,   193,
1831    194,   195,   709,   100,   198,   712,   200,   201,   202,    94,
1832    330,   256,   139,   375,   376,   377,     1,   634,     1,   332,
1833      1,     1,     1,   198,    94,     1,   777,   644,    62,    98,
1834    100,   782,     1,   784,     1,   786,    95,     1,    94,     1,
1835     94,    97,   287,   660,   129,     1,   100,   174,   133,   408,
1836      1,   178,    99,    86,     1,    89,     0,     1,   777,   777,
1837     94,     1,   256,   782,   782,   784,   784,   786,   786,     1,
1838    777,    97,     1,     1,    93,   782,   161,   784,     1,   786,
1839     94,    99,     1,    45,    46,   330,   100,    97,     1,   174,
1840     99,   101,     5,   287,   221,   129,   290,   564,    67,   133,
1841     44,    86,    92,   297,     1,   490,    86,    97,    98,    88,
1842    477,   305,   479,   307,    99,    98,   310,    61,    99,    99,
1843    482,     1,    98,    67,    86,   159,    88,   161,   745,    91,
1844     92,    93,    99,   440,    98,    97,   330,   653,   332,   101,
1845    174,     1,    98,   270,   598,     1,   600,    98,   182,     1,
1846    277,    98,     1,     1,   281,    99,     1,   332,    98,    88,
1847     72,     1,    94,   290,   198,     0,     1,    95,   202,   174,
1848    297,   256,    95,    86,    86,   174,   643,    83,   305,    98,
1849    307,   375,   376,   377,   378,   379,   380,   381,   382,   383,
1850    384,   385,   386,   387,   388,   389,   390,   391,   392,   393,
1851    394,    98,   561,    63,   331,   290,   648,    52,    97,    44,
1852     52,     1,   101,    93,   408,    63,   122,   123,     0,   346,
1853     55,    97,   256,   677,    94,   310,    61,     9,    10,    11,
1854    100,     9,    67,    11,    86,    95,     1,   100,    94,   366,
1855     75,   368,     0,     1,    93,   330,     1,    95,    30,     1,
1856     95,    33,    34,   287,    94,    33,   290,   129,    95,     1,
1857    578,   623,     1,   581,    99,   732,   174,   709,     1,    51,
1858    712,    94,    93,     1,     1,    47,   310,   100,     0,     1,
1859     62,   408,     0,     1,    98,   290,    44,   159,   482,   161,
1860     62,   290,   297,   735,   488,     1,   330,    55,   297,     1,
1861    305,     1,   307,    61,    94,   310,   305,   749,   307,    67,
1862    437,   310,    94,   440,     1,   637,   770,    96,     1,     1,
1863      1,   763,    44,   408,    96,   779,    44,    93,    93,     0,
1864      1,     1,     1,   653,    86,   777,     1,    55,    93,    61,
1865    782,    99,   784,    61,   786,    67,    99,   129,     1,    67,
1866     92,    93,    52,   387,    93,    97,    98,    99,   100,    95,
1867     93,   679,   174,    63,   686,    93,    93,   561,    53,    52,
1868    564,     0,     1,    44,   408,    44,   698,    99,     1,   161,
1869     63,    99,   290,    95,    55,    97,    92,     1,    94,   297,
1870     61,    97,    98,    99,   100,    95,    67,   305,    67,   307,
1871      0,     1,   310,   408,     1,    86,    93,     1,   653,   408,
1872    475,    93,    95,   478,    67,    44,    86,     1,     1,    72,
1873    742,    86,    44,    76,    93,     1,     1,     1,    99,   623,
1874     44,   625,    61,    86,   561,    65,    50,   564,    67,     1,
1875      1,   100,    72,   101,    44,    59,   640,    61,    50,   643,
1876     94,    94,   101,    67,   648,    64,   100,   100,     1,   653,
1877     69,    61,     1,    86,     1,     1,     1,    67,    82,    95,
1878     99,    85,    86,    99,    50,   669,   561,   107,   290,   564,
1879     82,    95,    44,    85,    86,   297,     1,    97,    50,    86,
1880    174,     1,    86,   305,     1,   307,     1,   101,   310,    99,
1881    408,     1,    86,    86,    95,    96,    82,    44,    99,    85,
1882     86,    86,    86,    50,   641,   709,   643,    11,   712,   128,
1883     82,   648,    12,    85,    86,    86,    65,   561,    67,    44,
1884    564,     1,    94,    72,    44,    50,   730,    76,   732,    13,
1885     50,   735,   669,    86,    59,    82,    61,    86,    85,    86,
1886     86,    86,    67,    10,     1,   749,   561,    97,   643,   564,
1887     94,   101,   561,    97,    14,   564,   174,    82,   653,   763,
1888     85,    86,    82,    30,    96,    85,    86,    34,   100,    86,
1889     50,    86,   709,   777,   669,   712,    86,    60,   782,    95,
1890    784,    64,   786,   598,    51,   600,   408,    94,    99,   598,
1891     97,   600,    93,   730,   101,   732,   290,    93,   735,   643,
1892     99,   709,    82,   297,   712,    85,    86,    99,    65,   653,
1893     67,   305,   749,   307,    93,    72,   310,    44,    97,    76,
1894     97,    94,   101,    50,    94,   669,   763,   100,   643,    86,
1895    100,    99,   100,   648,   643,   730,    99,   732,    67,   648,
1896    777,    99,   100,   561,    98,   782,   564,   784,    99,   786,
1897     45,    46,    45,    46,   669,    82,    91,    92,    85,    86,
1898    669,   100,   677,   383,   384,   385,   386,    94,   677,   777,
1899     91,    92,   290,    95,   782,    66,   784,   174,   786,   297,
1900    598,    93,   600,     5,     6,     7,   730,   305,   732,   307,
1901     45,    46,   310,    93,   709,    16,    17,   712,     3,     4,
1902    709,     1,    97,   712,    97,    88,   101,    93,   101,    99,
1903     18,    19,    20,    21,   408,   730,    94,   732,   174,   101,
1904    735,   730,    86,   732,   101,   643,   735,    91,    92,    93,
1905    648,    91,    92,    97,   749,    45,    46,   101,    99,   561,
1906    749,     1,   564,    93,     8,     9,    10,    94,   763,    57,
1907     94,   669,    45,    46,   763,   770,    97,    98,    99,   677,
1908     97,   770,   777,     1,   779,    97,    98,   782,   777,   784,
1909    779,   786,    95,   782,    94,   784,   598,   786,   600,   378,
1910    379,    44,   380,   381,   382,   100,    44,    50,   388,   389,
1911    408,   709,    50,   290,   712,    56,    59,    95,    61,    56,
1912    297,    59,    99,    61,    67,    91,    92,    93,   305,    67,
1913    307,    97,   730,   310,   732,   101,    94,   735,    94,    82,
1914      1,   643,    85,    86,    82,    94,   648,    85,    86,     1,
1915     56,   749,    95,    96,   290,    94,     0,    95,    96,     0,
1916     94,   297,    94,    99,    99,   763,   387,   669,    11,   305,
1917     54,   307,   770,    75,   310,   677,   139,    44,   161,   777,
1918    256,   779,    52,    50,   782,   159,   784,   561,   786,   408,
1919    564,    94,    59,   290,    61,   140,   264,    44,   310,   310,
1920     67,   667,   667,    50,   349,   390,   392,   709,   391,   579,
1921    712,   579,    59,   640,    61,    82,   394,    -1,    85,    86,
1922     67,    -1,   393,   398,   598,    -1,   600,    -1,   730,    96,
1923    732,   408,    -1,   735,    -1,    82,    -1,    86,    85,    86,
1924      1,    -1,    91,    92,    93,    -1,    -1,   749,    97,    96,
1925     -1,    -1,   101,    -1,    91,    92,    93,   202,   203,    -1,
1926     97,   763,    -1,   561,   101,    -1,   564,    -1,   770,   643,
1927     -1,    -1,   408,    -1,   648,   777,    -1,   779,    -1,    -1,
1928    782,    86,   784,    -1,   786,    -1,    91,    92,    93,    50,
1929     -1,    -1,    97,    -1,    -1,   669,   101,    -1,    59,    -1,
1930    598,    -1,   600,   677,    65,    -1,    91,    92,    93,    -1,
1931     -1,    72,    97,    -1,    -1,    76,   101,    -1,    -1,    -1,
1932     -1,    82,    -1,   268,    85,    86,   271,    -1,    89,    90,
1933     -1,    -1,    93,    -1,   279,   709,    -1,    -1,   712,    -1,
1934     -1,   102,   103,   104,   105,   643,    -1,   108,   109,    -1,
1935    648,    -1,    -1,    -1,    -1,    -1,   730,    -1,   732,    -1,
1936     -1,   735,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1937     -1,   669,    -1,    -1,    -1,   749,    -1,    -1,    -1,   677,
1938     -1,    -1,    -1,    -1,   561,    -1,    -1,   564,    -1,   763,
1939     -1,    -1,    -1,    -1,    -1,    -1,   770,    -1,    -1,    -1,
1940     -1,    -1,    -1,   777,    -1,   779,    -1,    -1,   782,    -1,
1941    784,   709,   786,    -1,   712,    -1,    -1,    -1,    -1,    -1,
1942    365,   598,    -1,   600,   369,   561,    -1,    -1,   564,    -1,
1943     -1,    -1,   730,    -1,   732,    -1,    -1,   735,    -1,    -1,
1944     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1945    395,   749,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1946     -1,    -1,   598,    -1,   600,   763,   643,    -1,   413,    -1,
1947     -1,   648,   770,    -1,   192,   193,   194,   195,   423,   777,
1948    425,   779,   200,   201,   782,    -1,   784,    -1,   786,    -1,
1949     -1,   436,   669,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1950    677,    -1,    -1,    -1,    -1,    -1,    -1,   643,   192,   193,
1951    194,   195,   648,   458,    -1,   460,   200,   201,    -1,    -1,
1952     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   474,
1953     -1,    -1,   709,   669,    -1,   712,    -1,    -1,    -1,    -1,
1954    485,   677,    -1,    -1,    -1,   490,    -1,    -1,    -1,    -1,
1955     -1,    -1,    -1,   730,    -1,   732,    -1,    -1,   735,    -1,
1956     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1957     -1,    -1,   749,   709,    -1,    -1,   712,    -1,    -1,    -1,
1958     -1,    -1,    -1,    -1,    -1,    -1,   763,    -1,    -1,    -1,
1959     -1,    -1,    -1,   770,   730,    -1,   732,    -1,    -1,   735,
1960    777,    -1,   779,    -1,    -1,   782,    -1,   784,    -1,   786,
1961     -1,    -1,    -1,   749,    -1,    -1,    -1,    -1,    -1,    -1,
1962     -1,    -1,    -1,    -1,    -1,    -1,    -1,   763,    -1,    -1,
1963     -1,    -1,    -1,    -1,   770,    -1,    -1,    -1,    -1,    -1,
1964     -1,   777,    -1,   779,    -1,    -1,   782,    -1,   784,    -1,
1965    786,    -1,    -1,    -1,    -1,    -1,    -1,   375,   376,   377,
1966    378,   379,   380,   381,   382,   383,   384,   385,   386,    -1,
1967    388,   389,   390,   391,   392,   393,   394,    -1,    -1,    -1,
1968     -1,    -1,    -1,    -1,     1,    -1,   631,    -1,    -1,    -1,
1969     -1,   375,   376,   377,   378,   379,   380,   381,   382,   383,
1970    384,   385,   386,    -1,   388,   389,   390,   391,   392,   393,
1971    394,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1972    665,    -1,    -1,    -1,    -1,    -1,   671,    44,    45,    46,
1973     47,    48,    49,    50,    51,    -1,    -1,    54,    -1,    -1,
1974     -1,    58,    59,    -1,    -1,    62,    -1,    -1,    65,    66,
1975     67,    68,    -1,    70,    71,    72,    73,    -1,    -1,    76,
1976     -1,    -1,    -1,    -1,   482,    82,     1,    -1,    85,    86,
1977    488,    -1,    -1,    -1,    -1,    -1,    93,    -1,    95,    96,
1978     -1,    -1,    99,    -1,    -1,   102,   103,   104,   105,    -1,
1979     -1,   108,   109,    -1,    -1,    -1,    -1,    -1,   482,    -1,
1980     -1,    -1,    -1,   748,   488,    -1,    -1,   752,    -1,    44,
1981     45,    46,    47,    48,    49,    50,    51,    -1,    -1,    54,
1982     -1,    -1,    -1,    58,    59,    -1,    -1,    62,    -1,    -1,
1983     65,    66,    67,    68,    -1,    70,    71,    72,    73,    -1,
1984     50,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    59,
1985     85,    86,    -1,    -1,    -1,    65,    -1,    -1,    93,    -1,
1986     95,    96,    72,    -1,    99,    -1,    76,   102,   103,   104,
1987    105,    -1,    82,   108,   109,    85,    86,    -1,    -1,    89,
1988     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
1989     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
1990      1,    -1,    -1,    -1,    -1,   623,    -1,   625,    -1,    -1,
1991     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1992     -1,    -1,   640,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1993     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   623,
1994     -1,   625,    -1,    44,    45,    46,    47,    48,    49,    50,
1995     51,    -1,    -1,    54,    -1,    -1,   640,    58,    59,    -1,
1996     -1,    62,    -1,    -1,    65,    66,    67,    68,     1,    70,
1997     71,    72,    73,    -1,    -1,    76,    -1,    -1,    -1,    -1,
1998     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,
1999     -1,    -1,    93,    -1,    95,    96,    -1,    -1,    99,    -1,
2000     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    -1,
2001     -1,    44,    45,    46,    -1,    48,    49,    50,    51,    -1,
2002     -1,    54,    -1,    -1,    -1,    58,    59,    -1,    -1,    -1,
2003     -1,    -1,    65,    66,    67,    68,     1,    70,    71,    72,
2004     73,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2005     -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,
2006     93,    -1,    95,    96,    -1,    -1,    99,    -1,    -1,   102,
2007    103,   104,   105,    -1,    -1,   108,   109,    -1,    -1,    44,
2008     45,    46,    -1,    48,    49,    50,    51,    -1,    -1,    54,
2009     -1,    -1,    -1,    58,    59,    -1,    -1,    -1,    -1,    -1,
2010     65,    66,    67,    68,     1,    70,    71,    72,    73,    -1,
2011     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2012     85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    93,    -1,
2013     95,    -1,    -1,    -1,    99,    -1,    -1,   102,   103,   104,
2014    105,    -1,    -1,   108,   109,    -1,    -1,    44,    45,    46,
2015     -1,    48,    49,    50,    51,    -1,    -1,    54,    -1,    -1,
2016     -1,    58,    59,    -1,    -1,    -1,    -1,    -1,    65,    66,
2017      1,    68,    -1,    70,    71,    72,    73,    -1,    -1,    76,
2018     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2019     -1,    -1,    -1,    -1,    -1,    -1,    93,    -1,    95,    -1,
2020     -1,    -1,    99,    -1,    -1,   102,   103,   104,   105,    -1,
2021     -1,   108,   109,    44,    45,    46,    -1,    48,    49,    50,
2022     51,    -1,    -1,    54,    -1,    -1,    -1,    58,    59,    -1,
2023     -1,    -1,    -1,    -1,    65,    66,    -1,    68,    -1,    70,
2024     71,    72,    73,    -1,     1,    76,     3,     4,    -1,    -1,
2025     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,
2026     -1,    -1,    93,    -1,    95,    -1,    -1,    -1,    99,    -1,
2027     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    -1,
2028     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    45,    46,
2029     -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,
2030     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2031     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2032     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2033     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    95,    96,
2034     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2035     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2036      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2037     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2038     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2039     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2040     -1,    93,    -1,    95,    45,    46,    -1,    -1,    -1,    50,
2041    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2042     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2043     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2044     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2045     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    99,    -1,
2046     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2047     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2048     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2049     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2050     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2051     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2052     45,    46,    98,    -1,    -1,    50,   102,   103,   104,   105,
2053     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2054     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2055     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2056     85,    86,    -1,    88,    89,    90,    -1,    -1,    93,    -1,
2057     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2058    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2059     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2060     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2061     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2062     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2063     90,    -1,    -1,    93,    -1,    -1,    45,    46,    98,    -1,
2064     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2065     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2066      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2067     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2068     89,    90,    -1,    -1,    93,    94,    -1,    -1,    -1,    -1,
2069     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2070    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2071      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2072     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2073     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2074     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2075     -1,    -1,    45,    46,    -1,    99,    -1,    50,   102,   103,
2076    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2077     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2078     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2079     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2080     93,    -1,    -1,    -1,    -1,    98,    -1,    -1,    -1,   102,
2081    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2082     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2083     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2084     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2085     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2086     -1,    89,    90,    -1,    -1,    93,    94,    -1,    45,    46,
2087     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2088    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2089     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2090     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2091     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2092     -1,    98,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2093     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2094      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2095     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2096     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2097     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2098     -1,    93,    94,    -1,    45,    46,    -1,    -1,    -1,    50,
2099    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2100     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2101     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2102     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2103     -1,    -1,    93,    94,    -1,    -1,    -1,    -1,    -1,    -1,
2104     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2105     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2106     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2107     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2108     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2109     86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,    -1,
2110     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2111     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2112     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2113     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2114     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2115     -1,    -1,    -1,    -1,    99,    -1,    -1,   102,   103,   104,
2116    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2117     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2118     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2119     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2120     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2121     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2122     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2123     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2124      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2125     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2126     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2127     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2128    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2129      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2130     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2131     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2132     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2133     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2134    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2135     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2136     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2137     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2138     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2139    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2140     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2141     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2142     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2143     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2144     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2145     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2146    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2147     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2148     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2149     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2150     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2151     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2152      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2153     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2154     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2155     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2156     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2157    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2158     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2159     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2160     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2161     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2162     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2163     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2164     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2165     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2166     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2167     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2168     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2169     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2170     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2171     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2172     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2173     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2174    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2175     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2176     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2177     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2178     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2179     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2180     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2181     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2182      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2183     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2184     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2185     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2186    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2187      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2188     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2189     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2190     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2191     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2192    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2193     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2194     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2195     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2196     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2197    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2198     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2199     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2200     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2201     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2202     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2203     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2204    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2205     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2206     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2207     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2208     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2209     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2210      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2211     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2212     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2213     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2214     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2215    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2216     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2217     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2218     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2219     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2220     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2221     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2222     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2223     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2224     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2225     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2226     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2227     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2228     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2229     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2230     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2231     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2232    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2233     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2234     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2235     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2236     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2237     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2238     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2239     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2240      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2241     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2242     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2243     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2244    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2245      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2246     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2247     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2248     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2249     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2250    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2251     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2252     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2253     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2254     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2255    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2256     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2257     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2258     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2259     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2260     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2261     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2262    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2263     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2264     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2265     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2266     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2267     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2268      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2269     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2270     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2271     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2272     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2273    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2274     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2275     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2276     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2277     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2278     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2279     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2280     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2281     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2282     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2283     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2284     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2285     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2286     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2287     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2288     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2289     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2290    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2291     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2292     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2293     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2294     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2295     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2296     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2297     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2298      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2299     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2300     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2301     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2302    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2303      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2304     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2305     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2306     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2307     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2308    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2309     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2310     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2311     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2312     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2313    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2314     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2315     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2316     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2317     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2318     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2319     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2320    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2321     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2322     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2323     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2324     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2325     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2326      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2327     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2328     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2329     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2330     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2331    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2332     -1,    -1,    -1,    -1,    65,    -1,     1,    -1,    -1,    -1,
2333     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2334     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2335     -1,     1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2336     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    44,
2337     45,    46,    -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,
2338     -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
2339     65,    -1,    -1,     1,    -1,    45,    46,    72,    -1,    -1,
2340     50,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    59,
2341     85,    86,    -1,    -1,    -1,    65,    -1,    -1,    93,    -1,
2342      3,     4,    72,    -1,    99,    -1,    76,   102,   103,   104,
2343    105,    -1,    82,   108,   109,    85,    86,    45,    46,    -1,
2344     -1,    -1,    50,    93,    94,    -1,    -1,    -1,    -1,    -1,
2345     -1,    59,   102,   103,   104,   105,    -1,    65,   108,   109,
2346      1,    -1,    45,    46,    72,    -1,    -1,    50,    76,    -1,
2347     -1,    -1,    -1,    -1,    82,    -1,    59,    85,    86,    -1,
2348     -1,    -1,    65,    -1,    -1,    93,    94,     3,     4,    72,
2349     -1,    -1,    -1,    76,   102,   103,   104,   105,    -1,    82,
2350    108,   109,    85,    86,    45,    46,    89,    90,    -1,    50,
2351     93,    -1,    95,    96,    -1,    -1,    -1,    -1,    59,   102,
2352    103,   104,   105,    -1,    65,   108,   109,    -1,    -1,    45,
2353     46,    72,    -1,    -1,    50,    76,    -1,    -1,     3,     4,
2354     -1,    82,    -1,    59,    85,    86,    -1,    -1,    -1,    65,
2355     -1,    -1,    93,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2356     76,   102,   103,   104,   105,    -1,    82,   108,   109,    85,
2357     86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,    -1,
2358     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2359     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2360     65,    -1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2361     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2362     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,
2363     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2364    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2365     50,    -1,    -1,    -1,     3,     4,    -1,    -1,    -1,    59,
2366     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2367     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2368     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2369     90,    -1,    -1,    93,    94,    -1,    45,    46,    -1,    -1,
2370     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2371     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,     3,
2372      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2373     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2374     89,    90,    -1,    -1,    93,    94,    -1,    -1,    -1,    -1,
2375     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2376    109,    45,    46,    -1,    -1,    -1,    50,    -1,    -1,    -1,
2377     -1,    -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2378     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2379     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2380     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2381     -1,    44,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2382    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2383     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
2384     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2385     -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,
2386     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2387    103,   104,   105,    -1,    -1,   108,   109
2388 };
2389 #define YYPURE 1
2390
2391 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
2392 #line 3 "/usr/lib/bison.simple"
2393 /* This file comes from bison-1.28.  */
2394
2395 /* Skeleton output parser for bison,
2396    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2397
2398    This program is free software; you can redistribute it and/or modify
2399    it under the terms of the GNU General Public License as published by
2400    the Free Software Foundation; either version 2, or (at your option)
2401    any later version.
2402
2403    This program is distributed in the hope that it will be useful,
2404    but WITHOUT ANY WARRANTY; without even the implied warranty of
2405    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2406    GNU General Public License for more details.
2407
2408    You should have received a copy of the GNU General Public License
2409    along with this program; if not, write to the Free Software
2410    Foundation, Inc., 59 Temple Place - Suite 330,
2411    Boston, MA 02111-1307, USA.  */
2412
2413 /* As a special exception, when this file is copied by Bison into a
2414    Bison output file, you may use that output file without restriction.
2415    This special exception was added by the Free Software Foundation
2416    in version 1.24 of Bison.  */
2417
2418 /* This is the parser code that is written into each bison parser
2419   when the %semantic_parser declaration is not specified in the grammar.
2420   It was written by Richard Stallman by simplifying the hairy parser
2421   used when %semantic_parser is specified.  */
2422
2423 #ifndef YYSTACK_USE_ALLOCA
2424 #ifdef alloca
2425 #define YYSTACK_USE_ALLOCA
2426 #else /* alloca not defined */
2427 #ifdef __GNUC__
2428 #define YYSTACK_USE_ALLOCA
2429 #define alloca __builtin_alloca
2430 #else /* not GNU C.  */
2431 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2432 #define YYSTACK_USE_ALLOCA
2433 #include <alloca.h>
2434 #else /* not sparc */
2435 /* We think this test detects Watcom and Microsoft C.  */
2436 /* This used to test MSDOS, but that is a bad idea
2437    since that symbol is in the user namespace.  */
2438 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2439 #if 0 /* No need for malloc.h, which pollutes the namespace;
2440          instead, just don't use alloca.  */
2441 #include <malloc.h>
2442 #endif
2443 #else /* not MSDOS, or __TURBOC__ */
2444 #if defined(_AIX)
2445 /* I don't know what this was needed for, but it pollutes the namespace.
2446    So I turned it off.   rms, 2 May 1997.  */
2447 /* #include <malloc.h>  */
2448  #pragma alloca
2449 #define YYSTACK_USE_ALLOCA
2450 #else /* not MSDOS, or __TURBOC__, or _AIX */
2451 #if 0
2452 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2453                  and on HPUX 10.  Eventually we can turn this on.  */
2454 #define YYSTACK_USE_ALLOCA
2455 #define alloca __builtin_alloca
2456 #endif /* __hpux */
2457 #endif
2458 #endif /* not _AIX */
2459 #endif /* not MSDOS, or __TURBOC__ */
2460 #endif /* not sparc */
2461 #endif /* not GNU C */
2462 #endif /* alloca not defined */
2463 #endif /* YYSTACK_USE_ALLOCA not defined */
2464
2465 #ifdef YYSTACK_USE_ALLOCA
2466 #define YYSTACK_ALLOC alloca
2467 #else
2468 #define YYSTACK_ALLOC malloc
2469 #endif
2470
2471 /* Note: there must be only one dollar sign in this file.
2472    It is replaced by the list of actions, each action
2473    as one case of the switch.  */
2474
2475 #define yyerrok         (yyerrstatus = 0)
2476 #define yyclearin       (yychar = YYEMPTY)
2477 #define YYEMPTY         -2
2478 #define YYEOF           0
2479 #define YYACCEPT        goto yyacceptlab
2480 #define YYABORT         goto yyabortlab
2481 #define YYERROR         goto yyerrlab1
2482 /* Like YYERROR except do call yyerror.
2483    This remains here temporarily to ease the
2484    transition to the new meaning of YYERROR, for GCC.
2485    Once GCC version 2 has supplanted version 1, this can go.  */
2486 #define YYFAIL          goto yyerrlab
2487 #define YYRECOVERING()  (!!yyerrstatus)
2488 #define YYBACKUP(token, value) \
2489 do                                                              \
2490   if (yychar == YYEMPTY && yylen == 1)                          \
2491     { yychar = (token), yylval = (value);                       \
2492       yychar1 = YYTRANSLATE (yychar);                           \
2493       YYPOPSTACK;                                               \
2494       goto yybackup;                                            \
2495     }                                                           \
2496   else                                                          \
2497     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
2498 while (0)
2499
2500 #define YYTERROR        1
2501 #define YYERRCODE       256
2502
2503 #ifndef YYPURE
2504 #define YYLEX           yylex()
2505 #endif
2506
2507 #ifdef YYPURE
2508 #ifdef YYLSP_NEEDED
2509 #ifdef YYLEX_PARAM
2510 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
2511 #else
2512 #define YYLEX           yylex(&yylval, &yylloc)
2513 #endif
2514 #else /* not YYLSP_NEEDED */
2515 #ifdef YYLEX_PARAM
2516 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
2517 #else
2518 #define YYLEX           yylex(&yylval)
2519 #endif
2520 #endif /* not YYLSP_NEEDED */
2521 #endif
2522
2523 /* If nonreentrant, generate the variables here */
2524
2525 #ifndef YYPURE
2526
2527 int     yychar;                 /*  the lookahead symbol                */
2528 YYSTYPE yylval;                 /*  the semantic value of the           */
2529                                 /*  lookahead symbol                    */
2530
2531 #ifdef YYLSP_NEEDED
2532 YYLTYPE yylloc;                 /*  location data for the lookahead     */
2533                                 /*  symbol                              */
2534 #endif
2535
2536 int yynerrs;                    /*  number of parse errors so far       */
2537 #endif  /* not YYPURE */
2538
2539 #if YYDEBUG != 0
2540 int yydebug;                    /*  nonzero means print parse trace     */
2541 /* Since this is uninitialized, it does not stop multiple parsers
2542    from coexisting.  */
2543 #endif
2544
2545 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
2546
2547 #ifndef YYINITDEPTH
2548 #define YYINITDEPTH 200
2549 #endif
2550
2551 /*  YYMAXDEPTH is the maximum size the stacks can grow to
2552     (effective only if the built-in stack extension method is used).  */
2553
2554 #if YYMAXDEPTH == 0
2555 #undef YYMAXDEPTH
2556 #endif
2557
2558 #ifndef YYMAXDEPTH
2559 #define YYMAXDEPTH 10000
2560 #endif
2561 \f
2562 /* Define __yy_memcpy.  Note that the size argument
2563    should be passed with type unsigned int, because that is what the non-GCC
2564    definitions require.  With GCC, __builtin_memcpy takes an arg
2565    of type size_t, but it can handle unsigned int.  */
2566
2567 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
2568 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
2569 #else                           /* not GNU C or C++ */
2570 #ifndef __cplusplus
2571
2572 /* This is the most reliable way to avoid incompatibilities
2573    in available built-in functions on various systems.  */
2574 static void
2575 __yy_memcpy (to, from, count)
2576      char *to;
2577      char *from;
2578      unsigned int count;
2579 {
2580   register char *f = from;
2581   register char *t = to;
2582   register int i = count;
2583
2584   while (i-- > 0)
2585     *t++ = *f++;
2586 }
2587
2588 #else /* __cplusplus */
2589
2590 /* This is the most reliable way to avoid incompatibilities
2591    in available built-in functions on various systems.  */
2592 static void
2593 __yy_memcpy (char *to, char *from, unsigned int count)
2594 {
2595   register char *t = to;
2596   register char *f = from;
2597   register int i = count;
2598
2599   while (i-- > 0)
2600     *t++ = *f++;
2601 }
2602
2603 #endif
2604 #endif
2605 \f
2606 #line 217 "/usr/lib/bison.simple"
2607
2608 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2609    into yyparse.  The argument should have type void *.
2610    It should actually point to an object.
2611    Grammar actions can access the variable by casting it
2612    to the proper pointer type.  */
2613
2614 #ifdef YYPARSE_PARAM
2615 #ifdef __cplusplus
2616 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2617 #define YYPARSE_PARAM_DECL
2618 #else /* not __cplusplus */
2619 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2620 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2621 #endif /* not __cplusplus */
2622 #else /* not YYPARSE_PARAM */
2623 #define YYPARSE_PARAM_ARG
2624 #define YYPARSE_PARAM_DECL
2625 #endif /* not YYPARSE_PARAM */
2626
2627 /* Prevent warning if -Wstrict-prototypes.  */
2628 #ifdef __GNUC__
2629 #ifdef YYPARSE_PARAM
2630 int yyparse (void *);
2631 #else
2632 int yyparse (void);
2633 #endif
2634 #endif
2635
2636 int
2637 yyparse(YYPARSE_PARAM_ARG)
2638      YYPARSE_PARAM_DECL
2639 {
2640   register int yystate;
2641   register int yyn;
2642   register short *yyssp;
2643   register YYSTYPE *yyvsp;
2644   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
2645   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
2646
2647   short yyssa[YYINITDEPTH];     /*  the state stack                     */
2648   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
2649
2650   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
2651   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
2652
2653 #ifdef YYLSP_NEEDED
2654   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
2655   YYLTYPE *yyls = yylsa;
2656   YYLTYPE *yylsp;
2657
2658 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
2659 #else
2660 #define YYPOPSTACK   (yyvsp--, yyssp--)
2661 #endif
2662
2663   int yystacksize = YYINITDEPTH;
2664   int yyfree_stacks = 0;
2665
2666 #ifdef YYPURE
2667   int yychar;
2668   YYSTYPE yylval;
2669   int yynerrs;
2670 #ifdef YYLSP_NEEDED
2671   YYLTYPE yylloc;
2672 #endif
2673 #endif
2674
2675   YYSTYPE yyval;                /*  the variable used to return         */
2676                                 /*  semantic values from the action     */
2677                                 /*  routines                            */
2678
2679   int yylen;
2680
2681 #if YYDEBUG != 0
2682   if (yydebug)
2683     fprintf(stderr, "Starting parse\n");
2684 #endif
2685
2686   yystate = 0;
2687   yyerrstatus = 0;
2688   yynerrs = 0;
2689   yychar = YYEMPTY;             /* Cause a token to be read.  */
2690
2691   /* Initialize stack pointers.
2692      Waste one element of value and location stack
2693      so that they stay on the same level as the state stack.
2694      The wasted elements are never initialized.  */
2695
2696   yyssp = yyss - 1;
2697   yyvsp = yyvs;
2698 #ifdef YYLSP_NEEDED
2699   yylsp = yyls;
2700 #endif
2701
2702 /* Push a new state, which is found in  yystate  .  */
2703 /* In all cases, when you get here, the value and location stacks
2704    have just been pushed. so pushing a state here evens the stacks.  */
2705 yynewstate:
2706
2707   *++yyssp = yystate;
2708
2709   if (yyssp >= yyss + yystacksize - 1)
2710     {
2711       /* Give user a chance to reallocate the stack */
2712       /* Use copies of these so that the &'s don't force the real ones into memory. */
2713       YYSTYPE *yyvs1 = yyvs;
2714       short *yyss1 = yyss;
2715 #ifdef YYLSP_NEEDED
2716       YYLTYPE *yyls1 = yyls;
2717 #endif
2718
2719       /* Get the current used size of the three stacks, in elements.  */
2720       int size = yyssp - yyss + 1;
2721
2722 #ifdef yyoverflow
2723       /* Each stack pointer address is followed by the size of
2724          the data in use in that stack, in bytes.  */
2725 #ifdef YYLSP_NEEDED
2726       /* This used to be a conditional around just the two extra args,
2727          but that might be undefined if yyoverflow is a macro.  */
2728       yyoverflow("parser stack overflow",
2729                  &yyss1, size * sizeof (*yyssp),
2730                  &yyvs1, size * sizeof (*yyvsp),
2731                  &yyls1, size * sizeof (*yylsp),
2732                  &yystacksize);
2733 #else
2734       yyoverflow("parser stack overflow",
2735                  &yyss1, size * sizeof (*yyssp),
2736                  &yyvs1, size * sizeof (*yyvsp),
2737                  &yystacksize);
2738 #endif
2739
2740       yyss = yyss1; yyvs = yyvs1;
2741 #ifdef YYLSP_NEEDED
2742       yyls = yyls1;
2743 #endif
2744 #else /* no yyoverflow */
2745       /* Extend the stack our own way.  */
2746       if (yystacksize >= YYMAXDEPTH)
2747         {
2748           yyerror("parser stack overflow");
2749           if (yyfree_stacks)
2750             {
2751               free (yyss);
2752               free (yyvs);
2753 #ifdef YYLSP_NEEDED
2754               free (yyls);
2755 #endif
2756             }
2757           return 2;
2758         }
2759       yystacksize *= 2;
2760       if (yystacksize > YYMAXDEPTH)
2761         yystacksize = YYMAXDEPTH;
2762 #ifndef YYSTACK_USE_ALLOCA
2763       yyfree_stacks = 1;
2764 #endif
2765       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2766       __yy_memcpy ((char *)yyss, (char *)yyss1,
2767                    size * (unsigned int) sizeof (*yyssp));
2768       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2769       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2770                    size * (unsigned int) sizeof (*yyvsp));
2771 #ifdef YYLSP_NEEDED
2772       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2773       __yy_memcpy ((char *)yyls, (char *)yyls1,
2774                    size * (unsigned int) sizeof (*yylsp));
2775 #endif
2776 #endif /* no yyoverflow */
2777
2778       yyssp = yyss + size - 1;
2779       yyvsp = yyvs + size - 1;
2780 #ifdef YYLSP_NEEDED
2781       yylsp = yyls + size - 1;
2782 #endif
2783
2784 #if YYDEBUG != 0
2785       if (yydebug)
2786         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2787 #endif
2788
2789       if (yyssp >= yyss + yystacksize - 1)
2790         YYABORT;
2791     }
2792
2793 #if YYDEBUG != 0
2794   if (yydebug)
2795     fprintf(stderr, "Entering state %d\n", yystate);
2796 #endif
2797
2798   goto yybackup;
2799  yybackup:
2800
2801 /* Do appropriate processing given the current state.  */
2802 /* Read a lookahead token if we need one and don't already have one.  */
2803 /* yyresume: */
2804
2805   /* First try to decide what to do without reference to lookahead token.  */
2806
2807   yyn = yypact[yystate];
2808   if (yyn == YYFLAG)
2809     goto yydefault;
2810
2811   /* Not known => get a lookahead token if don't already have one.  */
2812
2813   /* yychar is either YYEMPTY or YYEOF
2814      or a valid token in external form.  */
2815
2816   if (yychar == YYEMPTY)
2817     {
2818 #if YYDEBUG != 0
2819       if (yydebug)
2820         fprintf(stderr, "Reading a token: ");
2821 #endif
2822       yychar = YYLEX;
2823     }
2824
2825   /* Convert token to internal form (in yychar1) for indexing tables with */
2826
2827   if (yychar <= 0)              /* This means end of input. */
2828     {
2829       yychar1 = 0;
2830       yychar = YYEOF;           /* Don't call YYLEX any more */
2831
2832 #if YYDEBUG != 0
2833       if (yydebug)
2834         fprintf(stderr, "Now at end of input.\n");
2835 #endif
2836     }
2837   else
2838     {
2839       yychar1 = YYTRANSLATE(yychar);
2840
2841 #if YYDEBUG != 0
2842       if (yydebug)
2843         {
2844           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2845           /* Give the individual parser a way to print the precise meaning
2846              of a token, for further debugging info.  */
2847 #ifdef YYPRINT
2848           YYPRINT (stderr, yychar, yylval);
2849 #endif
2850           fprintf (stderr, ")\n");
2851         }
2852 #endif
2853     }
2854
2855   yyn += yychar1;
2856   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2857     goto yydefault;
2858
2859   yyn = yytable[yyn];
2860
2861   /* yyn is what to do for this token type in this state.
2862      Negative => reduce, -yyn is rule number.
2863      Positive => shift, yyn is new state.
2864        New state is final state => don't bother to shift,
2865        just return success.
2866      0, or most negative number => error.  */
2867
2868   if (yyn < 0)
2869     {
2870       if (yyn == YYFLAG)
2871         goto yyerrlab;
2872       yyn = -yyn;
2873       goto yyreduce;
2874     }
2875   else if (yyn == 0)
2876     goto yyerrlab;
2877
2878   if (yyn == YYFINAL)
2879     YYACCEPT;
2880
2881   /* Shift the lookahead token.  */
2882
2883 #if YYDEBUG != 0
2884   if (yydebug)
2885     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2886 #endif
2887
2888   /* Discard the token being shifted unless it is eof.  */
2889   if (yychar != YYEOF)
2890     yychar = YYEMPTY;
2891
2892   *++yyvsp = yylval;
2893 #ifdef YYLSP_NEEDED
2894   *++yylsp = yylloc;
2895 #endif
2896
2897   /* count tokens shifted since error; after three, turn off error status.  */
2898   if (yyerrstatus) yyerrstatus--;
2899
2900   yystate = yyn;
2901   goto yynewstate;
2902
2903 /* Do the default action for the current state.  */
2904 yydefault:
2905
2906   yyn = yydefact[yystate];
2907   if (yyn == 0)
2908     goto yyerrlab;
2909
2910 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
2911 yyreduce:
2912   yylen = yyr2[yyn];
2913   if (yylen > 0)
2914     yyval = yyvsp[1-yylen]; /* implement default value of the action */
2915
2916 #if YYDEBUG != 0
2917   if (yydebug)
2918     {
2919       int i;
2920
2921       fprintf (stderr, "Reducing via rule %d (line %d), ",
2922                yyn, yyrline[yyn]);
2923
2924       /* Print the symbols being reduced, and their result.  */
2925       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2926         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2927       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2928     }
2929 #endif
2930
2931
2932   switch (yyn) {
2933
2934 case 1:
2935 #line 578 "./parse.y"
2936 {;
2937     break;}
2938 case 18:
2939 #line 622 "./parse.y"
2940
2941                   yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2942                   CLASS_LOADED_P (yyval.node) = 1;
2943                 ;
2944     break;}
2945 case 19:
2946 #line 627 "./parse.y"
2947 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2948     break;}
2949 case 20:
2950 #line 629 "./parse.y"
2951 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2952     break;}
2953 case 21:
2954 #line 631 "./parse.y"
2955 {RULE ("']' expected"); RECOVER;;
2956     break;}
2957 case 22:
2958 #line 633 "./parse.y"
2959 {RULE ("']' expected"); RECOVER;;
2960     break;}
2961 case 26:
2962 #line 648 "./parse.y"
2963 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2964     break;}
2965 case 28:
2966 #line 657 "./parse.y"
2967 {yyval.node = NULL;;
2968     break;}
2969 case 36:
2970 #line 669 "./parse.y"
2971 {
2972                   yyval.node = NULL;
2973                 ;
2974     break;}
2975 case 37:
2976 #line 673 "./parse.y"
2977 {
2978                   yyval.node = NULL;
2979                 ;
2980     break;}
2981 case 40:
2982 #line 685 "./parse.y"
2983
2984                   ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node);
2985                   register_package (ctxp->package);
2986                 ;
2987     break;}
2988 case 41:
2989 #line 690 "./parse.y"
2990 {yyerror ("Missing name"); RECOVER;;
2991     break;}
2992 case 42:
2993 #line 692 "./parse.y"
2994 {yyerror ("';' expected"); RECOVER;;
2995     break;}
2996 case 45:
2997 #line 702 "./parse.y"
2998 {
2999                   tree name = EXPR_WFL_NODE (yyvsp[-1].node), last_name;
3000                   int   i = IDENTIFIER_LENGTH (name)-1;
3001                   const char *last = &IDENTIFIER_POINTER (name)[i];
3002                   while (last != IDENTIFIER_POINTER (name))
3003                     {
3004                       if (last [0] == '.')
3005                         break;
3006                       last--;
3007                     }
3008                   last_name = get_identifier (++last);
3009                   if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
3010                     {
3011                       tree err = find_name_in_single_imports (last_name);
3012                       if (err && err != name)
3013                         parse_error_context
3014                           (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
3015                            IDENTIFIER_POINTER (name), 
3016                            IDENTIFIER_POINTER (err));
3017                       else
3018                         REGISTER_IMPORT (yyvsp[-1].node, last_name);
3019                     }
3020                   else
3021                     REGISTER_IMPORT (yyvsp[-1].node, last_name);
3022                 ;
3023     break;}
3024 case 46:
3025 #line 728 "./parse.y"
3026 {yyerror ("Missing name"); RECOVER;;
3027     break;}
3028 case 47:
3029 #line 730 "./parse.y"
3030 {yyerror ("';' expected"); RECOVER;;
3031     break;}
3032 case 48:
3033 #line 735 "./parse.y"
3034 {
3035                   tree name = EXPR_WFL_NODE (yyvsp[-3].node);
3036                   /* Don't import java.lang.* twice. */
3037                   if (name != java_lang_id)
3038                     {
3039                       read_import_dir (yyvsp[-3].node);
3040                       ctxp->import_demand_list = 
3041                         chainon (ctxp->import_demand_list,
3042                                  build_tree_list (yyvsp[-3].node, NULL_TREE));
3043                     }
3044                 ;
3045     break;}
3046 case 49:
3047 #line 747 "./parse.y"
3048 {yyerror ("'*' expected"); RECOVER;;
3049     break;}
3050 case 50:
3051 #line 749 "./parse.y"
3052 {yyerror ("';' expected"); RECOVER;;
3053     break;}
3054 case 51:
3055 #line 754 "./parse.y"
3056 { end_class_declaration (0); ;
3057     break;}
3058 case 52:
3059 #line 756 "./parse.y"
3060 { end_class_declaration (0); ;
3061     break;}
3062 case 53:
3063 #line 758 "./parse.y"
3064 { yyval.node = NULL; ;
3065     break;}
3066 case 54:
3067 #line 760 "./parse.y"
3068 {
3069                   YYERROR_NOW;
3070                   yyerror ("Class or interface declaration expected");
3071                 ;
3072     break;}
3073 case 55:
3074 #line 771 "./parse.y"
3075 {
3076                   yyval.value = (1 << yyvsp[0].value);
3077                 ;
3078     break;}
3079 case 56:
3080 #line 775 "./parse.y"
3081 {
3082                   int acc = (1 << yyvsp[0].value);
3083                   if (yyval.value & acc)
3084                     parse_error_context 
3085                       (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
3086                        java_accstring_lookup (acc));
3087                   else
3088                     {
3089                       yyval.value |= acc;
3090                     }
3091                 ;
3092     break;}
3093 case 57:
3094 #line 791 "./parse.y"
3095 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3096     break;}
3097 case 59:
3098 #line 794 "./parse.y"
3099 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3100     break;}
3101 case 61:
3102 #line 797 "./parse.y"
3103 {yyerror ("Missing class name"); RECOVER;;
3104     break;}
3105 case 62:
3106 #line 799 "./parse.y"
3107 {yyerror ("Missing class name"); RECOVER;;
3108     break;}
3109 case 63:
3110 #line 801 "./parse.y"
3111 {
3112                   if (!ctxp->class_err) yyerror ("'{' expected"); 
3113                   DRECOVER(class1);
3114                 ;
3115     break;}
3116 case 64:
3117 #line 806 "./parse.y"
3118 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
3119     break;}
3120 case 65:
3121 #line 810 "./parse.y"
3122 { yyval.node = NULL; ;
3123     break;}
3124 case 66:
3125 #line 812 "./parse.y"
3126 { yyval.node = yyvsp[0].node; ;
3127     break;}
3128 case 67:
3129 #line 814 "./parse.y"
3130 {yyerror ("'{' expected"); ctxp->class_err=1;;
3131     break;}
3132 case 68:
3133 #line 816 "./parse.y"
3134 {yyerror ("Missing super class name"); ctxp->class_err=1;;
3135     break;}
3136 case 69:
3137 #line 820 "./parse.y"
3138 { yyval.node = NULL_TREE; ;
3139     break;}
3140 case 70:
3141 #line 822 "./parse.y"
3142 { yyval.node = yyvsp[0].node; ;
3143     break;}
3144 case 71:
3145 #line 824 "./parse.y"
3146 {
3147                   ctxp->class_err=1;
3148                   yyerror ("Missing interface name"); 
3149                 ;
3150     break;}
3151 case 72:
3152 #line 832 "./parse.y"
3153
3154                   ctxp->interface_number = 1;
3155                   yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3156                 ;
3157     break;}
3158 case 73:
3159 #line 837 "./parse.y"
3160
3161                   ctxp->interface_number++;
3162                   yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3163                 ;
3164     break;}
3165 case 74:
3166 #line 842 "./parse.y"
3167 {yyerror ("Missing interface name"); RECOVER;;
3168     break;}
3169 case 75:
3170 #line 847 "./parse.y"
3171
3172                   /* Store the location of the `}' when doing xrefs */
3173                   if (flag_emit_xref)
3174                     DECL_END_SOURCE_LINE (GET_CPC ()) = 
3175                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3176                   yyval.node = GET_CPC ();
3177                 ;
3178     break;}
3179 case 76:
3180 #line 855 "./parse.y"
3181
3182                   /* Store the location of the `}' when doing xrefs */
3183                   if (flag_emit_xref)
3184                     DECL_END_SOURCE_LINE (GET_CPC ()) = 
3185                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3186                   yyval.node = GET_CPC ();
3187                 ;
3188     break;}
3189 case 82:
3190 #line 874 "./parse.y"
3191 {
3192                   TREE_CHAIN (yyvsp[0].node) = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
3193                   SET_CPC_INSTANCE_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3194                 ;
3195     break;}
3196 case 84:
3197 #line 883 "./parse.y"
3198 { yyval.node = yyvsp[-1].node; ;
3199     break;}
3200 case 86:
3201 #line 886 "./parse.y"
3202 { end_class_declaration (1); ;
3203     break;}
3204 case 87:
3205 #line 888 "./parse.y"
3206 { end_class_declaration (1); ;
3207     break;}
3208 case 88:
3209 #line 894 "./parse.y"
3210 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3211     break;}
3212 case 89:
3213 #line 896 "./parse.y"
3214 {
3215                   check_modifiers 
3216                     ("Illegal modifier `%s' for field declaration",
3217                      yyvsp[-3].value, FIELD_MODIFIERS);
3218                   check_modifiers_consistency (yyvsp[-3].value);
3219                   register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3220                 ;
3221     break;}
3222 case 91:
3223 #line 909 "./parse.y"
3224 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3225     break;}
3226 case 92:
3227 #line 911 "./parse.y"
3228 {yyerror ("Missing term"); RECOVER;;
3229     break;}
3230 case 93:
3231 #line 916 "./parse.y"
3232 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3233     break;}
3234 case 94:
3235 #line 918 "./parse.y"
3236
3237                   if (java_error_count)
3238                     yyvsp[0].node = NULL_TREE;
3239                   yyval.node = build_tree_list 
3240                     (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3241                 ;
3242     break;}
3243 case 95:
3244 #line 925 "./parse.y"
3245 {
3246                   yyerror ("Missing variable initializer");
3247                   yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3248                   RECOVER;
3249                 ;
3250     break;}
3251 case 96:
3252 #line 931 "./parse.y"
3253 {
3254                   yyerror ("';' expected");
3255                   yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3256                   RECOVER;
3257                 ;
3258     break;}
3259 case 98:
3260 #line 941 "./parse.y"
3261 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3262     break;}
3263 case 99:
3264 #line 943 "./parse.y"
3265 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3266     break;}
3267 case 100:
3268 #line 945 "./parse.y"
3269 {yyerror ("']' expected"); DRECOVER(vdi);;
3270     break;}
3271 case 101:
3272 #line 947 "./parse.y"
3273 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3274     break;}
3275 case 104:
3276 #line 958 "./parse.y"
3277 {
3278                   current_function_decl = yyvsp[0].node;
3279                   if (current_function_decl
3280                       && TREE_CODE (current_function_decl) == FUNCTION_DECL)
3281                     source_start_java_method (current_function_decl);
3282                   else
3283                     current_function_decl = NULL_TREE;
3284                 ;
3285     break;}
3286 case 105:
3287 #line 967 "./parse.y"
3288 { finish_method_declaration (yyvsp[0].node); ;
3289     break;}
3290 case 106:
3291 #line 969 "./parse.y"
3292 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3293     break;}
3294 case 107:
3295 #line 974 "./parse.y"
3296 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3297     break;}
3298 case 108:
3299 #line 976 "./parse.y"
3300 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3301     break;}
3302 case 109:
3303 #line 978 "./parse.y"
3304 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3305     break;}
3306 case 110:
3307 #line 980 "./parse.y"
3308 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3309     break;}
3310 case 111:
3311 #line 982 "./parse.y"
3312 {
3313                   yyerror ("Invalid method declaration, method name required");
3314                   RECOVER;
3315                 ;
3316     break;}
3317 case 112:
3318 #line 987 "./parse.y"
3319 {RECOVER;;
3320     break;}
3321 case 113:
3322 #line 989 "./parse.y"
3323 {yyerror ("Identifier expected"); RECOVER;;
3324     break;}
3325 case 114:
3326 #line 991 "./parse.y"
3327 {yyerror ("Identifier expected"); RECOVER;;
3328     break;}
3329 case 115:
3330 #line 993 "./parse.y"
3331 {
3332                   yyerror ("Invalid method declaration, return type required");
3333                   RECOVER;
3334                 ;
3335     break;}
3336 case 116:
3337 #line 1001 "./parse.y"
3338
3339                   ctxp->formal_parameter_number = 0;
3340                   yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3341                 ;
3342     break;}
3343 case 117:
3344 #line 1006 "./parse.y"
3345 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3346     break;}
3347 case 118:
3348 #line 1008 "./parse.y"
3349 {
3350                   EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3351                   TREE_PURPOSE (yyvsp[-2].node) = 
3352                     build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3353                   parse_warning_context 
3354                     (wfl_operator, 
3355                      "Discouraged form of returned type specification");
3356                 ;
3357     break;}
3358 case 119:
3359 #line 1017 "./parse.y"
3360 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3361     break;}
3362 case 120:
3363 #line 1019 "./parse.y"
3364 {yyerror ("']' expected"); RECOVER;;
3365     break;}
3366 case 121:
3367 #line 1024 "./parse.y"
3368 {
3369                   ctxp->formal_parameter_number = 1;
3370                 ;
3371     break;}
3372 case 122:
3373 #line 1028 "./parse.y"
3374 {
3375                   ctxp->formal_parameter_number += 1;
3376                   yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3377                 ;
3378     break;}
3379 case 123:
3380 #line 1033 "./parse.y"
3381 { yyerror ("Missing formal parameter term"); RECOVER; ;
3382     break;}
3383 case 124:
3384 #line 1038 "./parse.y"
3385 {
3386                   yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3387                 ;
3388     break;}
3389 case 125:
3390 #line 1042 "./parse.y"
3391
3392                   yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3393                   ARG_FINAL_P (yyval.node) = 1;
3394                 ;
3395     break;}
3396 case 126:
3397 #line 1047 "./parse.y"
3398 {
3399                   yyerror ("Missing identifier"); RECOVER;
3400                   yyval.node = NULL_TREE;
3401                 ;
3402     break;}
3403 case 127:
3404 #line 1052 "./parse.y"
3405 {
3406                   yyerror ("Missing identifier"); RECOVER;
3407                   yyval.node = NULL_TREE;
3408                 ;
3409     break;}
3410 case 128:
3411 #line 1060 "./parse.y"
3412 {
3413                   check_modifiers ("Illegal modifier `%s'. Only `final' was expected here",
3414                                    yyvsp[0].value, ACC_FINAL);
3415                   if (yyvsp[0].value != ACC_FINAL)
3416                     MODIFIER_WFL (FINAL_TK) = build_wfl_node (NULL_TREE);
3417                 ;
3418     break;}
3419 case 129:
3420 #line 1069 "./parse.y"
3421 { yyval.node = NULL_TREE; ;
3422     break;}
3423 case 130:
3424 #line 1071 "./parse.y"
3425 { yyval.node = yyvsp[0].node; ;
3426     break;}
3427 case 131:
3428 #line 1073 "./parse.y"
3429 {yyerror ("Missing class type term"); RECOVER;;
3430     break;}
3431 case 132:
3432 #line 1078 "./parse.y"
3433 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3434     break;}
3435 case 133:
3436 #line 1080 "./parse.y"
3437 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3438     break;}
3439 case 134:
3440 #line 1082 "./parse.y"
3441 {yyerror ("Missing class type term"); RECOVER;;
3442     break;}
3443 case 137:
3444 #line 1089 "./parse.y"
3445 { yyval.node = NULL_TREE; ;
3446     break;}
3447 case 138:
3448 #line 1095 "./parse.y"
3449 {
3450                   TREE_CHAIN (yyvsp[0].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3451                   SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3452                 ;
3453     break;}
3454 case 139:
3455 #line 1100 "./parse.y"
3456 {
3457                   TREE_CHAIN (yyvsp[-1].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3458                   SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[-1].node);
3459                 ;
3460     break;}
3461 case 140:
3462 #line 1108 "./parse.y"
3463 {
3464                   check_modifiers ("Illegal modifier `%s' for static initializer", yyvsp[0].value, ACC_STATIC);
3465                   /* Can't have a static initializer in an innerclass */
3466                   if (yyvsp[0].value | ACC_STATIC &&
3467                       GET_CPC_LIST () && !TOPLEVEL_CLASS_DECL_P (GET_CPC ()))
3468                     parse_error_context 
3469                       (MODIFIER_WFL (STATIC_TK),
3470                        "Can't define static initializer in class `%s'. Static initializer can only be defined in top-level classes",
3471                        IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())));
3472                   SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3473                 ;
3474     break;}
3475 case 141:
3476 #line 1124 "./parse.y"
3477 {
3478                   current_function_decl = yyvsp[0].node;
3479                   source_start_java_method (current_function_decl);
3480                 ;
3481     break;}
3482 case 142:
3483 #line 1129 "./parse.y"
3484 { finish_method_declaration (yyvsp[0].node); ;
3485     break;}
3486 case 143:
3487 #line 1134 "./parse.y"
3488 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3489     break;}
3490 case 144:
3491 #line 1136 "./parse.y"
3492 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3493     break;}
3494 case 145:
3495 #line 1141 "./parse.y"
3496
3497                   ctxp->formal_parameter_number = 0;  
3498                   yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3499                 ;
3500     break;}
3501 case 146:
3502 #line 1146 "./parse.y"
3503 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3504     break;}
3505 case 147:
3506 #line 1154 "./parse.y"
3507
3508                   BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3509                   yyval.node = yyvsp[0].node;
3510                 ;
3511     break;}
3512 case 148:
3513 #line 1159 "./parse.y"
3514 { yyval.node = yyvsp[0].node; ;
3515     break;}
3516 case 149:
3517 #line 1161 "./parse.y"
3518 { yyval.node = yyvsp[0].node; ;
3519     break;}
3520 case 150:
3521 #line 1163 "./parse.y"
3522 { yyval.node = yyvsp[0].node; ;
3523     break;}
3524 case 153:
3525 #line 1173 "./parse.y"
3526
3527                   yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE); 
3528                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3529                   yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3530                 ;
3531     break;}
3532 case 154:
3533 #line 1179 "./parse.y"
3534
3535                   yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node); 
3536                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3537                   yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3538                 ;
3539     break;}
3540 case 155:
3541 #line 1187 "./parse.y"
3542 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3543     break;}
3544 case 156:
3545 #line 1189 "./parse.y"
3546 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3547     break;}
3548 case 157:
3549 #line 1194 "./parse.y"
3550 {
3551                   tree wfl = build_wfl_node (this_identifier_node);
3552                   EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3553                   yyval.node = wfl;
3554                 ;
3555     break;}
3556 case 158:
3557 #line 1200 "./parse.y"
3558 {
3559                   tree wfl = build_wfl_node (super_identifier_node);
3560                   EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3561                   yyval.node = wfl;
3562                 ;
3563     break;}
3564 case 159:
3565 #line 1211 "./parse.y"
3566 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3567     break;}
3568 case 161:
3569 #line 1214 "./parse.y"
3570 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3571     break;}
3572 case 163:
3573 #line 1217 "./parse.y"
3574 { create_interface (0, yyvsp[-1].node, yyvsp[0].node);  ;
3575     break;}
3576 case 165:
3577 #line 1220 "./parse.y"
3578 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3579     break;}
3580 case 167:
3581 #line 1223 "./parse.y"
3582 {yyerror ("'{' expected"); RECOVER;;
3583     break;}
3584 case 168:
3585 #line 1225 "./parse.y"
3586 {yyerror ("'{' expected"); RECOVER;;
3587     break;}
3588 case 169:
3589 #line 1230 "./parse.y"
3590
3591                   ctxp->interface_number = 1;
3592                   yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3593                 ;
3594     break;}
3595 case 170:
3596 #line 1235 "./parse.y"
3597
3598                   ctxp->interface_number++;
3599                   yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3600                 ;
3601     break;}
3602 case 171:
3603 #line 1240 "./parse.y"
3604 {yyerror ("Invalid interface type"); RECOVER;;
3605     break;}
3606 case 172:
3607 #line 1242 "./parse.y"
3608 {yyerror ("Missing term"); RECOVER;;
3609     break;}
3610 case 173:
3611 #line 1247 "./parse.y"
3612 { yyval.node = NULL_TREE; ;
3613     break;}
3614 case 174:
3615 #line 1249 "./parse.y"
3616 { yyval.node = NULL_TREE; ;
3617     break;}
3618 case 179:
3619 #line 1261 "./parse.y"
3620 { end_class_declaration (1); ;
3621     break;}
3622 case 180:
3623 #line 1263 "./parse.y"
3624 { end_class_declaration (1); ;
3625     break;}
3626 case 182:
3627 #line 1272 "./parse.y"
3628
3629                   check_abstract_method_header (yyvsp[-1].node);
3630                   current_function_decl = NULL_TREE; /* FIXME ? */
3631                 ;
3632     break;}
3633 case 183:
3634 #line 1277 "./parse.y"
3635 {yyerror ("';' expected"); RECOVER;;
3636     break;}
3637 case 184:
3638 #line 1283 "./parse.y"
3639 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3640     break;}
3641 case 185:
3642 #line 1285 "./parse.y"
3643 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3644     break;}
3645 case 186:
3646 #line 1287 "./parse.y"
3647 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3648     break;}
3649 case 187:
3650 #line 1292 "./parse.y"
3651
3652                   yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), 
3653                                   yyvsp[0].node, NULL_TREE);
3654                 ;
3655     break;}
3656 case 188:
3657 #line 1297 "./parse.y"
3658 {
3659                   yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3660                 ;
3661     break;}
3662 case 189:
3663 #line 1301 "./parse.y"
3664 {yyerror ("Missing term"); RECOVER;;
3665     break;}
3666 case 190:
3667 #line 1307 "./parse.y"
3668
3669                   /* Store the location of the `}' when doing xrefs */
3670                   if (current_function_decl && flag_emit_xref)
3671                     DECL_END_SOURCE_LINE (current_function_decl) = 
3672                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3673                   yyval.node = empty_stmt_node; 
3674                 ;
3675     break;}
3676 case 191:
3677 #line 1315 "./parse.y"
3678 { yyval.node = yyvsp[0].node; ;
3679     break;}
3680 case 192:
3681 #line 1320 "./parse.y"
3682 { enter_block (); ;
3683     break;}
3684 case 193:
3685 #line 1325 "./parse.y"
3686
3687                   maybe_absorb_scoping_blocks ();
3688                   /* Store the location of the `}' when doing xrefs */
3689                   if (current_function_decl && flag_emit_xref)
3690                     DECL_END_SOURCE_LINE (current_function_decl) = 
3691                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);           
3692                   yyval.node = exit_block ();
3693                   if (!BLOCK_SUBBLOCKS (yyval.node))
3694                     BLOCK_SUBBLOCKS (yyval.node) = empty_stmt_node;
3695                 ;
3696     break;}
3697 case 197:
3698 #line 1345 "./parse.y"
3699 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3700     break;}
3701 case 198:
3702 #line 1347 "./parse.y"
3703
3704                   LOCAL_CLASS_P (TREE_TYPE (GET_CPC ())) = 1;
3705                   end_class_declaration (1);
3706                 ;
3707     break;}
3708 case 200:
3709 #line 1359 "./parse.y"
3710 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3711     break;}
3712 case 201:
3713 #line 1361 "./parse.y"
3714 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3715     break;}
3716 case 207:
3717 #line 1371 "./parse.y"
3718 { yyval.node = exit_block (); ;
3719     break;}
3720 case 212:
3721 #line 1380 "./parse.y"
3722 { yyval.node = exit_block (); ;
3723     break;}
3724 case 224:
3725 #line 1399 "./parse.y"
3726 { yyval.node = empty_stmt_node; ;
3727     break;}
3728 case 225:
3729 #line 1404 "./parse.y"
3730 {
3731                   yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node), 
3732                                             EXPR_WFL_NODE (yyvsp[-1].node));
3733                   pushlevel (2);
3734                   push_labeled_block (yyval.node);
3735                   PUSH_LABELED_BLOCK (yyval.node);
3736                 ;
3737     break;}
3738 case 226:
3739 #line 1415 "./parse.y"
3740 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3741     break;}
3742 case 227:
3743 #line 1417 "./parse.y"
3744 {yyerror ("':' expected"); RECOVER;;
3745     break;}
3746 case 228:
3747 #line 1422 "./parse.y"
3748 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3749     break;}
3750 case 229:
3751 #line 1429 "./parse.y"
3752 {
3753                   /* We have a statement. Generate a WFL around it so
3754                      we can debug it */
3755                   yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3756                   /* We know we have a statement, so set the debug
3757                      info to be eventually generate here. */
3758                   yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3759                 ;
3760     break;}
3761 case 230:
3762 #line 1438 "./parse.y"
3763 {
3764                   if (ctxp->prevent_ese != lineno)
3765                     yyerror ("Invalid expression statement");
3766                   DRECOVER (expr_stmt);
3767                 ;
3768     break;}
3769 case 231:
3770 #line 1444 "./parse.y"
3771 {
3772                   if (ctxp->prevent_ese != lineno)
3773                     yyerror ("Invalid expression statement");
3774                   DRECOVER (expr_stmt);
3775                 ;
3776     break;}
3777 case 232:
3778 #line 1450 "./parse.y"
3779 {
3780                   if (ctxp->prevent_ese != lineno)
3781                     yyerror ("Invalid expression statement");
3782                   DRECOVER (expr_stmt);
3783                 ;
3784     break;}
3785 case 233:
3786 #line 1456 "./parse.y"
3787 {yyerror ("')' expected"); RECOVER;;
3788     break;}
3789 case 234:
3790 #line 1458 "./parse.y"
3791 {
3792                   parse_ctor_invocation_error ();
3793                   RECOVER;
3794                 ;
3795     break;}
3796 case 235:
3797 #line 1463 "./parse.y"
3798 {yyerror ("')' expected"); RECOVER;;
3799     break;}
3800 case 236:
3801 #line 1465 "./parse.y"
3802 {
3803                   parse_ctor_invocation_error ();
3804                   RECOVER;
3805                 ;
3806     break;}
3807 case 237:
3808 #line 1470 "./parse.y"
3809 {yyerror ("'(' expected"); RECOVER;;
3810     break;}
3811 case 238:
3812 #line 1472 "./parse.y"
3813 {yyerror ("')' expected"); RECOVER;;
3814     break;}
3815 case 239:
3816 #line 1474 "./parse.y"
3817 {yyerror ("')' expected"); RECOVER;;
3818     break;}
3819 case 240:
3820 #line 1476 "./parse.y"
3821 {yyerror ("';' expected"); RECOVER;;
3822     break;}
3823 case 241:
3824 #line 1478 "./parse.y"
3825 {yyerror ("';' expected"); RECOVER;;
3826     break;}
3827 case 249:
3828 #line 1493 "./parse.y"
3829
3830                   yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node, 
3831                                                 yyvsp[0].node, NULL_TREE);
3832                 ;
3833     break;}
3834 case 250:
3835 #line 1498 "./parse.y"
3836 {yyerror ("'(' expected"); RECOVER;;
3837     break;}
3838 case 251:
3839 #line 1500 "./parse.y"
3840 {yyerror ("Missing term"); RECOVER;;
3841     break;}
3842 case 252:
3843 #line 1502 "./parse.y"
3844 {yyerror ("')' expected"); RECOVER;;
3845     break;}
3846 case 253:
3847 #line 1507 "./parse.y"
3848 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3849     break;}
3850 case 254:
3851 #line 1512 "./parse.y"
3852 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3853     break;}
3854 case 255:
3855 #line 1517 "./parse.y"
3856 {
3857                   enter_block ();
3858                 ;
3859     break;}
3860 case 256:
3861 #line 1521 "./parse.y"
3862
3863                   /* Make into "proper list" of COMPOUND_EXPRs.
3864                      I.e. make the last statment also have its own
3865                      COMPOUND_EXPR. */
3866                   maybe_absorb_scoping_blocks ();
3867                   TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
3868                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
3869                 ;
3870     break;}
3871 case 257:
3872 #line 1533 "./parse.y"
3873
3874                   yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3875                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3876                 ;
3877     break;}
3878 case 258:
3879 #line 1538 "./parse.y"
3880 {yyerror ("'(' expected"); RECOVER;;
3881     break;}
3882 case 259:
3883 #line 1540 "./parse.y"
3884 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3885     break;}
3886 case 260:
3887 #line 1542 "./parse.y"
3888 {yyerror ("'{' expected"); RECOVER;;
3889     break;}
3890 case 261:
3891 #line 1550 "./parse.y"
3892 { yyval.node = NULL_TREE; ;
3893     break;}
3894 case 262:
3895 #line 1552 "./parse.y"
3896 { yyval.node = NULL_TREE; ;
3897     break;}
3898 case 263:
3899 #line 1554 "./parse.y"
3900 { yyval.node = NULL_TREE; ;
3901     break;}
3902 case 264:
3903 #line 1556 "./parse.y"
3904 { yyval.node = NULL_TREE; ;
3905     break;}
3906 case 270:
3907 #line 1575 "./parse.y"
3908
3909                   tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3910                   EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
3911                   java_method_add_stmt (current_function_decl, lab);
3912                 ;
3913     break;}
3914 case 271:
3915 #line 1581 "./parse.y"
3916
3917                   tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3918                   EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
3919                   java_method_add_stmt (current_function_decl, lab);
3920                 ;
3921     break;}
3922 case 272:
3923 #line 1587 "./parse.y"
3924 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3925     break;}
3926 case 273:
3927 #line 1589 "./parse.y"
3928 {yyerror ("':' expected"); RECOVER;;
3929     break;}
3930 case 274:
3931 #line 1591 "./parse.y"
3932 {yyerror ("':' expected"); RECOVER;;
3933     break;}
3934 case 275:
3935 #line 1596 "./parse.y"
3936
3937                   tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3938                   yyval.node = build_new_loop (body);
3939                 ;
3940     break;}
3941 case 276:
3942 #line 1604 "./parse.y"
3943 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3944     break;}
3945 case 277:
3946 #line 1606 "./parse.y"
3947 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3948     break;}
3949 case 278:
3950 #line 1608 "./parse.y"
3951 {yyerror ("Missing term and ')' expected"); RECOVER;;
3952     break;}
3953 case 279:
3954 #line 1610 "./parse.y"
3955 {yyerror ("')' expected"); RECOVER;;
3956     break;}
3957 case 280:
3958 #line 1615 "./parse.y"
3959 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3960     break;}
3961 case 281:
3962 #line 1620 "./parse.y"
3963
3964                   tree body = build_loop_body (0, NULL_TREE, 1);
3965                   yyval.node = build_new_loop (body);
3966                 ;
3967     break;}
3968 case 282:
3969 #line 1629 "./parse.y"
3970 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3971     break;}
3972 case 283:
3973 #line 1634 "./parse.y"
3974 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3975     break;}
3976 case 284:
3977 #line 1636 "./parse.y"
3978
3979                   yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3980                   /* We have not condition, so we get rid of the EXIT_EXPR */
3981                   LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = 
3982                     empty_stmt_node;
3983                 ;
3984     break;}
3985 case 285:
3986 #line 1643 "./parse.y"
3987 {yyerror ("Invalid control expression"); RECOVER;;
3988     break;}
3989 case 286:
3990 #line 1645 "./parse.y"
3991 {yyerror ("Invalid update expression"); RECOVER;;
3992     break;}
3993 case 287:
3994 #line 1647 "./parse.y"
3995 {yyerror ("Invalid update expression"); RECOVER;;
3996     break;}
3997 case 288:
3998 #line 1652 "./parse.y"
3999 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
4000     break;}
4001 case 289:
4002 #line 1654 "./parse.y"
4003
4004                   yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4005                   /* We have not condition, so we get rid of the EXIT_EXPR */
4006                   LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = 
4007                     empty_stmt_node;
4008                 ;
4009     break;}
4010 case 290:
4011 #line 1664 "./parse.y"
4012
4013                   /* This scope defined for local variable that may be
4014                      defined within the scope of the for loop */
4015                   enter_block (); 
4016                 ;
4017     break;}
4018 case 291:
4019 #line 1670 "./parse.y"
4020 {yyerror ("'(' expected"); DRECOVER(for_1);;
4021     break;}
4022 case 292:
4023 #line 1672 "./parse.y"
4024 {yyerror ("Invalid init statement"); RECOVER;;
4025     break;}
4026 case 293:
4027 #line 1677 "./parse.y"
4028
4029                   /* We now declare the loop body. The loop is
4030                      declared as a for loop. */
4031                   tree body = build_loop_body (0, NULL_TREE, 0);
4032                   yyval.node =  build_new_loop (body);
4033                   FOR_LOOP_P (yyval.node) = 1;
4034                   /* The loop is added to the current block the for
4035                      statement is defined within */
4036                   java_method_add_stmt (current_function_decl, yyval.node);
4037                 ;
4038     break;}
4039 case 294:
4040 #line 1689 "./parse.y"
4041 { yyval.node = empty_stmt_node; ;
4042     break;}
4043 case 295:
4044 #line 1691 "./parse.y"
4045
4046                   /* Init statement recorded within the previously
4047                      defined block scope */
4048                   yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
4049                 ;
4050     break;}
4051 case 296:
4052 #line 1697 "./parse.y"
4053
4054                   /* Local variable are recorded within the previously
4055                      defined block scope */
4056                   yyval.node = NULL_TREE;
4057                 ;
4058     break;}
4059 case 297:
4060 #line 1703 "./parse.y"
4061 {yyerror ("';' expected"); DRECOVER(for_init_1);;
4062     break;}
4063 case 298:
4064 #line 1707 "./parse.y"
4065 {yyval.node = empty_stmt_node;;
4066     break;}
4067 case 299:
4068 #line 1709 "./parse.y"
4069 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
4070     break;}
4071 case 300:
4072 #line 1714 "./parse.y"
4073 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
4074     break;}
4075 case 301:
4076 #line 1716 "./parse.y"
4077 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
4078     break;}
4079 case 302:
4080 #line 1718 "./parse.y"
4081 {yyerror ("Missing term"); RECOVER;;
4082     break;}
4083 case 303:
4084 #line 1723 "./parse.y"
4085 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
4086     break;}
4087 case 304:
4088 #line 1725 "./parse.y"
4089 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
4090     break;}
4091 case 305:
4092 #line 1727 "./parse.y"
4093 {yyerror ("Missing term"); RECOVER;;
4094     break;}
4095 case 306:
4096 #line 1729 "./parse.y"
4097 {yyerror ("';' expected"); RECOVER;;
4098     break;}
4099 case 307:
4100 #line 1734 "./parse.y"
4101 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
4102     break;}
4103 case 308:
4104 #line 1736 "./parse.y"
4105 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
4106     break;}
4107 case 309:
4108 #line 1738 "./parse.y"
4109 {yyerror ("Missing term"); RECOVER;;
4110     break;}
4111 case 310:
4112 #line 1740 "./parse.y"
4113 {yyerror ("';' expected"); RECOVER;;
4114     break;}
4115 case 311:
4116 #line 1745 "./parse.y"
4117 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
4118     break;}
4119 case 312:
4120 #line 1747 "./parse.y"
4121 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
4122     break;}
4123 case 313:
4124 #line 1749 "./parse.y"
4125 {yyerror ("Missing term"); RECOVER;;
4126     break;}
4127 case 314:
4128 #line 1751 "./parse.y"
4129 {yyerror ("';' expected"); RECOVER;;
4130     break;}
4131 case 315:
4132 #line 1756 "./parse.y"
4133
4134                   yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
4135                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
4136                 ;
4137     break;}
4138 case 316:
4139 #line 1761 "./parse.y"
4140 {yyerror ("Missing term"); RECOVER;;
4141     break;}
4142 case 317:
4143 #line 1763 "./parse.y"
4144 {yyerror ("';' expected"); RECOVER;;
4145     break;}
4146 case 318:
4147 #line 1768 "./parse.y"
4148
4149                   yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4150                   EXPR_WFL_LINECOL (yyval.node) = 
4151                     EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
4152                 ;
4153     break;}
4154 case 319:
4155 #line 1774 "./parse.y"
4156 {yyerror ("'{' expected"); RECOVER;;
4157     break;}
4158 case 320:
4159 #line 1776 "./parse.y"
4160 {yyerror ("'(' expected"); RECOVER;;
4161     break;}
4162 case 321:
4163 #line 1778 "./parse.y"
4164 {yyerror ("Missing term"); RECOVER;;
4165     break;}
4166 case 322:
4167 #line 1780 "./parse.y"
4168 {yyerror ("Missing term"); RECOVER;;
4169     break;}
4170 case 323:
4171 #line 1785 "./parse.y"
4172 {
4173                   check_modifiers (
4174              "Illegal modifier `%s'. Only `synchronized' was expected here",
4175                                    yyvsp[0].value, ACC_SYNCHRONIZED);
4176                   if (yyvsp[0].value != ACC_SYNCHRONIZED)
4177                     MODIFIER_WFL (SYNCHRONIZED_TK) = 
4178                       build_wfl_node (NULL_TREE);
4179                 ;
4180     break;}
4181 case 324:
4182 #line 1797 "./parse.y"
4183 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4184     break;}
4185 case 325:
4186 #line 1799 "./parse.y"
4187 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4188     break;}
4189 case 326:
4190 #line 1801 "./parse.y"
4191 { yyval.node = build_try_finally_statement 
4192                     (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
4193                                                        yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
4194                 ;
4195     break;}
4196 case 327:
4197 #line 1806 "./parse.y"
4198 {yyerror ("'{' expected"); DRECOVER (try_statement);;
4199     break;}
4200 case 329:
4201 #line 1812 "./parse.y"
4202
4203                   TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
4204                   yyval.node = yyvsp[0].node;
4205                 ;
4206     break;}
4207 case 330:
4208 #line 1820 "./parse.y"
4209
4210                   java_method_add_stmt (current_function_decl, yyvsp[0].node);
4211                   exit_block ();
4212                   yyval.node = yyvsp[-1].node;
4213                 ;
4214     break;}
4215 case 331:
4216 #line 1828 "./parse.y"
4217
4218                   /* We add a block to define a scope for
4219                      formal_parameter (CCBP). The formal parameter is
4220                      declared initialized by the appropriate function
4221                      call */
4222                   tree ccpb = enter_block ();
4223                   tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location, 
4224                                                 TREE_PURPOSE (yyvsp[-1].node), 
4225                                                 soft_exceptioninfo_call_node);
4226                   declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4227                                            build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
4228                                                             init));
4229                   yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4230                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4231                 ;
4232     break;}
4233 case 332:
4234 #line 1844 "./parse.y"
4235 {yyerror ("'(' expected"); RECOVER; yyval.node = NULL_TREE;;
4236     break;}
4237 case 333:
4238 #line 1846 "./parse.y"
4239 {
4240                   yyerror ("Missing term or ')' expected"); 
4241                   RECOVER; yyval.node = NULL_TREE;
4242                 ;
4243     break;}
4244 case 334:
4245 #line 1851 "./parse.y"
4246 {yyerror ("Missing term"); RECOVER; yyval.node = NULL_TREE;;
4247     break;}
4248 case 335:
4249 #line 1856 "./parse.y"
4250 { yyval.node = yyvsp[0].node; ;
4251     break;}
4252 case 336:
4253 #line 1858 "./parse.y"
4254 {yyerror ("'{' expected"); RECOVER; ;
4255     break;}
4256 case 340:
4257 #line 1870 "./parse.y"
4258 { yyval.node = build_this (yyvsp[0].operator.location); ;
4259     break;}
4260 case 341:
4261 #line 1872 "./parse.y"
4262 {yyval.node = yyvsp[-1].node;;
4263     break;}
4264 case 347:
4265 #line 1882 "./parse.y"
4266
4267                   tree wfl = build_wfl_node (this_identifier_node);
4268                   yyval.node = make_qualified_primary (yyvsp[-2].node, wfl, EXPR_WFL_LINECOL (yyvsp[-2].node));
4269                 ;
4270     break;}
4271 case 348:
4272 #line 1887 "./parse.y"
4273 {yyerror ("')' expected"); RECOVER;;
4274     break;}
4275 case 349:
4276 #line 1889 "./parse.y"
4277 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4278     break;}
4279 case 350:
4280 #line 1891 "./parse.y"
4281 {yyerror ("'class' expected" ); RECOVER;;
4282     break;}
4283 case 351:
4284 #line 1893 "./parse.y"
4285 {yyerror ("'class' expected" ); RECOVER;;
4286     break;}
4287 case 352:
4288 #line 1901 "./parse.y"
4289
4290                   yyval.node = build_java_array_type (yyvsp[-2].node, -1);
4291                   CLASS_LOADED_P (yyval.node) = 1;
4292                 ;
4293     break;}
4294 case 353:
4295 #line 1906 "./parse.y"
4296 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
4297     break;}
4298 case 354:
4299 #line 1916 "./parse.y"
4300 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4301     break;}
4302 case 355:
4303 #line 1918 "./parse.y"
4304 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4305     break;}
4306 case 356:
4307 #line 1920 "./parse.y"
4308 { yyval.node = build_class_ref (yyvsp[-2].node); ;
4309     break;}
4310 case 357:
4311 #line 1922 "./parse.y"
4312 { yyval.node = build_class_ref (void_type_node); ;
4313     break;}
4314 case 358:
4315 #line 1927 "./parse.y"
4316 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4317     break;}
4318 case 359:
4319 #line 1929 "./parse.y"
4320 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4321     break;}
4322 case 361:
4323 #line 1935 "./parse.y"
4324
4325                   tree ctor = build_new_invocation (yyvsp[-2].node, NULL_TREE);
4326                   yyval.node = make_qualified_primary (yyvsp[-3].node, ctor, 
4327                                                EXPR_WFL_LINECOL (yyvsp[-3].node));
4328                 ;
4329     break;}
4330 case 363:
4331 #line 1942 "./parse.y"
4332
4333                   tree ctor = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node);
4334                   yyval.node = make_qualified_primary (yyvsp[-4].node, ctor, 
4335                                                EXPR_WFL_LINECOL (yyvsp[-4].node));
4336                 ;
4337     break;}
4338 case 365:
4339 #line 1949 "./parse.y"
4340 {yyerror ("'(' expected"); DRECOVER(new_1);;
4341     break;}
4342 case 366:
4343 #line 1951 "./parse.y"
4344 {yyerror ("'(' expected"); RECOVER;;
4345     break;}
4346 case 367:
4347 #line 1953 "./parse.y"
4348 {yyerror ("')' or term expected"); RECOVER;;
4349     break;}
4350 case 368:
4351 #line 1955 "./parse.y"
4352 {yyerror ("')' expected"); RECOVER;;
4353     break;}
4354 case 369:
4355 #line 1957 "./parse.y"
4356 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4357     break;}
4358 case 370:
4359 #line 1959 "./parse.y"
4360 {yyerror ("'(' expected"); RECOVER;;
4361     break;}
4362 case 371:
4363 #line 1969 "./parse.y"
4364 { create_anonymous_class (yyvsp[-4].operator.location, yyvsp[-3].node); ;
4365     break;}
4366 case 372:
4367 #line 1971 "./parse.y"
4368
4369                   tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4370                   EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-5].node);
4371
4372                   end_class_declaration (1);
4373
4374                   /* Now we can craft the new expression */
4375                   yyval.node = build_new_invocation (id, yyvsp[-3].node);
4376
4377                   /* Note that we can't possibly be here if
4378                      `class_type' is an interface (in which case the
4379                      anonymous class extends Object and implements
4380                      `class_type', hence its constructor can't have
4381                      arguments.) */
4382
4383                   /* Otherwise, the innerclass must feature a
4384                      constructor matching `argument_list'. Anonymous
4385                      classes are a bit special: it's impossible to
4386                      define constructor for them, hence constructors
4387                      must be generated following the hints provided by
4388                      the `new' expression. Whether a super constructor
4389                      of that nature exists or not is to be verified
4390                      later on in verify_constructor_super. 
4391
4392                      It's during the expansion of a `new' statement
4393                      refering to an anonymous class that a ctor will
4394                      be generated for the anonymous class, with the
4395                      right arguments. */
4396
4397                 ;
4398     break;}
4399 case 373:
4400 #line 2002 "./parse.y"
4401 { create_anonymous_class (yyvsp[-3].operator.location, yyvsp[-2].node); ;
4402     break;}
4403 case 374:
4404 #line 2004 "./parse.y"
4405
4406                   tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4407                   EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-4].node);
4408
4409                   end_class_declaration (1);
4410
4411                   /* Now we can craft the new expression. The
4412                      statement doesn't need to be remember so that a
4413                      constructor can be generated, since its signature
4414                      is already known. */
4415                   yyval.node = build_new_invocation (id, NULL_TREE);
4416                 ;
4417     break;}
4418 case 375:
4419 #line 2020 "./parse.y"
4420 { yyval.node = yyvsp[-2].node; ;
4421     break;}
4422 case 376:
4423 #line 2022 "./parse.y"
4424 { yyval.node = yyvsp[-2].node; ;
4425     break;}
4426 case 377:
4427 #line 2027 "./parse.y"
4428
4429                   yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4430                   ctxp->formal_parameter_number = 1; 
4431                 ;
4432     break;}
4433 case 378:
4434 #line 2032 "./parse.y"
4435 {
4436                   ctxp->formal_parameter_number += 1;
4437                   yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4438                 ;
4439     break;}
4440 case 379:
4441 #line 2037 "./parse.y"
4442 {yyerror ("Missing term"); RECOVER;;
4443     break;}
4444 case 380:
4445 #line 2042 "./parse.y"
4446 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4447     break;}
4448 case 381:
4449 #line 2044 "./parse.y"
4450 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4451     break;}
4452 case 382:
4453 #line 2046 "./parse.y"
4454 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4455     break;}
4456 case 383:
4457 #line 2048 "./parse.y"
4458 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4459     break;}
4460 case 384:
4461 #line 2052 "./parse.y"
4462 {
4463                   char *sig;
4464                   while (CURRENT_OSB (ctxp)--)
4465                     obstack_1grow (&temporary_obstack, '[');
4466                   sig = obstack_finish (&temporary_obstack);
4467                   yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4468                               yyvsp[-2].node, get_identifier (sig), yyvsp[0].node);
4469                 ;
4470     break;}
4471 case 385:
4472 #line 2061 "./parse.y"
4473
4474                   tree type = yyvsp[-2].node;
4475                   while (CURRENT_OSB (ctxp)--)
4476                     type = build_java_array_type (type, -1);
4477                   yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE, 
4478                               build_pointer_type (type), NULL_TREE, yyvsp[0].node);
4479                 ;
4480     break;}
4481 case 386:
4482 #line 2069 "./parse.y"
4483 {yyerror ("'[' expected"); DRECOVER ("]");;
4484     break;}
4485 case 387:
4486 #line 2071 "./parse.y"
4487 {yyerror ("']' expected"); RECOVER;;
4488     break;}
4489 case 388:
4490 #line 2076 "./parse.y"
4491 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4492     break;}
4493 case 389:
4494 #line 2078 "./parse.y"
4495 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4496     break;}
4497 case 390:
4498 #line 2083 "./parse.y"
4499
4500                   if (JNUMERIC_TYPE_P (TREE_TYPE (yyvsp[-1].node)))
4501                     {
4502                       yyvsp[-1].node = build_wfl_node (yyvsp[-1].node);
4503                       TREE_TYPE (yyvsp[-1].node) = NULL_TREE;
4504                     }
4505                   EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4506                   yyval.node = yyvsp[-1].node;
4507                 ;
4508     break;}
4509 case 391:
4510 #line 2093 "./parse.y"
4511 {yyerror ("']' expected"); RECOVER;;
4512     break;}
4513 case 392:
4514 #line 2095 "./parse.y"
4515 {
4516                   yyerror ("Missing term");
4517                   yyerror ("']' expected");
4518                   RECOVER;
4519                 ;
4520     break;}
4521 case 393:
4522 #line 2104 "./parse.y"
4523
4524                   int allocate = 0;
4525                   /* If not initialized, allocate memory for the osb
4526                      numbers stack */
4527                   if (!ctxp->osb_limit)
4528                     {
4529                       allocate = ctxp->osb_limit = 32;
4530                       ctxp->osb_depth = -1;
4531                     }
4532                   /* If capacity overflown, reallocate a bigger chunk */
4533                   else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4534                     allocate = ctxp->osb_limit << 1;
4535                   
4536                   if (allocate)
4537                     {
4538                       allocate *= sizeof (int);
4539                       if (ctxp->osb_number)
4540                         ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
4541                                                             allocate);
4542                       else
4543                         ctxp->osb_number = (int *)xmalloc (allocate);
4544                     }
4545                   ctxp->osb_depth++;
4546                   CURRENT_OSB (ctxp) = 1;
4547                 ;
4548     break;}
4549 case 394:
4550 #line 2130 "./parse.y"
4551 { CURRENT_OSB (ctxp)++; ;
4552     break;}
4553 case 395:
4554 #line 2132 "./parse.y"
4555 { yyerror ("']' expected"); RECOVER;;
4556     break;}
4557 case 396:
4558 #line 2137 "./parse.y"
4559 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4560     break;}
4561 case 397:
4562 #line 2141 "./parse.y"
4563 {
4564                   tree super_wfl = 
4565                     build_wfl_node (super_identifier_node);
4566                   EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4567                   yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4568                 ;
4569     break;}
4570 case 398:
4571 #line 2148 "./parse.y"
4572 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4573     break;}
4574 case 399:
4575 #line 2153 "./parse.y"
4576 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4577     break;}
4578 case 400:
4579 #line 2155 "./parse.y"
4580 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4581     break;}
4582 case 401:
4583 #line 2157 "./parse.y"
4584
4585                   if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4586                     yyval.node = build_this_super_qualified_invocation 
4587                       (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4588                   else
4589                     {
4590                       tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4591                       yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4592                     }
4593                 ;
4594     break;}
4595 case 402:
4596 #line 2168 "./parse.y"
4597
4598                   if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4599                     yyval.node = build_this_super_qualified_invocation 
4600                       (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4601                   else
4602                     {
4603                       tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4604                       yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4605                     }
4606                 ;
4607     break;}
4608 case 403:
4609 #line 2179 "./parse.y"
4610
4611                   yyval.node = build_this_super_qualified_invocation 
4612                     (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4613                 ;
4614     break;}
4615 case 404:
4616 #line 2184 "./parse.y"
4617 {
4618                   yyval.node = build_this_super_qualified_invocation 
4619                     (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4620                 ;
4621     break;}
4622 case 405:
4623 #line 2193 "./parse.y"
4624 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4625     break;}
4626 case 406:
4627 #line 2195 "./parse.y"
4628 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4629     break;}
4630 case 407:
4631 #line 2200 "./parse.y"
4632 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4633     break;}
4634 case 408:
4635 #line 2202 "./parse.y"
4636 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4637     break;}
4638 case 409:
4639 #line 2204 "./parse.y"
4640 {
4641                   yyerror ("Missing term and ']' expected");
4642                   DRECOVER(array_access);
4643                 ;
4644     break;}
4645 case 410:
4646 #line 2209 "./parse.y"
4647 {
4648                   yyerror ("']' expected");
4649                   DRECOVER(array_access);
4650                 ;
4651     break;}
4652 case 411:
4653 #line 2214 "./parse.y"
4654 {
4655                   yyerror ("Missing term and ']' expected");
4656                   DRECOVER(array_access);
4657                 ;
4658     break;}
4659 case 412:
4660 #line 2219 "./parse.y"
4661 {
4662                   yyerror ("']' expected");
4663                   DRECOVER(array_access);
4664                 ;
4665     break;}
4666 case 417:
4667 #line 2234 "./parse.y"
4668 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4669     break;}
4670 case 418:
4671 #line 2239 "./parse.y"
4672 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4673     break;}
4674 case 421:
4675 #line 2246 "./parse.y"
4676 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4677     break;}
4678 case 422:
4679 #line 2248 "./parse.y"
4680 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4681     break;}
4682 case 424:
4683 #line 2251 "./parse.y"
4684 {yyerror ("Missing term"); RECOVER;
4685     break;}
4686 case 425:
4687 #line 2253 "./parse.y"
4688 {yyerror ("Missing term"); RECOVER;
4689     break;}
4690 case 426:
4691 #line 2258 "./parse.y"
4692 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4693     break;}
4694 case 427:
4695 #line 2260 "./parse.y"
4696 {yyerror ("Missing term"); RECOVER;
4697     break;}
4698 case 428:
4699 #line 2265 "./parse.y"
4700 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4701     break;}
4702 case 429:
4703 #line 2267 "./parse.y"
4704 {yyerror ("Missing term"); RECOVER;
4705     break;}
4706 case 431:
4707 #line 2273 "./parse.y"
4708 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4709     break;}
4710 case 432:
4711 #line 2275 "./parse.y"
4712 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4713     break;}
4714 case 434:
4715 #line 2278 "./parse.y"
4716 {yyerror ("Missing term"); RECOVER;
4717     break;}
4718 case 435:
4719 #line 2280 "./parse.y"
4720 {yyerror ("Missing term"); RECOVER;
4721     break;}
4722 case 436:
4723 #line 2285 "./parse.y"
4724
4725                   tree type = yyvsp[-3].node;
4726                   while (CURRENT_OSB (ctxp)--)
4727                     type = build_java_array_type (type, -1);
4728                   ctxp->osb_depth--;
4729                   yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node); 
4730                 ;
4731     break;}
4732 case 437:
4733 #line 2293 "./parse.y"
4734 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4735     break;}
4736 case 438:
4737 #line 2295 "./parse.y"
4738 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4739     break;}
4740 case 439:
4741 #line 2297 "./parse.y"
4742
4743                   const char *ptr;
4744                   while (CURRENT_OSB (ctxp)--)
4745                     obstack_1grow (&temporary_obstack, '[');
4746                   ctxp->osb_depth--;
4747                   obstack_grow0 (&temporary_obstack, 
4748                                  IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4749                                  IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4750                   ptr = obstack_finish (&temporary_obstack);
4751                   EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4752                   yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4753                 ;
4754     break;}
4755 case 440:
4756 #line 2310 "./parse.y"
4757 {yyerror ("']' expected, invalid type expression");;
4758     break;}
4759 case 441:
4760 #line 2312 "./parse.y"
4761 {
4762                   if (ctxp->prevent_ese != lineno)
4763                     yyerror ("Invalid type expression"); RECOVER;
4764                   RECOVER;
4765                 ;
4766     break;}
4767 case 442:
4768 #line 2318 "./parse.y"
4769 {yyerror ("Missing term"); RECOVER;;
4770     break;}
4771 case 443:
4772 #line 2320 "./parse.y"
4773 {yyerror ("Missing term"); RECOVER;;
4774     break;}
4775 case 444:
4776 #line 2322 "./parse.y"
4777 {yyerror ("Missing term"); RECOVER;;
4778     break;}
4779 case 446:
4780 #line 2328 "./parse.y"
4781
4782                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), 
4783                                     yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4784                 ;
4785     break;}
4786 case 447:
4787 #line 2333 "./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 448:
4794 #line 2338 "./parse.y"
4795 {
4796                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4797                                     yyvsp[-2].node, yyvsp[0].node); 
4798                 ;
4799     break;}
4800 case 449:
4801 #line 2343 "./parse.y"
4802 {yyerror ("Missing term"); RECOVER;;
4803     break;}
4804 case 450:
4805 #line 2345 "./parse.y"
4806 {yyerror ("Missing term"); RECOVER;;
4807     break;}
4808 case 451:
4809 #line 2347 "./parse.y"
4810 {yyerror ("Missing term"); RECOVER;;
4811     break;}
4812 case 453:
4813 #line 2353 "./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 454:
4820 #line 2358 "./parse.y"
4821 {
4822                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4823                                     yyvsp[-2].node, yyvsp[0].node); 
4824                 ;
4825     break;}
4826 case 455:
4827 #line 2363 "./parse.y"
4828 {yyerror ("Missing term"); RECOVER;;
4829     break;}
4830 case 456:
4831 #line 2365 "./parse.y"
4832 {yyerror ("Missing term"); RECOVER;;
4833     break;}
4834 case 458:
4835 #line 2371 "./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 459:
4842 #line 2376 "./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 460:
4849 #line 2381 "./parse.y"
4850 {
4851                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4852                                     yyvsp[-2].node, yyvsp[0].node); 
4853                 ;
4854     break;}
4855 case 461:
4856 #line 2386 "./parse.y"
4857 {yyerror ("Missing term"); RECOVER;;
4858     break;}
4859 case 462:
4860 #line 2388 "./parse.y"
4861 {yyerror ("Missing term"); RECOVER;;
4862     break;}
4863 case 463:
4864 #line 2390 "./parse.y"
4865 {yyerror ("Missing term"); RECOVER;;
4866     break;}
4867 case 465:
4868 #line 2396 "./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 466:
4875 #line 2401 "./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 467:
4882 #line 2406 "./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 468:
4889 #line 2411 "./parse.y"
4890 {
4891                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4892                                     yyvsp[-2].node, yyvsp[0].node); 
4893                 ;
4894     break;}
4895 case 469:
4896 #line 2416 "./parse.y"
4897 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4898     break;}
4899 case 470:
4900 #line 2418 "./parse.y"
4901 {yyerror ("Missing term"); RECOVER;;
4902     break;}
4903 case 471:
4904 #line 2420 "./parse.y"
4905 {yyerror ("Missing term"); RECOVER;;
4906     break;}
4907 case 472:
4908 #line 2422 "./parse.y"
4909 {yyerror ("Missing term"); RECOVER;;
4910     break;}
4911 case 473:
4912 #line 2424 "./parse.y"
4913 {yyerror ("Missing term"); RECOVER;;
4914     break;}
4915 case 474:
4916 #line 2426 "./parse.y"
4917 {yyerror ("Invalid reference type"); RECOVER;;
4918     break;}
4919 case 476:
4920 #line 2432 "./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 477:
4927 #line 2437 "./parse.y"
4928 {
4929                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4930                                     yyvsp[-2].node, yyvsp[0].node); 
4931                 ;
4932     break;}
4933 case 478:
4934 #line 2442 "./parse.y"
4935 {yyerror ("Missing term"); RECOVER;;
4936     break;}
4937 case 479:
4938 #line 2444 "./parse.y"
4939 {yyerror ("Missing term"); RECOVER;;
4940     break;}
4941 case 481:
4942 #line 2450 "./parse.y"
4943 {
4944                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4945                                     yyvsp[-2].node, yyvsp[0].node); 
4946                 ;
4947     break;}
4948 case 482:
4949 #line 2455 "./parse.y"
4950 {yyerror ("Missing term"); RECOVER;;
4951     break;}
4952 case 484:
4953 #line 2461 "./parse.y"
4954 {
4955                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4956                                     yyvsp[-2].node, yyvsp[0].node); 
4957                 ;
4958     break;}
4959 case 485:
4960 #line 2466 "./parse.y"
4961 {yyerror ("Missing term"); RECOVER;;
4962     break;}
4963 case 487:
4964 #line 2472 "./parse.y"
4965 {
4966                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4967                                     yyvsp[-2].node, yyvsp[0].node); 
4968                 ;
4969     break;}
4970 case 488:
4971 #line 2477 "./parse.y"
4972 {yyerror ("Missing term"); RECOVER;;
4973     break;}
4974 case 490:
4975 #line 2483 "./parse.y"
4976 {
4977                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4978                                     yyvsp[-2].node, yyvsp[0].node); 
4979                 ;
4980     break;}
4981 case 491:
4982 #line 2488 "./parse.y"
4983 {yyerror ("Missing term"); RECOVER;;
4984     break;}
4985 case 493:
4986 #line 2494 "./parse.y"
4987 {
4988                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4989                                     yyvsp[-2].node, yyvsp[0].node); 
4990                 ;
4991     break;}
4992 case 494:
4993 #line 2499 "./parse.y"
4994 {yyerror ("Missing term"); RECOVER;;
4995     break;}
4996 case 496:
4997 #line 2505 "./parse.y"
4998 {
4999                   yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
5000                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
5001                 ;
5002     break;}
5003 case 497:
5004 #line 2510 "./parse.y"
5005 {
5006                   YYERROR_NOW;
5007                   yyerror ("Missing term");
5008                   DRECOVER (1);
5009                 ;
5010     break;}
5011 case 498:
5012 #line 2516 "./parse.y"
5013 {yyerror ("Missing term"); DRECOVER (2);;
5014     break;}
5015 case 499:
5016 #line 2518 "./parse.y"
5017 {yyerror ("Missing term"); DRECOVER (3);;
5018     break;}
5019 case 502:
5020 #line 2528 "./parse.y"
5021 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
5022     break;}
5023 case 503:
5024 #line 2530 "./parse.y"
5025 {
5026                   if (ctxp->prevent_ese != lineno)
5027                     yyerror ("Missing term");
5028                   DRECOVER (assign);
5029                 ;
5030     break;}
5031 }
5032    /* the action file gets copied in in place of this dollarsign */
5033 #line 543 "/usr/lib/bison.simple"
5034 \f
5035   yyvsp -= yylen;
5036   yyssp -= yylen;
5037 #ifdef YYLSP_NEEDED
5038   yylsp -= yylen;
5039 #endif
5040
5041 #if YYDEBUG != 0
5042   if (yydebug)
5043     {
5044       short *ssp1 = yyss - 1;
5045       fprintf (stderr, "state stack now");
5046       while (ssp1 != yyssp)
5047         fprintf (stderr, " %d", *++ssp1);
5048       fprintf (stderr, "\n");
5049     }
5050 #endif
5051
5052   *++yyvsp = yyval;
5053
5054 #ifdef YYLSP_NEEDED
5055   yylsp++;
5056   if (yylen == 0)
5057     {
5058       yylsp->first_line = yylloc.first_line;
5059       yylsp->first_column = yylloc.first_column;
5060       yylsp->last_line = (yylsp-1)->last_line;
5061       yylsp->last_column = (yylsp-1)->last_column;
5062       yylsp->text = 0;
5063     }
5064   else
5065     {
5066       yylsp->last_line = (yylsp+yylen-1)->last_line;
5067       yylsp->last_column = (yylsp+yylen-1)->last_column;
5068     }
5069 #endif
5070
5071   /* Now "shift" the result of the reduction.
5072      Determine what state that goes to,
5073      based on the state we popped back to
5074      and the rule number reduced by.  */
5075
5076   yyn = yyr1[yyn];
5077
5078   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5079   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5080     yystate = yytable[yystate];
5081   else
5082     yystate = yydefgoto[yyn - YYNTBASE];
5083
5084   goto yynewstate;
5085
5086 yyerrlab:   /* here on detecting error */
5087
5088   if (! yyerrstatus)
5089     /* If not already recovering from an error, report this error.  */
5090     {
5091       ++yynerrs;
5092
5093 #ifdef YYERROR_VERBOSE
5094       yyn = yypact[yystate];
5095
5096       if (yyn > YYFLAG && yyn < YYLAST)
5097         {
5098           int size = 0;
5099           char *msg;
5100           int x, count;
5101
5102           count = 0;
5103           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
5104           for (x = (yyn < 0 ? -yyn : 0);
5105                x < (sizeof(yytname) / sizeof(char *)); x++)
5106             if (yycheck[x + yyn] == x)
5107               size += strlen(yytname[x]) + 15, count++;
5108           msg = (char *) malloc(size + 15);
5109           if (msg != 0)
5110             {
5111               strcpy(msg, "parse error");
5112
5113               if (count < 5)
5114                 {
5115                   count = 0;
5116                   for (x = (yyn < 0 ? -yyn : 0);
5117                        x < (sizeof(yytname) / sizeof(char *)); x++)
5118                     if (yycheck[x + yyn] == x)
5119                       {
5120                         strcat(msg, count == 0 ? ", expecting `" : " or `");
5121                         strcat(msg, yytname[x]);
5122                         strcat(msg, "'");
5123                         count++;
5124                       }
5125                 }
5126               yyerror(msg);
5127               free(msg);
5128             }
5129           else
5130             yyerror ("parse error; also virtual memory exceeded");
5131         }
5132       else
5133 #endif /* YYERROR_VERBOSE */
5134         yyerror("parse error");
5135     }
5136
5137   goto yyerrlab1;
5138 yyerrlab1:   /* here on error raised explicitly by an action */
5139
5140   if (yyerrstatus == 3)
5141     {
5142       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
5143
5144       /* return failure if at end of input */
5145       if (yychar == YYEOF)
5146         YYABORT;
5147
5148 #if YYDEBUG != 0
5149       if (yydebug)
5150         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5151 #endif
5152
5153       yychar = YYEMPTY;
5154     }
5155
5156   /* Else will try to reuse lookahead token
5157      after shifting the error token.  */
5158
5159   yyerrstatus = 3;              /* Each real token shifted decrements this */
5160
5161   goto yyerrhandle;
5162
5163 yyerrdefault:  /* current state does not do anything special for the error token. */
5164
5165 #if 0
5166   /* This is wrong; only states that explicitly want error tokens
5167      should shift them.  */
5168   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
5169   if (yyn) goto yydefault;
5170 #endif
5171
5172 yyerrpop:   /* pop the current state because it cannot handle the error token */
5173
5174   if (yyssp == yyss) YYABORT;
5175   yyvsp--;
5176   yystate = *--yyssp;
5177 #ifdef YYLSP_NEEDED
5178   yylsp--;
5179 #endif
5180
5181 #if YYDEBUG != 0
5182   if (yydebug)
5183     {
5184       short *ssp1 = yyss - 1;
5185       fprintf (stderr, "Error: state stack now");
5186       while (ssp1 != yyssp)
5187         fprintf (stderr, " %d", *++ssp1);
5188       fprintf (stderr, "\n");
5189     }
5190 #endif
5191
5192 yyerrhandle:
5193
5194   yyn = yypact[yystate];
5195   if (yyn == YYFLAG)
5196     goto yyerrdefault;
5197
5198   yyn += YYTERROR;
5199   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5200     goto yyerrdefault;
5201
5202   yyn = yytable[yyn];
5203   if (yyn < 0)
5204     {
5205       if (yyn == YYFLAG)
5206         goto yyerrpop;
5207       yyn = -yyn;
5208       goto yyreduce;
5209     }
5210   else if (yyn == 0)
5211     goto yyerrpop;
5212
5213   if (yyn == YYFINAL)
5214     YYACCEPT;
5215
5216 #if YYDEBUG != 0
5217   if (yydebug)
5218     fprintf(stderr, "Shifting error token, ");
5219 #endif
5220
5221   *++yyvsp = yylval;
5222 #ifdef YYLSP_NEEDED
5223   *++yylsp = yylloc;
5224 #endif
5225
5226   yystate = yyn;
5227   goto yynewstate;
5228
5229  yyacceptlab:
5230   /* YYACCEPT comes here.  */
5231   if (yyfree_stacks)
5232     {
5233       free (yyss);
5234       free (yyvs);
5235 #ifdef YYLSP_NEEDED
5236       free (yyls);
5237 #endif
5238     }
5239   return 0;
5240
5241  yyabortlab:
5242   /* YYABORT comes here.  */
5243   if (yyfree_stacks)
5244     {
5245       free (yyss);
5246       free (yyvs);
5247 #ifdef YYLSP_NEEDED
5248       free (yyls);
5249 #endif
5250     }
5251   return 1;
5252 }
5253 #line 2556 "./parse.y"
5254
5255 \f
5256
5257 /* This section of the code deal with save/restoring parser contexts.
5258    Add mode documentation here. FIXME */
5259
5260 /* Helper function. Create a new parser context. With
5261    COPY_FROM_PREVIOUS set to a non zero value, content of the previous
5262    context is copied, otherwise, the new context is zeroed. The newly
5263    created context becomes the current one.  */
5264
5265 static void
5266 create_new_parser_context (copy_from_previous)
5267     int copy_from_previous;
5268 {
5269   struct parser_ctxt *new;
5270
5271   new =  (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
5272   if (copy_from_previous)
5273     {
5274       memcpy ((PTR)new, (PTR)ctxp, sizeof (struct parser_ctxt));
5275       new->saved_data_ctx = 1;
5276     }
5277   else
5278     bzero ((PTR) new, sizeof (struct parser_ctxt));
5279       
5280   new->next = ctxp;
5281   ctxp = new;
5282 }
5283
5284 /* Create a new parser context and make it the current one. */
5285
5286 void
5287 java_push_parser_context ()
5288 {
5289   create_new_parser_context (0);
5290   if (ctxp->next)
5291     {
5292       ctxp->incomplete_class = ctxp->next->incomplete_class;
5293       ctxp->gclass_list = ctxp->next->gclass_list;
5294     }
5295 }  
5296
5297 void 
5298 java_pop_parser_context (generate)
5299      int generate;
5300 {
5301   tree current;
5302   struct parser_ctxt *toFree, *next;
5303
5304   if (!ctxp)
5305     return;
5306
5307   toFree = ctxp;
5308   next = ctxp->next;
5309   if (next)
5310     {
5311       next->incomplete_class = ctxp->incomplete_class;
5312       next->gclass_list = ctxp->gclass_list;
5313       lineno = ctxp->lineno;
5314       finput = ctxp->finput;
5315       current_class = ctxp->current_class;
5316     }
5317
5318   /* Set the single import class file flag to 0 for the current list
5319      of imported things */
5320   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5321     IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
5322
5323   /* And restore those of the previous context */
5324   if ((ctxp = next))            /* Assignment is really meant here */
5325     for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5326       IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
5327   
5328   /* If we pushed a context to parse a class intended to be generated,
5329      we keep it so we can remember the class. What we could actually
5330      do is to just update a list of class names.  */
5331   if (generate)
5332     {
5333       toFree->next = ctxp_for_generation;
5334       ctxp_for_generation = toFree;
5335     }
5336   else
5337     free (toFree);
5338 }
5339
5340 /* Create a parser context for the use of saving some global
5341    variables.  */
5342
5343 void
5344 java_parser_context_save_global ()
5345 {
5346   if (!ctxp)
5347     {
5348       java_push_parser_context ();
5349       ctxp->saved_data_ctx = 1;
5350     }
5351
5352   /* If this context already stores data, create a new one suitable
5353      for data storage. */
5354   else if (ctxp->saved_data)
5355     create_new_parser_context (1);
5356
5357   ctxp->finput = finput;
5358   ctxp->lineno = lineno;
5359   ctxp->current_class = current_class;
5360   ctxp->filename = input_filename;
5361   ctxp->current_function_decl = current_function_decl;
5362   ctxp->saved_data = 1;
5363 }
5364
5365 /* Restore some global variables from the previous context. Make the
5366    previous context the current one.  */
5367
5368 void
5369 java_parser_context_restore_global ()
5370 {
5371   finput = ctxp->finput;
5372   lineno = ctxp->lineno;
5373   current_class = ctxp->current_class;
5374   input_filename = ctxp->filename;
5375   current_function_decl = ctxp->current_function_decl;
5376   ctxp->saved_data = 0;
5377   if (ctxp->saved_data_ctx)
5378     java_pop_parser_context (0);
5379 }
5380
5381 /* Suspend vital data for the current class/function being parsed so
5382    that an other class can be parsed. Used to let local/anonymous
5383    classes be parsed.  */
5384
5385 static void
5386 java_parser_context_suspend ()
5387 {
5388   /* This makes debugging through java_debug_context easier */
5389   static const char *name = "<inner buffer context>";
5390
5391   /* Duplicate the previous context, use it to save the globals we're
5392      interested in */
5393   create_new_parser_context (1);
5394   ctxp->current_function_decl = current_function_decl;
5395   ctxp->current_class = current_class;
5396
5397   /* Then create a new context which inherits all data from the
5398      previous one. This will be the new current context  */
5399   create_new_parser_context (1);
5400
5401   /* Help debugging */
5402   ctxp->next->filename = name;
5403 }
5404
5405 /* Resume vital data for the current class/function being parsed so
5406    that an other class can be parsed. Used to let local/anonymous
5407    classes be parsed.  The trick is the data storing file position
5408    informations must be restored to their current value, so parsing
5409    can resume as if no context was ever saved. */
5410
5411 static void
5412 java_parser_context_resume ()
5413 {
5414   struct parser_ctxt *old = ctxp;             /* This one is to be discarded */
5415   struct parser_ctxt *saver = old->next;      /* This one contain saved info */
5416   struct parser_ctxt *restored = saver->next; /* This one is the old current */
5417
5418   /* We need to inherit the list of classes to complete/generate */
5419   restored->incomplete_class = old->incomplete_class;
5420   restored->gclass_list = old->gclass_list;
5421   restored->classd_list = old->classd_list;
5422   restored->class_list = old->class_list;
5423
5424   /* Restore the current class and function from the saver */
5425   current_class = saver->current_class;
5426   current_function_decl = saver->current_function_decl;
5427
5428   /* Retrive the restored context */
5429   ctxp = restored;
5430
5431   /* Re-installed the data for the parsing to carry on */
5432   bcopy (&old->marker_begining, &ctxp->marker_begining,
5433          (size_t)(&ctxp->marker_end - &ctxp->marker_begining));
5434
5435   /* Buffer context can now be discarded */
5436   free (saver);
5437   free (old);
5438 }
5439
5440 /* Add a new anchor node to which all statement(s) initializing static
5441    and non static initialized upon declaration field(s) will be
5442    linked.  */
5443
5444 static void
5445 java_parser_context_push_initialized_field ()
5446 {
5447   tree node;
5448
5449   node = build_tree_list (NULL_TREE, NULL_TREE);
5450   TREE_CHAIN (node) = CPC_STATIC_INITIALIZER_LIST (ctxp);
5451   CPC_STATIC_INITIALIZER_LIST (ctxp) = node;
5452
5453   node = build_tree_list (NULL_TREE, NULL_TREE);
5454   TREE_CHAIN (node) = CPC_INITIALIZER_LIST (ctxp);
5455   CPC_INITIALIZER_LIST (ctxp) = node;
5456
5457   node = build_tree_list (NULL_TREE, NULL_TREE);
5458   TREE_CHAIN (node) = CPC_INSTANCE_INITIALIZER_LIST (ctxp);
5459   CPC_INSTANCE_INITIALIZER_LIST (ctxp) = node;
5460 }
5461
5462 /* Pop the lists of initialized field. If this lists aren't empty,
5463    remember them so we can use it to create and populate the $finit$
5464    or <clinit> functions. */
5465
5466 static void
5467 java_parser_context_pop_initialized_field ()
5468 {
5469   tree stmts;
5470   tree class_type = TREE_TYPE (GET_CPC ());
5471
5472   if (CPC_INITIALIZER_LIST (ctxp))
5473     {
5474       stmts = CPC_INITIALIZER_STMT (ctxp);
5475       CPC_INITIALIZER_LIST (ctxp) = TREE_CHAIN (CPC_INITIALIZER_LIST (ctxp));
5476       if (stmts && !java_error_count)
5477         TYPE_FINIT_STMT_LIST (class_type) = reorder_static_initialized (stmts);
5478     }
5479
5480   if (CPC_STATIC_INITIALIZER_LIST (ctxp))
5481     {
5482       stmts = CPC_STATIC_INITIALIZER_STMT (ctxp);
5483       CPC_STATIC_INITIALIZER_LIST (ctxp) = 
5484         TREE_CHAIN (CPC_STATIC_INITIALIZER_LIST (ctxp));
5485       /* Keep initialization in order to enforce 8.5 */
5486       if (stmts && !java_error_count)
5487         TYPE_CLINIT_STMT_LIST (class_type) = nreverse (stmts);
5488     }
5489
5490   /* JDK 1.1 instance initializers */
5491   if (CPC_INSTANCE_INITIALIZER_LIST (ctxp))
5492     {
5493       stmts = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
5494       CPC_INSTANCE_INITIALIZER_LIST (ctxp) = 
5495         TREE_CHAIN (CPC_INSTANCE_INITIALIZER_LIST (ctxp));
5496       if (stmts && !java_error_count)
5497         TYPE_II_STMT_LIST (class_type) = nreverse (stmts);
5498     }
5499 }
5500
5501 static tree
5502 reorder_static_initialized (list)
5503      tree list;
5504 {
5505   /* We have to keep things in order. The alias initializer have to
5506      come first, then the initialized regular field, in reverse to
5507      keep them in lexical order. */
5508   tree marker, previous = NULL_TREE;
5509   for (marker = list; marker; previous = marker, marker = TREE_CHAIN (marker))
5510     if (TREE_CODE (marker) == TREE_LIST 
5511         && !TREE_VALUE (marker) && !TREE_PURPOSE (marker))
5512       break;
5513   
5514   /* No static initialized, the list is fine as is */
5515   if (!previous)
5516     list = TREE_CHAIN (marker);
5517
5518   /* No marker? reverse the whole list */
5519   else if (!marker)
5520     list = nreverse (list);
5521
5522   /* Otherwise, reverse what's after the marker and the new reordered
5523      sublist will replace the marker. */
5524   else
5525     {
5526       TREE_CHAIN (previous) = NULL_TREE;
5527       list = nreverse (list);
5528       list = chainon (TREE_CHAIN (marker), list);
5529     }
5530   return list;
5531 }
5532
5533 /* Helper functions to dump the parser context stack.  */
5534
5535 #define TAB_CONTEXT(C) \
5536   {int i; for (i = 0; i < (C); i++) fputc (' ', stderr);}
5537
5538 static void
5539 java_debug_context_do (tab)
5540      int tab;
5541 {
5542   struct parser_ctxt *copy = ctxp;
5543   while (copy)
5544     {
5545       TAB_CONTEXT (tab);
5546       fprintf (stderr, "ctxt: 0x%0lX\n", (unsigned long)copy);
5547       TAB_CONTEXT (tab);
5548       fprintf (stderr, "filename: %s\n", copy->filename);
5549       TAB_CONTEXT (tab);
5550       fprintf (stderr, "lineno: %d\n", copy->lineno);
5551       TAB_CONTEXT (tab);
5552       fprintf (stderr, "package: %s\n",
5553                (copy->package ? 
5554                 IDENTIFIER_POINTER (copy->package) : "<none>"));
5555       TAB_CONTEXT (tab);
5556       fprintf (stderr, "context for saving: %d\n", copy->saved_data_ctx);
5557       TAB_CONTEXT (tab);
5558       fprintf (stderr, "saved data: %d\n", copy->saved_data);
5559       copy = copy->next;
5560       tab += 2;
5561     }
5562 }
5563
5564 /* Dump the stacked up parser contexts. Intended to be called from a
5565    debugger.  */
5566
5567 void
5568 java_debug_context ()
5569 {
5570   java_debug_context_do (0);
5571 }
5572
5573 \f
5574
5575 /* Flag for the error report routine to issue the error the first time
5576    it's called (overriding the default behavior which is to drop the
5577    first invocation and honor the second one, taking advantage of a
5578    richer context.  */
5579 static int force_error = 0;
5580
5581 /* Reporting an constructor invocation error.  */
5582 static void
5583 parse_ctor_invocation_error ()
5584 {
5585   if (DECL_CONSTRUCTOR_P (current_function_decl))
5586     yyerror ("Constructor invocation must be first thing in a constructor"); 
5587   else
5588     yyerror ("Only constructors can invoke constructors");
5589 }
5590
5591 /* Reporting JDK1.1 features not implemented.  */
5592
5593 static tree
5594 parse_jdk1_1_error (msg)
5595     const char *msg;
5596 {
5597   sorry (": `%s' JDK1.1(TM) feature", msg);
5598   java_error_count++;
5599   return empty_stmt_node;
5600 }
5601
5602 static int do_warning = 0;
5603
5604 void
5605 yyerror (msg)
5606      const char *msg;
5607 {
5608   static java_lc elc;
5609   static int  prev_lineno;
5610   static const char *prev_msg;
5611
5612   int save_lineno;
5613   char *remainder, *code_from_source;
5614   extern struct obstack temporary_obstack;
5615   
5616   if (!force_error && prev_lineno == lineno)
5617     return;
5618
5619   /* Save current error location but report latter, when the context is
5620      richer.  */
5621   if (ctxp->java_error_flag == 0)
5622     {
5623       ctxp->java_error_flag = 1;
5624       elc = ctxp->elc;
5625       /* Do something to use the previous line if we're reaching the
5626          end of the file... */
5627 #ifdef VERBOSE_SKELETON
5628       printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5629 #endif
5630       return;
5631     }
5632
5633   /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5634   if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5635     return;
5636
5637   ctxp->java_error_flag = 0;
5638   if (do_warning)
5639     java_warning_count++;
5640   else
5641     java_error_count++;
5642   
5643   if (elc.col == 0 && msg && msg[1] == ';')
5644     {
5645       elc.col  = ctxp->p_line->char_col-1;
5646       elc.line = ctxp->p_line->lineno;
5647     }
5648
5649   save_lineno = lineno;
5650   prev_lineno = lineno = elc.line;
5651   prev_msg = msg;
5652
5653   code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5654   obstack_grow0 (&temporary_obstack, 
5655                  code_from_source, strlen (code_from_source));
5656   remainder = obstack_finish (&temporary_obstack);
5657   if (do_warning)
5658     warning ("%s.\n%s", msg, remainder);
5659   else
5660     error ("%s.\n%s", msg, remainder);
5661
5662   /* This allow us to cheaply avoid an extra 'Invalid expression
5663      statement' error report when errors have been already reported on
5664      the same line. This occurs when we report an error but don't have
5665      a synchronization point other than ';', which
5666      expression_statement is the only one to take care of.  */
5667   ctxp->prevent_ese = lineno = save_lineno;
5668 }
5669
5670 static void
5671 issue_warning_error_from_context (cl, msg, ap)
5672      tree cl;
5673      const char *msg;
5674      va_list ap;
5675 {
5676   const char *saved, *saved_input_filename;
5677   char buffer [4096];
5678   vsprintf (buffer, msg, ap);
5679   force_error = 1;
5680
5681   ctxp->elc.line = EXPR_WFL_LINENO (cl);
5682   ctxp->elc.col  = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 : 
5683                     (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5684
5685   /* We have a CL, that's a good reason for using it if it contains data */
5686   saved = ctxp->filename;
5687   if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5688     ctxp->filename = EXPR_WFL_FILENAME (cl);
5689   saved_input_filename = input_filename;
5690   input_filename = ctxp->filename;
5691   java_error (NULL);
5692   java_error (buffer);
5693   ctxp->filename = saved;
5694   input_filename = saved_input_filename;
5695   force_error = 0;
5696 }
5697
5698 /* Issue an error message at a current source line CL */
5699
5700 void
5701 parse_error_context VPARAMS ((tree cl, const char *msg, ...))
5702 {
5703 #ifndef ANSI_PROTOTYPES
5704   tree cl;
5705   const char *msg;
5706 #endif
5707   va_list ap;
5708
5709   VA_START (ap, msg);
5710 #ifndef ANSI_PROTOTYPES
5711   cl = va_arg (ap, tree);
5712   msg = va_arg (ap, const char *);
5713 #endif
5714   issue_warning_error_from_context (cl, msg, ap);
5715   va_end (ap);
5716 }
5717
5718 /* Issue a warning at a current source line CL */
5719
5720 static void
5721 parse_warning_context VPARAMS ((tree cl, const char *msg, ...))
5722 {
5723 #ifndef ANSI_PROTOTYPES
5724   tree cl;
5725   const char *msg;
5726 #endif
5727   va_list ap;
5728
5729   VA_START (ap, msg);
5730 #ifndef ANSI_PROTOTYPES
5731   cl = va_arg (ap, tree);
5732   msg = va_arg (ap, const char *);
5733 #endif
5734
5735   force_error = do_warning = 1;
5736   issue_warning_error_from_context (cl, msg, ap);
5737   do_warning = force_error = 0;
5738   va_end (ap);
5739 }
5740
5741 static tree
5742 find_expr_with_wfl (node)
5743      tree node;
5744 {
5745   while (node)
5746     {
5747       char code;
5748       tree to_return;
5749
5750       switch (TREE_CODE (node))
5751         {
5752         case BLOCK:
5753           node = BLOCK_EXPR_BODY (node);
5754           continue;
5755
5756         case COMPOUND_EXPR:
5757           to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
5758           if (to_return)
5759             return to_return;
5760           node = TREE_OPERAND (node, 1);
5761           continue;
5762
5763         case LOOP_EXPR:
5764           node = TREE_OPERAND (node, 0);
5765           continue;
5766           
5767         case LABELED_BLOCK_EXPR:
5768           node = TREE_OPERAND (node, 1);
5769           continue;
5770
5771         default:
5772           code = TREE_CODE_CLASS (TREE_CODE (node));
5773           if (((code == '1') || (code == '2') || (code == 'e'))
5774               && EXPR_WFL_LINECOL (node))
5775             return node;
5776           return NULL_TREE;
5777         }
5778     }
5779   return NULL_TREE;
5780 }
5781
5782 /* Issue a missing return statement error. Uses METHOD to figure the
5783    last line of the method the error occurs in.  */
5784
5785 static void
5786 missing_return_error (method)
5787      tree method;
5788 {
5789   EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
5790   parse_error_context (wfl_operator, "Missing return statement");
5791 }
5792
5793 /* Issue an unreachable statement error. From NODE, find the next
5794    statement to report appropriately.  */
5795 static void
5796 unreachable_stmt_error (node)
5797      tree node;
5798 {
5799   /* Browse node to find the next expression node that has a WFL. Use
5800      the location to report the error */
5801   if (TREE_CODE (node) == COMPOUND_EXPR)
5802     node = find_expr_with_wfl (TREE_OPERAND (node, 1));
5803   else
5804     node = find_expr_with_wfl (node);
5805
5806   if (node)
5807     {
5808       EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
5809       parse_error_context (wfl_operator, "Unreachable statement");
5810     }
5811   else
5812     fatal ("Can't get valid statement - unreachable_stmt_error");
5813 }
5814
5815 int
5816 java_report_errors ()
5817 {
5818   if (java_error_count)
5819     fprintf (stderr, "%d error%s", 
5820              java_error_count, (java_error_count == 1 ? "" : "s"));
5821   if (java_warning_count)
5822     fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
5823              java_warning_count, (java_warning_count == 1 ? "" : "s"));
5824   if (java_error_count || java_warning_count)
5825     putc ('\n', stderr);
5826   return java_error_count;
5827 }
5828
5829 static char *
5830 java_accstring_lookup (flags)
5831      int flags;
5832 {
5833   static char buffer [80];
5834 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
5835
5836   /* Access modifier looked-up first for easier report on forbidden
5837      access. */
5838   if (flags & ACC_PUBLIC) COPY_RETURN ("public");
5839   if (flags & ACC_PRIVATE) COPY_RETURN ("private");
5840   if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
5841   if (flags & ACC_STATIC) COPY_RETURN ("static");
5842   if (flags & ACC_FINAL) COPY_RETURN ("final");
5843   if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
5844   if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
5845   if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
5846   if (flags & ACC_NATIVE) COPY_RETURN ("native");
5847   if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
5848   if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
5849
5850   buffer [0] = '\0';
5851   return buffer;
5852 #undef COPY_RETURN
5853 }
5854
5855 /* Issuing error messages upon redefinition of classes, interfaces or
5856    variables. */
5857
5858 static void
5859 classitf_redefinition_error (context, id, decl, cl)
5860      const char *context;
5861      tree id, decl, cl;
5862 {
5863   parse_error_context (cl, "%s `%s' already defined in %s:%d", 
5864                        context, IDENTIFIER_POINTER (id), 
5865                        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5866   /* Here we should point out where its redefined. It's a unicode. FIXME */
5867 }
5868
5869 static void
5870 variable_redefinition_error (context, name, type, line)
5871      tree context, name, type;
5872      int line;
5873 {
5874   const char *type_name;
5875
5876   /* Figure a proper name for type. We might haven't resolved it */
5877   if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
5878     type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
5879   else
5880     type_name = lang_printable_name (type, 0);
5881
5882   parse_error_context (context,
5883                        "Variable `%s' is already defined in this method and was declared `%s %s' at line %d", 
5884                        IDENTIFIER_POINTER (name),
5885                        type_name, IDENTIFIER_POINTER (name), line);
5886 }
5887
5888 static tree
5889 build_array_from_name (type, type_wfl, name, ret_name)
5890      tree type, type_wfl, name, *ret_name;
5891 {
5892   int more_dims = 0;
5893   const char *string;
5894
5895   /* Eventually get more dims */
5896   string = IDENTIFIER_POINTER (name);
5897   while (string [more_dims] == '[')
5898     more_dims++;
5899   
5900   /* If we have, then craft a new type for this variable */
5901   if (more_dims)
5902     {
5903       name = get_identifier (&string [more_dims]);
5904
5905       /* If we have a pointer, use its type */
5906       if (TREE_CODE (type) == POINTER_TYPE)
5907         type = TREE_TYPE (type);
5908
5909       /* Building the first dimension of a primitive type uses this
5910          function */
5911       if (JPRIMITIVE_TYPE_P (type))
5912         {
5913           type = build_java_array_type (type, -1);
5914           CLASS_LOADED_P (type) = 1;
5915           more_dims--;
5916         }
5917       /* Otherwise, if we have a WFL for this type, use it (the type
5918          is already an array on an unresolved type, and we just keep
5919          on adding dimensions) */
5920       else if (type_wfl)
5921         type = type_wfl;
5922
5923       /* Add all the dimensions */
5924       while (more_dims--)
5925         type = build_unresolved_array_type (type);
5926
5927       /* The type may have been incomplete in the first place */
5928       if (type_wfl)
5929         type = obtain_incomplete_type (type);
5930     }
5931
5932   if (ret_name)
5933     *ret_name = name;
5934   return type;
5935 }
5936
5937 /* Build something that the type identifier resolver will identify as
5938    being an array to an unresolved type. TYPE_WFL is a WFL on a
5939    identifier. */
5940
5941 static tree
5942 build_unresolved_array_type (type_or_wfl)
5943      tree type_or_wfl;
5944 {
5945   const char *ptr;
5946
5947   /* TYPE_OR_WFL might be an array on a resolved type. In this case,
5948      just create a array type */
5949   if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5950     {
5951       tree type = build_java_array_type (type_or_wfl, -1);
5952       CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5953       return type;
5954     }
5955
5956   obstack_1grow (&temporary_obstack, '[');
5957   obstack_grow0 (&temporary_obstack,
5958                  IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5959                  IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5960   ptr = obstack_finish (&temporary_obstack);
5961   return build_expr_wfl (get_identifier (ptr),
5962                          EXPR_WFL_FILENAME (type_or_wfl),
5963                          EXPR_WFL_LINENO (type_or_wfl),
5964                          EXPR_WFL_COLNO (type_or_wfl));
5965 }
5966
5967 static void
5968 parser_add_interface (class_decl, interface_decl, wfl)
5969      tree class_decl, interface_decl, wfl;
5970 {
5971   if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5972     parse_error_context (wfl, "Interface `%s' repeated",
5973                          IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5974 }
5975
5976 /* Bulk of common class/interface checks. Return 1 if an error was
5977    encountered. TAG is 0 for a class, 1 for an interface.  */
5978
5979 static int
5980 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5981      int is_interface, flags;
5982      tree raw_name, qualified_name, decl, cl;
5983 {
5984   tree node;
5985   int sca = 0;                  /* Static class allowed */
5986   int icaf = 0;                 /* Inner class allowed flags */
5987   int uaaf = CLASS_MODIFIERS;   /* Usually allowed access flags */
5988
5989   if (!quiet_flag)
5990     fprintf (stderr, " %s%s %s", 
5991              (CPC_INNER_P () ? "inner" : ""),
5992              (is_interface ? "interface" : "class"), 
5993              IDENTIFIER_POINTER (qualified_name));
5994
5995   /* Scope of an interface/class type name:
5996        - Can't be imported by a single type import
5997        - Can't already exists in the package */
5998   if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5999       && (node = find_name_in_single_imports (raw_name)))
6000     {
6001       parse_error_context 
6002         (cl, "%s name `%s' clashes with imported type `%s'",
6003          (is_interface ? "Interface" : "Class"),
6004          IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
6005       return 1;
6006     }
6007   if (decl && CLASS_COMPLETE_P (decl))
6008     {
6009       classitf_redefinition_error ((is_interface ? "Interface" : "Class"), 
6010                                    qualified_name, decl, cl);
6011       return 1;
6012     }
6013
6014   if (check_inner_class_redefinition (raw_name, cl))
6015     return 1;
6016
6017   /* If public, file name should match class/interface name, except
6018      when dealing with an inner class */
6019   if (!CPC_INNER_P () && (flags & ACC_PUBLIC ))
6020     {
6021       const char *f;
6022
6023       /* Contains OS dependent assumption on path separator. FIXME */
6024       for (f = &input_filename [strlen (input_filename)]; 
6025            f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR;
6026            f--)
6027         ;
6028       if (f[0] == '/' || f[0] == DIR_SEPARATOR)
6029         f++;
6030       if (strncmp (IDENTIFIER_POINTER (raw_name), 
6031                    f , IDENTIFIER_LENGTH (raw_name)) ||
6032           f [IDENTIFIER_LENGTH (raw_name)] != '.')
6033         parse_error_context
6034           (cl, "Public %s `%s' must be defined in a file called `%s.java'", 
6035                              (is_interface ? "interface" : "class"),
6036                              IDENTIFIER_POINTER (qualified_name),
6037                              IDENTIFIER_POINTER (raw_name));
6038     }
6039
6040   /* Static classes can be declared only in top level classes. Note:
6041      once static, a inner class is a top level class. */
6042   if (flags & ACC_STATIC)
6043     {
6044       /* Catch the specific error of declaring an class inner class
6045          with no toplevel enclosing class. Prevent check_modifiers from
6046          complaining a second time */
6047       if (CPC_INNER_P () && !TOPLEVEL_CLASS_DECL_P (GET_CPC()))
6048         {
6049           parse_error_context (cl, "Inner class `%s' can't be static. Static classes can only occur in interfaces and top-level classes", 
6050                                IDENTIFIER_POINTER (qualified_name));
6051           sca = ACC_STATIC;
6052         }
6053       /* Else, in the context of a top-level class declaration, let
6054          `check_modifiers' do its job, otherwise, give it a go */
6055       else
6056         sca = (GET_CPC_LIST () ? ACC_STATIC : 0);
6057     }
6058
6059   /* Inner classes can be declared private or protected
6060      within their enclosing classes. */
6061   if (CPC_INNER_P ())
6062     {
6063       /* A class which is local to a block can't be public, private,
6064          protected or static. But it is created final, so allow this
6065          one. */
6066       if (current_function_decl)
6067         icaf = sca = uaaf = ACC_FINAL;
6068       else
6069         {
6070           check_modifiers_consistency (flags);
6071           icaf = ACC_PRIVATE|ACC_PROTECTED;
6072         }
6073     }
6074
6075   if (is_interface) 
6076     {
6077       if (CPC_INNER_P ())
6078         uaaf = INTERFACE_INNER_MODIFIERS;
6079       else
6080         uaaf = INTERFACE_MODIFIERS;
6081       
6082       check_modifiers ("Illegal modifier `%s' for interface declaration", 
6083                        flags, uaaf);
6084     }
6085   else
6086     check_modifiers ((current_function_decl ?
6087                       "Illegal modifier `%s' for local class declaration" :
6088                       "Illegal modifier `%s' for class declaration"),
6089                      flags, uaaf|sca|icaf);
6090   return 0;
6091 }
6092
6093 static void
6094 make_nested_class_name (cpc_list)
6095      tree cpc_list;
6096 {
6097   tree name;
6098
6099   if (!cpc_list)
6100     return;
6101   else
6102     make_nested_class_name (TREE_CHAIN (cpc_list));
6103
6104   /* Pick the qualified name when dealing with the first upmost
6105      enclosing class */
6106   name = (TREE_CHAIN (cpc_list) ? 
6107           TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
6108   obstack_grow (&temporary_obstack,
6109                 IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
6110   /* Why is NO_DOLLAR_IN_LABEL defined? */
6111 #if 0
6112 #ifdef NO_DOLLAR_IN_LABEL
6113   fatal ("make_nested_class_name: Can't use '$' as a separator "
6114          "for inner classes");
6115 #endif
6116 #endif
6117   obstack_1grow (&temporary_obstack, '$');
6118 }
6119
6120 /* Can't redefine a class already defined in an earlier scope. */
6121
6122 static int
6123 check_inner_class_redefinition (raw_name, cl)
6124      tree raw_name, cl;
6125 {
6126   tree scope_list;
6127
6128   for (scope_list = GET_CPC_LIST (); scope_list; 
6129        scope_list = GET_NEXT_ENCLOSING_CPC (scope_list))
6130     if (raw_name == GET_CPC_UN_NODE (scope_list))
6131       {
6132         parse_error_context 
6133           (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",
6134            IDENTIFIER_POINTER (raw_name));
6135         return 1;
6136       }
6137   return 0;
6138 }
6139
6140 static tree
6141 find_as_inner_class (enclosing, name, cl)
6142      tree enclosing, name, cl;
6143 {
6144   tree qual, to_return;
6145   if (!enclosing)
6146     return NULL_TREE;
6147
6148   name = TYPE_NAME (name);
6149
6150   /* First search: within the scope of `enclosing', search for name */
6151   if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6152     qual = EXPR_WFL_QUALIFICATION (cl);
6153   else if (cl)
6154     qual = build_tree_list (cl, NULL_TREE);
6155   else
6156     qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6157   
6158   if ((to_return = find_as_inner_class_do (qual, enclosing)))
6159     return to_return;
6160
6161   /* We're dealing with a qualified name. Try to resolve thing until
6162      we get something that is an enclosing class. */
6163   if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6164     {
6165       tree acc = NULL_TREE, decl = NULL_TREE, ptr;
6166
6167       for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl; 
6168           qual = TREE_CHAIN (qual))
6169         {
6170           acc = merge_qualified_name (acc, 
6171                                       EXPR_WFL_NODE (TREE_PURPOSE (qual)));
6172           BUILD_PTR_FROM_NAME (ptr, acc);
6173           decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
6174         }
6175
6176       /* A NULL qual and a decl means that the search ended
6177          successfully?!? We have to do something then. FIXME */
6178       
6179       if (decl)
6180         enclosing = decl;
6181       else
6182         qual = EXPR_WFL_QUALIFICATION (cl);
6183     }
6184   /* Otherwise, create a qual for the other part of the resolution. */
6185   else
6186     qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6187
6188   return find_as_inner_class_do (qual, enclosing);
6189 }
6190
6191 /* We go inside the list of sub classes and try to find a way
6192    through. */
6193
6194 static tree
6195 find_as_inner_class_do (qual, enclosing)
6196      tree qual, enclosing;
6197 {
6198   if (!qual)
6199     return NULL_TREE;
6200
6201   for (; qual && enclosing; qual = TREE_CHAIN (qual))
6202     {
6203       tree name_to_match = EXPR_WFL_NODE (TREE_PURPOSE (qual));
6204       tree next_enclosing = NULL_TREE;
6205       tree inner_list;
6206
6207       for (inner_list = DECL_INNER_CLASS_LIST (enclosing);
6208            inner_list; inner_list = TREE_CHAIN (inner_list))
6209         {
6210           if (TREE_VALUE (inner_list) == name_to_match)
6211             {
6212               next_enclosing = TREE_PURPOSE (inner_list);
6213               break;
6214             }
6215         }
6216       enclosing = next_enclosing;
6217     }
6218
6219   return (!qual && enclosing ? enclosing : NULL_TREE);
6220 }
6221
6222 /* Reach all inner classes and tie their unqualified name to a
6223    DECL. */
6224
6225 static void
6226 set_nested_class_simple_name_value (outer, set)
6227      tree outer;
6228      int set;
6229 {
6230   tree l;
6231
6232   for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
6233     IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ? 
6234                                                 TREE_PURPOSE (l) : NULL_TREE);
6235 }
6236
6237 static void
6238 link_nested_class_to_enclosing ()
6239 {
6240   if (GET_ENCLOSING_CPC ())
6241     {
6242       tree enclosing = GET_ENCLOSING_CPC_CONTEXT ();
6243       DECL_INNER_CLASS_LIST (enclosing) = 
6244         tree_cons (GET_CPC (), GET_CPC_UN (),
6245                    DECL_INNER_CLASS_LIST (enclosing));
6246       enclosing = enclosing;
6247     }
6248 }
6249
6250 static tree
6251 maybe_make_nested_class_name (name)
6252      tree name;
6253 {
6254   tree id = NULL_TREE;
6255
6256   if (CPC_INNER_P ())
6257     {
6258       make_nested_class_name (GET_CPC_LIST ());
6259       obstack_grow0 (&temporary_obstack,
6260                      IDENTIFIER_POINTER (name), 
6261                      IDENTIFIER_LENGTH (name));
6262       id = get_identifier (obstack_finish (&temporary_obstack));
6263       if (ctxp->package)
6264         QUALIFIED_P (id) = 1;
6265     }
6266   return id;
6267 }
6268
6269 /* If DECL is NULL, create and push a new DECL, record the current
6270    line CL and do other maintenance things.  */
6271
6272 static tree
6273 maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
6274      tree decl, raw_name, qualified_name, cl;
6275 {
6276   if (!decl)
6277     decl = push_class (make_class (), qualified_name);
6278
6279   /* Take care of the file and line business */
6280   DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
6281   /* If we're emiting xrefs, store the line/col number information */
6282   if (flag_emit_xref)
6283     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
6284   else
6285     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
6286   CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
6287   CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
6288     IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
6289
6290   PUSH_CPC (decl, raw_name);
6291   DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
6292
6293   /* Link the declaration to the already seen ones */
6294   TREE_CHAIN (decl) = ctxp->class_list;
6295   ctxp->class_list = decl;
6296
6297   /* Create a new nodes in the global lists */
6298   ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
6299   all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
6300
6301   /* Install a new dependency list element */
6302   create_jdep_list (ctxp);
6303
6304   SOURCE_FRONTEND_DEBUG (("Defining class/interface %s", 
6305                           IDENTIFIER_POINTER (qualified_name)));
6306   return decl;
6307 }
6308
6309 static void
6310 add_superinterfaces (decl, interface_list)
6311      tree decl, interface_list;
6312 {
6313   tree node;
6314   /* Superinterface(s): if present and defined, parser_check_super_interface ()
6315      takes care of ensuring that:
6316        - This is an accessible interface type,
6317        - Circularity detection.
6318    parser_add_interface is then called. If present but not defined,
6319    the check operation is delayed until the super interface gets
6320    defined.  */
6321   for (node = interface_list; node; node = TREE_CHAIN (node))
6322     {
6323       tree current = TREE_PURPOSE (node);
6324       tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
6325       if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
6326         {
6327           if (!parser_check_super_interface (idecl, decl, current))
6328             parser_add_interface (decl, idecl, current);
6329         }
6330       else
6331         register_incomplete_type (JDEP_INTERFACE,
6332                                   current, decl, NULL_TREE);
6333     }
6334 }
6335
6336 /* Create an interface in pass1 and return its decl. Return the
6337    interface's decl in pass 2.  */
6338
6339 static tree
6340 create_interface (flags, id, super)
6341      int flags;
6342      tree id, super;
6343 {
6344   tree raw_name = EXPR_WFL_NODE (id);
6345   tree q_name = parser_qualified_classname (flags & ACC_STATIC, raw_name);
6346   tree decl = IDENTIFIER_CLASS_VALUE (q_name);
6347
6348   EXPR_WFL_NODE (id) = q_name;  /* Keep source location, even if refined. */
6349
6350   /* Basic checks: scope, redefinition, modifiers */ 
6351   if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
6352     {
6353       PUSH_ERROR ();
6354       return NULL_TREE;
6355     }
6356
6357   /* Suspend the current parsing context if we're parsing an inner
6358      interface */
6359   if (CPC_INNER_P ())
6360     java_parser_context_suspend ();
6361
6362   /* Push a new context for (static) initialized upon declaration fields */
6363   java_parser_context_push_initialized_field ();
6364
6365   /* Interface modifiers check
6366        - public/abstract allowed (already done at that point)
6367        - abstract is obsolete (comes first, it's a warning, or should be)
6368        - Can't use twice the same (checked in the modifier rule) */
6369   if ((flags & ACC_ABSTRACT) && flag_redundant)
6370     parse_warning_context 
6371       (MODIFIER_WFL (ABSTRACT_TK),
6372        "Redundant use of `abstract' modifier. Interface `%s' is implicitely abstract", IDENTIFIER_POINTER (raw_name));
6373
6374   /* Create a new decl if DECL is NULL, otherwise fix it */
6375   decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
6376
6377   /* Set super info and mark the class a complete */
6378   set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl), 
6379                   object_type_node, ctxp->interface_number);
6380   ctxp->interface_number = 0;
6381   CLASS_COMPLETE_P (decl) = 1;
6382   add_superinterfaces (decl, super);
6383
6384   return decl;
6385 }
6386
6387 /* Anonymous class counter. Will be reset to 1 every time a non
6388    anonymous class gets created. */
6389 static int anonymous_class_counter = 1;
6390
6391 /* Patch anonymous class CLASS, by either extending or implementing
6392    DEP.  */
6393
6394 static void
6395 patch_anonymous_class (type_decl, class_decl, wfl)
6396     tree type_decl, class_decl, wfl;
6397 {
6398   tree class = TREE_TYPE (class_decl);
6399   tree type =  TREE_TYPE (type_decl);
6400   tree binfo = TYPE_BINFO (class);
6401
6402   /* If it's an interface, implement it */
6403   if (CLASS_INTERFACE (type_decl))
6404     {
6405       tree s_binfo;
6406       int length;
6407
6408       if (parser_check_super_interface (type_decl, class_decl, wfl))
6409         return;
6410
6411       s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
6412       length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
6413       TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
6414       TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
6415       /* And add the interface */
6416       parser_add_interface (class_decl, type_decl, wfl);
6417     }
6418   /* Otherwise, it's a type we want to extend */
6419   else
6420     {
6421       if (parser_check_super (type_decl, class_decl, wfl))
6422         return;
6423       BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
6424     }
6425 }
6426
6427 static tree
6428 create_anonymous_class (location, type_name)
6429     int location;
6430     tree type_name;
6431 {
6432   char buffer [80];
6433   tree super = NULL_TREE, itf = NULL_TREE;
6434   tree id, type_decl, class;
6435
6436   /* The unqualified name of the anonymous class. It's just a number. */
6437   sprintf (buffer, "%d", anonymous_class_counter++);
6438   id = build_wfl_node (get_identifier (buffer));
6439   EXPR_WFL_LINECOL (id) = location;
6440
6441   /* We know about the type to extend/implement. We go ahead */
6442   if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
6443     {
6444       /* Create a class which either implements on extends the designated
6445          class. The class bears an innacessible name. */
6446       if (CLASS_INTERFACE (type_decl))
6447         {
6448           /* It's OK to modify it here. It's been already used and
6449              shouldn't be reused */
6450           ctxp->interface_number = 1;
6451           /* Interfaces should presented as a list of WFLs */
6452           itf = build_tree_list (type_name, NULL_TREE);
6453         }
6454       else
6455         super = type_name;
6456     }
6457
6458   class = create_class (ACC_FINAL, id, super, itf);
6459
6460   /* We didn't know anything about the stuff. We register a dependence. */
6461   if (!type_decl)
6462     register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);
6463
6464   ANONYMOUS_CLASS_P (TREE_TYPE (class)) = 1;
6465   return class;
6466 }
6467
6468 /* Create a class in pass1 and return its decl. Return class
6469    interface's decl in pass 2.  */
6470
6471 static tree
6472 create_class (flags, id, super, interfaces)
6473      int flags;
6474      tree id, super, interfaces;
6475 {
6476   tree raw_name = EXPR_WFL_NODE (id);
6477   tree class_id, decl;
6478   tree super_decl_type;
6479
6480   class_id = parser_qualified_classname (0, raw_name);
6481   decl = IDENTIFIER_CLASS_VALUE (class_id);
6482   EXPR_WFL_NODE (id) = class_id;
6483
6484   /* Basic check: scope, redefinition, modifiers */
6485   if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
6486     {
6487       PUSH_ERROR ();
6488       return NULL_TREE;
6489     }
6490   
6491   /* Suspend the current parsing context if we're parsing an inner
6492      class or an anonymous class. */
6493   if (CPC_INNER_P ())
6494     java_parser_context_suspend ();
6495   /* Push a new context for (static) initialized upon declaration fields */
6496   java_parser_context_push_initialized_field ();
6497
6498   /* Class modifier check: 
6499        - Allowed modifier (already done at that point)
6500        - abstract AND final forbidden 
6501        - Public classes defined in the correct file */
6502   if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
6503     parse_error_context
6504       (id, "Class `%s' can't be declared both abstract and final",
6505        IDENTIFIER_POINTER (raw_name));
6506
6507   /* Create a new decl if DECL is NULL, otherwise fix it */
6508   decl = maybe_create_class_interface_decl (decl, raw_name, class_id, id);
6509
6510   /* If SUPER exists, use it, otherwise use Object */
6511   if (super)
6512     {
6513       /* Can't extend java.lang.Object */
6514       if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
6515         {
6516           parse_error_context (id, "Can't extend `java.lang.Object'");
6517           return NULL_TREE;
6518         }
6519
6520       super_decl_type = 
6521         register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
6522     }
6523   else if (TREE_TYPE (decl) != object_type_node)
6524     super_decl_type = object_type_node;
6525   /* We're defining java.lang.Object */
6526   else
6527     super_decl_type = NULL_TREE;
6528
6529   /* Set super info and mark the class a complete */
6530   set_super_info (flags, TREE_TYPE (decl), super_decl_type, 
6531                   ctxp->interface_number);
6532   ctxp->interface_number = 0;
6533   CLASS_COMPLETE_P (decl) = 1;
6534   add_superinterfaces (decl, interfaces);
6535
6536   /* If the class is a top level inner class, install an alias. */
6537   if (INNER_CLASS_DECL_P (decl) && CLASS_STATIC (decl))
6538     {
6539       tree alias = parser_qualified_classname (1, raw_name);
6540       IDENTIFIER_GLOBAL_VALUE (alias) = decl;
6541     }
6542
6543   /* Add the private this$<n> field, Replicate final locals still in
6544      scope as private final fields mangled like val$<local_name>.
6545      This doesn't not occur for top level (static) inner classes. */
6546   if (PURE_INNER_CLASS_DECL_P (decl))
6547     add_inner_class_fields (decl, current_function_decl);
6548
6549   /* If doing xref, store the location at which the inherited class
6550      (if any) was seen. */
6551   if (flag_emit_xref && super)
6552     DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
6553
6554   /* Eventually sets the @deprecated tag flag */
6555   CHECK_DEPRECATED (decl);
6556
6557   /* Reset the anonymous class counter when declaring non inner classes */
6558   if (!INNER_CLASS_DECL_P (decl))
6559     anonymous_class_counter = 1;
6560
6561   return decl;
6562 }
6563
6564 /* End a class declaration: register the statements used to create
6565    $finit$ and <clinit>, pop the current class and resume the prior
6566    parser context if necessary.  */
6567
6568 static void
6569 end_class_declaration (resume)
6570      int resume;
6571 {
6572   /* If an error occured, context weren't pushed and won't need to be
6573      popped by a resume. */
6574   int no_error_occured = ctxp->next && GET_CPC () != error_mark_node;
6575
6576   java_parser_context_pop_initialized_field ();
6577   POP_CPC ();
6578   if (resume && no_error_occured)
6579     java_parser_context_resume ();
6580
6581   /* We're ending a class declaration, this is a good time to reset
6582      the interface cout. Note that might have been already done in
6583      create_interface, but if at that time an inner class was being
6584      dealt with, the interface count was reset in a context created
6585      for the sake of handling inner classes declaration. */
6586   ctxp->interface_number = 0;
6587 }
6588
6589 static void
6590 add_inner_class_fields (class_decl, fct_decl)
6591      tree class_decl;
6592      tree fct_decl;
6593 {
6594   tree block, marker, f;
6595
6596   f = add_field (TREE_TYPE (class_decl),
6597                  build_current_thisn (TREE_TYPE (class_decl)),
6598                  build_pointer_type (TREE_TYPE (DECL_CONTEXT (class_decl))), 
6599                  ACC_PRIVATE);
6600   FIELD_THISN (f) = 1;
6601
6602   if (!fct_decl)
6603     return;
6604     
6605   for (block = GET_CURRENT_BLOCK (fct_decl); 
6606        block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block))
6607     {
6608       tree decl;
6609       for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl))
6610         {
6611           char *name, *pname;
6612           tree wfl, init, list;
6613           
6614           /* Avoid non final arguments. */
6615           if (!LOCAL_FINAL (decl))
6616             continue;
6617           
6618           MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl));
6619           MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl));
6620           wfl = build_wfl_node (get_identifier (name));
6621           init = build_wfl_node (get_identifier (pname));
6622           /* Build an initialization for the field: it will be
6623              initialized by a parameter added to $finit$, bearing a
6624              mangled name of the field itself (param$<n>.) The
6625              parameter is provided to $finit$ by the constructor
6626              invoking it (hence the constructor will also feature a
6627              hidden parameter, set to the value of the outer context
6628              local at the time the inner class is created.)
6629              
6630              Note: we take into account all possible locals that can
6631              be accessed by the inner class. It's actually not trivial
6632              to minimize these aliases down to the ones really
6633              used. One way to do that would be to expand all regular
6634              methods first, then $finit$ to get a picture of what's
6635              used.  It works with the exception that we would have to
6636              go back on all constructor invoked in regular methods to
6637              have their invokation reworked (to include the right amount
6638              of alias initializer parameters.)
6639
6640              The only real way around, I think, is a first pass to
6641              identify locals really used in the inner class. We leave
6642              the flag FIELD_LOCAL_ALIAS_USED around for that future
6643              use.
6644              
6645              On the other hand, it only affect local inner classes,
6646              whose constructors (and $finit$ call) will be featuring
6647              unecessary arguments. It's easy for a developper to keep
6648              this number of parameter down by using the `final'
6649              keyword only when necessary. For the time being, we can
6650              issue a warning on unecessary finals. FIXME */
6651           init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl), 
6652                                    wfl, init);
6653
6654           /* Register the field. The TREE_LIST holding the part
6655              initialized/initializer will be marked ARG_FINAL_P so
6656              that the created field can be marked
6657              FIELD_LOCAL_ALIAS. */
6658           list = build_tree_list (wfl, init);
6659           ARG_FINAL_P (list) = 1;
6660           register_fields (ACC_PRIVATE | ACC_FINAL, TREE_TYPE (decl), list);
6661         }
6662     }
6663
6664   if (!CPC_INITIALIZER_STMT (ctxp))
6665     return;
6666
6667   /* If we ever registered an alias field, insert and marker to
6668      remeber where the list ends. The second part of the list (the one
6669      featuring initialized fields) so it can be later reversed to
6670      enforce 8.5. The marker will be removed during that operation. */
6671   marker = build_tree_list (NULL_TREE, NULL_TREE);
6672   TREE_CHAIN (marker) = CPC_INITIALIZER_STMT (ctxp);
6673   SET_CPC_INITIALIZER_STMT (ctxp, marker);
6674 }
6675
6676 /* Can't use lookup_field () since we don't want to load the class and
6677    can't set the CLASS_LOADED_P flag */
6678
6679 static tree
6680 find_field (class, name)
6681      tree class;
6682      tree name;
6683 {
6684   tree decl;
6685   for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
6686     {
6687       if (DECL_NAME (decl) == name)
6688         return decl;
6689     }
6690   return NULL_TREE;
6691 }
6692
6693 /* Wrap around lookup_field that doesn't potentially upset the value
6694    of CLASS */
6695
6696 static tree
6697 lookup_field_wrapper (class, name)
6698      tree class, name;
6699 {
6700   tree type = class;
6701   tree decl = NULL_TREE;
6702   java_parser_context_save_global ();
6703
6704   /* Last chance: if we're within the context of an inner class, we
6705      might be trying to access a local variable defined in an outer
6706      context. We try to look for it now. */
6707   if (INNER_CLASS_TYPE_P (class))
6708     {
6709       char *alias_buffer;
6710       tree new_name;
6711       MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
6712       new_name = get_identifier (alias_buffer);
6713       decl = lookup_field (&type, new_name);
6714       if (decl && decl != error_mark_node)
6715         FIELD_LOCAL_ALIAS_USED (decl) = 1;
6716     }
6717   if (!decl || decl == error_mark_node)
6718     {
6719       type = class;
6720       decl = lookup_field (&type, name);
6721     }
6722
6723   java_parser_context_restore_global ();
6724   return decl == error_mark_node ? NULL : decl;
6725 }
6726
6727 /* Find duplicate field within the same class declarations and report
6728    the error. Returns 1 if a duplicated field was found, 0
6729    otherwise.  */
6730
6731 static int
6732 duplicate_declaration_error_p (new_field_name, new_type, cl)
6733      tree new_field_name, new_type, cl;
6734 {
6735   /* This might be modified to work with method decl as well */
6736   tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
6737   if (decl)
6738     {
6739       char *t1 = xstrdup (purify_type_name
6740                          ((TREE_CODE (new_type) == POINTER_TYPE 
6741                            && TREE_TYPE (new_type) == NULL_TREE) ?
6742                           IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
6743                           lang_printable_name (new_type, 1)));
6744       /* The type may not have been completed by the time we report
6745          the error */
6746       char *t2 = xstrdup (purify_type_name
6747                          ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE 
6748                            && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
6749                           IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
6750                           lang_printable_name (TREE_TYPE (decl), 1)));
6751       parse_error_context 
6752         (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)", 
6753          t1, IDENTIFIER_POINTER (new_field_name),
6754          t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
6755          DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
6756       free (t1);
6757       free (t2);
6758       return 1;
6759     }
6760   return 0;
6761 }
6762
6763 /* Field registration routine. If TYPE doesn't exist, field
6764    declarations are linked to the undefined TYPE dependency list, to
6765    be later resolved in java_complete_class () */
6766
6767 static void
6768 register_fields (flags, type, variable_list)
6769      int flags;
6770      tree type, variable_list;
6771 {
6772   tree current, saved_type;
6773   tree class_type = NULL_TREE;
6774   int saved_lineno = lineno;
6775   int must_chain = 0;
6776   tree wfl = NULL_TREE;
6777
6778   if (GET_CPC ())
6779     class_type = TREE_TYPE (GET_CPC ());
6780
6781   if (!class_type || class_type == error_mark_node)
6782     return;
6783
6784   /* If we're adding fields to interfaces, those fields are public,
6785      static, final */
6786   if (CLASS_INTERFACE (TYPE_NAME (class_type)))
6787     {
6788       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
6789                                  flags, ACC_PUBLIC, "interface field(s)");
6790       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
6791                                  flags, ACC_STATIC, "interface field(s)");
6792       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
6793                                  flags, ACC_FINAL, "interface field(s)");
6794       check_modifiers ("Illegal interface member modifier `%s'", flags,
6795                        INTERFACE_FIELD_MODIFIERS);
6796       flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
6797     }
6798
6799   /* Obtain a suitable type for resolution, if necessary */
6800   SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
6801
6802   /* If TYPE is fully resolved and we don't have a reference, make one */
6803   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6804
6805   for (current = variable_list, saved_type = type; current; 
6806        current = TREE_CHAIN (current), type = saved_type)
6807     {
6808       tree real_type;
6809       tree field_decl;
6810       tree cl = TREE_PURPOSE (current);
6811       tree init = TREE_VALUE (current);
6812       tree current_name = EXPR_WFL_NODE (cl);
6813
6814       /* Can't declare static fields in inner classes */
6815       if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
6816           && !CLASS_INTERFACE (TYPE_NAME (class_type)))
6817         parse_error_context 
6818           (cl, "Field `%s' can't be static in innerclass `%s'. Only members of interfaces and top-level classes can be static",
6819            IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
6820            lang_printable_name (class_type, 0));
6821
6822       /* Process NAME, as it may specify extra dimension(s) for it */
6823       type = build_array_from_name (type, wfl, current_name, &current_name);
6824
6825       /* Type adjustment. We may have just readjusted TYPE because
6826          the variable specified more dimensions. Make sure we have
6827          a reference if we can and don't have one already. Also
6828          change the name if we have an init. */
6829       if (type != saved_type)
6830         {
6831           PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6832           if (init)
6833             EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
6834         }
6835
6836       real_type = GET_REAL_TYPE (type);
6837       /* Check for redeclarations */
6838       if (duplicate_declaration_error_p (current_name, real_type, cl))
6839         continue;
6840
6841       /* Set lineno to the line the field was found and create a
6842          declaration for it. Eventually sets the @deprecated tag flag. */
6843       if (flag_emit_xref)
6844         lineno = EXPR_WFL_LINECOL (cl);
6845       else
6846         lineno = EXPR_WFL_LINENO (cl);
6847       field_decl = add_field (class_type, current_name, real_type, flags);
6848       CHECK_DEPRECATED (field_decl);
6849
6850       /* If the couple initializer/initialized is marked ARG_FINAL_P, we
6851          mark the created field FIELD_LOCAL_ALIAS, so that we can 
6852          hide parameters to this inner class $finit$ and constructors. */
6853       if (ARG_FINAL_P (current))
6854         FIELD_LOCAL_ALIAS (field_decl) = 1;
6855       
6856       /* Check if we must chain. */
6857       if (must_chain)
6858         register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
6859           
6860       /* If we have an initialization value tied to the field */
6861       if (init)
6862         {
6863           /* The field is declared static */
6864           if (flags & ACC_STATIC)
6865             {
6866               /* We include the field and its initialization part into
6867                  a list used to generate <clinit>. After <clinit> is
6868                  walked, field initializations will be processed and
6869                  fields initialized with known constants will be taken
6870                  out of <clinit> and have their DECL_INITIAL set
6871                  appropriately. */
6872               TREE_CHAIN (init) = CPC_STATIC_INITIALIZER_STMT (ctxp);
6873               SET_CPC_STATIC_INITIALIZER_STMT (ctxp, init);
6874               if (TREE_OPERAND (init, 1) 
6875                   && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
6876                 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
6877             }
6878           /* A non-static field declared with an immediate initialization is
6879              to be initialized in <init>, if any.  This field is remembered
6880              to be processed at the time of the generation of <init>. */
6881           else
6882             {
6883               TREE_CHAIN (init) = CPC_INITIALIZER_STMT (ctxp);
6884               SET_CPC_INITIALIZER_STMT (ctxp, init);
6885             }
6886           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
6887           DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
6888         }
6889     }
6890   lineno = saved_lineno;
6891 }
6892
6893 /* Generate $finit$, using the list of initialized fields to populate
6894    its body. $finit$'s parameter(s) list is adjusted to include the
6895    one(s) used to initialized the field(s) caching outer context
6896    local(s). */
6897
6898 static tree
6899 generate_finit (class_type)
6900      tree class_type;
6901 {
6902   int count = 0;
6903   tree list = TYPE_FINIT_STMT_LIST (class_type);
6904   tree mdecl, current, parms;
6905
6906   parms = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION, 
6907                                                   class_type, NULL_TREE, 
6908                                                   &count);
6909   CRAFTED_PARAM_LIST_FIXUP (parms);
6910   mdecl = create_artificial_method (class_type, ACC_PRIVATE, void_type_node,
6911                                     finit_identifier_node, parms);
6912   fix_method_argument_names (parms, mdecl);
6913   layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
6914                        mdecl, NULL_TREE);
6915   DECL_FUNCTION_NAP (mdecl) = count;
6916   start_artificial_method_body (mdecl);
6917
6918   for (current = list; current; current = TREE_CHAIN (current))
6919     java_method_add_stmt (mdecl, 
6920                           build_debugable_stmt (EXPR_WFL_LINECOL (current), 
6921                                                 current));
6922   end_artificial_method_body (mdecl);
6923   return mdecl;
6924 }
6925
6926 static void
6927 add_instance_initializer (mdecl)
6928      tree mdecl;
6929 {
6930   tree current;
6931   tree stmt_list = TYPE_II_STMT_LIST (DECL_CONTEXT (mdecl));
6932   tree compound = NULL_TREE;
6933
6934   if (stmt_list)
6935     {
6936       for (current = stmt_list; current; current = TREE_CHAIN (current))
6937         compound = add_stmt_to_compound (compound, NULL_TREE, current);
6938
6939       java_method_add_stmt (mdecl, build1 (INSTANCE_INITIALIZERS_EXPR,
6940                                            NULL_TREE, compound));
6941     }
6942 }
6943
6944 /* Shared accros method_declarator and method_header to remember the
6945    patch stage that was reached during the declaration of the method.
6946    A method DECL is built differently is there is no patch
6947    (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
6948    pending on the currently defined method.  */
6949
6950 static int patch_stage;
6951
6952 /* Check the method declaration and add the method to its current
6953    class.  If the argument list is known to contain incomplete types,
6954    the method is partially added and the registration will be resume
6955    once the method arguments resolved. If TYPE is NULL, we're dealing
6956    with a constructor.  */
6957
6958 static tree
6959 method_header (flags, type, mdecl, throws)
6960      int flags;
6961      tree type, mdecl, throws;
6962 {
6963   tree meth = TREE_VALUE (mdecl);
6964   tree id = TREE_PURPOSE (mdecl);
6965   tree type_wfl = NULL_TREE;
6966   tree meth_name = NULL_TREE;
6967   tree current, orig_arg, this_class = NULL;
6968   int saved_lineno;
6969   int constructor_ok = 0, must_chain;
6970   int count;
6971   
6972   check_modifiers_consistency (flags);
6973
6974   if (GET_CPC ())
6975     this_class = TREE_TYPE (GET_CPC ());
6976
6977   if (!this_class || this_class == error_mark_node)
6978     return NULL_TREE;
6979   
6980   /* There are some forbidden modifiers for an abstract method and its
6981      class must be abstract as well.  */
6982   if (type && (flags & ACC_ABSTRACT))
6983     {
6984       ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
6985       ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
6986       ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
6987       ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
6988       ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
6989       if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
6990           && !CLASS_INTERFACE (TYPE_NAME (this_class)))
6991         parse_error_context 
6992           (id, "Class `%s' must be declared abstract to define abstract method `%s'", 
6993            IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
6994            IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6995     }
6996
6997   /* Things to be checked when declaring a constructor */
6998   if (!type)
6999     {
7000       int ec = java_error_count;
7001       /* 8.6: Constructor declarations: we might be trying to define a
7002          method without specifying a return type. */
7003       if (EXPR_WFL_NODE (id) != GET_CPC_UN ())
7004         parse_error_context 
7005           (id, "Invalid method declaration, return type required");
7006       /* 8.6.3: Constructor modifiers */
7007       else
7008         {
7009           JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
7010           JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
7011           JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
7012           JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
7013           JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
7014         }
7015       /* If we found error here, we don't consider it's OK to tread
7016          the method definition as a constructor, for the rest of this
7017          function */
7018       if (ec == java_error_count)
7019         constructor_ok = 1;
7020     }
7021
7022   /* Method declared within the scope of an interface are implicitly
7023      abstract and public. Conflicts with other erroneously provided
7024      modifiers are checked right after. */
7025
7026   if (CLASS_INTERFACE (TYPE_NAME (this_class)))
7027     {
7028       /* If FLAGS isn't set because of a modifier, turn the
7029          corresponding modifier WFL to NULL so we issue a warning on
7030          the obsolete use of the modifier */
7031       if (!(flags & ACC_PUBLIC))
7032         MODIFIER_WFL (PUBLIC_TK) = NULL;
7033       if (!(flags & ACC_ABSTRACT))
7034         MODIFIER_WFL (ABSTRACT_TK) = NULL;
7035       flags |= ACC_PUBLIC;
7036       flags |= ACC_ABSTRACT;
7037     }
7038
7039   /* Inner class can't declare static methods */
7040   if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
7041     {
7042       parse_error_context 
7043         (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
7044          IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
7045          lang_printable_name (this_class, 0));
7046     }
7047
7048   /* Modifiers context reset moved up, so abstract method declaration
7049      modifiers can be later checked.  */
7050
7051   /* Set constructor returned type to void and method name to <init>,
7052      unless we found an error identifier the constructor (in which
7053      case we retain the original name) */
7054   if (!type)
7055     {
7056       type = void_type_node;
7057       if (constructor_ok)
7058         meth_name = init_identifier_node;
7059     }
7060   else
7061     meth_name = EXPR_WFL_NODE (id);
7062
7063   /* Do the returned type resolution and registration if necessary */
7064   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7065
7066   if (meth_name)
7067     type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
7068   EXPR_WFL_NODE (id) = meth_name;
7069   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7070
7071   if (must_chain)
7072     {
7073       patch_stage = JDEP_METHOD_RETURN;
7074       register_incomplete_type (patch_stage, type_wfl, id, type);
7075       TREE_TYPE (meth) = GET_REAL_TYPE (type);
7076     }
7077   else
7078     TREE_TYPE (meth) = type;
7079
7080   saved_lineno = lineno;
7081   /* When defining an abstract or interface method, the curly
7082      bracket at level 1 doesn't exist because there is no function
7083      body */
7084   lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 : 
7085             EXPR_WFL_LINENO (id));
7086
7087   /* Remember the original argument list */
7088   orig_arg = TYPE_ARG_TYPES (meth);
7089
7090   if (patch_stage)              /* includes ret type and/or all args */
7091     {
7092       jdep *jdep;
7093       meth = add_method_1 (this_class, flags, meth_name, meth);
7094       /* Patch for the return type */
7095       if (patch_stage == JDEP_METHOD_RETURN)
7096         {
7097           jdep = CLASSD_LAST (ctxp->classd_list);
7098           JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
7099         }
7100       /* This is the stop JDEP. METH allows the function's signature
7101          to be computed. */
7102       register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
7103     }
7104   else
7105     meth = add_method (this_class, flags, meth_name, 
7106                        build_java_signature (meth));
7107
7108   /* Remember final parameters */
7109   MARK_FINAL_PARMS (meth, orig_arg);
7110
7111   /* Fix the method argument list so we have the argument name
7112      information */
7113   fix_method_argument_names (orig_arg, meth);
7114
7115   /* Register the parameter number and re-install the current line
7116      number */
7117   DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
7118   lineno = saved_lineno;
7119
7120   /* Register exception specified by the `throws' keyword for
7121      resolution and set the method decl appropriate field to the list.
7122      Note: the grammar ensures that what we get here are class
7123      types. */
7124   if (throws)
7125     {
7126       throws = nreverse (throws);
7127       for (current = throws; current; current = TREE_CHAIN (current))
7128         {
7129           register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
7130                                     NULL_TREE, NULL_TREE);
7131           JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) = 
7132             &TREE_VALUE (current);
7133         }
7134       DECL_FUNCTION_THROWS (meth) = throws;
7135     }
7136
7137   /* We set the DECL_NAME to ID so we can track the location where
7138      the function was declared. This allow us to report
7139      redefinition error accurately. When method are verified,
7140      DECL_NAME is reinstalled properly (using the content of the
7141      WFL node ID) (see check_method_redefinition). We don't do that
7142      when Object is being defined. Constructor <init> names will be
7143      reinstalled the same way. */
7144   if (TREE_TYPE (GET_CPC ()) != object_type_node)
7145     DECL_NAME (meth) = id;
7146
7147   /* Set the flag if we correctly processed a constructor */
7148   if (constructor_ok)
7149     {
7150       DECL_CONSTRUCTOR_P (meth) = 1;
7151       /* Compute and store the number of artificial parameters declared
7152          for this constructor */
7153       for (count = 0, current = TYPE_FIELDS (this_class); current; 
7154            current = TREE_CHAIN (current))
7155         if (FIELD_LOCAL_ALIAS (current))
7156           count++;
7157       DECL_FUNCTION_NAP (meth) = count;
7158     }
7159
7160   /* Eventually set the @deprecated tag flag */
7161   CHECK_DEPRECATED (meth);
7162
7163   /* If doing xref, store column and line number information instead
7164      of the line number only. */
7165   if (flag_emit_xref)
7166     DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
7167
7168   return meth;
7169 }
7170
7171 static void
7172 fix_method_argument_names (orig_arg, meth)
7173     tree orig_arg, meth;
7174 {
7175   tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
7176   if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
7177     {
7178       TREE_PURPOSE (arg) = this_identifier_node;
7179       arg = TREE_CHAIN (arg);
7180     }
7181   while (orig_arg != end_params_node)
7182     {
7183       TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
7184       orig_arg = TREE_CHAIN (orig_arg);
7185       arg = TREE_CHAIN (arg);
7186     }
7187 }
7188
7189 /* Complete the method declaration with METHOD_BODY.  */
7190
7191 static void
7192 finish_method_declaration (method_body)
7193      tree method_body;
7194 {
7195   int flags;
7196
7197   if (!current_function_decl)
7198     return;
7199
7200   flags = get_access_flags_from_decl (current_function_decl);
7201
7202   /* 8.4.5 Method Body */
7203   if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
7204     {
7205       tree wfl = DECL_NAME (current_function_decl);
7206       parse_error_context (wfl, 
7207                            "%s method `%s' can't have a body defined",
7208                            (METHOD_NATIVE (current_function_decl) ?
7209                             "Native" : "Abstract"),
7210                            IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7211       method_body = NULL_TREE;
7212     }
7213   else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
7214     {
7215       tree wfl = DECL_NAME (current_function_decl);
7216       parse_error_context
7217         (wfl, 
7218          "Non native and non abstract method `%s' must have a body defined",
7219          IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7220       method_body = NULL_TREE;
7221     }
7222
7223   if (flag_emit_class_files && method_body 
7224       && TREE_CODE (method_body) == NOP_EXPR 
7225       && TREE_TYPE (current_function_decl) 
7226       && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
7227     method_body = build1 (RETURN_EXPR, void_type_node, NULL);
7228
7229   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
7230   maybe_absorb_scoping_blocks ();
7231   /* Exit function's body */
7232   exit_block ();
7233   /* Merge last line of the function with first line, directly in the
7234      function decl. It will be used to emit correct debug info. */
7235   if (!flag_emit_xref)
7236     DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
7237
7238   /* Since function's argument's list are shared, reset the
7239      ARG_FINAL_P parameter that might have been set on some of this
7240      function parameters. */
7241   UNMARK_FINAL_PARMS (current_function_decl);
7242   
7243   /* So we don't have an irrelevant function declaration context for
7244      the next static block we'll see. */
7245   current_function_decl = NULL_TREE;
7246 }
7247
7248 /* Build a an error message for constructor circularity errors.  */
7249
7250 static char *
7251 constructor_circularity_msg (from, to)
7252      tree from, to;
7253 {
7254   static char string [4096];
7255   char *t = xstrdup (lang_printable_name (from, 0));
7256   sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
7257   free (t);
7258   return string;
7259 }
7260
7261 /* Verify a circular call to METH. Return 1 if an error is found, 0
7262    otherwise.  */
7263
7264 static int
7265 verify_constructor_circularity (meth, current)
7266      tree meth, current;
7267 {
7268   static tree list = NULL_TREE;
7269   tree c;
7270   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7271     {
7272       if (TREE_VALUE (c) == meth)
7273         {
7274           char *t;
7275           if (list)
7276             {
7277               tree liste;
7278               list = nreverse (list);
7279               for (liste = list; liste; liste = TREE_CHAIN (liste))
7280                 {
7281                   parse_error_context 
7282                     (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s",
7283                      constructor_circularity_msg
7284                       (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste)))); 
7285                   java_error_count--;
7286                 }
7287             }
7288           t = xstrdup (lang_printable_name (meth, 0));
7289           parse_error_context (TREE_PURPOSE (c), 
7290                                "%s: recursive invocation of constructor `%s'",
7291                                constructor_circularity_msg (current, meth), t);
7292           free (t);
7293           list = NULL_TREE;
7294           return 1;
7295         }
7296     }
7297   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7298     {
7299       list = tree_cons (c, current, list);
7300       if (verify_constructor_circularity (meth, TREE_VALUE (c)))
7301         return 1;
7302       list = TREE_CHAIN (list);
7303     }
7304   return 0;
7305 }
7306
7307 /* Check modifiers that can be declared but exclusively */
7308
7309 static void
7310 check_modifiers_consistency (flags)
7311      int flags;
7312 {
7313   int acc_count = 0;
7314   tree cl = NULL_TREE;
7315
7316   THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, PUBLIC_TK, acc_count, cl);
7317   THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, PRIVATE_TK, acc_count, cl);
7318   THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
7319   if (acc_count > 1)
7320     parse_error_context
7321       (cl, "Inconsistent member declaration.  At most one of `public', `private', or `protected' may be specified");
7322
7323   acc_count = 0;
7324   cl = NULL_TREE;
7325   THIS_MODIFIER_ONLY (flags, ACC_FINAL, FINAL_TK, acc_count, cl);
7326   THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK, acc_count, cl);
7327   if (acc_count > 1)
7328     parse_error_context (cl,
7329                          "Inconsistent member declaration.  At most one of `final' or `volatile' may be specified");
7330 }
7331
7332 /* Check the methode header METH for abstract specifics features */
7333
7334 static void
7335 check_abstract_method_header (meth)
7336      tree meth;
7337 {
7338   int flags = get_access_flags_from_decl (meth);
7339   /* DECL_NAME might still be a WFL node */
7340   tree name = GET_METHOD_NAME (meth);
7341
7342   OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
7343                               ACC_ABSTRACT, "abstract method",
7344                               IDENTIFIER_POINTER (name));
7345   OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags, 
7346                               ACC_PUBLIC, "abstract method",
7347                               IDENTIFIER_POINTER (name));
7348
7349   check_modifiers ("Illegal modifier `%s' for interface method",
7350                   flags, INTERFACE_METHOD_MODIFIERS);
7351 }
7352
7353 /* Create a FUNCTION_TYPE node and start augmenting it with the
7354    declared function arguments. Arguments type that can't be resolved
7355    are left as they are, but the returned node is marked as containing
7356    incomplete types.  */
7357
7358 static tree
7359 method_declarator (id, list)
7360      tree id, list;
7361 {
7362   tree arg_types = NULL_TREE, current, node;
7363   tree meth = make_node (FUNCTION_TYPE);
7364   jdep *jdep;
7365
7366   patch_stage = JDEP_NO_PATCH;
7367
7368   /* If we're dealing with an inner class constructor, we hide the
7369      this$<n> decl in the name field of its parameter declaration.  We
7370      also might have to hide the outer context local alias
7371      initializers. Not done when the class is a toplevel class. */
7372   if (PURE_INNER_CLASS_DECL_P (GET_CPC ()) 
7373       && EXPR_WFL_NODE (id) == GET_CPC_UN ())
7374     {
7375       tree aliases_list, type, thisn;
7376       /* First the aliases, linked to the regular parameters */
7377       aliases_list =
7378         build_alias_initializer_parameter_list (AIPL_FUNCTION_DECLARATION, 
7379                                                 TREE_TYPE (GET_CPC ()),
7380                                                 NULL_TREE, NULL);
7381       list = chainon (nreverse (aliases_list), list);
7382
7383       /* Then this$<n> */
7384       type = TREE_TYPE (DECL_CONTEXT (GET_CPC ()));
7385       thisn = build_current_thisn (TREE_TYPE (GET_CPC ()));
7386       list = tree_cons (build_wfl_node (thisn), build_pointer_type (type),
7387                         list);
7388     }
7389   
7390   for (current = list; current; current = TREE_CHAIN (current))
7391     {
7392       int must_chain = 0;
7393       tree wfl_name = TREE_PURPOSE (current);
7394       tree type = TREE_VALUE (current);
7395       tree name = EXPR_WFL_NODE (wfl_name);
7396       tree already, arg_node;
7397       tree type_wfl = NULL_TREE;
7398       tree real_type;
7399
7400       /* Obtain a suitable type for resolution, if necessary */
7401       SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7402
7403       /* Process NAME, as it may specify extra dimension(s) for it */
7404       type = build_array_from_name (type, type_wfl, name, &name);
7405       EXPR_WFL_NODE (wfl_name) = name;
7406
7407       real_type = GET_REAL_TYPE (type);
7408       if (TREE_CODE (real_type) == RECORD_TYPE)
7409         {
7410           real_type = promote_type (real_type);
7411           if (TREE_CODE (type) == TREE_LIST)
7412             TREE_PURPOSE (type) = real_type;
7413         }
7414
7415       /* Check redefinition */
7416       for (already = arg_types; already; already = TREE_CHAIN (already))
7417         if (TREE_PURPOSE (already) == name)
7418           {
7419             parse_error_context
7420               (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
7421                IDENTIFIER_POINTER (name),
7422                IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7423             break;
7424           }
7425
7426       /* If we've an incomplete argument type, we know there is a location
7427          to patch when the type get resolved, later.  */
7428       jdep = NULL;
7429       if (must_chain)
7430         {
7431           patch_stage = JDEP_METHOD;
7432           type = register_incomplete_type (patch_stage, 
7433                                            type_wfl, wfl_name, type);
7434           jdep = CLASSD_LAST (ctxp->classd_list);
7435           JDEP_MISC (jdep) = id;
7436         }
7437
7438       /* The argument node: a name and a (possibly) incomplete type.  */
7439       arg_node = build_tree_list (name, real_type);
7440       /* Remeber arguments declared final. */
7441       ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
7442       
7443       if (jdep)
7444         JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
7445       TREE_CHAIN (arg_node) = arg_types;
7446       arg_types = arg_node;
7447     }
7448   TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
7449   node = build_tree_list (id, meth);
7450   return node;
7451 }
7452
7453 static int
7454 unresolved_type_p (wfl, returned)
7455      tree wfl;
7456      tree *returned;
7457      
7458 {
7459   if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
7460     {
7461       if (returned)
7462         {
7463           tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
7464           if (decl && current_class && (decl == TYPE_NAME (current_class)))
7465             *returned = TREE_TYPE (decl);
7466           else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
7467             *returned = TREE_TYPE (GET_CPC ());
7468           else
7469             *returned = NULL_TREE;
7470         }
7471       return 1;
7472     }
7473   if (returned)
7474     *returned = wfl;
7475   return 0;
7476 }
7477
7478 /* From NAME, build a qualified identifier node using the
7479    qualification from the current package definition. */
7480
7481 static tree
7482 parser_qualified_classname (is_static, name)
7483      int is_static;
7484      tree name;
7485 {
7486   tree nested_class_name;
7487
7488   if (!is_static 
7489       && (nested_class_name = maybe_make_nested_class_name (name)))
7490     return nested_class_name;
7491
7492   if (ctxp->package)
7493     return merge_qualified_name (ctxp->package, name);
7494   else 
7495     return name;
7496 }
7497
7498 /* Called once the type a interface extends is resolved. Returns 0 if
7499    everything is OK.  */
7500
7501 static int
7502 parser_check_super_interface (super_decl, this_decl, this_wfl)
7503      tree super_decl, this_decl, this_wfl;
7504 {
7505   tree super_type = TREE_TYPE (super_decl);
7506
7507   /* Has to be an interface */
7508   if (!CLASS_INTERFACE (super_decl))
7509     {
7510       parse_error_context 
7511         (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
7512          (TYPE_ARRAY_P (super_type) ? "array" : "class"),
7513          IDENTIFIER_POINTER (DECL_NAME (super_decl)),
7514          (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ? 
7515           "interface" : "class"),
7516          IDENTIFIER_POINTER (DECL_NAME (this_decl)));
7517       return 1;
7518     }
7519
7520   /* Check scope: same package OK, other package: OK if public */
7521   if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
7522     return 1;
7523
7524   SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
7525                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7526                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7527   return 0;
7528 }
7529
7530 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
7531    0 if everthing is OK.  */
7532
7533 static int
7534 parser_check_super (super_decl, this_decl, wfl)
7535      tree super_decl, this_decl, wfl;
7536 {
7537   tree super_type = TREE_TYPE (super_decl);
7538
7539   /* SUPER should be a CLASS (neither an array nor an interface) */
7540   if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
7541     {
7542       parse_error_context 
7543         (wfl, "Class `%s' can't subclass %s `%s'",
7544          IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7545          (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
7546          IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7547       return 1;
7548     }
7549
7550   if (CLASS_FINAL (TYPE_NAME (super_type)))
7551     {
7552       parse_error_context (wfl, "Can't subclass final classes: %s",
7553                            IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7554       return 1;
7555     }
7556
7557   /* Check scope: same package OK, other package: OK if public */
7558   if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
7559     return 1;
7560   
7561   SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
7562                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7563                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7564   return 0;
7565 }
7566
7567 /* Create a new dependency list and link it (in a LIFO manner) to the
7568    CTXP list of type dependency list.  */
7569
7570 static void
7571 create_jdep_list (ctxp)
7572      struct parser_ctxt *ctxp;
7573 {
7574   jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));      
7575   new->first = new->last = NULL;
7576   new->next = ctxp->classd_list;
7577   ctxp->classd_list = new;
7578 }
7579
7580 static jdeplist *
7581 reverse_jdep_list (ctxp)
7582      struct parser_ctxt *ctxp;
7583 {
7584   register jdeplist *prev = NULL, *current, *next;
7585   for (current = ctxp->classd_list; current; current = next)
7586     {
7587       next = current->next;
7588       current->next = prev;
7589       prev = current;
7590     }
7591   return prev;
7592 }
7593
7594 /* Create a fake pointer based on the ID stored in
7595    TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
7596    registered again. */
7597
7598 static tree
7599 obtain_incomplete_type (type_name)
7600      tree type_name;
7601 {
7602   tree ptr, name;
7603
7604   if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
7605     name = EXPR_WFL_NODE (type_name);
7606   else if (INCOMPLETE_TYPE_P (type_name))
7607     name = TYPE_NAME (type_name);
7608   else
7609     fatal ("invalid type name - obtain_incomplete_type");
7610
7611   for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
7612     if (TYPE_NAME (ptr) == name)
7613       break;
7614
7615   if (!ptr)
7616     {
7617       push_obstacks (&permanent_obstack, &permanent_obstack);
7618       BUILD_PTR_FROM_NAME (ptr, name);
7619       layout_type (ptr);
7620       pop_obstacks ();
7621       TREE_CHAIN (ptr) = ctxp->incomplete_class;
7622       ctxp->incomplete_class = ptr;
7623     }
7624
7625   return ptr;
7626 }
7627
7628 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
7629    non NULL instead of computing a new fake type based on WFL. The new
7630    dependency is inserted in the current type dependency list, in FIFO
7631    manner.  */
7632
7633 static tree
7634 register_incomplete_type (kind, wfl, decl, ptr)
7635      int kind;
7636      tree wfl, decl, ptr;
7637 {
7638   jdep *new = (jdep *)xmalloc (sizeof (jdep));
7639
7640   if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
7641     ptr = obtain_incomplete_type (wfl);
7642
7643   JDEP_KIND (new) = kind;
7644   JDEP_DECL (new) = decl;
7645   JDEP_SOLV (new) = ptr;
7646   JDEP_WFL (new) = wfl;
7647   JDEP_CHAIN (new) = NULL;
7648   JDEP_MISC (new) = NULL_TREE;
7649   /* For some dependencies, set the enclosing class of the current
7650      class to be the enclosing context */
7651   if ((kind == JDEP_SUPER || kind == JDEP_INTERFACE || kind == JDEP_ANONYMOUS)
7652       && GET_ENCLOSING_CPC ())
7653     JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
7654   else
7655     JDEP_ENCLOSING (new) = GET_CPC ();
7656   JDEP_GET_PATCH (new) = (tree *)NULL;
7657
7658   JDEP_INSERT (ctxp->classd_list, new);
7659
7660   return ptr;
7661 }
7662
7663 void
7664 java_check_circular_reference ()
7665 {
7666   tree current;
7667   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7668     {
7669       tree type = TREE_TYPE (current);
7670       if (CLASS_INTERFACE (current))
7671         {
7672           /* Check all interfaces this class extends */
7673           tree basetype_vec = TYPE_BINFO_BASETYPES (type);
7674           int n, i;
7675
7676           if (!basetype_vec)
7677             return;
7678           n = TREE_VEC_LENGTH (basetype_vec);
7679           for (i = 0; i < n; i++)
7680             {
7681               tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7682               if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node 
7683                   && interface_of_p (type, BINFO_TYPE (vec_elt)))
7684                 parse_error_context (lookup_cl (current),
7685                                      "Cyclic interface inheritance");
7686             }
7687         }
7688       else
7689         if (inherits_from_p (CLASSTYPE_SUPER (type), type))
7690           parse_error_context (lookup_cl (current), 
7691                                "Cyclic class inheritance%s",
7692                                (cyclic_inheritance_report ?
7693                                 cyclic_inheritance_report : ""));
7694     }
7695 }
7696
7697 /* Augment the parameter list PARM with parameters crafted to
7698    initialize outer context locals aliases. Through ARTIFICIAL, a
7699    count is kept of the number of crafted parameters. MODE governs
7700    what eventually gets created: something suitable for a function
7701    creation or a function invocation, either the constructor or
7702    $finit$.  */
7703
7704 static tree
7705 build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
7706     int mode;
7707     tree class_type, parm;
7708     int *artificial;
7709 {
7710   tree field;
7711   for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
7712     if (FIELD_LOCAL_ALIAS (field))
7713       {
7714         char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
7715         tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
7716
7717         switch (mode)
7718           {
7719           case AIPL_FUNCTION_DECLARATION:
7720             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7721             purpose = build_wfl_node (get_identifier (buffer));
7722             if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
7723               value = build_wfl_node (TYPE_NAME (TREE_TYPE (field)));
7724             else
7725               value = TREE_TYPE (field);
7726             break;
7727
7728           case AIPL_FUNCTION_CREATION:
7729             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7730             purpose = get_identifier (buffer);
7731             value = TREE_TYPE (field);
7732             break;
7733
7734           case AIPL_FUNCTION_FINIT_INVOCATION:
7735             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7736             /* Now, this is wrong. purpose should always be the NAME
7737                of something and value its matching value (decl, type,
7738                etc...) FIXME -- but there is a lot to fix. */
7739
7740             /* When invoked for this kind of operation, we already
7741                know whether a field is used or not. */
7742             purpose = TREE_TYPE (field);
7743             value = build_wfl_node (get_identifier (buffer));
7744             break;
7745
7746           case AIPL_FUNCTION_CTOR_INVOCATION:
7747             /* There are two case: the constructor invokation happends
7748                outside the local inner, in which case, locales from the outer
7749                context are directly used.
7750
7751                Otherwise, we fold to using the alias directly. */
7752             if (class_type == current_class)
7753               value = field;
7754             else
7755               {
7756                 name = get_identifier (&buffer[4]);
7757                 value = IDENTIFIER_LOCAL_VALUE (name);
7758               }
7759             break;
7760           }
7761         parm = tree_cons (purpose, value, parm);
7762         if (artificial)
7763           *artificial +=1;
7764       }
7765   return parm;
7766 }
7767
7768 /* Craft a constructor for CLASS_DECL -- what we should do when none
7769    where found. ARGS is non NULL when a special signature must be
7770    enforced. This is the case for anonymous classes.  */
7771
7772 static void
7773 craft_constructor (class_decl, args)
7774      tree class_decl, args;
7775 {
7776   tree class_type = TREE_TYPE (class_decl);
7777   tree parm = NULL_TREE;
7778   int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7779                ACC_PUBLIC : 0);
7780   int i = 0, artificial = 0;
7781   tree decl, ctor_name;
7782   char buffer [80];
7783   
7784   push_obstacks (&permanent_obstack, &permanent_obstack);
7785
7786   /* The constructor name is <init> unless we're dealing with an
7787      anonymous class, in which case the name will be fixed after having
7788      be expanded. */
7789   if (ANONYMOUS_CLASS_P (class_type))
7790     ctor_name = DECL_NAME (class_decl);
7791   else
7792     ctor_name = init_identifier_node;
7793
7794   /* If we're dealing with an inner class constructor, we hide the
7795      this$<n> decl in the name field of its parameter declaration. */
7796   if (PURE_INNER_CLASS_TYPE_P (class_type))
7797     {
7798       tree type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_type)));
7799       parm = tree_cons (build_current_thisn (class_type),
7800                         build_pointer_type (type), parm);
7801
7802       /* Some more arguments to be hidden here. The values of the local
7803          variables of the outer context that the inner class needs to see. */
7804       parm = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
7805                                                      class_type, parm, 
7806                                                      &artificial);
7807     }
7808
7809   /* Then if there are any args to be enforced, enforce them now */
7810   for (; args && args != end_params_node; args = TREE_CHAIN (args))
7811     {
7812       sprintf (buffer, "parm%d", i++);
7813       parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
7814     }
7815
7816   CRAFTED_PARAM_LIST_FIXUP (parm);
7817   decl = create_artificial_method (class_type, flags, void_type_node, 
7818                                    ctor_name, parm);
7819   fix_method_argument_names (parm, decl);
7820   /* Now, mark the artificial parameters. */
7821   DECL_FUNCTION_NAP (decl) = artificial;
7822
7823   pop_obstacks ();
7824   DECL_CONSTRUCTOR_P (decl) = 1;
7825 }
7826
7827
7828 /* Fix the constructors. This will be called right after circular
7829    references have been checked. It is necessary to fix constructors
7830    early even if no code generation will take place for that class:
7831    some generated constructor might be required by the class whose
7832    compilation triggered this one to be simply loaded.  */
7833
7834 void
7835 java_fix_constructors ()
7836 {
7837   tree current;
7838
7839   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7840     {
7841       tree class_type = TREE_TYPE (current);
7842       int saw_ctor = 0;
7843       tree decl;
7844
7845       if (CLASS_INTERFACE (TYPE_NAME (class_type)))
7846         continue;
7847
7848       for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
7849         {
7850           if (DECL_CONSTRUCTOR_P (decl))
7851             {
7852               fix_constructors (decl);
7853               saw_ctor = 1;
7854             }
7855         }
7856
7857       /* Anonymous class constructor can't be generated that early. */
7858       if (!saw_ctor && !ANONYMOUS_CLASS_P (class_type))
7859         craft_constructor (current, NULL_TREE);
7860     }
7861 }
7862
7863 /* safe_layout_class just makes sure that we can load a class without
7864    disrupting the current_class, input_file, lineno, etc, information
7865    about the class processed currently.  */
7866
7867 void
7868 safe_layout_class (class)
7869      tree class;
7870 {
7871   tree save_current_class = current_class;
7872   const char *save_input_filename = input_filename;
7873   int save_lineno = lineno;
7874
7875   push_obstacks (&permanent_obstack, &permanent_obstack);
7876
7877   layout_class (class);
7878   pop_obstacks ();
7879
7880   current_class = save_current_class;
7881   input_filename = save_input_filename;
7882   lineno = save_lineno;
7883   CLASS_LOADED_P (class) = 1;
7884 }
7885
7886 static tree
7887 jdep_resolve_class (dep)
7888      jdep *dep;
7889 {
7890   tree decl;
7891
7892   if (JDEP_RESOLVED_P (dep))
7893     decl = JDEP_RESOLVED_DECL (dep);
7894   else
7895     {
7896       decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
7897                             JDEP_DECL (dep), JDEP_WFL (dep));
7898       JDEP_RESOLVED (dep, decl);
7899     }
7900     
7901   if (!decl)
7902     complete_class_report_errors (dep);
7903
7904   return decl;
7905 }
7906
7907 /* Complete unsatisfied class declaration and their dependencies */
7908
7909 void
7910 java_complete_class ()
7911 {
7912   tree cclass;
7913   jdeplist *cclassd;
7914   int error_found;
7915   tree type;
7916
7917   push_obstacks (&permanent_obstack, &permanent_obstack);
7918
7919   /* Process imports */
7920   process_imports ();
7921
7922   /* Rever things so we have the right order */
7923   ctxp->class_list = nreverse (ctxp->class_list);
7924   ctxp->classd_list = reverse_jdep_list (ctxp);
7925
7926   for (cclassd = ctxp->classd_list, cclass = ctxp->class_list; 
7927        cclass && cclassd; 
7928        cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
7929     {
7930       jdep *dep;
7931       for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
7932         {
7933           tree decl;
7934           if (!(decl = jdep_resolve_class (dep)))
7935             continue;
7936
7937           /* Now it's time to patch */
7938           switch (JDEP_KIND (dep))
7939             {
7940             case JDEP_SUPER:
7941               /* Simply patch super */
7942               if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
7943                 continue;
7944               BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO 
7945                 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
7946               break;
7947
7948             case JDEP_FIELD:
7949               {
7950                 /* We do part of the job done in add_field */
7951                 tree field_decl = JDEP_DECL (dep);
7952                 tree field_type = TREE_TYPE (decl);
7953                 push_obstacks (&permanent_obstack, &permanent_obstack);
7954                 if (TREE_CODE (field_type) == RECORD_TYPE)
7955                   field_type = promote_type (field_type);
7956                 pop_obstacks ();
7957                 TREE_TYPE (field_decl) = field_type;
7958                 DECL_ALIGN (field_decl) = 0;
7959                 DECL_USER_ALIGN (field_decl) = 0;
7960                 layout_decl (field_decl, 0);
7961                 SOURCE_FRONTEND_DEBUG 
7962                   (("Completed field/var decl `%s' with `%s'",
7963                     IDENTIFIER_POINTER (DECL_NAME (field_decl)),
7964                     IDENTIFIER_POINTER (DECL_NAME (decl))));
7965                 break;
7966               }
7967             case JDEP_METHOD:   /* We start patching a method */
7968             case JDEP_METHOD_RETURN:
7969               error_found = 0;
7970               while (1)
7971                 {
7972                   if (decl)
7973                     {
7974                       type = TREE_TYPE(decl);
7975                       if (TREE_CODE (type) == RECORD_TYPE)
7976                         type = promote_type (type);
7977                       JDEP_APPLY_PATCH (dep, type);
7978                       SOURCE_FRONTEND_DEBUG 
7979                         (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
7980                            "Completing fct `%s' with ret type `%s'":
7981                            "Completing arg `%s' with type `%s'"),
7982                           IDENTIFIER_POINTER (EXPR_WFL_NODE 
7983                                               (JDEP_DECL_WFL (dep))),
7984                           IDENTIFIER_POINTER (DECL_NAME (decl))));
7985                     }
7986                   else
7987                     error_found = 1;
7988                   dep = JDEP_CHAIN (dep);
7989                   if (JDEP_KIND (dep) == JDEP_METHOD_END)
7990                     break;
7991                   else
7992                     decl = jdep_resolve_class (dep);
7993                 }
7994               if (!error_found)
7995                 {
7996                   tree mdecl = JDEP_DECL (dep), signature;
7997                   push_obstacks (&permanent_obstack, &permanent_obstack);
7998                   /* Recompute and reset the signature, check first that
7999                      all types are now defined. If they're not,
8000                      dont build the signature. */
8001                   if (check_method_types_complete (mdecl))
8002                     {
8003                       signature = build_java_signature (TREE_TYPE (mdecl));
8004                       set_java_signature (TREE_TYPE (mdecl), signature);
8005                     }
8006                   pop_obstacks ();
8007                 }
8008               else
8009                 continue;
8010               break;
8011
8012             case JDEP_INTERFACE:
8013               if (parser_check_super_interface (decl, JDEP_DECL (dep),
8014                                                 JDEP_WFL (dep)))
8015                 continue;
8016               parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
8017               break;
8018
8019             case JDEP_PARM:
8020             case JDEP_VARIABLE:
8021               type = TREE_TYPE(decl);
8022               if (TREE_CODE (type) == RECORD_TYPE)
8023                 type = promote_type (type);
8024               JDEP_APPLY_PATCH (dep, type);
8025               break;
8026
8027             case JDEP_TYPE:
8028               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8029               SOURCE_FRONTEND_DEBUG 
8030                 (("Completing a random type dependency on a '%s' node",
8031                   tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
8032               break;
8033
8034             case JDEP_EXCEPTION:
8035               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8036               SOURCE_FRONTEND_DEBUG 
8037                 (("Completing `%s' `throws' argument node",
8038                   IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
8039               break;
8040
8041             case JDEP_ANONYMOUS:
8042               patch_anonymous_class (decl, JDEP_DECL (dep), JDEP_WFL (dep));
8043               break;
8044
8045             default:
8046               fatal ("Can't handle patch code %d - java_complete_class",
8047                      JDEP_KIND (dep));
8048             }
8049         }
8050     }
8051   pop_obstacks ();
8052   return;
8053 }
8054
8055 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
8056    array.  */
8057
8058 static tree
8059 resolve_class (enclosing, class_type, decl, cl)
8060      tree enclosing, class_type, decl, cl;
8061 {
8062   const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
8063   const char *base = name;
8064   tree resolved_type = TREE_TYPE (class_type);
8065   tree resolved_type_decl;
8066   
8067   if (resolved_type != NULL_TREE)
8068     {
8069       tree resolved_type_decl = TYPE_NAME (resolved_type);
8070       if (resolved_type_decl == NULL_TREE
8071           || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
8072         {
8073           resolved_type_decl = build_decl (TYPE_DECL,
8074                                            TYPE_NAME (class_type),
8075                                            resolved_type);
8076         }
8077       return resolved_type_decl;
8078     }
8079
8080   /* 1- Check to see if we have an array. If true, find what we really
8081      want to resolve  */
8082   while (name[0] == '[')
8083     name++;
8084   if (base != name)
8085     TYPE_NAME (class_type) = get_identifier (name);
8086
8087   /* 2- Resolve the bare type */
8088   if (!(resolved_type_decl = do_resolve_class (enclosing, class_type, 
8089                                                decl, cl)))
8090     return NULL_TREE;
8091   resolved_type = TREE_TYPE (resolved_type_decl);
8092
8093   /* 3- If we have and array, reconstruct the array down to its nesting */
8094   if (base != name)
8095     {
8096       while (base != name)
8097         {
8098           if (TREE_CODE (resolved_type) == RECORD_TYPE)
8099             resolved_type  = promote_type (resolved_type);
8100           resolved_type = build_java_array_type (resolved_type, -1);
8101           CLASS_LOADED_P (resolved_type) = 1;
8102           name--;
8103         }
8104       /* Build a fake decl for this, since this is what is expected to
8105          be returned.  */
8106       resolved_type_decl =
8107         build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
8108       /* Figure how those two things are important for error report. FIXME */
8109       DECL_SOURCE_LINE (resolved_type_decl) = 0;
8110       DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
8111       TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
8112     }
8113   TREE_TYPE (class_type) = resolved_type;
8114   return resolved_type_decl;
8115 }
8116
8117 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
8118    are used to report error messages.  */
8119
8120 tree
8121 do_resolve_class (enclosing, class_type, decl, cl)
8122      tree enclosing, class_type, decl, cl;
8123 {
8124   tree new_class_decl;
8125
8126   /* Do not try to replace TYPE_NAME (class_type) by a variable, since
8127      it is changed by find_in_imports{_on_demand} and (but it doesn't
8128      really matter) qualify_and_find */
8129
8130   /* 0- Search in the current class as an inner class */
8131
8132   /* Maybe some code here should be added to load the class or
8133      something, at least if the class isn't an inner class and ended
8134      being loaded from class file. FIXME. */
8135   while (enclosing)
8136     {
8137       tree name;
8138
8139       if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl)))
8140         return new_class_decl;
8141
8142       /* Now go to the upper classes, bail out if necessary. */
8143       enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing));
8144       if (!enclosing || enclosing == object_type_node)
8145         break;
8146       
8147       if (TREE_CODE (enclosing) == RECORD_TYPE)
8148         {
8149           enclosing = TYPE_NAME (enclosing);
8150           continue;
8151         }
8152
8153       if (TREE_CODE (enclosing) == IDENTIFIER_NODE)
8154         {
8155           BUILD_PTR_FROM_NAME (name, enclosing);
8156         }
8157       else
8158         name = enclosing;
8159       enclosing = do_resolve_class (NULL, name, NULL, NULL);
8160     }
8161
8162   /* 1- Check for the type in single imports. This will change
8163      TYPE_NAME() if something relevant is found */
8164   find_in_imports (class_type);
8165
8166   /* 2- And check for the type in the current compilation unit */
8167   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8168     {
8169       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8170           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8171         load_class (TYPE_NAME (class_type), 0);
8172       return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8173     }
8174
8175   /* 3- Search according to the current package definition */
8176   if (!QUALIFIED_P (TYPE_NAME (class_type)))
8177     {
8178       if ((new_class_decl = qualify_and_find (class_type, ctxp->package,
8179                                              TYPE_NAME (class_type))))
8180         return new_class_decl;
8181     }
8182
8183   /* 4- Check the import on demands. Don't allow bar.baz to be
8184      imported from foo.* */
8185   if (!QUALIFIED_P (TYPE_NAME (class_type)))
8186     if (find_in_imports_on_demand (class_type))
8187       return NULL_TREE;
8188
8189   /* If found in find_in_imports_on_demant, the type has already been
8190      loaded. */
8191   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8192     return new_class_decl;
8193
8194   /* 5- Try with a name qualified with the package name we've seen so far */
8195   if (!QUALIFIED_P (TYPE_NAME (class_type)))
8196     {
8197       tree package;
8198
8199       /* If there is a current package (ctxp->package), it's the first
8200          element of package_list and we can skip it. */
8201       for (package = (ctxp->package ? 
8202                       TREE_CHAIN (package_list) : package_list);
8203            package; package = TREE_CHAIN (package))
8204         if ((new_class_decl = qualify_and_find (class_type,
8205                                                TREE_PURPOSE (package), 
8206                                                TYPE_NAME (class_type))))
8207           return new_class_decl;
8208     }
8209
8210   /* 5- Check an other compilation unit that bears the name of type */
8211   load_class (TYPE_NAME (class_type), 0);
8212   if (check_pkg_class_access (TYPE_NAME (class_type), 
8213                               (cl ? cl : lookup_cl (decl))))
8214     return NULL_TREE;
8215
8216   /* 6- Last call for a resolution */
8217   return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8218 }
8219
8220 static tree
8221 qualify_and_find (class_type, package, name)
8222      tree class_type, package, name;
8223 {
8224   tree new_qualified = merge_qualified_name (package, name);
8225   tree new_class_decl;
8226
8227   if (!IDENTIFIER_CLASS_VALUE (new_qualified))
8228     load_class (new_qualified, 0);
8229   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (new_qualified)))
8230     {
8231       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8232           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8233         load_class (new_qualified, 0);
8234       TYPE_NAME (class_type) = new_qualified;
8235       return IDENTIFIER_CLASS_VALUE (new_qualified);
8236     }
8237   return NULL_TREE;
8238 }
8239
8240 /* Resolve NAME and lay it out (if not done and if not the current
8241    parsed class). Return a decl node. This function is meant to be
8242    called when type resolution is necessary during the walk pass.  */
8243
8244 static tree
8245 resolve_and_layout (something, cl)
8246      tree something;
8247      tree cl;
8248 {
8249   tree decl;
8250
8251   /* Don't do that on the current class */
8252   if (something == current_class)
8253     return TYPE_NAME (current_class);
8254
8255   /* Don't do anything for void and other primitive types */
8256   if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8257     return NULL_TREE;
8258
8259   /* Pointer types can be reall pointer types or fake pointers. When
8260      finding a real pointer, recheck for primitive types */
8261   if (TREE_CODE (something) == POINTER_TYPE)
8262     {
8263       if (TREE_TYPE (something))
8264         {
8265           something = TREE_TYPE (something);
8266           if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8267             return NULL_TREE;
8268         }
8269       else
8270         something = TYPE_NAME (something);
8271     }
8272
8273   /* Don't do anything for arrays of primitive types */
8274   if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
8275       && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
8276     return NULL_TREE;
8277
8278   /* Something might be a WFL */
8279   if (TREE_CODE (something) == EXPR_WITH_FILE_LOCATION)
8280     something = EXPR_WFL_NODE (something);
8281
8282   /* Otherwise, if something is not and IDENTIFIER_NODE, it can be a a
8283      TYPE_DECL or a real TYPE */
8284   else if (TREE_CODE (something) != IDENTIFIER_NODE)
8285     something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
8286             DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
8287
8288   if (!(decl = resolve_no_layout (something, cl)))
8289     return NULL_TREE;
8290
8291   /* Resolve and layout if necessary */
8292   layout_class_methods (TREE_TYPE (decl));
8293   /* Check methods, but only once */
8294   if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) 
8295       && !CLASS_LOADED_P (TREE_TYPE (decl)))
8296     CHECK_METHODS (decl);
8297   if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
8298     safe_layout_class (TREE_TYPE (decl));
8299
8300   return decl;
8301 }
8302
8303 /* Resolve a class, returns its decl but doesn't perform any
8304    layout. The current parsing context is saved and restored */
8305
8306 static tree
8307 resolve_no_layout (name, cl)
8308      tree name, cl;
8309 {
8310   tree ptr, decl;
8311   BUILD_PTR_FROM_NAME (ptr, name);
8312   java_parser_context_save_global ();
8313   decl = resolve_class (TYPE_NAME (current_class), ptr, NULL_TREE, cl);
8314   java_parser_context_restore_global ();
8315   
8316   return decl;
8317 }
8318
8319 /* Called when reporting errors. Skip leader '[' in a complex array
8320    type description that failed to be resolved.  */
8321
8322 static const char *
8323 purify_type_name (name)
8324      const char *name;
8325 {
8326   while (*name && *name == '[')
8327     name++;
8328   return name;
8329 }
8330
8331 /* The type CURRENT refers to can't be found. We print error messages.  */
8332
8333 static void
8334 complete_class_report_errors (dep)
8335      jdep *dep;
8336 {
8337   const char *name;
8338
8339   if (!JDEP_WFL (dep))
8340     return;
8341
8342   name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
8343   switch (JDEP_KIND (dep))
8344     {
8345     case JDEP_SUPER:
8346       parse_error_context  
8347         (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
8348          purify_type_name (name),
8349          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8350       break;
8351     case JDEP_FIELD:
8352       parse_error_context
8353         (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
8354          purify_type_name (name),
8355          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8356       break;
8357     case JDEP_METHOD:           /* Covers arguments */
8358       parse_error_context
8359         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
8360          purify_type_name (name),
8361          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
8362          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
8363       break;
8364     case JDEP_METHOD_RETURN:    /* Covers return type */
8365       parse_error_context
8366         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'", 
8367          purify_type_name (name),
8368          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
8369       break;
8370     case JDEP_INTERFACE:
8371       parse_error_context
8372         (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
8373          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
8374          (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
8375          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8376       break;
8377     case JDEP_VARIABLE:
8378       parse_error_context
8379         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'", 
8380          purify_type_name (IDENTIFIER_POINTER 
8381                            (EXPR_WFL_NODE (JDEP_WFL (dep)))),
8382          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8383       break;
8384     case JDEP_EXCEPTION:        /* As specified by `throws' */
8385       parse_error_context 
8386           (JDEP_WFL (dep), "Class `%s' not found in `throws'",
8387          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
8388       break;
8389     default:
8390       /* Fix for -Wall. Just break doing nothing. The error will be
8391          caught later */
8392       break;
8393     }
8394 }
8395
8396 /* Return a static string containing the DECL prototype string. If
8397    DECL is a constructor, use the class name instead of the form
8398    <init> */
8399
8400 static const char *
8401 get_printable_method_name (decl)
8402      tree decl;
8403 {
8404   const char *to_return;
8405   tree name = NULL_TREE;
8406
8407   if (DECL_CONSTRUCTOR_P (decl))
8408     {
8409       name = DECL_NAME (decl);
8410       DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
8411     }
8412       
8413   to_return = lang_printable_name (decl, 0);
8414   if (DECL_CONSTRUCTOR_P (decl))
8415     DECL_NAME (decl) = name;
8416   
8417   return to_return;
8418 }
8419
8420 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
8421    nevertheless needs to be verfied, 1 otherwise.  */
8422
8423 static int
8424 reset_method_name (method)
8425      tree method;
8426 {
8427   if (!DECL_CLINIT_P (method) && !DECL_FINIT_P (method))
8428     {
8429       /* NAME is just the plain name when Object is being defined */
8430       if (DECL_CONTEXT (method) != object_type_node)
8431         DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ? 
8432                               init_identifier_node : GET_METHOD_NAME (method));
8433       return 0;
8434     }
8435   else 
8436     return 1;
8437 }
8438
8439 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
8440
8441 tree
8442 java_get_real_method_name (method_decl)
8443      tree method_decl;
8444 {
8445   tree method_name = DECL_NAME (method_decl);
8446   if (DECL_CONSTRUCTOR_P (method_decl))
8447     return init_identifier_node;
8448
8449   /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
8450      and still can be a constructor. FIXME */
8451
8452   /* Don't confuse method only bearing the name of their class as
8453      constructors */
8454   else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
8455            && ctxp
8456            && GET_CPC_UN () == EXPR_WFL_NODE (method_name)
8457            && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
8458            && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
8459     return init_identifier_node;
8460   else
8461     return EXPR_WFL_NODE (method_name);
8462 }
8463
8464 /* Track method being redefined inside the same class. As a side
8465    effect, set DECL_NAME to an IDENTIFIER (prior entering this
8466    function it's a FWL, so we can track errors more accurately.)  */
8467
8468 static int
8469 check_method_redefinition (class, method)
8470      tree class, method;
8471 {
8472   tree redef, name;
8473   tree cl = DECL_NAME (method);
8474   tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
8475   /* decl name of artificial <clinit> and $finit$ doesn't need to be
8476      fixed and checked */
8477
8478   /* Reset the method name before running the check. If it returns 1,
8479      the method doesn't need to be verified with respect to method
8480      redeclaration and we return 0 */
8481   if (reset_method_name (method))
8482     return 0;
8483
8484   name = DECL_NAME (method);
8485   for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
8486     {
8487       if (redef == method)
8488         break;
8489       if (DECL_NAME (redef) == name 
8490           && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
8491         {
8492           parse_error_context 
8493             (cl, "Duplicate %s declaration `%s'",
8494              (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
8495              get_printable_method_name (redef));
8496           return 1;
8497         }
8498     }
8499   return 0;
8500 }
8501
8502 static void
8503 check_abstract_method_definitions (do_interface, class_decl, type)
8504      int do_interface;
8505      tree class_decl, type;
8506 {
8507   tree class = TREE_TYPE (class_decl);
8508   tree method, end_type;
8509
8510   end_type = (do_interface ? object_type_node : type);
8511   for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
8512     {
8513       tree other_super, other_method, method_sig, method_name;
8514       int found = 0;
8515       int end_type_reached = 0;
8516       
8517       if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
8518         continue;
8519       
8520       /* Now verify that somewhere in between TYPE and CLASS,
8521          abstract method METHOD gets a non abstract definition
8522          that is inherited by CLASS.  */
8523       
8524       method_sig = build_java_signature (TREE_TYPE (method));
8525       method_name = DECL_NAME (method);
8526       if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
8527         method_name = EXPR_WFL_NODE (method_name);
8528
8529       other_super = class;
8530       do {
8531         if (other_super == end_type)
8532           end_type_reached = 1;
8533         
8534         /* Method search */
8535         for (other_method = TYPE_METHODS (other_super); other_method;
8536             other_method = TREE_CHAIN (other_method))
8537           {
8538             tree s = build_java_signature (TREE_TYPE (other_method));
8539             tree other_name = DECL_NAME (other_method);
8540             
8541             if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
8542               other_name = EXPR_WFL_NODE (other_name);
8543             if (!DECL_CLINIT_P (other_method)
8544                 && !DECL_CONSTRUCTOR_P (other_method)
8545                 && method_name == other_name
8546                 && method_sig == s
8547                 && !METHOD_ABSTRACT (other_method))
8548              {
8549                found = 1;
8550                break;
8551              }
8552           }
8553         other_super = CLASSTYPE_SUPER (other_super);
8554       } while (!end_type_reached);
8555  
8556       /* Report that abstract METHOD didn't find an implementation
8557          that CLASS can use. */
8558       if (!found)
8559         {
8560           char *t = xstrdup (lang_printable_name 
8561                             (TREE_TYPE (TREE_TYPE (method)), 0));
8562           tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
8563           tree saved_wfl = NULL_TREE;
8564           
8565           if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION)
8566             {
8567               saved_wfl = DECL_NAME (method);
8568               DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
8569             }
8570           
8571           parse_error_context 
8572             (lookup_cl (class_decl),
8573              "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",
8574              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8575              t, lang_printable_name (method, 0), 
8576              (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ? 
8577               "interface" : "class"),
8578              IDENTIFIER_POINTER (ccn),
8579              (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
8580              IDENTIFIER_POINTER (DECL_NAME (class_decl)));
8581           
8582           free (t);
8583           
8584           if (saved_wfl)
8585             DECL_NAME (method) = saved_wfl;
8586         }
8587     }
8588 }
8589
8590 /* Check that CLASS_DECL somehow implements all inherited abstract
8591    methods.  */
8592
8593 static void
8594 java_check_abstract_method_definitions (class_decl)
8595      tree class_decl;
8596 {
8597   tree class = TREE_TYPE (class_decl);
8598   tree super, vector;
8599   int i;
8600
8601   if (CLASS_ABSTRACT (class_decl))
8602     return;
8603
8604   /* Check for inherited types */
8605   super = class;
8606   do {
8607     super = CLASSTYPE_SUPER (super);
8608     check_abstract_method_definitions (0, class_decl, super);
8609   } while (super != object_type_node);
8610
8611   /* Check for implemented interfaces. */
8612   vector = TYPE_BINFO_BASETYPES (class);
8613   for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
8614     {
8615       super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
8616       check_abstract_method_definitions (1, class_decl, super);
8617     }
8618 }
8619
8620 /* Check all the types method DECL uses and return 1 if all of them
8621    are now complete, 0 otherwise. This is used to check whether its
8622    safe to build a method signature or not.  */
8623
8624 static int
8625 check_method_types_complete (decl)
8626      tree decl;
8627 {
8628   tree type = TREE_TYPE (decl);
8629   tree args;
8630
8631   if (!INCOMPLETE_TYPE_P (TREE_TYPE (type)))
8632     return 0;
8633   
8634   args = TYPE_ARG_TYPES (type);
8635   if (TREE_CODE (type) == METHOD_TYPE)
8636     args = TREE_CHAIN (args);
8637   for (; args != end_params_node; args = TREE_CHAIN (args))
8638     if (INCOMPLETE_TYPE_P (TREE_VALUE (args)))
8639       return 0;
8640
8641   return 1;
8642 }
8643
8644 /* Check all the methods of CLASS_DECL. Methods are first completed
8645    then checked according to regular method existance rules.  If no
8646    constructor for CLASS_DECL were encountered, then build its
8647    declaration.  */
8648
8649 static void
8650 java_check_regular_methods (class_decl)
8651      tree class_decl;
8652 {
8653   int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
8654   tree method;
8655   tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
8656   tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
8657   tree mthrows;
8658
8659   /* It is not necessary to check methods defined in java.lang.Object */
8660   if (class == object_type_node)
8661     return;
8662
8663   if (!TYPE_NVIRTUALS (class))
8664     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8665
8666   /* Should take interfaces into account. FIXME */
8667   for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
8668     {
8669       tree sig;
8670       tree method_wfl = DECL_NAME (method);
8671       int aflags;
8672
8673       /* If we previously found something and its name was saved,
8674          reinstall it now */
8675       if (found && saved_found_wfl)
8676         {
8677           DECL_NAME (found) = saved_found_wfl;
8678           saved_found_wfl = NULL_TREE;
8679         }
8680
8681       /* Check for redefinitions */
8682       if (check_method_redefinition (class, method))
8683         continue;
8684
8685       /* If we see one constructor a mark so we don't generate the
8686          default one. Also skip other verifications: constructors
8687          can't be inherited hence hiden or overriden */
8688      if (DECL_CONSTRUCTOR_P (method))
8689        {
8690          saw_constructor = 1;
8691          continue;
8692        }
8693
8694       /* We verify things thrown by the method. They must inherits from
8695          java.lang.Throwable */
8696       for (mthrows = DECL_FUNCTION_THROWS (method);
8697            mthrows; mthrows = TREE_CHAIN (mthrows))
8698         {
8699           if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
8700             parse_error_context 
8701               (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
8702                IDENTIFIER_POINTER 
8703                  (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
8704         }
8705
8706       sig = build_java_argument_signature (TREE_TYPE (method));
8707       found = lookup_argument_method2 (class, DECL_NAME (method), sig);
8708
8709       /* Inner class can't declare static methods */
8710       if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
8711         {
8712           char *t = xstrdup (lang_printable_name (class, 0));
8713           parse_error_context 
8714             (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
8715              lang_printable_name (method, 0), t);
8716           free (t);
8717         }
8718
8719       /* Nothing overrides or it's a private method. */
8720       if (!found)
8721         continue;
8722       if (METHOD_PRIVATE (found))
8723         {
8724           found = NULL_TREE;
8725           continue;
8726         }
8727
8728       /* If found wasn't verified, it's DECL_NAME won't be set properly. 
8729          We set it temporarily for the sake of the error report. */
8730       saved_found_wfl = DECL_NAME (found);
8731       reset_method_name (found);
8732
8733       /* If `found' is declared in an interface, make sure the
8734          modifier matches. */
8735       if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found))) 
8736           && clinit_identifier_node != DECL_NAME (found)
8737           && !METHOD_PUBLIC (method))
8738         {
8739           tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
8740           parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
8741                                IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8742                                lang_printable_name (method, 0),
8743                                IDENTIFIER_POINTER (DECL_NAME (found_decl)));
8744         }
8745
8746       /* Can't override a method with the same name and different return
8747          types. */
8748       if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
8749         {
8750           char *t = xstrdup 
8751             (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8752           parse_error_context 
8753             (method_wfl,
8754              "Method `%s' was defined with return type `%s' in class `%s'", 
8755              lang_printable_name (found, 0), t,
8756              IDENTIFIER_POINTER 
8757                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8758           free (t);
8759         }
8760
8761       aflags = get_access_flags_from_decl (found);
8762       /* If the method has default, access in an other package, then
8763          issue a warning that the current method doesn't override the
8764          one that was found elsewhere. Do not issue this warning when
8765          the match was found in java.lang.Object.  */
8766       if (DECL_CONTEXT (found) != object_type_node
8767           && ((aflags & ACC_VISIBILITY) == 0)
8768           && !class_in_current_package (DECL_CONTEXT (found))
8769           && !DECL_CLINIT_P (found)
8770           && flag_not_overriding)
8771         {
8772           parse_warning_context 
8773             (method_wfl, "Method `%s' in class `%s' does not override the corresponding method in class `%s', which is private to a different package",
8774              lang_printable_name (found, 0),
8775              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8776              IDENTIFIER_POINTER (DECL_NAME 
8777                                  (TYPE_NAME (DECL_CONTEXT (found)))));
8778           continue;
8779         }
8780
8781       /* Can't override final. Can't override static. */
8782       if (METHOD_FINAL (found) || METHOD_STATIC (found))
8783         {
8784           /* Static *can* override static */
8785           if (METHOD_STATIC (found) && METHOD_STATIC (method))
8786             continue;
8787           parse_error_context 
8788             (method_wfl,
8789              "%s methods can't be overriden. Method `%s' is %s in class `%s'",
8790              (METHOD_FINAL (found) ? "Final" : "Static"),
8791              lang_printable_name (found, 0),
8792              (METHOD_FINAL (found) ? "final" : "static"),
8793              IDENTIFIER_POINTER
8794                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8795           continue;
8796         }
8797
8798       /* Static method can't override instance method. */
8799       if (METHOD_STATIC (method))
8800         {
8801           parse_error_context 
8802             (method_wfl,
8803              "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'",
8804              lang_printable_name (found, 0),
8805              IDENTIFIER_POINTER
8806                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8807           continue;
8808         }
8809
8810       /* - Overriding/hiding public must be public
8811          - Overriding/hiding protected must be protected or public
8812          - If the overriden or hidden method has default (package)
8813            access, then the overriding or hiding method must not be
8814            private; otherwise, a compile-time error occurs.  If
8815            `found' belongs to an interface, things have been already
8816            taken care of.  */
8817       if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8818           && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
8819               || (METHOD_PROTECTED (found) 
8820                   && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
8821               || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
8822                   && METHOD_PRIVATE (method))))
8823         {
8824           parse_error_context 
8825             (method_wfl,
8826              "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
8827              (METHOD_PUBLIC (method) ? "public" : 
8828               (METHOD_PRIVATE (method) ? "private" : "protected")),
8829              IDENTIFIER_POINTER (DECL_NAME 
8830                                  (TYPE_NAME (DECL_CONTEXT (found)))));
8831           continue;
8832         }
8833
8834       /* Overriding methods must have compatible `throws' clauses on checked
8835          exceptions, if any */
8836       check_throws_clauses (method, method_wfl, found);
8837
8838       /* Inheriting multiple methods with the same signature. FIXME */
8839     }
8840   
8841   /* Don't forget eventual pending found and saved_found_wfl. Take
8842      into account that we might have exited because we saw an
8843      artificial method as the last entry. */
8844
8845   if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
8846     DECL_NAME (found) = saved_found_wfl;
8847
8848   if (!TYPE_NVIRTUALS (class))
8849     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8850
8851   /* Search for inherited abstract method not yet implemented in this
8852      class.  */
8853   java_check_abstract_method_definitions (class_decl);
8854
8855   if (!saw_constructor)
8856     fatal ("No constructor found");
8857 }
8858
8859 /* Return a non zero value if the `throws' clause of METHOD (if any)
8860    is incompatible with the `throws' clause of FOUND (if any).  */
8861
8862 static void
8863 check_throws_clauses (method, method_wfl, found)
8864      tree method, method_wfl, found;
8865 {
8866   tree mthrows, fthrows;
8867
8868   /* Can't check these things with class loaded from bytecode. FIXME */
8869   if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
8870     return;
8871
8872   for (mthrows = DECL_FUNCTION_THROWS (method);
8873        mthrows; mthrows = TREE_CHAIN (mthrows))
8874     {
8875       /* We don't verify unchecked expressions */
8876       if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
8877         continue;
8878       /* Checked expression must be compatible */
8879       for (fthrows = DECL_FUNCTION_THROWS (found); 
8880            fthrows; fthrows = TREE_CHAIN (fthrows))
8881         if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
8882           break;
8883       if (!fthrows)
8884         {
8885           parse_error_context 
8886             (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'",
8887              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
8888              lang_printable_name (found, 0),
8889              IDENTIFIER_POINTER 
8890                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8891         }
8892     }
8893 }
8894
8895 /* Check abstract method of interface INTERFACE */
8896
8897 static void
8898 java_check_abstract_methods (interface_decl)
8899      tree interface_decl;
8900 {
8901   int i, n;
8902   tree method, basetype_vec, found;
8903   tree interface = TREE_TYPE (interface_decl);
8904
8905   for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
8906     {
8907       tree method_wfl = DECL_NAME (method);
8908
8909       /* 2- Check for double definition inside the defining interface */
8910       if (check_method_redefinition (interface, method))
8911         continue;
8912
8913       /* 3- Overriding is OK as far as we preserve the return type and
8914          the thrown exceptions (FIXME) */
8915       found = lookup_java_interface_method2 (interface, method);
8916       if (found)
8917         {
8918           char *t;
8919           tree saved_found_wfl = DECL_NAME (found);
8920           reset_method_name (found);
8921           t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8922           parse_error_context 
8923             (method_wfl,
8924              "Method `%s' was defined with return type `%s' in class `%s'",
8925              lang_printable_name (found, 0), t,
8926              IDENTIFIER_POINTER 
8927                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8928           free (t);
8929           DECL_NAME (found) = saved_found_wfl;
8930           continue;
8931         }
8932     }
8933
8934   /* 4- Inherited methods can't differ by their returned types */
8935   if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
8936     return;
8937   n = TREE_VEC_LENGTH (basetype_vec);
8938   for (i = 0; i < n; i++)
8939     {
8940       tree sub_interface_method, sub_interface;
8941       tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
8942       if (!vec_elt)
8943         continue;
8944       sub_interface = BINFO_TYPE (vec_elt);
8945       for (sub_interface_method = TYPE_METHODS (sub_interface); 
8946            sub_interface_method;
8947            sub_interface_method = TREE_CHAIN (sub_interface_method))
8948         {
8949           found = lookup_java_interface_method2 (interface, 
8950                                                  sub_interface_method);
8951           if (found && (found != sub_interface_method))
8952             {
8953               tree saved_found_wfl = DECL_NAME (found);
8954               reset_method_name (found);
8955               parse_error_context 
8956                 (lookup_cl (sub_interface_method),
8957                  "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
8958                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
8959                  lang_printable_name (found, 0),
8960                  IDENTIFIER_POINTER 
8961                    (DECL_NAME (TYPE_NAME 
8962                                (DECL_CONTEXT (sub_interface_method)))),
8963                  IDENTIFIER_POINTER 
8964                    (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8965               DECL_NAME (found) = saved_found_wfl;
8966             }
8967         }
8968     }
8969 }
8970
8971 /* Lookup methods in interfaces using their name and partial
8972    signature. Return a matching method only if their types differ.  */
8973
8974 static tree
8975 lookup_java_interface_method2 (class, method_decl)
8976      tree class, method_decl;
8977 {
8978   int i, n;
8979   tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
8980
8981   if (!basetype_vec)
8982     return NULL_TREE;
8983
8984   n = TREE_VEC_LENGTH (basetype_vec);
8985   for (i = 0; i < n; i++)
8986     {
8987       tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
8988       if ((BINFO_TYPE (vec_elt) != object_type_node)
8989           && (to_return = 
8990               lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
8991         return to_return;
8992     }
8993   for (i = 0; i < n; i++)
8994     {
8995       to_return = lookup_java_interface_method2 
8996         (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
8997       if (to_return)
8998         return to_return;
8999     }
9000
9001   return NULL_TREE;
9002 }
9003
9004 /* Lookup method using their name and partial signature. Return a
9005    matching method only if their types differ.  */
9006
9007 static tree
9008 lookup_java_method2 (clas, method_decl, do_interface)
9009      tree clas, method_decl;
9010      int do_interface;
9011 {
9012   tree method, method_signature, method_name, method_type, name;
9013
9014   method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
9015   name = DECL_NAME (method_decl);
9016   method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ? 
9017                  EXPR_WFL_NODE (name) : name);
9018   method_type = TREE_TYPE (TREE_TYPE (method_decl));
9019
9020   while (clas != NULL_TREE)
9021     {
9022       for (method = TYPE_METHODS (clas);
9023            method != NULL_TREE;  method = TREE_CHAIN (method))
9024         {
9025           tree method_sig = build_java_argument_signature (TREE_TYPE (method));
9026           tree name = DECL_NAME (method);
9027           if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
9028                EXPR_WFL_NODE (name) : name) == method_name
9029               && method_sig == method_signature 
9030               && TREE_TYPE (TREE_TYPE (method)) != method_type)
9031             return method;
9032         }
9033       clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
9034     }
9035   return NULL_TREE;
9036 }
9037
9038 /* Return the line that matches DECL line number, and try its best to
9039    position the column number. Used during error reports.  */
9040
9041 static tree
9042 lookup_cl (decl)
9043      tree decl;
9044 {
9045   static tree cl = NULL_TREE;
9046   char *line, *found;
9047   
9048   if (!decl)
9049     return NULL_TREE;
9050
9051   if (cl == NULL_TREE)
9052     cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
9053
9054   EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
9055   EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
9056
9057   line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
9058                             EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
9059
9060   found = strstr ((const char *)line, 
9061                   (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
9062   if (found)
9063     EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line);
9064
9065   return cl;
9066 }
9067
9068 /* Look for a simple name in the single-type import list */
9069
9070 static tree
9071 find_name_in_single_imports (name)
9072      tree name;
9073 {
9074   tree node;
9075
9076   for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
9077     if (TREE_VALUE (node) == name)
9078       return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
9079
9080   return NULL_TREE;
9081 }
9082
9083 /* Process all single-type import. */
9084
9085 static int
9086 process_imports ()
9087 {
9088   tree import;
9089   int error_found;
9090
9091   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9092     {
9093       tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
9094
9095       /* Don't load twice something already defined. */
9096       if (IDENTIFIER_CLASS_VALUE (to_be_found))
9097         continue;
9098       QUALIFIED_P (to_be_found) = 1;
9099       load_class (to_be_found, 0);
9100       error_found =
9101         check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
9102       if (!IDENTIFIER_CLASS_VALUE (to_be_found))
9103         {
9104           parse_error_context (TREE_PURPOSE (import),
9105                                "Class or interface `%s' not found in import",
9106                                IDENTIFIER_POINTER (to_be_found));
9107           return 1;
9108         }
9109       if (error_found)
9110         return 1;
9111     }
9112   return 0;
9113 }
9114
9115 /* Possibly find and mark a class imported by a single-type import
9116    statement.  */
9117
9118 static void
9119 find_in_imports (class_type)
9120      tree class_type;
9121 {
9122   tree import;
9123
9124   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9125     if (TREE_VALUE (import) == TYPE_NAME (class_type))
9126       {
9127         TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
9128         QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9129       }
9130 }
9131
9132 static int
9133 note_possible_classname (name, len)
9134      const char *name;
9135      int len;
9136 {
9137   tree node;
9138   if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
9139     len = len - 5;
9140   else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
9141     len = len - 6;
9142   else
9143     return 0;
9144   node = ident_subst (name, len, "", '/', '.', "");
9145   IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
9146   QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
9147   return 1;
9148 }
9149
9150 /* Read a import directory, gathering potential match for further type
9151    references. Indifferently reads a filesystem or a ZIP archive
9152    directory.  */
9153
9154 static void
9155 read_import_dir (wfl)
9156      tree wfl;
9157 {
9158   tree package_id = EXPR_WFL_NODE (wfl);
9159   const char *package_name = IDENTIFIER_POINTER (package_id);
9160   int package_length = IDENTIFIER_LENGTH (package_id);
9161   DIR *dirp = NULL;
9162   JCF *saved_jcf = current_jcf;
9163
9164   int found = 0;
9165   int k;
9166   void *entry;
9167   struct buffer filename[1];
9168
9169
9170   if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
9171     return;
9172   IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
9173
9174   BUFFER_INIT (filename);
9175   buffer_grow (filename, package_length + 100);
9176
9177   for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
9178     {
9179       const char *entry_name = jcf_path_name (entry);
9180       int entry_length = strlen (entry_name);
9181       if (jcf_path_is_zipfile (entry))
9182         {
9183           ZipFile *zipf;
9184           buffer_grow (filename, entry_length);
9185           memcpy (filename->data, entry_name, entry_length - 1);
9186           filename->data[entry_length-1] = '\0';
9187           zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
9188           if (zipf == NULL)
9189             error ("malformed .zip archive in CLASSPATH: %s", entry_name);
9190           else
9191             {
9192               ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
9193               BUFFER_RESET (filename);
9194               for (k = 0; k < package_length; k++)
9195                 {
9196                   char ch = package_name[k];
9197                   *filename->ptr++ = ch == '.' ? '/' : ch;
9198                 }
9199               *filename->ptr++ = '/';
9200
9201               for (k = 0; k < zipf->count;  k++, zipd = ZIPDIR_NEXT (zipd))
9202                 {
9203                   const char *current_entry = ZIPDIR_FILENAME (zipd);
9204                   int current_entry_len = zipd->filename_length;
9205
9206                   if (current_entry_len >= BUFFER_LENGTH (filename)
9207                       && strncmp (filename->data, current_entry, 
9208                                   BUFFER_LENGTH (filename)) != 0)
9209                     continue;
9210                   found |= note_possible_classname (current_entry,
9211                                                     current_entry_len);
9212                 }
9213             }
9214         }
9215       else
9216         {
9217           BUFFER_RESET (filename);
9218           buffer_grow (filename, entry_length + package_length + 4);
9219           strcpy (filename->data, entry_name);
9220           filename->ptr = filename->data + entry_length;
9221           for (k = 0; k < package_length; k++)
9222             {
9223               char ch = package_name[k];
9224               *filename->ptr++ = ch == '.' ? '/' : ch;
9225             }
9226           *filename->ptr = '\0';
9227
9228           dirp = opendir (filename->data);
9229           if (dirp == NULL)
9230             continue;
9231           *filename->ptr++ = '/';
9232           for (;;)
9233             {
9234               int len; 
9235               const char *d_name;
9236               struct dirent *direntp = readdir (dirp);
9237               if (!direntp)
9238                 break;
9239               d_name = direntp->d_name;
9240               len = strlen (direntp->d_name);
9241               buffer_grow (filename, len+1);
9242               strcpy (filename->ptr, d_name);
9243               found |= note_possible_classname (filename->data + entry_length,
9244                                                 package_length+len+1);
9245             }
9246           if (dirp)
9247             closedir (dirp);
9248         }
9249     }
9250
9251   free (filename->data);
9252
9253   /* Here we should have a unified way of retrieving an entry, to be
9254      indexed. */
9255   if (!found)
9256     {
9257       static int first = 1;
9258       if (first)
9259         {
9260           error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives.", package_name);
9261           java_error_count++;
9262           first = 0;
9263         }
9264       else
9265         parse_error_context (wfl, "Package `%s' not found in import",
9266                              package_name);
9267       current_jcf = saved_jcf;
9268       return;
9269     }
9270   current_jcf = saved_jcf;
9271 }
9272
9273 /* Possibly find a type in the import on demands specified
9274    types. Returns 1 if an error occured, 0 otherwise. Run throught the
9275    entire list, to detected potential double definitions.  */
9276                  
9277 static int
9278 find_in_imports_on_demand (class_type)
9279      tree class_type;
9280 {
9281   tree node, import, node_to_use = NULL_TREE;
9282   int seen_once = -1;
9283   tree cl = NULL_TREE;
9284
9285   for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
9286     {
9287       const char *id_name;
9288       obstack_grow (&temporary_obstack, 
9289                     IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
9290                     IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9291       obstack_1grow (&temporary_obstack, '.');
9292       obstack_grow0 (&temporary_obstack, 
9293                      IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9294                      IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
9295       id_name = obstack_finish (&temporary_obstack);
9296               
9297       node = maybe_get_identifier (id_name);
9298       if (node && IS_A_CLASSFILE_NAME (node))
9299         {
9300           if (seen_once < 0)
9301             {
9302               cl = TREE_PURPOSE (import);
9303               seen_once = 1;
9304               node_to_use = node;
9305             }
9306           else
9307             {
9308               seen_once++;
9309               parse_error_context 
9310                 (import, "Type `%s' also potentially defined in package `%s'",
9311                  IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9312                  IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9313             }
9314         }
9315     }
9316
9317   if (seen_once == 1)
9318     {
9319       /* Setup lineno so that it refers to the line of the import (in
9320          case we parse a class file and encounter errors */
9321       tree decl;
9322       int saved_lineno = lineno;
9323       lineno = EXPR_WFL_LINENO (cl);
9324       TYPE_NAME (class_type) = node_to_use;
9325       QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9326       decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
9327       /* If there is no DECL set for the class or if the class isn't
9328          loaded and not seen in source yet, the load */
9329       if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
9330                     && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
9331         load_class (node_to_use, 0);
9332       lineno = saved_lineno;
9333       return check_pkg_class_access (TYPE_NAME (class_type), cl);
9334     }
9335   else
9336     return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
9337 }
9338
9339 /* Add package NAME to the list of package encountered so far. To
9340    speed up class lookup in do_resolve_class, we make sure a
9341    particular package is added only once.  */
9342
9343 static void
9344 register_package (name)
9345      tree name;
9346 {
9347   static struct hash_table _pht, *pht = NULL;
9348
9349   if (!pht)
9350     {
9351       hash_table_init (&_pht, hash_newfunc, 
9352                        java_hash_hash_tree_node, java_hash_compare_tree_node);
9353       pht = &_pht;
9354     }
9355   
9356   if (!hash_lookup (pht, (const hash_table_key) name, FALSE, NULL))
9357     {
9358       package_list = chainon (package_list, build_tree_list (name, NULL));
9359       hash_lookup (pht, (const hash_table_key) name, TRUE, NULL);
9360     }
9361 }
9362
9363 static tree
9364 resolve_package (pkg, next)
9365      tree pkg, *next;
9366 {
9367   tree current, acc;
9368   tree type_name = NULL_TREE;
9369   const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
9370
9371   /* The trick is to determine when the package name stops and were
9372      the name of something contained in the package starts. Then we
9373      return a fully qualified name of what we want to get. */
9374
9375   /* Do a quick search on well known package names */
9376   if (!strncmp (name, "java.lang.reflect", 17))
9377     {
9378       *next = 
9379         TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
9380       type_name = lookup_package_type (name, 17);
9381     }
9382   else if (!strncmp (name, "java.lang", 9))
9383     {
9384       *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
9385       type_name = lookup_package_type (name, 9);
9386     }
9387
9388   /* If we found something here, return */
9389   if (type_name)
9390     return type_name; 
9391
9392   *next = EXPR_WFL_QUALIFICATION (pkg);
9393
9394   /* Try the current package. */
9395   if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),  
9396                                  IDENTIFIER_LENGTH (ctxp->package)))
9397     {
9398       type_name = 
9399         lookup_package_type_and_set_next (name, 
9400                                           IDENTIFIER_LENGTH (ctxp->package), 
9401                                           next );
9402       if (type_name)
9403         return type_name;
9404     }
9405
9406   /* Search in imported package */
9407   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
9408     {
9409       tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
9410       int len = IDENTIFIER_LENGTH (current_pkg_name);
9411       if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
9412         {
9413           tree left, dummy;
9414           
9415           breakdown_qualified (&left, &dummy, current_pkg_name);
9416           len = IDENTIFIER_LENGTH (left);
9417           type_name = lookup_package_type_and_set_next (name, len, next);
9418           if (type_name)
9419             break;
9420         }
9421     }
9422
9423   /* Try to progressively construct a type name */
9424   if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
9425     for (acc = NULL_TREE, current = EXPR_WFL_QUALIFICATION (pkg); 
9426          current; current = TREE_CHAIN (current))
9427       {
9428         acc = merge_qualified_name (acc, EXPR_WFL_NODE (QUAL_WFL (current)));
9429         if ((type_name = resolve_no_layout (acc, NULL_TREE)))
9430           {
9431             type_name = acc;
9432             /* resolve_package should be used in a loop, hence we
9433                point at this one to naturally process the next one at
9434                the next iteration. */
9435             *next = current;
9436             break;
9437           }
9438       }
9439   return type_name;
9440 }
9441
9442 static tree
9443 lookup_package_type_and_set_next (name, len, next)
9444      const char *name;
9445      int len;
9446      tree *next;
9447 {
9448   const char *ptr;
9449   tree type_name = lookup_package_type (name, len);
9450
9451   if (!type_name)
9452     return NULL;
9453   
9454   ptr = IDENTIFIER_POINTER (type_name);
9455   while (ptr && (ptr = strchr (ptr, '.'))) 
9456     {
9457       *next = TREE_CHAIN (*next);
9458       ptr++;
9459     }
9460   return type_name;
9461 }
9462
9463 static tree
9464 lookup_package_type (name, from)
9465      const char *name;
9466      int from;
9467 {
9468   char subname [128];
9469   const char *sub = &name[from+1];
9470   while (*sub != '.' && *sub)
9471     sub++;
9472   strncpy (subname, name, sub-name);
9473   subname [sub-name] = '\0';
9474   return get_identifier (subname);
9475 }
9476
9477 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
9478    access violations were found, 1 otherwise.  */
9479
9480 static int
9481 check_pkg_class_access (class_name, cl)
9482      tree class_name;
9483      tree cl;
9484 {
9485   tree type;
9486
9487   if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
9488     return 0;
9489
9490   if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
9491     return 0;
9492
9493   if (!CLASS_PUBLIC (TYPE_NAME (type)))
9494     {
9495       /* Access to a private class within the same package is
9496          allowed. */
9497       tree l, r;
9498       breakdown_qualified (&l, &r, class_name);
9499       if (l == ctxp->package)
9500         return 0;
9501
9502       parse_error_context 
9503         (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
9504          (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
9505          IDENTIFIER_POINTER (class_name));
9506       return 1;
9507     }
9508   return 0;
9509 }
9510
9511 /* Local variable declaration. */
9512
9513 static void
9514 declare_local_variables (modifier, type, vlist)
9515      int modifier;
9516      tree type;
9517      tree vlist;
9518 {
9519   tree decl, current, saved_type;
9520   tree type_wfl = NULL_TREE;
9521   int must_chain = 0;
9522   int final_p = 0;
9523
9524   /* Push a new block if statements were seen between the last time we
9525      pushed a block and now. Keep a cound of block to close */
9526   if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
9527     {
9528       tree body = GET_CURRENT_BLOCK (current_function_decl);
9529       tree b = enter_block ();
9530       BLOCK_EXPR_ORIGIN (b) = body;
9531     }
9532
9533   if (modifier)
9534     {
9535       int i;
9536       for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
9537       if (modifier == ACC_FINAL)
9538         final_p = 1;
9539       else 
9540         {
9541           parse_error_context 
9542             (ctxp->modifier_ctx [i], 
9543              "Only `final' is allowed as a local variables modifier");
9544           return;
9545         }
9546     }
9547
9548   /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
9549      hold the TYPE value if a new incomplete has to be created (as
9550      opposed to being found already existing and reused). */
9551   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
9552
9553   /* If TYPE is fully resolved and we don't have a reference, make one */
9554   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9555
9556   /* Go through all the declared variables */
9557   for (current = vlist, saved_type = type; current;
9558        current = TREE_CHAIN (current), type = saved_type)
9559     {
9560       tree other, real_type;
9561       tree wfl  = TREE_PURPOSE (current);
9562       tree name = EXPR_WFL_NODE (wfl);
9563       tree init = TREE_VALUE (current);
9564
9565       /* Process NAME, as it may specify extra dimension(s) for it */
9566       type = build_array_from_name (type, type_wfl, name, &name);
9567
9568       /* Variable redefinition check */
9569       if ((other = lookup_name_in_blocks (name)))
9570         {
9571           variable_redefinition_error (wfl, name, TREE_TYPE (other),
9572                                        DECL_SOURCE_LINE (other));
9573           continue;
9574         }
9575
9576       /* Type adjustment. We may have just readjusted TYPE because
9577          the variable specified more dimensions. Make sure we have
9578          a reference if we can and don't have one already. */
9579       PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9580
9581       real_type = GET_REAL_TYPE (type);
9582       /* Never layout this decl. This will be done when its scope
9583          will be entered */
9584       decl = build_decl (VAR_DECL, name, real_type);
9585       LOCAL_FINAL (decl) = final_p;
9586       BLOCK_CHAIN_DECL (decl);
9587       
9588       /* If doing xreferencing, replace the line number with the WFL
9589          compound value */
9590       if (flag_emit_xref)
9591         DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
9592       
9593       /* Don't try to use an INIT statement when an error was found */
9594       if (init && java_error_count)
9595         init = NULL_TREE;
9596       
9597       /* Add the initialization function to the current function's code */
9598       if (init)
9599         {
9600           /* Name might have been readjusted */
9601           EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
9602           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
9603           java_method_add_stmt (current_function_decl,
9604                                 build_debugable_stmt (EXPR_WFL_LINECOL (init),
9605                                                       init));
9606         }
9607     
9608       /* Setup dependency the type of the decl */
9609       if (must_chain)
9610         {
9611           jdep *dep;
9612           register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
9613           dep = CLASSD_LAST (ctxp->classd_list);
9614           JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
9615         }
9616     }
9617   SOURCE_FRONTEND_DEBUG (("Defined locals"));
9618 }
9619
9620 /* Called during parsing. Build decls from argument list.  */
9621
9622 static void
9623 source_start_java_method (fndecl)
9624      tree fndecl;
9625 {
9626   tree tem;
9627   tree parm_decl;
9628   int i;
9629
9630   if (!fndecl)
9631     return;
9632
9633   current_function_decl = fndecl;
9634
9635   /* New scope for the function */
9636   enter_block ();
9637   for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
9638        tem != end_params_node; tem = TREE_CHAIN (tem), i++)
9639     {
9640       tree type = TREE_VALUE (tem);
9641       tree name = TREE_PURPOSE (tem);
9642       
9643       /* If type is incomplete. Create an incomplete decl and ask for
9644          the decl to be patched later */
9645       if (INCOMPLETE_TYPE_P (type))
9646         {
9647           jdep *jdep;
9648           tree real_type = GET_REAL_TYPE (type);
9649           parm_decl = build_decl (PARM_DECL, name, real_type);
9650           type = obtain_incomplete_type (type);
9651           register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
9652           jdep = CLASSD_LAST (ctxp->classd_list);
9653           JDEP_MISC (jdep) = name;
9654           JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
9655         }
9656       else
9657         parm_decl = build_decl (PARM_DECL, name, type);
9658
9659       /* Remember if a local variable was declared final (via its
9660          TREE_LIST of type/name.) Set LOCAL_FINAL accordingly. */
9661       if (ARG_FINAL_P (tem))
9662         LOCAL_FINAL (parm_decl) = 1;
9663
9664       BLOCK_CHAIN_DECL (parm_decl);
9665     }
9666   tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9667   BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
9668     nreverse (tem);
9669   DECL_ARG_SLOT_COUNT (current_function_decl) = i;
9670   DECL_MAX_LOCALS (current_function_decl) = i;
9671 }
9672
9673 /* Called during parsing. Creates an artificial method declaration.  */
9674
9675 static tree
9676 create_artificial_method (class, flags, type, name, args)
9677      tree class;
9678      int flags;
9679      tree type, name, args;
9680 {
9681   tree mdecl;
9682
9683   java_parser_context_save_global ();
9684   lineno = 0;                                                               
9685   mdecl = make_node (FUNCTION_TYPE);                                
9686   TREE_TYPE (mdecl) = type;
9687   TYPE_ARG_TYPES (mdecl) = args;
9688   mdecl = add_method (class, flags, name, build_java_signature (mdecl)); 
9689   java_parser_context_restore_global ();
9690   DECL_ARTIFICIAL (mdecl) = 1;                                      
9691   return mdecl;
9692 }
9693
9694 /* Starts the body if an artifical method.  */
9695
9696 static void
9697 start_artificial_method_body (mdecl)
9698      tree mdecl;
9699 {
9700   DECL_SOURCE_LINE (mdecl) = 1;
9701   DECL_SOURCE_LINE_MERGE (mdecl, 1);
9702   source_start_java_method (mdecl);
9703   enter_block ();
9704 }
9705
9706 static void
9707 end_artificial_method_body (mdecl)
9708      tree mdecl;
9709 {
9710   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
9711   exit_block ();
9712 }
9713
9714 /* Called during expansion. Push decls formerly built from argument
9715    list so they're usable during expansion. */
9716
9717 static void
9718 expand_start_java_method (fndecl)
9719      tree fndecl;
9720 {
9721   tree tem, *ptr;
9722
9723   current_function_decl = fndecl;
9724
9725   if (! quiet_flag)
9726     fprintf (stderr, " [%s.", lang_printable_name (DECL_CONTEXT (fndecl), 0));
9727   announce_function (fndecl);
9728   if (! quiet_flag)
9729     fprintf (stderr, "]");
9730
9731   pushlevel (1);                /* Prepare for a parameter push */
9732   ptr = &DECL_ARGUMENTS (fndecl);
9733   tem  = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9734   while (tem)
9735     {
9736       tree next = TREE_CHAIN (tem);
9737       tree type = TREE_TYPE (tem);
9738       if (PROMOTE_PROTOTYPES
9739           && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
9740           && INTEGRAL_TYPE_P (type))
9741         type = integer_type_node;
9742       DECL_ARG_TYPE (tem) = type;
9743       layout_decl (tem, 0);
9744       pushdecl (tem);
9745       *ptr = tem;
9746       ptr = &TREE_CHAIN (tem);
9747       tem = next;
9748     }
9749   *ptr = NULL_TREE;
9750   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9751   lineno = DECL_SOURCE_LINE_FIRST (fndecl);
9752 }
9753
9754 /* Terminate a function and expand its body.  */
9755
9756 static void
9757 source_end_java_method ()
9758 {
9759   tree fndecl = current_function_decl;
9760   int flag_asynchronous_exceptions = asynchronous_exceptions;
9761
9762   if (!fndecl)
9763     return;
9764
9765   java_parser_context_save_global ();
9766   lineno = ctxp->last_ccb_indent1;
9767
9768   /* Set EH language codes */
9769   java_set_exception_lang_code ();
9770
9771   /* Turn function bodies with only a NOP expr null, so they don't get
9772      generated at all and we won't get warnings when using the -W
9773      -Wall flags. */
9774   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
9775     BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
9776
9777   /* Generate function's code */
9778   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
9779       && ! flag_emit_class_files
9780       && ! flag_emit_xref)
9781     expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
9782
9783   /* pop out of its parameters */
9784   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9785   poplevel (1, 0, 1);
9786   BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
9787
9788   /* Generate rtl for function exit.  */
9789   if (! flag_emit_class_files && ! flag_emit_xref)
9790     {
9791       lineno = DECL_SOURCE_LINE_LAST (fndecl);
9792       /* Emit catch-finally clauses */
9793       emit_handlers ();
9794       expand_function_end (input_filename, lineno, 0);
9795
9796       /* FIXME: If the current method contains any exception handlers,
9797          force asynchronous_exceptions: this is necessary because signal
9798          handlers in libjava may throw exceptions.  This is far from being
9799          a perfect solution, but it's better than doing nothing at all.*/
9800       if (catch_clauses)
9801         asynchronous_exceptions = 1;
9802
9803       /* Run the optimizers and output assembler code for this function. */
9804       rest_of_compilation (fndecl);
9805     }
9806
9807   current_function_decl = NULL_TREE;
9808   permanent_allocation (1);
9809   java_parser_context_restore_global ();
9810   asynchronous_exceptions = flag_asynchronous_exceptions;
9811 }
9812
9813 /* Record EXPR in the current function block. Complements compound
9814    expression second operand if necessary.  */
9815
9816 tree
9817 java_method_add_stmt (fndecl, expr)
9818      tree fndecl, expr;
9819 {
9820   if (!GET_CURRENT_BLOCK (fndecl))
9821     return NULL_TREE;
9822   return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
9823 }
9824
9825 static tree
9826 add_stmt_to_block (b, type, stmt)
9827      tree b, type, stmt;
9828 {
9829   tree body = BLOCK_EXPR_BODY (b), c;
9830   
9831   if (java_error_count)
9832     return body;
9833     
9834   if ((c = add_stmt_to_compound (body, type, stmt)) == body)
9835     return body;
9836
9837   BLOCK_EXPR_BODY (b) = c;
9838   TREE_SIDE_EFFECTS (c) = 1;
9839   return c;
9840 }
9841
9842 /* Add STMT to EXISTING if possible, otherwise create a new
9843    COMPOUND_EXPR and add STMT to it. */
9844
9845 static tree
9846 add_stmt_to_compound (existing, type, stmt)
9847      tree existing, type, stmt;
9848 {
9849   if (existing)
9850     return build (COMPOUND_EXPR, type, existing, stmt);
9851   else
9852     return stmt;
9853 }
9854
9855 /* Hold THIS for the scope of the current public method decl.  */
9856 static tree current_this;
9857
9858 void java_layout_seen_class_methods ()
9859 {
9860   tree previous_list = all_class_list;
9861   tree end = NULL_TREE;
9862   tree current;
9863
9864   while (1)
9865     {
9866       for (current = previous_list; 
9867            current != end; current = TREE_CHAIN (current))
9868         layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
9869       
9870       if (previous_list != all_class_list)
9871         {
9872           end = previous_list;
9873           previous_list = all_class_list;
9874         }
9875       else
9876         break;
9877     }
9878 }
9879
9880 void
9881 java_reorder_fields ()
9882 {
9883   static tree stop_reordering = NULL_TREE;
9884
9885   tree current;
9886   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9887     {
9888       current_class = TREE_TYPE (TREE_VALUE (current));
9889
9890       if (current_class == stop_reordering)
9891         break;
9892
9893       /* Reverse the fields, but leave the dummy field in front.
9894          Fields are already ordered for Object and Class */
9895       if (TYPE_FIELDS (current_class) && current_class != object_type_node
9896           && current_class != class_type_node)
9897       {
9898         /* If the dummy field is there, reverse the right fields and
9899            just layout the type for proper fields offset */
9900         if (!DECL_NAME (TYPE_FIELDS (current_class)))
9901           {
9902             tree fields = TYPE_FIELDS (current_class);
9903             TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
9904             TYPE_SIZE (current_class) = NULL_TREE;
9905           }
9906         /* We don't have a dummy field, we need to layout the class,
9907            after having reversed the fields */
9908         else
9909           {
9910             TYPE_FIELDS (current_class) = 
9911               nreverse (TYPE_FIELDS (current_class));
9912             TYPE_SIZE (current_class) = NULL_TREE;
9913           }
9914       }
9915     }
9916   stop_reordering = TREE_TYPE (TREE_VALUE (ctxp->gclass_list));
9917 }
9918
9919 /* Layout the methods of all classes loaded in one way on an
9920    other. Check methods of source parsed classes. Then reorder the
9921    fields and layout the classes or the type of all source parsed
9922    classes */
9923
9924 void
9925 java_layout_classes ()
9926 {
9927   tree current;
9928   int save_error_count = java_error_count;
9929
9930   /* Layout the methods of all classes seen so far */
9931   java_layout_seen_class_methods ();
9932   java_parse_abort_on_error ();
9933   all_class_list = NULL_TREE;
9934
9935   /* Then check the methods of all parsed classes */
9936   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9937     if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
9938       CHECK_METHODS (TREE_VALUE (current));
9939   java_parse_abort_on_error ();
9940
9941   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9942     {
9943       current_class = TREE_TYPE (TREE_VALUE (current));
9944       layout_class (current_class);
9945
9946       /* From now on, the class is considered completely loaded */
9947       CLASS_LOADED_P (current_class) = 1;
9948
9949       /* Error reported by the caller */
9950       if (java_error_count)
9951         return;
9952     }
9953
9954   /* We might have reloaded classes durign the process of laying out
9955      classes for code generation. We must layout the methods of those
9956      late additions, as constructor checks might use them */
9957   java_layout_seen_class_methods ();
9958   java_parse_abort_on_error ();
9959 }
9960
9961 /* Expand methods in the current set of classes rememebered for
9962    generation.  */
9963
9964 static void
9965 java_complete_expand_classes ()
9966 {
9967   tree current;
9968
9969   do_not_fold = flag_emit_xref;
9970
9971   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
9972     if (!INNER_CLASS_DECL_P (current))
9973       java_complete_expand_class (current);
9974 }
9975
9976 /* Expand the methods found in OUTER, starting first by OUTER's inner
9977    classes, if any.  */
9978
9979 static void
9980 java_complete_expand_class (outer)
9981      tree outer;
9982 {
9983   tree inner_list;
9984
9985   set_nested_class_simple_name_value (outer, 1); /* Set */
9986
9987   /* We need to go after all inner classes and start expanding them,
9988      starting with most nested ones. We have to do that because nested
9989      classes might add functions to outer classes */
9990
9991   for (inner_list = DECL_INNER_CLASS_LIST (outer);
9992        inner_list; inner_list = TREE_CHAIN (inner_list))
9993     java_complete_expand_class (TREE_PURPOSE (inner_list));
9994
9995   java_complete_expand_methods (outer);
9996   set_nested_class_simple_name_value (outer, 0); /* Reset */
9997 }
9998
9999 /* Expand methods registered in CLASS_DECL. The general idea is that
10000    we expand regular methods first. This allows us get an estimate on
10001    how outer context local alias fields are really used so we can add
10002    to the constructor just enough code to initialize them properly (it
10003    also lets us generate $finit$ correctly.) Then we expand the
10004    constructors and then <clinit>.  */
10005
10006 static void
10007 java_complete_expand_methods (class_decl)
10008      tree class_decl;
10009 {
10010   tree clinit, finit, decl, first_decl;
10011
10012   current_class = TREE_TYPE (class_decl);
10013
10014   /* Initialize a new constant pool */
10015   init_outgoing_cpool ();
10016
10017   /* Pre-expand <clinit> to figure whether we really need it or
10018      not. If we do need it, we pre-expand the static fields so they're
10019      ready to be used somewhere else. <clinit> will be fully expanded
10020      after we processed the constructors. */
10021   first_decl = TYPE_METHODS (current_class);
10022   clinit = maybe_generate_pre_expand_clinit (current_class);
10023
10024   /* Then generate $finit$ (if we need to) because constructor will
10025    try to use it.*/
10026   if (TYPE_FINIT_STMT_LIST (current_class))
10027     {
10028       finit = generate_finit (current_class);
10029       java_complete_expand_method (finit);
10030     }
10031
10032   /* Now do the constructors */
10033   for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
10034     {
10035       int no_body;
10036
10037       if (!DECL_CONSTRUCTOR_P (decl))
10038         continue;
10039       
10040       no_body = !DECL_FUNCTION_BODY (decl);
10041       /* Don't generate debug info on line zero when expanding a
10042          generated constructor. */
10043       if (no_body)
10044         restore_line_number_status (1);
10045
10046       java_complete_expand_method (decl);
10047       
10048       if (no_body)
10049         restore_line_number_status (0);
10050     }
10051
10052   /* First, do the ordinary methods. */
10053   for (decl = first_decl; decl; decl = TREE_CHAIN (decl))
10054     {
10055       /* Skip abstract or native methods -- but do handle native
10056          methods when generating JNI stubs.  */
10057       if (METHOD_ABSTRACT (decl)
10058           || (! flag_jni && METHOD_NATIVE (decl))
10059           || DECL_CONSTRUCTOR_P (decl) || DECL_CLINIT_P (decl))
10060         continue;
10061
10062       if (METHOD_NATIVE (decl))
10063         {
10064           tree body = build_jni_stub (decl);
10065           BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl)) = body;
10066         }
10067
10068       java_complete_expand_method (decl);
10069     }
10070
10071   /* If there is indeed a <clinit>, fully expand it now */
10072   if (clinit)
10073     {
10074       /* Prevent the use of `this' inside <clinit> */
10075       ctxp->explicit_constructor_p = 1;
10076       java_complete_expand_method (clinit);
10077       ctxp->explicit_constructor_p = 0;
10078     }
10079   
10080   /* We might have generated a class$ that we now want to expand */
10081   if (TYPE_DOT_CLASS (current_class))
10082     java_complete_expand_method (TYPE_DOT_CLASS (current_class));
10083
10084   /* Now verify constructor circularity (stop after the first one we
10085      prove wrong.) */
10086   if (!CLASS_INTERFACE (class_decl))
10087     for (decl = TYPE_METHODS (current_class); decl; decl = TREE_CHAIN (decl))
10088       if (DECL_CONSTRUCTOR_P (decl) 
10089           && verify_constructor_circularity (decl, decl))
10090         break;
10091
10092   /* Save the constant pool. We'll need to restore it later. */
10093   TYPE_CPOOL (current_class) = outgoing_cpool;
10094 }
10095
10096 /* Hold a list of catch clauses list. The first element of this list is
10097    the list of the catch clauses of the currently analysed try block. */
10098 static tree currently_caught_type_list;
10099
10100 /* Attempt to create <clinit>. Pre-expand static fields so they can be
10101    safely used in some other methods/constructors.  */
10102
10103 static tree
10104 maybe_generate_pre_expand_clinit (class_type)
10105      tree class_type;
10106 {
10107   tree current, mdecl;
10108
10109   if (!TYPE_CLINIT_STMT_LIST (class_type))
10110     return NULL_TREE;
10111
10112   /* Go through all static fields and pre expand them */
10113   for (current = TYPE_FIELDS (class_type); current; 
10114        current = TREE_CHAIN (current))
10115     if (FIELD_STATIC (current))
10116       build_field_ref (NULL_TREE, class_type, DECL_NAME (current));
10117
10118   /* Then build the <clinit> method */
10119   mdecl = create_artificial_method (class_type, ACC_STATIC, void_type_node,
10120                                     clinit_identifier_node, end_params_node);
10121   layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
10122                        mdecl, NULL_TREE);
10123   start_artificial_method_body (mdecl);
10124
10125   /* We process the list of assignment we produced as the result of
10126      the declaration of initialized static field and add them as
10127      statement to the <clinit> method. */
10128   for (current = TYPE_CLINIT_STMT_LIST (class_type); current;
10129        current = TREE_CHAIN (current))
10130     {
10131       tree stmt = current;
10132       /* We build the assignment expression that will initialize the
10133          field to its value. There are strict rules on static
10134          initializers (8.5). FIXME */
10135       if (TREE_CODE (stmt) != BLOCK)
10136         stmt = build_debugable_stmt (EXPR_WFL_LINECOL (stmt), stmt);
10137       java_method_add_stmt (mdecl, stmt);
10138     }
10139
10140   end_artificial_method_body (mdecl);
10141
10142   /* Now we want to place <clinit> as the last method (because we need
10143      it at least for interface so that it doesn't interfere with the
10144      dispatch table based lookup. */
10145   if (TREE_CHAIN (TYPE_METHODS (class_type)))
10146     {
10147       current = TREE_CHAIN (TYPE_METHODS (class_type));
10148       TYPE_METHODS (class_type) = current;
10149
10150       while (TREE_CHAIN (current))
10151         current = TREE_CHAIN (current);
10152
10153       TREE_CHAIN (current) = mdecl;
10154       TREE_CHAIN (mdecl) = NULL_TREE;
10155     }
10156
10157   return mdecl;
10158 }
10159
10160 /* See whether we could get rid of <clinit>. Criteria are: all static
10161    final fields have constant initial values and the body of <clinit>
10162    is empty. Return 1 if <clinit> was discarded, 0 otherwise. */
10163
10164 static int
10165 maybe_yank_clinit (mdecl)
10166      tree mdecl;
10167 {
10168   tree type, current;
10169   tree fbody, bbody;
10170   
10171   if (!DECL_CLINIT_P (mdecl))
10172     return 0;
10173   
10174   /* If the body isn't empty, then we keep <clinit> */
10175   fbody = DECL_FUNCTION_BODY (mdecl);
10176   if ((bbody = BLOCK_EXPR_BODY (fbody)))
10177     bbody = BLOCK_EXPR_BODY (bbody);
10178   if (bbody && bbody != empty_stmt_node)
10179     return 0;
10180   
10181   type = DECL_CONTEXT (mdecl);
10182   current = TYPE_FIELDS (type);
10183
10184   for (current = (current ? TREE_CHAIN (current) : current); 
10185        current; current = TREE_CHAIN (current))
10186     if (!(FIELD_STATIC (current) && FIELD_FINAL (current)
10187           && DECL_INITIAL (current) && TREE_CONSTANT (DECL_INITIAL (current))))
10188       break;
10189
10190   if (current)
10191     return 0;
10192
10193   /* Get rid of <clinit> in the class' list of methods */
10194   if (TYPE_METHODS (type) == mdecl)
10195     TYPE_METHODS (type) = TREE_CHAIN (mdecl);
10196   else
10197     for (current = TYPE_METHODS (type); current; 
10198          current = TREE_CHAIN (current))
10199       if (TREE_CHAIN (current) == mdecl)
10200         {
10201           TREE_CHAIN (current) = TREE_CHAIN (mdecl);
10202           break;
10203         }
10204
10205   return 1;
10206 }
10207
10208
10209 /* Complete and expand a method.  */
10210
10211 static void
10212 java_complete_expand_method (mdecl)
10213      tree mdecl;
10214 {
10215   int yank_clinit = 0;
10216
10217   current_function_decl = mdecl;
10218   /* Fix constructors before expanding them */
10219   if (DECL_CONSTRUCTOR_P (mdecl))
10220     fix_constructors (mdecl);
10221   
10222   /* Expand functions that have a body */
10223   if (DECL_FUNCTION_BODY (mdecl))
10224     {
10225       tree fbody = DECL_FUNCTION_BODY (mdecl);
10226       tree block_body = BLOCK_EXPR_BODY (fbody);
10227       tree exception_copy = NULL_TREE;
10228       expand_start_java_method (mdecl);
10229       build_result_decl (mdecl);
10230
10231       current_this 
10232         = (!METHOD_STATIC (mdecl) ? 
10233            BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
10234
10235       /* Purge the `throws' list of unchecked exceptions. If we're
10236          doing xref, save a copy of the list and re-install it
10237          later. */
10238       if (flag_emit_xref)
10239         exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
10240
10241       purge_unchecked_exceptions (mdecl);
10242
10243       /* Install exceptions thrown with `throws' */
10244       PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
10245
10246       if (block_body != NULL_TREE)
10247         {
10248           block_body = java_complete_tree (block_body);
10249
10250           if (! flag_emit_xref && ! METHOD_NATIVE (mdecl))
10251             check_for_initialization (block_body);
10252           ctxp->explicit_constructor_p = 0;
10253         }
10254
10255       BLOCK_EXPR_BODY (fbody) = block_body;
10256
10257       /* If we saw a return but couldn't evaluate it properly, we'll
10258          have an error_mark_node here. */
10259       if (block_body != error_mark_node
10260           && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
10261           && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
10262           && !flag_emit_xref)
10263         missing_return_error (current_function_decl);
10264
10265       /* Check wether we could just get rid of clinit, now the picture
10266          is complete. */
10267       if (!(yank_clinit = maybe_yank_clinit (mdecl)))
10268         complete_start_java_method (mdecl); 
10269       
10270       /* Don't go any further if we've found error(s) during the
10271          expansion */
10272       if (!java_error_count && !yank_clinit)
10273         source_end_java_method ();
10274       else
10275         {
10276           if (java_error_count)
10277             pushdecl_force_head (DECL_ARGUMENTS (mdecl));
10278           poplevel (1, 0, 1);
10279         }
10280
10281       /* Pop the exceptions and sanity check */
10282       POP_EXCEPTIONS();
10283       if (currently_caught_type_list)
10284         fatal ("Exception list non empty - java_complete_expand_method");
10285
10286       if (flag_emit_xref)
10287         DECL_FUNCTION_THROWS (mdecl) = exception_copy;
10288     }
10289 }
10290
10291 \f
10292
10293 /* This section of the code deals with accessing enclosing context
10294    fields either directly by using the relevant access to this$<n> or
10295    by invoking an access method crafted for that purpose.  */
10296
10297 /* Build the necessary access from an inner class to an outer
10298    class. This routine could be optimized to cache previous result
10299    (decl, current_class and returned access).  When an access method
10300    needs to be generated, it always takes the form of a read. It might
10301    be later turned into a write by calling outer_field_access_fix.  */
10302
10303 static tree
10304 build_outer_field_access (id, decl)
10305      tree id, decl;
10306 {
10307   tree access = NULL_TREE;
10308   tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
10309
10310   /* If decl's class is the direct outer class of the current_class,
10311      build the access as `this$<n>.<field>'. Not that we will break
10312      the `private' barrier if we're not emitting bytecodes. */
10313   if (ctx == DECL_CONTEXT (decl) 
10314       && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
10315     {
10316       tree thisn = build_current_thisn (current_class);
10317       access = make_qualified_primary (build_wfl_node (thisn), 
10318                                        id, EXPR_WFL_LINECOL (id));
10319     }
10320   /* Otherwise, generate access methods to outer this and access the
10321      field (either using an access method or by direct access.) */
10322   else
10323     {
10324       int lc = EXPR_WFL_LINECOL (id);
10325
10326       /* Now we chain the required number of calls to the access$0 to
10327          get a hold to the enclosing instance we need, and the we
10328          build the field access. */
10329       access = build_access_to_thisn (ctx, DECL_CONTEXT (decl), lc);
10330
10331       /* If the field is private and we're generating bytecode, then
10332          we generate an access method */
10333       if (FIELD_PRIVATE (decl) && flag_emit_class_files )
10334         {
10335           tree name = build_outer_field_access_methods (decl);
10336           access = build_outer_field_access_expr (lc, DECL_CONTEXT (decl),
10337                                                   name, access, NULL_TREE);
10338         }
10339       /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
10340          Once again we break the `private' access rule from a foreign
10341          class. */
10342       else
10343         access = make_qualified_primary (access, id, lc);
10344     }
10345   return resolve_expression_name (access, NULL);
10346 }
10347
10348 /* Return a non zero value if NODE describes an outer field inner
10349    access.  */
10350
10351 static int
10352 outer_field_access_p (type, decl)
10353     tree type, decl;
10354 {
10355   if (!INNER_CLASS_TYPE_P (type) 
10356       || TREE_CODE (decl) != FIELD_DECL
10357       || DECL_CONTEXT (decl) == type)
10358     return 0;
10359
10360   for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
10361        type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
10362     {
10363       if (type == DECL_CONTEXT (decl))
10364         return 1;
10365       if (!DECL_CONTEXT (TYPE_NAME (type)))
10366         break;
10367     }
10368
10369   return 0;
10370 }
10371
10372 /* Return a non zero value if NODE represents an outer field inner
10373    access that was been already expanded. As a side effect, it returns
10374    the name of the field being accessed and the argument passed to the
10375    access function, suitable for a regeneration of the access method
10376    call if necessary. */
10377
10378 static int
10379 outer_field_expanded_access_p (node, name, arg_type, arg)
10380     tree node, *name, *arg_type, *arg;
10381 {
10382   int identified = 0;
10383
10384   if (TREE_CODE (node) != CALL_EXPR)
10385     return 0;
10386
10387   /* Well, gcj generates slightly different tree nodes when compiling
10388      to native or bytecodes. It's the case for function calls. */
10389
10390   if (flag_emit_class_files 
10391       && TREE_CODE (node) == CALL_EXPR
10392       && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
10393     identified = 1;
10394   else if (!flag_emit_class_files)
10395     {
10396       node = TREE_OPERAND (node, 0);
10397       
10398       if (node && TREE_OPERAND (node, 0)
10399           && TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR)
10400         {
10401           node = TREE_OPERAND (node, 0);
10402           if (TREE_OPERAND (node, 0)
10403               && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
10404               && (OUTER_FIELD_ACCESS_IDENTIFIER_P 
10405                   (DECL_NAME (TREE_OPERAND (node, 0)))))
10406             identified = 1;
10407         }
10408     }
10409
10410   if (identified && name && arg_type && arg)
10411     {
10412       tree argument = TREE_OPERAND (node, 1);
10413       *name = DECL_NAME (TREE_OPERAND (node, 0));
10414       *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
10415       *arg = TREE_VALUE (argument);
10416     }
10417   return identified;
10418 }
10419
10420 /* Detect in NODE an outer field read access from an inner class and
10421    transform it into a write with RHS as an argument. This function is
10422    called from the java_complete_lhs when an assignment to a LHS can
10423    be identified. */
10424
10425 static tree
10426 outer_field_access_fix (wfl, node, rhs)
10427     tree wfl, node, rhs;
10428 {
10429   tree name, arg_type, arg;
10430   
10431   if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
10432     {
10433       /* At any rate, check whether we're trying to assign a value to
10434          a final. */
10435       tree accessed = (JDECL_P (node) ? node : 
10436                        (TREE_CODE (node) == COMPONENT_REF ? 
10437                         TREE_OPERAND (node, 1) : node));
10438       if (check_final_assignment (accessed, wfl))
10439         return error_mark_node;
10440   
10441       node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl), 
10442                                             arg_type, name, arg, rhs);
10443       return java_complete_tree (node);
10444     }
10445   return NULL_TREE;
10446 }
10447
10448 /* Construct the expression that calls an access method:
10449      <type>.access$<n>(<arg1> [, <arg2>]); 
10450
10451    ARG2 can be NULL and will be omitted in that case. It will denote a
10452    read access.  */
10453
10454 static tree
10455 build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
10456     int lc;
10457     tree type, access_method_name, arg1, arg2;
10458 {
10459   tree args, cn, access;
10460
10461   args = arg1 ? arg1 : 
10462     build_wfl_node (build_current_thisn (current_class));
10463   args = build_tree_list (NULL_TREE, args);
10464
10465   if (arg2)
10466     args = tree_cons (NULL_TREE, arg2, args);
10467
10468   access = build_method_invocation (build_wfl_node (access_method_name), args);
10469   cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
10470   return make_qualified_primary (cn, access, lc);
10471 }
10472
10473 static tree
10474 build_new_access_id ()
10475 {
10476   static int access_n_counter = 1;
10477   char buffer [128];
10478
10479   sprintf (buffer, "access$%d", access_n_counter++);
10480   return get_identifier (buffer);
10481 }
10482
10483 /* Create the static access functions for the outer field DECL. We define a
10484    read:
10485      TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
10486        return inst$.field;
10487      }
10488    and a write access:
10489      TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$,
10490                                      TREE_TYPE (<field>) value$) {
10491        return inst$.field = value$;
10492      }
10493    We should have a usage flags on the DECL so we can lazily turn the ones
10494    we're using for code generation. FIXME.
10495 */
10496
10497 static tree
10498 build_outer_field_access_methods (decl)
10499     tree decl;
10500 {
10501   tree id, args, stmt, mdecl;
10502   
10503   /* Check point, to be removed. FIXME */
10504   if (FIELD_INNER_ACCESS (decl) 
10505       && TREE_CODE (FIELD_INNER_ACCESS (decl)) != IDENTIFIER_NODE)
10506     abort ();
10507
10508   if (FIELD_INNER_ACCESS (decl))
10509     return FIELD_INNER_ACCESS (decl);
10510
10511   push_obstacks (&permanent_obstack, &permanent_obstack);
10512
10513   /* Create the identifier and a function named after it. */
10514   id = build_new_access_id ();
10515
10516   /* The identifier is marked as bearing the name of a generated write
10517      access function for outer field accessed from inner classes. */
10518   OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10519
10520   /* Create the read access */
10521   args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10522   TREE_CHAIN (args) = end_params_node;
10523   stmt = make_qualified_primary (build_wfl_node (inst_id),
10524                                  build_wfl_node (DECL_NAME (decl)), 0);
10525   stmt = build_return (0, stmt);
10526   mdecl = build_outer_field_access_method (DECL_CONTEXT (decl), 
10527                                            TREE_TYPE (decl), id, args, stmt);
10528   DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10529
10530   /* Create the write access method */
10531   args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10532   TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
10533   TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
10534   stmt = make_qualified_primary (build_wfl_node (inst_id),
10535                                  build_wfl_node (DECL_NAME (decl)), 0);
10536   stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
10537                                             build_wfl_node (wpv_id)));
10538
10539   mdecl = build_outer_field_access_method (DECL_CONTEXT (decl), 
10540                                            TREE_TYPE (decl), id, args, stmt);
10541   DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10542   pop_obstacks ();
10543
10544   /* Return the access name */
10545   return FIELD_INNER_ACCESS (decl) = id;
10546 }
10547
10548 /* Build an field access method NAME.  */
10549
10550 static tree 
10551 build_outer_field_access_method (class, type, name, args, body)
10552     tree class, type, name, args, body;
10553 {
10554   tree saved_current_function_decl, mdecl;
10555
10556   /* Create the method */
10557   mdecl = create_artificial_method (class, ACC_STATIC, type, name, args);
10558   fix_method_argument_names (args, mdecl);
10559   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10560
10561   /* Attach the method body. */
10562   saved_current_function_decl = current_function_decl;
10563   start_artificial_method_body (mdecl);
10564   java_method_add_stmt (mdecl, body);
10565   end_artificial_method_body (mdecl);
10566   current_function_decl = saved_current_function_decl;
10567
10568   return mdecl;
10569 }
10570
10571 \f
10572 /* This section deals with building access function necessary for
10573    certain kinds of method invocation from inner classes.  */
10574
10575 static tree
10576 build_outer_method_access_method (decl)
10577     tree decl;
10578 {
10579   tree saved_current_function_decl, mdecl;
10580   tree args = NULL_TREE, call_args = NULL_TREE;
10581   tree carg, id, body, class;
10582   char buffer [80];
10583   int parm_id_count = 0;
10584
10585   /* Test this abort with an access to a private field */
10586   if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "access$"))
10587     abort ();
10588
10589   /* Check the cache first */
10590   if (DECL_FUNCTION_INNER_ACCESS (decl))
10591     return DECL_FUNCTION_INNER_ACCESS (decl);
10592
10593   class = DECL_CONTEXT (decl);
10594
10595   /* Obtain an access identifier and mark it */
10596   id = build_new_access_id ();
10597   OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10598
10599   push_obstacks (&permanent_obstack, &permanent_obstack);
10600
10601   carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
10602   /* Create the arguments, as much as the original */
10603   for (; carg && carg != end_params_node; 
10604        carg = TREE_CHAIN (carg))
10605     {
10606       sprintf (buffer, "write_parm_value$%d", parm_id_count++);
10607       args = chainon (args, build_tree_list (get_identifier (buffer), 
10608                                              TREE_VALUE (carg)));
10609     }
10610   args = chainon (args, end_params_node);
10611
10612   /* Create the method */
10613   mdecl = create_artificial_method (class, ACC_STATIC, 
10614                                     TREE_TYPE (TREE_TYPE (decl)), id, args);
10615   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10616   /* There is a potential bug here. We should be able to use
10617      fix_method_argument_names, but then arg names get mixed up and
10618      eventually a constructor will have its this$0 altered and the
10619      outer context won't be assignment properly. The test case is
10620      stub.java FIXME */
10621   TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
10622
10623   /* Attach the method body. */
10624   saved_current_function_decl = current_function_decl;
10625   start_artificial_method_body (mdecl);
10626
10627   /* The actual method invocation uses the same args. When invoking a
10628      static methods that way, we don't want to skip the first
10629      argument. */
10630   carg = args;
10631   if (!METHOD_STATIC (decl))
10632     carg = TREE_CHAIN (carg);
10633   for (; carg && carg != end_params_node; carg = TREE_CHAIN (carg))
10634     call_args = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (carg)),
10635                            call_args);
10636
10637   body = build_method_invocation (build_wfl_node (DECL_NAME (decl)), 
10638                                   call_args);
10639   if (!METHOD_STATIC (decl))
10640     body = make_qualified_primary (build_wfl_node (TREE_PURPOSE (args)), 
10641                                    body, 0);
10642   if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
10643     body = build_return (0, body);
10644   java_method_add_stmt (mdecl,body);
10645   end_artificial_method_body (mdecl);
10646   current_function_decl = saved_current_function_decl;
10647   pop_obstacks ();
10648
10649   /* Back tag the access function so it know what it accesses */
10650   DECL_FUNCTION_ACCESS_DECL (decl) = mdecl;
10651
10652   /* Tag the current method so it knows it has an access generated */
10653   return DECL_FUNCTION_INNER_ACCESS (decl) = mdecl;
10654 }
10655
10656 \f
10657 /* This section of the code deals with building expressions to access
10658    the enclosing instance of an inner class. The enclosing instance is
10659    kept in a generated field called this$<n>, with <n> being the
10660    inner class nesting level (starting from 0.)  */
10661     
10662 /* Build an access to a given this$<n>, possibly by chaining access
10663    call to others. Access methods to this$<n> are build on the fly if
10664    necessary */
10665
10666 static tree
10667 build_access_to_thisn (from, to, lc)
10668      tree from, to;
10669      int lc;
10670 {
10671   tree access = NULL_TREE;
10672
10673   while (from != to)
10674     {
10675       tree access0_wfl, cn;
10676
10677       maybe_build_thisn_access_method (from);
10678       access0_wfl = build_wfl_node (access0_identifier_node);
10679       cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
10680       EXPR_WFL_LINECOL (access0_wfl) = lc;
10681       
10682       if (!access)
10683         {
10684           access = build_current_thisn (current_class);
10685           access = build_wfl_node (access);
10686         }
10687       access = build_tree_list (NULL_TREE, access);
10688       access = build_method_invocation (access0_wfl, access);
10689       access = make_qualified_primary (cn, access, lc);
10690       
10691       from = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (from)));
10692     }
10693   return access;
10694 }
10695
10696 /* Build an access function to the this$<n> local to TYPE. NULL_TREE
10697    is returned if nothing needs to be generated. Otherwise, the method
10698    generated and a method decl is returned.  
10699
10700    NOTE: These generated methods should be declared in a class file
10701    attribute so that they can't be referred to directly.  */
10702
10703 static tree
10704 maybe_build_thisn_access_method (type)
10705     tree type;
10706 {
10707   tree mdecl, args, stmt, rtype;
10708   tree saved_current_function_decl;
10709
10710   /* If TYPE is a top-level class, no access method is required.
10711      If there already is such an access method, bail out. */
10712   if (CLASS_ACCESS0_GENERATED_P (type) || !INNER_CLASS_TYPE_P (type))
10713     return NULL_TREE;
10714
10715   /* We generate the method. The method looks like:
10716      static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; }
10717   */
10718   push_obstacks (&permanent_obstack, &permanent_obstack);
10719   args = build_tree_list (inst_id, build_pointer_type (type));
10720   TREE_CHAIN (args) = end_params_node;
10721   rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))));
10722   mdecl = create_artificial_method (type, ACC_STATIC, rtype,
10723                                     access0_identifier_node, args);
10724   fix_method_argument_names (args, mdecl);
10725   layout_class_method (type, NULL_TREE, mdecl, NULL_TREE);
10726   stmt = build_current_thisn (type);
10727   stmt = make_qualified_primary (build_wfl_node (inst_id), 
10728                                  build_wfl_node (stmt), 0);
10729   stmt = build_return (0, stmt);
10730
10731   saved_current_function_decl = current_function_decl;
10732   start_artificial_method_body (mdecl);
10733   java_method_add_stmt (mdecl, stmt);
10734   end_artificial_method_body (mdecl);
10735   current_function_decl = saved_current_function_decl;
10736   pop_obstacks ();
10737
10738   CLASS_ACCESS0_GENERATED_P (type) = 1;
10739
10740   return mdecl;
10741 }
10742
10743 /* Craft an correctly numbered `this$<n>'string. this$0 is used for
10744    the first level of innerclassing. this$1 for the next one, etc...
10745    This function can be invoked with TYPE to NULL, available and then
10746    has to count the parser context.  */
10747
10748 static tree
10749 build_current_thisn (type)
10750     tree type;
10751 {
10752   static int saved_i = -1;
10753   static tree saved_thisn = NULL_TREE;
10754
10755   tree decl;
10756   char buffer [80];
10757   int i = 0;
10758
10759   if (type)
10760     {
10761       static tree saved_type = NULL_TREE;
10762       static int saved_type_i = 0;
10763
10764       if (type == saved_type)
10765         i = saved_type_i;
10766       else
10767         {
10768           for (i = -1, decl = DECL_CONTEXT (TYPE_NAME (type)); 
10769                decl; decl = DECL_CONTEXT (decl), i++)
10770             ;
10771       
10772           saved_type = type;
10773           saved_type_i = i;
10774         }
10775     }
10776   else
10777     i = list_length (GET_CPC_LIST ())-2;
10778
10779   if (i == saved_i)
10780     return saved_thisn;
10781     
10782   sprintf (buffer, "this$%d", i);
10783   saved_i = i;
10784   saved_thisn = get_identifier (buffer);
10785   return saved_thisn;
10786 }
10787
10788 /* Return the assignement to the hidden enclosing context `this$<n>'
10789    by the second incoming parameter to the innerclass constructor. The
10790    form used is `this.this$<n> = this$<n>;'.  */
10791
10792 static tree
10793 build_thisn_assign ()
10794 {
10795   if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
10796     {
10797       tree thisn = build_current_thisn (current_class);
10798       tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
10799                                          build_wfl_node (thisn), 0);
10800       tree rhs = build_wfl_node (thisn);
10801       EXPR_WFL_SET_LINECOL (lhs, lineno, 0);
10802       return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
10803     }
10804   return NULL_TREE;
10805 }
10806
10807 \f
10808 /* Building the synthetic `class$' used to implement the `.class' 1.1
10809    extension for non primitive types. This method looks like:
10810
10811     static Class class$(String type) throws NoClassDefFoundError
10812     {
10813       try {return (java.lang.Class.forName (String));}
10814       catch (ClassNotFoundException e) {
10815         throw new NoClassDefFoundError(e.getMessage());}
10816     } */
10817
10818 static tree
10819 build_dot_class_method (class)
10820      tree class;
10821 {
10822 #define BWF(S) build_wfl_node (get_identifier ((S)))
10823 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
10824   tree args, tmp, saved_current_function_decl, mdecl;
10825   tree stmt, throw_stmt, catch, catch_block, try_block;
10826   tree catch_clause_param;
10827   tree class_not_found_exception, no_class_def_found_error;
10828
10829   static tree get_message_wfl, type_parm_wfl;
10830
10831   if (!get_message_wfl)
10832     {
10833       get_message_wfl = build_wfl_node (get_identifier ("getMessage"));
10834       type_parm_wfl = build_wfl_node (get_identifier ("type$"));
10835     }
10836
10837   /* Build the arguments */
10838   args = build_tree_list (get_identifier ("type$"),
10839                           build_pointer_type (string_type_node));
10840   TREE_CHAIN (args) = end_params_node;
10841
10842   /* Build the qualified name java.lang.Class.forName */
10843   tmp = MQN (MQN (MQN (BWF ("java"), 
10844                        BWF ("lang")), BWF ("Class")), BWF ("forName"));
10845
10846   /* For things we have to catch and throw */
10847   class_not_found_exception = 
10848     lookup_class (get_identifier ("java.lang.ClassNotFoundException"));
10849   no_class_def_found_error = 
10850     lookup_class (get_identifier ("java.lang.NoClassDefFoundError"));
10851   load_class (class_not_found_exception, 1);
10852   load_class (no_class_def_found_error, 1);
10853
10854   /* Create the "class$" function */
10855   mdecl = create_artificial_method (class, ACC_STATIC, 
10856                                     build_pointer_type (class_type_node),
10857                                     get_identifier ("class$"), args);
10858   DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE,
10859                                                   no_class_def_found_error);
10860   
10861   /* We start by building the try block. We need to build:
10862        return (java.lang.Class.forName (type)); */
10863   stmt = build_method_invocation (tmp, 
10864                                   build_tree_list (NULL_TREE, type_parm_wfl));
10865   stmt = build_return (0, stmt);
10866   /* Put it in a block. That's the try block */
10867   try_block = build_expr_block (stmt, NULL_TREE);
10868
10869   /* Now onto the catch block. We start by building the expression
10870      throwing a new exception: 
10871        throw new NoClassDefFoundError (_.getMessage); */
10872   throw_stmt = make_qualified_name (build_wfl_node (wpv_id), 
10873                                     get_message_wfl, 0);
10874   throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
10875   
10876   /* Build new NoClassDefFoundError (_.getMessage) */
10877   throw_stmt = build_new_invocation 
10878     (build_wfl_node (get_identifier ("NoClassDefFoundError")),
10879      build_tree_list (build_pointer_type (string_type_node), throw_stmt));
10880
10881   /* Build the throw, (it's too early to use BUILD_THROW) */
10882   throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
10883
10884   /* Build the catch block to encapsulate all this. We begin by
10885      building an decl for the catch clause parameter and link it to
10886      newly created block, the catch block. */
10887   catch_clause_param = 
10888     build_decl (VAR_DECL, wpv_id, 
10889                 build_pointer_type (class_not_found_exception));
10890   catch_block = build_expr_block (NULL_TREE, catch_clause_param);
10891   
10892   /* We initialize the variable with the exception handler. */
10893   catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
10894                  soft_exceptioninfo_call_node);
10895   add_stmt_to_block (catch_block, NULL_TREE, catch);
10896
10897   /* We add the statement throwing the new exception */
10898   add_stmt_to_block (catch_block, NULL_TREE, throw_stmt);
10899
10900   /* Build a catch expression for all this */
10901   catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
10902
10903   /* Build the try/catch sequence */
10904   stmt = build_try_statement (0, try_block, catch_block);
10905
10906   fix_method_argument_names (args, mdecl);
10907   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10908   saved_current_function_decl = current_function_decl;
10909   start_artificial_method_body (mdecl);
10910   java_method_add_stmt (mdecl, stmt);
10911   end_artificial_method_body (mdecl);
10912   current_function_decl = saved_current_function_decl;
10913   TYPE_DOT_CLASS (class) = mdecl;
10914
10915   return mdecl;
10916 }
10917
10918 static tree
10919 build_dot_class_method_invocation (name)
10920      tree name;
10921 {
10922   tree s = make_node (STRING_CST);
10923   TREE_STRING_LENGTH (s) = IDENTIFIER_LENGTH (name);
10924   TREE_STRING_POINTER (s) = obstack_alloc (expression_obstack,
10925                                            TREE_STRING_LENGTH (s)+1);
10926   strcpy (TREE_STRING_POINTER (s), IDENTIFIER_POINTER (name));
10927   return build_method_invocation (build_wfl_node (get_identifier ("class$")),
10928                                   build_tree_list (NULL_TREE, s));
10929 }
10930
10931 /* This section of the code deals with constructor.  */
10932
10933 /* Craft a body for default constructor. Patch existing constructor
10934    bodies with call to super() and field initialization statements if
10935    necessary.  */
10936
10937 static void
10938 fix_constructors (mdecl)
10939      tree mdecl;
10940 {
10941   tree body = DECL_FUNCTION_BODY (mdecl);
10942   tree thisn_assign, compound = NULL_TREE;
10943   tree class_type = DECL_CONTEXT (mdecl);
10944
10945   if (!body)
10946     {
10947       /* It is an error for the compiler to generate a default
10948          constructor if the superclass doesn't have a constructor that
10949          takes no argument, or the same args for an anonymous class */
10950       if (verify_constructor_super (mdecl))
10951         {
10952           tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (class_type));
10953           tree save = DECL_NAME (mdecl);
10954           const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
10955           DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
10956           parse_error_context
10957             (lookup_cl (TYPE_NAME (class_type)), 
10958              "No constructor matching `%s' found in class `%s'",
10959              lang_printable_name (mdecl, 0), n);
10960           DECL_NAME (mdecl) = save;
10961         }
10962       
10963       /* The constructor body must be crafted by hand. It's the
10964          constructor we defined when we realize we didn't have the
10965          CLASSNAME() constructor */
10966       start_artificial_method_body (mdecl);
10967       
10968       /* We don't generate a super constructor invocation if we're
10969          compiling java.lang.Object. build_super_invocation takes care
10970          of that. */
10971       compound = java_method_add_stmt (mdecl, build_super_invocation (mdecl));
10972
10973       /* Insert the instance initializer block right here, after the
10974          super invocation. */
10975       add_instance_initializer (mdecl);
10976
10977       /* Insert an assignment to the this$<n> hidden field, if
10978          necessary */
10979       if ((thisn_assign = build_thisn_assign ()))
10980         java_method_add_stmt (mdecl, thisn_assign);
10981
10982       end_artificial_method_body (mdecl);
10983     }
10984   /* Search for an explicit constructor invocation */
10985   else 
10986     {
10987       int found = 0;
10988       tree main_block = BLOCK_EXPR_BODY (body);
10989       
10990       while (body)
10991         switch (TREE_CODE (body))
10992           {
10993           case CALL_EXPR:
10994             found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
10995             body = NULL_TREE;
10996             break;
10997           case COMPOUND_EXPR:
10998           case EXPR_WITH_FILE_LOCATION:
10999             body = TREE_OPERAND (body, 0);
11000             break;
11001           case BLOCK:
11002             body = BLOCK_EXPR_BODY (body);
11003             break;
11004           default:
11005             found = 0;
11006             body = NULL_TREE;
11007           }
11008       /* The constructor is missing an invocation of super() */
11009       if (!found)
11010         compound = add_stmt_to_compound (compound, NULL_TREE,
11011                                          build_super_invocation (mdecl));
11012       
11013       /* Insert the instance initializer block right here, after the
11014          super invocation. */
11015       add_instance_initializer (mdecl);
11016
11017       /* Generate the assignment to this$<n>, if necessary */
11018       if ((thisn_assign = build_thisn_assign ()))
11019         compound = add_stmt_to_compound (compound, NULL_TREE, thisn_assign);
11020
11021       /* Fix the constructor main block if we're adding extra stmts */
11022       if (compound)
11023         {
11024           compound = add_stmt_to_compound (compound, NULL_TREE,
11025                                            BLOCK_EXPR_BODY (main_block));
11026           BLOCK_EXPR_BODY (main_block) = compound;
11027         }
11028     }
11029 }
11030
11031 /* Browse constructors in the super class, searching for a constructor
11032    that doesn't take any argument. Return 0 if one is found, 1
11033    otherwise.  If the current class is an anonymous inner class, look
11034    for something that has the same signature. */
11035
11036 static int
11037 verify_constructor_super (mdecl)
11038      tree mdecl;
11039 {
11040   tree class = CLASSTYPE_SUPER (current_class);
11041   int super_inner = PURE_INNER_CLASS_TYPE_P (class);
11042   tree sdecl;
11043
11044   if (!class)
11045     return 0;
11046
11047   if (ANONYMOUS_CLASS_P (current_class))
11048     {
11049       tree mdecl_arg_type;
11050       SKIP_THIS_AND_ARTIFICIAL_PARMS (mdecl_arg_type, mdecl);
11051       for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
11052         if (DECL_CONSTRUCTOR_P (sdecl))
11053           {
11054             tree arg_type = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
11055             if (super_inner)
11056               arg_type = TREE_CHAIN (arg_type);
11057             for (; (arg_type != end_params_node 
11058                     && mdecl_arg_type != end_params_node);
11059                  arg_type = TREE_CHAIN (arg_type), 
11060                  mdecl_arg_type = TREE_CHAIN (mdecl_arg_type))
11061               if (TREE_VALUE (arg_type) != TREE_VALUE (mdecl_arg_type))
11062                 break;
11063
11064             if (arg_type == end_params_node && 
11065                 mdecl_arg_type == end_params_node)
11066               return 0;
11067           }
11068     }
11069   else
11070     {
11071       for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
11072         {
11073           tree arg = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
11074           if (super_inner)
11075             arg = TREE_CHAIN (arg);
11076           if (DECL_CONSTRUCTOR_P (sdecl) && arg == end_params_node)
11077             return 0;
11078         }
11079     }
11080   return 1;
11081 }
11082
11083 /* Generate code for all context remembered for code generation.  */
11084
11085 void
11086 java_expand_classes ()
11087 {
11088   int save_error_count = 0;
11089   static struct parser_ctxt *saved_ctxp = NULL;
11090
11091   java_parse_abort_on_error ();
11092   if (!(ctxp = ctxp_for_generation))
11093     return;
11094   java_layout_classes ();
11095   java_parse_abort_on_error ();
11096
11097   saved_ctxp = ctxp_for_generation;
11098   for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11099     {
11100       ctxp = ctxp_for_generation;
11101       lang_init_source (2);            /* Error msgs have method prototypes */
11102       java_complete_expand_classes (); /* Complete and expand classes */
11103       java_parse_abort_on_error ();
11104     }
11105
11106   /* Find anonymous classes and expand their constructor, now they
11107      have been fixed. */
11108   for (ctxp_for_generation = saved_ctxp;
11109        ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11110     {
11111       tree current;
11112       ctxp = ctxp_for_generation;
11113       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11114         {
11115           current_class = TREE_TYPE (current);
11116           if (ANONYMOUS_CLASS_P (current_class))
11117             {
11118               tree d;
11119               for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
11120                 {
11121                   if (DECL_CONSTRUCTOR_P (d))
11122                     {
11123                       restore_line_number_status (1);
11124                       reset_method_name (d);
11125                       java_complete_expand_method (d);
11126                       restore_line_number_status (0);
11127                       break;    /* We now there are no other ones */
11128                     }
11129                 }
11130             }
11131         }
11132     }
11133
11134   /* If we've found error at that stage, don't try to generate
11135      anything, unless we're emitting xrefs or checking the syntax only
11136      (but not using -fsyntax-only for the purpose of generating
11137      bytecode. */
11138   if (java_error_count && !flag_emit_xref 
11139       && (!flag_syntax_only && !flag_emit_class_files))
11140     return;
11141
11142   /* Now things are stable, go for generation of the class data. */
11143   for (ctxp_for_generation = saved_ctxp;
11144        ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11145     {
11146       tree current;
11147       ctxp = ctxp_for_generation;
11148       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11149         {
11150           current_class = TREE_TYPE (current);
11151           outgoing_cpool = TYPE_CPOOL (current_class);
11152           if (flag_emit_class_files)
11153             write_classfile (current_class);
11154           if (flag_emit_xref)
11155             expand_xref (current_class);
11156           else if (! flag_syntax_only)
11157             finish_class ();
11158         }
11159     }
11160 }
11161
11162 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
11163    a tree list node containing RIGHT. Fore coming RIGHTs will be
11164    chained to this hook. LOCATION contains the location of the
11165    separating `.' operator.  */
11166
11167 static tree
11168 make_qualified_primary (primary, right, location)
11169      tree primary, right;
11170      int location;
11171 {
11172   tree wfl;
11173
11174   if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
11175     wfl = build_wfl_wrap (primary, location);
11176   else
11177     {
11178       wfl = primary;
11179       /* If wfl wasn't qualified, we build a first anchor */
11180       if (!EXPR_WFL_QUALIFICATION (wfl))
11181         EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (wfl, NULL_TREE);
11182     }
11183
11184   /* And chain them */
11185   EXPR_WFL_LINECOL (right) = location;
11186   chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
11187   PRIMARY_P (wfl) =  1;
11188   return wfl;
11189 }
11190
11191 /* Simple merge of two name separated by a `.' */
11192
11193 static tree
11194 merge_qualified_name (left, right)
11195      tree left, right;
11196 {
11197   tree node;
11198   if (!left && !right)
11199     return NULL_TREE;
11200
11201   if (!left)
11202     return right;
11203
11204   if (!right)
11205     return left;
11206
11207   obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
11208                 IDENTIFIER_LENGTH (left));
11209   obstack_1grow (&temporary_obstack, '.');
11210   obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
11211                  IDENTIFIER_LENGTH (right));
11212   node =  get_identifier (obstack_base (&temporary_obstack));
11213   obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
11214   QUALIFIED_P (node) = 1;
11215   return node;
11216 }
11217
11218 /* Merge the two parts of a qualified name into LEFT.  Set the
11219    location information of the resulting node to LOCATION, usually
11220    inherited from the location information of the `.' operator. */
11221
11222 static tree
11223 make_qualified_name (left, right, location)
11224      tree left, right;
11225      int location;
11226 {
11227 #ifdef USE_COMPONENT_REF
11228   tree node = build (COMPONENT_REF, NULL_TREE, left, right);
11229   EXPR_WFL_LINECOL (node) = location;
11230   return node;
11231 #else
11232   tree left_id = EXPR_WFL_NODE (left);
11233   tree right_id = EXPR_WFL_NODE (right);
11234   tree wfl, merge;
11235
11236   merge = merge_qualified_name (left_id, right_id);
11237
11238   /* Left wasn't qualified and is now qualified */
11239   if (!QUALIFIED_P (left_id))
11240     {
11241       tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
11242       EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
11243       EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
11244     }
11245   
11246   wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
11247   EXPR_WFL_LINECOL (wfl) = location;
11248   chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
11249
11250   EXPR_WFL_NODE (left) = merge;
11251   return left;
11252 #endif
11253 }
11254
11255 /* Extract the last identifier component of the qualified in WFL. The
11256    last identifier is removed from the linked list */
11257
11258 static tree
11259 cut_identifier_in_qualified (wfl)
11260      tree wfl;
11261 {
11262   tree q;
11263   tree previous = NULL_TREE;
11264   for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
11265     if (!TREE_CHAIN (q))
11266       {
11267         if (!previous)
11268           fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified");
11269         TREE_CHAIN (previous) = NULL_TREE;
11270         return TREE_PURPOSE (q);
11271       }
11272 }
11273
11274 /* Resolve the expression name NAME. Return its decl.  */
11275
11276 static tree
11277 resolve_expression_name (id, orig)
11278      tree id;
11279      tree *orig;
11280 {
11281   tree name = EXPR_WFL_NODE (id);
11282   tree decl;
11283
11284   /* 6.5.5.1: Simple expression names */
11285   if (!PRIMARY_P (id) && !QUALIFIED_P (name))
11286     {
11287       /* 15.13.1: NAME can appear within the scope of a local variable
11288          declaration */
11289       if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
11290         return decl;
11291
11292       /* 15.13.1: NAME can appear within a class declaration */
11293       else 
11294         {
11295           decl = lookup_field_wrapper (current_class, name);
11296           if (decl)
11297             {
11298               tree access = NULL_TREE;
11299               int fs = FIELD_STATIC (decl);
11300
11301               /* If we're accessing an outer scope local alias, make
11302                  sure we change the name of the field we're going to
11303                  build access to. */
11304               if (FIELD_LOCAL_ALIAS_USED (decl))
11305                 name = DECL_NAME (decl);
11306
11307               /* Instance variable (8.3.1.1) can't appear within
11308                  static method, static initializer or initializer for
11309                  a static variable. */
11310               if (!fs && METHOD_STATIC (current_function_decl))
11311                 {
11312                   static_ref_err (id, name, current_class);
11313                   return error_mark_node;
11314                 }
11315               /* Instance variables can't appear as an argument of
11316                  an explicit constructor invocation */
11317               if (!fs && ctxp->explicit_constructor_p)
11318                 {
11319                   parse_error_context
11320                     (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
11321                   return error_mark_node;
11322                 }
11323
11324               /* If we're processing an inner class and we're trying
11325                  to access a field belonging to an outer class, build
11326                  the access to the field */
11327               if (!fs && outer_field_access_p (current_class, decl))
11328                 return build_outer_field_access (id, decl);
11329
11330               /* Otherwise build what it takes to access the field */
11331               access = build_field_ref ((fs ? NULL_TREE : current_this),
11332                                         DECL_CONTEXT (decl), name);
11333               if (fs && !flag_emit_class_files && !flag_emit_xref)
11334                 access = build_class_init (DECL_CONTEXT (access), access);
11335               /* We may be asked to save the real field access node */
11336               if (orig)
11337                 *orig = access;
11338               /* And we return what we got */
11339               return access;
11340             }
11341           /* Fall down to error report on undefined variable */
11342         }
11343     }
11344   /* 6.5.5.2 Qualified Expression Names */
11345   else
11346     {
11347       if (orig)
11348         *orig = NULL_TREE;
11349       qualify_ambiguous_name (id);
11350       /* 15.10.1 Field Access Using a Primary and/or Expression Name */
11351       /* 15.10.2: Accessing Superclass Members using super */
11352       return resolve_field_access (id, orig, NULL);
11353     }
11354
11355   /* We've got an error here */
11356   parse_error_context (id, "Undefined variable `%s'", 
11357                        IDENTIFIER_POINTER (name));
11358
11359   return error_mark_node;
11360 }
11361
11362 static void
11363 static_ref_err (wfl, field_id, class_type)
11364     tree wfl, field_id, class_type;
11365 {
11366   parse_error_context 
11367     (wfl, 
11368      "Can't make a static reference to nonstatic variable `%s' in class `%s'",
11369      IDENTIFIER_POINTER (field_id), 
11370      IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
11371 }
11372
11373 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
11374    We return something suitable to generate the field access. We also
11375    return the field decl in FIELD_DECL and its type in FIELD_TYPE.  If
11376    recipient's address can be null. */
11377
11378 static tree
11379 resolve_field_access (qual_wfl, field_decl, field_type)
11380      tree qual_wfl;
11381      tree *field_decl, *field_type;
11382 {
11383   int is_static = 0;
11384   tree field_ref;
11385   tree decl, where_found, type_found;
11386
11387   if (resolve_qualified_expression_name (qual_wfl, &decl,
11388                                          &where_found, &type_found))
11389     return error_mark_node;
11390
11391   /* Resolve the LENGTH field of an array here */
11392   if (DECL_P (decl) && DECL_NAME (decl) == length_identifier_node 
11393       && TYPE_ARRAY_P (type_found) 
11394       && ! flag_emit_class_files && ! flag_emit_xref)
11395     {
11396       tree length = build_java_array_length_access (where_found);
11397       field_ref =
11398         build_java_arraynull_check (type_found, length, int_type_node);
11399
11400       /* In case we're dealing with a static array, we need to
11401          initialize its class before the array length can be fetched.
11402          It's also a good time to create a DECL_RTL for the field if
11403          none already exists, otherwise if the field was declared in a
11404          class found in an external file and hasn't been (and won't
11405          be) accessed for its value, none will be created. */
11406       if (TREE_CODE (where_found) == VAR_DECL && FIELD_STATIC (where_found))
11407         {
11408           build_static_field_ref (where_found);
11409           field_ref = build_class_init (DECL_CONTEXT (where_found), field_ref);
11410         }
11411     }
11412   /* We might have been trying to resolve field.method(). In which
11413      case, the resolution is over and decl is the answer */
11414   else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
11415     field_ref = decl;
11416   else if (JDECL_P (decl))
11417     {
11418       int static_final_found = 0;
11419       if (!type_found)
11420         type_found = DECL_CONTEXT (decl);
11421       is_static = JDECL_P (decl) && FIELD_STATIC (decl);
11422       if (FIELD_FINAL (decl) 
11423           && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
11424           && DECL_INITIAL (decl))
11425         {
11426           field_ref = java_complete_tree (DECL_INITIAL (decl));
11427           static_final_found = 1;
11428         }
11429       else
11430         field_ref = build_field_ref ((is_static && !flag_emit_xref? 
11431                                       NULL_TREE : where_found), 
11432                                      type_found, DECL_NAME (decl));
11433       if (field_ref == error_mark_node)
11434         return error_mark_node;
11435       if (is_static && !static_final_found 
11436           && !flag_emit_class_files && !flag_emit_xref)
11437         field_ref = build_class_init (DECL_CONTEXT (decl), field_ref);
11438     }
11439   else
11440     field_ref = decl;
11441
11442   if (field_decl)
11443     *field_decl = decl;
11444   if (field_type)
11445     *field_type = (QUAL_DECL_TYPE (decl) ? 
11446                    QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
11447   return field_ref;
11448 }
11449
11450 /* If NODE is an access to f static field, strip out the class
11451    initialization part and return the field decl, otherwise, return
11452    NODE. */
11453
11454 static tree
11455 strip_out_static_field_access_decl (node)
11456     tree node;
11457 {
11458   if (TREE_CODE (node) == COMPOUND_EXPR)
11459     {
11460       tree op1 = TREE_OPERAND (node, 1);
11461       if (TREE_CODE (op1) == COMPOUND_EXPR)
11462          {
11463            tree call = TREE_OPERAND (op1, 0);
11464            if (TREE_CODE (call) == CALL_EXPR
11465                && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
11466                && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
11467                == soft_initclass_node)
11468              return TREE_OPERAND (op1, 1);
11469          }
11470       else if (JDECL_P (op1))
11471         return op1;
11472     }
11473   return node;
11474 }
11475
11476 /* 6.5.5.2: Qualified Expression Names */
11477
11478 static int
11479 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
11480      tree wfl;
11481      tree *found_decl, *type_found, *where_found;
11482 {
11483   int from_type = 0;            /* Field search initiated from a type */
11484   int from_super = 0, from_cast = 0, from_qualified_this = 0;
11485   int previous_call_static = 0;
11486   int is_static;
11487   tree decl = NULL_TREE, type = NULL_TREE, q;
11488   /* For certain for of inner class instantiation */
11489   tree saved_current, saved_this;               
11490 #define RESTORE_THIS_AND_CURRENT_CLASS                          \
11491   { current_class = saved_current; current_this = saved_this;}
11492
11493   *type_found = *where_found = NULL_TREE;
11494
11495   for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
11496     {
11497       tree qual_wfl = QUAL_WFL (q);
11498       tree ret_decl;            /* for EH checking */
11499       int location;             /* for EH checking */
11500
11501       /* 15.10.1 Field Access Using a Primary */
11502       switch (TREE_CODE (qual_wfl))
11503         {
11504         case CALL_EXPR:
11505         case NEW_CLASS_EXPR:
11506           /* If the access to the function call is a non static field,
11507              build the code to access it. */
11508           if (JDECL_P (decl) && !FIELD_STATIC (decl))
11509             {
11510               decl = maybe_access_field (decl, *where_found, 
11511                                          DECL_CONTEXT (decl));
11512               if (decl == error_mark_node)
11513                 return 1;
11514             }
11515
11516           /* And code for the function call */
11517           if (complete_function_arguments (qual_wfl))
11518             return 1;
11519
11520           /* We might have to setup a new current class and a new this
11521              for the search of an inner class, relative to the type of
11522              a expression resolved as `decl'. The current values are
11523              saved and restored shortly after */
11524           saved_current = current_class;
11525           saved_this = current_this;
11526           if (decl && TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
11527             {
11528               current_class = type;
11529               current_this = decl;
11530             }
11531
11532           if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
11533             CALL_USING_SUPER (qual_wfl) = 1;
11534           location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
11535                       EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
11536           *where_found = patch_method_invocation (qual_wfl, decl, type, 
11537                                                   &is_static, &ret_decl);
11538           if (*where_found == error_mark_node)
11539             {
11540               RESTORE_THIS_AND_CURRENT_CLASS;
11541               return 1;
11542             }
11543           *type_found = type = QUAL_DECL_TYPE (*where_found);
11544
11545           /* If we're creating an inner class instance, check for that
11546              an enclosing instance is in scope */
11547           if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
11548               && INNER_ENCLOSING_SCOPE_CHECK (type))
11549             {
11550               parse_error_context 
11551                 (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
11552                  lang_printable_name (type, 0),
11553                  (!current_this ? "" :
11554                   "; an explicit one must be provided when creating this inner class"));
11555               RESTORE_THIS_AND_CURRENT_CLASS;
11556               return 1;
11557             }
11558
11559           /* In case we had to change then to resolve a inner class
11560              instantiation using a primary qualified by a `new' */
11561           RESTORE_THIS_AND_CURRENT_CLASS;
11562
11563           /* EH check */
11564           if (location)
11565             check_thrown_exceptions (location, ret_decl);
11566
11567           /* If the previous call was static and this one is too,
11568              build a compound expression to hold the two (because in
11569              that case, previous function calls aren't transported as
11570              forcoming function's argument. */
11571           if (previous_call_static && is_static)
11572             {
11573               decl = build (COMPOUND_EXPR, type, decl, *where_found);
11574               TREE_SIDE_EFFECTS (decl) = 1;
11575             }
11576           else
11577             {
11578               previous_call_static = is_static;
11579               decl = *where_found;
11580             }
11581           from_type = 0;
11582           continue;
11583
11584         case NEW_ARRAY_EXPR:
11585         case NEW_ANONYMOUS_ARRAY_EXPR:
11586           *where_found = decl = java_complete_tree (qual_wfl);
11587           if (decl == error_mark_node)
11588             return 1;
11589           *type_found = type = QUAL_DECL_TYPE (decl);
11590           CLASS_LOADED_P (type) = 1;
11591           continue;
11592
11593         case CONVERT_EXPR:
11594           *where_found = decl = java_complete_tree (qual_wfl);
11595           if (decl == error_mark_node)
11596             return 1;
11597           *type_found = type = QUAL_DECL_TYPE (decl);
11598           from_cast = 1;
11599           continue;
11600
11601         case CONDITIONAL_EXPR:
11602         case STRING_CST:
11603         case MODIFY_EXPR:
11604           *where_found = decl = java_complete_tree (qual_wfl);
11605           if (decl == error_mark_node)
11606             return 1;
11607           *type_found = type = QUAL_DECL_TYPE (decl);
11608           continue;
11609
11610         case ARRAY_REF:
11611           /* If the access to the function call is a non static field,
11612              build the code to access it. */
11613           if (JDECL_P (decl) && !FIELD_STATIC (decl))
11614             {
11615               decl = maybe_access_field (decl, *where_found, type);
11616               if (decl == error_mark_node)
11617                 return 1;
11618             }
11619           /* And code for the array reference expression */
11620           decl = java_complete_tree (qual_wfl);
11621           if (decl == error_mark_node)
11622             return 1;
11623           type = QUAL_DECL_TYPE (decl);
11624           continue;
11625
11626         case PLUS_EXPR:
11627           if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11628             return 1;
11629           if ((type = patch_string (decl)))
11630             decl = type;
11631           *where_found = QUAL_RESOLUTION (q) = decl;
11632           *type_found = type = TREE_TYPE (decl);
11633           break;
11634
11635         case CLASS_LITERAL:
11636           if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11637             return 1;
11638           *where_found = QUAL_RESOLUTION (q) = decl;
11639           *type_found = type = TREE_TYPE (decl);
11640           break;
11641
11642         default:
11643           /* Fix for -Wall Just go to the next statement. Don't
11644              continue */
11645           break;
11646         }
11647
11648       /* If we fall here, we weren't processing a (static) function call. */
11649       previous_call_static = 0;
11650
11651       /* It can be the keyword THIS */
11652       if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
11653         {
11654           if (!current_this)
11655             {
11656               parse_error_context 
11657                 (wfl, "Keyword `this' used outside allowed context");
11658               return 1;
11659             }
11660           if (ctxp->explicit_constructor_p)
11661             {
11662               parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
11663               return 1;
11664             }
11665           /* We have to generate code for intermediate acess */
11666           if (!from_type || TREE_TYPE (TREE_TYPE (current_this)) == type)
11667             {
11668               *where_found = decl = current_this;
11669               *type_found = type = QUAL_DECL_TYPE (decl);
11670             }
11671           /* We're trying to access the this from somewhere else... */
11672           else
11673             {
11674               *where_found = decl = build_current_thisn (type);
11675               from_qualified_this = 1;
11676             }
11677
11678           from_type = 0;
11679           continue;
11680         }
11681
11682       /* 15.10.2 Accessing Superclass Members using SUPER */
11683       if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
11684         {
11685           tree node;
11686           /* Check on the restricted use of SUPER */
11687           if (METHOD_STATIC (current_function_decl)
11688               || current_class == object_type_node)
11689             {
11690               parse_error_context 
11691                 (wfl, "Keyword `super' used outside allowed context");
11692               return 1;
11693             }
11694           /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
11695           node = build_cast (EXPR_WFL_LINECOL (qual_wfl), 
11696                              CLASSTYPE_SUPER (current_class),
11697                              build_this (EXPR_WFL_LINECOL (qual_wfl)));
11698           *where_found = decl = java_complete_tree (node);
11699           if (decl == error_mark_node)
11700             return 1;
11701           *type_found = type = QUAL_DECL_TYPE (decl);
11702           from_super = from_type = 1;
11703           continue;
11704         }
11705
11706       /* 15.13.1: Can't search for field name in packages, so we
11707          assume a variable/class name was meant. */
11708       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
11709         {
11710           tree name = resolve_package (wfl, &q);
11711           if (name)
11712             {
11713               tree list;
11714               *where_found = decl = resolve_no_layout (name, qual_wfl);
11715               /* We want to be absolutely sure that the class is laid
11716                  out. We're going to search something inside it. */
11717               *type_found = type = TREE_TYPE (decl);
11718               layout_class (type);
11719               from_type = 1;
11720
11721               /* Fix them all the way down, if any are left. */
11722               if (q)
11723                 {
11724                   list = TREE_CHAIN (q);
11725                   while (list)
11726                     {
11727                       RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
11728                       RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
11729                       list = TREE_CHAIN (list);
11730                     }
11731                 }
11732             }
11733           else
11734             {
11735               if (from_super || from_cast)
11736                 parse_error_context 
11737                   ((from_cast ? qual_wfl : wfl),
11738                    "No variable `%s' defined in class `%s'",
11739                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11740                    lang_printable_name (type, 0));
11741               else
11742                 parse_error_context
11743                   (qual_wfl, "Undefined variable or class name: `%s'",
11744                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
11745               return 1;
11746             }
11747         }
11748
11749       /* We have a type name. It's been already resolved when the
11750          expression was qualified. */
11751       else if (RESOLVE_TYPE_NAME_P (qual_wfl))
11752         {
11753           if (!(decl = QUAL_RESOLUTION (q)))
11754             return 1;           /* Error reported already */
11755
11756           /* Sneak preview. If next we see a `new', we're facing a
11757              qualification with resulted in a type being selected
11758              instead of a field.  Report the error */
11759           if(TREE_CHAIN (q) 
11760              && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
11761             {
11762               parse_error_context (qual_wfl, "Undefined variable `%s'",
11763                                    IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11764               return 1;
11765             }
11766
11767           if (not_accessible_p (TREE_TYPE (decl), decl, 0))
11768             {
11769               parse_error_context 
11770                 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
11771                  java_accstring_lookup (get_access_flags_from_decl (decl)),
11772                  GET_TYPE_NAME (type),
11773                  IDENTIFIER_POINTER (DECL_NAME (decl)),
11774                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
11775               return 1;
11776             }
11777           check_deprecation (qual_wfl, decl);
11778
11779           type = TREE_TYPE (decl);
11780           from_type = 1;
11781         }
11782       /* We resolve and expression name */
11783       else 
11784         {
11785           tree field_decl = NULL_TREE;
11786
11787           /* If there exists an early resolution, use it. That occurs
11788              only once and we know that there are more things to
11789              come. Don't do that when processing something after SUPER
11790              (we need more thing to be put in place below */
11791           if (!from_super && QUAL_RESOLUTION (q))
11792             {
11793               decl = QUAL_RESOLUTION (q);
11794               if (!type)
11795                 {
11796                   if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
11797                     {
11798                       if (current_this)
11799                         *where_found = current_this;
11800                       else
11801                         {
11802                           static_ref_err (qual_wfl, DECL_NAME (decl),
11803                                           current_class);
11804                           return 1;
11805                         }
11806                     }
11807                   else
11808                     {
11809                       *where_found = TREE_TYPE (decl);
11810                       if (TREE_CODE (*where_found) == POINTER_TYPE)
11811                         *where_found = TREE_TYPE (*where_found);
11812                     }
11813                 }
11814             }
11815
11816           /* We have to search for a field, knowing the type of its
11817              container. The flag FROM_TYPE indicates that we resolved
11818              the last member of the expression as a type name, which
11819              means that for the resolution of this field, we'll look
11820              for other errors than if it was resolved as a member of
11821              an other field. */
11822           else
11823             {
11824               int is_static;
11825               tree field_decl_type; /* For layout */
11826
11827               if (!from_type && !JREFERENCE_TYPE_P (type))
11828                 {
11829                   parse_error_context 
11830                     (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
11831                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11832                      lang_printable_name (type, 0),
11833                      IDENTIFIER_POINTER (DECL_NAME (field_decl)));
11834                   return 1;
11835                 }
11836               
11837               field_decl = lookup_field_wrapper (type,
11838                                                  EXPR_WFL_NODE (qual_wfl));
11839               if (field_decl == NULL_TREE)
11840                 {
11841                   parse_error_context 
11842                     (qual_wfl, "No variable `%s' defined in type `%s'",
11843                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)), 
11844                      GET_TYPE_NAME (type));
11845                   return 1;
11846                 }
11847               if (field_decl == error_mark_node)
11848                 return 1;
11849
11850               /* Layout the type of field_decl, since we may need
11851                  it. Don't do primitive types or loaded classes. The
11852                  situation of non primitive arrays may not handled
11853                  properly here. FIXME */
11854               if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
11855                 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
11856               else
11857                 field_decl_type = TREE_TYPE (field_decl);
11858               if (!JPRIMITIVE_TYPE_P (field_decl_type) 
11859                   && !CLASS_LOADED_P (field_decl_type)
11860                   && !TYPE_ARRAY_P (field_decl_type))
11861                 resolve_and_layout (field_decl_type, NULL_TREE);
11862               if (TYPE_ARRAY_P (field_decl_type))
11863                 CLASS_LOADED_P (field_decl_type) = 1;
11864               
11865               /* Check on accessibility here */
11866               if (not_accessible_p (type, field_decl, from_super))
11867                 {
11868                   parse_error_context 
11869                     (qual_wfl,
11870                      "Can't access %s field `%s.%s' from `%s'",
11871                      java_accstring_lookup 
11872                        (get_access_flags_from_decl (field_decl)),
11873                      GET_TYPE_NAME (type),
11874                      IDENTIFIER_POINTER (DECL_NAME (field_decl)),
11875                      IDENTIFIER_POINTER 
11876                        (DECL_NAME (TYPE_NAME (current_class))));
11877                   return 1;
11878                 }
11879               check_deprecation (qual_wfl, field_decl);
11880               
11881               /* There are things to check when fields are accessed
11882                  from type. There are no restrictions on a static
11883                  declaration of the field when it is accessed from an
11884                  interface */
11885               is_static = FIELD_STATIC (field_decl);
11886               if (!from_super && from_type 
11887                   && !TYPE_INTERFACE_P (type) 
11888                   && !is_static 
11889                   && (current_function_decl 
11890                       && METHOD_STATIC (current_function_decl)))
11891                 {
11892                   static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
11893                   return 1;
11894                 }
11895               from_cast = from_super = 0;
11896
11897               /* It's an access from a type but it isn't static, we
11898                  make it relative to `this'. */
11899               if (!is_static && from_type)
11900                 decl = current_this;
11901
11902               /* If we need to generate something to get a proper
11903                  handle on what this field is accessed from, do it
11904                  now. */
11905               if (!is_static)
11906                 {
11907                   decl = maybe_access_field (decl, *where_found, *type_found);
11908                   if (decl == error_mark_node)
11909                     return 1;
11910                 }
11911
11912               /* We want to keep the location were found it, and the type
11913                  we found. */
11914               *where_found = decl;
11915               *type_found = type;
11916
11917               /* Generate the correct expression for field access from
11918                  qualified this */
11919               if (from_qualified_this)
11920                 {
11921                   field_decl = build_outer_field_access (qual_wfl, field_decl);
11922                   from_qualified_this = 0;
11923                 }
11924
11925               /* This is the decl found and eventually the next one to
11926                  search from */
11927               decl = field_decl;
11928             }
11929           from_type = 0;
11930           type = QUAL_DECL_TYPE (decl);
11931
11932           /* Sneak preview. If decl is qualified by a `new', report
11933              the error here to be accurate on the peculiar construct */
11934           if (TREE_CHAIN (q) 
11935               && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
11936               && !JREFERENCE_TYPE_P (type))
11937             {
11938               parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'", 
11939                                    lang_printable_name (type, 0));
11940               return 1;
11941             }
11942         }
11943       /* `q' might have changed due to a after package resolution
11944          re-qualification */
11945       if (!q)
11946         break;
11947     }
11948   *found_decl = decl;
11949   return 0;
11950 }
11951
11952 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
11953    can't be accessed from REFERENCE (a record type). */
11954
11955 static int
11956 not_accessible_p (reference, member, from_super)
11957      tree reference, member;
11958      int from_super;
11959 {
11960   int access_flag = get_access_flags_from_decl (member);
11961
11962   /* Access always granted for members declared public */
11963   if (access_flag & ACC_PUBLIC)
11964     return 0;
11965   
11966   /* Check access on protected members */
11967   if (access_flag & ACC_PROTECTED)
11968     {
11969       /* Access granted if it occurs from within the package
11970          containing the class in which the protected member is
11971          declared */
11972       if (class_in_current_package (DECL_CONTEXT (member)))
11973         return 0;
11974
11975       /* If accessed with the form `super.member', then access is granted */
11976       if (from_super)
11977         return 0;
11978
11979       /* Otherwise, access is granted if occuring from the class where
11980          member is declared or a subclass of it */
11981       if (inherits_from_p (reference, DECL_CONTEXT (member)))
11982         return 0;
11983       return 1;
11984     }
11985
11986   /* Check access on private members. Access is granted only if it
11987      occurs from within the class in which it is declared. Exceptions
11988      are accesses from inner-classes. This section is probably not
11989      complete. FIXME */
11990   if (access_flag & ACC_PRIVATE)
11991     return (current_class == DECL_CONTEXT (member) ? 0 : 
11992             (INNER_CLASS_TYPE_P (current_class) ? 0 : 1));
11993
11994   /* Default access are permitted only when occuring within the
11995      package in which the type (REFERENCE) is declared. In other words,
11996      REFERENCE is defined in the current package */
11997   if (ctxp->package)
11998     return !class_in_current_package (reference);
11999
12000   /* Otherwise, access is granted */
12001   return 0;
12002 }
12003
12004 /* Test deprecated decl access.  */
12005 static void
12006 check_deprecation (wfl, decl)
12007      tree wfl, decl;
12008 {
12009   const char *file = DECL_SOURCE_FILE (decl);
12010   /* Complain if the field is deprecated and the file it was defined
12011      in isn't compiled at the same time the file which contains its
12012      use is */
12013   if (DECL_DEPRECATED (decl) 
12014       && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
12015     {
12016       char the [20];
12017       switch (TREE_CODE (decl))
12018         {
12019         case FUNCTION_DECL:
12020           strcpy (the, "method");
12021           break;
12022         case FIELD_DECL:
12023           strcpy (the, "field");
12024           break;
12025         case TYPE_DECL:
12026           strcpy (the, "class");
12027           break;
12028         default:
12029           fatal ("unexpected DECL code - check_deprecation");
12030         }
12031       parse_warning_context 
12032         (wfl, "The %s `%s' in class `%s' has been deprecated", 
12033          the, lang_printable_name (decl, 0),
12034          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
12035     }
12036 }
12037
12038 /* Returns 1 if class was declared in the current package, 0 otherwise */
12039
12040 static int
12041 class_in_current_package (class)
12042      tree class;
12043 {
12044   static tree cache = NULL_TREE;
12045   int qualified_flag;
12046   tree left;
12047
12048   if (cache == class)
12049     return 1;
12050
12051   qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
12052
12053   /* If the current package is empty and the name of CLASS is
12054      qualified, class isn't in the current package.  If there is a
12055      current package and the name of the CLASS is not qualified, class
12056      isn't in the current package */
12057   if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
12058     return 0;
12059
12060   /* If there is not package and the name of CLASS isn't qualified,
12061      they belong to the same unnamed package */
12062   if (!ctxp->package && !qualified_flag)
12063     return 1;
12064
12065   /* Compare the left part of the name of CLASS with the package name */
12066   breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
12067   if (ctxp->package == left)
12068     {
12069       cache = class;
12070       return 1;
12071     }
12072   return 0;
12073 }
12074
12075 /* This function may generate code to access DECL from WHERE. This is
12076    done only if certain conditions meet.  */
12077
12078 static tree
12079 maybe_access_field (decl, where, type)
12080   tree decl, where, type;
12081 {
12082   if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
12083       && !FIELD_STATIC (decl))
12084     decl = build_field_ref (where ? where : current_this, 
12085                             (type ? type : DECL_CONTEXT (decl)),
12086                             DECL_NAME (decl));
12087   return decl;
12088 }
12089
12090 /* Build a method invocation, by patching PATCH. If non NULL
12091    and according to the situation, PRIMARY and WHERE may be
12092    used. IS_STATIC is set to 1 if the invoked function is static. */
12093
12094 static tree
12095 patch_method_invocation (patch, primary, where, is_static, ret_decl)
12096      tree patch, primary, where;
12097      int *is_static;
12098      tree *ret_decl;
12099 {
12100   tree wfl = TREE_OPERAND (patch, 0);
12101   tree args = TREE_OPERAND (patch, 1);
12102   tree name = EXPR_WFL_NODE (wfl);
12103   tree list;
12104   int is_static_flag = 0;
12105   int is_super_init = 0;
12106   tree this_arg = NULL_TREE;
12107   
12108   /* Should be overriden if everything goes well. Otherwise, if
12109      something fails, it should keep this value. It stop the
12110      evaluation of a bogus assignment. See java_complete_tree,
12111      MODIFY_EXPR: for the reasons why we sometimes want to keep on
12112      evaluating an assignment */
12113   TREE_TYPE (patch) = error_mark_node;
12114
12115   /* Since lookup functions are messing with line numbers, save the
12116      context now.  */
12117   java_parser_context_save_global ();
12118
12119   /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
12120
12121   /* Resolution of qualified name, excluding constructors */
12122   if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
12123     {
12124       tree identifier, identifier_wfl, type, resolved;
12125       /* Extract the last IDENTIFIER of the qualified
12126          expression. This is a wfl and we will use it's location
12127          data during error report. */
12128       identifier_wfl = cut_identifier_in_qualified (wfl);
12129       identifier = EXPR_WFL_NODE (identifier_wfl);
12130       
12131       /* Given the context, IDENTIFIER is syntactically qualified
12132          as a MethodName. We need to qualify what's before */
12133       qualify_ambiguous_name (wfl);
12134       resolved = resolve_field_access (wfl, NULL, NULL);
12135
12136       if (resolved == error_mark_node)
12137         PATCH_METHOD_RETURN_ERROR ();
12138
12139       type = GET_SKIP_TYPE (resolved);
12140       resolve_and_layout (type, NULL_TREE);
12141       
12142       if (JPRIMITIVE_TYPE_P (type))
12143         {
12144         parse_error_context
12145           (identifier_wfl,
12146           "Can't invoke a method on primitive type `%s'",
12147           IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
12148         PATCH_METHOD_RETURN_ERROR ();         
12149       }      
12150       
12151       list = lookup_method_invoke (0, identifier_wfl, type, identifier, args);
12152       args = nreverse (args);
12153
12154       /* We're resolving a call from a type */
12155       if (TREE_CODE (resolved) == TYPE_DECL)
12156         {
12157           if (CLASS_INTERFACE (resolved))
12158             {
12159               parse_error_context
12160                 (identifier_wfl,
12161                 "Can't make static reference to method `%s' in interface `%s'",
12162                  IDENTIFIER_POINTER (identifier), 
12163                  IDENTIFIER_POINTER (name));
12164               PATCH_METHOD_RETURN_ERROR ();
12165             }
12166           if (list && !METHOD_STATIC (list))
12167             {
12168               char *fct_name = xstrdup (lang_printable_name (list, 0));
12169               parse_error_context 
12170                 (identifier_wfl,
12171                  "Can't make static reference to method `%s %s' in class `%s'",
12172                  lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
12173                  fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
12174               free (fct_name);
12175               PATCH_METHOD_RETURN_ERROR ();
12176             }
12177         }
12178       else
12179         this_arg = primary = resolved;
12180       
12181       /* IDENTIFIER_WFL will be used to report any problem further */
12182       wfl = identifier_wfl;
12183     }
12184   /* Resolution of simple names, names generated after a primary: or
12185      constructors */
12186   else
12187     {
12188       tree class_to_search = NULL_TREE;
12189       int lc;                   /* Looking for Constructor */
12190       
12191       /* We search constructor in their target class */
12192       if (CALL_CONSTRUCTOR_P (patch))
12193         {
12194           if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12195             class_to_search = EXPR_WFL_NODE (wfl);
12196           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) == 
12197                    this_identifier_node)
12198             class_to_search = NULL_TREE;
12199           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12200                    super_identifier_node)
12201             {
12202               is_super_init = 1;
12203               if (CLASSTYPE_SUPER (current_class))
12204                 class_to_search = 
12205                   DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
12206               else
12207                 {
12208                   parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object");
12209                   PATCH_METHOD_RETURN_ERROR ();
12210                 }
12211             }
12212
12213           /* Class to search is NULL if we're searching the current one */
12214           if (class_to_search)
12215             {
12216               class_to_search = resolve_and_layout (class_to_search, wfl);
12217
12218               if (!class_to_search)
12219                 {
12220                   parse_error_context 
12221                     (wfl, "Class `%s' not found in type declaration",
12222                      IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12223                   PATCH_METHOD_RETURN_ERROR ();
12224                 }
12225               
12226               /* Can't instantiate an abstract class, but we can
12227                  invoke it's constructor. It's use within the `new'
12228                  context is denied here. */
12229               if (CLASS_ABSTRACT (class_to_search) 
12230                   && TREE_CODE (patch) == NEW_CLASS_EXPR)
12231                 {
12232                   parse_error_context 
12233                     (wfl, "Class `%s' is an abstract class. It can't be instantiated",
12234                      IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12235                   PATCH_METHOD_RETURN_ERROR ();
12236                 }
12237
12238               class_to_search = TREE_TYPE (class_to_search);
12239             }
12240           else
12241             class_to_search = current_class;
12242           lc = 1;
12243         }
12244       /* This is a regular search in the local class, unless an
12245          alternate class is specified. */
12246       else
12247         {
12248           class_to_search = (where ? where : current_class);
12249           lc = 0;
12250         }
12251
12252       /* NAME is a simple identifier or comes from a primary. Search
12253          in the class whose declaration contain the method being
12254          invoked. */
12255       resolve_and_layout (class_to_search, NULL_TREE);
12256
12257       list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
12258       /* Don't continue if no method were found, as the next statement
12259          can't be executed then. */
12260       if (!list)
12261         PATCH_METHOD_RETURN_ERROR ();
12262
12263       /* Check for static reference if non static methods */
12264       if (check_for_static_method_reference (wfl, patch, list, 
12265                                              class_to_search, primary))
12266         PATCH_METHOD_RETURN_ERROR ();
12267
12268       /* Check for inner classes creation from illegal contexts */
12269       if (lc && (INNER_CLASS_TYPE_P (class_to_search)
12270                  && !CLASS_STATIC (TYPE_NAME (class_to_search)))
12271           && INNER_ENCLOSING_SCOPE_CHECK (class_to_search))
12272         {
12273           parse_error_context 
12274             (wfl, "No enclosing instance for inner class `%s' is in scope%s",
12275              lang_printable_name (class_to_search, 0),
12276              (!current_this ? "" :
12277               "; an explicit one must be provided when creating this inner class"));
12278           PATCH_METHOD_RETURN_ERROR ();
12279         }
12280
12281       /* Non static methods are called with the current object extra
12282          argument. If patch a `new TYPE()', the argument is the value
12283          returned by the object allocator. If method is resolved as a
12284          primary, use the primary otherwise use the current THIS. */
12285       args = nreverse (args);
12286       if (TREE_CODE (patch) != NEW_CLASS_EXPR)
12287         {
12288           this_arg = primary ? primary : current_this;
12289
12290           /* If we're using an access method, things are different.
12291              There are two familly of cases:
12292
12293              1) We're not generating bytecodes:
12294
12295              - LIST is non static. It's invocation is transformed from
12296                x(a1,...,an) into this$<n>.x(a1,....an).
12297              - LIST is static. It's invocation is transformed from
12298                x(a1,...,an) into TYPE_OF(this$<n>).x(a1,....an)
12299
12300              2) We're generating bytecodes:
12301              
12302              - LIST is non static. It's invocation is transformed from
12303                x(a1,....,an) into access$<n>(this$<n>,a1,...,an).
12304              - LIST is static. It's invocation is transformed from
12305                x(a1,....,an) into TYPEOF(this$<n>).x(a1,....an).
12306
12307              Of course, this$<n> can be abitrary complex, ranging from
12308              this$0 (the immediate outer context) to 
12309              access$0(access$0(...(this$0))). 
12310              
12311              maybe_use_access_method returns a non zero value if the
12312              this_arg has to be moved into the (then generated) stub
12313              argument list. In the mean time, the selected function
12314              might have be replaced by a generated stub. */
12315           if (maybe_use_access_method (is_super_init, &list, &this_arg))
12316             args = tree_cons (NULL_TREE, this_arg, args);
12317         }
12318     }
12319
12320   /* Merge point of all resolution schemes. If we have nothing, this
12321      is an error, already signaled */
12322   if (!list) 
12323     PATCH_METHOD_RETURN_ERROR ();
12324
12325   /* Check accessibility, position the is_static flag, build and
12326      return the call */
12327   if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
12328     {
12329       char *fct_name = xstrdup (lang_printable_name (list, 0));
12330       parse_error_context 
12331         (wfl, "Can't access %s method `%s %s.%s' from `%s'",
12332          java_accstring_lookup (get_access_flags_from_decl (list)),
12333          lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
12334          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))), 
12335          fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
12336       free (fct_name);
12337       PATCH_METHOD_RETURN_ERROR ();
12338     }
12339   check_deprecation (wfl, list);
12340
12341   /* If invoking a innerclass constructor, there are hidden parameters
12342      to pass */
12343   if (TREE_CODE (patch) == NEW_CLASS_EXPR 
12344       && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12345     {
12346       /* And make sure we add the accessed local variables to be saved
12347          in field aliases. */
12348       args = build_alias_initializer_parameter_list
12349         (AIPL_FUNCTION_CTOR_INVOCATION, DECL_CONTEXT (list), args, NULL);
12350
12351       /* We have to reverse things. Find out why. FIXME */
12352       if (ANONYMOUS_CLASS_P (DECL_CONTEXT (list)))
12353         args = nreverse (args);
12354       
12355       /* Secretely pass the current_this/primary as a second argument */
12356       if (primary || current_this)
12357         args = tree_cons (NULL_TREE, (primary ? primary : current_this), args);
12358       else
12359         args = tree_cons (NULL_TREE, integer_zero_node, args);
12360     }
12361
12362   /* This handles the situation where a constructor invocation needs
12363      to have an enclosing context passed as a second parameter (the
12364      constructor is one of an inner class. We extract it from the
12365      current function.  */
12366   if (is_super_init && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12367     {
12368       tree enclosing_decl = DECL_CONTEXT (TYPE_NAME (current_class));
12369       tree extra_arg;
12370
12371       if (ANONYMOUS_CLASS_P (current_class) || !DECL_CONTEXT (enclosing_decl))
12372         {
12373           extra_arg = DECL_FUNCTION_BODY (current_function_decl);
12374           extra_arg = TREE_CHAIN (BLOCK_EXPR_DECLS (extra_arg));
12375         }
12376       else
12377         {
12378           tree dest = TREE_TYPE (DECL_CONTEXT (enclosing_decl));
12379           extra_arg = 
12380             build_access_to_thisn (TREE_TYPE (enclosing_decl), dest, 0);
12381           extra_arg = java_complete_tree (extra_arg);
12382         }
12383       args = tree_cons (NULL_TREE, extra_arg, args);
12384     }
12385
12386   is_static_flag = METHOD_STATIC (list);
12387   if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
12388     args = tree_cons (NULL_TREE, this_arg, args);
12389
12390   /* In the context of an explicit constructor invocation, we can't
12391      invoke any method relying on `this'. Exceptions are: we're
12392      invoking a static function, primary exists and is not the current
12393      this, we're creating a new object. */
12394   if (ctxp->explicit_constructor_p 
12395       && !is_static_flag 
12396       && (!primary || primary == current_this)
12397       && (TREE_CODE (patch) != NEW_CLASS_EXPR))
12398     {
12399       parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
12400       PATCH_METHOD_RETURN_ERROR ();
12401     }
12402   java_parser_context_restore_global ();
12403   if (is_static) 
12404     *is_static = is_static_flag;
12405   /* Sometimes, we want the decl of the selected method. Such as for
12406      EH checking */
12407   if (ret_decl)
12408     *ret_decl = list;
12409   patch = patch_invoke (patch, list, args);
12410   if (is_super_init && CLASS_HAS_FINIT_P (current_class))
12411     {
12412       tree finit_parms, finit_call;
12413       
12414       /* Prepare to pass hidden parameters to $finit$, if any. */
12415       finit_parms = build_alias_initializer_parameter_list 
12416         (AIPL_FUNCTION_FINIT_INVOCATION, current_class, NULL_TREE, NULL);
12417
12418       finit_call = 
12419         build_method_invocation (build_wfl_node (finit_identifier_node),
12420                                  finit_parms);
12421
12422       /* Generate the code used to initialize fields declared with an
12423          initialization statement and build a compound statement along
12424          with the super constructor invocation. */
12425       patch = build (COMPOUND_EXPR, void_type_node, patch,
12426                      java_complete_tree (finit_call));
12427       CAN_COMPLETE_NORMALLY (patch) = 1;
12428     }
12429   return patch;
12430 }
12431
12432 /* Check that we're not trying to do a static reference to a method in
12433    non static method. Return 1 if it's the case, 0 otherwise. */
12434
12435 static int
12436 check_for_static_method_reference (wfl, node, method, where, primary)
12437      tree wfl, node, method, where, primary;
12438 {
12439   if (METHOD_STATIC (current_function_decl) 
12440       && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
12441     {
12442       char *fct_name = xstrdup (lang_printable_name (method, 0));
12443       parse_error_context 
12444         (wfl, "Can't make static reference to method `%s %s' in class `%s'", 
12445          lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
12446          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
12447       free (fct_name);
12448       return 1;
12449     }
12450   return 0;
12451 }
12452
12453 /* Fix the invocation of *MDECL if necessary in the case of a
12454    invocation from an inner class. *THIS_ARG might be modified
12455    appropriately and an alternative access to *MDECL might be
12456    returned.  */
12457
12458 static int
12459 maybe_use_access_method (is_super_init, mdecl, this_arg)
12460      int is_super_init;
12461      tree *mdecl, *this_arg;
12462 {
12463   tree ctx;
12464   tree md = *mdecl, ta = *this_arg;
12465   int to_return = 0;
12466   int non_static_context = !METHOD_STATIC (md);
12467
12468   if (is_super_init 
12469       || DECL_CONTEXT (md) == current_class
12470       || !PURE_INNER_CLASS_TYPE_P (current_class) 
12471       || DECL_FINIT_P (md))
12472     return 0;
12473   
12474   /* If we're calling a method found in an enclosing class, generate
12475      what it takes to retrieve the right this. Don't do that if we're
12476      invoking a static method. */
12477
12478   if (non_static_context)
12479     {
12480       ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
12481       if (ctx == DECL_CONTEXT (md))
12482         {
12483           ta = build_current_thisn (current_class);
12484           ta = build_wfl_node (ta);
12485         }
12486       else
12487         {
12488           tree type = ctx;
12489           while (type)
12490             {
12491               maybe_build_thisn_access_method (type);
12492               if (type == DECL_CONTEXT (md))
12493                 {
12494                   ta = build_access_to_thisn (ctx, type, 0);
12495                   break;
12496                 }
12497               type = (DECL_CONTEXT (TYPE_NAME (type)) ? 
12498                       TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))) : NULL_TREE);
12499             }
12500         }
12501       ta = java_complete_tree (ta);
12502     }
12503
12504   /* We might have to use an access method to get to MD. We can
12505      break the method access rule as far as we're not generating
12506      bytecode */
12507   if (METHOD_PRIVATE (md) && flag_emit_class_files)
12508     {
12509       md = build_outer_method_access_method (md);
12510       to_return = 1;
12511     }
12512
12513   *mdecl = md;
12514   *this_arg = ta;
12515
12516   /* Returnin a non zero value indicates we were doing a non static
12517      method invokation that is now a static invocation. It will have
12518      callee displace `this' to insert it in the regular argument
12519      list. */
12520   return (non_static_context && to_return);
12521 }
12522
12523 /* Patch an invoke expression METHOD and ARGS, based on its invocation
12524    mode.  */
12525
12526 static tree
12527 patch_invoke (patch, method, args)
12528      tree patch, method, args;
12529 {
12530   tree dtable, func;
12531   tree original_call, t, ta;
12532   tree cond = NULL_TREE;
12533
12534   /* Last step for args: convert build-in types. If we're dealing with
12535      a new TYPE() type call, the first argument to the constructor
12536      isn't found in the incoming argument list, but delivered by
12537      `new' */
12538   t = TYPE_ARG_TYPES (TREE_TYPE (method));
12539   if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12540     t = TREE_CHAIN (t);
12541   for (ta = args; t != end_params_node && ta; 
12542        t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
12543     if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
12544         TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
12545       TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
12546
12547   /* Resolve unresolved returned type isses */
12548   t = TREE_TYPE (TREE_TYPE (method));
12549   if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
12550     resolve_and_layout (TREE_TYPE (t), NULL);
12551
12552   if (flag_emit_class_files || flag_emit_xref)
12553     func = method;
12554   else
12555     {
12556       tree signature = build_java_signature (TREE_TYPE (method));
12557       switch (invocation_mode (method, CALL_USING_SUPER (patch)))
12558         {
12559         case INVOKE_VIRTUAL:
12560           dtable = invoke_build_dtable (0, args);
12561           func = build_invokevirtual (dtable, method);
12562           break;
12563
12564         case INVOKE_NONVIRTUAL:
12565           /* If the object for the method call is null, we throw an
12566              exception.  We don't do this if the object is the current
12567              method's `this'.  In other cases we just rely on an
12568              optimization pass to eliminate redundant checks.  */
12569           if (TREE_VALUE (args) != current_this)
12570             {
12571               /* We use a SAVE_EXPR here to make sure we only evaluate
12572                  the new `self' expression once.  */
12573               tree save_arg = save_expr (TREE_VALUE (args));
12574               TREE_VALUE (args) = save_arg;
12575               cond = build (EQ_EXPR, boolean_type_node, save_arg,
12576                             null_pointer_node);
12577             }
12578           /* Fall through.  */
12579
12580         case INVOKE_SUPER:
12581         case INVOKE_STATIC:
12582           func = build_known_method_ref (method, TREE_TYPE (method),
12583                                          DECL_CONTEXT (method),
12584                                          signature, args);
12585           break;
12586
12587         case INVOKE_INTERFACE:
12588           dtable = invoke_build_dtable (1, args);
12589           func = build_invokeinterface (dtable, method);
12590           break;
12591
12592         default:
12593           fatal ("internal error - unknown invocation_mode result");
12594         }
12595
12596       /* Ensure self_type is initialized, (invokestatic). FIXME */
12597       func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
12598     }
12599
12600   TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
12601   TREE_OPERAND (patch, 0) = func;
12602   TREE_OPERAND (patch, 1) = args;
12603   original_call = patch;
12604
12605   /* We're processing a `new TYPE ()' form. New is called and its
12606      returned value is the first argument to the constructor. We build
12607      a COMPOUND_EXPR and use saved expression so that the overall NEW
12608      expression value is a pointer to a newly created and initialized
12609      class. */
12610   if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
12611     {
12612       tree class = DECL_CONTEXT (method);
12613       tree c1, saved_new, size, new;
12614       if (flag_emit_class_files || flag_emit_xref)
12615         {
12616           TREE_TYPE (patch) = build_pointer_type (class);
12617           return patch;
12618         }
12619       if (!TYPE_SIZE (class))
12620         safe_layout_class (class);
12621       size = size_in_bytes (class);
12622       new = build (CALL_EXPR, promote_type (class),
12623                    build_address_of (alloc_object_node),
12624                    tree_cons (NULL_TREE, build_class_ref (class),
12625                               build_tree_list (NULL_TREE, 
12626                                                size_in_bytes (class))),
12627                    NULL_TREE);
12628       saved_new = save_expr (new);
12629       c1 = build_tree_list (NULL_TREE, saved_new);
12630       TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
12631       TREE_OPERAND (original_call, 1) = c1;
12632       TREE_SET_CODE (original_call, CALL_EXPR);
12633       patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
12634     }
12635
12636   /* If COND is set, then we are building a check to see if the object
12637      is NULL.  */
12638   if (cond != NULL_TREE)
12639     {
12640       /* We have to make the `then' branch a compound expression to
12641          make the types turn out right.  This seems bizarre.  */
12642       patch = build (COND_EXPR, TREE_TYPE (patch), cond,
12643                      build (COMPOUND_EXPR, TREE_TYPE (patch),
12644                             build (CALL_EXPR, void_type_node,
12645                                    build_address_of (soft_nullpointer_node),
12646                                    NULL_TREE, NULL_TREE),
12647                             (FLOAT_TYPE_P (TREE_TYPE (patch))
12648                              ? build_real (TREE_TYPE (patch), dconst0)
12649                              : build1 (CONVERT_EXPR, TREE_TYPE (patch),
12650                                        integer_zero_node))),
12651                      patch);
12652       TREE_SIDE_EFFECTS (patch) = 1;
12653     }
12654
12655   return patch;
12656 }
12657
12658 static int
12659 invocation_mode (method, super)
12660      tree method;
12661      int super;
12662 {
12663   int access = get_access_flags_from_decl (method);
12664
12665   if (super)
12666     return INVOKE_SUPER;
12667
12668   if (access & ACC_STATIC)
12669     return INVOKE_STATIC;
12670
12671   /* We have to look for a constructor before we handle nonvirtual
12672      calls; otherwise the constructor will look nonvirtual.  */
12673   if (DECL_CONSTRUCTOR_P (method))
12674     return INVOKE_STATIC;
12675
12676   if (access & ACC_FINAL || access & ACC_PRIVATE)
12677     return INVOKE_NONVIRTUAL;
12678
12679   if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
12680     return INVOKE_NONVIRTUAL;
12681
12682   if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
12683     return INVOKE_INTERFACE;
12684
12685   return INVOKE_VIRTUAL;
12686 }
12687
12688 /* Retrieve a refined list of matching methods. It covers the step
12689    15.11.2 (Compile-Time Step 2) */
12690
12691 static tree
12692 lookup_method_invoke (lc, cl, class, name, arg_list)
12693      int lc;
12694      tree cl;
12695      tree class, name, arg_list;
12696 {
12697   tree atl = end_params_node;           /* Arg Type List */
12698   tree method, signature, list, node;
12699   const char *candidates;               /* Used for error report */
12700   char *dup;
12701
12702   /* Fix the arguments */
12703   for (node = arg_list; node; node = TREE_CHAIN (node))
12704     {
12705       tree current_arg = TREE_TYPE (TREE_VALUE (node));
12706       /* Non primitive type may have to be resolved */
12707       if (!JPRIMITIVE_TYPE_P (current_arg))
12708         resolve_and_layout (current_arg, NULL_TREE);
12709       /* And promoted */
12710       if (TREE_CODE (current_arg) == RECORD_TYPE)
12711         current_arg = promote_type (current_arg);
12712       atl = tree_cons (NULL_TREE, current_arg, atl);
12713     }
12714
12715   /* Presto. If we're dealing with an anonymous class and a
12716      constructor call, generate the right constructor now, since we
12717      know the arguments' types. */
12718
12719   if (lc && ANONYMOUS_CLASS_P (class))
12720     craft_constructor (TYPE_NAME (class), atl);
12721
12722   /* Find all candidates and then refine the list, searching for the
12723      most specific method. */
12724   list = find_applicable_accessible_methods_list (lc, class, name, atl);
12725   list = find_most_specific_methods_list (list);
12726   if (list && !TREE_CHAIN (list))
12727     return TREE_VALUE (list);
12728
12729   /* Issue an error. List candidates if any. Candidates are listed
12730      only if accessible (non accessible methods may end-up here for
12731      the sake of a better error report). */
12732   candidates = NULL;
12733   if (list)
12734     {
12735       tree current;
12736       obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
12737       for (current = list; current; current = TREE_CHAIN (current))
12738         {
12739           tree cm = TREE_VALUE (current);
12740           char string [4096];
12741           if (!cm || not_accessible_p (class, cm, 0))
12742             continue;
12743           sprintf 
12744             (string, "  `%s' in `%s'%s",
12745              get_printable_method_name (cm),
12746              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
12747              (TREE_CHAIN (current) ? "\n" : ""));
12748           obstack_grow (&temporary_obstack, string, strlen (string));
12749         }
12750       obstack_1grow (&temporary_obstack, '\0');
12751       candidates = obstack_finish (&temporary_obstack);
12752     }
12753   /* Issue the error message */
12754   method = make_node (FUNCTION_TYPE);
12755   TYPE_ARG_TYPES (method) = atl;
12756   signature = build_java_argument_signature (method);
12757   dup = xstrdup (lang_printable_name (class, 0));
12758   parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
12759                        (lc ? "constructor" : "method"),
12760                        (lc ? dup : IDENTIFIER_POINTER (name)),
12761                        IDENTIFIER_POINTER (signature), dup,
12762                        (candidates ? candidates : ""));
12763   free (dup);
12764   return NULL_TREE;
12765 }
12766
12767 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
12768    when we're looking for a constructor. */
12769
12770 static tree
12771 find_applicable_accessible_methods_list (lc, class, name, arglist)
12772      int lc;
12773      tree class, name, arglist;
12774 {
12775   static int object_done = 0;
12776   tree list = NULL_TREE, all_list = NULL_TREE;
12777
12778   if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
12779     {
12780       load_class (class, 1);
12781       safe_layout_class (class);
12782     }
12783
12784   /* Search interfaces */
12785   if (TREE_CODE (TYPE_NAME (class)) == TYPE_DECL 
12786       && CLASS_INTERFACE (TYPE_NAME (class)))
12787     {
12788       static struct hash_table t, *searched_interfaces = NULL;
12789       static int search_not_done = 0;
12790       int i, n;
12791       tree basetype_vec = TYPE_BINFO_BASETYPES (class);
12792
12793       /* Search in the hash table, otherwise create a new one if
12794          necessary and insert the new entry. */
12795
12796       if (searched_interfaces)
12797         {
12798           if (hash_lookup (searched_interfaces, 
12799                            (const hash_table_key) class, FALSE, NULL))
12800             return NULL;
12801         }
12802       else
12803         {
12804           hash_table_init (&t, hash_newfunc, java_hash_hash_tree_node,
12805                            java_hash_compare_tree_node);
12806           searched_interfaces = &t;
12807         }
12808
12809       hash_lookup (searched_interfaces, 
12810                    (const hash_table_key) class, TRUE, NULL);
12811
12812       search_applicable_methods_list (lc, TYPE_METHODS (class), 
12813                                       name, arglist, &list, &all_list);
12814       n = TREE_VEC_LENGTH (basetype_vec);
12815       for (i = 1; i < n; i++)
12816         {
12817           tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12818           tree rlist;
12819
12820           search_not_done++;
12821           rlist = find_applicable_accessible_methods_list (lc,  t, name, 
12822                                                            arglist);
12823           list = chainon (rlist, list);
12824           search_not_done--;
12825         }
12826
12827       /* We're done. Reset the searched interfaces list and finally search
12828          java.lang.Object */
12829       if (!search_not_done)
12830         {  
12831           if (!object_done)
12832             search_applicable_methods_list (lc, 
12833                                             TYPE_METHODS (object_type_node),
12834                                             name, arglist, &list, &all_list);
12835           hash_table_free (searched_interfaces);
12836           searched_interfaces = NULL;  
12837         }
12838     }
12839   /* Search classes */
12840   else
12841     {
12842       tree sc = class;
12843       int seen_inner_class = 0;
12844       search_applicable_methods_list (lc, TYPE_METHODS (class), 
12845                                       name, arglist, &list, &all_list);
12846
12847       /* We must search all interfaces of this class */
12848       if (!lc)
12849       {
12850         tree basetype_vec = TYPE_BINFO_BASETYPES (sc);
12851         int n = TREE_VEC_LENGTH (basetype_vec), i;
12852         object_done = 1;
12853         for (i = 1; i < n; i++)
12854           {
12855             tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12856             if (t != object_type_node)
12857               {
12858                 tree rlist
12859                   = find_applicable_accessible_methods_list (lc, t,
12860                                                              name, arglist);
12861                 list = chainon (rlist, list);
12862               }
12863           }
12864         object_done = 0;
12865       }
12866
12867       /* Search enclosing context of inner classes before looking
12868          ancestors up. */
12869       while (!lc && INNER_CLASS_TYPE_P (class))
12870         {
12871           tree rlist;
12872           seen_inner_class = 1;
12873           class = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
12874           rlist = find_applicable_accessible_methods_list (lc, class, 
12875                                                            name, arglist);
12876           list = chainon (rlist, list);
12877         }
12878
12879       if (!lc && seen_inner_class 
12880           && TREE_TYPE (DECL_CONTEXT (TYPE_NAME (sc))) == CLASSTYPE_SUPER (sc))
12881         class = CLASSTYPE_SUPER (sc);
12882       else
12883         class = sc;
12884
12885       for (class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class)); 
12886         class; class = CLASSTYPE_SUPER (class))
12887        search_applicable_methods_list (lc, TYPE_METHODS (class), 
12888                                        name, arglist, &list, &all_list);
12889     }
12890
12891   /* Either return the list obtained or all selected (but
12892      inaccessible) methods for better error report. */
12893   return (!list ? all_list : list);
12894 }
12895
12896 /* Effectively search for the approriate method in method */
12897
12898 static void 
12899 search_applicable_methods_list (lc, method, name, arglist, list, all_list)
12900      int lc;
12901      tree method, name, arglist;
12902      tree *list, *all_list;
12903 {
12904   for (; method; method = TREE_CHAIN (method))
12905     {
12906       /* When dealing with constructor, stop here, otherwise search
12907          other classes */
12908       if (lc && !DECL_CONSTRUCTOR_P (method))
12909         continue;
12910       else if (!lc && (DECL_CONSTRUCTOR_P (method) 
12911                        || (GET_METHOD_NAME (method) != name)))
12912         continue;
12913           
12914       if (argument_types_convertible (method, arglist))
12915         {
12916           /* Retain accessible methods only */
12917           if (!not_accessible_p (DECL_CONTEXT (current_function_decl), 
12918                                  method, 0))
12919             *list = tree_cons (NULL_TREE, method, *list);
12920           else
12921             /* Also retain all selected method here */
12922             *all_list = tree_cons (NULL_TREE, method, *list);
12923         }
12924     }
12925 }    
12926
12927 /* 15.11.2.2 Choose the Most Specific Method */
12928
12929 static tree
12930 find_most_specific_methods_list (list)
12931      tree list;
12932 {
12933   int max = 0;
12934   int abstract, candidates;
12935   tree current, new_list = NULL_TREE;
12936   for (current = list; current; current = TREE_CHAIN (current))
12937     {
12938       tree method;
12939       DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
12940
12941       for (method = list; method; method = TREE_CHAIN (method))
12942         {
12943           /* Don't test a method against itself */
12944           if (method == current)
12945             continue;
12946
12947           /* Compare arguments and location where method where declared */
12948           if (argument_types_convertible (TREE_VALUE (method), 
12949                                           TREE_VALUE (current))
12950               && valid_method_invocation_conversion_p 
12951                    (DECL_CONTEXT (TREE_VALUE (method)), 
12952                     DECL_CONTEXT (TREE_VALUE (current))))
12953             {
12954               int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
12955               max = (v > max ? v : max);
12956             }
12957         }
12958     }
12959
12960   /* Review the list and select the maximally specific methods */
12961   for (current = list, abstract = -1, candidates = -1;
12962        current; current = TREE_CHAIN (current))
12963     if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12964       {
12965         new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12966         abstract += (METHOD_ABSTRACT (TREE_VALUE (current)) ? 1 : 0);
12967         candidates++;
12968       }
12969
12970   /* If we have several and they're all abstract, just pick the
12971      closest one. */
12972   if (candidates > 0 && (candidates == abstract))
12973     {
12974       new_list = nreverse (new_list);
12975       TREE_CHAIN (new_list) = NULL_TREE;
12976     }
12977
12978   /* We have several, we couldn't find a most specific, all but one are
12979      abstract, we pick the only non abstract one. */
12980   if (candidates > 0 && !max && (candidates == abstract+1))
12981     {
12982       for (current = new_list; current; current = TREE_CHAIN (current))
12983         if (!METHOD_ABSTRACT (TREE_VALUE (current)))
12984           {
12985             TREE_CHAIN (current) = NULL_TREE;
12986             new_list = current;
12987           }
12988     }
12989
12990   /* If we can't find one, lower expectations and try to gather multiple
12991      maximally specific methods */
12992   while (!new_list && max)
12993     {
12994       while (--max > 0)
12995         {
12996           if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12997             new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12998         }
12999     }
13000
13001   return new_list;
13002 }
13003
13004 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
13005    converted by method invocation conversion (5.3) to the type of the
13006    corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
13007    to change less often than M1. */
13008
13009 static int
13010 argument_types_convertible (m1, m2_or_arglist)
13011     tree m1, m2_or_arglist;
13012 {
13013   static tree m2_arg_value = NULL_TREE;
13014   static tree m2_arg_cache = NULL_TREE;
13015
13016   register tree m1_arg, m2_arg;
13017
13018   SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
13019
13020   if (m2_arg_value == m2_or_arglist)
13021     m2_arg = m2_arg_cache;
13022   else
13023     {
13024       /* M2_OR_ARGLIST can be a function DECL or a raw list of
13025          argument types */
13026       if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
13027         {
13028           m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
13029           if (!METHOD_STATIC (m2_or_arglist))
13030             m2_arg = TREE_CHAIN (m2_arg);
13031         }
13032       else
13033         m2_arg = m2_or_arglist;
13034
13035       m2_arg_value = m2_or_arglist;
13036       m2_arg_cache = m2_arg;
13037     }
13038
13039   while (m1_arg != end_params_node && m2_arg != end_params_node)
13040     {
13041       resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
13042       if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
13043                                                  TREE_VALUE (m2_arg)))
13044         break;
13045       m1_arg = TREE_CHAIN (m1_arg);
13046       m2_arg = TREE_CHAIN (m2_arg);
13047     }
13048   return m1_arg == end_params_node && m2_arg == end_params_node;
13049 }
13050
13051 /* Qualification routines */
13052
13053 static void
13054 qualify_ambiguous_name (id)
13055      tree id;
13056 {
13057   tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
13058     saved_current_class;
13059   int again, super_found = 0, this_found = 0, new_array_found = 0;
13060   int code;
13061
13062   /* We first qualify the first element, then derive qualification of
13063      others based on the first one. If the first element is qualified
13064      by a resolution (field or type), this resolution is stored in the
13065      QUAL_RESOLUTION of the qual element being examined. We need to
13066      save the current_class since the use of SUPER might change the
13067      its value. */
13068   saved_current_class = current_class;
13069   qual = EXPR_WFL_QUALIFICATION (id);
13070   do {
13071
13072     /* Simple qualified expression feature a qual_wfl that is a
13073        WFL. Expression derived from a primary feature more complicated
13074        things like a CALL_EXPR. Expression from primary need to be
13075        worked out to extract the part on which the qualification will
13076        take place. */
13077     qual_wfl = QUAL_WFL (qual);
13078     switch (TREE_CODE (qual_wfl))
13079       {
13080       case CALL_EXPR:
13081         qual_wfl = TREE_OPERAND (qual_wfl, 0);
13082         if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
13083           {
13084             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
13085             qual_wfl = QUAL_WFL (qual);
13086           }
13087         break;
13088       case NEW_ARRAY_EXPR:
13089       case NEW_ANONYMOUS_ARRAY_EXPR:
13090         qual = TREE_CHAIN (qual);
13091         again = new_array_found = 1;
13092         continue;
13093       case CONVERT_EXPR:
13094         break;
13095       case NEW_CLASS_EXPR:
13096         qual_wfl = TREE_OPERAND (qual_wfl, 0);
13097         break;
13098       case ARRAY_REF:
13099         while (TREE_CODE (qual_wfl) == ARRAY_REF)
13100           qual_wfl = TREE_OPERAND (qual_wfl, 0);
13101         break;
13102       case STRING_CST:
13103         qual = TREE_CHAIN (qual);
13104         qual_wfl = QUAL_WFL (qual);
13105         break;
13106       case CLASS_LITERAL:
13107         qual = TREE_CHAIN (qual);
13108         qual_wfl = QUAL_WFL (qual);
13109       break;
13110       default:
13111         /* Fix for -Wall. Just break doing nothing */
13112         break;
13113       }
13114
13115     ptr_type = current_class;
13116     again = 0;
13117     code = TREE_CODE (qual_wfl);
13118
13119     /* Pos evaluation: non WFL leading expression nodes */
13120     if (code == CONVERT_EXPR
13121         && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
13122       name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
13123
13124     else if (code == INTEGER_CST)
13125       name = qual_wfl;
13126     
13127     else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
13128              TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
13129       name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
13130
13131     else if (code == TREE_LIST)
13132       name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
13133
13134     else if (code == STRING_CST || code == CONDITIONAL_EXPR 
13135              || code == PLUS_EXPR)
13136       {
13137         qual = TREE_CHAIN (qual);
13138         qual_wfl = QUAL_WFL (qual);
13139         again = 1;
13140       }
13141     else 
13142       {
13143         name = EXPR_WFL_NODE (qual_wfl);
13144         if (!name)
13145           {
13146             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
13147             again = 1;
13148           }
13149       }
13150
13151     /* If we have a THIS (from a primary), we set the context accordingly */
13152     if (name == this_identifier_node)
13153       {
13154         qual = TREE_CHAIN (qual);
13155         qual_wfl = QUAL_WFL (qual);
13156         if (TREE_CODE (qual_wfl) == CALL_EXPR)
13157           again = 1;
13158         else
13159           name = EXPR_WFL_NODE (qual_wfl);
13160         this_found = 1;
13161       }
13162     /* If we have a SUPER, we set the context accordingly */
13163     if (name == super_identifier_node)
13164       {
13165         current_class = CLASSTYPE_SUPER (ptr_type);
13166         /* Check that there is such a thing as a super class. If not,
13167            return.  The error will be caught later on, during the
13168            resolution */
13169         if (!current_class)
13170           {
13171             current_class = saved_current_class;
13172             return;
13173           }
13174         qual = TREE_CHAIN (qual);
13175         /* Do one more interation to set things up */
13176         super_found = again = 1;
13177       }
13178   } while (again);
13179   
13180   /* If name appears within the scope of a local variable declaration
13181      or parameter declaration, then it is an expression name. We don't
13182      carry this test out if we're in the context of the use of SUPER
13183      or THIS */
13184   if (!this_found && !super_found 
13185       && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
13186       && (decl = IDENTIFIER_LOCAL_VALUE (name)))
13187     {
13188       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13189       QUAL_RESOLUTION (qual) = decl;
13190     }
13191
13192   /* If within the class/interface NAME was found to be used there
13193      exists a (possibly inherited) field named NAME, then this is an
13194      expression name. If we saw a NEW_ARRAY_EXPR before and want to
13195      address length, it is OK. */
13196   else if ((decl = lookup_field_wrapper (ptr_type, name))
13197            || (new_array_found && name == length_identifier_node))
13198     {
13199       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13200       QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
13201     }
13202
13203   /* We reclassify NAME as yielding to a type name resolution if:
13204      - NAME is a class/interface declared within the compilation
13205        unit containing NAME,
13206      - NAME is imported via a single-type-import declaration,
13207      - NAME is declared in an another compilation unit of the package
13208        of the compilation unit containing NAME,
13209      - NAME is declared by exactly on type-import-on-demand declaration
13210      of the compilation unit containing NAME. 
13211      - NAME is actually a STRING_CST. */
13212   else if (TREE_CODE (name) == STRING_CST || TREE_CODE (name) == INTEGER_CST
13213            || (decl = resolve_and_layout (name, NULL_TREE)))
13214     {
13215       RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
13216       QUAL_RESOLUTION (qual) = decl;
13217     }
13218
13219   /* Method call, array references and cast are expression name */
13220   else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
13221            || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
13222            || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
13223     RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13224
13225   /* Check here that NAME isn't declared by more than one
13226      type-import-on-demand declaration of the compilation unit
13227      containing NAME. FIXME */
13228
13229   /* Otherwise, NAME is reclassified as a package name */
13230   else 
13231     RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
13232
13233   /* Propagate the qualification accross other components of the
13234      qualified name */
13235   for (qual = TREE_CHAIN (qual); qual;
13236        qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
13237     {
13238       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13239         RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
13240       else 
13241         RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
13242     }
13243
13244   /* Store the global qualification for the ambiguous part of ID back
13245      into ID fields */
13246   if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
13247     RESOLVE_EXPRESSION_NAME_P (id) = 1;
13248   else if (RESOLVE_TYPE_NAME_P (qual_wfl))
13249     RESOLVE_TYPE_NAME_P (id) = 1;
13250   else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13251     RESOLVE_PACKAGE_NAME_P (id) = 1;
13252
13253   /* Restore the current class */
13254   current_class = saved_current_class;
13255 }
13256
13257 static int
13258 breakdown_qualified (left, right, source)
13259     tree *left, *right, source;
13260 {
13261   char *p = IDENTIFIER_POINTER (source), *base;
13262   int   l = IDENTIFIER_LENGTH (source);
13263
13264   /* Breakdown NAME into REMAINDER . IDENTIFIER */
13265   base = p;
13266   p += (l-1);
13267   while (*p != '.' && p != base)
13268     p--;
13269
13270   /* We didn't find a '.'. Return an error */
13271   if (p == base)
13272     return 1;
13273
13274   *p = '\0';
13275   if (right)
13276     *right = get_identifier (p+1);
13277   *left = get_identifier (IDENTIFIER_POINTER (source));
13278   *p = '.';
13279   
13280   return 0;
13281 }
13282
13283 /* Patch tree nodes in a function body. When a BLOCK is found, push
13284    local variable decls if present.
13285    Same as java_complete_lhs, but does resolve static finals to values. */
13286
13287 static tree
13288 java_complete_tree (node)
13289      tree node;
13290 {
13291   node = java_complete_lhs (node);
13292   if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
13293       && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
13294       && !flag_emit_xref)
13295     {
13296       tree value = DECL_INITIAL (node);
13297       DECL_INITIAL (node) = NULL_TREE;
13298       push_obstacks (&permanent_obstack, &permanent_obstack);
13299       value = fold_constant_for_init (value, node);
13300       pop_obstacks ();
13301       DECL_INITIAL (node) = value;
13302       if (value != NULL_TREE)
13303         {
13304           /* fold_constant_for_init sometimes widen the original type
13305              of the constant (i.e. byte to int.) It's not desirable,
13306              especially if NODE is a function argument. */
13307           if (TREE_CODE (value) == INTEGER_CST
13308               && TREE_TYPE (node) != TREE_TYPE (value))
13309             return convert (TREE_TYPE (node), value);
13310           else
13311             return value;
13312         }
13313     }
13314   return node;
13315 }
13316
13317 static tree
13318 java_stabilize_reference (node)
13319      tree node;
13320 {
13321   if (TREE_CODE (node) == COMPOUND_EXPR)
13322     {
13323       tree op0 = TREE_OPERAND (node, 0);
13324       tree op1 = TREE_OPERAND (node, 1);
13325       TREE_OPERAND (node, 0) = save_expr (op0);
13326       TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
13327       return node;
13328     }
13329   return stabilize_reference (node);
13330 }
13331
13332 /* Patch tree nodes in a function body. When a BLOCK is found, push
13333    local variable decls if present.
13334    Same as java_complete_tree, but does not resolve static finals to values. */
13335
13336 static tree
13337 java_complete_lhs (node)
13338      tree node;
13339 {
13340   tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
13341   int flag;
13342
13343   /* CONVERT_EXPR always has its type set, even though it needs to be
13344      worked out. */
13345   if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
13346     return node;
13347
13348   /* The switch block implements cases processing container nodes
13349      first.  Contained nodes are always written back. Leaves come
13350      next and return a value. */
13351   switch (TREE_CODE (node))
13352     {
13353     case BLOCK:
13354
13355       /* 1- Block section.
13356          Set the local values on decl names so we can identify them
13357          faster when they're referenced. At that stage, identifiers
13358          are legal so we don't check for declaration errors. */
13359       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13360         {
13361           DECL_CONTEXT (cn) = current_function_decl;
13362           IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
13363         }
13364       if (BLOCK_EXPR_BODY (node) == NULL_TREE)
13365           CAN_COMPLETE_NORMALLY (node) = 1;
13366       else
13367         {
13368           tree stmt = BLOCK_EXPR_BODY (node);
13369           tree *ptr;
13370           int error_seen = 0;
13371           if (TREE_CODE (stmt) == COMPOUND_EXPR)
13372             {
13373               /* Re-order from (((A; B); C); ...; Z) to 
13374                  (A; (B; (C ; (...; Z)))).
13375                  This makes it easier to scan the statements left-to-right
13376                  without using recursion (which might overflow the stack
13377                  if the block has many statements. */
13378               for (;;)
13379                 {
13380                   tree left = TREE_OPERAND (stmt, 0);
13381                   if (TREE_CODE (left) != COMPOUND_EXPR)
13382                     break;
13383                   TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
13384                   TREE_OPERAND (left, 1) = stmt;
13385                   stmt = left;
13386                 }
13387               BLOCK_EXPR_BODY (node) = stmt;
13388             }
13389
13390           /* Now do the actual complete, without deep recursion for
13391              long blocks. */
13392           ptr = &BLOCK_EXPR_BODY (node);
13393           while (TREE_CODE (*ptr) == COMPOUND_EXPR
13394                  && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
13395             {
13396               tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
13397               tree *next = &TREE_OPERAND (*ptr, 1);
13398               TREE_OPERAND (*ptr, 0) = cur;
13399               if (cur == empty_stmt_node)
13400                 {
13401                   /* Optimization;  makes it easier to detect empty bodies.
13402                      Most useful for <clinit> with all-constant initializer. */
13403                   *ptr = *next;
13404                   continue;
13405                 }
13406               if (TREE_CODE (cur) == ERROR_MARK)
13407                 error_seen++;
13408               else if (! CAN_COMPLETE_NORMALLY (cur))
13409                 {
13410                   wfl_op2 = *next;
13411                   for (;;)
13412                     {
13413                       if (TREE_CODE (wfl_op2) == BLOCK)
13414                         wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
13415                       else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
13416                         wfl_op2 = TREE_OPERAND (wfl_op2, 0);
13417                       else
13418                         break;
13419                     }
13420                   if (TREE_CODE (wfl_op2) != CASE_EXPR
13421                       && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
13422                     unreachable_stmt_error (*ptr);
13423                 }
13424               ptr = next;
13425             }
13426           *ptr = java_complete_tree (*ptr);
13427
13428           if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
13429             return error_mark_node;
13430           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
13431         }
13432       /* Turn local bindings to null */
13433       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13434         IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
13435
13436       TREE_TYPE (node) = void_type_node;
13437       break;
13438
13439       /* 2- They are expressions but ultimately deal with statements */
13440
13441     case THROW_EXPR:
13442       wfl_op1 = TREE_OPERAND (node, 0);
13443       COMPLETE_CHECK_OP_0 (node);
13444       /* 14.19 A throw statement cannot complete normally. */
13445       CAN_COMPLETE_NORMALLY (node) = 0;
13446       return patch_throw_statement (node, wfl_op1);
13447
13448     case SYNCHRONIZED_EXPR:
13449       wfl_op1 = TREE_OPERAND (node, 0);
13450       return patch_synchronized_statement (node, wfl_op1);
13451
13452     case TRY_EXPR:
13453       return patch_try_statement (node);
13454
13455     case TRY_FINALLY_EXPR:
13456       COMPLETE_CHECK_OP_0 (node);
13457       COMPLETE_CHECK_OP_1 (node);
13458       CAN_COMPLETE_NORMALLY (node)
13459         = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
13460            && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
13461       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
13462       return node;
13463
13464     case CLEANUP_POINT_EXPR:
13465       COMPLETE_CHECK_OP_0 (node);
13466       TREE_TYPE (node) = void_type_node;
13467       CAN_COMPLETE_NORMALLY (node) = 
13468         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13469       return node;
13470
13471     case WITH_CLEANUP_EXPR:
13472       COMPLETE_CHECK_OP_0 (node);
13473       COMPLETE_CHECK_OP_2 (node);
13474       CAN_COMPLETE_NORMALLY (node) = 
13475         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13476       TREE_TYPE (node) = void_type_node;
13477       return node;
13478
13479     case LABELED_BLOCK_EXPR:
13480       PUSH_LABELED_BLOCK (node);
13481       if (LABELED_BLOCK_BODY (node))
13482         COMPLETE_CHECK_OP_1 (node);
13483       TREE_TYPE (node) = void_type_node;
13484       POP_LABELED_BLOCK ();
13485
13486       if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
13487         {
13488           LABELED_BLOCK_BODY (node) = NULL_TREE;
13489           CAN_COMPLETE_NORMALLY (node) = 1;
13490         }
13491       else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
13492         CAN_COMPLETE_NORMALLY (node) = 1;
13493       return node;
13494
13495     case EXIT_BLOCK_EXPR:
13496       /* We don't complete operand 1, because it's the return value of
13497          the EXIT_BLOCK_EXPR which doesn't exist it Java */
13498       return patch_bc_statement (node);
13499
13500     case CASE_EXPR:
13501       cn = java_complete_tree (TREE_OPERAND (node, 0));
13502       if (cn == error_mark_node)
13503         return cn;
13504
13505       /* First, the case expression must be constant. Values of final
13506          fields are accepted. */
13507       cn = fold (cn);
13508       if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
13509           && JDECL_P (TREE_OPERAND (cn, 1))
13510           && FIELD_FINAL (TREE_OPERAND (cn, 1))
13511           && DECL_INITIAL (TREE_OPERAND (cn, 1)))
13512         {
13513           push_obstacks (&permanent_obstack, &permanent_obstack);
13514           cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
13515                                        TREE_OPERAND (cn, 1));
13516           pop_obstacks ();
13517         }
13518
13519       if (!TREE_CONSTANT (cn) && !flag_emit_xref)
13520         {
13521           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13522           parse_error_context (node, "Constant expression required");
13523           return error_mark_node;
13524         }
13525
13526       nn = ctxp->current_loop;
13527
13528       /* It must be assignable to the type of the switch expression. */
13529       if (!try_builtin_assignconv (NULL_TREE, 
13530                                    TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
13531         {
13532           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13533           parse_error_context 
13534             (wfl_operator,
13535              "Incompatible type for case. Can't convert `%s' to `int'",
13536              lang_printable_name (TREE_TYPE (cn), 0));
13537           return error_mark_node;
13538         }
13539
13540       cn = fold (convert (int_type_node, cn));
13541
13542       /* Multiple instance of a case label bearing the same
13543          value is checked during code generation. The case
13544          expression is allright so far. */
13545       TREE_OPERAND (node, 0) = cn;
13546       TREE_TYPE (node) = void_type_node;
13547       CAN_COMPLETE_NORMALLY (node) = 1;
13548       TREE_SIDE_EFFECTS (node) = 1;
13549       break;
13550
13551     case DEFAULT_EXPR:
13552       nn = ctxp->current_loop;
13553       /* Only one default label is allowed per switch statement */
13554       if (SWITCH_HAS_DEFAULT (nn))
13555         {
13556           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13557           parse_error_context (wfl_operator, 
13558                                "Duplicate case label: `default'");
13559           return error_mark_node;
13560         }
13561       else
13562         SWITCH_HAS_DEFAULT (nn) = 1;
13563       TREE_TYPE (node) = void_type_node;
13564       TREE_SIDE_EFFECTS (node) = 1;
13565       CAN_COMPLETE_NORMALLY (node) = 1;
13566       break;
13567
13568     case SWITCH_EXPR:
13569     case LOOP_EXPR:
13570       PUSH_LOOP (node);
13571       /* Check whether the loop was enclosed in a labeled
13572          statement. If not, create one, insert the loop in it and
13573          return the node */
13574       nn = patch_loop_statement (node);
13575
13576       /* Anyways, walk the body of the loop */
13577       if (TREE_CODE (node) == LOOP_EXPR)
13578         TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13579       /* Switch statement: walk the switch expression and the cases */
13580       else
13581         node = patch_switch_statement (node);
13582
13583       if (TREE_OPERAND (node, 0) == error_mark_node)
13584         nn = error_mark_node;
13585       else
13586         {
13587           TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
13588           /* If we returned something different, that's because we
13589              inserted a label. Pop the label too. */
13590           if (nn != node)
13591             {
13592               if (CAN_COMPLETE_NORMALLY (node))
13593                 CAN_COMPLETE_NORMALLY (nn) = 1;
13594               POP_LABELED_BLOCK ();
13595             }
13596         }
13597       POP_LOOP ();
13598       return nn;
13599
13600     case EXIT_EXPR:
13601       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13602       return patch_exit_expr (node);
13603
13604     case COND_EXPR:
13605       /* Condition */
13606       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13607       if (TREE_OPERAND (node, 0) == error_mark_node)
13608         return error_mark_node;
13609       /* then-else branches */
13610       TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13611       if (TREE_OPERAND (node, 1) == error_mark_node)
13612         return error_mark_node;
13613       TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
13614       if (TREE_OPERAND (node, 2) == error_mark_node)
13615         return error_mark_node;
13616       return patch_if_else_statement (node);
13617       break;
13618
13619     case CONDITIONAL_EXPR:
13620       /* Condition */
13621       wfl_op1 = TREE_OPERAND (node, 0);
13622       COMPLETE_CHECK_OP_0 (node);
13623       wfl_op2 = TREE_OPERAND (node, 1);
13624       COMPLETE_CHECK_OP_1 (node);
13625       wfl_op3 = TREE_OPERAND (node, 2);
13626       COMPLETE_CHECK_OP_2 (node);
13627       return patch_conditional_expr (node, wfl_op1, wfl_op2);
13628
13629       /* 3- Expression section */
13630     case COMPOUND_EXPR:
13631       wfl_op2 = TREE_OPERAND (node, 1);
13632       TREE_OPERAND (node, 0) = nn = 
13633         java_complete_tree (TREE_OPERAND (node, 0));
13634       if (wfl_op2 == empty_stmt_node)
13635         CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
13636       else
13637         {
13638           if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
13639             {
13640               /* An unreachable condition in a do-while statement
13641                  is *not* (technically) an unreachable statement. */
13642               nn = wfl_op2;
13643               if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
13644                 nn = EXPR_WFL_NODE (nn);
13645               if (TREE_CODE (nn) != EXIT_EXPR)
13646                 {
13647                   SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
13648                   parse_error_context (wfl_operator, "Unreachable statement");
13649                 }
13650             }
13651           TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13652           if (TREE_OPERAND (node, 1) == error_mark_node)
13653             return error_mark_node;
13654           CAN_COMPLETE_NORMALLY (node)
13655             = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
13656         }
13657       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
13658       break;
13659
13660     case RETURN_EXPR:
13661       /* CAN_COMPLETE_NORMALLY (node) = 0; */
13662       return patch_return (node);
13663
13664     case EXPR_WITH_FILE_LOCATION:
13665       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
13666           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
13667         {
13668           tree wfl = node;
13669           node = resolve_expression_name (node, NULL);
13670           if (node == error_mark_node)
13671             return node;
13672           /* Keep line number information somewhere were it doesn't
13673              disrupt the completion process. */
13674           if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
13675             {
13676               EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
13677               TREE_OPERAND (node, 1) = wfl;
13678             }
13679           CAN_COMPLETE_NORMALLY (node) = 1;
13680         }
13681       else
13682         {
13683           tree body;
13684           int save_lineno = lineno;
13685           lineno = EXPR_WFL_LINENO (node);
13686           body = java_complete_tree (EXPR_WFL_NODE (node));
13687           lineno = save_lineno;
13688           EXPR_WFL_NODE (node) = body;
13689           TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
13690           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
13691           if (body == empty_stmt_node)
13692             {
13693               /* Optimization;  makes it easier to detect empty bodies. */
13694               return body;
13695             }
13696           if (body == error_mark_node)
13697             {
13698               /* Its important for the evaluation of assignment that
13699                  this mark on the TREE_TYPE is propagated. */
13700               TREE_TYPE (node) = error_mark_node;
13701               return error_mark_node;
13702             }
13703           else
13704             TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
13705           
13706         }
13707       break;
13708
13709     case NEW_ARRAY_EXPR:
13710       /* Patch all the dimensions */
13711       flag = 0;
13712       for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13713         {
13714           int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
13715           tree dim = convert (int_type_node, 
13716                               java_complete_tree (TREE_VALUE (cn)));
13717           if (dim == error_mark_node)
13718             {
13719               flag = 1;
13720               continue;
13721             }
13722           else
13723             {
13724               TREE_VALUE (cn) = dim;
13725               /* Setup the location of the current dimension, for
13726                  later error report. */
13727               TREE_PURPOSE (cn) = 
13728                 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
13729               EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
13730             }
13731         }
13732       /* They complete the array creation expression, if no errors
13733          were found. */
13734       CAN_COMPLETE_NORMALLY (node) = 1;
13735       return (flag ? error_mark_node
13736               : force_evaluation_order (patch_newarray (node)));
13737
13738     case NEW_ANONYMOUS_ARRAY_EXPR:
13739       /* Create the array type if necessary. */
13740       if (ANONYMOUS_ARRAY_DIMS_SIG (node))
13741         {
13742           tree type = ANONYMOUS_ARRAY_BASE_TYPE (node);
13743           if (!(type = resolve_type_during_patch (type)))
13744             return error_mark_node;
13745           type = build_array_from_name (type, NULL_TREE,
13746                                         ANONYMOUS_ARRAY_DIMS_SIG (node), NULL);
13747           ANONYMOUS_ARRAY_BASE_TYPE (node) = build_pointer_type (type);
13748         }
13749       node = patch_new_array_init (ANONYMOUS_ARRAY_BASE_TYPE (node),
13750                                    ANONYMOUS_ARRAY_INITIALIZER (node));
13751       if (node == error_mark_node)
13752         return error_mark_node;
13753       CAN_COMPLETE_NORMALLY (node) = 1;
13754       return node;
13755
13756     case NEW_CLASS_EXPR:
13757     case CALL_EXPR:
13758       /* Complete function's argument(s) first */
13759       if (complete_function_arguments (node))
13760         return error_mark_node;
13761       else
13762         {
13763           tree decl, wfl = TREE_OPERAND (node, 0);
13764           int in_this = CALL_THIS_CONSTRUCTOR_P (node);
13765
13766           node = patch_method_invocation (node, NULL_TREE, 
13767                                           NULL_TREE, 0, &decl);
13768           if (node == error_mark_node)
13769             return error_mark_node;
13770
13771           check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
13772           /* If we call this(...), register signature and positions */
13773           if (in_this)
13774             DECL_CONSTRUCTOR_CALLS (current_function_decl) = 
13775               tree_cons (wfl, decl, 
13776                          DECL_CONSTRUCTOR_CALLS (current_function_decl));
13777           CAN_COMPLETE_NORMALLY (node) = 1;
13778           return force_evaluation_order (node);
13779         }
13780
13781     case MODIFY_EXPR:
13782       /* Save potential wfls */
13783       wfl_op1 = TREE_OPERAND (node, 0);
13784       TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
13785       
13786       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
13787           && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
13788           && DECL_INITIAL (nn) != NULL_TREE)
13789         {
13790           tree value;
13791           
13792           push_obstacks (&permanent_obstack, &permanent_obstack);
13793           value = fold_constant_for_init (nn, nn);
13794           pop_obstacks ();
13795
13796           if (value != NULL_TREE)
13797             {
13798               tree type = TREE_TYPE (value);
13799               if (JPRIMITIVE_TYPE_P (type) || 
13800                   (type == string_ptr_type_node && ! flag_emit_class_files))
13801                 return empty_stmt_node;
13802             }
13803           DECL_INITIAL (nn) = NULL_TREE;
13804         }
13805       wfl_op2 = TREE_OPERAND (node, 1);
13806
13807       if (TREE_OPERAND (node, 0) == error_mark_node)
13808         return error_mark_node;
13809
13810       flag = COMPOUND_ASSIGN_P (wfl_op2);
13811       if (flag)
13812         {
13813           /* This might break when accessing outer field from inner
13814              class. TESTME, FIXME */
13815           tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0)); 
13816
13817           /* Hand stablize the lhs on both places */
13818           TREE_OPERAND (node, 0) = lvalue;
13819           TREE_OPERAND (TREE_OPERAND (node, 1), 0) = 
13820             (flag_emit_class_files ? lvalue : save_expr (lvalue));
13821
13822           /* 15.25.2.a: Left hand is not an array access. FIXME */
13823           /* Now complete the RHS. We write it back later on. */
13824           nn = java_complete_tree (TREE_OPERAND (node, 1));
13825
13826           if ((cn = patch_string (nn)))
13827             nn = cn;
13828
13829           /* The last part of the rewrite for E1 op= E2 is to have 
13830              E1 = (T)(E1 op E2), with T being the type of E1. */
13831           nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2), 
13832                                                TREE_TYPE (lvalue), nn));
13833
13834           /* 15.25.2.b: Left hand is an array access. FIXME */
13835         }
13836
13837       /* If we're about to patch a NEW_ARRAY_INIT, we call a special
13838          function to complete this RHS. Note that a NEW_ARRAY_INIT
13839          might have been already fully expanded if created as a result
13840          of processing an anonymous array initializer. We avoid doing
13841          the operation twice by testing whether the node already bears
13842          a type. */
13843       else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT && !TREE_TYPE (wfl_op2))
13844         nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
13845                                    TREE_OPERAND (node, 1));
13846       /* Otherwise we simply complete the RHS */
13847       else
13848         nn = java_complete_tree (TREE_OPERAND (node, 1));
13849
13850       if (nn == error_mark_node)
13851         return error_mark_node;
13852
13853       /* Write back the RHS as we evaluated it. */
13854       TREE_OPERAND (node, 1) = nn;
13855
13856       /* In case we're handling = with a String as a RHS, we need to
13857          produce a String out of the RHS (it might still be a
13858          STRING_CST or a StringBuffer at this stage */
13859       if ((nn = patch_string (TREE_OPERAND (node, 1))))
13860         TREE_OPERAND (node, 1) = nn;
13861
13862       if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
13863                                         TREE_OPERAND (node, 1))))
13864         {
13865           /* We return error_mark_node if outer_field_access_fix
13866              detects we write into a final. */
13867           if (nn == error_mark_node)
13868             return error_mark_node;
13869           node = nn;
13870         }
13871       else
13872         {
13873           node = patch_assignment (node, wfl_op1, wfl_op2);
13874           /* Reorganize the tree if necessary. */
13875           if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node)) 
13876                        || JSTRING_P (TREE_TYPE (node))))
13877             node = java_refold (node);
13878         }
13879       
13880       CAN_COMPLETE_NORMALLY (node) = 1;
13881       return node;
13882
13883     case MULT_EXPR:
13884     case PLUS_EXPR:
13885     case MINUS_EXPR:
13886     case LSHIFT_EXPR:
13887     case RSHIFT_EXPR:
13888     case URSHIFT_EXPR:
13889     case BIT_AND_EXPR:
13890     case BIT_XOR_EXPR:
13891     case BIT_IOR_EXPR:
13892     case TRUNC_MOD_EXPR:
13893     case TRUNC_DIV_EXPR:
13894     case RDIV_EXPR:
13895     case TRUTH_ANDIF_EXPR:
13896     case TRUTH_ORIF_EXPR:
13897     case EQ_EXPR: 
13898     case NE_EXPR:
13899     case GT_EXPR:
13900     case GE_EXPR:
13901     case LT_EXPR:
13902     case LE_EXPR:
13903       /* Operands 0 and 1 are WFL in certain cases only. patch_binop
13904          knows how to handle those cases. */
13905       wfl_op1 = TREE_OPERAND (node, 0);
13906       wfl_op2 = TREE_OPERAND (node, 1);
13907
13908       CAN_COMPLETE_NORMALLY (node) = 1;
13909       /* Don't complete string nodes if dealing with the PLUS operand. */
13910       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
13911         {
13912           nn = java_complete_tree (wfl_op1);
13913           if (nn == error_mark_node)
13914             return error_mark_node;
13915
13916           TREE_OPERAND (node, 0) = nn;
13917         }
13918       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
13919         {
13920           nn = java_complete_tree (wfl_op2);
13921           if (nn == error_mark_node)
13922             return error_mark_node;
13923
13924           TREE_OPERAND (node, 1) = nn;
13925         }
13926       return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
13927
13928     case INSTANCEOF_EXPR:
13929       wfl_op1 = TREE_OPERAND (node, 0);
13930       COMPLETE_CHECK_OP_0 (node);
13931       if (flag_emit_xref)
13932         {
13933           TREE_TYPE (node) = boolean_type_node;
13934           return node;
13935         }
13936       return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
13937
13938     case UNARY_PLUS_EXPR:
13939     case NEGATE_EXPR:
13940     case TRUTH_NOT_EXPR:
13941     case BIT_NOT_EXPR:
13942     case PREDECREMENT_EXPR:
13943     case PREINCREMENT_EXPR:
13944     case POSTDECREMENT_EXPR:
13945     case POSTINCREMENT_EXPR:
13946     case CONVERT_EXPR:
13947       /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
13948          how to handle those cases. */
13949       wfl_op1 = TREE_OPERAND (node, 0);
13950       CAN_COMPLETE_NORMALLY (node) = 1;
13951       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13952       if (TREE_OPERAND (node, 0) == error_mark_node)
13953         return error_mark_node;
13954       node = patch_unaryop (node, wfl_op1);
13955       CAN_COMPLETE_NORMALLY (node) = 1;
13956       break;
13957
13958     case ARRAY_REF:
13959       /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
13960          how to handle those cases. */
13961       wfl_op1 = TREE_OPERAND (node, 0);
13962       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13963       if (TREE_OPERAND (node, 0) == error_mark_node)
13964         return error_mark_node;
13965       if (!flag_emit_class_files && !flag_emit_xref)
13966         TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
13967       /* The same applies to wfl_op2 */
13968       wfl_op2 = TREE_OPERAND (node, 1);
13969       TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
13970       if (TREE_OPERAND (node, 1) == error_mark_node)
13971         return error_mark_node;
13972       if (!flag_emit_class_files && !flag_emit_xref)
13973         TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
13974       return patch_array_ref (node);
13975
13976     case RECORD_TYPE:
13977       return node;;
13978
13979     case COMPONENT_REF:
13980       /* The first step in the re-write of qualified name handling.  FIXME.
13981          So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
13982       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13983       if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
13984         {
13985           tree name = TREE_OPERAND (node, 1);
13986           tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
13987           if (field == NULL_TREE)
13988             {
13989               error ("missing static field `%s'", IDENTIFIER_POINTER (name));
13990               return error_mark_node;
13991             }
13992           if (! FIELD_STATIC (field))
13993             {
13994               error ("not a static field `%s'", IDENTIFIER_POINTER (name));
13995               return error_mark_node;
13996             }
13997           return field;
13998         }
13999       else
14000         fatal ("unimplemented java_complete_tree for COMPONENT_REF");
14001       break;
14002
14003     case THIS_EXPR:
14004       /* Can't use THIS in a static environment */
14005       if (!current_this)
14006         {
14007           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14008           parse_error_context (wfl_operator,
14009                                "Keyword `this' used outside allowed context");
14010           TREE_TYPE (node) = error_mark_node;
14011           return error_mark_node;
14012         }
14013       if (ctxp->explicit_constructor_p)
14014         {
14015           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14016           parse_error_context 
14017             (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
14018           TREE_TYPE (node) = error_mark_node;
14019           return error_mark_node;
14020         }
14021       return current_this;
14022       
14023     case CLASS_LITERAL:
14024       CAN_COMPLETE_NORMALLY (node) = 1;
14025       node = patch_incomplete_class_ref (node);
14026       if (node == error_mark_node)
14027         return error_mark_node;
14028       break;
14029
14030     case INSTANCE_INITIALIZERS_EXPR:
14031       in_instance_initializer++;
14032       node = java_complete_tree (TREE_OPERAND (node, 0));
14033       in_instance_initializer--;
14034       if (node != error_mark_node)
14035         TREE_TYPE (node) = void_type_node;
14036       else
14037         return error_mark_node;
14038       break;
14039
14040     default:
14041       CAN_COMPLETE_NORMALLY (node) = 1;
14042       /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
14043          and it's time to turn it into the appropriate String object */
14044       if ((nn = patch_string (node)))
14045         node = nn;
14046       else
14047         fatal ("No case for tree code `%s' - java_complete_tree\n",
14048                tree_code_name [TREE_CODE (node)]);
14049     }
14050   return node;
14051 }
14052
14053 /* Complete function call's argument. Return a non zero value is an
14054    error was found.  */
14055
14056 static int
14057 complete_function_arguments (node)
14058      tree node;
14059 {
14060   int flag = 0;
14061   tree cn;
14062
14063   ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
14064   for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
14065     {
14066       tree wfl = TREE_VALUE (cn), parm, temp;
14067       parm = java_complete_tree (wfl);
14068
14069       if (parm == error_mark_node)
14070         {
14071           flag = 1;
14072           continue;
14073         }
14074       /* If have a string literal that we haven't transformed yet or a
14075          crafted string buffer, as a result of use of the the String
14076          `+' operator. Build `parm.toString()' and expand it. */
14077       if ((temp = patch_string (parm)))
14078         parm = temp;
14079       /* Inline PRIMTYPE.TYPE read access */
14080       parm = maybe_build_primttype_type_ref (parm, wfl);
14081
14082       TREE_VALUE (cn) = parm;
14083     }
14084   ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
14085   return flag;
14086 }
14087
14088 /* Sometimes (for loops and variable initialized during their
14089    declaration), we want to wrap a statement around a WFL and turn it
14090    debugable.  */
14091
14092 static tree
14093 build_debugable_stmt (location, stmt)
14094     int location;
14095     tree stmt;
14096 {
14097   if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
14098     {
14099       stmt = build_expr_wfl (stmt, input_filename, 0, 0);
14100       EXPR_WFL_LINECOL (stmt) = location;
14101     }
14102   JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
14103   return stmt;
14104 }
14105
14106 static tree
14107 build_expr_block (body, decls)
14108      tree body, decls;
14109 {
14110   tree node = make_node (BLOCK);
14111   BLOCK_EXPR_DECLS (node) = decls;
14112   BLOCK_EXPR_BODY (node) = body;
14113   if (body)
14114     TREE_TYPE (node) = TREE_TYPE (body);
14115   TREE_SIDE_EFFECTS (node) = 1;
14116   return node;
14117 }
14118
14119 /* Create a new function block and link it approriately to current
14120    function block chain */
14121
14122 static tree
14123 enter_block ()
14124 {
14125   return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
14126 }
14127
14128 /* Link block B supercontext to the previous block. The current
14129    function DECL is used as supercontext when enter_a_block is called
14130    for the first time for a given function. The current function body
14131    (DECL_FUNCTION_BODY) is set to be block B.  */
14132
14133 static tree
14134 enter_a_block (b)
14135      tree b;
14136 {
14137   tree fndecl = current_function_decl; 
14138
14139   if (!fndecl) {
14140     BLOCK_SUPERCONTEXT (b) = current_static_block;
14141     current_static_block = b;
14142   }
14143
14144   else if (!DECL_FUNCTION_BODY (fndecl))
14145     {
14146       BLOCK_SUPERCONTEXT (b) = fndecl;
14147       DECL_FUNCTION_BODY (fndecl) = b;
14148     }
14149   else
14150     {
14151       BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
14152       DECL_FUNCTION_BODY (fndecl) = b;
14153     }
14154   return b;
14155 }
14156
14157 /* Exit a block by changing the current function body
14158    (DECL_FUNCTION_BODY) to the current block super context, only if
14159    the block being exited isn't the method's top level one.  */
14160
14161 static tree
14162 exit_block ()
14163 {
14164   tree b;
14165   if (current_function_decl)
14166     {
14167       b = DECL_FUNCTION_BODY (current_function_decl);
14168       if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
14169         DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
14170     }
14171   else
14172     {
14173       b = current_static_block;
14174
14175       if (BLOCK_SUPERCONTEXT (b))
14176         current_static_block = BLOCK_SUPERCONTEXT (b);
14177     }
14178   return b;
14179 }
14180
14181 /* Lookup for NAME in the nested function's blocks, all the way up to
14182    the current toplevel one. It complies with Java's local variable
14183    scoping rules.  */
14184
14185 static tree
14186 lookup_name_in_blocks (name)
14187      tree name;
14188 {
14189   tree b = GET_CURRENT_BLOCK (current_function_decl);
14190
14191   while (b != current_function_decl)
14192     {
14193       tree current;
14194
14195       /* Paranoid sanity check. To be removed */
14196       if (TREE_CODE (b) != BLOCK)
14197         fatal ("non block expr function body - lookup_name_in_blocks");
14198
14199       for (current = BLOCK_EXPR_DECLS (b); current; 
14200            current = TREE_CHAIN (current))
14201         if (DECL_NAME (current) == name)
14202           return current;
14203       b = BLOCK_SUPERCONTEXT (b);
14204     }
14205   return NULL_TREE;
14206 }
14207
14208 static void
14209 maybe_absorb_scoping_blocks ()
14210 {
14211   while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
14212     {
14213       tree b = exit_block ();
14214       java_method_add_stmt (current_function_decl, b);
14215       SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
14216     }
14217 }
14218
14219 \f
14220 /* This section of the source is reserved to build_* functions that
14221    are building incomplete tree nodes and the patch_* functions that
14222    are completing them.  */
14223
14224 /* Wrap a non WFL node around a WFL.  */
14225 static tree
14226 build_wfl_wrap (node, location)
14227     tree node;
14228     int location;
14229 {
14230   tree wfl, node_to_insert = node;
14231   
14232   /* We want to process THIS . xxx symbolicaly, to keep it consistent
14233      with the way we're processing SUPER. A THIS from a primary as a
14234      different form than a SUPER. Turn THIS into something symbolic */
14235   if (TREE_CODE (node) == THIS_EXPR)
14236     node_to_insert = wfl = build_wfl_node (this_identifier_node);
14237   else
14238     wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
14239
14240   EXPR_WFL_LINECOL (wfl) = location;
14241   EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
14242   return wfl;
14243 }
14244
14245
14246 /* Build a super() constructor invocation. Returns empty_stmt_node if
14247    we're currently dealing with the class java.lang.Object. */
14248
14249 static tree
14250 build_super_invocation (mdecl)
14251      tree mdecl;
14252 {
14253   if (DECL_CONTEXT (mdecl) == object_type_node)
14254     return empty_stmt_node;
14255   else
14256     {
14257       tree super_wfl = build_wfl_node (super_identifier_node);
14258       tree a = NULL_TREE, t;
14259       /* If we're dealing with an anonymous class, pass the arguments
14260          of the crafted constructor along. */
14261       if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
14262         {
14263           SKIP_THIS_AND_ARTIFICIAL_PARMS (t, mdecl);
14264           for (; t != end_params_node; t = TREE_CHAIN (t))
14265             a = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (t)), a);
14266         }
14267       return build_method_invocation (super_wfl, a);
14268     }
14269 }
14270
14271 /* Build a SUPER/THIS qualified method invocation.  */
14272
14273 static tree
14274 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
14275      int use_this;
14276      tree name, args;
14277      int lloc, rloc;
14278 {
14279   tree invok;
14280   tree wfl = 
14281     build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
14282   EXPR_WFL_LINECOL (wfl) = lloc;
14283   invok = build_method_invocation (name, args);
14284   return make_qualified_primary (wfl, invok, rloc);
14285 }
14286
14287 /* Build an incomplete CALL_EXPR node. */
14288
14289 static tree
14290 build_method_invocation (name, args)
14291     tree name;
14292     tree args;
14293 {
14294   tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
14295   TREE_SIDE_EFFECTS (call) = 1;
14296   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14297   return call;
14298 }
14299
14300 /* Build an incomplete new xxx(...) node. */
14301
14302 static tree
14303 build_new_invocation (name, args)
14304     tree name, args;
14305 {
14306   tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
14307   TREE_SIDE_EFFECTS (call) = 1;
14308   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14309   return call;
14310 }
14311
14312 /* Build an incomplete assignment expression. */
14313
14314 static tree
14315 build_assignment (op, op_location, lhs, rhs)
14316      int op, op_location;
14317      tree lhs, rhs;
14318 {
14319   tree assignment;
14320   /* Build the corresponding binop if we deal with a Compound
14321      Assignment operator. Mark the binop sub-tree as part of a
14322      Compound Assignment expression */
14323   if (op != ASSIGN_TK)
14324     {
14325       rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
14326       COMPOUND_ASSIGN_P (rhs) = 1;
14327     }
14328   assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
14329   TREE_SIDE_EFFECTS (assignment) = 1;
14330   EXPR_WFL_LINECOL (assignment) = op_location;
14331   return assignment;
14332 }
14333
14334 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
14335
14336 char *
14337 print_int_node (node)
14338     tree node;
14339 {
14340   static char buffer [80];
14341   if (TREE_CONSTANT_OVERFLOW (node))
14342     sprintf (buffer, "<overflow>");
14343     
14344   if (TREE_INT_CST_HIGH (node) == 0)
14345     sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
14346              TREE_INT_CST_LOW (node));
14347   else if (TREE_INT_CST_HIGH (node) == -1
14348            && TREE_INT_CST_LOW (node) != 0)
14349     {
14350       buffer [0] = '-';
14351       sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
14352                -TREE_INT_CST_LOW (node));
14353     }
14354   else
14355     sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
14356              TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
14357
14358   return buffer;
14359 }
14360
14361 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
14362    context.  */
14363
14364 static int
14365 check_final_assignment (lvalue, wfl)
14366      tree lvalue, wfl;
14367 {
14368   if (TREE_CODE (lvalue) == COMPOUND_EXPR 
14369       && JDECL_P (TREE_OPERAND (lvalue, 1)))
14370     lvalue = TREE_OPERAND (lvalue, 1);
14371
14372   /* When generating class files, references to the `length' field
14373      look a bit different.  */
14374   if ((flag_emit_class_files
14375        && TREE_CODE (lvalue) == COMPONENT_REF
14376        && TYPE_ARRAY_P (TREE_TYPE (TREE_OPERAND (lvalue, 0)))
14377        && FIELD_FINAL (TREE_OPERAND (lvalue, 1)))
14378       || (TREE_CODE (lvalue) == FIELD_DECL
14379           && FIELD_FINAL (lvalue)
14380           && !DECL_CLINIT_P (current_function_decl)
14381           && !DECL_FINIT_P (current_function_decl)))
14382     {
14383       parse_error_context 
14384         (wfl, "Can't assign a value to the final variable `%s'",
14385          IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
14386       return 1;
14387     }
14388   return 0;
14389 }
14390
14391 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
14392    read. This is needed to avoid circularities in the implementation
14393    of these fields in libjava. */
14394
14395 static tree
14396 maybe_build_primttype_type_ref (rhs, wfl)
14397     tree rhs, wfl;
14398 {
14399   tree to_return = NULL_TREE;
14400   tree rhs_type = TREE_TYPE (rhs);
14401   if (TREE_CODE (rhs) == COMPOUND_EXPR)
14402     {
14403       tree n = TREE_OPERAND (rhs, 1);
14404       if (TREE_CODE (n) == VAR_DECL 
14405           && DECL_NAME (n) == TYPE_identifier_node
14406           && rhs_type == class_ptr_type
14407           && TREE_CODE (EXPR_WFL_NODE (wfl)) == IDENTIFIER_NODE)
14408         {
14409           const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
14410           if (!strncmp (self_name, "java.lang.", 10))
14411             to_return = build_primtype_type_ref (self_name);
14412         }
14413     }
14414   return (to_return ? to_return : rhs );
14415 }
14416
14417 /* 15.25 Assignment operators. */
14418
14419 static tree
14420 patch_assignment (node, wfl_op1, wfl_op2)
14421      tree node;
14422      tree wfl_op1;
14423      tree wfl_op2;
14424 {
14425   tree rhs = TREE_OPERAND (node, 1);
14426   tree lvalue = TREE_OPERAND (node, 0), llvalue;
14427   tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
14428   int error_found = 0;
14429   int lvalue_from_array = 0;
14430
14431   /* Can't assign to a (blank) final. */
14432   if (check_final_assignment (lvalue, wfl_op1))
14433     error_found = 1;
14434
14435   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14436
14437   /* Lhs can be a named variable */
14438   if (JDECL_P (lvalue))
14439     {
14440       lhs_type = TREE_TYPE (lvalue);
14441     }
14442   /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
14443      comment on reason why */
14444   else if (TREE_CODE (wfl_op1) == ARRAY_REF)
14445     {
14446       lhs_type = TREE_TYPE (lvalue);
14447       lvalue_from_array = 1;
14448     }
14449   /* Or a field access */
14450   else if (TREE_CODE (lvalue) == COMPONENT_REF)
14451     lhs_type = TREE_TYPE (lvalue);
14452   /* Or a function return slot */
14453   else if (TREE_CODE (lvalue) == RESULT_DECL)
14454     lhs_type = TREE_TYPE (lvalue);
14455   /* Otherwise, we might want to try to write into an optimized static
14456      final, this is an of a different nature, reported further on. */
14457   else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
14458            && resolve_expression_name (wfl_op1, &llvalue))
14459     {
14460       if (!error_found && check_final_assignment (llvalue, wfl_op1))
14461         {
14462           /* What we should do instead is resetting the all the flags
14463              previously set, exchange lvalue for llvalue and continue. */
14464           error_found = 1;
14465           return error_mark_node;
14466         }
14467       else 
14468         lhs_type = TREE_TYPE (lvalue);
14469     }
14470   else 
14471     {
14472       parse_error_context (wfl_op1, "Invalid left hand side of assignment");
14473       error_found = 1;
14474     }
14475
14476   rhs_type = TREE_TYPE (rhs);
14477   /* 5.1 Try the assignment conversion for builtin type. */
14478   new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
14479
14480   /* 5.2 If it failed, try a reference conversion */
14481   if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
14482     lhs_type = promote_type (rhs_type);
14483
14484   /* 15.25.2 If we have a compound assignment, convert RHS into the
14485      type of the LHS */
14486   else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14487     new_rhs = convert (lhs_type, rhs);
14488
14489   /* Explicit cast required. This is an error */
14490   if (!new_rhs)
14491     {
14492       char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
14493       char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
14494       tree wfl;
14495       char operation [32];      /* Max size known */
14496
14497       /* If the assignment is part of a declaration, we use the WFL of
14498          the declared variable to point out the error and call it a
14499          declaration problem. If the assignment is a genuine =
14500          operator, we call is a operator `=' problem, otherwise we
14501          call it an assignment problem. In both of these last cases,
14502          we use the WFL of the operator to indicate the error. */
14503
14504       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
14505         {
14506           wfl = wfl_op1;
14507           strcpy (operation, "declaration");
14508         }
14509       else
14510         {
14511           wfl = wfl_operator;
14512           if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14513             strcpy (operation, "assignment");
14514           else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
14515             strcpy (operation, "`return'");
14516           else
14517             strcpy (operation, "`='");
14518         }
14519
14520       if (!valid_cast_to_p (rhs_type, lhs_type))
14521         parse_error_context
14522           (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
14523            operation, t1, t2);
14524       else
14525         parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
14526                              operation, t1, t2);
14527       free (t1); free (t2);
14528       error_found = 1;
14529     }
14530
14531   /* Inline read access to java.lang.PRIMTYPE.TYPE */
14532   if (new_rhs)
14533     new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
14534
14535   if (error_found)
14536     return error_mark_node;
14537
14538   /* 10.10: Array Store Exception runtime check */
14539   if (!flag_emit_class_files
14540       && !flag_emit_xref
14541       && lvalue_from_array 
14542       && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
14543     {
14544       tree check;
14545       tree base = lvalue;
14546
14547       /* We need to retrieve the right argument for _Jv_CheckArrayStore */
14548       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14549         base = TREE_OPERAND (lvalue, 0);
14550       else
14551         {
14552           if (flag_bounds_check)
14553             base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
14554           else
14555             base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
14556         }
14557
14558       /* Build the invocation of _Jv_CheckArrayStore */
14559       new_rhs = save_expr (new_rhs);
14560       check = build (CALL_EXPR, void_type_node,
14561                      build_address_of (soft_checkarraystore_node),
14562                      tree_cons (NULL_TREE, base,
14563                                 build_tree_list (NULL_TREE, new_rhs)),
14564                      NULL_TREE);
14565       TREE_SIDE_EFFECTS (check) = 1;
14566
14567       /* We have to decide on an insertion point */
14568       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14569         {
14570           tree t;
14571           if (flag_bounds_check)
14572             {
14573               t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
14574               TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
14575                 build (COMPOUND_EXPR, void_type_node, t, check);
14576             }
14577           else
14578             TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
14579                                               check, TREE_OPERAND (lvalue, 1));
14580         }
14581       else 
14582         {
14583           /* Make sure the bound check will happen before the store check */
14584           if (flag_bounds_check)
14585             TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
14586               build (COMPOUND_EXPR, void_type_node,
14587                      TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
14588           else
14589             lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
14590         }
14591     }
14592
14593   TREE_OPERAND (node, 0) = lvalue;
14594   TREE_OPERAND (node, 1) = new_rhs;
14595   TREE_TYPE (node) = lhs_type;
14596   return node;
14597 }
14598
14599 /* Check that type SOURCE can be cast into type DEST. If the cast
14600    can't occur at all, return 0 otherwise 1. This function is used to
14601    produce accurate error messages on the reasons why an assignment
14602    failed. */
14603
14604 static tree
14605 try_reference_assignconv (lhs_type, rhs)
14606      tree lhs_type, rhs;
14607 {
14608   tree new_rhs = NULL_TREE;
14609   tree rhs_type = TREE_TYPE (rhs);
14610
14611   if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
14612     {
14613       /* `null' may be assigned to any reference type */
14614       if (rhs == null_pointer_node)
14615         new_rhs = null_pointer_node;
14616       /* Try the reference assignment conversion */
14617       else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
14618         new_rhs = rhs;
14619       /* This is a magic assignment that we process differently */
14620       else if (rhs == soft_exceptioninfo_call_node)
14621         new_rhs = rhs;
14622     }
14623   return new_rhs;
14624 }
14625
14626 /* Check that RHS can be converted into LHS_TYPE by the assignment
14627    conversion (5.2), for the cases of RHS being a builtin type. Return
14628    NULL_TREE if the conversion fails or if because RHS isn't of a
14629    builtin type. Return a converted RHS if the conversion is possible.  */
14630
14631 static tree
14632 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
14633      tree wfl_op1, lhs_type, rhs;
14634 {
14635   tree new_rhs = NULL_TREE;
14636   tree rhs_type = TREE_TYPE (rhs);
14637
14638   /* Zero accepted everywhere */
14639   if (TREE_CODE (rhs) == INTEGER_CST 
14640       && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
14641       && JPRIMITIVE_TYPE_P (rhs_type))
14642     new_rhs = convert (lhs_type, rhs);
14643
14644   /* 5.1.1 Try Identity Conversion,
14645      5.1.2 Try Widening Primitive Conversion */
14646   else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
14647     new_rhs = convert (lhs_type, rhs);
14648
14649   /* Try a narrowing primitive conversion (5.1.3): 
14650        - expression is a constant expression of type int AND
14651        - variable is byte, short or char AND
14652        - The value of the expression is representable in the type of the 
14653          variable */
14654   else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
14655            && (lhs_type == byte_type_node || lhs_type == char_type_node
14656                || lhs_type == short_type_node))
14657     {
14658       if (int_fits_type_p (rhs, lhs_type))
14659         new_rhs = convert (lhs_type, rhs);
14660       else if (wfl_op1)         /* Might be called with a NULL */
14661         parse_warning_context 
14662           (wfl_op1, "Constant expression `%s' to wide for narrowing primitive conversion to `%s'", 
14663            print_int_node (rhs), lang_printable_name (lhs_type, 0));
14664       /* Reported a warning that will turn into an error further
14665          down, so we don't return */
14666     }
14667
14668   return new_rhs;
14669 }
14670
14671 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
14672    conversion (5.1.1) or widening primitve conversion (5.1.2).  Return
14673    0 is the conversion test fails.  This implements parts the method
14674    invocation convertion (5.3).  */
14675
14676 static int
14677 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
14678      tree lhs_type, rhs_type;
14679 {
14680   /* 5.1.1: This is the identity conversion part. */
14681   if (lhs_type == rhs_type)
14682     return 1;
14683
14684   /* Reject non primitive types */
14685   if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
14686     return 0;
14687
14688   /* 5.1.2: widening primitive conversion. byte, even if it's smaller
14689      than a char can't be converted into a char. Short can't too, but
14690      the < test below takes care of that */
14691   if (lhs_type == char_type_node && rhs_type == byte_type_node)
14692     return 0;
14693
14694   /* Accept all promoted type here. Note, we can't use <= in the test
14695      below, because we still need to bounce out assignments of short
14696      to char and the likes */
14697   if (lhs_type == int_type_node
14698       && (rhs_type == promoted_byte_type_node
14699           || rhs_type == promoted_short_type_node
14700           || rhs_type == promoted_char_type_node
14701           || rhs_type == promoted_boolean_type_node))
14702     return 1;
14703
14704   /* From here, an integral is widened if its precision is smaller
14705      than the precision of the LHS or if the LHS is a floating point
14706      type, or the RHS is a float and the RHS a double. */
14707   if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type) 
14708        && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
14709       || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
14710       || (rhs_type == float_type_node && lhs_type == double_type_node))
14711     return 1;
14712
14713   return 0;
14714 }
14715
14716 /* Check that something of SOURCE type can be assigned or cast to
14717    something of DEST type at runtime. Return 1 if the operation is
14718    valid, 0 otherwise. If CAST is set to 1, we're treating the case
14719    were SOURCE is cast into DEST, which borrows a lot of the
14720    assignment check. */
14721
14722 static int
14723 valid_ref_assignconv_cast_p (source, dest, cast)
14724      tree source;
14725      tree dest;
14726      int cast;
14727 {
14728   /* SOURCE or DEST might be null if not from a declared entity. */
14729   if (!source || !dest)
14730     return 0;
14731   if (JNULLP_TYPE_P (source))
14732     return 1;
14733   if (TREE_CODE (source) == POINTER_TYPE)
14734     source = TREE_TYPE (source);
14735   if (TREE_CODE (dest) == POINTER_TYPE)
14736     dest = TREE_TYPE (dest);
14737   /* Case where SOURCE is a class type */
14738   if (TYPE_CLASS_P (source))
14739     {
14740       if (TYPE_CLASS_P (dest))
14741         return  (source == dest 
14742                  || inherits_from_p (source, dest)
14743                  || enclosing_context_p (source, dest)
14744                  || (cast && inherits_from_p (dest, source)));
14745       if (TYPE_INTERFACE_P (dest))
14746         {
14747           /* If doing a cast and SOURCE is final, the operation is
14748              always correct a compile time (because even if SOURCE
14749              does not implement DEST, a subclass of SOURCE might). */
14750           if (cast && !CLASS_FINAL (TYPE_NAME (source)))
14751             return 1;
14752           /* Otherwise, SOURCE must implement DEST */
14753           return interface_of_p (dest, source);
14754         }
14755       /* DEST is an array, cast permited if SOURCE is of Object type */
14756       return (cast && source == object_type_node ? 1 : 0);
14757     }
14758   if (TYPE_INTERFACE_P (source))
14759     {
14760       if (TYPE_CLASS_P (dest))
14761         {
14762           /* If not casting, DEST must be the Object type */
14763           if (!cast)
14764             return dest == object_type_node;
14765           /* We're doing a cast. The cast is always valid is class
14766              DEST is not final, otherwise, DEST must implement SOURCE */
14767           else if (!CLASS_FINAL (TYPE_NAME (dest)))
14768             return 1;
14769           else
14770             return interface_of_p (source, dest);
14771         }
14772       if (TYPE_INTERFACE_P (dest))
14773         {
14774           /* If doing a cast, then if SOURCE and DEST contain method
14775              with the same signature but different return type, then
14776              this is a (compile time) error */
14777           if (cast)
14778             {
14779               tree method_source, method_dest;
14780               tree source_type;
14781               tree source_sig;
14782               tree source_name;
14783               for (method_source = TYPE_METHODS (source); method_source; 
14784                    method_source = TREE_CHAIN (method_source))
14785                 {
14786                   source_sig = 
14787                     build_java_argument_signature (TREE_TYPE (method_source));
14788                   source_type = TREE_TYPE (TREE_TYPE (method_source));
14789                   source_name = DECL_NAME (method_source);
14790                   for (method_dest = TYPE_METHODS (dest);
14791                        method_dest; method_dest = TREE_CHAIN (method_dest))
14792                     if (source_sig == 
14793                         build_java_argument_signature (TREE_TYPE (method_dest))
14794                         && source_name == DECL_NAME (method_dest)
14795                         && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
14796                       return 0;
14797                 }
14798               return 1;
14799             }
14800           else
14801             return source == dest || interface_of_p (dest, source);
14802         }
14803       else                      /* Array */
14804         return (cast ? 
14805                 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
14806     }
14807   if (TYPE_ARRAY_P (source))
14808     {
14809       if (TYPE_CLASS_P (dest))
14810         return dest == object_type_node;
14811       /* Can't cast an array to an interface unless the interface is
14812          java.lang.Cloneable */
14813       if (TYPE_INTERFACE_P (dest))
14814         return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
14815       else                      /* Arrays */
14816         {
14817           tree source_element_type = TYPE_ARRAY_ELEMENT (source);
14818           tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
14819           
14820           /* In case of severe errors, they turn out null */
14821           if (!dest_element_type || !source_element_type)
14822             return 0;
14823           if (source_element_type == dest_element_type)
14824             return 1;
14825           return valid_ref_assignconv_cast_p (source_element_type,
14826                                               dest_element_type, cast);
14827         }
14828       return 0;
14829     }
14830   return 0;
14831 }
14832
14833 static int
14834 valid_cast_to_p (source, dest)
14835      tree source;
14836      tree dest;
14837 {
14838   if (TREE_CODE (source) == POINTER_TYPE)
14839     source = TREE_TYPE (source);
14840   if (TREE_CODE (dest) == POINTER_TYPE)
14841     dest = TREE_TYPE (dest);
14842
14843   if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
14844     return valid_ref_assignconv_cast_p (source, dest, 1);
14845
14846   else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
14847     return 1;
14848
14849   return 0;
14850 }
14851
14852 /* Method invocation conversion test. Return 1 if type SOURCE can be
14853    converted to type DEST through the methond invocation conversion
14854    process (5.3) */
14855
14856 static tree
14857 do_unary_numeric_promotion (arg)
14858      tree arg;
14859 {
14860   tree type = TREE_TYPE (arg);
14861   if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
14862       : TREE_CODE (type) == CHAR_TYPE)
14863     arg = convert (int_type_node, arg);
14864   return arg;
14865 }
14866
14867 /* Return a non zero value if SOURCE can be converted into DEST using
14868    the method invocation conversion rule (5.3).  */
14869 static int
14870 valid_method_invocation_conversion_p (dest, source)
14871      tree dest, source;
14872 {
14873   return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
14874            && valid_builtin_assignconv_identity_widening_p (dest, source))
14875           || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
14876               && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
14877               && valid_ref_assignconv_cast_p (source, dest, 0)));
14878 }
14879
14880 /* Build an incomplete binop expression. */
14881
14882 static tree
14883 build_binop (op, op_location, op1, op2)
14884      enum tree_code op;
14885      int op_location;
14886      tree op1, op2;
14887 {
14888   tree binop = build (op, NULL_TREE, op1, op2);
14889   TREE_SIDE_EFFECTS (binop) = 1;
14890   /* Store the location of the operator, for better error report. The
14891      string of the operator will be rebuild based on the OP value. */
14892   EXPR_WFL_LINECOL (binop) = op_location;
14893   return binop;
14894 }
14895
14896 /* Build the string of the operator retained by NODE. If NODE is part
14897    of a compound expression, add an '=' at the end of the string. This
14898    function is called when an error needs to be reported on an
14899    operator. The string is returned as a pointer to a static character
14900    buffer. */
14901
14902 static char *
14903 operator_string (node)
14904      tree node;
14905 {
14906 #define BUILD_OPERATOR_STRING(S)                                        \
14907   {                                                                     \
14908     sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
14909     return buffer;                                                      \
14910   }
14911   
14912   static char buffer [10];
14913   switch (TREE_CODE (node))
14914     {
14915     case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
14916     case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
14917     case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
14918     case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14919     case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
14920     case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
14921     case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
14922     case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
14923     case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
14924     case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
14925     case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
14926     case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
14927     case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
14928     case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
14929     case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
14930     case GT_EXPR: BUILD_OPERATOR_STRING (">");
14931     case GE_EXPR: BUILD_OPERATOR_STRING (">=");
14932     case LT_EXPR: BUILD_OPERATOR_STRING ("<");
14933     case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
14934     case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14935     case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
14936     case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
14937     case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
14938     case PREINCREMENT_EXPR:     /* Fall through */
14939     case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
14940     case PREDECREMENT_EXPR:     /* Fall through */
14941     case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
14942     default:
14943       fatal ("unregistered operator %s - operator_string",
14944              tree_code_name [TREE_CODE (node)]);
14945     }
14946   return NULL;
14947 #undef BUILD_OPERATOR_STRING
14948 }
14949
14950 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2.  */
14951
14952 static int
14953 java_decl_equiv (var_acc1, var_acc2)
14954      tree var_acc1, var_acc2;
14955 {
14956   if (JDECL_P (var_acc1))
14957     return (var_acc1 == var_acc2);
14958   
14959   return (TREE_CODE (var_acc1) == COMPONENT_REF
14960           && TREE_CODE (var_acc2) == COMPONENT_REF
14961           && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
14962              == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
14963           && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
14964 }
14965
14966 /* Return a non zero value if CODE is one of the operators that can be
14967    used in conjunction with the `=' operator in a compound assignment.  */
14968
14969 static int
14970 binop_compound_p (code)
14971     enum tree_code code;
14972 {
14973   int i;
14974   for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
14975     if (binop_lookup [i] == code)
14976       break;
14977
14978   return i < BINOP_COMPOUND_CANDIDATES;
14979 }
14980
14981 /* Reorganize after a fold to get SAVE_EXPR to generate what we want.  */
14982
14983 static tree
14984 java_refold (t)
14985      tree t;
14986 {
14987   tree c, b, ns, decl;
14988
14989   if (TREE_CODE (t) != MODIFY_EXPR)
14990     return t;
14991
14992   c = TREE_OPERAND (t, 1);
14993   if (! (c && TREE_CODE (c) == COMPOUND_EXPR
14994          && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
14995          && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
14996     return t;
14997
14998   /* Now the left branch of the binary operator. */
14999   b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
15000   if (! (b && TREE_CODE (b) == NOP_EXPR 
15001          && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
15002     return t;
15003
15004   ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
15005   if (! (ns && TREE_CODE (ns) == NOP_EXPR
15006          && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
15007     return t;
15008
15009   decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
15010   if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
15011       /* It's got to be the an equivalent decl */
15012       && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
15013     {
15014       /* Shorten the NOP_EXPR/SAVE_EXPR path. */
15015       TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
15016       /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
15017       TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
15018       /* Change the right part of the BINOP_EXPR */
15019       TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
15020     }
15021
15022   return t;
15023 }
15024
15025 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
15026    errors but we modify NODE so that it contains the type computed
15027    according to the expression, when it's fixed. Otherwise, we write
15028    error_mark_node as the type. It allows us to further the analysis
15029    of remaining nodes and detects more errors in certain cases.  */
15030
15031 static tree
15032 patch_binop (node, wfl_op1, wfl_op2)
15033      tree node;
15034      tree wfl_op1;
15035      tree wfl_op2;
15036 {
15037   tree op1 = TREE_OPERAND (node, 0);
15038   tree op2 = TREE_OPERAND (node, 1);
15039   tree op1_type = TREE_TYPE (op1);
15040   tree op2_type = TREE_TYPE (op2);
15041   tree prom_type = NULL_TREE, cn;
15042   int code = TREE_CODE (node);
15043
15044   /* If 1, tell the routine that we have to return error_mark_node
15045      after checking for the initialization of the RHS */
15046   int error_found = 0;
15047
15048   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15049
15050   switch (code)
15051     {
15052     /* 15.16 Multiplicative operators */
15053     case MULT_EXPR:             /* 15.16.1 Multiplication Operator * */
15054     case RDIV_EXPR:             /* 15.16.2 Division Operator / */
15055     case TRUNC_DIV_EXPR:        /* 15.16.2 Integral type Division Operator / */
15056     case TRUNC_MOD_EXPR:        /* 15.16.3 Remainder operator % */
15057       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
15058         {
15059           if (!JPRIMITIVE_TYPE_P (op1_type))
15060             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15061           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
15062             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15063           TREE_TYPE (node) = error_mark_node;
15064           error_found = 1;
15065           break;
15066         }
15067       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15068       /* Change the division operator if necessary */
15069       if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
15070         TREE_SET_CODE (node, TRUNC_DIV_EXPR);
15071
15072       if (TREE_CODE (prom_type) == INTEGER_TYPE
15073           && flag_use_divide_subroutine
15074           && ! flag_emit_class_files
15075           && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
15076         return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
15077  
15078       /* This one is more complicated. FLOATs are processed by a
15079          function call to soft_fmod. Duplicate the value of the
15080          COMPOUND_ASSIGN_P flag. */
15081       if (code == TRUNC_MOD_EXPR)
15082         {
15083           tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
15084           COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
15085           TREE_SIDE_EFFECTS (mod)
15086             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15087           return mod;
15088         }
15089       break;
15090
15091     /* 15.17 Additive Operators */
15092     case PLUS_EXPR:             /* 15.17.1 String Concatenation Operator + */
15093
15094       /* Operation is valid if either one argument is a string
15095          constant, a String object or a StringBuffer crafted for the
15096          purpose of the a previous usage of the String concatenation
15097          operator */
15098
15099       if (TREE_CODE (op1) == STRING_CST 
15100           || TREE_CODE (op2) == STRING_CST
15101           || JSTRING_TYPE_P (op1_type)
15102           || JSTRING_TYPE_P (op2_type)
15103           || IS_CRAFTED_STRING_BUFFER_P (op1)
15104           || IS_CRAFTED_STRING_BUFFER_P (op2))
15105         return build_string_concatenation (op1, op2);
15106
15107     case MINUS_EXPR:            /* 15.17.2 Additive Operators (+ and -) for
15108                                    Numeric Types */
15109       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
15110         {
15111           if (!JPRIMITIVE_TYPE_P (op1_type))
15112             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15113           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
15114             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15115           TREE_TYPE (node) = error_mark_node;
15116           error_found = 1;
15117           break;
15118         }
15119       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15120       break;
15121
15122     /* 15.18 Shift Operators */
15123     case LSHIFT_EXPR:
15124     case RSHIFT_EXPR:
15125     case URSHIFT_EXPR:
15126       if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
15127         {
15128           if (!JINTEGRAL_TYPE_P (op1_type))
15129             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15130           else
15131             {
15132               if (JPRIMITIVE_TYPE_P (op2_type))
15133                 parse_error_context (wfl_operator,
15134                                      "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
15135                                      operator_string (node),
15136                                      lang_printable_name (op2_type, 0));
15137               else
15138                 parse_error_context (wfl_operator,
15139                                      "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral", 
15140                                      operator_string (node),
15141                                      lang_printable_name (op2_type, 0));
15142             }
15143           TREE_TYPE (node) = error_mark_node;
15144           error_found = 1;
15145           break;
15146         }
15147
15148       /* Unary numeric promotion (5.6.1) is performed on each operand
15149          separatly */
15150       op1 = do_unary_numeric_promotion (op1);
15151       op2 = do_unary_numeric_promotion (op2);
15152
15153       /* The type of the shift expression is the type of the promoted
15154          type of the left-hand operand */
15155       prom_type = TREE_TYPE (op1);
15156
15157       /* Shift int only up to 0x1f and long up to 0x3f */
15158       if (prom_type == int_type_node)
15159         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
15160                            build_int_2 (0x1f, 0)));
15161       else
15162         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
15163                            build_int_2 (0x3f, 0)));
15164
15165       /* The >>> operator is a >> operating on unsigned quantities */
15166       if (code == URSHIFT_EXPR && ! flag_emit_class_files)
15167         {
15168           tree to_return;
15169           tree utype = unsigned_type (prom_type);
15170           op1 = convert (utype, op1);
15171           TREE_SET_CODE (node, RSHIFT_EXPR);
15172           TREE_OPERAND (node, 0) = op1;
15173           TREE_OPERAND (node, 1) = op2;
15174           TREE_TYPE (node) = utype;
15175           to_return = convert (prom_type, node);
15176           /* Copy the original value of the COMPOUND_ASSIGN_P flag */
15177           COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
15178           TREE_SIDE_EFFECTS (to_return)
15179             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15180           return to_return;
15181         }
15182       break;
15183
15184       /* 15.19.1 Type Comparison Operator instaceof */
15185     case INSTANCEOF_EXPR:
15186
15187       TREE_TYPE (node) = boolean_type_node;
15188
15189       if (!(op2_type = resolve_type_during_patch (op2)))
15190         return error_mark_node;
15191
15192       /* The first operand must be a reference type or the null type */
15193       if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
15194         error_found = 1;        /* Error reported further below */
15195
15196       /* The second operand must be a reference type */
15197       if (!JREFERENCE_TYPE_P (op2_type))
15198         {
15199           SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
15200           parse_error_context
15201             (wfl_operator, "Invalid argument `%s' for `instanceof'",
15202              lang_printable_name (op2_type, 0));
15203           error_found = 1;
15204         }
15205
15206       if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
15207         {
15208           /* If the first operand is null, the result is always false */
15209           if (op1 == null_pointer_node)
15210             return boolean_false_node;
15211           else if (flag_emit_class_files)
15212             {
15213               TREE_OPERAND (node, 1) = op2_type;
15214               TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
15215               return node;
15216             }
15217           /* Otherwise we have to invoke instance of to figure it out */
15218           else
15219             return build_instanceof (op1, op2_type);
15220         }
15221       /* There is no way the expression operand can be an instance of
15222          the type operand. This is a compile time error. */
15223       else
15224         {
15225           char *t1 = xstrdup (lang_printable_name (op1_type, 0));
15226           SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
15227           parse_error_context 
15228             (wfl_operator, "Impossible for `%s' to be instance of `%s'",
15229              t1, lang_printable_name (op2_type, 0));
15230           free (t1);
15231           error_found = 1;
15232         }
15233       
15234       break;
15235
15236       /* 15.21 Bitwise and Logical Operators */
15237     case BIT_AND_EXPR:
15238     case BIT_XOR_EXPR:
15239     case BIT_IOR_EXPR:
15240       if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
15241         /* Binary numeric promotion is performed on both operand and the
15242            expression retain that type */
15243         prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15244
15245       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE 
15246                && TREE_CODE (op1_type) == BOOLEAN_TYPE)
15247         /* The type of the bitwise operator expression is BOOLEAN */
15248         prom_type = boolean_type_node;
15249       else
15250         {
15251           if (!JINTEGRAL_TYPE_P (op1_type))
15252             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15253           if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
15254             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
15255           TREE_TYPE (node) = error_mark_node;
15256           error_found = 1;
15257           /* Insert a break here if adding thing before the switch's
15258              break for this case */
15259         }
15260       break;
15261
15262       /* 15.22 Conditional-And Operator */
15263     case TRUTH_ANDIF_EXPR:
15264       /* 15.23 Conditional-Or Operator */
15265     case TRUTH_ORIF_EXPR:
15266       /* Operands must be of BOOLEAN type */
15267       if (TREE_CODE (op1_type) != BOOLEAN_TYPE || 
15268           TREE_CODE (op2_type) != BOOLEAN_TYPE)
15269         {
15270           if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
15271             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
15272           if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
15273             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
15274           TREE_TYPE (node) = boolean_type_node;
15275           error_found = 1;
15276           break;
15277         }
15278       /* The type of the conditional operators is BOOLEAN */
15279       prom_type = boolean_type_node;
15280       break;
15281
15282       /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
15283     case LT_EXPR:
15284     case GT_EXPR:
15285     case LE_EXPR:
15286     case GE_EXPR:
15287       /* The type of each of the operands must be a primitive numeric
15288          type */
15289       if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
15290         {
15291           if (!JNUMERIC_TYPE_P (op1_type))
15292             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15293           if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
15294             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15295           TREE_TYPE (node) = boolean_type_node;
15296           error_found = 1;
15297           break;
15298         }
15299       /* Binary numeric promotion is performed on the operands */
15300       binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15301       /* The type of the relation expression is always BOOLEAN */
15302       prom_type = boolean_type_node;
15303       break;
15304
15305       /* 15.20 Equality Operator */
15306     case EQ_EXPR:
15307     case NE_EXPR:
15308       /* It's time for us to patch the strings. */
15309       if ((cn = patch_string (op1))) 
15310        {
15311          op1 = cn;
15312          op1_type = TREE_TYPE (op1);
15313        }
15314       if ((cn = patch_string (op2))) 
15315        {
15316          op2 = cn;
15317          op2_type = TREE_TYPE (op2);
15318        }
15319       
15320       /* 15.20.1 Numerical Equality Operators == and != */
15321       /* Binary numeric promotion is performed on the operands */
15322       if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
15323         binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15324       
15325       /* 15.20.2 Boolean Equality Operators == and != */
15326       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
15327           TREE_CODE (op2_type) == BOOLEAN_TYPE)
15328         ;                       /* Nothing to do here */
15329       
15330       /* 15.20.3 Reference Equality Operators == and != */
15331       /* Types have to be either references or the null type. If
15332          they're references, it must be possible to convert either
15333          type to the other by casting conversion. */
15334       else if (op1 == null_pointer_node || op2 == null_pointer_node 
15335                || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
15336                    && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
15337                        || valid_ref_assignconv_cast_p (op2_type, 
15338                                                        op1_type, 1))))
15339         ;                       /* Nothing to do here */
15340           
15341       /* Else we have an error figure what can't be converted into
15342          what and report the error */
15343       else
15344         {
15345           char *t1;
15346           t1 = xstrdup (lang_printable_name (op1_type, 0));
15347           parse_error_context 
15348             (wfl_operator,
15349              "Incompatible type for `%s'. Can't convert `%s' to `%s'",
15350              operator_string (node), t1, 
15351              lang_printable_name (op2_type, 0));
15352           free (t1);
15353           TREE_TYPE (node) = boolean_type_node;
15354           error_found = 1;
15355           break;
15356         }
15357       prom_type = boolean_type_node;
15358       break;
15359     }
15360
15361   if (error_found)
15362     return error_mark_node;
15363
15364   TREE_OPERAND (node, 0) = op1;
15365   TREE_OPERAND (node, 1) = op2;
15366   TREE_TYPE (node) = prom_type;
15367   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15368   
15369   if (flag_emit_xref)
15370     return node;
15371
15372   /* fold does not respect side-effect order as required for Java but not C.
15373    * Also, it sometimes create SAVE_EXPRs which are bad when emitting
15374    * bytecode.
15375    */
15376   if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
15377       : ! TREE_SIDE_EFFECTS (node))
15378     node = fold (node);
15379   return node;
15380 }
15381
15382 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
15383    zero value, the value of CSTE comes after the valude of STRING */
15384
15385 static tree
15386 do_merge_string_cste (cste, string, string_len, after)
15387      tree cste;
15388      const char *string;
15389      int string_len, after;
15390 {
15391   int len = TREE_STRING_LENGTH (cste) + string_len;
15392   const char *old = TREE_STRING_POINTER (cste);
15393   TREE_STRING_LENGTH (cste) = len;
15394   TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
15395   if (after)
15396     {
15397       strcpy (TREE_STRING_POINTER (cste), string);
15398       strcat (TREE_STRING_POINTER (cste), old);
15399     }
15400   else
15401     {
15402       strcpy (TREE_STRING_POINTER (cste), old);
15403       strcat (TREE_STRING_POINTER (cste), string);
15404     }
15405   return cste;
15406 }
15407
15408 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
15409    new STRING_CST on success, NULL_TREE on failure */
15410
15411 static tree
15412 merge_string_cste (op1, op2, after)
15413      tree op1, op2;
15414      int after;
15415 {
15416   /* Handle two string constants right away */
15417   if (TREE_CODE (op2) == STRING_CST)
15418     return do_merge_string_cste (op1, TREE_STRING_POINTER (op2), 
15419                                  TREE_STRING_LENGTH (op2), after);
15420   
15421   /* Reasonable integer constant can be treated right away */
15422   if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
15423     {
15424       static const char *boolean_true = "true";
15425       static const char *boolean_false = "false";
15426       static const char *null_pointer = "null";
15427       char ch[3];
15428       const char *string;
15429       
15430       if (op2 == boolean_true_node)
15431         string = boolean_true;
15432       else if (op2 == boolean_false_node)
15433         string = boolean_false;
15434       else if (op2 == null_pointer_node)
15435         string = null_pointer;
15436       else if (TREE_TYPE (op2) == char_type_node)
15437         {
15438           ch[0] = (char )TREE_INT_CST_LOW (op2);
15439           ch[1] = '\0';
15440           string = ch;
15441         }
15442       else
15443           string = print_int_node (op2);
15444       
15445       return do_merge_string_cste (op1, string, strlen (string), after);
15446     }
15447   return NULL_TREE;
15448 }
15449
15450 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
15451    has to be a STRING_CST and the other part must be a STRING_CST or a
15452    INTEGRAL constant. Return a new STRING_CST if the operation
15453    succeed, NULL_TREE otherwise.
15454
15455    If the case we want to optimize for space, we might want to return
15456    NULL_TREE for each invocation of this routine. FIXME */
15457
15458 static tree
15459 string_constant_concatenation (op1, op2)
15460      tree op1, op2;
15461 {
15462   if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
15463     {
15464       tree string, rest;
15465       int invert;
15466       
15467       string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
15468       rest   = (string == op1 ? op2 : op1);
15469       invert = (string == op1 ? 0 : 1 );
15470       
15471       /* Walk REST, only if it looks reasonable */
15472       if (TREE_CODE (rest) != STRING_CST
15473           && !IS_CRAFTED_STRING_BUFFER_P (rest)
15474           && !JSTRING_TYPE_P (TREE_TYPE (rest))
15475           && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
15476         {
15477           rest = java_complete_tree (rest);
15478           if (rest == error_mark_node)
15479             return error_mark_node;
15480           rest = fold (rest);
15481         }
15482       return merge_string_cste (string, rest, invert);
15483     }
15484   return NULL_TREE;
15485 }
15486
15487 /* Implement the `+' operator. Does static optimization if possible,
15488    otherwise create (if necessary) and append elements to a
15489    StringBuffer. The StringBuffer will be carried around until it is
15490    used for a function call or an assignment. Then toString() will be
15491    called on it to turn it into a String object. */
15492
15493 static tree
15494 build_string_concatenation (op1, op2)
15495      tree op1, op2;
15496 {
15497   tree result;
15498   int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15499
15500   if (flag_emit_xref)
15501     return build (PLUS_EXPR, string_type_node, op1, op2);
15502   
15503   /* Try to do some static optimization */
15504   if ((result = string_constant_concatenation (op1, op2)))
15505     return result;
15506
15507   /* Discard empty strings on either side of the expression */
15508   if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
15509     {
15510       op1 = op2;
15511       op2 = NULL_TREE;
15512     }
15513   else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
15514     op2 = NULL_TREE;
15515
15516   /* If operands are string constant, turn then into object references */
15517   if (TREE_CODE (op1) == STRING_CST)
15518     op1 = patch_string_cst (op1);
15519   if (op2 && TREE_CODE (op2) == STRING_CST)
15520     op2 = patch_string_cst (op2);
15521
15522   /* If either one of the constant is null and the other non null
15523      operand is a String object, return it. */
15524   if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
15525     return op1;
15526
15527   /* If OP1 isn't already a StringBuffer, create and
15528      initialize a new one */
15529   if (!IS_CRAFTED_STRING_BUFFER_P (op1))
15530     {
15531       /* Two solutions here: 
15532          1) OP1 is a constant string reference, we call new StringBuffer(OP1)
15533          2) OP1 is something else, we call new StringBuffer().append(OP1).  */
15534       if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1)))
15535         op1 = BUILD_STRING_BUFFER (op1);
15536       else
15537         {
15538           tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
15539           op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
15540         }
15541     }
15542
15543   if (op2)
15544     {
15545       /* OP1 is no longer the last node holding a crafted StringBuffer */
15546       IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
15547       /* Create a node for `{new...,xxx}.append (op2)' */
15548       if (op2)
15549         op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
15550     }
15551
15552   /* Mark the last node holding a crafted StringBuffer */
15553   IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
15554
15555   TREE_SIDE_EFFECTS (op1) = side_effects;
15556   return op1;
15557 }
15558
15559 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
15560    StringBuffer. If no string were found to be patched, return
15561    NULL. */
15562
15563 static tree
15564 patch_string (node)
15565     tree node;
15566 {
15567   if (node == error_mark_node)
15568     return error_mark_node;
15569   if (TREE_CODE (node) == STRING_CST)
15570     return patch_string_cst (node);
15571   else if (IS_CRAFTED_STRING_BUFFER_P (node))
15572     {
15573       int saved = ctxp->explicit_constructor_p;
15574       tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
15575       tree ret;
15576       /* Temporary disable forbid the use of `this'. */
15577       ctxp->explicit_constructor_p = 0;
15578       ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
15579       /* String concatenation arguments must be evaluated in order too. */
15580       ret = force_evaluation_order (ret);
15581       /* Restore it at its previous value */
15582       ctxp->explicit_constructor_p = saved;
15583       return ret;
15584     }
15585   return NULL_TREE;
15586 }
15587
15588 /* Build the internal representation of a string constant.  */
15589
15590 static tree
15591 patch_string_cst (node)
15592      tree node;
15593 {
15594   int location;
15595   if (! flag_emit_class_files)
15596     {
15597       push_obstacks (&permanent_obstack, &permanent_obstack);
15598       node = get_identifier (TREE_STRING_POINTER (node));
15599       location = alloc_name_constant (CONSTANT_String, node);
15600       node = build_ref_from_constant_pool (location);
15601       pop_obstacks ();
15602     }
15603   TREE_TYPE (node) = string_ptr_type_node;
15604   TREE_CONSTANT (node) = 1;
15605   return node;
15606 }
15607
15608 /* Build an incomplete unary operator expression. */
15609
15610 static tree
15611 build_unaryop (op_token, op_location, op1)
15612      int op_token, op_location;
15613      tree op1;
15614 {
15615   enum tree_code op;
15616   tree unaryop;
15617   switch (op_token)
15618     {
15619     case PLUS_TK: op = UNARY_PLUS_EXPR; break;
15620     case MINUS_TK: op = NEGATE_EXPR; break;
15621     case NEG_TK: op = TRUTH_NOT_EXPR; break;
15622     case NOT_TK: op = BIT_NOT_EXPR; break;
15623     default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
15624                     op_token);
15625     }
15626
15627   unaryop = build1 (op, NULL_TREE, op1);
15628   TREE_SIDE_EFFECTS (unaryop) = 1;
15629   /* Store the location of the operator, for better error report. The
15630      string of the operator will be rebuild based on the OP value. */
15631   EXPR_WFL_LINECOL (unaryop) = op_location;
15632   return unaryop;
15633 }
15634
15635 /* Special case for the ++/-- operators, since they require an extra
15636    argument to build, which is set to NULL and patched
15637    later. IS_POST_P is 1 if the operator, 0 otherwise.  */
15638
15639 static tree
15640 build_incdec (op_token, op_location, op1, is_post_p)
15641      int op_token, op_location;
15642      tree op1;
15643      int is_post_p;
15644 {
15645   static enum tree_code lookup [2][2] = 
15646     {
15647       { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
15648       { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
15649     };
15650   tree node = build (lookup [is_post_p][(op_token - DECR_TK)], 
15651                      NULL_TREE, op1, NULL_TREE);
15652   TREE_SIDE_EFFECTS (node) = 1;
15653   /* Store the location of the operator, for better error report. The
15654      string of the operator will be rebuild based on the OP value. */
15655   EXPR_WFL_LINECOL (node) = op_location;
15656   return node;
15657 }     
15658
15659 /* Build an incomplete cast operator, based on the use of the
15660    CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
15661    set. java_complete_tree is trained to walk a CONVERT_EXPR even
15662    though its type is already set.  */
15663
15664 static tree
15665 build_cast (location, type, exp)
15666      int location;
15667      tree type, exp;
15668 {
15669   tree node = build1 (CONVERT_EXPR, type, exp);
15670   EXPR_WFL_LINECOL (node) = location;
15671   return node;
15672 }
15673
15674 /* Build an incomplete class reference operator.  */
15675 static tree
15676 build_incomplete_class_ref (location, class_name)
15677     int location;
15678     tree class_name;
15679 {
15680   tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
15681   EXPR_WFL_LINECOL (node) = location;
15682   return node;
15683 }
15684
15685 /* Complete an incomplete class reference operator.  */
15686 static tree
15687 patch_incomplete_class_ref (node)
15688     tree node;
15689 {
15690   tree type = TREE_OPERAND (node, 0);
15691   tree ref_type;
15692
15693   if (!(ref_type = resolve_type_during_patch (type)))
15694     return error_mark_node;
15695
15696   if (!flag_emit_class_files || JPRIMITIVE_TYPE_P (ref_type))
15697     {
15698       /* A class referenced by `foo.class' is initialized.  */
15699       return build_class_init (ref_type, build_class_ref (ref_type));
15700     }
15701
15702   /* If we're emitting class files and we have to deal with non
15703      primitive types, we invoke (and consider generating) the
15704      synthetic static method `class$'. */
15705   if (!TYPE_DOT_CLASS (current_class))
15706       build_dot_class_method (current_class);
15707   ref_type = 
15708     build_dot_class_method_invocation (DECL_NAME (TYPE_NAME (ref_type)));
15709   return java_complete_tree (ref_type);
15710 }
15711
15712 /* 15.14 Unary operators. We return error_mark_node in case of error,
15713    but preserve the type of NODE if the type is fixed.  */
15714
15715 static tree
15716 patch_unaryop (node, wfl_op)
15717      tree node;
15718      tree wfl_op;
15719 {
15720   tree op = TREE_OPERAND (node, 0);
15721   tree op_type = TREE_TYPE (op);
15722   tree prom_type = NULL_TREE, value, decl;
15723   int outer_field_flag = 0;
15724   int code = TREE_CODE (node);
15725   int error_found = 0;
15726
15727   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15728
15729   switch (code)
15730     {
15731       /* 15.13.2 Postfix Increment Operator ++ */
15732     case POSTINCREMENT_EXPR:
15733       /* 15.13.3 Postfix Increment Operator -- */
15734     case POSTDECREMENT_EXPR:
15735       /* 15.14.1 Prefix Increment Operator ++ */
15736     case PREINCREMENT_EXPR:
15737       /* 15.14.2 Prefix Decrement Operator -- */
15738     case PREDECREMENT_EXPR:
15739       op = decl = strip_out_static_field_access_decl (op);
15740       outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
15741       /* We might be trying to change an outer field accessed using
15742          access method. */
15743       if (outer_field_flag)
15744         {
15745           /* Retrieve the decl of the field we're trying to access. We
15746              do that by first retrieving the function we would call to
15747              access the field. It has been already verified that this
15748              field isn't final */
15749           if (flag_emit_class_files)
15750             decl = TREE_OPERAND (op, 0);
15751           else
15752             decl = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (op, 0), 0), 0);
15753           decl = DECL_FUNCTION_ACCESS_DECL (decl);
15754         }
15755       /* We really should have a JAVA_ARRAY_EXPR to avoid this */
15756       else if (!JDECL_P (decl) 
15757           && TREE_CODE (decl) != COMPONENT_REF
15758           && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
15759           && TREE_CODE (decl) != INDIRECT_REF
15760           && !(TREE_CODE (decl) == COMPOUND_EXPR
15761                && TREE_OPERAND (decl, 1)
15762                && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
15763         {
15764           tree lvalue;
15765           /* Before screaming, check that we're not in fact trying to
15766              increment a optimized static final access, in which case
15767              we issue an different error message. */
15768           if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
15769                 && resolve_expression_name (wfl_op, &lvalue)
15770                 && check_final_assignment (lvalue, wfl_op)))
15771             parse_error_context (wfl_operator, "Invalid argument to `%s'",
15772                                  operator_string (node));
15773           TREE_TYPE (node) = error_mark_node;
15774           error_found = 1;
15775         }
15776       
15777       if (check_final_assignment (op, wfl_op))
15778         error_found = 1;
15779
15780       /* From now on, we know that op if a variable and that it has a
15781          valid wfl. We use wfl_op to locate errors related to the
15782          ++/-- operand. */
15783       else if (!JNUMERIC_TYPE_P (op_type))
15784         {
15785           parse_error_context
15786             (wfl_op, "Invalid argument type `%s' to `%s'",
15787              lang_printable_name (op_type, 0), operator_string (node));
15788           TREE_TYPE (node) = error_mark_node;
15789           error_found = 1;
15790         }
15791       else
15792         {
15793           /* Before the addition, binary numeric promotion is performed on
15794              both operands, if really necessary */
15795           if (JINTEGRAL_TYPE_P (op_type))
15796             {
15797               value = build_int_2 (1, 0);
15798               TREE_TYPE (value) = TREE_TYPE (node) = op_type;
15799             }
15800           else
15801             {
15802               value = build_int_2 (1, 0);
15803               TREE_TYPE (node) = 
15804                 binary_numeric_promotion (op_type, 
15805                                           TREE_TYPE (value), &op, &value);
15806             }
15807
15808           /* We remember we might be accessing an outer field */
15809           if (outer_field_flag)
15810             {
15811               /* We re-generate an access to the field */
15812               value = build (PLUS_EXPR, TREE_TYPE (op), 
15813                              build_outer_field_access (wfl_op, decl), value);
15814                                                     
15815               /* And we patch the original access$() into a write 
15816                  with plus_op as a rhs */
15817               return outer_field_access_fix (node, op, value);
15818             }
15819
15820           /* And write back into the node. */
15821           TREE_OPERAND (node, 0) = op;
15822           TREE_OPERAND (node, 1) = value;
15823           /* Convert the overall back into its original type, if
15824              necessary, and return */
15825           if (JINTEGRAL_TYPE_P (op_type))
15826             return fold (node);
15827           else
15828             return fold (convert (op_type, node));
15829         }
15830       break;
15831
15832       /* 15.14.3 Unary Plus Operator + */
15833     case UNARY_PLUS_EXPR:
15834       /* 15.14.4 Unary Minus Operator - */
15835     case NEGATE_EXPR:
15836       if (!JNUMERIC_TYPE_P (op_type))
15837         {
15838           ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
15839           TREE_TYPE (node) = error_mark_node;
15840           error_found = 1;
15841         }
15842       /* Unary numeric promotion is performed on operand */
15843       else
15844         {
15845           op = do_unary_numeric_promotion (op);
15846           prom_type = TREE_TYPE (op);
15847           if (code == UNARY_PLUS_EXPR)
15848             return fold (op);
15849         }
15850       break;
15851
15852       /* 15.14.5 Bitwise Complement Operator ~ */
15853     case BIT_NOT_EXPR:
15854       if (!JINTEGRAL_TYPE_P (op_type))
15855         {
15856           ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
15857           TREE_TYPE (node) = error_mark_node;
15858           error_found = 1;
15859         }
15860       else
15861         {
15862           op = do_unary_numeric_promotion (op);
15863           prom_type = TREE_TYPE (op);
15864         }
15865       break;
15866
15867       /* 15.14.6 Logical Complement Operator ! */
15868     case TRUTH_NOT_EXPR:
15869       if (TREE_CODE (op_type) != BOOLEAN_TYPE)
15870         {
15871           ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
15872           /* But the type is known. We will report an error if further
15873              attempt of a assignment is made with this rhs */
15874           TREE_TYPE (node) = boolean_type_node;
15875           error_found = 1;
15876         }
15877       else
15878         prom_type = boolean_type_node;
15879       break;
15880
15881       /* 15.15 Cast Expression */
15882     case CONVERT_EXPR:
15883       value = patch_cast (node, wfl_operator);
15884       if (value == error_mark_node)
15885         {
15886           /* If this cast is part of an assignment, we tell the code
15887              that deals with it not to complain about a mismatch,
15888              because things have been cast, anyways */
15889           TREE_TYPE (node) = error_mark_node;
15890           error_found = 1;
15891         }
15892       else
15893         {
15894           value = fold (value);
15895           TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
15896           return value;
15897         }
15898       break;
15899     }
15900   
15901   if (error_found)
15902     return error_mark_node;
15903
15904   /* There are cases where node has been replaced by something else
15905      and we don't end up returning here: UNARY_PLUS_EXPR,
15906      CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
15907   TREE_OPERAND (node, 0) = fold (op);
15908   TREE_TYPE (node) = prom_type;
15909   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
15910   return fold (node);
15911 }
15912
15913 /* Generic type resolution that sometimes takes place during node
15914    patching. Returned the resolved type or generate an error
15915    message. Return the resolved type or NULL_TREE.  */
15916
15917 static tree
15918 resolve_type_during_patch (type)
15919      tree type;
15920 {
15921   if (unresolved_type_p (type, NULL))
15922     {
15923       tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
15924       if (!type_decl)
15925         {
15926           parse_error_context (type, 
15927                                "Class `%s' not found in type declaration",
15928                                IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
15929           return NULL_TREE;
15930         }
15931       else
15932         {
15933           CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
15934           return TREE_TYPE (type_decl);
15935         }
15936     }
15937   return type;
15938 }
15939 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
15940    found. Otherwise NODE or something meant to replace it is returned.  */
15941
15942 static tree
15943 patch_cast (node, wfl_operator)
15944      tree node;
15945      tree wfl_operator;
15946 {
15947   tree op = TREE_OPERAND (node, 0);
15948   tree op_type = TREE_TYPE (op);
15949   tree cast_type = TREE_TYPE (node);
15950   char *t1;
15951
15952   /* First resolve OP_TYPE if unresolved */
15953   if (!(cast_type = resolve_type_during_patch (cast_type)))
15954     return error_mark_node;
15955
15956   /* Check on cast that are proven correct at compile time */
15957   if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
15958     {
15959       /* Same type */
15960       if (cast_type == op_type)
15961         return node;
15962
15963       /* float and double type are converted to the original type main
15964          variant and then to the target type. */
15965       if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
15966         op = convert (integer_type_node, op);
15967
15968       /* Try widening/narowwing convertion. Potentially, things need
15969          to be worked out in gcc so we implement the extreme cases
15970          correctly. fold_convert() needs to be fixed. */
15971       return convert (cast_type, op);
15972     }
15973
15974   /* It's also valid to cast a boolean into a boolean */
15975   if (op_type == boolean_type_node && cast_type == boolean_type_node)
15976     return node;
15977
15978   /* null can be casted to references */
15979   if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
15980     return build_null_of_type (cast_type);
15981
15982   /* The remaining legal casts involve conversion between reference
15983      types. Check for their compile time correctness. */
15984   if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type) 
15985       && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
15986     {
15987       TREE_TYPE (node) = promote_type (cast_type);
15988       /* Now, the case can be determined correct at compile time if
15989          OP_TYPE can be converted into CAST_TYPE by assignment
15990          conversion (5.2) */
15991
15992       if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
15993         {
15994           TREE_SET_CODE (node, NOP_EXPR);
15995           return node;
15996         }
15997
15998       if (flag_emit_class_files)
15999         {
16000           TREE_SET_CODE (node, CONVERT_EXPR);
16001           return node;
16002         }
16003
16004       /* The cast requires a run-time check */
16005       return build (CALL_EXPR, promote_type (cast_type),
16006                     build_address_of (soft_checkcast_node),
16007                     tree_cons (NULL_TREE, build_class_ref (cast_type),
16008                                build_tree_list (NULL_TREE, op)),
16009                     NULL_TREE);
16010     }
16011
16012   /* Any other casts are proven incorrect at compile time */
16013   t1 = xstrdup (lang_printable_name (op_type, 0));
16014   parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
16015                        t1, lang_printable_name (cast_type, 0));
16016   free (t1);
16017   return error_mark_node;
16018 }
16019
16020 /* Build a null constant and give it the type TYPE.  */
16021
16022 static tree
16023 build_null_of_type (type)
16024      tree type;
16025 {
16026   tree node = build_int_2 (0, 0);
16027   TREE_TYPE (node) = promote_type (type);
16028   return node;
16029 }
16030
16031 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
16032    a list of indices. */
16033 static tree
16034 build_array_ref (location, array, index)
16035      int location;
16036      tree array, index;
16037 {
16038   tree node = build (ARRAY_REF, NULL_TREE, array, index);
16039   EXPR_WFL_LINECOL (node) = location;
16040   return node;
16041 }
16042
16043 /* 15.12 Array Access Expression */
16044
16045 static tree
16046 patch_array_ref (node)
16047      tree node;
16048 {
16049   tree array = TREE_OPERAND (node, 0);
16050   tree array_type  = TREE_TYPE (array);
16051   tree index = TREE_OPERAND (node, 1);
16052   tree index_type = TREE_TYPE (index);
16053   int error_found = 0;
16054
16055   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16056
16057   if (TREE_CODE (array_type) == POINTER_TYPE)
16058     array_type = TREE_TYPE (array_type);
16059
16060   /* The array reference must be an array */
16061   if (!TYPE_ARRAY_P (array_type))
16062     {
16063       parse_error_context 
16064         (wfl_operator,
16065          "`[]' can only be applied to arrays. It can't be applied to `%s'",
16066          lang_printable_name (array_type, 0));
16067       TREE_TYPE (node) = error_mark_node;
16068       error_found = 1;
16069     }
16070
16071   /* The array index undergoes unary numeric promotion. The promoted
16072      type must be int */
16073   index = do_unary_numeric_promotion (index);
16074   if (TREE_TYPE (index) != int_type_node)
16075     {
16076       if (valid_cast_to_p (index_type, int_type_node))
16077         parse_error_context (wfl_operator,
16078    "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
16079                              lang_printable_name (index_type, 0));
16080       else
16081         parse_error_context (wfl_operator,
16082           "Incompatible type for `[]'. Can't convert `%s' to `int'",
16083                              lang_printable_name (index_type, 0));
16084       TREE_TYPE (node) = error_mark_node;
16085       error_found = 1;
16086     }
16087
16088   if (error_found)
16089     return error_mark_node;
16090
16091   array_type = TYPE_ARRAY_ELEMENT (array_type);
16092
16093   if (flag_emit_class_files || flag_emit_xref)
16094     {
16095       TREE_OPERAND (node, 0) = array;
16096       TREE_OPERAND (node, 1) = index;
16097     }
16098   else
16099     {
16100       /* The save_expr is for correct evaluation order.  It would be cleaner
16101          to use force_evaluation_order (see comment there), but that is
16102          difficult when we also have to deal with bounds checking. */
16103       if (TREE_SIDE_EFFECTS (index))
16104         array = save_expr (array);
16105       node = build_java_arrayaccess (array, array_type, index);
16106       if (TREE_SIDE_EFFECTS (index))
16107         node = build (COMPOUND_EXPR, array_type, array, node);
16108     }
16109   TREE_TYPE (node) = array_type;
16110   return node;
16111 }
16112
16113 /* 15.9 Array Creation Expressions */
16114
16115 static tree
16116 build_newarray_node (type, dims, extra_dims)
16117      tree type;
16118      tree dims;
16119      int extra_dims;
16120 {
16121   tree node =
16122     build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims), 
16123            build_int_2 (extra_dims, 0));
16124   return node;
16125 }
16126
16127 static tree
16128 patch_newarray (node)
16129      tree node;
16130 {
16131   tree type = TREE_OPERAND (node, 0);
16132   tree dims = TREE_OPERAND (node, 1);
16133   tree cdim, array_type;
16134   int error_found = 0;
16135   int ndims = 0;
16136   int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
16137
16138   /* Dimension types are verified. It's better for the types to be
16139      verified in order. */
16140   for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
16141     {
16142       int dim_error = 0;
16143       tree dim = TREE_VALUE (cdim);
16144
16145       /* Dim might have been saved during its evaluation */
16146       dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
16147
16148       /* The type of each specified dimension must be an integral type. */
16149       if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
16150         dim_error = 1;
16151
16152       /* Each expression undergoes an unary numeric promotion (5.6.1) and the
16153          promoted type must be int. */
16154       else
16155         {
16156           dim = do_unary_numeric_promotion (dim);
16157           if (TREE_TYPE (dim) != int_type_node)
16158             dim_error = 1;
16159         }
16160
16161       /* Report errors on types here */
16162       if (dim_error)
16163         {
16164           parse_error_context 
16165             (TREE_PURPOSE (cdim), 
16166              "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'", 
16167              (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
16168               "Explicit cast needed to" : "Can't"),
16169              lang_printable_name (TREE_TYPE (dim), 0));
16170           error_found = 1;
16171         }
16172
16173       TREE_PURPOSE (cdim) = NULL_TREE;
16174     }
16175
16176   /* Resolve array base type if unresolved */
16177   if (!(type = resolve_type_during_patch (type)))
16178     error_found = 1;
16179
16180   if (error_found)
16181     {
16182       /* We don't want further evaluation of this bogus array creation
16183          operation */
16184       TREE_TYPE (node) = error_mark_node;
16185       return error_mark_node;
16186     }
16187
16188   /* Set array_type to the actual (promoted) array type of the result. */
16189   if (TREE_CODE (type) == RECORD_TYPE)
16190     type = build_pointer_type (type);
16191   while (--xdims >= 0)
16192     {
16193       type = promote_type (build_java_array_type (type, -1));
16194     }
16195   dims = nreverse (dims);
16196   array_type = type;
16197   for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
16198     {
16199       type = array_type;
16200       array_type
16201         = build_java_array_type (type,
16202                                  TREE_CODE (cdim) == INTEGER_CST
16203                                  ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim)
16204                                  : -1);
16205       array_type = promote_type (array_type);
16206     }
16207   dims = nreverse (dims);
16208
16209   /* The node is transformed into a function call. Things are done
16210      differently according to the number of dimensions. If the number
16211      of dimension is equal to 1, then the nature of the base type
16212      (primitive or not) matters. */
16213   if (ndims == 1)
16214     return build_new_array (type, TREE_VALUE (dims));
16215   
16216   /* Can't reuse what's already written in expr.c because it uses the
16217      JVM stack representation. Provide a build_multianewarray. FIXME */
16218   return build (CALL_EXPR, array_type,
16219                 build_address_of (soft_multianewarray_node),
16220                 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
16221                            tree_cons (NULL_TREE, 
16222                                       build_int_2 (ndims, 0), dims )),
16223                 NULL_TREE);
16224 }
16225
16226 /* 10.6 Array initializer.  */
16227
16228 /* Build a wfl for array element that don't have one, so we can
16229    pin-point errors.  */
16230
16231 static tree
16232 maybe_build_array_element_wfl (node)
16233      tree node;
16234 {
16235   if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
16236     return build_expr_wfl (NULL_TREE, ctxp->filename,
16237                            ctxp->elc.line, ctxp->elc.prev_col);
16238   else
16239     return NULL_TREE;
16240 }
16241
16242 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
16243    identification of initialized arrays easier to detect during walk
16244    and expansion.  */
16245
16246 static tree
16247 build_new_array_init (location, values)
16248      int location;
16249      tree values;
16250 {
16251   tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
16252   tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
16253   EXPR_WFL_LINECOL (to_return) = location;
16254   return to_return;
16255 }
16256
16257 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
16258    occurred.  Otherwise return NODE after having set its type
16259    appropriately.  */
16260
16261 static tree
16262 patch_new_array_init (type, node)
16263      tree type, node;
16264 {
16265   int error_seen = 0;
16266   tree current, element_type;
16267   HOST_WIDE_INT length;
16268   int all_constant = 1;
16269   tree init = TREE_OPERAND (node, 0);
16270
16271   if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
16272     {
16273       parse_error_context (node,
16274                            "Invalid array initializer for non-array type `%s'",
16275                            lang_printable_name (type, 1));
16276       return error_mark_node;
16277     }
16278   type = TREE_TYPE (type);
16279   element_type = TYPE_ARRAY_ELEMENT (type);
16280
16281   CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
16282
16283   for (length = 0, current = CONSTRUCTOR_ELTS (init);
16284        current;  length++, current = TREE_CHAIN (current))
16285     {
16286       tree elt = TREE_VALUE (current);
16287       if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
16288         {
16289           error_seen |= array_constructor_check_entry (element_type, current);
16290           elt = TREE_VALUE (current);
16291           /* When compiling to native code, STRING_CST is converted to
16292              INDIRECT_REF, but still with a TREE_CONSTANT flag. */
16293           if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
16294             all_constant = 0;
16295         }
16296       else
16297         {
16298           TREE_VALUE (current) = patch_new_array_init (element_type, elt);
16299           TREE_PURPOSE (current) = NULL_TREE;
16300           all_constant = 0;
16301         }
16302       if (elt && TREE_CODE (elt) == TREE_LIST 
16303           && TREE_VALUE (elt) == error_mark_node)
16304         error_seen = 1;
16305     }
16306
16307   if (error_seen)
16308     return error_mark_node;
16309
16310   /* Create a new type. We can't reuse the one we have here by
16311      patching its dimension because it originally is of dimension -1
16312      hence reused by gcc. This would prevent triangular arrays. */
16313   type = build_java_array_type (element_type, length);
16314   TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
16315   TREE_TYPE (node) = promote_type (type);
16316   TREE_CONSTANT (init) = all_constant;
16317   TREE_CONSTANT (node) = all_constant;
16318   return node;
16319 }
16320
16321 /* Verify that one entry of the initializer element list can be
16322    assigned to the array base type. Report 1 if an error occurred, 0
16323    otherwise.  */
16324
16325 static int
16326 array_constructor_check_entry (type, entry)
16327      tree type, entry;
16328 {
16329   char *array_type_string = NULL;       /* For error reports */
16330   tree value, type_value, new_value, wfl_value, patched;
16331   int error_seen = 0;
16332
16333   new_value = NULL_TREE;
16334   wfl_value = TREE_VALUE (entry);
16335
16336   push_obstacks (&permanent_obstack, &permanent_obstack);
16337   value = java_complete_tree (TREE_VALUE (entry));
16338   /* patch_string return error_mark_node if arg is error_mark_node */
16339   if ((patched = patch_string (value)))
16340     value = patched;
16341   if (value == error_mark_node)
16342     return 1;
16343   
16344   type_value = TREE_TYPE (value);
16345   
16346   /* At anytime, try_builtin_assignconv can report a warning on
16347      constant overflow during narrowing. */
16348   SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
16349   new_value = try_builtin_assignconv (wfl_operator, type, value);
16350   if (!new_value && (new_value = try_reference_assignconv (type, value)))
16351     type_value = promote_type (type);
16352
16353   pop_obstacks ();
16354   /* Check and report errors */
16355   if (!new_value)
16356     {
16357       const char *msg = (!valid_cast_to_p (type_value, type) ?
16358                    "Can't" : "Explicit cast needed to");
16359       if (!array_type_string)
16360         array_type_string = xstrdup (lang_printable_name (type, 1));
16361       parse_error_context 
16362         (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
16363          msg, lang_printable_name (type_value, 1), array_type_string);
16364       error_seen = 1;
16365     }
16366   
16367   if (new_value)
16368     {
16369       new_value = maybe_build_primttype_type_ref (new_value, wfl_value);
16370       TREE_VALUE (entry) = new_value;
16371     }
16372
16373   if (array_type_string)
16374     free (array_type_string);
16375
16376   TREE_PURPOSE (entry) = NULL_TREE;
16377   return error_seen;
16378 }
16379
16380 static tree
16381 build_this (location)
16382      int location;
16383 {
16384   tree node = build_wfl_node (this_identifier_node);
16385   TREE_SET_CODE (node, THIS_EXPR);
16386   EXPR_WFL_LINECOL (node) = location;
16387   return node;
16388 }
16389
16390 /* 14.15 The return statement. It builds a modify expression that
16391    assigns the returned value to the RESULT_DECL that hold the value
16392    to be returned. */
16393
16394 static tree
16395 build_return (location, op)
16396      int location;
16397      tree op;
16398 {
16399   tree node = build1 (RETURN_EXPR, NULL_TREE, op);
16400   EXPR_WFL_LINECOL (node) = location;
16401   node = build_debugable_stmt (location, node);
16402   return node;
16403 }
16404
16405 static tree
16406 patch_return (node)
16407      tree node;
16408 {
16409   tree return_exp = TREE_OPERAND (node, 0);
16410   tree meth = current_function_decl;
16411   tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
16412   int error_found = 0;
16413
16414   TREE_TYPE (node) = error_mark_node;
16415   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16416
16417   /* It's invalid to have a return value within a function that is
16418      declared with the keyword void or that is a constructor */
16419   if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
16420     error_found = 1;
16421
16422   /* It's invalid to use a return statement in a static block */
16423   if (DECL_CLINIT_P (current_function_decl))
16424     error_found = 1;
16425
16426   /* It's invalid to have a no return value within a function that
16427      isn't declared with the keyword `void' */
16428   if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
16429     error_found = 2;
16430   
16431   if (in_instance_initializer)
16432     error_found = 1;
16433
16434   if (error_found)
16435     {
16436       if (in_instance_initializer)
16437         parse_error_context (wfl_operator,
16438                              "`return' inside instance initializer");
16439         
16440       else if (DECL_CLINIT_P (current_function_decl))
16441         parse_error_context (wfl_operator,
16442                              "`return' inside static initializer");
16443
16444       else if (!DECL_CONSTRUCTOR_P (meth))
16445         {
16446           char *t = xstrdup (lang_printable_name (mtype, 0));
16447           parse_error_context (wfl_operator, 
16448                                "`return' with%s value from `%s %s'",
16449                                (error_found == 1 ? "" : "out"), 
16450                                t, lang_printable_name (meth, 0));
16451           free (t);
16452         }
16453       else
16454         parse_error_context (wfl_operator, 
16455                              "`return' with value from constructor `%s'",
16456                              lang_printable_name (meth, 0));
16457       return error_mark_node;
16458     }
16459
16460   /* If we have a return_exp, build a modify expression and expand
16461      it. Note: at that point, the assignment is declared valid, but we
16462      may want to carry some more hacks */
16463   if (return_exp)
16464     {
16465       tree exp = java_complete_tree (return_exp);
16466       tree modify, patched;
16467
16468       /* If the function returned value and EXP are booleans, EXP has
16469       to be converted into the type of DECL_RESULT, which is integer
16470       (see complete_start_java_method) */
16471       if (TREE_TYPE (exp) == boolean_type_node &&
16472           TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
16473         exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
16474
16475       /* `null' can be assigned to a function returning a reference */
16476       if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
16477           exp == null_pointer_node)
16478         exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
16479
16480       if ((patched = patch_string (exp)))
16481         exp = patched;
16482       
16483       modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
16484       EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
16485       modify = java_complete_tree (modify);
16486
16487       if (modify != error_mark_node)
16488         {
16489           TREE_SIDE_EFFECTS (modify) = 1;
16490           TREE_OPERAND (node, 0) = modify;
16491         }
16492       else
16493         return error_mark_node;
16494     }
16495   TREE_TYPE (node) = void_type_node;
16496   TREE_SIDE_EFFECTS (node) = 1;
16497   return node;
16498 }
16499
16500 /* 14.8 The if Statement */
16501
16502 static tree
16503 build_if_else_statement (location, expression, if_body, else_body)
16504      int location;
16505      tree expression, if_body, else_body;
16506 {
16507   tree node;
16508   if (!else_body)
16509     else_body = empty_stmt_node;
16510   node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
16511   EXPR_WFL_LINECOL (node) = location;
16512   node = build_debugable_stmt (location, node);
16513   return node;
16514 }
16515
16516 static tree
16517 patch_if_else_statement (node)
16518      tree node;
16519 {
16520   tree expression = TREE_OPERAND (node, 0);
16521
16522   TREE_TYPE (node) = error_mark_node;
16523   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16524
16525   /* The type of expression must be boolean */
16526   if (TREE_TYPE (expression) != boolean_type_node
16527       && TREE_TYPE (expression) != promoted_boolean_type_node)
16528     {
16529       parse_error_context 
16530         (wfl_operator, 
16531          "Incompatible type for `if'. Can't convert `%s' to `boolean'", 
16532          lang_printable_name (TREE_TYPE (expression), 0));
16533       return error_mark_node;
16534     }
16535   
16536   TREE_TYPE (node) = void_type_node;
16537   TREE_SIDE_EFFECTS (node) = 1;
16538   CAN_COMPLETE_NORMALLY (node)
16539     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16540     | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
16541   return node;
16542 }
16543
16544 /* 14.6 Labeled Statements */
16545
16546 /* Action taken when a lableled statement is parsed. a new
16547    LABELED_BLOCK_EXPR is created. No statement is attached to the
16548    label, yet.  LABEL can be NULL_TREE for artificially-generated blocks. */
16549
16550 static tree
16551 build_labeled_block (location, label)
16552      int location;
16553      tree label;
16554 {
16555   tree label_name ;
16556   tree label_decl, node;
16557   if (label == NULL_TREE || label == continue_identifier_node)
16558     label_name = label;
16559   else
16560     {
16561       label_name = merge_qualified_name (label_id, label);
16562       /* Issue an error if we try to reuse a label that was previously
16563          declared */
16564       if (IDENTIFIER_LOCAL_VALUE (label_name))
16565         {
16566           EXPR_WFL_LINECOL (wfl_operator) = location;
16567           parse_error_context (wfl_operator,
16568             "Declaration of `%s' shadows a previous label declaration",
16569                                IDENTIFIER_POINTER (label));
16570           EXPR_WFL_LINECOL (wfl_operator) = 
16571             EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
16572           parse_error_context (wfl_operator,
16573             "This is the location of the previous declaration of label `%s'",
16574                                IDENTIFIER_POINTER (label));
16575           java_error_count--;
16576         }
16577     }
16578
16579   label_decl = create_label_decl (label_name);
16580   node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
16581   EXPR_WFL_LINECOL (node) = location;
16582   TREE_SIDE_EFFECTS (node) = 1;
16583   return node;
16584 }
16585
16586 /* A labeled statement LBE is attached a statement.  */
16587
16588 static tree
16589 finish_labeled_statement (lbe, statement)
16590      tree lbe;                  /* Labeled block expr */
16591      tree statement;
16592 {
16593   /* In anyways, tie the loop to its statement */
16594   LABELED_BLOCK_BODY (lbe) = statement;
16595   pop_labeled_block ();
16596   POP_LABELED_BLOCK ();
16597   return lbe;
16598 }
16599
16600 /* 14.10, 14.11, 14.12 Loop Statements */
16601
16602 /* Create an empty LOOP_EXPR and make it the last in the nested loop
16603    list. */
16604
16605 static tree
16606 build_new_loop (loop_body)
16607      tree loop_body;
16608 {
16609   tree loop =  build (LOOP_EXPR, NULL_TREE, loop_body);
16610   TREE_SIDE_EFFECTS (loop) = 1;
16611   PUSH_LOOP (loop);
16612   return loop;
16613 }
16614
16615 /* Create a loop body according to the following structure:
16616      COMPOUND_EXPR
16617        COMPOUND_EXPR            (loop main body)
16618          EXIT_EXPR              (this order is for while/for loops.
16619          LABELED_BLOCK_EXPR      the order is reversed for do loops)
16620            LABEL_DECL           (a continue occuring here branches at the 
16621            BODY                  end of this labeled block)
16622        INCREMENT                (if any)
16623
16624   REVERSED, if non zero, tells that the loop condition expr comes
16625   after the body, like in the do-while loop.
16626
16627   To obtain a loop, the loop body structure described above is
16628   encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
16629
16630    LABELED_BLOCK_EXPR
16631      LABEL_DECL                   (use this label to exit the loop)
16632      LOOP_EXPR
16633        <structure described above> */
16634
16635 static tree
16636 build_loop_body (location, condition, reversed)
16637      int location;
16638      tree condition;
16639      int reversed;
16640 {
16641   tree first, second, body;
16642
16643   condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
16644   EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
16645   condition = build_debugable_stmt (location, condition);
16646   TREE_SIDE_EFFECTS (condition) = 1;
16647
16648   body = build_labeled_block (0, continue_identifier_node);
16649   first = (reversed ? body : condition);
16650   second = (reversed ? condition : body);
16651   return 
16652     build (COMPOUND_EXPR, NULL_TREE, 
16653            build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
16654 }
16655
16656 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
16657    their order) on the current loop. Unlink the current loop from the
16658    loop list.  */
16659
16660 static tree
16661 finish_loop_body (location, condition, body, reversed)
16662      int location;
16663      tree condition, body;
16664      int reversed;
16665 {
16666   tree to_return = ctxp->current_loop;
16667   tree loop_body = LOOP_EXPR_BODY (to_return);
16668   if (condition)
16669     {
16670       tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
16671       /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
16672          The real EXIT_EXPR is one operand further. */
16673       EXPR_WFL_LINECOL (cnode) = location;
16674       /* This one is for accurate error reports */
16675       EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
16676       TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
16677     }
16678   LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
16679   POP_LOOP ();
16680   return to_return;
16681 }
16682
16683 /* Tailored version of finish_loop_body for FOR loops, when FOR
16684    loops feature the condition part */
16685
16686 static tree
16687 finish_for_loop (location, condition, update, body)
16688     int location;
16689     tree condition, update, body;
16690 {
16691   /* Put the condition and the loop body in place */
16692   tree loop = finish_loop_body (location, condition, body, 0);
16693   /* LOOP is the current loop which has been now popped of the loop
16694      stack. Install the update block */
16695   LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
16696   return loop;
16697 }
16698
16699 /* Try to find the loop a block might be related to. This comprises
16700    the case where the LOOP_EXPR is found as the second operand of a
16701    COMPOUND_EXPR, because the loop happens to have an initialization
16702    part, then expressed as the first operand of the COMPOUND_EXPR. If
16703    the search finds something, 1 is returned. Otherwise, 0 is
16704    returned. The search is assumed to start from a
16705    LABELED_BLOCK_EXPR's block.  */
16706
16707 static tree
16708 search_loop (statement)
16709     tree statement;
16710 {
16711   if (TREE_CODE (statement) == LOOP_EXPR)
16712     return statement;
16713
16714   if (TREE_CODE (statement) == BLOCK)
16715     statement = BLOCK_SUBBLOCKS (statement);
16716   else
16717     return NULL_TREE;
16718
16719   if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16720     while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16721       statement = TREE_OPERAND (statement, 1);
16722
16723   return (TREE_CODE (statement) == LOOP_EXPR
16724           && FOR_LOOP_P (statement) ? statement : NULL_TREE);
16725 }
16726
16727 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
16728    returned otherwise.  */
16729
16730 static int
16731 labeled_block_contains_loop_p (block, loop)
16732     tree block, loop;
16733 {
16734   if (!block)
16735     return 0;
16736
16737   if (LABELED_BLOCK_BODY (block) == loop)
16738     return 1;
16739
16740   if (FOR_LOOP_P (loop) && search_loop (LABELED_BLOCK_BODY (block)) == loop)
16741     return 1;
16742
16743   return 0;
16744 }
16745
16746 /* If the loop isn't surrounded by a labeled statement, create one and
16747    insert LOOP as its body.  */
16748
16749 static tree
16750 patch_loop_statement (loop)
16751      tree loop;
16752 {
16753   tree loop_label;
16754
16755   TREE_TYPE (loop) = void_type_node;
16756   if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
16757     return loop;
16758
16759   loop_label = build_labeled_block (0, NULL_TREE);
16760   /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
16761      that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
16762   LABELED_BLOCK_BODY (loop_label) = loop;
16763   PUSH_LABELED_BLOCK (loop_label);
16764   return loop_label;
16765 }
16766
16767 /* 14.13, 14.14: break and continue Statements */
16768
16769 /* Build a break or a continue statement. a null NAME indicates an
16770    unlabeled break/continue statement.  */
16771
16772 static tree
16773 build_bc_statement (location, is_break, name)
16774      int location, is_break;
16775      tree name;
16776 {
16777   tree break_continue, label_block_expr = NULL_TREE;
16778
16779   if (name)
16780     {
16781       if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE 
16782             (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
16783         /* Null means that we don't have a target for this named
16784            break/continue. In this case, we make the target to be the
16785            label name, so that the error can be reported accuratly in
16786            patch_bc_statement. */
16787         label_block_expr = EXPR_WFL_NODE (name);
16788     }
16789   /* Unlabeled break/continue will be handled during the
16790      break/continue patch operation */
16791   break_continue 
16792     = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
16793
16794   IS_BREAK_STMT_P (break_continue) = is_break;
16795   TREE_SIDE_EFFECTS (break_continue) = 1;
16796   EXPR_WFL_LINECOL (break_continue) = location;
16797   break_continue = build_debugable_stmt (location, break_continue);
16798   return break_continue;
16799 }
16800
16801 /* Verification of a break/continue statement. */
16802
16803 static tree
16804 patch_bc_statement (node)
16805      tree node;
16806 {
16807   tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
16808   tree labeled_block = ctxp->current_labeled_block;
16809   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16810  
16811   /* Having an identifier here means that the target is unknown. */
16812   if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
16813     {
16814       parse_error_context (wfl_operator, "No label definition found for `%s'",
16815                            IDENTIFIER_POINTER (bc_label));
16816       return error_mark_node;
16817     }
16818   if (! IS_BREAK_STMT_P (node))
16819     {
16820       /* It's a continue statement. */
16821       for (;; labeled_block = TREE_CHAIN (labeled_block))
16822         {
16823           if (labeled_block == NULL_TREE)
16824             {
16825               if (bc_label == NULL_TREE)
16826                 parse_error_context (wfl_operator,
16827                                      "`continue' must be in loop");
16828               else
16829                 parse_error_context 
16830                   (wfl_operator, "continue label `%s' does not name a loop",
16831                    IDENTIFIER_POINTER (bc_label));
16832               return error_mark_node;
16833             }
16834           if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
16835                == continue_identifier_node)
16836               && (bc_label == NULL_TREE
16837                   || TREE_CHAIN (labeled_block) == bc_label))
16838             {
16839               bc_label = labeled_block;
16840               break;
16841             }
16842         }
16843     }
16844   else if (!bc_label)
16845     { 
16846       for (;; labeled_block = TREE_CHAIN (labeled_block))
16847         {
16848           if (labeled_block == NULL_TREE)
16849             {
16850               parse_error_context (wfl_operator,
16851                                      "`break' must be in loop or switch");
16852               return error_mark_node;
16853             }
16854           target_stmt = LABELED_BLOCK_BODY (labeled_block);
16855           if (TREE_CODE (target_stmt) == SWITCH_EXPR
16856               || search_loop (target_stmt))
16857             {
16858               bc_label = labeled_block;
16859               break;
16860             }
16861         }
16862     }
16863
16864   EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
16865   CAN_COMPLETE_NORMALLY (bc_label) = 1;
16866
16867   /* Our break/continue don't return values. */
16868   TREE_TYPE (node) = void_type_node;
16869   /* Encapsulate the break within a compound statement so that it's
16870      expanded all the times by expand_expr (and not clobbered
16871      sometimes, like after a if statement) */
16872   node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
16873   TREE_SIDE_EFFECTS (node) = 1;
16874   return node;
16875 }
16876
16877 /* Process the exit expression belonging to a loop. Its type must be
16878    boolean.  */
16879
16880 static tree
16881 patch_exit_expr (node)
16882      tree node;
16883 {
16884   tree expression = TREE_OPERAND (node, 0);
16885   TREE_TYPE (node) = error_mark_node;
16886   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16887
16888   /* The type of expression must be boolean */
16889   if (TREE_TYPE (expression) != boolean_type_node)
16890     {
16891       parse_error_context 
16892         (wfl_operator, 
16893     "Incompatible type for loop conditional. Can't convert `%s' to `boolean'", 
16894          lang_printable_name (TREE_TYPE (expression), 0));
16895       return error_mark_node;
16896     }
16897   /* Now we know things are allright, invert the condition, fold and
16898      return */
16899   TREE_OPERAND (node, 0) = 
16900     fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
16901
16902   if (! integer_zerop (TREE_OPERAND (node, 0))
16903       && ctxp->current_loop != NULL_TREE
16904       && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
16905     CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
16906   if (! integer_onep (TREE_OPERAND (node, 0)))
16907     CAN_COMPLETE_NORMALLY (node) = 1;
16908
16909
16910   TREE_TYPE (node) = void_type_node;
16911   return node;
16912 }
16913
16914 /* 14.9 Switch statement */
16915
16916 static tree
16917 patch_switch_statement (node)
16918      tree node;
16919 {
16920   tree se = TREE_OPERAND (node, 0), se_type;
16921
16922   /* Complete the switch expression */
16923   se = TREE_OPERAND (node, 0) = java_complete_tree (se);
16924   se_type = TREE_TYPE (se);
16925   /* The type of the switch expression must be char, byte, short or
16926      int */
16927   if (!JINTEGRAL_TYPE_P (se_type))
16928     {
16929       EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16930       parse_error_context (wfl_operator,
16931           "Incompatible type for `switch'. Can't convert `%s' to `int'",
16932                            lang_printable_name (se_type, 0));
16933       /* This is what java_complete_tree will check */
16934       TREE_OPERAND (node, 0) = error_mark_node;
16935       return error_mark_node;
16936     }
16937
16938   TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
16939
16940   /* Ready to return */
16941   if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
16942     {
16943       TREE_TYPE (node) = error_mark_node;
16944       return error_mark_node;
16945     }
16946   TREE_TYPE (node) = void_type_node;
16947   TREE_SIDE_EFFECTS (node) = 1;
16948   CAN_COMPLETE_NORMALLY (node)
16949     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)) 
16950       || ! SWITCH_HAS_DEFAULT (node);
16951   return node;
16952 }
16953
16954 /* 14.18 The try/catch statements */
16955
16956 static tree
16957 build_try_statement (location, try_block, catches)
16958      int location;
16959      tree try_block, catches;
16960 {
16961   tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
16962   EXPR_WFL_LINECOL (node) = location;
16963   return node;
16964 }
16965
16966 static tree
16967 build_try_finally_statement (location, try_block, finally)
16968      int location;
16969      tree try_block, finally;
16970 {
16971   tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
16972   EXPR_WFL_LINECOL (node) = location;
16973   return node;
16974 }
16975
16976 static tree
16977 patch_try_statement (node)
16978      tree node;
16979 {
16980   int error_found = 0;
16981   tree try = TREE_OPERAND (node, 0);
16982   /* Exception handlers are considered in left to right order */
16983   tree catch = nreverse (TREE_OPERAND (node, 1));
16984   tree current, caught_type_list = NULL_TREE;
16985
16986   /* Check catch clauses, if any. Every time we find an error, we try
16987      to process the next catch clause. We process the catch clause before
16988      the try block so that when processing the try block we can check thrown
16989      exceptions againts the caught type list. */
16990   for (current = catch; current; current = TREE_CHAIN (current))
16991     {
16992       tree carg_decl, carg_type;
16993       tree sub_current, catch_block, catch_clause;
16994       int unreachable;
16995
16996       /* At this point, the structure of the catch clause is
16997            CATCH_EXPR           (catch node)
16998              BLOCK              (with the decl of the parameter)
16999                COMPOUND_EXPR
17000                  MODIFY_EXPR   (assignment of the catch parameter)
17001                  BLOCK          (catch clause block)
17002        */
17003       catch_clause = TREE_OPERAND (current, 0);
17004       carg_decl = BLOCK_EXPR_DECLS (catch_clause);
17005       carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
17006
17007       /* Catch clauses can't have more than one parameter declared,
17008          but it's already enforced by the grammar. Make sure that the
17009          only parameter of the clause statement in of class Throwable
17010          or a subclass of Throwable, but that was done earlier. The
17011          catch clause parameter type has also been resolved. */
17012       
17013       /* Just make sure that the catch clause parameter type inherits
17014          from java.lang.Throwable */
17015       if (!inherits_from_p (carg_type, throwable_type_node))
17016         {
17017           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
17018           parse_error_context (wfl_operator,
17019                                "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
17020                                lang_printable_name (carg_type, 0));
17021           error_found = 1;
17022           continue;
17023         }
17024       
17025       /* Partial check for unreachable catch statement: The catch
17026          clause is reachable iff is no earlier catch block A in
17027          the try statement such that the type of the catch
17028          clause's parameter is the same as or a subclass of the
17029          type of A's parameter */
17030       unreachable = 0;
17031       for (sub_current = catch;
17032            sub_current != current; sub_current = TREE_CHAIN (sub_current))
17033         {
17034           tree sub_catch_clause, decl;
17035           sub_catch_clause = TREE_OPERAND (sub_current, 0);
17036           decl = BLOCK_EXPR_DECLS (sub_catch_clause);
17037
17038           if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
17039             {
17040               EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
17041               parse_error_context 
17042                 (wfl_operator,
17043                  "`catch' not reached because of the catch clause at line %d",
17044                  EXPR_WFL_LINENO (sub_current));
17045               unreachable = error_found = 1;
17046               break;
17047             }
17048         }
17049       /* Complete the catch clause block */
17050       catch_block = java_complete_tree (TREE_OPERAND (current, 0));
17051       if (catch_block == error_mark_node)
17052         {
17053           error_found = 1;
17054           continue;
17055         }
17056       if (CAN_COMPLETE_NORMALLY (catch_block))
17057         CAN_COMPLETE_NORMALLY (node) = 1;
17058       TREE_OPERAND (current, 0) = catch_block;
17059
17060       if (unreachable)
17061         continue;
17062
17063       /* Things to do here: the exception must be thrown */
17064
17065       /* Link this type to the caught type list */
17066       caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
17067     }
17068
17069   PUSH_EXCEPTIONS (caught_type_list);
17070   if ((try = java_complete_tree (try)) == error_mark_node)
17071     error_found = 1;
17072   if (CAN_COMPLETE_NORMALLY (try))
17073     CAN_COMPLETE_NORMALLY (node) = 1;
17074   POP_EXCEPTIONS ();
17075
17076   /* Verification ends here */
17077   if (error_found) 
17078     return error_mark_node;
17079
17080   TREE_OPERAND (node, 0) = try;
17081   TREE_OPERAND (node, 1) = catch;
17082   TREE_TYPE (node) = void_type_node;
17083   return node;
17084 }
17085
17086 /* 14.17 The synchronized Statement */
17087
17088 static tree
17089 patch_synchronized_statement (node, wfl_op1)
17090     tree node, wfl_op1;
17091 {
17092   tree expr = java_complete_tree (TREE_OPERAND (node, 0));
17093   tree block = TREE_OPERAND (node, 1);
17094
17095   tree enter, exit, expr_decl, assignment;
17096
17097   if (expr == error_mark_node)
17098     {
17099       block = java_complete_tree (block);
17100       return expr;
17101     }
17102
17103   /* The TYPE of expr must be a reference type */
17104   if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
17105     {
17106       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17107       parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
17108                            lang_printable_name (TREE_TYPE (expr), 0));
17109       return error_mark_node;
17110     }
17111
17112   if (flag_emit_xref)
17113     {
17114       TREE_OPERAND (node, 0) = expr;
17115       TREE_OPERAND (node, 1) = java_complete_tree (block);
17116       CAN_COMPLETE_NORMALLY (node) = 1;
17117       return node;
17118     }
17119
17120   /* Generate a try-finally for the synchronized statement, except
17121      that the handler that catches all throw exception calls
17122      _Jv_MonitorExit and then rethrow the exception.
17123      The synchronized statement is then implemented as:
17124      TRY 
17125        {
17126          _Jv_MonitorEnter (expression)
17127          synchronized_block
17128          _Jv_MonitorExit (expression)
17129        }
17130      CATCH_ALL
17131        {
17132          e = _Jv_exception_info ();
17133          _Jv_MonitorExit (expression)
17134          Throw (e);
17135        } */
17136
17137   expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
17138   BUILD_MONITOR_ENTER (enter, expr_decl);
17139   BUILD_MONITOR_EXIT (exit, expr_decl);
17140   CAN_COMPLETE_NORMALLY (enter) = 1;
17141   CAN_COMPLETE_NORMALLY (exit) = 1;
17142   assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
17143   TREE_SIDE_EFFECTS (assignment) = 1;
17144   node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
17145                  build (COMPOUND_EXPR, NULL_TREE,
17146                         build (WITH_CLEANUP_EXPR, NULL_TREE,
17147                                build (COMPOUND_EXPR, NULL_TREE,
17148                                       assignment, enter),
17149                                NULL_TREE, exit),
17150                         block));
17151   node = build_expr_block (node, expr_decl);
17152
17153   return java_complete_tree (node);
17154 }
17155
17156 /* 14.16 The throw Statement */
17157
17158 static tree
17159 patch_throw_statement (node, wfl_op1)
17160     tree node, wfl_op1;
17161 {
17162   tree expr = TREE_OPERAND (node, 0);
17163   tree type = TREE_TYPE (expr);
17164   int unchecked_ok = 0, tryblock_throws_ok = 0;
17165
17166   /* Thrown expression must be assignable to java.lang.Throwable */
17167   if (!try_reference_assignconv (throwable_type_node, expr))
17168     {
17169       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17170       parse_error_context (wfl_operator,
17171     "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
17172                            lang_printable_name (type, 0));
17173       /* If the thrown expression was a reference, we further the
17174          compile-time check. */
17175       if (!JREFERENCE_TYPE_P (type))
17176         return error_mark_node;
17177     }
17178
17179   /* At least one of the following must be true */
17180
17181   /* The type of the throw expression is a not checked exception,
17182      i.e. is a unchecked expression. */
17183   unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
17184
17185   SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17186   /* An instance can't throw a checked excetion unless that exception
17187      is explicitely declared in the `throws' clause of each
17188      constructor. This doesn't apply to anonymous classes, since they
17189      don't have declared constructors. */
17190   if (!unchecked_ok 
17191       && in_instance_initializer && !ANONYMOUS_CLASS_P (current_class))
17192     {
17193       tree current;
17194       for (current = TYPE_METHODS (current_class); current; 
17195            current = TREE_CHAIN (current))
17196         if (DECL_CONSTRUCTOR_P (current) 
17197             && !check_thrown_exceptions_do (TREE_TYPE (expr)))
17198           {
17199             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)", 
17200                                  lang_printable_name (TREE_TYPE (expr), 0));
17201             return error_mark_node;
17202           }
17203     }
17204
17205   /* Throw is contained in a try statement and at least one catch
17206      clause can receive the thrown expression or the current method is
17207      declared to throw such an exception. Or, the throw statement is
17208      contained in a method or constructor declaration and the type of
17209      the Expression is assignable to at least one type listed in the
17210      throws clause the declaration. */
17211   if (!unchecked_ok)
17212     tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
17213   if (!(unchecked_ok || tryblock_throws_ok))
17214     {
17215       /* If there is a surrounding try block that has no matching
17216          clatch clause, report it first. A surrounding try block exits
17217          only if there is something after the list of checked
17218          exception thrown by the current function (if any). */
17219       if (IN_TRY_BLOCK_P ())
17220         parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
17221                              lang_printable_name (type, 0));
17222       /* If we have no surrounding try statement and the method doesn't have
17223          any throws, report it now. FIXME */
17224
17225       /* We report that the exception can't be throw from a try block
17226          in all circumstances but when the `throw' is inside a static
17227          block. */
17228       else if (!EXCEPTIONS_P (currently_caught_type_list) 
17229                && !tryblock_throws_ok)
17230         {
17231           if (DECL_CLINIT_P (current_function_decl))
17232             parse_error_context (wfl_operator,
17233                    "Checked exception `%s' can't be thrown in initializer",
17234                                  lang_printable_name (type, 0));
17235           else
17236             parse_error_context (wfl_operator,
17237                    "Checked exception `%s' isn't thrown from a `try' block", 
17238                                  lang_printable_name (type, 0));
17239         }
17240       /* Otherwise, the current method doesn't have the appropriate
17241          throws declaration */
17242       else
17243         parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)", 
17244                              lang_printable_name (type, 0));
17245       return error_mark_node;
17246     }
17247
17248   if (! flag_emit_class_files && ! flag_emit_xref)
17249     BUILD_THROW (node, expr);
17250
17251   /* If doing xrefs, keep the location where the `throw' was seen. */
17252   if (flag_emit_xref)
17253     EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
17254   return node;
17255 }
17256
17257 /* Check that exception said to be thrown by method DECL can be
17258    effectively caught from where DECL is invoked.  */
17259
17260 static void
17261 check_thrown_exceptions (location, decl)
17262      int location;
17263      tree decl;
17264 {
17265   tree throws;
17266   /* For all the unchecked exceptions thrown by DECL */
17267   for (throws = DECL_FUNCTION_THROWS (decl); throws; 
17268        throws = TREE_CHAIN (throws)) 
17269     if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
17270       {
17271 #if 1
17272         /* Temporary hack to suppresses errors about cloning arrays. FIXME */
17273         if (DECL_NAME (decl) == get_identifier ("clone"))
17274           continue;
17275 #endif
17276         EXPR_WFL_LINECOL (wfl_operator) = location;
17277         if (DECL_FINIT_P (current_function_decl))
17278           parse_error_context
17279             (wfl_operator, "Exception `%s' can't be thrown in initializer",
17280              lang_printable_name (TREE_VALUE (throws), 0));
17281         else 
17282           {
17283             parse_error_context 
17284               (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'", 
17285                lang_printable_name (TREE_VALUE (throws), 0),
17286                (DECL_INIT_P (current_function_decl) ?
17287                 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
17288                 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
17289           }
17290       }
17291 }
17292
17293 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
17294    try-catch blocks, OR is listed in the `throws' clause of the
17295    current method.  */
17296
17297 static int
17298 check_thrown_exceptions_do (exception)
17299      tree exception;
17300 {
17301   tree list = currently_caught_type_list;
17302   resolve_and_layout (exception, NULL_TREE);
17303   /* First, all the nested try-catch-finally at that stage. The
17304      last element contains `throws' clause exceptions, if any. */
17305   if (IS_UNCHECKED_EXCEPTION_P (exception))
17306     return 1;
17307   while (list)
17308     {
17309       tree caught;
17310       for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
17311         if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
17312           return 1;
17313       list = TREE_CHAIN (list);
17314     }
17315   return 0;
17316 }
17317
17318 static void
17319 purge_unchecked_exceptions (mdecl)
17320      tree mdecl;
17321 {
17322   tree throws = DECL_FUNCTION_THROWS (mdecl);
17323   tree new = NULL_TREE;
17324
17325   while (throws)
17326     {
17327       tree next = TREE_CHAIN (throws);
17328       if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
17329         {
17330           TREE_CHAIN (throws) = new;
17331           new = throws;
17332         }
17333       throws = next;
17334     }
17335   /* List is inverted here, but it doesn't matter */
17336   DECL_FUNCTION_THROWS (mdecl) = new;
17337 }
17338
17339 /* 15.24 Conditional Operator ?: */
17340
17341 static tree
17342 patch_conditional_expr (node, wfl_cond, wfl_op1)
17343      tree node, wfl_cond, wfl_op1;
17344 {
17345   tree cond = TREE_OPERAND (node, 0);
17346   tree op1 = TREE_OPERAND (node, 1);
17347   tree op2 = TREE_OPERAND (node, 2);
17348   tree resulting_type = NULL_TREE;
17349   tree t1, t2, patched;
17350   int error_found = 0;
17351
17352   /* Operands of ?: might be StringBuffers crafted as a result of a
17353      string concatenation. Obtain a descent operand here.  */
17354   if ((patched = patch_string (op1)))
17355     TREE_OPERAND (node, 1) = op1 = patched;
17356   if ((patched = patch_string (op2)))
17357     TREE_OPERAND (node, 2) = op2 = patched;
17358
17359   t1 = TREE_TYPE (op1);
17360   t2 = TREE_TYPE (op2);
17361
17362   /* The first expression must be a boolean */
17363   if (TREE_TYPE (cond) != boolean_type_node)
17364     {
17365       SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
17366       parse_error_context (wfl_operator,
17367                "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
17368                            lang_printable_name (TREE_TYPE (cond), 0));
17369       error_found = 1;
17370     }
17371
17372   /* Second and third can be numeric, boolean (i.e. primitive),
17373      references or null. Anything else results in an error */
17374   if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
17375         || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node) 
17376             && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
17377         || (t1 == boolean_type_node && t2 == boolean_type_node)))
17378     error_found = 1;
17379
17380   /* Determine the type of the conditional expression. Same types are
17381      easy to deal with */
17382   else if (t1 == t2)
17383     resulting_type = t1;
17384
17385   /* There are different rules for numeric types */
17386   else if (JNUMERIC_TYPE_P (t1))
17387     {
17388       /* if byte/short found, the resulting type is short */
17389       if ((t1 == byte_type_node && t2 == short_type_node)
17390           || (t1 == short_type_node && t2 == byte_type_node))
17391         resulting_type = short_type_node;
17392
17393       /* If t1 is a constant int and t2 is of type byte, short or char
17394          and t1's value fits in t2, then the resulting type is t2 */
17395       else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
17396           && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
17397         resulting_type = t2;
17398
17399       /* If t2 is a constant int and t1 is of type byte, short or char
17400          and t2's value fits in t1, then the resulting type is t1 */
17401       else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
17402           && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
17403         resulting_type = t1;
17404
17405       /* Otherwise, binary numeric promotion is applied and the
17406          resulting type is the promoted type of operand 1 and 2 */
17407       else 
17408         resulting_type = binary_numeric_promotion (t1, t2, 
17409                                                    &TREE_OPERAND (node, 1), 
17410                                                    &TREE_OPERAND (node, 2));
17411     }
17412
17413   /* Cases of a reference and a null type */
17414   else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
17415     resulting_type = t1;
17416
17417   else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
17418     resulting_type = t2;
17419
17420   /* Last case: different reference types. If a type can be converted
17421      into the other one by assignment conversion, the latter
17422      determines the type of the expression */
17423   else if ((resulting_type = try_reference_assignconv (t1, op2)))
17424     resulting_type = promote_type (t1);
17425
17426   else if ((resulting_type = try_reference_assignconv (t2, op1)))
17427     resulting_type = promote_type (t2);
17428
17429   /* If we don't have any resulting type, we're in trouble */
17430   if (!resulting_type)
17431     {
17432       char *t = xstrdup (lang_printable_name (t1, 0));
17433       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17434       parse_error_context (wfl_operator,
17435                  "Incompatible type for `?:'. Can't convert `%s' to `%s'",
17436                            t, lang_printable_name (t2, 0));
17437       free (t);
17438       error_found = 1;
17439     }
17440
17441   if (error_found)
17442     {
17443       TREE_TYPE (node) = error_mark_node;
17444       return error_mark_node;
17445     }
17446
17447   TREE_TYPE (node) = resulting_type;
17448   TREE_SET_CODE (node, COND_EXPR);
17449   CAN_COMPLETE_NORMALLY (node) = 1;
17450   return node;
17451 }
17452
17453 /* Try to constant fold NODE.
17454    If NODE is not a constant expression, return NULL_EXPR.
17455    CONTEXT is a static final VAR_DECL whose initializer we are folding. */
17456
17457 static tree
17458 fold_constant_for_init (node, context)
17459      tree node;
17460      tree context;
17461 {
17462   tree op0, op1, val;
17463   enum tree_code code = TREE_CODE (node);
17464
17465   if (code == STRING_CST)
17466     return node;
17467
17468   if (code == INTEGER_CST || code == REAL_CST)
17469     return convert (TREE_TYPE (context), node);
17470
17471   switch (code)
17472     {
17473     case PLUS_EXPR:
17474     case MINUS_EXPR:
17475     case MULT_EXPR:
17476     case TRUNC_MOD_EXPR:
17477     case RDIV_EXPR:
17478     case LSHIFT_EXPR:
17479     case RSHIFT_EXPR:
17480     case URSHIFT_EXPR:
17481     case BIT_AND_EXPR:
17482     case BIT_XOR_EXPR:
17483     case BIT_IOR_EXPR:
17484     case TRUTH_ANDIF_EXPR:
17485     case TRUTH_ORIF_EXPR:
17486     case EQ_EXPR: 
17487     case NE_EXPR:
17488     case GT_EXPR:
17489     case GE_EXPR:
17490     case LT_EXPR:
17491     case LE_EXPR:
17492       op0 = TREE_OPERAND (node, 0);
17493       op1 = TREE_OPERAND (node, 1);
17494       val = fold_constant_for_init (op0, context);
17495       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17496         return NULL_TREE;
17497       TREE_OPERAND (node, 0) = val;
17498       val = fold_constant_for_init (op1, context);
17499       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17500         return NULL_TREE;
17501       TREE_OPERAND (node, 1) = val;
17502       return patch_binop (node, op0, op1);
17503
17504     case UNARY_PLUS_EXPR:
17505     case NEGATE_EXPR:
17506     case TRUTH_NOT_EXPR:
17507     case BIT_NOT_EXPR:
17508     case CONVERT_EXPR:
17509       op0 = TREE_OPERAND (node, 0);
17510       val = fold_constant_for_init (op0, context);
17511       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17512         return NULL_TREE;
17513       TREE_OPERAND (node, 0) = val;
17514       return patch_unaryop (node, op0);
17515       break;
17516
17517     case COND_EXPR:
17518       val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
17519       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17520         return NULL_TREE;
17521       TREE_OPERAND (node, 0) = val;
17522       val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
17523       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17524         return NULL_TREE;
17525       TREE_OPERAND (node, 1) = val;
17526       val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
17527       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17528         return NULL_TREE;
17529       TREE_OPERAND (node, 2) = val;
17530       return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
17531         : TREE_OPERAND (node, 2);
17532
17533     case VAR_DECL:
17534     case FIELD_DECL:
17535       if (! FIELD_FINAL (node)
17536           || DECL_INITIAL (node) == NULL_TREE)
17537         return NULL_TREE;
17538       val = DECL_INITIAL (node);
17539       /* Guard against infinite recursion. */
17540       DECL_INITIAL (node) = NULL_TREE;
17541       val = fold_constant_for_init (val, node);
17542       DECL_INITIAL (node) = val;
17543       return val;
17544
17545     case EXPR_WITH_FILE_LOCATION:
17546       /* Compare java_complete_tree and resolve_expression_name. */
17547       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
17548           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
17549         {
17550           tree name = EXPR_WFL_NODE (node);
17551           tree decl;
17552           if (PRIMARY_P (node))
17553             return NULL_TREE;
17554           else if (! QUALIFIED_P (name))
17555             {
17556               decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
17557               if (decl == NULL_TREE 
17558                   || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
17559                 return NULL_TREE;
17560               return fold_constant_for_init (decl, decl);
17561             }
17562           else
17563             {
17564               /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
17565               qualify_ambiguous_name (node);
17566               if (resolve_field_access (node, &decl, NULL)
17567                   && decl != NULL_TREE)
17568                 return fold_constant_for_init (decl, decl);
17569               return NULL_TREE;
17570             }
17571         }
17572       else
17573         {
17574           op0 = TREE_OPERAND (node, 0);
17575           val = fold_constant_for_init (op0, context);
17576           if (val == NULL_TREE || ! TREE_CONSTANT (val))
17577             return NULL_TREE;
17578           TREE_OPERAND (node, 0) = val;
17579           return val;
17580         }
17581
17582 #ifdef USE_COMPONENT_REF
17583     case IDENTIFIER:
17584     case COMPONENT_REF:
17585       ?;
17586 #endif
17587
17588     default:
17589       return NULL_TREE;
17590     }
17591 }
17592
17593 #ifdef USE_COMPONENT_REF
17594 /* Context is 'T' for TypeName, 'P' for PackageName,
17595    'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
17596
17597 tree
17598 resolve_simple_name (name, context)
17599      tree name;
17600      int context;
17601 {
17602 }
17603
17604 tree
17605 resolve_qualified_name (name, context)
17606      tree name;
17607      int context;
17608 {
17609 }
17610 #endif