OSDN Git Service

Thu Oct 21 01:27:31 1999 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.25
4   */
5
6 #define YYBISON 1  /* Identify Bison output.  */
7
8 #define yyparse java_parse
9 #define yylex java_lex
10 #define yyerror java_error
11 #define yylval java_lval
12 #define yychar java_char
13 #define yydebug java_debug
14 #define yynerrs java_nerrs
15 #define PLUS_TK 258
16 #define MINUS_TK        259
17 #define MULT_TK 260
18 #define DIV_TK  261
19 #define REM_TK  262
20 #define LS_TK   263
21 #define SRS_TK  264
22 #define ZRS_TK  265
23 #define AND_TK  266
24 #define XOR_TK  267
25 #define OR_TK   268
26 #define BOOL_AND_TK     269
27 #define BOOL_OR_TK      270
28 #define EQ_TK   271
29 #define NEQ_TK  272
30 #define GT_TK   273
31 #define GTE_TK  274
32 #define LT_TK   275
33 #define LTE_TK  276
34 #define PLUS_ASSIGN_TK  277
35 #define MINUS_ASSIGN_TK 278
36 #define MULT_ASSIGN_TK  279
37 #define DIV_ASSIGN_TK   280
38 #define REM_ASSIGN_TK   281
39 #define LS_ASSIGN_TK    282
40 #define SRS_ASSIGN_TK   283
41 #define ZRS_ASSIGN_TK   284
42 #define AND_ASSIGN_TK   285
43 #define XOR_ASSIGN_TK   286
44 #define OR_ASSIGN_TK    287
45 #define PUBLIC_TK       288
46 #define PRIVATE_TK      289
47 #define PROTECTED_TK    290
48 #define STATIC_TK       291
49 #define FINAL_TK        292
50 #define SYNCHRONIZED_TK 293
51 #define VOLATILE_TK     294
52 #define TRANSIENT_TK    295
53 #define NATIVE_TK       296
54 #define PAD_TK  297
55 #define ABSTRACT_TK     298
56 #define MODIFIER_TK     299
57 #define DECR_TK 300
58 #define INCR_TK 301
59 #define DEFAULT_TK      302
60 #define IF_TK   303
61 #define THROW_TK        304
62 #define BOOLEAN_TK      305
63 #define DO_TK   306
64 #define IMPLEMENTS_TK   307
65 #define THROWS_TK       308
66 #define BREAK_TK        309
67 #define IMPORT_TK       310
68 #define ELSE_TK 311
69 #define INSTANCEOF_TK   312
70 #define RETURN_TK       313
71 #define VOID_TK 314
72 #define CATCH_TK        315
73 #define INTERFACE_TK    316
74 #define CASE_TK 317
75 #define EXTENDS_TK      318
76 #define FINALLY_TK      319
77 #define SUPER_TK        320
78 #define WHILE_TK        321
79 #define CLASS_TK        322
80 #define SWITCH_TK       323
81 #define CONST_TK        324
82 #define TRY_TK  325
83 #define FOR_TK  326
84 #define NEW_TK  327
85 #define CONTINUE_TK     328
86 #define GOTO_TK 329
87 #define PACKAGE_TK      330
88 #define THIS_TK 331
89 #define BYTE_TK 332
90 #define SHORT_TK        333
91 #define INT_TK  334
92 #define LONG_TK 335
93 #define CHAR_TK 336
94 #define INTEGRAL_TK     337
95 #define FLOAT_TK        338
96 #define DOUBLE_TK       339
97 #define FP_TK   340
98 #define ID_TK   341
99 #define REL_QM_TK       342
100 #define REL_CL_TK       343
101 #define NOT_TK  344
102 #define NEG_TK  345
103 #define ASSIGN_ANY_TK   346
104 #define ASSIGN_TK       347
105 #define OP_TK   348
106 #define CP_TK   349
107 #define OCB_TK  350
108 #define CCB_TK  351
109 #define OSB_TK  352
110 #define CSB_TK  353
111 #define SC_TK   354
112 #define C_TK    355
113 #define DOT_TK  356
114 #define STRING_LIT_TK   357
115 #define CHAR_LIT_TK     358
116 #define INT_LIT_TK      359
117 #define FP_LIT_TK       360
118 #define TRUE_TK 361
119 #define FALSE_TK        362
120 #define BOOL_LIT_TK     363
121 #define NULL_TK 364
122
123 #line 48 "./parse.y"
124
125 #include "config.h"
126 #include "system.h"
127 #include <dirent.h>
128 #include "tree.h"
129 #include "rtl.h"
130 #include "obstack.h"
131 #include "toplev.h"
132 #include "flags.h"
133 #include "java-tree.h"
134 #include "jcf.h"
135 #include "lex.h"
136 #include "parse.h"
137 #include "zipfile.h"
138 #include "convert.h"
139 #include "buffer.h"
140 #include "xref.h"
141 #include "function.h"
142 #include "except.h"
143 #include "defaults.h"
144
145 #ifndef DIR_SEPARATOR
146 #define DIR_SEPARATOR '/'
147 #endif
148
149 /* Local function prototypes */
150 static char *java_accstring_lookup PROTO ((int));
151 static void  classitf_redefinition_error PROTO ((const char *,tree, tree, tree));
152 static void  variable_redefinition_error PROTO ((tree, tree, tree, int));
153 static void  check_modifiers PROTO ((const char *, int, int));
154 static tree  create_class PROTO ((int, tree, tree, tree));
155 static tree  create_interface PROTO ((int, tree, tree));
156 static tree  find_field PROTO ((tree, tree));
157 static tree lookup_field_wrapper PROTO ((tree, tree));
158 static int   duplicate_declaration_error_p PROTO ((tree, tree, tree));
159 static void  register_fields PROTO ((int, tree, tree));
160 static tree parser_qualified_classname PROTO ((tree));
161 static int  parser_check_super PROTO ((tree, tree, tree));
162 static int  parser_check_super_interface PROTO ((tree, tree, tree));
163 static void check_modifiers_consistency PROTO ((int));
164 static tree lookup_cl PROTO ((tree));
165 static tree lookup_java_method2 PROTO ((tree, tree, int));
166 static tree method_header PROTO ((int, tree, tree, tree));
167 static void fix_method_argument_names PROTO ((tree ,tree));
168 static tree method_declarator PROTO ((tree, tree));
169 static void parse_warning_context PVPROTO ((tree cl, const char *msg, ...))
170   ATTRIBUTE_PRINTF_2;
171 static void issue_warning_error_from_context PROTO ((tree, const char *msg, va_list));
172 static tree parse_jdk1_1_error PROTO ((const char *));
173 static void complete_class_report_errors PROTO ((jdep *));
174 static int process_imports PROTO ((void));
175 static void read_import_dir PROTO ((tree));
176 static int find_in_imports_on_demand PROTO ((tree));
177 static int find_in_imports PROTO ((tree));
178 static int check_pkg_class_access PROTO ((tree, tree));
179 static tree resolve_package PROTO ((tree, tree *));
180 static tree lookup_package_type PROTO ((const char *, int));
181 static tree lookup_package_type_and_set_next PROTO ((const char *, int, tree *));
182 static tree resolve_class PROTO ((tree, tree, tree));
183 static void declare_local_variables PROTO ((int, tree, tree));
184 static void source_start_java_method PROTO ((tree));
185 static void source_end_java_method PROTO ((void));
186 static void expand_start_java_method PROTO ((tree));
187 static tree find_name_in_single_imports PROTO ((tree));
188 static void check_abstract_method_header PROTO ((tree));
189 static tree lookup_java_interface_method2 PROTO ((tree, tree));
190 static tree resolve_expression_name PROTO ((tree, tree *));
191 static tree maybe_create_class_interface_decl PROTO ((tree, tree, tree));
192 static int check_class_interface_creation PROTO ((int, int, tree, 
193                                                   tree, tree, tree));
194 static tree patch_method_invocation PROTO ((tree, tree, tree, 
195                                             int *, tree *));
196 static int breakdown_qualified PROTO ((tree *, tree *, tree));
197 static tree resolve_and_layout PROTO ((tree, tree));
198 static tree resolve_no_layout PROTO ((tree, tree));
199 static int invocation_mode PROTO ((tree, int));
200 static tree find_applicable_accessible_methods_list PROTO ((int, tree, 
201                                                             tree, tree));
202 static void search_applicable_methods_list PROTO ((int, tree, tree, tree, 
203                                                    tree *, tree *));
204 static tree find_most_specific_methods_list PROTO ((tree));
205 static int argument_types_convertible PROTO ((tree, tree));
206 static tree patch_invoke PROTO ((tree, tree, tree));
207 static tree lookup_method_invoke PROTO ((int, tree, tree, tree, tree));
208 static tree register_incomplete_type PROTO ((int, tree, tree, tree));
209 static tree obtain_incomplete_type PROTO ((tree));
210 static tree java_complete_lhs PROTO ((tree));
211 static tree java_complete_tree PROTO ((tree));
212 static void java_complete_expand_method PROTO ((tree));
213 static int  unresolved_type_p PROTO ((tree, tree *));
214 static void create_jdep_list PROTO ((struct parser_ctxt *));
215 static tree build_expr_block PROTO ((tree, tree));
216 static tree enter_block PROTO ((void));
217 static tree enter_a_block PROTO ((tree));
218 static tree exit_block PROTO ((void));
219 static tree lookup_name_in_blocks PROTO ((tree));
220 static void maybe_absorb_scoping_blocks PROTO ((void));
221 static tree build_method_invocation PROTO ((tree, tree));
222 static tree build_new_invocation PROTO ((tree, tree));
223 static tree build_assignment PROTO ((int, int, tree, tree));
224 static tree build_binop PROTO ((enum tree_code, int, tree, tree));
225 static int check_final_assignment PROTO ((tree ,tree));
226 static tree patch_assignment PROTO ((tree, tree, tree ));
227 static tree patch_binop PROTO ((tree, tree, tree));
228 static tree build_unaryop PROTO ((int, int, tree));
229 static tree build_incdec PROTO ((int, int, tree, int));
230 static tree patch_unaryop PROTO ((tree, tree));
231 static tree build_cast PROTO ((int, tree, tree));
232 static tree build_null_of_type PROTO ((tree));
233 static tree patch_cast PROTO ((tree, tree));
234 static int valid_ref_assignconv_cast_p PROTO ((tree, tree, int));
235 static int valid_builtin_assignconv_identity_widening_p PROTO ((tree, tree));
236 static int valid_cast_to_p PROTO ((tree, tree));
237 static int valid_method_invocation_conversion_p PROTO ((tree, tree));
238 static tree try_builtin_assignconv PROTO ((tree, tree, tree));
239 static tree try_reference_assignconv PROTO ((tree, tree));
240 static tree build_unresolved_array_type PROTO ((tree));
241 static tree build_array_from_name PROTO ((tree, tree, tree, tree *));
242 static tree build_array_ref PROTO ((int, tree, tree));
243 static tree patch_array_ref PROTO ((tree));
244 static tree make_qualified_name PROTO ((tree, tree, int));
245 static tree merge_qualified_name PROTO ((tree, tree));
246 static tree make_qualified_primary PROTO ((tree, tree, int));
247 static int resolve_qualified_expression_name PROTO ((tree, tree *, 
248                                                      tree *, tree *));
249 static void qualify_ambiguous_name PROTO ((tree));
250 static void maybe_generate_clinit PROTO ((void));
251 static tree resolve_field_access PROTO ((tree, tree *, tree *));
252 static tree build_newarray_node PROTO ((tree, tree, int));
253 static tree patch_newarray PROTO ((tree));
254 static tree resolve_type_during_patch PROTO ((tree));
255 static tree build_this PROTO ((int));
256 static tree build_return PROTO ((int, tree));
257 static tree patch_return PROTO ((tree));
258 static tree maybe_access_field PROTO ((tree, tree, tree));
259 static int complete_function_arguments PROTO ((tree));
260 static int check_for_static_method_reference PROTO ((tree, tree, tree, tree, tree));
261 static int not_accessible_p PROTO ((tree, tree, int));
262 static void check_deprecation PROTO ((tree, tree));
263 static int class_in_current_package PROTO ((tree));
264 static tree build_if_else_statement PROTO ((int, tree, tree, tree));
265 static tree patch_if_else_statement PROTO ((tree));
266 static tree add_stmt_to_compound PROTO ((tree, tree, tree));
267 static tree add_stmt_to_block PROTO ((tree, tree, tree));
268 static tree patch_exit_expr PROTO ((tree));
269 static tree build_labeled_block PROTO ((int, tree));
270 static tree finish_labeled_statement PROTO ((tree, tree));
271 static tree build_bc_statement PROTO ((int, int, tree));
272 static tree patch_bc_statement PROTO ((tree));
273 static tree patch_loop_statement PROTO ((tree));
274 static tree build_new_loop PROTO ((tree));
275 static tree build_loop_body PROTO ((int, tree, int));
276 static tree finish_loop_body PROTO ((int, tree, tree, int));
277 static tree build_debugable_stmt PROTO ((int, tree));
278 static tree finish_for_loop PROTO ((int, tree, tree, tree));
279 static tree patch_switch_statement PROTO ((tree));
280 static tree string_constant_concatenation PROTO ((tree, tree));
281 static tree build_string_concatenation PROTO ((tree, tree));
282 static tree patch_string_cst PROTO ((tree));
283 static tree patch_string PROTO ((tree));
284 static tree build_try_statement PROTO ((int, tree, tree));
285 static tree build_try_finally_statement PROTO ((int, tree, tree));
286 static tree patch_try_statement PROTO ((tree));
287 static tree patch_synchronized_statement PROTO ((tree, tree));
288 static tree patch_throw_statement PROTO ((tree, tree));
289 static void check_thrown_exceptions PROTO ((int, tree));
290 static int check_thrown_exceptions_do PROTO ((tree));
291 static void purge_unchecked_exceptions PROTO ((tree));
292 static void check_throws_clauses PROTO ((tree, tree, tree));
293 static void finish_method_declaration PROTO ((tree));
294 static tree build_super_invocation PROTO ((void));
295 static int verify_constructor_circularity PROTO ((tree, tree));
296 static char *constructor_circularity_msg PROTO ((tree, tree));
297 static tree build_this_super_qualified_invocation PROTO ((int, tree, tree,
298                                                           int, int));
299 static const char *get_printable_method_name PROTO ((tree));
300 static tree patch_conditional_expr PROTO ((tree, tree, tree));
301 static void maybe_generate_finit PROTO ((void));
302 static void fix_constructors PROTO ((tree));
303 static int verify_constructor_super PROTO ((void));
304 static tree create_artificial_method PROTO ((tree, int, tree, tree, tree));
305 static void start_artificial_method_body PROTO ((tree));
306 static void end_artificial_method_body PROTO ((tree));
307 static int check_method_redefinition PROTO ((tree, tree));
308 static int reset_method_name PROTO ((tree));
309 static void java_check_regular_methods PROTO ((tree));
310 static void java_check_abstract_methods PROTO ((tree));
311 static tree maybe_build_primttype_type_ref PROTO ((tree, tree));
312 static void unreachable_stmt_error PROTO ((tree));
313 static tree find_expr_with_wfl PROTO ((tree));
314 static void missing_return_error PROTO ((tree));
315 static tree build_new_array_init PROTO ((int, tree));
316 static tree patch_new_array_init PROTO ((tree, tree));
317 static tree maybe_build_array_element_wfl PROTO ((tree));
318 static int array_constructor_check_entry PROTO ((tree, tree));
319 static const char *purify_type_name PROTO ((const char *));
320 static tree fold_constant_for_init PROTO ((tree, tree));
321 static tree strip_out_static_field_access_decl PROTO ((tree));
322 static jdeplist *reverse_jdep_list PROTO ((struct parser_ctxt *));
323 static void static_ref_err PROTO ((tree, tree, tree));
324 static void parser_add_interface PROTO ((tree, tree, tree));
325 static void add_superinterfaces PROTO ((tree, tree));
326 static tree jdep_resolve_class PROTO ((jdep *));
327 static int note_possible_classname PROTO ((const char *, int));
328 static void java_complete_expand_methods PROTO ((void));
329 static void java_expand_finals PROTO ((void));
330 static tree cut_identifier_in_qualified PROTO ((tree));
331 static tree java_stabilize_reference PROTO ((tree));
332 static tree do_unary_numeric_promotion PROTO ((tree));
333 static char * operator_string PROTO ((tree));
334 static tree do_merge_string_cste PROTO ((tree, const char *, int, int));
335 static tree merge_string_cste PROTO ((tree, tree, int));
336 static tree java_refold PROTO ((tree));
337 static int java_decl_equiv PROTO ((tree, tree));
338 static int binop_compound_p PROTO ((enum tree_code));
339 static tree search_loop PROTO ((tree));
340 static int labeled_block_contains_loop_p PROTO ((tree, tree));
341 static void check_abstract_method_definitions PROTO ((int, tree, tree));
342 static void java_check_abstract_method_definitions PROTO ((tree));
343
344 /* Number of error found so far. */
345 int java_error_count; 
346 /* Number of warning found so far. */
347 int java_warning_count;
348 /* Tell when not to fold, when doing xrefs */
349 int do_not_fold;
350
351 /* The current parser context */
352 struct parser_ctxt *ctxp;
353
354 /* List of things that were analyzed for which code will be generated */
355 static struct parser_ctxt *ctxp_for_generation = NULL;
356
357 /* binop_lookup maps token to tree_code. It is used where binary
358    operations are involved and required by the parser. RDIV_EXPR
359    covers both integral/floating point division. The code is changed
360    once the type of both operator is worked out.  */
361
362 static enum tree_code binop_lookup[19] = 
363   { 
364     PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
365     LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR, 
366     BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
367     TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
368     EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
369    };
370 #define BINOP_LOOKUP(VALUE)                                             \
371   binop_lookup [((VALUE) - PLUS_TK)%                                    \
372                 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
373
374 /* This is the end index for binary operators that can also be used
375    in compound assignements. */
376 #define BINOP_COMPOUND_CANDIDATES 11
377
378 /* Fake WFL used to report error message. It is initialized once if
379    needed and reused with it's location information is overriden.  */
380 tree wfl_operator = NULL_TREE;
381
382 /* The "$L" identifier we use to create labels.  */
383 static tree label_id = NULL_TREE;
384
385 /* The "StringBuffer" identifier used for the String `+' operator. */
386 static tree wfl_string_buffer = NULL_TREE; 
387
388 /* The "append" identifier used for String `+' operator.  */
389 static tree wfl_append = NULL_TREE;
390
391 /* The "toString" identifier used for String `+' operator. */
392 static tree wfl_to_string = NULL_TREE;
393
394 /* The "java.lang" import qualified name.  */
395 static tree java_lang_id = NULL_TREE;
396
397 /* The "java.lang.Cloneable" qualified name.  */
398 static tree java_lang_cloneable = NULL_TREE;
399
400 /* Context and flag for static blocks */
401 static tree current_static_block = NULL_TREE;
402
403
404 #line 329 "./parse.y"
405 typedef union {
406   tree node;
407   int sub_token;
408   struct {
409     int token;
410     int location;
411   } operator;
412   int value;
413 } YYSTYPE;
414 #line 339 "./parse.y"
415
416 #include "lex.c"
417 #ifndef YYDEBUG
418 #define YYDEBUG 1
419 #endif
420
421 #include <stdio.h>
422
423 #ifndef __cplusplus
424 #ifndef __STDC__
425 #define const
426 #endif
427 #endif
428
429
430
431 #define YYFINAL         777
432 #define YYFLAG          -32768
433 #define YYNTBASE        110
434
435 #define YYTRANSLATE(x) ((unsigned)(x) <= 364 ? yytranslate[x] : 266)
436
437 static const char yytranslate[] = {     0,
438      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
439      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
440      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
441      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
442      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
443      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
444      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
445      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
446      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
447      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
448      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
449      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
450      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
451      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
452      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
453      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
454      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
455      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
456      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
457      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
458      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
459      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
460      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
461      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
462      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
463      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
464      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
465     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
466     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
467     36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
468     46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
469     56,    57,    58,    59,    60,    61,    62,    63,    64,    65,
470     66,    67,    68,    69,    70,    71,    72,    73,    74,    75,
471     76,    77,    78,    79,    80,    81,    82,    83,    84,    85,
472     86,    87,    88,    89,    90,    91,    92,    93,    94,    95,
473     96,    97,    98,    99,   100,   101,   102,   103,   104,   105,
474    106,   107,   108,   109
475 };
476
477 #if YYDEBUG != 0
478 static const short yyprhs[] = {     0,
479      0,     2,     4,     6,     8,    10,    12,    14,    16,    18,
480     20,    22,    24,    26,    28,    30,    32,    34,    38,    42,
481     46,    50,    54,    56,    58,    60,    64,    66,    67,    69,
482     71,    73,    76,    79,    82,    86,    88,    91,    93,    96,
483    100,   103,   107,   109,   111,   115,   118,   122,   128,   133,
484    139,   141,   143,   145,   147,   149,   152,   153,   161,   162,
485    169,   173,   176,   180,   185,   186,   189,   193,   196,   197,
486    200,   203,   205,   209,   213,   216,   220,   222,   225,   227,
487    229,   231,   233,   235,   238,   240,   242,   244,   248,   253,
488    255,   259,   263,   265,   269,   273,   278,   280,   284,   287,
489    291,   295,   297,   299,   300,   304,   307,   311,   315,   320,
490    325,   328,   332,   335,   339,   342,   346,   351,   355,   359,
491    363,   365,   369,   373,   376,   380,   383,   387,   388,   391,
492    394,   396,   400,   404,   406,   409,   411,   414,   418,   420,
493    421,   425,   428,   432,   436,   441,   444,   448,   452,   457,
494    459,   462,   467,   473,   481,   488,   490,   492,   493,   498,
495    499,   505,   506,   512,   513,   520,   524,   529,   532,   536,
496    539,   543,   546,   550,   552,   555,   557,   559,   561,   563,
497    565,   568,   571,   574,   578,   583,   585,   589,   593,   596,
498    600,   602,   604,   606,   609,   611,   613,   615,   618,   621,
499    625,   627,   629,   631,   633,   635,   637,   639,   641,   643,
500    645,   647,   649,   651,   653,   655,   657,   659,   661,   663,
501    665,   667,   669,   671,   674,   677,   680,   683,   686,   689,
502    692,   695,   699,   704,   709,   715,   720,   726,   733,   741,
503    748,   750,   752,   754,   756,   758,   760,   762,   768,   771,
504    775,   780,   788,   796,   797,   801,   806,   809,   813,   819,
505    822,   826,   830,   835,   837,   840,   843,   845,   848,   852,
506    855,   858,   862,   865,   870,   873,   876,   880,   885,   888,
507    890,   898,   906,   913,   917,   923,   928,   936,   943,   946,
508    949,   953,   956,   957,   959,   961,   964,   965,   967,   969,
509    973,   977,   980,   984,   987,   991,   994,   998,  1001,  1005,
510   1008,  1012,  1015,  1019,  1023,  1026,  1030,  1036,  1042,  1045,
511   1050,  1054,  1056,  1060,  1064,  1069,  1072,  1074,  1077,  1080,
512   1085,  1088,  1092,  1097,  1100,  1103,  1105,  1107,  1109,  1111,
513   1115,  1117,  1119,  1121,  1123,  1127,  1131,  1135,  1139,  1143,
514   1147,  1151,  1155,  1161,  1166,  1173,  1179,  1184,  1190,  1196,
515   1203,  1207,  1211,  1216,  1222,  1225,  1229,  1233,  1237,  1239,
516   1243,  1247,  1251,  1255,  1260,  1265,  1270,  1275,  1279,  1283,
517   1285,  1288,  1292,  1296,  1299,  1302,  1306,  1310,  1314,  1318,
518   1321,  1325,  1330,  1336,  1343,  1349,  1356,  1361,  1366,  1371,
519   1376,  1380,  1385,  1389,  1394,  1396,  1398,  1400,  1402,  1405,
520   1408,  1410,  1412,  1415,  1418,  1420,  1423,  1426,  1429,  1432,
521   1435,  1438,  1440,  1443,  1446,  1448,  1451,  1454,  1460,  1465,
522   1470,  1476,  1481,  1484,  1490,  1495,  1501,  1503,  1507,  1511,
523   1515,  1519,  1523,  1527,  1529,  1533,  1537,  1541,  1545,  1547,
524   1551,  1555,  1559,  1563,  1567,  1571,  1573,  1577,  1581,  1585,
525   1589,  1593,  1597,  1601,  1605,  1609,  1613,  1615,  1619,  1623,
526   1627,  1631,  1633,  1637,  1641,  1643,  1647,  1651,  1653,  1657,
527   1661,  1663,  1667,  1671,  1673,  1677,  1681,  1683,  1689,  1694,
528   1698,  1704,  1706,  1708,  1712,  1716,  1718,  1720,  1722,  1724,
529   1726,  1728
530 };
531
532 static const short yyrhs[] = {   123,
533      0,   104,     0,   105,     0,   108,     0,   103,     0,   102,
534      0,   109,     0,   113,     0,   114,     0,    82,     0,    85,
535      0,    50,     0,   115,     0,   118,     0,   119,     0,   115,
536      0,   115,     0,   113,    97,    98,     0,   119,    97,    98,
537      0,   118,    97,    98,     0,   113,    97,     1,     0,   118,
538     97,     1,     0,   120,     0,   121,     0,   122,     0,   119,
539    101,   122,     0,    86,     0,     0,   126,     0,   124,     0,
540    125,     0,   126,   124,     0,   126,   125,     0,   124,   125,
541      0,   126,   124,   125,     0,   127,     0,   124,   127,     0,
542    130,     0,   125,   130,     0,    75,   119,    99,     0,    75,
543      1,     0,    75,   119,     1,     0,   128,     0,   129,     0,
544     55,   119,    99,     0,    55,     1,     0,    55,   119,     1,
545      0,    55,   119,   101,     5,    99,     0,    55,   119,   101,
546      1,     0,    55,   119,   101,     5,     1,     0,   132,     0,
547    166,     0,    99,     0,     1,     0,    44,     0,   131,    44,
548      0,     0,   131,    67,   122,   135,   136,   133,   138,     0,
549      0,    67,   122,   135,   136,   134,   138,     0,   131,    67,
550      1,     0,    67,     1,     0,    67,   122,     1,     0,   131,
551     67,   122,     1,     0,     0,    63,   116,     0,    63,   116,
552      1,     0,    63,     1,     0,     0,    52,   137,     0,    52,
553      1,     0,   117,     0,   137,   100,   117,     0,   137,   100,
554      1,     0,    95,    96,     0,    95,   139,    96,     0,   140,
555      0,   139,   140,     0,   141,     0,   156,     0,   158,     0,
556    179,     0,   142,     0,   142,    99,     0,   147,     0,   132,
557      0,   166,     0,   112,   143,    99,     0,   131,   112,   143,
558     99,     0,   144,     0,   143,   100,   144,     0,   143,   100,
559      1,     0,   145,     0,   145,    92,   146,     0,   145,    92,
560      1,     0,   145,    92,   146,     1,     0,   122,     0,   145,
561     97,    98,     0,   122,     1,     0,   145,    97,     1,     0,
562    145,    98,     1,     0,   264,     0,   177,     0,     0,   149,
563    148,   155,     0,   149,     1,     0,   112,   150,   153,     0,
564     59,   150,   153,     0,   131,   112,   150,   153,     0,   131,
565     59,   150,   153,     0,   112,     1,     0,   131,   112,     1,
566      0,    59,     1,     0,   131,    59,     1,     0,   131,     1,
567      0,   122,    93,    94,     0,   122,    93,   151,    94,     0,
568    150,    97,    98,     0,   122,    93,     1,     0,   150,    97,
569      1,     0,   152,     0,   151,   100,   152,     0,   151,   100,
570      1,     0,   112,   145,     0,   131,   112,   145,     0,   112,
571      1,     0,   131,   112,     1,     0,     0,    53,   154,     0,
572     53,     1,     0,   116,     0,   154,   100,   116,     0,   154,
573    100,     1,     0,   179,     0,   179,    99,     0,    99,     0,
574    157,   179,     0,   157,   179,    99,     0,    44,     0,     0,
575    160,   159,   162,     0,   161,   153,     0,   131,   161,   153,
576      0,   120,    93,    94,     0,   120,    93,   151,    94,     0,
577    180,   163,     0,   180,   164,   163,     0,   180,   182,   163,
578      0,   180,   164,   182,   163,     0,   181,     0,   181,    99,
579      0,   165,    93,    94,    99,     0,   165,    93,   233,    94,
580     99,     0,   119,   101,    65,    93,   233,    94,    99,     0,
581    119,   101,    65,    93,    94,    99,     0,    76,     0,    65,
582      0,     0,    61,   122,   167,   172,     0,     0,   131,    61,
583    122,   168,   172,     0,     0,    61,   122,   171,   169,   172,
584      0,     0,   131,    61,   122,   171,   170,   172,     0,    61,
585    122,     1,     0,   131,    61,   122,     1,     0,    63,   117,
586      0,   171,   100,   117,     0,    63,     1,     0,   171,   100,
587      1,     0,    95,    96,     0,    95,   173,    96,     0,   174,
588      0,   173,   174,     0,   175,     0,   176,     0,   132,     0,
589    166,     0,   142,     0,   149,    99,     0,   149,     1,     0,
590     95,    96,     0,    95,   178,    96,     0,    95,   178,   100,
591     96,     0,   146,     0,   178,   100,   146,     0,   178,   100,
592      1,     0,    95,    96,     0,   180,   182,   181,     0,    95,
593      0,    96,     0,   183,     0,   182,   183,     0,   184,     0,
594    186,     0,   132,     0,   185,    99,     0,   112,   143,     0,
595    131,   112,   143,     0,   188,     0,   191,     0,   195,     0,
596    196,     0,   207,     0,   211,     0,   188,     0,   192,     0,
597    197,     0,   208,     0,   212,     0,   179,     0,   189,     0,
598    193,     0,   198,     0,   210,     0,   218,     0,   219,     0,
599    220,     0,   222,     0,   221,     0,   224,     0,    99,     0,
600    122,    88,     0,   190,   186,     0,   122,     1,     0,   190,
601    187,     0,   194,    99,     0,     1,    99,     0,     1,    95,
602      0,     1,    96,     0,   165,    93,     1,     0,   165,    93,
603     94,     1,     0,   165,    93,   233,     1,     0,   165,    93,
604    233,    94,     1,     0,   119,   101,    65,     1,     0,   119,
605    101,    65,    93,     1,     0,   119,   101,    65,    93,   233,
606      1,     0,   119,   101,    65,    93,   233,    94,     1,     0,
607    119,   101,    65,    93,    94,     1,     0,   261,     0,   245,
608      0,   246,     0,   242,     0,   243,     0,   239,     0,   231,
609      0,    48,    93,   264,    94,   186,     0,    48,     1,     0,
610     48,    93,     1,     0,    48,    93,   264,     1,     0,    48,
611     93,   264,    94,   187,    56,   186,     0,    48,    93,   264,
612     94,   187,    56,   187,     0,     0,   200,   199,   201,     0,
613     68,    93,   264,    94,     0,    68,     1,     0,    68,    93,
614      1,     0,    68,    93,   264,    94,     1,     0,    95,    96,
615      0,    95,   204,    96,     0,    95,   202,    96,     0,    95,
616    202,   204,    96,     0,   203,     0,   202,   203,     0,   204,
617    182,     0,   205,     0,   204,   205,     0,    62,   265,    88,
618      0,    47,    88,     0,    62,     1,     0,    62,   265,     1,
619      0,    47,     1,     0,    66,    93,   264,    94,     0,   206,
620    186,     0,    66,     1,     0,    66,    93,     1,     0,    66,
621     93,   264,     1,     0,   206,   187,     0,    51,     0,   209,
622    186,    66,    93,   264,    94,    99,     0,   214,    99,   264,
623     99,   216,    94,   186,     0,   214,    99,    99,   216,    94,
624    186,     0,   214,    99,     1,     0,   214,    99,   264,    99,
625      1,     0,   214,    99,    99,     1,     0,   214,    99,   264,
626     99,   216,    94,   187,     0,   214,    99,    99,   216,    94,
627    187,     0,    71,    93,     0,    71,     1,     0,    71,    93,
628      1,     0,   213,   215,     0,     0,   217,     0,   185,     0,
629    217,     1,     0,     0,   217,     0,   194,     0,   217,   100,
630    194,     0,   217,   100,     1,     0,    54,    99,     0,    54,
631    122,    99,     0,    54,     1,     0,    54,   122,     1,     0,
632     73,    99,     0,    73,   122,    99,     0,    73,     1,     0,
633     73,   122,     1,     0,    58,    99,     0,    58,   264,    99,
634      0,    58,     1,     0,    58,   264,     1,     0,    49,   264,
635     99,     0,    49,     1,     0,    49,   264,     1,     0,   223,
636     93,   264,    94,   179,     0,   223,    93,   264,    94,     1,
637      0,   223,     1,     0,   223,    93,     1,    94,     0,   223,
638     93,     1,     0,    44,     0,    70,   179,   225,     0,    70,
639    179,   228,     0,    70,   179,   225,   228,     0,    70,     1,
640      0,   226,     0,   225,   226,     0,   227,   179,     0,    60,
641     93,   152,    94,     0,    60,     1,     0,    60,    93,     1,
642      0,    60,    93,     1,    94,     0,    64,   179,     0,    64,
643      1,     0,   230,     0,   234,     0,   111,     0,    76,     0,
644     93,   264,    94,     0,   231,     0,   238,     0,   239,     0,
645    240,     0,   119,   101,    67,     0,   113,   101,    67,     0,
646     59,   101,    67,     0,   119,   101,    76,     0,    93,   264,
647      1,     0,   119,   101,     1,     0,   113,   101,     1,     0,
648     59,   101,     1,     0,    72,   116,    93,   233,    94,     0,
649     72,   116,    93,    94,     0,    72,   116,    93,   233,    94,
650    138,     0,    72,   116,    93,    94,   138,     0,   232,   122,
651     93,    94,     0,   232,   122,    93,    94,   138,     0,   232,
652    122,    93,   233,    94,     0,   232,   122,    93,   233,    94,
653    138,     0,    72,     1,    99,     0,    72,   116,     1,     0,
654     72,   116,    93,     1,     0,    72,   116,    93,   233,     1,
655      0,   232,     1,     0,   232,   122,     1,     0,   119,   101,
656     72,     0,   229,   101,    72,     0,   264,     0,   233,   100,
657    264,     0,   233,   100,     1,     0,    72,   113,   235,     0,
658     72,   115,   235,     0,    72,   113,   235,   237,     0,    72,
659    115,   235,   237,     0,    72,   115,   237,   177,     0,    72,
660    113,   237,   177,     0,    72,     1,    98,     0,    72,     1,
661     97,     0,   236,     0,   235,   236,     0,    97,   264,    98,
662      0,    97,   264,     1,     0,    97,     1,     0,    97,    98,
663      0,   237,    97,    98,     0,   237,    97,     1,     0,   229,
664    101,   122,     0,    65,   101,   122,     0,    65,     1,     0,
665    119,    93,    94,     0,   119,    93,   233,    94,     0,   229,
666    101,   122,    93,    94,     0,   229,   101,   122,    93,   233,
667     94,     0,    65,   101,   122,    93,    94,     0,    65,   101,
668    122,    93,   233,    94,     0,    65,   101,     1,    94,     0,
669     65,   101,     1,   101,     0,   119,    97,   264,    98,     0,
670    230,    97,   264,    98,     0,   119,    97,     1,     0,   119,
671     97,   264,     1,     0,   230,    97,     1,     0,   230,    97,
672    264,     1,     0,   229,     0,   119,     0,   242,     0,   243,
673      0,   241,    46,     0,   241,    45,     0,   245,     0,   246,
674      0,     3,   244,     0,     4,   244,     0,   247,     0,     3,
675      1,     0,     4,     1,     0,    46,   244,     0,    46,     1,
676      0,    45,   244,     0,    45,     1,     0,   241,     0,    89,
677    244,     0,    90,   244,     0,   248,     0,    89,     1,     0,
678     90,     1,     0,    93,   113,   237,    94,   244,     0,    93,
679    113,    94,   244,     0,    93,   264,    94,   247,     0,    93,
680    119,   237,    94,   247,     0,    93,   113,    97,     1,     0,
681     93,     1,     0,    93,   113,   237,    94,     1,     0,    93,
682    113,    94,     1,     0,    93,   119,   237,    94,     1,     0,
683    244,     0,   249,     5,   244,     0,   249,     6,   244,     0,
684    249,     7,   244,     0,   249,     5,     1,     0,   249,     6,
685      1,     0,   249,     7,     1,     0,   249,     0,   250,     3,
686    249,     0,   250,     4,   249,     0,   250,     3,     1,     0,
687    250,     4,     1,     0,   250,     0,   251,     8,   250,     0,
688    251,     9,   250,     0,   251,    10,   250,     0,   251,     8,
689      1,     0,   251,     9,     1,     0,   251,    10,     1,     0,
690    251,     0,   252,    20,   251,     0,   252,    18,   251,     0,
691    252,    21,   251,     0,   252,    19,   251,     0,   252,    57,
692    114,     0,   252,    20,     1,     0,   252,    18,     1,     0,
693    252,    21,     1,     0,   252,    19,     1,     0,   252,    57,
694      1,     0,   252,     0,   253,    16,   252,     0,   253,    17,
695    252,     0,   253,    16,     1,     0,   253,    17,     1,     0,
696    253,     0,   254,    11,   253,     0,   254,    11,     1,     0,
697    254,     0,   255,    12,   254,     0,   255,    12,     1,     0,
698    255,     0,   256,    13,   255,     0,   256,    13,     1,     0,
699    256,     0,   257,    14,   256,     0,   257,    14,     1,     0,
700    257,     0,   258,    15,   257,     0,   258,    15,     1,     0,
701    258,     0,   258,    87,   264,    88,   259,     0,   258,    87,
702     88,     1,     0,   258,    87,     1,     0,   258,    87,   264,
703     88,     1,     0,   259,     0,   261,     0,   262,   263,   260,
704      0,   262,   263,     1,     0,   119,     0,   238,     0,   240,
705      0,    91,     0,    92,     0,   260,     0,   264,     0
706 };
707
708 #endif
709
710 #if YYDEBUG != 0
711 static const short yyrline[] = { 0,
712    483,   489,   491,   492,   493,   494,   495,   499,   501,   504,
713    506,   507,   510,   512,   515,   519,   523,   527,   533,   535,
714    537,   539,   544,   546,   549,   553,   558,   563,   565,   566,
715    567,   568,   569,   570,   571,   574,   579,   585,   587,   590,
716    593,   595,   599,   601,   604,   631,   633,   637,   650,   652,
717    656,   663,   668,   670,   680,   685,   700,   704,   707,   710,
718    713,   715,   717,   722,   726,   728,   730,   732,   736,   738,
719    740,   747,   753,   758,   762,   771,   781,   783,   786,   788,
720    789,   790,   794,   796,   798,   799,   801,   806,   809,   819,
721    822,   824,   828,   831,   838,   844,   852,   854,   856,   858,
722    860,   864,   866,   870,   877,   878,   882,   885,   887,   889,
723    891,   893,   895,   897,   899,   906,   909,   911,   920,   922,
724    926,   931,   936,   940,   945,   950,   952,   959,   961,   963,
725    967,   970,   972,   976,   978,   979,   984,   990,   997,  1005,
726   1012,  1015,  1018,  1022,  1025,  1029,  1038,  1040,  1042,  1046,
727   1048,  1051,  1058,  1066,  1068,  1072,  1079,  1089,  1093,  1096,
728   1099,  1102,  1105,  1108,  1111,  1114,  1116,  1120,  1126,  1131,
729   1133,  1137,  1140,  1144,  1146,  1149,  1151,  1152,  1154,  1158,
730   1162,  1168,  1173,  1176,  1178,  1182,  1188,  1192,  1197,  1206,
731   1210,  1215,  1227,  1229,  1232,  1234,  1236,  1240,  1244,  1247,
732   1251,  1253,  1254,  1255,  1256,  1257,  1261,  1263,  1264,  1265,
733   1266,  1270,  1272,  1273,  1274,  1275,  1276,  1277,  1278,  1279,
734   1280,  1281,  1284,  1289,  1300,  1303,  1307,  1314,  1324,  1330,
735   1336,  1342,  1344,  1350,  1352,  1358,  1360,  1362,  1364,  1366,
736   1370,  1372,  1373,  1374,  1375,  1376,  1377,  1380,  1386,  1388,
737   1390,  1394,  1399,  1404,  1410,  1420,  1426,  1428,  1430,  1437,
738   1440,  1442,  1444,  1448,  1450,  1453,  1457,  1459,  1462,  1469,
739   1475,  1477,  1479,  1483,  1491,  1494,  1496,  1498,  1502,  1507,
740   1516,  1521,  1524,  1531,  1533,  1535,  1539,  1542,  1551,  1558,
741   1560,  1564,  1577,  1579,  1585,  1591,  1595,  1597,  1601,  1604,
742   1606,  1610,  1613,  1615,  1617,  1621,  1624,  1626,  1628,  1632,
743   1635,  1637,  1639,  1643,  1649,  1651,  1655,  1662,  1664,  1666,
744   1668,  1672,  1680,  1683,  1685,  1690,  1694,  1696,  1703,  1711,
745   1728,  1730,  1732,  1736,  1739,  1744,  1746,  1749,  1751,  1753,
746   1755,  1756,  1757,  1758,  1762,  1764,  1766,  1771,  1773,  1775,
747   1777,  1779,  1783,  1786,  1791,  1793,  1798,  1799,  1800,  1801,
748   1802,  1804,  1806,  1808,  1810,  1812,  1816,  1818,  1821,  1827,
749   1832,  1836,  1839,  1841,  1843,  1847,  1849,  1851,  1853,  1857,
750   1860,  1864,  1870,  1872,  1880,  1907,  1909,  1913,  1918,  1925,
751   1929,  1932,  1934,  1945,  1956,  1961,  1970,  1972,  1976,  1979,
752   1981,  1986,  1991,  1996,  2003,  2005,  2006,  2007,  2010,  2015,
753   2020,  2022,  2023,  2025,  2027,  2028,  2030,  2034,  2037,  2041,
754   2044,  2048,  2050,  2052,  2054,  2055,  2057,  2061,  2070,  2072,
755   2074,  2087,  2089,  2095,  2097,  2099,  2103,  2105,  2110,  2115,
756   2120,  2122,  2124,  2128,  2130,  2135,  2140,  2142,  2146,  2148,
757   2153,  2158,  2163,  2165,  2167,  2171,  2173,  2178,  2183,  2188,
758   2193,  2195,  2197,  2199,  2201,  2203,  2207,  2209,  2214,  2219,
759   2221,  2225,  2227,  2232,  2236,  2238,  2243,  2247,  2249,  2254,
760   2258,  2260,  2265,  2269,  2271,  2276,  2280,  2282,  2287,  2293,
761   2295,  2299,  2301,  2304,  2307,  2315,  2317,  2318,  2321,  2323,
762   2326,  2330
763 };
764 #endif
765
766
767 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
768
769 static const char * const yytname[] = {   "$","error","$undefined.","PLUS_TK",
770 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
771 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
772 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
773 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
774 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
775 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
776 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
777 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
778 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
779 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
780 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
781 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
782 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
783 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
784 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
785 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
786 "class_type","interface_type","array_type","name","simple_name","qualified_name",
787 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
788 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
789 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
790 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
791 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
792 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
793 "method_declarator","formal_parameter_list","formal_parameter","throws","class_type_list",
794 "method_body","static_initializer","static","constructor_declaration","@4","constructor_header",
795 "constructor_declarator","constructor_body","constructor_block_end","explicit_constructor_invocation",
796 "this_or_super","interface_declaration","@5","@6","@7","@8","extends_interfaces",
797 "interface_body","interface_member_declarations","interface_member_declaration",
798 "constant_declaration","abstract_method_declaration","array_initializer","variable_initializers",
799 "block","block_begin","block_end","block_statements","block_statement","local_variable_declaration_statement",
800 "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement",
801 "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
802 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
803 "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups",
804 "switch_block_statement_group","switch_labels","switch_label","while_expression",
805 "while_statement","while_statement_nsi","do_statement_begin","do_statement",
806 "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update",
807 "statement_expression_list","break_statement","continue_statement","return_statement",
808 "throw_statement","synchronized_statement","synchronized","try_statement","catches",
809 "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array",
810 "class_instance_creation_expression","something_dot_new","argument_list","array_creation_expression",
811 "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access",
812 "postfix_expression","post_increment_expression","post_decrement_expression",
813 "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus",
814 "cast_expression","multiplicative_expression","additive_expression","shift_expression",
815 "relational_expression","equality_expression","and_expression","exclusive_or_expression",
816 "inclusive_or_expression","conditional_and_expression","conditional_or_expression",
817 "conditional_expression","assignment_expression","assignment","left_hand_side",
818 "assignment_operator","expression","constant_expression", NULL
819 };
820 #endif
821
822 static const short yyr1[] = {     0,
823    110,   111,   111,   111,   111,   111,   111,   112,   112,   113,
824    113,   113,   114,   114,   115,   116,   117,   118,   118,   118,
825    118,   118,   119,   119,   120,   121,   122,   123,   123,   123,
826    123,   123,   123,   123,   123,   124,   124,   125,   125,   126,
827    126,   126,   127,   127,   128,   128,   128,   129,   129,   129,
828    130,   130,   130,   130,   131,   131,   133,   132,   134,   132,
829    132,   132,   132,   132,   135,   135,   135,   135,   136,   136,
830    136,   137,   137,   137,   138,   138,   139,   139,   140,   140,
831    140,   140,   141,   141,   141,   141,   141,   142,   142,   143,
832    143,   143,   144,   144,   144,   144,   145,   145,   145,   145,
833    145,   146,   146,   148,   147,   147,   149,   149,   149,   149,
834    149,   149,   149,   149,   149,   150,   150,   150,   150,   150,
835    151,   151,   151,   152,   152,   152,   152,   153,   153,   153,
836    154,   154,   154,   155,   155,   155,   156,   156,   157,   159,
837    158,   160,   160,   161,   161,   162,   162,   162,   162,   163,
838    163,   164,   164,   164,   164,   165,   165,   167,   166,   168,
839    166,   169,   166,   170,   166,   166,   166,   171,   171,   171,
840    171,   172,   172,   173,   173,   174,   174,   174,   174,   175,
841    176,   176,   177,   177,   177,   178,   178,   178,   179,   179,
842    180,   181,   182,   182,   183,   183,   183,   184,   185,   185,
843    186,   186,   186,   186,   186,   186,   187,   187,   187,   187,
844    187,   188,   188,   188,   188,   188,   188,   188,   188,   188,
845    188,   188,   189,   190,   191,   191,   192,   193,   193,   193,
846    193,   193,   193,   193,   193,   193,   193,   193,   193,   193,
847    194,   194,   194,   194,   194,   194,   194,   195,   195,   195,
848    195,   196,   197,   199,   198,   200,   200,   200,   200,   201,
849    201,   201,   201,   202,   202,   203,   204,   204,   205,   205,
850    205,   205,   205,   206,   207,   207,   207,   207,   208,   209,
851    210,   211,   211,   211,   211,   211,   212,   212,   213,   213,
852    213,   214,   215,   215,   215,   215,   216,   216,   217,   217,
853    217,   218,   218,   218,   218,   219,   219,   219,   219,   220,
854    220,   220,   220,   221,   221,   221,   222,   222,   222,   222,
855    222,   223,   224,   224,   224,   224,   225,   225,   226,   227,
856    227,   227,   227,   228,   228,   229,   229,   230,   230,   230,
857    230,   230,   230,   230,   230,   230,   230,   230,   230,   230,
858    230,   230,   231,   231,   231,   231,   231,   231,   231,   231,
859    231,   231,   231,   231,   231,   231,   232,   232,   233,   233,
860    233,   234,   234,   234,   234,   234,   234,   234,   234,   235,
861    235,   236,   236,   236,   237,   237,   237,   238,   238,   238,
862    239,   239,   239,   239,   239,   239,   239,   239,   240,   240,
863    240,   240,   240,   240,   241,   241,   241,   241,   242,   243,
864    244,   244,   244,   244,   244,   244,   244,   245,   245,   246,
865    246,   247,   247,   247,   247,   247,   247,   248,   248,   248,
866    248,   248,   248,   248,   248,   248,   249,   249,   249,   249,
867    249,   249,   249,   250,   250,   250,   250,   250,   251,   251,
868    251,   251,   251,   251,   251,   252,   252,   252,   252,   252,
869    252,   252,   252,   252,   252,   252,   253,   253,   253,   253,
870    253,   254,   254,   254,   255,   255,   255,   256,   256,   256,
871    257,   257,   257,   258,   258,   258,   259,   259,   259,   259,
872    259,   260,   260,   261,   261,   262,   262,   262,   263,   263,
873    264,   265
874 };
875
876 static const short yyr2[] = {     0,
877      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
878      1,     1,     1,     1,     1,     1,     1,     3,     3,     3,
879      3,     3,     1,     1,     1,     3,     1,     0,     1,     1,
880      1,     2,     2,     2,     3,     1,     2,     1,     2,     3,
881      2,     3,     1,     1,     3,     2,     3,     5,     4,     5,
882      1,     1,     1,     1,     1,     2,     0,     7,     0,     6,
883      3,     2,     3,     4,     0,     2,     3,     2,     0,     2,
884      2,     1,     3,     3,     2,     3,     1,     2,     1,     1,
885      1,     1,     1,     2,     1,     1,     1,     3,     4,     1,
886      3,     3,     1,     3,     3,     4,     1,     3,     2,     3,
887      3,     1,     1,     0,     3,     2,     3,     3,     4,     4,
888      2,     3,     2,     3,     2,     3,     4,     3,     3,     3,
889      1,     3,     3,     2,     3,     2,     3,     0,     2,     2,
890      1,     3,     3,     1,     2,     1,     2,     3,     1,     0,
891      3,     2,     3,     3,     4,     2,     3,     3,     4,     1,
892      2,     4,     5,     7,     6,     1,     1,     0,     4,     0,
893      5,     0,     5,     0,     6,     3,     4,     2,     3,     2,
894      3,     2,     3,     1,     2,     1,     1,     1,     1,     1,
895      2,     2,     2,     3,     4,     1,     3,     3,     2,     3,
896      1,     1,     1,     2,     1,     1,     1,     2,     2,     3,
897      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
898      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
899      1,     1,     1,     2,     2,     2,     2,     2,     2,     2,
900      2,     3,     4,     4,     5,     4,     5,     6,     7,     6,
901      1,     1,     1,     1,     1,     1,     1,     5,     2,     3,
902      4,     7,     7,     0,     3,     4,     2,     3,     5,     2,
903      3,     3,     4,     1,     2,     2,     1,     2,     3,     2,
904      2,     3,     2,     4,     2,     2,     3,     4,     2,     1,
905      7,     7,     6,     3,     5,     4,     7,     6,     2,     2,
906      3,     2,     0,     1,     1,     2,     0,     1,     1,     3,
907      3,     2,     3,     2,     3,     2,     3,     2,     3,     2,
908      3,     2,     3,     3,     2,     3,     5,     5,     2,     4,
909      3,     1,     3,     3,     4,     2,     1,     2,     2,     4,
910      2,     3,     4,     2,     2,     1,     1,     1,     1,     3,
911      1,     1,     1,     1,     3,     3,     3,     3,     3,     3,
912      3,     3,     5,     4,     6,     5,     4,     5,     5,     6,
913      3,     3,     4,     5,     2,     3,     3,     3,     1,     3,
914      3,     3,     3,     4,     4,     4,     4,     3,     3,     1,
915      2,     3,     3,     2,     2,     3,     3,     3,     3,     2,
916      3,     4,     5,     6,     5,     6,     4,     4,     4,     4,
917      3,     4,     3,     4,     1,     1,     1,     1,     2,     2,
918      1,     1,     2,     2,     1,     2,     2,     2,     2,     2,
919      2,     1,     2,     2,     1,     2,     2,     5,     4,     4,
920      5,     4,     2,     5,     4,     5,     1,     3,     3,     3,
921      3,     3,     3,     1,     3,     3,     3,     3,     1,     3,
922      3,     3,     3,     3,     3,     1,     3,     3,     3,     3,
923      3,     3,     3,     3,     3,     3,     1,     3,     3,     3,
924      3,     1,     3,     3,     1,     3,     3,     1,     3,     3,
925      1,     3,     3,     1,     3,     3,     1,     5,     4,     3,
926      5,     1,     1,     3,     3,     1,     1,     1,     1,     1,
927      1,     1
928 };
929
930 static const short yydefact[] = {     0,
931     54,    55,     0,     0,     0,     0,    53,     1,     0,     0,
932      0,    36,    43,    44,    38,     0,    51,    52,    46,    27,
933      0,    23,    24,    25,     0,    62,     0,    41,     0,     0,
934     37,    39,     0,     0,    56,     0,     0,    47,    45,     0,
935    166,     0,     0,   162,    63,     0,    69,    42,    40,     0,
936      0,     0,    61,     0,    49,     0,    26,   170,    17,   168,
937     15,     0,   159,     0,     0,    68,    16,     0,     0,    59,
938    167,     0,   164,    64,    69,    50,    48,    12,     0,    10,
939     11,   172,     0,     8,     9,    13,    14,    15,     0,   178,
940    180,     0,   179,     0,   174,   176,   177,   171,   169,   163,
941     67,    71,    72,    70,     0,   161,     0,    57,   113,     0,
942    128,   111,     0,     0,    90,    93,   128,     0,     0,     0,
943    115,     0,     0,   182,   181,   173,   175,     0,     0,    60,
944    165,     0,     0,     0,     0,   108,    99,    88,     0,     0,
945      0,     0,   107,    21,    18,    22,    20,    19,   114,   128,
946    112,     0,   128,    74,    73,    55,   191,    75,    23,     0,
947     86,     0,    77,    79,    83,    85,     0,    80,     0,    81,
948    140,   128,    87,    82,     0,    58,   119,   116,     0,     0,
949      0,   121,   130,   131,   129,   120,   118,    92,     0,    91,
950     95,     0,     0,     0,     0,     0,     0,     0,   339,     0,
951      0,     0,     0,     6,     5,     2,     3,     4,     7,   338,
952      0,   406,     0,   103,   405,   336,   341,     0,   337,   342,
953    343,   344,   422,   407,   408,   437,   411,   412,   415,   425,
954    444,   449,   456,   467,   472,   475,   478,   481,   484,   487,
955    492,   501,   493,     0,   102,   100,    98,   101,   110,    89,
956    109,   189,     0,   128,    76,    78,    84,   106,     0,   137,
957      0,   142,     0,    55,     0,     0,   280,     0,     0,     0,
958      0,     0,     0,     0,     0,   339,     0,   223,     0,     8,
959    406,     0,     0,   197,     0,   212,     0,   193,   195,     0,
960    196,   201,   213,     0,   202,   214,     0,   203,   204,   215,
961    254,     0,   205,     0,   216,   206,   293,     0,   217,   218,
962    219,   221,   220,     0,   222,   247,   246,     0,   244,   245,
963    242,   243,   241,   126,   124,     0,   117,     0,     0,   416,
964    406,   342,   344,   413,   417,   414,   421,   420,   419,   418,
965      0,   390,     0,     0,     0,    16,     0,   426,   423,   427,
966    424,   433,     0,   406,     0,   183,   186,     0,     0,     0,
967      0,     0,    96,     0,     0,   365,     0,   410,   409,     0,
968      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
969      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
970    499,   500,     0,   144,     0,   143,   136,   105,   134,   138,
971    191,   141,     0,   230,   231,   229,   249,     0,   315,     0,
972    304,   302,     0,   312,   310,     0,   276,     0,   257,     0,
973    326,     0,   290,     0,   308,   306,     0,     0,   199,     0,
974      0,   226,   224,     0,     0,   192,   190,   194,   198,   322,
975    406,   225,   228,     0,   275,     0,   406,     0,   295,   299,
976    292,     0,     0,   319,     0,   127,   125,   123,   122,   133,
977    132,   352,   347,     0,   389,   379,   378,   361,     0,   372,
978    380,     0,   373,     0,   362,     0,     0,     0,     0,     0,
979      0,   349,   340,   184,     0,   351,   346,   391,     0,   369,
980    401,     0,   350,   345,   367,   348,   368,   388,   403,     0,
981    366,     0,   441,   438,   442,   439,   443,   440,   447,   445,
982    448,   446,   453,   450,   454,   451,   455,   452,   463,   458,
983    465,   460,   462,   457,   464,   459,   466,     0,   461,   470,
984    468,   471,   469,   474,   473,   477,   476,   480,   479,   483,
985    482,   486,   485,   490,     0,     0,   495,   494,   145,   135,
986    406,   146,     0,     0,   150,     0,   250,     0,   316,   314,
987    305,   303,   313,   311,   277,     0,   258,     0,     0,     0,
988    323,   327,     0,   324,   291,   309,   307,   340,     0,   200,
989    232,     0,     0,     0,   255,     0,   296,     0,   284,     0,
990      0,   321,     0,   397,   398,     0,   384,   385,     0,   381,
991    374,     0,   377,   375,   376,   363,   354,     0,   435,   429,
992    432,     0,     0,   430,   188,   185,   187,   392,     0,   402,
993    399,     0,   404,   400,   357,     0,   489,     0,     0,   147,
994      0,     0,   151,   148,   251,     0,   278,   274,     0,   331,
995      0,   335,   334,   328,   325,   329,   236,     0,   233,   234,
996      0,     0,     0,   260,     0,   264,     0,   267,     0,   301,
997    300,   286,     0,   298,     0,   320,     0,   395,     0,   383,
998    382,   387,   386,   356,   364,   353,   434,   428,   436,   431,
999    371,   370,   393,     0,   358,   359,   491,   488,     0,   149,
1000      0,     0,     0,   248,     0,   201,     0,   208,   209,     0,
1001    210,   211,     0,   259,   332,     0,   237,     0,     0,   235,
1002    273,   270,   271,   502,     0,   262,   265,     0,   261,     0,
1003    268,     0,     0,   285,     0,   318,   317,   396,   355,   394,
1004    360,     0,   152,     0,     0,     0,   227,   279,     0,   333,
1005    330,   240,   238,     0,   272,   269,   263,     0,   283,     0,
1006      0,     0,   153,     0,   252,     0,     0,   239,   281,   282,
1007    155,     0,     0,     0,     0,   154,     0,     0,     0,     0,
1008    288,     0,   253,   287,     0,     0,     0
1009 };
1010
1011 static const short yydefgoto[] = {   775,
1012    210,   279,   211,    85,    86,    68,    60,    87,   212,    22,
1013     23,    24,     8,     9,    10,    11,    12,    13,    14,    15,
1014    283,   284,   132,   105,    47,    70,   104,   130,   162,   163,
1015    164,    91,   114,   115,   116,   213,   166,   259,    92,   111,
1016    181,   182,   136,   185,   398,   168,   169,   170,   261,   171,
1017    172,   402,   552,   553,   285,    18,    43,    72,    65,   107,
1018     44,    63,    94,    95,    96,    97,   214,   358,   286,   175,
1019    555,   720,   288,   289,   290,   291,   695,   292,   293,   294,
1020    295,   698,   296,   297,   298,   299,   699,   300,   444,   301,
1021    585,   655,   656,   657,   658,   302,   303,   701,   304,   305,
1022    306,   702,   307,   308,   451,   663,   664,   309,   310,   311,
1023    312,   313,   314,   315,   571,   572,   573,   574,   215,   216,
1024    217,   218,   489,   219,   470,   471,   472,   220,   221,   222,
1025    223,   224,   225,   226,   227,   228,   229,   230,   231,   232,
1026    233,   234,   235,   236,   237,   238,   239,   240,   241,   242,
1027    243,   244,   393,   490,   715
1028 };
1029
1030 static const short yypact[] = {   507,
1031 -32768,-32768,    15,   -30,    18,   244,-32768,-32768,   414,   443,
1032    556,-32768,-32768,-32768,-32768,   714,-32768,-32768,-32768,-32768,
1033     23,-32768,-32768,-32768,   359,-32768,   340,-32768,    49,   601,
1034 -32768,-32768,   585,   603,-32768,   -30,   417,-32768,-32768,    92,
1035 -32768,   489,   -24,   107,-32768,   529,   295,-32768,-32768,   -30,
1036    710,   452,-32768,   344,-32768,    40,-32768,-32768,-32768,-32768,
1037    192,  1047,-32768,   530,   -24,-32768,-32768,   388,   534,-32768,
1038 -32768,   -24,   107,-32768,   295,-32768,-32768,-32768,   540,-32768,
1039 -32768,-32768,   548,   258,-32768,-32768,   307,   442,   736,-32768,
1040 -32768,    77,-32768,  1638,-32768,-32768,-32768,-32768,-32768,-32768,
1041 -32768,-32768,-32768,   312,   406,-32768,   -24,-32768,-32768,   379,
1042    -18,-32768,   426,   331,-32768,   693,   -18,   120,   210,   429,
1043 -32768,   564,   587,-32768,-32768,-32768,-32768,   593,   951,-32768,
1044 -32768,   406,   607,   617,   214,-32768,-32768,-32768,   618,  1077,
1045    219,   531,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   -18,
1046 -32768,   361,   -18,-32768,-32768,   460,   471,-32768,   494,   736,
1047 -32768,  1204,-32768,-32768,   500,-32768,   180,-32768,   535,-32768,
1048 -32768,   591,-32768,-32768,  1759,-32768,-32768,-32768,   620,   728,
1049    377,-32768,-32768,-32768,   613,-32768,-32768,-32768,   157,-32768,
1050 -32768,  2663,  2728,  2779,  2844,   655,    32,   707,-32768,  2895,
1051   2960,  3011,  5025,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1052    673,   881,    56,-32768,   678,   746,-32768,   640,-32768,   671,
1053 -32768,   715,   866,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1054    899,   921,  1006,   838,   920,   654,   814,   820,   847,   263,
1055 -32768,-32768,-32768,   850,-32768,-32768,-32768,-32768,-32768,-32768,
1056 -32768,-32768,   963,   591,-32768,-32768,-32768,-32768,   484,   769,
1057    775,-32768,    -1,   306,   353,  3076,-32768,   232,  1357,    35,
1058    392,   419,   228,   424,   234,   779,  5324,-32768,   -30,   538,
1059    974,   265,   872,-32768,   784,-32768,  1691,-32768,-32768,   789,
1060 -32768,-32768,-32768,  1827,-32768,-32768,   797,-32768,-32768,-32768,
1061 -32768,  1827,-32768,  1827,-32768,-32768,  5375,   802,-32768,-32768,
1062 -32768,-32768,-32768,   427,-32768,   737,   806,   866,   902,   916,
1063 -32768,-32768,-32768,-32768,   891,   642,-32768,   592,   660,-32768,
1064    189,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1065    409,-32768,   666,   964,   793,   793,   428,-32768,-32768,-32768,
1066 -32768,-32768,   777,  1121,    66,-32768,-32768,   622,   432,  5092,
1067   3127,   729,-32768,   -28,  3192,-32768,   435,-32768,-32768,  3243,
1068   3308,  3359,  3424,  3475,  3540,  3591,  3656,  3707,  3772,  3823,
1069   3888,   864,  3939,  4004,  4055,  4120,  4171,  4236,  4287,  2032,
1070 -32768,-32768,  4352,-32768,   605,-32768,-32768,-32768,   810,-32768,
1071 -32768,-32768,  1691,-32768,-32768,-32768,-32768,  4403,-32768,    95,
1072 -32768,-32768,   126,-32768,-32768,   174,-32768,  4468,-32768,  4519,
1073 -32768,   785,-32768,  4933,-32768,-32768,   182,   269,   815,  2083,
1074    604,-32768,-32768,   -30,  2148,-32768,-32768,-32768,-32768,-32768,
1075   1158,-32768,-32768,   823,-32768,   861,  1018,   728,-32768,-32768,
1076 -32768,    86,  2199,-32768,  4584,-32768,   891,-32768,-32768,-32768,
1077 -32768,-32768,-32768,   565,   836,-32768,-32768,-32768,  2264,   793,
1078 -32768,   590,   793,   590,-32768,  2315,  4635,   223,   -43,  2380,
1079    191,-32768,   894,-32768,  1967,-32768,-32768,-32768,   649,-32768,
1080 -32768,   237,-32768,-32768,-32768,-32768,-32768,   839,-32768,   239,
1081 -32768,  5143,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   899,
1082 -32768,   899,-32768,   921,-32768,   921,-32768,   921,-32768,  1006,
1083 -32768,  1006,-32768,  1006,-32768,  1006,-32768,   258,-32768,-32768,
1084    838,-32768,   838,-32768,   920,-32768,   654,-32768,   814,-32768,
1085    820,-32768,   847,-32768,   933,   857,-32768,-32768,-32768,-32768,
1086   1254,-32768,  1691,   859,   856,  1691,-32768,   314,-32768,-32768,
1087 -32768,-32768,-32768,-32768,-32768,   348,-32768,   870,   461,   229,
1088    785,-32768,   535,-32768,-32768,-32768,-32768,-32768,   467,   815,
1089 -32768,   967,    14,   444,-32768,   878,-32768,  5067,-32768,  4958,
1090    876,   887,   892,-32768,-32768,  5208,-32768,-32768,   241,-32768,
1091    895,   299,-32768,   895,-32768,-32768,   406,    17,-32768,-32768,
1092 -32768,  4700,   487,-32768,-32768,-32768,-32768,-32768,  4751,-32768,
1093 -32768,  5259,-32768,-32768,   406,   704,-32768,  4816,   662,-32768,
1094   1691,  2431,-32768,-32768,-32768,  1893,-32768,-32768,   343,-32768,
1095    835,-32768,-32768,-32768,-32768,-32768,-32768,  2496,-32768,-32768,
1096    999,    91,  4867,-32768,   674,-32768,  1467,-32768,  5324,-32768,
1097 -32768,-32768,   928,   923,  5000,-32768,   410,-32768,   723,-32768,
1098 -32768,-32768,-32768,-32768,-32768,   406,-32768,-32768,-32768,-32768,
1099 -32768,-32768,-32768,   731,-32768,   406,-32768,-32768,   477,-32768,
1100    243,   108,   485,-32768,   978,   979,  1893,-32768,-32768,  1893,
1101 -32768,-32768,   942,-32768,   948,   950,-32768,  1053,   128,-32768,
1102 -32768,-32768,-32768,-32768,   328,-32768,-32768,  1540,-32768,  1608,
1103 -32768,   961,  1827,-32768,   970,-32768,-32768,-32768,-32768,-32768,
1104 -32768,  2547,-32768,   262,  4403,  1827,-32768,-32768,  2612,-32768,
1105 -32768,-32768,-32768,  1071,-32768,-32768,-32768,   980,-32768,  1827,
1106    296,   202,-32768,   358,-32768,  4958,   983,-32768,-32768,-32768,
1107 -32768,   302,  1893,   990,  5000,-32768,  1021,  1893,   992,  1893,
1108 -32768,  1893,-32768,-32768,  1087,  1089,-32768
1109 };
1110
1111 static const short yypgoto[] = {-32768,
1112 -32768,   -57,   -60,   711,   -16,  -123,   568,-32768,    -3,   552,
1113 -32768,   130,-32768,  1085,   791,-32768,    22,-32768,-32768,   778,
1114     12,   154,-32768,-32768,  1044,  1030,-32768,  -128,-32768,   945,
1115 -32768,   382,  -106,   973,  -165,  -193,-32768,-32768,   469,   -58,
1116    865,  -327,   -40,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1117    957,-32768,   142,-32768,   718,   -10,-32768,-32768,-32768,-32768,
1118   1072,   584,-32768,  1031,-32768,-32768,   372,-32768,  -122,   867,
1119    843,  -166,  -279,-32768,   819,  -234,   197,  -551,-32768,  -529,
1120 -32768,-32768,-32768,  -301,-32768,-32768,-32768,-32768,-32768,-32768,
1121 -32768,-32768,   476,   486,  -619,  -496,-32768,-32768,-32768,-32768,
1122 -32768,-32768,-32768,  -436,-32768,  -603,   832,-32768,-32768,-32768,
1123 -32768,-32768,-32768,-32768,-32768,   569,-32768,   573,-32768,-32768,
1124    119,-32768,  -386,-32768,   799,   362,  -326,   858,   163,  1120,
1125    320,   437,   438,  -112,   560,   636,  -470,-32768,   632,   724,
1126    651,   625,   761,   765,   760,   764,   776,-32768,   526,   771,
1127    717,-32768,-32768,    29,-32768
1128 };
1129
1130
1131 #define YYLAST          5484
1132
1133
1134 static const short yytable[] = {    21,
1135    459,    84,    29,   176,    83,   450,   174,   438,   287,   357,
1136    184,    16,   614,   325,   650,    19,   152,   675,    26,   474,
1137     16,    16,    16,    38,   117,    59,   479,   481,    84,    67,
1138     31,   123,   342,    84,   134,   342,    83,   721,    61,   174,
1139     76,    16,    61,   497,    16,    16,   260,    59,   583,    48,
1140    612,    93,    59,   602,    31,    20,   363,    20,    88,   442,
1141     61,   725,    16,   150,   153,    61,   482,   445,    84,   446,
1142     62,    83,    84,    89,   347,   179,   143,   124,   135,   334,
1143    336,   338,   340,    93,   696,    88,   587,   349,   351,   608,
1144     88,   711,    55,   404,   405,   559,    56,   406,   721,    84,
1145     20,    84,   123,    20,    83,    89,   697,   651,   650,   249,
1146    676,    59,   251,   619,   280,   626,   619,    67,   173,    84,
1147    144,    39,   326,    40,    61,    88,   561,  -157,   743,    88,
1148     61,   262,   343,    25,    27,   343,   399,   345,    77,   700,
1149    160,   353,   680,   601,   180,   696,   604,    49,   696,    50,
1150    422,   173,   764,    17,   -94,   -94,    88,   137,    88,   483,
1151    457,   769,    17,    17,    17,    52,    54,   697,   245,    57,
1152    697,   281,   429,   160,   563,   125,    88,    20,   712,    57,
1153    258,   346,   576,    17,  -294,   588,    17,    17,   331,   331,
1154    331,   331,    84,   560,    61,   179,   331,   331,   354,   703,
1155    700,   734,   743,   700,    17,   461,    64,   619,   110,   669,
1156    146,   696,   113,   396,   186,    90,   696,   145,   696,   246,
1157    696,   744,    84,   611,   562,   434,   280,   619,   421,   642,
1158    355,   245,   411,   697,   425,   684,   556,   620,   697,   623,
1159    697,   670,   697,   649,    28,   692,   280,    90,   -97,    88,
1160    -97,   110,   113,   -97,   -97,   -97,   -97,   504,   506,   508,
1161    703,   709,   710,   703,   180,   432,   700,    84,   189,   482,
1162    179,   700,   564,   700,  -104,   700,   438,   389,  -104,    88,
1163    577,   360,   161,   281,   613,   361,   661,   602,   450,   362,
1164    441,   617,    50,   316,   410,   762,   742,   416,   441,   672,
1165    441,   619,   758,   447,   282,   428,  -322,   147,   189,   -25,
1166    -25,   187,    67,   706,   635,   161,   247,    20,   448,    20,
1167    598,   528,   157,   157,    88,    61,   703,   580,   745,    20,
1168    412,   703,   426,   703,   621,   703,   624,   317,   671,   180,
1169     45,   733,   280,   704,    74,   752,    69,   367,   637,   390,
1170    -25,   438,   433,   407,   118,   -25,   -25,   -25,   635,    41,
1171    753,   -25,   578,   450,   610,   -25,   331,   331,   331,   331,
1172    331,   331,   331,   331,   331,   331,   331,   331,    88,   331,
1173    331,   331,   331,   331,   331,   331,   631,    84,   101,   492,
1174    434,   -65,   417,   500,   761,   -65,   673,   413,  -322,   551,
1175    766,   694,    46,   119,   427,   316,    46,   636,   189,   462,
1176    726,   128,   316,   -30,     1,   746,   282,    53,   546,   419,
1177    316,    42,   316,   282,   423,   316,   137,   454,   475,   138,
1178    139,   282,   486,   282,   -65,   501,   558,  -256,   -65,   -66,
1179    438,   638,   -31,     1,    88,   408,   566,   643,   568,   317,
1180    646,   763,    71,  -158,   450,   189,   317,     2,   492,   250,
1181    139,   640,   442,   450,   317,   445,   317,   647,     3,   317,
1182    327,   133,   465,   331,     4,   463,   328,   647,   674,   331,
1183      5,   591,   -66,   593,   418,   407,     2,   679,   749,    58,
1184    652,    57,   280,   498,   318,   280,   685,   599,   487,   678,
1185    129,   755,    20,     4,   157,   653,   -28,     1,   492,     5,
1186    165,   420,     7,   245,    42,   760,   424,   -97,   133,   455,
1187    476,   316,   -97,   -97,   -97,   -97,   148,   502,   694,    66,
1188     98,   248,   282,   749,   102,   755,    78,   760,   120,   654,
1189    109,     7,    50,   165,   727,   196,  -160,   729,   112,   281,
1190      2,   197,   281,   641,  -139,   -29,     1,   731,   198,   648,
1191     57,     3,   199,   189,   149,   317,   252,     4,    80,   732,
1192    280,    81,    20,     5,    20,   200,   201,   735,   157,   202,
1193     84,     6,   397,   179,   -32,     1,   253,   151,   204,   205,
1194    206,   207,   458,   154,   208,   209,   280,   167,   257,     2,
1195    -34,     1,   -33,     1,   493,     7,   318,   177,   331,   331,
1196      3,   319,   320,   318,    20,    20,     4,   183,   188,    20,
1197    324,   318,     5,   318,   331,    20,   318,   281,     2,   157,
1198    167,    99,   441,    20,   118,     2,   103,    88,   359,     3,
1199    366,    78,   456,   134,     2,     4,     2,   682,   100,    20,
1200      2,     5,   180,   281,     7,   106,    78,   280,   594,   280,
1201    460,     4,   493,     4,   385,   595,   464,     5,   579,     5,
1202    494,   316,    20,    80,   316,   495,    81,    20,    20,   496,
1203    159,   714,   282,     7,   203,   282,   602,   722,    80,    20,
1204    131,    81,    20,   441,   630,   155,   441,   634,   549,     7,
1205    178,     7,    20,    20,   328,    20,   316,   344,   316,   -35,
1206      1,   159,   329,   159,   281,   317,   281,   484,   317,   441,
1207    652,   485,   318,   319,   320,    20,   689,    20,   494,   493,
1208    319,   320,   441,   495,   321,   653,   121,   496,   319,   320,
1209    319,   320,   618,   319,   320,    20,   441,    20,   619,   316,
1210    317,    20,   317,     2,   316,   341,    78,    35,    57,   441,
1211    282,  -497,  -497,   754,   441,   282,   441,   757,   441,   716,
1212      4,    35,   690,   359,    36,   316,     5,    78,   364,    35,
1213     37,  -341,  -341,   316,   140,    78,   282,    32,    80,   141,
1214    142,    81,    20,   317,   122,   494,    36,   686,   317,    30,
1215    495,    34,    37,   619,   496,  -498,  -498,    32,     7,    80,
1216    322,    32,    81,    20,    20,   316,   728,    80,   316,   317,
1217     81,    20,   619,    51,   730,   386,   282,   317,    32,   282,
1218    619,   600,   387,  -341,   600,   705,   316,  -341,   316,   319,
1219    320,   316,   365,   603,   569,   605,   321,   282,   570,   282,
1220   -343,  -343,   282,   321,   316,   378,   379,   380,   381,   317,
1221    388,   321,   317,   321,   527,   282,   321,   400,   316,   401,
1222    477,  -156,   318,   478,   316,   318,   435,   359,     2,   282,
1223    317,   316,   317,   316,    78,   317,   316,   439,   316,   469,
1224    316,   323,   282,   737,   382,   443,   738,   282,   317,   282,
1225    453,   282,  -343,   370,   371,   372,  -343,   318,   550,   318,
1226    368,   369,   317,    78,   139,    35,    80,   584,   317,    81,
1227     20,    78,   322,   373,   374,   317,   586,   317,   596,   322,
1228    317,   622,   317,   627,   317,   383,   384,   322,    37,   322,
1229    391,   392,   322,    78,   628,    80,  -407,  -407,    81,    20,
1230    318,   632,   196,    80,   633,   318,    81,    20,   197,   767,
1231   -408,  -408,   321,   639,   771,   198,   773,   649,   774,   199,
1232    659,  -496,  -496,   360,   665,    80,   318,   361,    81,    20,
1233    666,   362,   200,   201,   318,   667,   202,   141,   142,   319,
1234    320,   602,   319,   320,   156,   204,   205,   206,   207,   710,
1235     78,   208,   209,   323,   510,   512,     2,   531,   533,    79,
1236    323,     4,    78,   375,   376,   377,   318,     5,   323,   318,
1237    323,   723,   588,   323,   319,   320,   319,   320,   520,   522,
1238    524,   526,    80,   736,  -207,    81,    20,   318,   322,   318,
1239    739,   740,   318,   741,    80,   157,   158,    81,    20,   332,
1240    332,   332,   332,   742,   748,   318,   394,   332,   332,   -15,
1241    466,   467,   468,   750,  -496,  -496,   360,   319,   320,   318,
1242    430,   758,   319,   320,   431,   318,   770,   191,   759,   192,
1243    193,   765,   318,   768,   318,   772,   776,   318,   777,   318,
1244      2,   318,   529,   319,   320,    33,    78,    75,   514,   516,
1245    518,   319,   320,   -15,   108,    79,   256,     4,  -496,  -496,
1246    360,   190,   321,     5,   430,   321,   254,   395,   362,   323,
1247    554,   194,   195,    73,   127,   449,    78,   403,    80,   437,
1248    717,    81,    20,   319,   320,   196,   319,   320,   452,   644,
1249    718,   197,    82,   645,   473,   535,   539,   321,   198,   321,
1250    537,   541,   199,   688,   319,   320,   319,   320,    80,   319,
1251    320,    81,    20,   548,   543,   200,   201,     0,     0,   202,
1252      0,   203,   319,   320,     0,     0,     0,     0,   204,   205,
1253    206,   207,     0,     0,   208,   209,   319,   320,   322,     0,
1254    321,   322,   319,   320,     0,   321,     0,     0,     0,   319,
1255    320,   319,   320,     0,   319,   320,   319,   320,   319,   320,
1256      0,  -496,  -496,   360,     0,     0,   321,   480,     0,     0,
1257      0,   362,     0,   322,   321,   322,     0,   332,   332,   332,
1258    332,   332,   332,   332,   332,   332,   332,   332,   332,     0,
1259    332,   332,   332,   332,   332,   332,   332,   156,  -496,  -496,
1260    360,     0,     0,    78,   361,     0,   321,     0,   431,   321,
1261      0,     0,    79,     0,     4,     0,   322,     0,     0,   323,
1262      5,   322,   323,     0,     0,     0,     0,   321,     0,   321,
1263      0,     0,   321,     0,     0,    80,     0,     0,    81,    20,
1264      0,     0,   322,     0,     0,   321,     0,     0,   157,   255,
1265    322,     0,     0,     0,   323,     0,   323,     0,     0,   321,
1266      0,   333,   333,   333,   333,   321,     0,     0,     0,   333,
1267    333,     0,   321,     0,   321,     0,     0,   321,     0,   321,
1268      0,   321,   322,     0,   332,   322,     0,     0,     0,   -15,
1269    332,     0,     0,     0,  -496,  -496,   360,   323,     0,     0,
1270    430,     0,   323,   322,   629,   322,     0,   414,   322,   192,
1271    193,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1272      0,   322,     0,   323,     0,     0,     0,     0,     0,     0,
1273      0,   323,     0,     0,     0,   322,     0,     0,     0,     0,
1274      0,   322,     0,     0,     0,     0,     0,     0,   322,     0,
1275    322,   194,   195,   322,     0,   322,    78,   322,     0,     0,
1276      0,     0,     0,   323,     0,   196,   323,     0,     0,     0,
1277      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1278      0,     0,   199,     0,   323,     0,   323,     0,    80,   323,
1279      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1280      0,     0,   323,     0,     0,   415,     0,     0,   204,   205,
1281    206,   207,     0,     0,   208,   209,   323,   263,     0,   332,
1282    332,     0,   323,     0,     0,     0,     0,     0,     0,   323,
1283      0,   323,     0,     0,   323,   332,   323,     0,   323,   333,
1284    333,   333,   333,   333,   333,   333,   333,   333,   333,   333,
1285    333,     0,   333,   333,   333,   333,   333,   333,   333,     0,
1286    264,   194,   195,   652,   265,   266,    78,   267,     0,     0,
1287    268,     0,     0,     0,   269,   196,     0,     0,   653,     0,
1288      0,   270,   271,     5,   272,     0,   273,   274,   198,   275,
1289    263,     0,   276,     0,     0,     0,     0,     0,    80,     0,
1290      0,    81,    20,     0,     0,     0,     0,     0,     0,   277,
1291      0,   157,   719,     0,     0,   278,     0,     0,   204,   205,
1292    206,   207,     0,     0,   208,   209,     0,     0,     0,     0,
1293      0,     0,     0,   264,   194,   195,   652,   265,   266,    78,
1294    267,     0,     0,   268,     0,     0,   333,   269,   196,     0,
1295      0,   653,   333,     0,   270,   271,     5,   272,   263,   273,
1296    274,   198,   275,     0,     0,   276,     0,     0,     0,     0,
1297      0,    80,     0,     0,    81,    20,     0,     0,     0,     0,
1298      0,     0,   277,     0,   157,   747,     0,     0,   278,     0,
1299      0,   204,   205,   206,   207,     0,     0,   208,   209,     0,
1300      0,   264,   194,   195,  -266,   265,   266,    78,   267,     0,
1301      0,   268,     0,     0,     0,   269,   196,     0,     0,  -266,
1302      0,     0,   270,   271,     5,   272,     0,   273,   274,   198,
1303    275,     2,     0,   276,     0,     0,     0,    78,     0,    80,
1304      0,   263,    81,    20,     0,     0,    79,     0,     4,     0,
1305    277,     0,   157,  -266,     5,     0,   278,     0,     0,   204,
1306    205,   206,   207,     0,     0,   208,   209,     0,     0,    80,
1307      0,     0,    81,    20,     0,     0,     0,     0,     0,     0,
1308      0,   333,   333,   126,   264,   194,   195,     0,   265,   266,
1309     78,   267,     0,     0,   268,     0,     0,   333,   269,   196,
1310      0,     0,     0,     0,     0,   270,   271,     5,   272,   263,
1311    273,   274,   198,   275,     0,     0,   276,     0,     0,     0,
1312      0,     0,    80,     0,     0,    81,    20,     0,     0,     0,
1313      0,     0,     0,   277,     0,   157,   436,     0,     0,   278,
1314      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1315      0,     0,   264,   194,   195,     0,   265,   266,    78,   267,
1316      0,     0,   268,     0,     0,     0,   269,   196,     0,     0,
1317      0,     0,     0,   270,   271,     5,   272,   263,   273,   274,
1318    198,   275,     0,     0,   276,     0,     0,     0,     0,     0,
1319     80,     0,     0,    81,    20,     0,     0,     0,     0,     0,
1320      0,   277,     0,   157,     0,     0,     0,   278,     0,     0,
1321    204,   205,   206,   207,     0,     0,   208,   209,     0,     0,
1322    440,   194,   195,     0,   265,   266,    78,   267,     0,     0,
1323    268,     0,     0,     0,   269,   196,     0,     0,     0,     0,
1324      0,   270,   271,   263,   272,     0,   273,   274,   198,   275,
1325      0,     0,   276,     0,     0,     0,     0,     0,    80,     0,
1326      0,    81,    20,     0,     0,     0,     0,     0,     0,   277,
1327      0,   157,     0,     0,     0,   278,     0,     0,   204,   205,
1328    206,   207,     0,     0,   208,   209,   440,   194,   195,     0,
1329    693,   266,    78,   267,     0,     0,   268,     0,     0,     0,
1330    269,   196,     0,     0,     0,     0,     0,   270,   271,     0,
1331    272,     0,   273,   274,   198,   275,     0,   615,   276,   192,
1332    193,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1333      0,     0,     0,     0,     0,   277,     0,   157,     0,     0,
1334      0,   278,     0,     0,   204,   205,   206,   207,     0,     0,
1335    208,   209,     0,     0,     0,     0,     0,     0,     0,     0,
1336      0,   194,   195,     0,     0,     0,    78,     0,     0,     0,
1337      0,     0,     0,     0,     0,   196,     0,     0,     0,     0,
1338      0,   197,   544,     0,   192,   193,     0,     0,   198,     0,
1339      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1340      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1341      0,   203,   616,     0,     0,     0,     0,     0,   204,   205,
1342    206,   207,     0,     0,   208,   209,   194,   195,     0,     0,
1343      0,    78,     0,   491,     0,   192,   193,     0,     0,     0,
1344    196,     0,     0,     0,     0,     0,   197,     0,     0,     0,
1345      0,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1346      0,     0,     0,    80,     0,     0,    81,    20,     0,   545,
1347    200,   201,     0,     0,   202,     0,     0,   194,   195,     0,
1348      0,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1349    209,   196,     0,     0,     0,     0,     0,   197,   581,     0,
1350    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1351      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1352      0,   200,   201,     0,     0,   202,     0,     0,     0,     0,
1353    148,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1354    208,   209,   194,   195,     0,     0,     0,    78,     0,   589,
1355      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1356      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1357      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1358      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1359    202,   582,     0,   194,   195,     0,     0,     0,    78,   204,
1360    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1361      0,     0,     0,   197,   597,     0,   192,   193,     0,     0,
1362    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1363     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1364      0,   202,     0,     0,     0,     0,     0,   590,     0,     0,
1365    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1366      0,     0,     0,    78,     0,   606,     0,   192,   193,     0,
1367      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1368      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1369      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1370      0,     0,   200,   201,     0,     0,   202,     0,     0,   194,
1371    195,   598,     0,     0,    78,   204,   205,   206,   207,     0,
1372      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1373    491,     0,   192,   193,     0,     0,   198,     0,     0,     0,
1374    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1375     20,     0,     0,   200,   201,     0,     0,   202,   607,     0,
1376      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1377      0,     0,   208,   209,   194,   195,     0,     0,     0,    78,
1378      0,   581,     0,   192,   193,     0,     0,     0,   196,     0,
1379      0,     0,     0,     0,   197,     0,     0,     0,     0,     0,
1380      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1381      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1382      0,     0,   202,     0,     0,   194,   195,   598,     0,     0,
1383     78,   204,   205,   206,   207,     0,     0,   208,   209,   196,
1384      0,     0,     0,     0,     0,   197,   707,     0,   192,   193,
1385      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1386      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1387    201,     0,     0,   202,   691,     0,     0,     0,     0,     0,
1388      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1389    194,   195,     0,     0,     0,    78,     0,   707,     0,   192,
1390    193,     0,     0,     0,   196,     0,     0,     0,     0,     0,
1391    197,     0,     0,     0,     0,     0,     0,   198,     0,     0,
1392      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1393     81,    20,     0,     0,   200,   201,     0,     0,   202,   708,
1394      0,   194,   195,     0,     0,     0,    78,   204,   205,   206,
1395    207,     0,     0,   208,   209,   196,     0,     0,     0,     0,
1396      0,   197,   589,     0,   192,   193,     0,     0,   198,     0,
1397      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1398      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1399    751,     0,     0,     0,     0,     0,     0,     0,   204,   205,
1400    206,   207,     0,     0,   208,   209,   194,   195,     0,     0,
1401      0,    78,     0,   330,     0,   192,   193,     0,     0,     0,
1402    196,     0,     0,     0,     0,     0,   197,     0,     0,     0,
1403      0,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1404      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1405    200,   201,     0,     0,   202,     0,     0,   194,   195,     0,
1406    756,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1407    209,   196,     0,     0,     0,     0,     0,   197,   335,     0,
1408    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1409      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1410      0,   200,   201,     0,     0,   202,     0,     0,     0,     0,
1411      0,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1412    208,   209,   194,   195,     0,     0,     0,    78,     0,   337,
1413      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1414      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1415      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1416      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1417    202,     0,     0,   194,   195,     0,     0,     0,    78,   204,
1418    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1419      0,     0,     0,   197,   339,     0,   192,   193,     0,     0,
1420    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1421     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1422      0,   202,     0,     0,     0,     0,     0,     0,     0,     0,
1423    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1424      0,     0,     0,    78,     0,   348,     0,   192,   193,     0,
1425      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1426      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1427      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1428      0,     0,   200,   201,     0,     0,   202,     0,     0,   194,
1429    195,     0,     0,     0,    78,   204,   205,   206,   207,     0,
1430      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1431    350,     0,   192,   193,     0,     0,   198,     0,     0,     0,
1432    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1433     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1434      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1435      0,     0,   208,   209,   194,   195,     0,     0,     0,    78,
1436      0,   352,     0,   192,   193,     0,     0,     0,   196,     0,
1437      0,     0,     0,     0,   197,     0,     0,     0,     0,     0,
1438      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1439      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1440      0,     0,   202,     0,     0,   194,   195,     0,     0,     0,
1441     78,   204,   205,   206,   207,     0,     0,   208,   209,   196,
1442      0,     0,     0,     0,     0,   197,   409,     0,   192,   193,
1443      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1444      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1445    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1446      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1447    194,   195,     0,     0,     0,    78,     0,   491,     0,   192,
1448    193,     0,     0,     0,   196,     0,     0,     0,     0,     0,
1449    197,     0,     0,     0,     0,     0,     0,   198,     0,     0,
1450      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1451     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1452      0,   194,   195,     0,     0,     0,    78,   204,   205,   206,
1453    207,     0,     0,   208,   209,   196,     0,     0,     0,     0,
1454      0,   197,   499,     0,   192,   193,     0,     0,   198,     0,
1455      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1456      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1457      0,     0,     0,     0,     0,     0,     0,     0,   204,   205,
1458    206,   207,     0,     0,   208,   209,   194,   195,     0,     0,
1459      0,    78,     0,   503,     0,   192,   193,     0,     0,     0,
1460    196,     0,     0,     0,     0,     0,   197,     0,     0,     0,
1461      0,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1462      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1463    200,   201,     0,     0,   202,     0,     0,   194,   195,     0,
1464      0,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1465    209,   196,     0,     0,     0,     0,     0,   197,   505,     0,
1466    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1467      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1468      0,   200,   201,     0,     0,   202,     0,     0,     0,     0,
1469      0,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1470    208,   209,   194,   195,     0,     0,     0,    78,     0,   507,
1471      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1472      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1473      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1474      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1475    202,     0,     0,   194,   195,     0,     0,     0,    78,   204,
1476    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1477      0,     0,     0,   197,   509,     0,   192,   193,     0,     0,
1478    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1479     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1480      0,   202,     0,     0,     0,     0,     0,     0,     0,     0,
1481    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1482      0,     0,     0,    78,     0,   511,     0,   192,   193,     0,
1483      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1484      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1485      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1486      0,     0,   200,   201,     0,     0,   202,     0,     0,   194,
1487    195,     0,     0,     0,    78,   204,   205,   206,   207,     0,
1488      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1489    513,     0,   192,   193,     0,     0,   198,     0,     0,     0,
1490    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1491     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1492      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1493      0,     0,   208,   209,   194,   195,     0,     0,     0,    78,
1494      0,   515,     0,   192,   193,     0,     0,     0,   196,     0,
1495      0,     0,     0,     0,   197,     0,     0,     0,     0,     0,
1496      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1497      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1498      0,     0,   202,     0,     0,   194,   195,     0,     0,     0,
1499     78,   204,   205,   206,   207,     0,     0,   208,   209,   196,
1500      0,     0,     0,     0,     0,   197,   517,     0,   192,   193,
1501      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1502      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1503    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1504      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1505    194,   195,     0,     0,     0,    78,     0,   519,     0,   192,
1506    193,     0,     0,     0,   196,     0,     0,     0,     0,     0,
1507    197,     0,     0,     0,     0,     0,     0,   198,     0,     0,
1508      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1509     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1510      0,   194,   195,     0,     0,     0,    78,   204,   205,   206,
1511    207,     0,     0,   208,   209,   196,     0,     0,     0,     0,
1512      0,   197,   521,     0,   192,   193,     0,     0,   198,     0,
1513      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1514      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1515      0,     0,     0,     0,     0,     0,     0,     0,   204,   205,
1516    206,   207,     0,     0,   208,   209,   194,   195,     0,     0,
1517      0,    78,     0,   523,     0,   192,   193,     0,     0,     0,
1518    196,     0,     0,     0,     0,     0,   197,     0,     0,     0,
1519      0,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1520      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1521    200,   201,     0,     0,   202,     0,     0,   194,   195,     0,
1522      0,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1523    209,   196,     0,     0,     0,     0,     0,   197,   525,     0,
1524    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1525      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1526      0,   200,   201,     0,     0,   202,     0,     0,     0,     0,
1527      0,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1528    208,   209,   194,   195,     0,     0,     0,    78,     0,   530,
1529      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1530      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1531      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1532      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1533    202,     0,     0,   194,   195,     0,     0,     0,    78,   204,
1534    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1535      0,     0,     0,   197,   532,     0,   192,   193,     0,     0,
1536    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1537     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1538      0,   202,     0,     0,     0,     0,     0,     0,     0,     0,
1539    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1540      0,     0,     0,    78,     0,   534,     0,   192,   193,     0,
1541      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1542      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1543      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1544      0,     0,   200,   201,     0,     0,   202,     0,     0,   194,
1545    195,     0,     0,     0,    78,   204,   205,   206,   207,     0,
1546      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1547    536,     0,   192,   193,     0,     0,   198,     0,     0,     0,
1548    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1549     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1550      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1551      0,     0,   208,   209,   194,   195,     0,     0,     0,    78,
1552      0,   538,     0,   192,   193,     0,     0,     0,   196,     0,
1553      0,     0,     0,     0,   197,     0,     0,     0,     0,     0,
1554      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1555      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1556      0,     0,   202,     0,     0,   194,   195,     0,     0,     0,
1557     78,   204,   205,   206,   207,     0,     0,   208,   209,   196,
1558      0,     0,     0,     0,     0,   197,   540,     0,   192,   193,
1559      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1560      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1561    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1562      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1563    194,   195,     0,     0,     0,    78,     0,   542,     0,   192,
1564    193,     0,     0,     0,   196,     0,     0,     0,     0,     0,
1565    197,     0,     0,     0,     0,     0,     0,   198,     0,     0,
1566      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1567     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1568      0,   194,   195,     0,     0,     0,    78,   204,   205,   206,
1569    207,     0,     0,   208,   209,   196,     0,     0,     0,     0,
1570      0,   197,   547,     0,   192,   193,     0,     0,   198,     0,
1571      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1572      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1573      0,     0,     0,     0,     0,     0,     0,     0,   204,   205,
1574    206,   207,     0,     0,   208,   209,   194,   195,     0,     0,
1575      0,    78,     0,   557,     0,   192,   193,     0,     0,     0,
1576    196,     0,     0,     0,     0,     0,   197,     0,     0,     0,
1577      0,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1578      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1579    200,   201,     0,     0,   202,     0,     0,   194,   195,     0,
1580      0,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1581    209,   196,     0,     0,     0,     0,     0,   197,   565,     0,
1582    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1583      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1584      0,   200,   201,     0,     0,   202,     0,     0,     0,     0,
1585      0,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1586    208,   209,   194,   195,     0,     0,     0,    78,     0,   567,
1587      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1588      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1589      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1590      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1591    202,     0,     0,   194,   195,     0,     0,     0,    78,   204,
1592    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1593      0,     0,     0,   197,   592,     0,   192,   193,     0,     0,
1594    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1595     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1596      0,   202,     0,     0,     0,     0,     0,     0,     0,     0,
1597    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1598      0,     0,     0,    78,     0,   609,     0,   192,   193,     0,
1599      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1600      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1601      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1602      0,     0,   200,   201,     0,     0,   202,     0,     0,   194,
1603    195,     0,     0,     0,    78,   204,   205,   206,   207,     0,
1604      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1605    677,     0,   192,   193,     0,     0,   198,     0,     0,     0,
1606    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1607     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1608      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1609      0,     0,   208,   209,   194,   195,     0,     0,     0,    78,
1610      0,   681,     0,   192,   193,     0,     0,     0,   196,     0,
1611      0,     0,     0,     0,   197,     0,     0,     0,     0,     0,
1612      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1613      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1614      0,     0,   202,     0,     0,   194,   195,     0,     0,     0,
1615     78,   204,   205,   206,   207,     0,     0,   208,   209,   196,
1616      0,     0,     0,     0,     0,   197,   687,     0,   192,   193,
1617      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1618      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1619    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1620      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1621    194,   195,     0,     0,     0,    78,     0,   713,     0,   192,
1622    193,     0,     0,     0,   196,     0,     0,     0,     0,     0,
1623    197,     0,     0,     0,     0,     0,     0,   198,     0,     0,
1624      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1625     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1626      0,   194,   195,     0,     0,     0,    78,   204,   205,   206,
1627    207,     0,     0,   208,   209,   196,     0,     0,     0,     0,
1628      0,   197,     0,   575,     0,     0,     0,     0,   198,     0,
1629      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1630      0,    81,    20,     0,     0,   200,   201,     0,   662,   202,
1631      0,     0,     0,     0,     0,     0,     0,     0,   204,   205,
1632    206,   207,     0,     0,   208,   209,  -289,  -289,  -289,     0,
1633      0,     0,  -289,     0,     0,     0,     0,     0,     0,     0,
1634      0,  -289,     0,     0,     0,     0,     0,  -289,     0,     0,
1635    724,     0,   194,   195,  -289,     0,     0,    78,  -289,     0,
1636      0,     0,     0,     0,  -289,     0,   196,  -289,  -289,     0,
1637      0,     0,   197,     0,     0,  -289,     0,   192,   193,   198,
1638      0,  -289,     0,   199,  -289,  -289,  -289,  -289,     0,    80,
1639   -289,  -289,    81,    20,   194,   195,     0,     0,     0,    78,
1640    277,  -297,     0,     0,     0,     0,     0,     0,   196,   204,
1641    205,   206,   207,     0,   197,   208,   209,   660,     0,   194,
1642    195,   198,     0,     0,    78,   199,     0,     0,     0,     0,
1643      0,    80,     0,   196,    81,    20,     0,     0,     0,   197,
1644      0,     0,   277,  -297,   192,   193,   198,     0,     0,     0,
1645    199,   204,   205,   206,   207,     0,    80,   208,   209,    81,
1646     20,   194,   195,   200,   201,     0,    78,   202,     0,   203,
1647    356,     0,     0,     0,     0,   196,   204,   205,   206,   207,
1648      0,   197,   208,   209,     0,     0,   194,   195,   198,     0,
1649      0,    78,   199,     0,     0,   192,   193,     0,    80,     0,
1650    196,    81,    20,     0,     0,     0,   197,     0,     0,   277,
1651      0,     0,     0,   198,     0,     0,     0,   199,   204,   205,
1652    206,   207,     0,    80,   208,   209,    81,    20,     0,     0,
1653    200,   201,     0,     0,   202,   488,     0,   194,   195,     0,
1654      0,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1655    209,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1656    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1657      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1658      0,   200,   201,     0,     0,   202,   625,     0,     0,     0,
1659      0,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1660    208,   209,   194,   195,     0,     0,     0,    78,     0,     0,
1661      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1662      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1663      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1664      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1665    202,   668,     0,   194,   195,     0,     0,     0,    78,   204,
1666    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1667      0,     0,     0,   197,     0,     0,   192,   193,     0,     0,
1668    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1669     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1670      0,   202,   683,     0,     0,     0,     0,     0,     0,     0,
1671    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1672      0,     0,     0,    78,     0,     0,     0,     0,     0,     0,
1673      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1674      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1675      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1676      0,     0,   200,   201,     0,     0,   202,     0,     2,   194,
1677    195,     0,     0,     0,    78,   204,   205,   206,   207,     0,
1678      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1679      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1680    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1681     20,     0,     0,     0,     0,     0,     0,   277,     0,     0,
1682      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1683      0,     0,   208,   209
1684 };
1685
1686 static const short yycheck[] = {     3,
1687    328,    62,     6,   132,    62,   307,   129,   287,   175,   203,
1688    134,     0,   483,   179,     1,     1,   123,     1,     1,   346,
1689      9,    10,    11,     1,    83,    42,   353,   354,    89,    46,
1690      9,    89,     1,    94,    53,     1,    94,   657,    42,   162,
1691      1,    30,    46,    72,    33,    34,   169,    64,   435,     1,
1692     94,    62,    69,    97,    33,    86,     1,    86,    62,   294,
1693     64,   665,    51,   122,   123,    69,     1,   302,   129,   304,
1694     95,   129,   133,    62,   198,   133,   117,     1,    97,   192,
1695    193,   194,   195,    94,   636,    89,     1,   200,   201,   476,
1696     94,     1,     1,    95,    96,     1,     5,    99,   718,   160,
1697     86,   162,   160,    86,   162,    94,   636,    94,     1,   150,
1698     94,   128,   153,   100,   175,   502,   100,   134,   129,   180,
1699      1,    99,   180,   101,   128,   129,     1,    93,     1,   133,
1700    134,   172,   101,     4,     5,   101,   259,   198,    99,   636,
1701    129,   202,   613,   470,   133,   697,   473,    99,   700,   101,
1702    273,   162,   756,     0,    99,   100,   160,     1,   162,    94,
1703    326,   765,     9,    10,    11,    36,    37,   697,   140,    40,
1704    700,   175,   279,   162,     1,    99,   180,    86,    88,    50,
1705      1,   198,     1,    30,    99,   100,    33,    34,   192,   193,
1706    194,   195,   253,    99,   198,   253,   200,   201,   202,   636,
1707    697,    94,     1,   700,    51,   329,   100,   100,    79,   596,
1708      1,   763,    83,   254,     1,    62,   768,    98,   770,     1,
1709    772,    94,   283,     1,    99,   283,   287,   100,     1,     1,
1710    202,   203,     1,   763,     1,   622,   403,     1,   768,     1,
1711    770,     1,   772,     1,     1,   632,   307,    94,    92,   253,
1712     94,   122,   123,    97,    98,    99,   100,   370,   371,   372,
1713    697,   648,     1,   700,   253,     1,   763,   328,   139,     1,
1714    328,   768,    99,   770,    95,   772,   556,    15,    99,   283,
1715     99,    93,   129,   287,    94,    97,   588,    97,   590,   101,
1716    294,   485,   101,   175,   266,    94,     1,   269,   302,     1,
1717    304,   100,     1,   307,   175,   277,     1,    98,   179,    45,
1718     46,    98,   329,   641,     1,   162,    98,    86,   307,    86,
1719     98,   382,    95,    95,   328,   329,   763,   434,     1,    86,
1720     99,   768,    99,   770,    98,   772,    98,   175,    98,   328,
1721      1,    99,   403,     1,     1,   732,    52,   218,     1,    87,
1722     86,   631,    88,     1,    97,    91,    92,    93,     1,     1,
1723     99,    97,    94,   665,   477,   101,   370,   371,   372,   373,
1724    374,   375,   376,   377,   378,   379,   380,   381,   382,   383,
1725    384,   385,   386,   387,   388,   389,   553,   448,     1,   361,
1726    448,    52,     1,   365,    99,    52,    98,   268,    93,   403,
1727     99,   636,    63,    97,   275,   287,    63,    94,   279,     1,
1728      1,   100,   294,     0,     1,    88,   287,     1,   390,     1,
1729    302,    63,   304,   294,     1,   307,     1,     1,     1,    99,
1730    100,   302,     1,   304,    95,     1,   408,    95,    95,    52,
1731    720,    94,     0,     1,   448,    93,   418,   570,   420,   287,
1732    573,    94,     1,    95,   756,   326,   294,    44,   430,    99,
1733    100,     1,   697,   765,   302,   700,   304,     1,    55,   307,
1734     94,    93,   343,   477,    61,    67,   100,     1,   607,   483,
1735     67,   453,    95,   455,    93,     1,    44,     1,   723,     1,
1736     47,   362,   553,   364,   175,   556,   625,   469,    67,   612,
1737     95,   736,    86,    61,    95,    62,     0,     1,   480,    67,
1738    129,    93,    99,   485,    63,   750,    93,    92,    93,    93,
1739     93,   403,    97,    98,    99,   100,    98,    93,   763,     1,
1740      1,     1,   403,   768,     1,   770,    50,   772,    97,    96,
1741      1,    99,   101,   162,   667,    59,    95,   676,     1,   553,
1742     44,    65,   556,    93,    95,     0,     1,   686,    72,    93,
1743    431,    55,    76,   434,     1,   403,    96,    61,    82,    93,
1744    631,    85,    86,    67,    86,    89,    90,    93,    95,    93,
1745    641,    75,    99,   641,     0,     1,    93,     1,   102,   103,
1746    104,   105,     1,     1,   108,   109,   657,   129,    99,    44,
1747      0,     1,     0,     1,     1,    99,   287,     1,   612,   613,
1748     55,   175,   175,   294,    86,    86,    61,     1,     1,    86,
1749      1,   302,    67,   304,   628,    86,   307,   631,    44,    95,
1750    162,    64,   636,    86,    97,    44,    69,   641,   101,    55,
1751      1,    50,     1,    53,    44,    61,    44,   619,    65,    86,
1752     44,    67,   641,   657,    99,    72,    50,   718,    94,   720,
1753      1,    61,     1,    61,    11,   101,     1,    67,    65,    67,
1754     67,   553,    86,    82,   556,    72,    85,    86,    86,    76,
1755    129,   653,   553,    99,    95,   556,    97,   659,    82,    86,
1756    107,    85,    86,   697,   553,   128,   700,   556,    94,    99,
1757     94,    99,    86,    86,   100,    86,   588,     1,   590,     0,
1758      1,   160,   100,   162,   718,   553,   720,    96,   556,   723,
1759     47,   100,   403,   287,   287,    86,    65,    86,    67,     1,
1760    294,   294,   736,    72,   175,    62,     1,    76,   302,   302,
1761    304,   304,    94,   307,   307,    86,   750,    86,   100,   631,
1762    588,    86,   590,    44,   636,   101,    50,    44,   629,   763,
1763    631,    91,    92,   735,   768,   636,   770,   739,   772,    96,
1764     61,    44,   631,   101,    61,   657,    67,    50,   101,    44,
1765     67,    45,    46,   665,    92,    50,   657,    10,    82,    97,
1766     98,    85,    86,   631,    59,    67,    61,    94,   636,     9,
1767     72,    11,    67,   100,    76,    91,    92,    30,    99,    82,
1768    175,    34,    85,    86,    86,   697,    94,    82,   700,   657,
1769     85,    86,   100,    33,    94,    12,   697,   665,    51,   700,
1770    100,   470,    13,    97,   473,     1,   718,   101,   720,   403,
1771    403,   723,    97,   472,    60,   474,   287,   718,    64,   720,
1772     45,    46,   723,   294,   736,    18,    19,    20,    21,   697,
1773     14,   302,   700,   304,     1,   736,   307,    99,   750,    95,
1774     94,    93,   553,    97,   756,   556,    93,   101,    44,   750,
1775    718,   763,   720,   765,    50,   723,   768,    99,   770,    97,
1776    772,   175,   763,   697,    57,    99,   700,   768,   736,   770,
1777     99,   772,    97,     5,     6,     7,   101,   588,    99,   590,
1778     45,    46,   750,    50,   100,    44,    82,    95,   756,    85,
1779     86,    50,   287,     3,     4,   763,    66,   765,    93,   294,
1780    768,    93,   770,     1,   772,    16,    17,   302,    67,   304,
1781     91,    92,   307,    50,    88,    82,    45,    46,    85,    86,
1782    631,    93,    59,    82,    99,   636,    85,    86,    65,   763,
1783     45,    46,   403,    94,   768,    72,   770,     1,   772,    76,
1784     93,    91,    92,    93,    99,    82,   657,    97,    85,    86,
1785     94,   101,    89,    90,   665,    94,    93,    97,    98,   553,
1786    553,    97,   556,   556,    44,   102,   103,   104,   105,     1,
1787     50,   108,   109,   287,   373,   374,    44,   383,   384,    59,
1788    294,    61,    50,     8,     9,    10,   697,    67,   302,   700,
1789    304,    94,   100,   307,   588,   588,   590,   590,   378,   379,
1790    380,   381,    82,    56,    56,    85,    86,   718,   403,   720,
1791     99,    94,   723,    94,    82,    95,    96,    85,    86,   192,
1792    193,   194,   195,     1,    94,   736,    94,   200,   201,    86,
1793     97,    98,    99,    94,    91,    92,    93,   631,   631,   750,
1794     97,     1,   636,   636,   101,   756,    56,     1,    99,     3,
1795      4,    99,   763,    94,   765,    94,     0,   768,     0,   770,
1796     44,   772,   382,   657,   657,    11,    50,    54,   375,   376,
1797    377,   665,   665,    86,    75,    59,   162,    61,    91,    92,
1798     93,   139,   553,    67,    97,   556,   160,   253,   101,   403,
1799    403,    45,    46,    52,    94,   307,    50,   261,    82,   287,
1800    655,    85,    86,   697,   697,    59,   700,   700,   307,   571,
1801    655,    65,    96,   571,   346,   385,   387,   588,    72,   590,
1802    386,   388,    76,   628,   718,   718,   720,   720,    82,   723,
1803    723,    85,    86,   393,   389,    89,    90,    -1,    -1,    93,
1804     -1,    95,   736,   736,    -1,    -1,    -1,    -1,   102,   103,
1805    104,   105,    -1,    -1,   108,   109,   750,   750,   553,    -1,
1806    631,   556,   756,   756,    -1,   636,    -1,    -1,    -1,   763,
1807    763,   765,   765,    -1,   768,   768,   770,   770,   772,   772,
1808     -1,    91,    92,    93,    -1,    -1,   657,    97,    -1,    -1,
1809     -1,   101,    -1,   588,   665,   590,    -1,   370,   371,   372,
1810    373,   374,   375,   376,   377,   378,   379,   380,   381,    -1,
1811    383,   384,   385,   386,   387,   388,   389,    44,    91,    92,
1812     93,    -1,    -1,    50,    97,    -1,   697,    -1,   101,   700,
1813     -1,    -1,    59,    -1,    61,    -1,   631,    -1,    -1,   553,
1814     67,   636,   556,    -1,    -1,    -1,    -1,   718,    -1,   720,
1815     -1,    -1,   723,    -1,    -1,    82,    -1,    -1,    85,    86,
1816     -1,    -1,   657,    -1,    -1,   736,    -1,    -1,    95,    96,
1817    665,    -1,    -1,    -1,   588,    -1,   590,    -1,    -1,   750,
1818     -1,   192,   193,   194,   195,   756,    -1,    -1,    -1,   200,
1819    201,    -1,   763,    -1,   765,    -1,    -1,   768,    -1,   770,
1820     -1,   772,   697,    -1,   477,   700,    -1,    -1,    -1,    86,
1821    483,    -1,    -1,    -1,    91,    92,    93,   631,    -1,    -1,
1822     97,    -1,   636,   718,   101,   720,    -1,     1,   723,     3,
1823      4,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1824     -1,   736,    -1,   657,    -1,    -1,    -1,    -1,    -1,    -1,
1825     -1,   665,    -1,    -1,    -1,   750,    -1,    -1,    -1,    -1,
1826     -1,   756,    -1,    -1,    -1,    -1,    -1,    -1,   763,    -1,
1827    765,    45,    46,   768,    -1,   770,    50,   772,    -1,    -1,
1828     -1,    -1,    -1,   697,    -1,    59,   700,    -1,    -1,    -1,
1829     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
1830     -1,    -1,    76,    -1,   718,    -1,   720,    -1,    82,   723,
1831     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
1832     -1,    -1,   736,    -1,    -1,    99,    -1,    -1,   102,   103,
1833    104,   105,    -1,    -1,   108,   109,   750,     1,    -1,   612,
1834    613,    -1,   756,    -1,    -1,    -1,    -1,    -1,    -1,   763,
1835     -1,   765,    -1,    -1,   768,   628,   770,    -1,   772,   370,
1836    371,   372,   373,   374,   375,   376,   377,   378,   379,   380,
1837    381,    -1,   383,   384,   385,   386,   387,   388,   389,    -1,
1838     44,    45,    46,    47,    48,    49,    50,    51,    -1,    -1,
1839     54,    -1,    -1,    -1,    58,    59,    -1,    -1,    62,    -1,
1840     -1,    65,    66,    67,    68,    -1,    70,    71,    72,    73,
1841      1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
1842     -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    93,
1843     -1,    95,    96,    -1,    -1,    99,    -1,    -1,   102,   103,
1844    104,   105,    -1,    -1,   108,   109,    -1,    -1,    -1,    -1,
1845     -1,    -1,    -1,    44,    45,    46,    47,    48,    49,    50,
1846     51,    -1,    -1,    54,    -1,    -1,   477,    58,    59,    -1,
1847     -1,    62,   483,    -1,    65,    66,    67,    68,     1,    70,
1848     71,    72,    73,    -1,    -1,    76,    -1,    -1,    -1,    -1,
1849     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,
1850     -1,    -1,    93,    -1,    95,    96,    -1,    -1,    99,    -1,
1851     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    -1,
1852     -1,    44,    45,    46,    47,    48,    49,    50,    51,    -1,
1853     -1,    54,    -1,    -1,    -1,    58,    59,    -1,    -1,    62,
1854     -1,    -1,    65,    66,    67,    68,    -1,    70,    71,    72,
1855     73,    44,    -1,    76,    -1,    -1,    -1,    50,    -1,    82,
1856     -1,     1,    85,    86,    -1,    -1,    59,    -1,    61,    -1,
1857     93,    -1,    95,    96,    67,    -1,    99,    -1,    -1,   102,
1858    103,   104,   105,    -1,    -1,   108,   109,    -1,    -1,    82,
1859     -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,
1860     -1,   612,   613,    96,    44,    45,    46,    -1,    48,    49,
1861     50,    51,    -1,    -1,    54,    -1,    -1,   628,    58,    59,
1862     -1,    -1,    -1,    -1,    -1,    65,    66,    67,    68,     1,
1863     70,    71,    72,    73,    -1,    -1,    76,    -1,    -1,    -1,
1864     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,
1865     -1,    -1,    -1,    93,    -1,    95,    96,    -1,    -1,    99,
1866     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
1867     -1,    -1,    44,    45,    46,    -1,    48,    49,    50,    51,
1868     -1,    -1,    54,    -1,    -1,    -1,    58,    59,    -1,    -1,
1869     -1,    -1,    -1,    65,    66,    67,    68,     1,    70,    71,
1870     72,    73,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
1871     82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,
1872     -1,    93,    -1,    95,    -1,    -1,    -1,    99,    -1,    -1,
1873    102,   103,   104,   105,    -1,    -1,   108,   109,    -1,    -1,
1874     44,    45,    46,    -1,    48,    49,    50,    51,    -1,    -1,
1875     54,    -1,    -1,    -1,    58,    59,    -1,    -1,    -1,    -1,
1876     -1,    65,    66,     1,    68,    -1,    70,    71,    72,    73,
1877     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
1878     -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    93,
1879     -1,    95,    -1,    -1,    -1,    99,    -1,    -1,   102,   103,
1880    104,   105,    -1,    -1,   108,   109,    44,    45,    46,    -1,
1881     48,    49,    50,    51,    -1,    -1,    54,    -1,    -1,    -1,
1882     58,    59,    -1,    -1,    -1,    -1,    -1,    65,    66,    -1,
1883     68,    -1,    70,    71,    72,    73,    -1,     1,    76,     3,
1884      4,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
1885     -1,    -1,    -1,    -1,    -1,    93,    -1,    95,    -1,    -1,
1886     -1,    99,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
1887    108,   109,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1888     -1,    45,    46,    -1,    -1,    -1,    50,    -1,    -1,    -1,
1889     -1,    -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
1890     -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,
1891     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
1892     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
1893     -1,    95,    96,    -1,    -1,    -1,    -1,    -1,   102,   103,
1894    104,   105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,
1895     -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,
1896     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,
1897     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
1898     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    88,
1899     89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,
1900     -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
1901    109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,
1902      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
1903     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
1904     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,
1905     98,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
1906    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,
1907     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
1908     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
1909     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
1910     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
1911     93,    94,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
1912    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
1913     -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,
1914     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
1915     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
1916     -1,    93,    -1,    -1,    -1,    -1,    -1,    99,    -1,    -1,
1917    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
1918     -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,
1919     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
1920     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
1921     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
1922     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,
1923     46,    98,    -1,    -1,    50,   102,   103,   104,   105,    -1,
1924     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
1925      1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,
1926     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
1927     86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,    -1,
1928     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
1929     -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,
1930     -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,
1931     -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,
1932     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
1933     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
1934     -1,    -1,    93,    -1,    -1,    45,    46,    98,    -1,    -1,
1935     50,   102,   103,   104,   105,    -1,    -1,   108,   109,    59,
1936     -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,
1937     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
1938     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
1939     90,    -1,    -1,    93,    94,    -1,    -1,    -1,    -1,    -1,
1940     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
1941     45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,
1942      4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
1943     65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,
1944     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
1945     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,
1946     -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,   104,
1947    105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,
1948     -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,
1949     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
1950     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
1951     94,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,
1952    104,   105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,
1953     -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,
1954     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,
1955     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
1956     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
1957     89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,
1958     99,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
1959    109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,
1960      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
1961     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
1962     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,
1963     -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
1964    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,
1965     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
1966     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
1967     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
1968     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
1969     93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
1970    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
1971     -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,
1972     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
1973     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
1974     -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1975    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
1976     -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,
1977     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
1978     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
1979     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
1980     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,
1981     46,    -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,
1982     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
1983      1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,
1984     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
1985     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
1986     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
1987     -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,
1988     -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,
1989     -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,
1990     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
1991     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
1992     -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,
1993     50,   102,   103,   104,   105,    -1,    -1,   108,   109,    59,
1994     -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,
1995     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
1996     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
1997     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
1998     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
1999     45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,
2000      4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
2001     65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,
2002     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2003     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2004     -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,   104,
2005    105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,
2006     -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,
2007     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2008     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2009     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,
2010    104,   105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,
2011     -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,
2012     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,
2013     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2014     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2015     89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,
2016     -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
2017    109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,
2018      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2019     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2020     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,
2021     -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
2022    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,
2023     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
2024     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
2025     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2026     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2027     93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
2028    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
2029     -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,
2030     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2031     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2032     -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2033    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
2034     -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,
2035     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
2036     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
2037     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2038     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,
2039     46,    -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,
2040     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
2041      1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,
2042     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2043     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2044     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
2045     -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,
2046     -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,
2047     -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,
2048     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2049     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2050     -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,
2051     50,   102,   103,   104,   105,    -1,    -1,   108,   109,    59,
2052     -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,
2053     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2054     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2055     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
2056     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
2057     45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,
2058      4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
2059     65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,
2060     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2061     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2062     -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,   104,
2063    105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,
2064     -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,
2065     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2066     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2067     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,
2068    104,   105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,
2069     -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,
2070     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,
2071     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2072     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2073     89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,
2074     -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
2075    109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,
2076      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2077     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2078     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,
2079     -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
2080    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,
2081     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
2082     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
2083     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2084     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2085     93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
2086    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
2087     -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,
2088     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2089     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2090     -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2091    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
2092     -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,
2093     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
2094     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
2095     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2096     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,
2097     46,    -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,
2098     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
2099      1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,
2100     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2101     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2102     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
2103     -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,
2104     -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,
2105     -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,
2106     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2107     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2108     -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,
2109     50,   102,   103,   104,   105,    -1,    -1,   108,   109,    59,
2110     -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,
2111     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2112     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2113     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
2114     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
2115     45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,
2116      4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
2117     65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,
2118     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2119     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2120     -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,   104,
2121    105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,
2122     -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,
2123     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2124     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2125     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,
2126    104,   105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,
2127     -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,
2128     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,
2129     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2130     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2131     89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,
2132     -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
2133    109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,
2134      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2135     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2136     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,
2137     -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
2138    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,
2139     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
2140     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
2141     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2142     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2143     93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
2144    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
2145     -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,
2146     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2147     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2148     -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2149    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
2150     -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,
2151     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
2152     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
2153     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2154     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,
2155     46,    -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,
2156     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
2157      1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,
2158     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2159     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2160     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
2161     -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,
2162     -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,
2163     -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,
2164     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2165     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2166     -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,
2167     50,   102,   103,   104,   105,    -1,    -1,   108,   109,    59,
2168     -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,
2169     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2170     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2171     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
2172     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
2173     45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,
2174      4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
2175     65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,
2176     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2177     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2178     -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,   104,
2179    105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,
2180     -1,    65,    -1,     1,    -1,    -1,    -1,    -1,    72,    -1,
2181     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2182     -1,    85,    86,    -1,    -1,    89,    90,    -1,     1,    93,
2183     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,
2184    104,   105,    -1,    -1,   108,   109,    44,    45,    46,    -1,
2185     -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2186     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2187      1,    -1,    45,    46,    72,    -1,    -1,    50,    76,    -1,
2188     -1,    -1,    -1,    -1,    82,    -1,    59,    85,    86,    -1,
2189     -1,    -1,    65,    -1,    -1,    93,    -1,     3,     4,    72,
2190     -1,    99,    -1,    76,   102,   103,   104,   105,    -1,    82,
2191    108,   109,    85,    86,    45,    46,    -1,    -1,    -1,    50,
2192     93,    94,    -1,    -1,    -1,    -1,    -1,    -1,    59,   102,
2193    103,   104,   105,    -1,    65,   108,   109,     1,    -1,    45,
2194     46,    72,    -1,    -1,    50,    76,    -1,    -1,    -1,    -1,
2195     -1,    82,    -1,    59,    85,    86,    -1,    -1,    -1,    65,
2196     -1,    -1,    93,    94,     3,     4,    72,    -1,    -1,    -1,
2197     76,   102,   103,   104,   105,    -1,    82,   108,   109,    85,
2198     86,    45,    46,    89,    90,    -1,    50,    93,    -1,    95,
2199     96,    -1,    -1,    -1,    -1,    59,   102,   103,   104,   105,
2200     -1,    65,   108,   109,    -1,    -1,    45,    46,    72,    -1,
2201     -1,    50,    76,    -1,    -1,     3,     4,    -1,    82,    -1,
2202     59,    85,    86,    -1,    -1,    -1,    65,    -1,    -1,    93,
2203     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,   102,   103,
2204    104,   105,    -1,    82,   108,   109,    85,    86,    -1,    -1,
2205     89,    90,    -1,    -1,    93,    94,    -1,    45,    46,    -1,
2206     -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
2207    109,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2208      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2209     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2210     -1,    89,    90,    -1,    -1,    93,    94,    -1,    -1,    -1,
2211     -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
2212    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,    -1,
2213     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
2214     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
2215     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2216     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2217     93,    94,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
2218    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
2219     -1,    -1,    -1,    65,    -1,    -1,     3,     4,    -1,    -1,
2220     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2221     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2222     -1,    93,    94,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2223    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
2224     -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,
2225     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
2226     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
2227     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2228     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    44,    45,
2229     46,    -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,
2230     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
2231     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2232     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2233     86,    -1,    -1,    -1,    -1,    -1,    -1,    93,    -1,    -1,
2234     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
2235     -1,    -1,   108,   109
2236 };
2237 #define YYPURE 1
2238
2239 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
2240 #line 3 "/usr/share/misc/bison.simple"
2241
2242 /* Skeleton output parser for bison,
2243    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2244
2245    This program is free software; you can redistribute it and/or modify
2246    it under the terms of the GNU General Public License as published by
2247    the Free Software Foundation; either version 2, or (at your option)
2248    any later version.
2249
2250    This program is distributed in the hope that it will be useful,
2251    but WITHOUT ANY WARRANTY; without even the implied warranty of
2252    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2253    GNU General Public License for more details.
2254
2255    You should have received a copy of the GNU General Public License
2256    along with this program; if not, write to the Free Software
2257    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
2258
2259 /* As a special exception, when this file is copied by Bison into a
2260    Bison output file, you may use that output file without restriction.
2261    This special exception was added by the Free Software Foundation
2262    in version 1.24 of Bison.  */
2263
2264 #ifndef alloca
2265 #ifdef __GNUC__
2266 #define alloca __builtin_alloca
2267 #else /* not GNU C.  */
2268 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
2269 #include <alloca.h>
2270 #else /* not sparc */
2271 #if defined (MSDOS) && !defined (__TURBOC__)
2272 #include <malloc.h>
2273 #else /* not MSDOS, or __TURBOC__ */
2274 #if defined(_AIX)
2275 #include <malloc.h>
2276  #pragma alloca
2277 #else /* not MSDOS, __TURBOC__, or _AIX */
2278 #ifdef __hpux
2279 #ifdef __cplusplus
2280 extern "C" {
2281 void *alloca (unsigned int);
2282 };
2283 #else /* not __cplusplus */
2284 void *alloca ();
2285 #endif /* not __cplusplus */
2286 #endif /* __hpux */
2287 #endif /* not _AIX */
2288 #endif /* not MSDOS, or __TURBOC__ */
2289 #endif /* not sparc.  */
2290 #endif /* not GNU C.  */
2291 #endif /* alloca not defined.  */
2292
2293 /* This is the parser code that is written into each bison parser
2294   when the %semantic_parser declaration is not specified in the grammar.
2295   It was written by Richard Stallman by simplifying the hairy parser
2296   used when %semantic_parser is specified.  */
2297
2298 /* Note: there must be only one dollar sign in this file.
2299    It is replaced by the list of actions, each action
2300    as one case of the switch.  */
2301
2302 #define yyerrok         (yyerrstatus = 0)
2303 #define yyclearin       (yychar = YYEMPTY)
2304 #define YYEMPTY         -2
2305 #define YYEOF           0
2306 #define YYACCEPT        return(0)
2307 #define YYABORT         return(1)
2308 #define YYERROR         goto yyerrlab1
2309 /* Like YYERROR except do call yyerror.
2310    This remains here temporarily to ease the
2311    transition to the new meaning of YYERROR, for GCC.
2312    Once GCC version 2 has supplanted version 1, this can go.  */
2313 #define YYFAIL          goto yyerrlab
2314 #define YYRECOVERING()  (!!yyerrstatus)
2315 #define YYBACKUP(token, value) \
2316 do                                                              \
2317   if (yychar == YYEMPTY && yylen == 1)                          \
2318     { yychar = (token), yylval = (value);                       \
2319       yychar1 = YYTRANSLATE (yychar);                           \
2320       YYPOPSTACK;                                               \
2321       goto yybackup;                                            \
2322     }                                                           \
2323   else                                                          \
2324     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
2325 while (0)
2326
2327 #define YYTERROR        1
2328 #define YYERRCODE       256
2329
2330 #ifndef YYPURE
2331 #define YYLEX           yylex()
2332 #endif
2333
2334 #ifdef YYPURE
2335 #ifdef YYLSP_NEEDED
2336 #ifdef YYLEX_PARAM
2337 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
2338 #else
2339 #define YYLEX           yylex(&yylval, &yylloc)
2340 #endif
2341 #else /* not YYLSP_NEEDED */
2342 #ifdef YYLEX_PARAM
2343 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
2344 #else
2345 #define YYLEX           yylex(&yylval)
2346 #endif
2347 #endif /* not YYLSP_NEEDED */
2348 #endif
2349
2350 /* If nonreentrant, generate the variables here */
2351
2352 #ifndef YYPURE
2353
2354 int     yychar;                 /*  the lookahead symbol                */
2355 YYSTYPE yylval;                 /*  the semantic value of the           */
2356                                 /*  lookahead symbol                    */
2357
2358 #ifdef YYLSP_NEEDED
2359 YYLTYPE yylloc;                 /*  location data for the lookahead     */
2360                                 /*  symbol                              */
2361 #endif
2362
2363 int yynerrs;                    /*  number of parse errors so far       */
2364 #endif  /* not YYPURE */
2365
2366 #if YYDEBUG != 0
2367 int yydebug;                    /*  nonzero means print parse trace     */
2368 /* Since this is uninitialized, it does not stop multiple parsers
2369    from coexisting.  */
2370 #endif
2371
2372 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
2373
2374 #ifndef YYINITDEPTH
2375 #define YYINITDEPTH 200
2376 #endif
2377
2378 /*  YYMAXDEPTH is the maximum size the stacks can grow to
2379     (effective only if the built-in stack extension method is used).  */
2380
2381 #if YYMAXDEPTH == 0
2382 #undef YYMAXDEPTH
2383 #endif
2384
2385 #ifndef YYMAXDEPTH
2386 #define YYMAXDEPTH 10000
2387 #endif
2388
2389 /* Prevent warning if -Wstrict-prototypes.  */
2390 #ifdef __GNUC__
2391 #ifndef YYPARSE_PARAM
2392 int yyparse (void);
2393 #endif
2394 #endif
2395 \f
2396 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
2397 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
2398 #else                           /* not GNU C or C++ */
2399 #ifndef __cplusplus
2400
2401 /* This is the most reliable way to avoid incompatibilities
2402    in available built-in functions on various systems.  */
2403 static void
2404 __yy_memcpy (to, from, count)
2405      char *to;
2406      char *from;
2407      int count;
2408 {
2409   register char *f = from;
2410   register char *t = to;
2411   register int i = count;
2412
2413   while (i-- > 0)
2414     *t++ = *f++;
2415 }
2416
2417 #else /* __cplusplus */
2418
2419 /* This is the most reliable way to avoid incompatibilities
2420    in available built-in functions on various systems.  */
2421 static void
2422 __yy_memcpy (char *to, char *from, int count)
2423 {
2424   register char *f = from;
2425   register char *t = to;
2426   register int i = count;
2427
2428   while (i-- > 0)
2429     *t++ = *f++;
2430 }
2431
2432 #endif
2433 #endif
2434 \f
2435 #line 196 "/usr/share/misc/bison.simple"
2436
2437 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2438    into yyparse.  The argument should have type void *.
2439    It should actually point to an object.
2440    Grammar actions can access the variable by casting it
2441    to the proper pointer type.  */
2442
2443 #ifdef YYPARSE_PARAM
2444 #ifdef __cplusplus
2445 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2446 #define YYPARSE_PARAM_DECL
2447 #else /* not __cplusplus */
2448 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2449 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2450 #endif /* not __cplusplus */
2451 #else /* not YYPARSE_PARAM */
2452 #define YYPARSE_PARAM_ARG
2453 #define YYPARSE_PARAM_DECL
2454 #endif /* not YYPARSE_PARAM */
2455
2456 int
2457 yyparse(YYPARSE_PARAM_ARG)
2458      YYPARSE_PARAM_DECL
2459 {
2460   register int yystate;
2461   register int yyn;
2462   register short *yyssp;
2463   register YYSTYPE *yyvsp;
2464   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
2465   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
2466
2467   short yyssa[YYINITDEPTH];     /*  the state stack                     */
2468   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
2469
2470   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
2471   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
2472
2473 #ifdef YYLSP_NEEDED
2474   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
2475   YYLTYPE *yyls = yylsa;
2476   YYLTYPE *yylsp;
2477
2478 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
2479 #else
2480 #define YYPOPSTACK   (yyvsp--, yyssp--)
2481 #endif
2482
2483   int yystacksize = YYINITDEPTH;
2484
2485 #ifdef YYPURE
2486   int yychar;
2487   YYSTYPE yylval;
2488   int yynerrs;
2489 #ifdef YYLSP_NEEDED
2490   YYLTYPE yylloc;
2491 #endif
2492 #endif
2493
2494   YYSTYPE yyval;                /*  the variable used to return         */
2495                                 /*  semantic values from the action     */
2496                                 /*  routines                            */
2497
2498   int yylen;
2499
2500 #if YYDEBUG != 0
2501   if (yydebug)
2502     fprintf(stderr, "Starting parse\n");
2503 #endif
2504
2505   yystate = 0;
2506   yyerrstatus = 0;
2507   yynerrs = 0;
2508   yychar = YYEMPTY;             /* Cause a token to be read.  */
2509
2510   /* Initialize stack pointers.
2511      Waste one element of value and location stack
2512      so that they stay on the same level as the state stack.
2513      The wasted elements are never initialized.  */
2514
2515   yyssp = yyss - 1;
2516   yyvsp = yyvs;
2517 #ifdef YYLSP_NEEDED
2518   yylsp = yyls;
2519 #endif
2520
2521 /* Push a new state, which is found in  yystate  .  */
2522 /* In all cases, when you get here, the value and location stacks
2523    have just been pushed. so pushing a state here evens the stacks.  */
2524 yynewstate:
2525
2526   *++yyssp = yystate;
2527
2528   if (yyssp >= yyss + yystacksize - 1)
2529     {
2530       /* Give user a chance to reallocate the stack */
2531       /* Use copies of these so that the &'s don't force the real ones into memory. */
2532       YYSTYPE *yyvs1 = yyvs;
2533       short *yyss1 = yyss;
2534 #ifdef YYLSP_NEEDED
2535       YYLTYPE *yyls1 = yyls;
2536 #endif
2537
2538       /* Get the current used size of the three stacks, in elements.  */
2539       int size = yyssp - yyss + 1;
2540
2541 #ifdef yyoverflow
2542       /* Each stack pointer address is followed by the size of
2543          the data in use in that stack, in bytes.  */
2544 #ifdef YYLSP_NEEDED
2545       /* This used to be a conditional around just the two extra args,
2546          but that might be undefined if yyoverflow is a macro.  */
2547       yyoverflow("parser stack overflow",
2548                  &yyss1, size * sizeof (*yyssp),
2549                  &yyvs1, size * sizeof (*yyvsp),
2550                  &yyls1, size * sizeof (*yylsp),
2551                  &yystacksize);
2552 #else
2553       yyoverflow("parser stack overflow",
2554                  &yyss1, size * sizeof (*yyssp),
2555                  &yyvs1, size * sizeof (*yyvsp),
2556                  &yystacksize);
2557 #endif
2558
2559       yyss = yyss1; yyvs = yyvs1;
2560 #ifdef YYLSP_NEEDED
2561       yyls = yyls1;
2562 #endif
2563 #else /* no yyoverflow */
2564       /* Extend the stack our own way.  */
2565       if (yystacksize >= YYMAXDEPTH)
2566         {
2567           yyerror("parser stack overflow");
2568           return 2;
2569         }
2570       yystacksize *= 2;
2571       if (yystacksize > YYMAXDEPTH)
2572         yystacksize = YYMAXDEPTH;
2573       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
2574       __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
2575       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
2576       __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
2577 #ifdef YYLSP_NEEDED
2578       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
2579       __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
2580 #endif
2581 #endif /* no yyoverflow */
2582
2583       yyssp = yyss + size - 1;
2584       yyvsp = yyvs + size - 1;
2585 #ifdef YYLSP_NEEDED
2586       yylsp = yyls + size - 1;
2587 #endif
2588
2589 #if YYDEBUG != 0
2590       if (yydebug)
2591         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2592 #endif
2593
2594       if (yyssp >= yyss + yystacksize - 1)
2595         YYABORT;
2596     }
2597
2598 #if YYDEBUG != 0
2599   if (yydebug)
2600     fprintf(stderr, "Entering state %d\n", yystate);
2601 #endif
2602
2603   goto yybackup;
2604  yybackup:
2605
2606 /* Do appropriate processing given the current state.  */
2607 /* Read a lookahead token if we need one and don't already have one.  */
2608 /* yyresume: */
2609
2610   /* First try to decide what to do without reference to lookahead token.  */
2611
2612   yyn = yypact[yystate];
2613   if (yyn == YYFLAG)
2614     goto yydefault;
2615
2616   /* Not known => get a lookahead token if don't already have one.  */
2617
2618   /* yychar is either YYEMPTY or YYEOF
2619      or a valid token in external form.  */
2620
2621   if (yychar == YYEMPTY)
2622     {
2623 #if YYDEBUG != 0
2624       if (yydebug)
2625         fprintf(stderr, "Reading a token: ");
2626 #endif
2627       yychar = YYLEX;
2628     }
2629
2630   /* Convert token to internal form (in yychar1) for indexing tables with */
2631
2632   if (yychar <= 0)              /* This means end of input. */
2633     {
2634       yychar1 = 0;
2635       yychar = YYEOF;           /* Don't call YYLEX any more */
2636
2637 #if YYDEBUG != 0
2638       if (yydebug)
2639         fprintf(stderr, "Now at end of input.\n");
2640 #endif
2641     }
2642   else
2643     {
2644       yychar1 = YYTRANSLATE(yychar);
2645
2646 #if YYDEBUG != 0
2647       if (yydebug)
2648         {
2649           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2650           /* Give the individual parser a way to print the precise meaning
2651              of a token, for further debugging info.  */
2652 #ifdef YYPRINT
2653           YYPRINT (stderr, yychar, yylval);
2654 #endif
2655           fprintf (stderr, ")\n");
2656         }
2657 #endif
2658     }
2659
2660   yyn += yychar1;
2661   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2662     goto yydefault;
2663
2664   yyn = yytable[yyn];
2665
2666   /* yyn is what to do for this token type in this state.
2667      Negative => reduce, -yyn is rule number.
2668      Positive => shift, yyn is new state.
2669        New state is final state => don't bother to shift,
2670        just return success.
2671      0, or most negative number => error.  */
2672
2673   if (yyn < 0)
2674     {
2675       if (yyn == YYFLAG)
2676         goto yyerrlab;
2677       yyn = -yyn;
2678       goto yyreduce;
2679     }
2680   else if (yyn == 0)
2681     goto yyerrlab;
2682
2683   if (yyn == YYFINAL)
2684     YYACCEPT;
2685
2686   /* Shift the lookahead token.  */
2687
2688 #if YYDEBUG != 0
2689   if (yydebug)
2690     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2691 #endif
2692
2693   /* Discard the token being shifted unless it is eof.  */
2694   if (yychar != YYEOF)
2695     yychar = YYEMPTY;
2696
2697   *++yyvsp = yylval;
2698 #ifdef YYLSP_NEEDED
2699   *++yylsp = yylloc;
2700 #endif
2701
2702   /* count tokens shifted since error; after three, turn off error status.  */
2703   if (yyerrstatus) yyerrstatus--;
2704
2705   yystate = yyn;
2706   goto yynewstate;
2707
2708 /* Do the default action for the current state.  */
2709 yydefault:
2710
2711   yyn = yydefact[yystate];
2712   if (yyn == 0)
2713     goto yyerrlab;
2714
2715 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
2716 yyreduce:
2717   yylen = yyr2[yyn];
2718   if (yylen > 0)
2719     yyval = yyvsp[1-yylen]; /* implement default value of the action */
2720
2721 #if YYDEBUG != 0
2722   if (yydebug)
2723     {
2724       int i;
2725
2726       fprintf (stderr, "Reducing via rule %d (line %d), ",
2727                yyn, yyrline[yyn]);
2728
2729       /* Print the symbols being reduced, and their result.  */
2730       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2731         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2732       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2733     }
2734 #endif
2735
2736
2737   switch (yyn) {
2738
2739 case 1:
2740 #line 485 "./parse.y"
2741 {;
2742     break;}
2743 case 18:
2744 #line 529 "./parse.y"
2745
2746                   yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2747                   CLASS_LOADED_P (yyval.node) = 1;
2748                 ;
2749     break;}
2750 case 19:
2751 #line 534 "./parse.y"
2752 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2753     break;}
2754 case 20:
2755 #line 536 "./parse.y"
2756 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2757     break;}
2758 case 21:
2759 #line 538 "./parse.y"
2760 {RULE ("']' expected"); RECOVER;;
2761     break;}
2762 case 22:
2763 #line 540 "./parse.y"
2764 {RULE ("']' expected"); RECOVER;;
2765     break;}
2766 case 26:
2767 #line 555 "./parse.y"
2768 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2769     break;}
2770 case 28:
2771 #line 564 "./parse.y"
2772 {yyval.node = NULL;;
2773     break;}
2774 case 36:
2775 #line 576 "./parse.y"
2776 {
2777                   yyval.node = NULL;
2778                 ;
2779     break;}
2780 case 37:
2781 #line 580 "./parse.y"
2782 {
2783                   yyval.node = NULL;
2784                 ;
2785     break;}
2786 case 40:
2787 #line 592 "./parse.y"
2788 { ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node); ;
2789     break;}
2790 case 41:
2791 #line 594 "./parse.y"
2792 {yyerror ("Missing name"); RECOVER;;
2793     break;}
2794 case 42:
2795 #line 596 "./parse.y"
2796 {yyerror ("';' expected"); RECOVER;;
2797     break;}
2798 case 45:
2799 #line 606 "./parse.y"
2800 {
2801                   tree name = EXPR_WFL_NODE (yyvsp[-1].node), node, last_name;
2802                   int   i = IDENTIFIER_LENGTH (name)-1;
2803                   const char *last = &IDENTIFIER_POINTER (name)[i];
2804                   while (last != IDENTIFIER_POINTER (name))
2805                     {
2806                       if (last [0] == '.')
2807                         break;
2808                       last--;
2809                     }
2810                   last_name = get_identifier (++last);
2811                   if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
2812                     {
2813                       tree err = find_name_in_single_imports (last_name);
2814                       if (err && err != name)
2815                         parse_error_context
2816                           (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
2817                            IDENTIFIER_POINTER (name), 
2818                            IDENTIFIER_POINTER (err));
2819                       else
2820                         REGISTER_IMPORT (yyvsp[-1].node, last_name)
2821                     }
2822                   else
2823                     REGISTER_IMPORT (yyvsp[-1].node, last_name);
2824                 ;
2825     break;}
2826 case 46:
2827 #line 632 "./parse.y"
2828 {yyerror ("Missing name"); RECOVER;;
2829     break;}
2830 case 47:
2831 #line 634 "./parse.y"
2832 {yyerror ("';' expected"); RECOVER;;
2833     break;}
2834 case 48:
2835 #line 639 "./parse.y"
2836 {
2837                   tree name = EXPR_WFL_NODE (yyvsp[-3].node);
2838                   /* Don't import java.lang.* twice. */
2839                   if (name != java_lang_id)
2840                     {
2841                       tree node = build_tree_list (yyvsp[-3].node, NULL_TREE);
2842                       read_import_dir (yyvsp[-3].node);
2843                       TREE_CHAIN (node) = ctxp->import_demand_list;
2844                       ctxp->import_demand_list = node;
2845                     }
2846                 ;
2847     break;}
2848 case 49:
2849 #line 651 "./parse.y"
2850 {yyerror ("'*' expected"); RECOVER;;
2851     break;}
2852 case 50:
2853 #line 653 "./parse.y"
2854 {yyerror ("';' expected"); RECOVER;;
2855     break;}
2856 case 51:
2857 #line 658 "./parse.y"
2858 {
2859                   maybe_generate_finit ();
2860                   maybe_generate_clinit ();
2861                   yyval.node = yyvsp[0].node;
2862                 ;
2863     break;}
2864 case 52:
2865 #line 664 "./parse.y"
2866 {
2867                   maybe_generate_clinit ();
2868                   yyval.node = yyvsp[0].node;
2869                 ;
2870     break;}
2871 case 53:
2872 #line 669 "./parse.y"
2873 { yyval.node = NULL; ;
2874     break;}
2875 case 54:
2876 #line 671 "./parse.y"
2877 {
2878                   YYERROR_NOW;
2879                   yyerror ("Class or interface declaration expected");
2880                 ;
2881     break;}
2882 case 55:
2883 #line 682 "./parse.y"
2884 {
2885                   yyval.value = (1 << yyvsp[0].value);
2886                 ;
2887     break;}
2888 case 56:
2889 #line 686 "./parse.y"
2890 {
2891                   int acc = (1 << yyvsp[0].value);
2892                   if (yyval.value & acc)
2893                     parse_error_context 
2894                       (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
2895                        java_accstring_lookup (acc));
2896                   else
2897                     {
2898                       yyval.value |= acc;
2899                     }
2900                 ;
2901     break;}
2902 case 57:
2903 #line 702 "./parse.y"
2904 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
2905     break;}
2906 case 58:
2907 #line 704 "./parse.y"
2908
2909                   yyval.node = yyvsp[0].node;
2910                 ;
2911     break;}
2912 case 59:
2913 #line 708 "./parse.y"
2914 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
2915     break;}
2916 case 60:
2917 #line 710 "./parse.y"
2918 {       
2919                   yyval.node = yyvsp[0].node;
2920                 ;
2921     break;}
2922 case 61:
2923 #line 714 "./parse.y"
2924 {yyerror ("Missing class name"); RECOVER;;
2925     break;}
2926 case 62:
2927 #line 716 "./parse.y"
2928 {yyerror ("Missing class name"); RECOVER;;
2929     break;}
2930 case 63:
2931 #line 718 "./parse.y"
2932 {
2933                   if (!ctxp->class_err) yyerror ("'{' expected"); 
2934                   DRECOVER(class1);
2935                 ;
2936     break;}
2937 case 64:
2938 #line 723 "./parse.y"
2939 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
2940     break;}
2941 case 65:
2942 #line 727 "./parse.y"
2943 { yyval.node = NULL; ;
2944     break;}
2945 case 66:
2946 #line 729 "./parse.y"
2947 { yyval.node = yyvsp[0].node; ;
2948     break;}
2949 case 67:
2950 #line 731 "./parse.y"
2951 {yyerror ("'{' expected"); ctxp->class_err=1;;
2952     break;}
2953 case 68:
2954 #line 733 "./parse.y"
2955 {yyerror ("Missing super class name"); ctxp->class_err=1;;
2956     break;}
2957 case 69:
2958 #line 737 "./parse.y"
2959 { yyval.node = NULL_TREE; ;
2960     break;}
2961 case 70:
2962 #line 739 "./parse.y"
2963 { yyval.node = yyvsp[0].node; ;
2964     break;}
2965 case 71:
2966 #line 741 "./parse.y"
2967 {
2968                   ctxp->class_err=1;
2969                   yyerror ("Missing interface name"); 
2970                 ;
2971     break;}
2972 case 72:
2973 #line 749 "./parse.y"
2974
2975                   ctxp->interface_number = 1;
2976                   yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
2977                 ;
2978     break;}
2979 case 73:
2980 #line 754 "./parse.y"
2981
2982                   ctxp->interface_number++;
2983                   yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
2984                 ;
2985     break;}
2986 case 74:
2987 #line 759 "./parse.y"
2988 {yyerror ("Missing interface name"); RECOVER;;
2989     break;}
2990 case 75:
2991 #line 764 "./parse.y"
2992
2993                   /* Store the location of the `}' when doing xrefs */
2994                   if (flag_emit_xref)
2995                     DECL_END_SOURCE_LINE (ctxp->current_parsed_class) = 
2996                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
2997                   yyval.node = ctxp->current_parsed_class;
2998                 ;
2999     break;}
3000 case 76:
3001 #line 772 "./parse.y"
3002
3003                   /* Store the location of the `}' when doing xrefs */
3004                   if (flag_emit_xref)
3005                     DECL_END_SOURCE_LINE (ctxp->current_parsed_class) = 
3006                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3007                   yyval.node = ctxp->current_parsed_class;
3008                 ;
3009     break;}
3010 case 82:
3011 #line 791 "./parse.y"
3012 { yyval.node = parse_jdk1_1_error ("instance initializer"); ;
3013     break;}
3014 case 84:
3015 #line 797 "./parse.y"
3016 { yyval.node = yyvsp[-1].node; ;
3017     break;}
3018 case 86:
3019 #line 800 "./parse.y"
3020 { yyval.node = parse_jdk1_1_error ("inner classe declaration"); ;
3021     break;}
3022 case 87:
3023 #line 802 "./parse.y"
3024 { yyval.node = parse_jdk1_1_error ("inner interface declaration"); ;
3025     break;}
3026 case 88:
3027 #line 808 "./parse.y"
3028 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3029     break;}
3030 case 89:
3031 #line 810 "./parse.y"
3032 {
3033                   check_modifiers 
3034                     ("Illegal modifier `%s' for field declaration",
3035                      yyvsp[-3].value, FIELD_MODIFIERS);
3036                   check_modifiers_consistency (yyvsp[-3].value);
3037                   register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3038                 ;
3039     break;}
3040 case 91:
3041 #line 823 "./parse.y"
3042 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3043     break;}
3044 case 92:
3045 #line 825 "./parse.y"
3046 {yyerror ("Missing term"); RECOVER;;
3047     break;}
3048 case 93:
3049 #line 830 "./parse.y"
3050 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3051     break;}
3052 case 94:
3053 #line 832 "./parse.y"
3054
3055                   if (java_error_count)
3056                     yyvsp[0].node = NULL_TREE;
3057                   yyval.node = build_tree_list 
3058                     (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3059                 ;
3060     break;}
3061 case 95:
3062 #line 839 "./parse.y"
3063 {
3064                   yyerror ("Missing variable initializer");
3065                   yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3066                   RECOVER;
3067                 ;
3068     break;}
3069 case 96:
3070 #line 845 "./parse.y"
3071 {
3072                   yyerror ("';' expected");
3073                   yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3074                   RECOVER;
3075                 ;
3076     break;}
3077 case 98:
3078 #line 855 "./parse.y"
3079 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3080     break;}
3081 case 99:
3082 #line 857 "./parse.y"
3083 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3084     break;}
3085 case 100:
3086 #line 859 "./parse.y"
3087 {yyerror ("']' expected"); DRECOVER(vdi);;
3088     break;}
3089 case 101:
3090 #line 861 "./parse.y"
3091 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3092     break;}
3093 case 104:
3094 #line 872 "./parse.y"
3095 {
3096                   current_function_decl = yyvsp[0].node;
3097                   source_start_java_method (current_function_decl);
3098                 ;
3099     break;}
3100 case 105:
3101 #line 877 "./parse.y"
3102 { finish_method_declaration (yyvsp[0].node); ;
3103     break;}
3104 case 106:
3105 #line 879 "./parse.y"
3106 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3107     break;}
3108 case 107:
3109 #line 884 "./parse.y"
3110 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3111     break;}
3112 case 108:
3113 #line 886 "./parse.y"
3114 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3115     break;}
3116 case 109:
3117 #line 888 "./parse.y"
3118 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3119     break;}
3120 case 110:
3121 #line 890 "./parse.y"
3122 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3123     break;}
3124 case 111:
3125 #line 892 "./parse.y"
3126 {RECOVER;;
3127     break;}
3128 case 112:
3129 #line 894 "./parse.y"
3130 {RECOVER;;
3131     break;}
3132 case 113:
3133 #line 896 "./parse.y"
3134 {yyerror ("Identifier expected"); RECOVER;;
3135     break;}
3136 case 114:
3137 #line 898 "./parse.y"
3138 {yyerror ("Identifier expected"); RECOVER;;
3139     break;}
3140 case 115:
3141 #line 900 "./parse.y"
3142 {
3143                   yyerror ("Invalid method declaration, return type required");
3144                   RECOVER;
3145                 ;
3146     break;}
3147 case 116:
3148 #line 908 "./parse.y"
3149 { yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE); ;
3150     break;}
3151 case 117:
3152 #line 910 "./parse.y"
3153 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3154     break;}
3155 case 118:
3156 #line 912 "./parse.y"
3157 {
3158                   EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3159                   TREE_PURPOSE (yyvsp[-2].node) = 
3160                     build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3161                   parse_warning_context 
3162                     (wfl_operator, 
3163                      "Discouraged form of returned type specification");
3164                 ;
3165     break;}
3166 case 119:
3167 #line 921 "./parse.y"
3168 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3169     break;}
3170 case 120:
3171 #line 923 "./parse.y"
3172 {yyerror ("']' expected"); RECOVER;;
3173     break;}
3174 case 121:
3175 #line 928 "./parse.y"
3176 {
3177                   ctxp->formal_parameter_number = 1;
3178                 ;
3179     break;}
3180 case 122:
3181 #line 932 "./parse.y"
3182 {
3183                   ctxp->formal_parameter_number += 1;
3184                   yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3185                 ;
3186     break;}
3187 case 123:
3188 #line 937 "./parse.y"
3189 {yyerror ("Missing formal parameter term"); RECOVER;;
3190     break;}
3191 case 124:
3192 #line 942 "./parse.y"
3193 {
3194                   yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3195                 ;
3196     break;}
3197 case 125:
3198 #line 946 "./parse.y"
3199
3200                   parse_jdk1_1_error ("final parameters");
3201                   yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3202                 ;
3203     break;}
3204 case 126:
3205 #line 951 "./parse.y"
3206 {yyerror ("Missing identifier"); RECOVER;;
3207     break;}
3208 case 127:
3209 #line 953 "./parse.y"
3210 {
3211                   SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[-2].value));
3212                   yyerror ("Missing identifier"); RECOVER;
3213                 ;
3214     break;}
3215 case 128:
3216 #line 960 "./parse.y"
3217 { yyval.node = NULL_TREE; ;
3218     break;}
3219 case 129:
3220 #line 962 "./parse.y"
3221 { yyval.node = yyvsp[0].node; ;
3222     break;}
3223 case 130:
3224 #line 964 "./parse.y"
3225 {yyerror ("Missing class type term"); RECOVER;;
3226     break;}
3227 case 131:
3228 #line 969 "./parse.y"
3229 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3230     break;}
3231 case 132:
3232 #line 971 "./parse.y"
3233 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3234     break;}
3235 case 133:
3236 #line 973 "./parse.y"
3237 {yyerror ("Missing class type term"); RECOVER;;
3238     break;}
3239 case 136:
3240 #line 980 "./parse.y"
3241 { yyval.node = NULL_TREE; ;
3242     break;}
3243 case 137:
3244 #line 986 "./parse.y"
3245 {
3246                   TREE_CHAIN (yyvsp[0].node) = ctxp->static_initialized;
3247                   ctxp->static_initialized = yyvsp[0].node;
3248                 ;
3249     break;}
3250 case 138:
3251 #line 991 "./parse.y"
3252 {
3253                   TREE_CHAIN (yyvsp[-1].node) = ctxp->static_initialized;
3254                   ctxp->static_initialized = yyvsp[-1].node;
3255                 ;
3256     break;}
3257 case 139:
3258 #line 999 "./parse.y"
3259 {
3260                   SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3261                 ;
3262     break;}
3263 case 140:
3264 #line 1007 "./parse.y"
3265 {
3266                   current_function_decl = yyvsp[0].node;
3267                   source_start_java_method (current_function_decl);
3268                 ;
3269     break;}
3270 case 141:
3271 #line 1012 "./parse.y"
3272 { finish_method_declaration (yyvsp[0].node); ;
3273     break;}
3274 case 142:
3275 #line 1017 "./parse.y"
3276 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3277     break;}
3278 case 143:
3279 #line 1019 "./parse.y"
3280 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3281     break;}
3282 case 144:
3283 #line 1024 "./parse.y"
3284 { yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE); ;
3285     break;}
3286 case 145:
3287 #line 1026 "./parse.y"
3288 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3289     break;}
3290 case 146:
3291 #line 1034 "./parse.y"
3292
3293                   BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3294                   yyval.node = yyvsp[0].node;
3295                 ;
3296     break;}
3297 case 147:
3298 #line 1039 "./parse.y"
3299 { yyval.node = yyvsp[0].node; ;
3300     break;}
3301 case 148:
3302 #line 1041 "./parse.y"
3303 { yyval.node = yyvsp[0].node; ;
3304     break;}
3305 case 149:
3306 #line 1043 "./parse.y"
3307 { yyval.node = yyvsp[0].node; ;
3308     break;}
3309 case 152:
3310 #line 1053 "./parse.y"
3311
3312                   yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE); 
3313                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3314                   yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3315                 ;
3316     break;}
3317 case 153:
3318 #line 1059 "./parse.y"
3319
3320                   yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node); 
3321                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3322                   yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3323                 ;
3324     break;}
3325 case 154:
3326 #line 1067 "./parse.y"
3327 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3328     break;}
3329 case 155:
3330 #line 1069 "./parse.y"
3331 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3332     break;}
3333 case 156:
3334 #line 1074 "./parse.y"
3335 {
3336                   tree wfl = build_wfl_node (this_identifier_node);
3337                   EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3338                   yyval.node = wfl;
3339                 ;
3340     break;}
3341 case 157:
3342 #line 1080 "./parse.y"
3343 {
3344                   tree wfl = build_wfl_node (super_identifier_node);
3345                   EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3346                   yyval.node = wfl;
3347                 ;
3348     break;}
3349 case 158:
3350 #line 1091 "./parse.y"
3351 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3352     break;}
3353 case 159:
3354 #line 1093 "./parse.y"
3355 {
3356                   yyval.node = yyvsp[0].node;
3357                 ;
3358     break;}
3359 case 160:
3360 #line 1097 "./parse.y"
3361 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3362     break;}
3363 case 161:
3364 #line 1099 "./parse.y"
3365 {
3366                   yyval.node = yyvsp[0].node;
3367                 ;
3368     break;}
3369 case 162:
3370 #line 1103 "./parse.y"
3371 { create_interface (0, yyvsp[-1].node, yyvsp[0].node);  ;
3372     break;}
3373 case 163:
3374 #line 1105 "./parse.y"
3375 {
3376                   yyval.node = yyvsp[0].node;
3377                 ;
3378     break;}
3379 case 164:
3380 #line 1109 "./parse.y"
3381 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3382     break;}
3383 case 165:
3384 #line 1111 "./parse.y"
3385 {
3386                   yyval.node = yyvsp[0].node;
3387                 ;
3388     break;}
3389 case 166:
3390 #line 1115 "./parse.y"
3391 {yyerror ("'{' expected"); RECOVER;;
3392     break;}
3393 case 167:
3394 #line 1117 "./parse.y"
3395 {yyerror ("'{' expected"); RECOVER;;
3396     break;}
3397 case 168:
3398 #line 1122 "./parse.y"
3399
3400                   ctxp->interface_number = 1;
3401                   yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3402                 ;
3403     break;}
3404 case 169:
3405 #line 1127 "./parse.y"
3406
3407                   ctxp->interface_number++;
3408                   yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3409                 ;
3410     break;}
3411 case 170:
3412 #line 1132 "./parse.y"
3413 {yyerror ("Invalid interface type"); RECOVER;;
3414     break;}
3415 case 171:
3416 #line 1134 "./parse.y"
3417 {yyerror ("Missing term"); RECOVER;;
3418     break;}
3419 case 172:
3420 #line 1139 "./parse.y"
3421 { yyval.node = NULL_TREE; ;
3422     break;}
3423 case 173:
3424 #line 1141 "./parse.y"
3425 { yyval.node = NULL_TREE; ;
3426     break;}
3427 case 178:
3428 #line 1153 "./parse.y"
3429 { yyval.node = parse_jdk1_1_error ("inner class declaration"); ;
3430     break;}
3431 case 179:
3432 #line 1155 "./parse.y"
3433 { yyval.node = parse_jdk1_1_error ("inner interface declaration"); ;
3434     break;}
3435 case 181:
3436 #line 1164 "./parse.y"
3437
3438                   check_abstract_method_header (yyvsp[-1].node);
3439                   current_function_decl = NULL_TREE; /* FIXME ? */
3440                 ;
3441     break;}
3442 case 182:
3443 #line 1169 "./parse.y"
3444 {yyerror ("';' expected"); RECOVER;;
3445     break;}
3446 case 183:
3447 #line 1175 "./parse.y"
3448 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3449     break;}
3450 case 184:
3451 #line 1177 "./parse.y"
3452 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3453     break;}
3454 case 185:
3455 #line 1179 "./parse.y"
3456 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3457     break;}
3458 case 186:
3459 #line 1184 "./parse.y"
3460
3461                   yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), 
3462                                   yyvsp[0].node, NULL_TREE);
3463                 ;
3464     break;}
3465 case 187:
3466 #line 1189 "./parse.y"
3467 {
3468                   yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3469                 ;
3470     break;}
3471 case 188:
3472 #line 1193 "./parse.y"
3473 {yyerror ("Missing term"); RECOVER;;
3474     break;}
3475 case 189:
3476 #line 1199 "./parse.y"
3477
3478                   /* Store the location of the `}' when doing xrefs */
3479                   if (current_function_decl && flag_emit_xref)
3480                     DECL_END_SOURCE_LINE (current_function_decl) = 
3481                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3482                   yyval.node = empty_stmt_node; 
3483                 ;
3484     break;}
3485 case 190:
3486 #line 1207 "./parse.y"
3487 { yyval.node = yyvsp[0].node; ;
3488     break;}
3489 case 191:
3490 #line 1212 "./parse.y"
3491 { enter_block (); ;
3492     break;}
3493 case 192:
3494 #line 1217 "./parse.y"
3495
3496                   maybe_absorb_scoping_blocks ();
3497                   /* Store the location of the `}' when doing xrefs */
3498                   if (current_function_decl && flag_emit_xref)
3499                     DECL_END_SOURCE_LINE (current_function_decl) = 
3500                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);           
3501                   yyval.node = exit_block ();
3502                 ;
3503     break;}
3504 case 196:
3505 #line 1235 "./parse.y"
3506 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3507     break;}
3508 case 197:
3509 #line 1237 "./parse.y"
3510 { parse_jdk1_1_error ("inner class declaration"); ;
3511     break;}
3512 case 199:
3513 #line 1246 "./parse.y"
3514 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3515     break;}
3516 case 200:
3517 #line 1248 "./parse.y"
3518 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3519     break;}
3520 case 206:
3521 #line 1258 "./parse.y"
3522 { yyval.node = exit_block (); ;
3523     break;}
3524 case 211:
3525 #line 1267 "./parse.y"
3526 { yyval.node = exit_block (); ;
3527     break;}
3528 case 223:
3529 #line 1286 "./parse.y"
3530 { yyval.node = empty_stmt_node; ;
3531     break;}
3532 case 224:
3533 #line 1291 "./parse.y"
3534 {
3535                   yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node), 
3536                                             EXPR_WFL_NODE (yyvsp[-1].node));
3537                   pushlevel (2);
3538                   push_labeled_block (yyval.node);
3539                   PUSH_LABELED_BLOCK (yyval.node);
3540                 ;
3541     break;}
3542 case 225:
3543 #line 1302 "./parse.y"
3544 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3545     break;}
3546 case 226:
3547 #line 1304 "./parse.y"
3548 {yyerror ("':' expected"); RECOVER;;
3549     break;}
3550 case 227:
3551 #line 1309 "./parse.y"
3552 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3553     break;}
3554 case 228:
3555 #line 1316 "./parse.y"
3556 {
3557                   /* We have a statement. Generate a WFL around it so
3558                      we can debug it */
3559                   yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3560                   /* We know we have a statement, so set the debug
3561                      info to be eventually generate here. */
3562                   yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3563                 ;
3564     break;}
3565 case 229:
3566 #line 1325 "./parse.y"
3567 {
3568                   if (ctxp->prevent_ese != lineno)
3569                     yyerror ("Invalid expression statement");
3570                   DRECOVER (expr_stmt);
3571                 ;
3572     break;}
3573 case 230:
3574 #line 1331 "./parse.y"
3575 {
3576                   if (ctxp->prevent_ese != lineno)
3577                     yyerror ("Invalid expression statement");
3578                   DRECOVER (expr_stmt);
3579                 ;
3580     break;}
3581 case 231:
3582 #line 1337 "./parse.y"
3583 {
3584                   if (ctxp->prevent_ese != lineno)
3585                     yyerror ("Invalid expression statement");
3586                   DRECOVER (expr_stmt);
3587                 ;
3588     break;}
3589 case 232:
3590 #line 1343 "./parse.y"
3591 {yyerror ("')' expected"); RECOVER;;
3592     break;}
3593 case 233:
3594 #line 1345 "./parse.y"
3595 {
3596                   yyerror ("Constructor invocation must be first "
3597                            "thing in a constructor"); 
3598                   RECOVER;
3599                 ;
3600     break;}
3601 case 234:
3602 #line 1351 "./parse.y"
3603 {yyerror ("')' expected"); RECOVER;;
3604     break;}
3605 case 235:
3606 #line 1353 "./parse.y"
3607 {
3608                   yyerror ("Constructor invocation must be first "
3609                            "thing in a constructor"); 
3610                   RECOVER;
3611                 ;
3612     break;}
3613 case 236:
3614 #line 1359 "./parse.y"
3615 {yyerror ("'(' expected"); RECOVER;;
3616     break;}
3617 case 237:
3618 #line 1361 "./parse.y"
3619 {yyerror ("')' expected"); RECOVER;;
3620     break;}
3621 case 238:
3622 #line 1363 "./parse.y"
3623 {yyerror ("')' expected"); RECOVER;;
3624     break;}
3625 case 239:
3626 #line 1365 "./parse.y"
3627 {yyerror ("';' expected"); RECOVER;;
3628     break;}
3629 case 240:
3630 #line 1367 "./parse.y"
3631 {yyerror ("';' expected"); RECOVER;;
3632     break;}
3633 case 248:
3634 #line 1382 "./parse.y"
3635
3636                   yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node, 
3637                                                 yyvsp[0].node, NULL_TREE);
3638                 ;
3639     break;}
3640 case 249:
3641 #line 1387 "./parse.y"
3642 {yyerror ("'(' expected"); RECOVER;;
3643     break;}
3644 case 250:
3645 #line 1389 "./parse.y"
3646 {yyerror ("Missing term"); RECOVER;;
3647     break;}
3648 case 251:
3649 #line 1391 "./parse.y"
3650 {yyerror ("')' expected"); RECOVER;;
3651     break;}
3652 case 252:
3653 #line 1396 "./parse.y"
3654 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3655     break;}
3656 case 253:
3657 #line 1401 "./parse.y"
3658 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3659     break;}
3660 case 254:
3661 #line 1406 "./parse.y"
3662 {
3663                   enter_block ();
3664                 ;
3665     break;}
3666 case 255:
3667 #line 1410 "./parse.y"
3668
3669                   /* Make into "proper list" of COMPOUND_EXPRs.
3670                      I.e. make the last statment also have its own
3671                      COMPOUND_EXPR. */
3672                   maybe_absorb_scoping_blocks ();
3673                   TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
3674                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
3675                 ;
3676     break;}
3677 case 256:
3678 #line 1422 "./parse.y"
3679
3680                   yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3681                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3682                 ;
3683     break;}
3684 case 257:
3685 #line 1427 "./parse.y"
3686 {yyerror ("'(' expected"); RECOVER;;
3687     break;}
3688 case 258:
3689 #line 1429 "./parse.y"
3690 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3691     break;}
3692 case 259:
3693 #line 1431 "./parse.y"
3694 {yyerror ("'{' expected"); RECOVER;;
3695     break;}
3696 case 260:
3697 #line 1439 "./parse.y"
3698 { yyval.node = NULL_TREE; ;
3699     break;}
3700 case 261:
3701 #line 1441 "./parse.y"
3702 { yyval.node = NULL_TREE; ;
3703     break;}
3704 case 262:
3705 #line 1443 "./parse.y"
3706 { yyval.node = NULL_TREE; ;
3707     break;}
3708 case 263:
3709 #line 1445 "./parse.y"
3710 { yyval.node = NULL_TREE; ;
3711     break;}
3712 case 269:
3713 #line 1464 "./parse.y"
3714
3715                   tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3716                   EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
3717                   java_method_add_stmt (current_function_decl, lab);
3718                 ;
3719     break;}
3720 case 270:
3721 #line 1470 "./parse.y"
3722
3723                   tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3724                   EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
3725                   java_method_add_stmt (current_function_decl, lab);
3726                 ;
3727     break;}
3728 case 271:
3729 #line 1476 "./parse.y"
3730 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3731     break;}
3732 case 272:
3733 #line 1478 "./parse.y"
3734 {yyerror ("':' expected"); RECOVER;;
3735     break;}
3736 case 273:
3737 #line 1480 "./parse.y"
3738 {yyerror ("':' expected"); RECOVER;;
3739     break;}
3740 case 274:
3741 #line 1485 "./parse.y"
3742
3743                   tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3744                   yyval.node = build_new_loop (body);
3745                 ;
3746     break;}
3747 case 275:
3748 #line 1493 "./parse.y"
3749 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3750     break;}
3751 case 276:
3752 #line 1495 "./parse.y"
3753 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3754     break;}
3755 case 277:
3756 #line 1497 "./parse.y"
3757 {yyerror ("Missing term and ')' expected"); RECOVER;;
3758     break;}
3759 case 278:
3760 #line 1499 "./parse.y"
3761 {yyerror ("')' expected"); RECOVER;;
3762     break;}
3763 case 279:
3764 #line 1504 "./parse.y"
3765 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3766     break;}
3767 case 280:
3768 #line 1509 "./parse.y"
3769
3770                   tree body = build_loop_body (0, NULL_TREE, 1);
3771                   yyval.node = build_new_loop (body);
3772                 ;
3773     break;}
3774 case 281:
3775 #line 1518 "./parse.y"
3776 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3777     break;}
3778 case 282:
3779 #line 1523 "./parse.y"
3780 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3781     break;}
3782 case 283:
3783 #line 1525 "./parse.y"
3784
3785                   yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3786                   /* We have not condition, so we get rid of the EXIT_EXPR */
3787                   LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = 
3788                     empty_stmt_node;
3789                 ;
3790     break;}
3791 case 284:
3792 #line 1532 "./parse.y"
3793 {yyerror ("Invalid control expression"); RECOVER;;
3794     break;}
3795 case 285:
3796 #line 1534 "./parse.y"
3797 {yyerror ("Invalid update expression"); RECOVER;;
3798     break;}
3799 case 286:
3800 #line 1536 "./parse.y"
3801 {yyerror ("Invalid update expression"); RECOVER;;
3802     break;}
3803 case 287:
3804 #line 1541 "./parse.y"
3805 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
3806     break;}
3807 case 288:
3808 #line 1543 "./parse.y"
3809
3810                   yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3811                   /* We have not condition, so we get rid of the EXIT_EXPR */
3812                   LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = 
3813                     empty_stmt_node;
3814                 ;
3815     break;}
3816 case 289:
3817 #line 1553 "./parse.y"
3818
3819                   /* This scope defined for local variable that may be
3820                      defined within the scope of the for loop */
3821                   enter_block (); 
3822                 ;
3823     break;}
3824 case 290:
3825 #line 1559 "./parse.y"
3826 {yyerror ("'(' expected"); DRECOVER(for_1);;
3827     break;}
3828 case 291:
3829 #line 1561 "./parse.y"
3830 {yyerror ("Invalid init statement"); RECOVER;;
3831     break;}
3832 case 292:
3833 #line 1566 "./parse.y"
3834
3835                   /* We now declare the loop body. The loop is
3836                      declared as a for loop. */
3837                   tree body = build_loop_body (0, NULL_TREE, 0);
3838                   yyval.node =  build_new_loop (body);
3839                   IS_FOR_LOOP_P (yyval.node) = 1;
3840                   /* The loop is added to the current block the for
3841                      statement is defined within */
3842                   java_method_add_stmt (current_function_decl, yyval.node);
3843                 ;
3844     break;}
3845 case 293:
3846 #line 1578 "./parse.y"
3847 { yyval.node = empty_stmt_node; ;
3848     break;}
3849 case 294:
3850 #line 1580 "./parse.y"
3851
3852                   /* Init statement recorded within the previously
3853                      defined block scope */
3854                   yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
3855                 ;
3856     break;}
3857 case 295:
3858 #line 1586 "./parse.y"
3859
3860                   /* Local variable are recorded within the previously
3861                      defined block scope */
3862                   yyval.node = NULL_TREE;
3863                 ;
3864     break;}
3865 case 296:
3866 #line 1592 "./parse.y"
3867 {yyerror ("';' expected"); DRECOVER(for_init_1);;
3868     break;}
3869 case 297:
3870 #line 1596 "./parse.y"
3871 {yyval.node = empty_stmt_node;;
3872     break;}
3873 case 298:
3874 #line 1598 "./parse.y"
3875 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
3876     break;}
3877 case 299:
3878 #line 1603 "./parse.y"
3879 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
3880     break;}
3881 case 300:
3882 #line 1605 "./parse.y"
3883 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
3884     break;}
3885 case 301:
3886 #line 1607 "./parse.y"
3887 {yyerror ("Missing term"); RECOVER;;
3888     break;}
3889 case 302:
3890 #line 1612 "./parse.y"
3891 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
3892     break;}
3893 case 303:
3894 #line 1614 "./parse.y"
3895 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
3896     break;}
3897 case 304:
3898 #line 1616 "./parse.y"
3899 {yyerror ("Missing term"); RECOVER;;
3900     break;}
3901 case 305:
3902 #line 1618 "./parse.y"
3903 {yyerror ("';' expected"); RECOVER;;
3904     break;}
3905 case 306:
3906 #line 1623 "./parse.y"
3907 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
3908     break;}
3909 case 307:
3910 #line 1625 "./parse.y"
3911 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
3912     break;}
3913 case 308:
3914 #line 1627 "./parse.y"
3915 {yyerror ("Missing term"); RECOVER;;
3916     break;}
3917 case 309:
3918 #line 1629 "./parse.y"
3919 {yyerror ("';' expected"); RECOVER;;
3920     break;}
3921 case 310:
3922 #line 1634 "./parse.y"
3923 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
3924     break;}
3925 case 311:
3926 #line 1636 "./parse.y"
3927 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3928     break;}
3929 case 312:
3930 #line 1638 "./parse.y"
3931 {yyerror ("Missing term"); RECOVER;;
3932     break;}
3933 case 313:
3934 #line 1640 "./parse.y"
3935 {yyerror ("';' expected"); RECOVER;;
3936     break;}
3937 case 314:
3938 #line 1645 "./parse.y"
3939
3940                   yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
3941                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3942                 ;
3943     break;}
3944 case 315:
3945 #line 1650 "./parse.y"
3946 {yyerror ("Missing term"); RECOVER;;
3947     break;}
3948 case 316:
3949 #line 1652 "./parse.y"
3950 {yyerror ("';' expected"); RECOVER;;
3951     break;}
3952 case 317:
3953 #line 1657 "./parse.y"
3954
3955                   yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3956                   EXPR_WFL_LINECOL (yyval.node) = 
3957                     EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
3958                 ;
3959     break;}
3960 case 318:
3961 #line 1663 "./parse.y"
3962 {yyerror ("'{' expected"); RECOVER;;
3963     break;}
3964 case 319:
3965 #line 1665 "./parse.y"
3966 {yyerror ("'(' expected"); RECOVER;;
3967     break;}
3968 case 320:
3969 #line 1667 "./parse.y"
3970 {yyerror ("Missing term"); RECOVER;;
3971     break;}
3972 case 321:
3973 #line 1669 "./parse.y"
3974 {yyerror ("Missing term"); RECOVER;;
3975     break;}
3976 case 322:
3977 #line 1674 "./parse.y"
3978 {
3979                   if ((1 << yyvsp[0].value) != ACC_SYNCHRONIZED)
3980                     fatal ("synchronized was '%d' - yyparse", (1 << yyvsp[0].value));
3981                 ;
3982     break;}
3983 case 323:
3984 #line 1682 "./parse.y"
3985 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
3986     break;}
3987 case 324:
3988 #line 1684 "./parse.y"
3989 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
3990     break;}
3991 case 325:
3992 #line 1686 "./parse.y"
3993 { yyval.node = build_try_finally_statement 
3994                     (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
3995                                                        yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
3996                 ;
3997     break;}
3998 case 326:
3999 #line 1691 "./parse.y"
4000 {yyerror ("'{' expected"); DRECOVER (try_statement);;
4001     break;}
4002 case 328:
4003 #line 1697 "./parse.y"
4004
4005                   TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
4006                   yyval.node = yyvsp[0].node;
4007                 ;
4008     break;}
4009 case 329:
4010 #line 1705 "./parse.y"
4011
4012                   java_method_add_stmt (current_function_decl, yyvsp[0].node);
4013                   exit_block ();
4014                   yyval.node = yyvsp[-1].node;
4015                 ;
4016     break;}
4017 case 330:
4018 #line 1713 "./parse.y"
4019
4020                   /* We add a block to define a scope for
4021                      formal_parameter (CCBP). The formal parameter is
4022                      declared initialized by the appropriate function
4023                      call */
4024                   tree ccpb = enter_block ();
4025                   tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location, 
4026                                                 TREE_PURPOSE (yyvsp[-1].node), 
4027                                                 soft_exceptioninfo_call_node);
4028                   declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4029                                            build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
4030                                                             init));
4031                   yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4032                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4033                 ;
4034     break;}
4035 case 331:
4036 #line 1729 "./parse.y"
4037 {yyerror ("'(' expected"); RECOVER;;
4038     break;}
4039 case 332:
4040 #line 1731 "./parse.y"
4041 {yyerror ("Missing term or ')' expected"); DRECOVER (2);;
4042     break;}
4043 case 333:
4044 #line 1733 "./parse.y"
4045 {yyerror ("')' expected"); DRECOVER (1);;
4046     break;}
4047 case 334:
4048 #line 1738 "./parse.y"
4049 { yyval.node = yyvsp[0].node; ;
4050     break;}
4051 case 335:
4052 #line 1740 "./parse.y"
4053 {yyerror ("'{' expected"); RECOVER; ;
4054     break;}
4055 case 339:
4056 #line 1752 "./parse.y"
4057 { yyval.node = build_this (yyvsp[0].operator.location); ;
4058     break;}
4059 case 340:
4060 #line 1754 "./parse.y"
4061 {yyval.node = yyvsp[-1].node;;
4062     break;}
4063 case 345:
4064 #line 1763 "./parse.y"
4065 { yyval.node = parse_jdk1_1_error ("named class literals"); ;
4066     break;}
4067 case 346:
4068 #line 1765 "./parse.y"
4069 { yyval.node = build_class_ref (yyvsp[-2].node); ;
4070     break;}
4071 case 347:
4072 #line 1767 "./parse.y"
4073 { yyval.node = build_class_ref (void_type_node); ;
4074     break;}
4075 case 348:
4076 #line 1772 "./parse.y"
4077 { yyval.node = parse_jdk1_1_error ("class literals"); ;
4078     break;}
4079 case 349:
4080 #line 1774 "./parse.y"
4081 {yyerror ("')' expected"); RECOVER;;
4082     break;}
4083 case 350:
4084 #line 1776 "./parse.y"
4085 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4086     break;}
4087 case 351:
4088 #line 1778 "./parse.y"
4089 {yyerror ("'class' expected" ); RECOVER;;
4090     break;}
4091 case 352:
4092 #line 1780 "./parse.y"
4093 {yyerror ("'class' expected" ); RECOVER;;
4094     break;}
4095 case 353:
4096 #line 1785 "./parse.y"
4097 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4098     break;}
4099 case 354:
4100 #line 1787 "./parse.y"
4101 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4102     break;}
4103 case 355:
4104 #line 1792 "./parse.y"
4105 { yyval.node = parse_jdk1_1_error ("inner class instance creation"); ;
4106     break;}
4107 case 356:
4108 #line 1794 "./parse.y"
4109 { yyval.node = parse_jdk1_1_error ("inner class instance creation"); ;
4110     break;}
4111 case 361:
4112 #line 1803 "./parse.y"
4113 {yyerror ("'(' expected"); DRECOVER(new_1);;
4114     break;}
4115 case 362:
4116 #line 1805 "./parse.y"
4117 {yyerror ("'(' expected"); RECOVER;;
4118     break;}
4119 case 363:
4120 #line 1807 "./parse.y"
4121 {yyerror ("')' or term expected"); RECOVER;;
4122     break;}
4123 case 364:
4124 #line 1809 "./parse.y"
4125 {yyerror ("')' expected"); RECOVER;;
4126     break;}
4127 case 365:
4128 #line 1811 "./parse.y"
4129 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4130     break;}
4131 case 366:
4132 #line 1813 "./parse.y"
4133 {yyerror ("'(' expected"); RECOVER;;
4134     break;}
4135 case 369:
4136 #line 1823 "./parse.y"
4137
4138                   yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4139                   ctxp->formal_parameter_number = 1; 
4140                 ;
4141     break;}
4142 case 370:
4143 #line 1828 "./parse.y"
4144 {
4145                   ctxp->formal_parameter_number += 1;
4146                   yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4147                 ;
4148     break;}
4149 case 371:
4150 #line 1833 "./parse.y"
4151 {yyerror ("Missing term"); RECOVER;;
4152     break;}
4153 case 372:
4154 #line 1838 "./parse.y"
4155 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4156     break;}
4157 case 373:
4158 #line 1840 "./parse.y"
4159 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4160     break;}
4161 case 374:
4162 #line 1842 "./parse.y"
4163 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4164     break;}
4165 case 375:
4166 #line 1844 "./parse.y"
4167 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4168     break;}
4169 case 376:
4170 #line 1848 "./parse.y"
4171 { yyval.node = parse_jdk1_1_error ("anonymous array"); ;
4172     break;}
4173 case 377:
4174 #line 1850 "./parse.y"
4175 { yyval.node = parse_jdk1_1_error ("anonymous array"); ;
4176     break;}
4177 case 378:
4178 #line 1852 "./parse.y"
4179 {yyerror ("'[' expected"); DRECOVER ("]");;
4180     break;}
4181 case 379:
4182 #line 1854 "./parse.y"
4183 {yyerror ("']' expected"); RECOVER;;
4184     break;}
4185 case 380:
4186 #line 1859 "./parse.y"
4187 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4188     break;}
4189 case 381:
4190 #line 1861 "./parse.y"
4191 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4192     break;}
4193 case 382:
4194 #line 1866 "./parse.y"
4195
4196                   EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4197                   yyval.node = yyvsp[-1].node;
4198                 ;
4199     break;}
4200 case 383:
4201 #line 1871 "./parse.y"
4202 {yyerror ("']' expected"); RECOVER;;
4203     break;}
4204 case 384:
4205 #line 1873 "./parse.y"
4206 {
4207                   yyerror ("Missing term");
4208                   yyerror ("']' expected");
4209                   RECOVER;
4210                 ;
4211     break;}
4212 case 385:
4213 #line 1882 "./parse.y"
4214
4215                   int allocate = 0;
4216                   /* If not initialized, allocate memory for the osb
4217                      numbers stack */
4218                   if (!ctxp->osb_limit)
4219                     {
4220                       allocate = ctxp->osb_limit = 32;
4221                       ctxp->osb_depth = -1;
4222                     }
4223                   /* If capacity overflown, reallocate a bigger chuck */
4224                   else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4225                     allocate = ctxp->osb_limit << 1;
4226                   
4227                   if (allocate)
4228                     {
4229                       allocate *= sizeof (int);
4230                       if (ctxp->osb_number)
4231                         ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
4232                                                             allocate);
4233                       else
4234                         ctxp->osb_number = (int *)xmalloc (allocate);
4235                     }
4236                   ctxp->osb_depth++;
4237                   CURRENT_OSB (ctxp) = 1;
4238                 ;
4239     break;}
4240 case 386:
4241 #line 1908 "./parse.y"
4242 { CURRENT_OSB (ctxp)++; ;
4243     break;}
4244 case 387:
4245 #line 1910 "./parse.y"
4246 { yyerror ("']' expected"); RECOVER;;
4247     break;}
4248 case 388:
4249 #line 1915 "./parse.y"
4250 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4251     break;}
4252 case 389:
4253 #line 1919 "./parse.y"
4254 {
4255                   tree super_wfl = 
4256                     build_wfl_node (super_identifier_node);
4257                   EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4258                   yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4259                 ;
4260     break;}
4261 case 390:
4262 #line 1926 "./parse.y"
4263 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4264     break;}
4265 case 391:
4266 #line 1931 "./parse.y"
4267 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4268     break;}
4269 case 392:
4270 #line 1933 "./parse.y"
4271 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4272     break;}
4273 case 393:
4274 #line 1935 "./parse.y"
4275
4276                   if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4277                     yyval.node = build_this_super_qualified_invocation 
4278                       (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4279                   else
4280                     {
4281                       tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4282                       yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4283                     }
4284                 ;
4285     break;}
4286 case 394:
4287 #line 1946 "./parse.y"
4288
4289                   if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4290                     yyval.node = build_this_super_qualified_invocation 
4291                       (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4292                   else
4293                     {
4294                       tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4295                       yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4296                     }
4297                 ;
4298     break;}
4299 case 395:
4300 #line 1957 "./parse.y"
4301
4302                   yyval.node = build_this_super_qualified_invocation 
4303                     (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4304                 ;
4305     break;}
4306 case 396:
4307 #line 1962 "./parse.y"
4308 {
4309                   yyval.node = build_this_super_qualified_invocation 
4310                     (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4311                 ;
4312     break;}
4313 case 397:
4314 #line 1971 "./parse.y"
4315 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4316     break;}
4317 case 398:
4318 #line 1973 "./parse.y"
4319 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4320     break;}
4321 case 399:
4322 #line 1978 "./parse.y"
4323 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4324     break;}
4325 case 400:
4326 #line 1980 "./parse.y"
4327 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4328     break;}
4329 case 401:
4330 #line 1982 "./parse.y"
4331 {
4332                   yyerror ("Missing term and ']' expected");
4333                   DRECOVER(array_access);
4334                 ;
4335     break;}
4336 case 402:
4337 #line 1987 "./parse.y"
4338 {
4339                   yyerror ("']' expected");
4340                   DRECOVER(array_access);
4341                 ;
4342     break;}
4343 case 403:
4344 #line 1992 "./parse.y"
4345 {
4346                   yyerror ("Missing term and ']' expected");
4347                   DRECOVER(array_access);
4348                 ;
4349     break;}
4350 case 404:
4351 #line 1997 "./parse.y"
4352 {
4353                   yyerror ("']' expected");
4354                   DRECOVER(array_access);
4355                 ;
4356     break;}
4357 case 409:
4358 #line 2012 "./parse.y"
4359 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4360     break;}
4361 case 410:
4362 #line 2017 "./parse.y"
4363 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4364     break;}
4365 case 413:
4366 #line 2024 "./parse.y"
4367 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4368     break;}
4369 case 414:
4370 #line 2026 "./parse.y"
4371 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4372     break;}
4373 case 416:
4374 #line 2029 "./parse.y"
4375 {yyerror ("Missing term"); RECOVER;
4376     break;}
4377 case 417:
4378 #line 2031 "./parse.y"
4379 {yyerror ("Missing term"); RECOVER;
4380     break;}
4381 case 418:
4382 #line 2036 "./parse.y"
4383 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4384     break;}
4385 case 419:
4386 #line 2038 "./parse.y"
4387 {yyerror ("Missing term"); RECOVER;
4388     break;}
4389 case 420:
4390 #line 2043 "./parse.y"
4391 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4392     break;}
4393 case 421:
4394 #line 2045 "./parse.y"
4395 {yyerror ("Missing term"); RECOVER;
4396     break;}
4397 case 423:
4398 #line 2051 "./parse.y"
4399 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4400     break;}
4401 case 424:
4402 #line 2053 "./parse.y"
4403 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4404     break;}
4405 case 426:
4406 #line 2056 "./parse.y"
4407 {yyerror ("Missing term"); RECOVER;
4408     break;}
4409 case 427:
4410 #line 2058 "./parse.y"
4411 {yyerror ("Missing term"); RECOVER;
4412     break;}
4413 case 428:
4414 #line 2063 "./parse.y"
4415
4416                   tree type = yyvsp[-3].node;
4417                   while (CURRENT_OSB (ctxp)--)
4418                     type = build_java_array_type (type, -1);
4419                   ctxp->osb_depth--;
4420                   yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node); 
4421                 ;
4422     break;}
4423 case 429:
4424 #line 2071 "./parse.y"
4425 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4426     break;}
4427 case 430:
4428 #line 2073 "./parse.y"
4429 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4430     break;}
4431 case 431:
4432 #line 2075 "./parse.y"
4433
4434                   const char *ptr;
4435                   while (CURRENT_OSB (ctxp)--)
4436                     obstack_1grow (&temporary_obstack, '[');
4437                   ctxp->osb_depth--;
4438                   obstack_grow0 (&temporary_obstack, 
4439                                  IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4440                                  IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4441                   ptr = obstack_finish (&temporary_obstack);
4442                   EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4443                   yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4444                 ;
4445     break;}
4446 case 432:
4447 #line 2088 "./parse.y"
4448 {yyerror ("']' expected, invalid type expression");;
4449     break;}
4450 case 433:
4451 #line 2090 "./parse.y"
4452 {
4453                   if (ctxp->prevent_ese != lineno)
4454                     yyerror ("Invalid type expression"); RECOVER;
4455                   RECOVER;
4456                 ;
4457     break;}
4458 case 434:
4459 #line 2096 "./parse.y"
4460 {yyerror ("Missing term"); RECOVER;;
4461     break;}
4462 case 435:
4463 #line 2098 "./parse.y"
4464 {yyerror ("Missing term"); RECOVER;;
4465     break;}
4466 case 436:
4467 #line 2100 "./parse.y"
4468 {yyerror ("Missing term"); RECOVER;;
4469     break;}
4470 case 438:
4471 #line 2106 "./parse.y"
4472
4473                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), 
4474                                     yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4475                 ;
4476     break;}
4477 case 439:
4478 #line 2111 "./parse.y"
4479 {
4480                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4481                                     yyvsp[-2].node, yyvsp[0].node); 
4482                 ;
4483     break;}
4484 case 440:
4485 #line 2116 "./parse.y"
4486 {
4487                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4488                                     yyvsp[-2].node, yyvsp[0].node); 
4489                 ;
4490     break;}
4491 case 441:
4492 #line 2121 "./parse.y"
4493 {yyerror ("Missing term"); RECOVER;;
4494     break;}
4495 case 442:
4496 #line 2123 "./parse.y"
4497 {yyerror ("Missing term"); RECOVER;;
4498     break;}
4499 case 443:
4500 #line 2125 "./parse.y"
4501 {yyerror ("Missing term"); RECOVER;;
4502     break;}
4503 case 445:
4504 #line 2131 "./parse.y"
4505 {
4506                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4507                                     yyvsp[-2].node, yyvsp[0].node); 
4508                 ;
4509     break;}
4510 case 446:
4511 #line 2136 "./parse.y"
4512 {
4513                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4514                                     yyvsp[-2].node, yyvsp[0].node); 
4515                 ;
4516     break;}
4517 case 447:
4518 #line 2141 "./parse.y"
4519 {yyerror ("Missing term"); RECOVER;;
4520     break;}
4521 case 448:
4522 #line 2143 "./parse.y"
4523 {yyerror ("Missing term"); RECOVER;;
4524     break;}
4525 case 450:
4526 #line 2149 "./parse.y"
4527 {
4528                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4529                                     yyvsp[-2].node, yyvsp[0].node); 
4530                 ;
4531     break;}
4532 case 451:
4533 #line 2154 "./parse.y"
4534 {
4535                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4536                                     yyvsp[-2].node, yyvsp[0].node); 
4537                 ;
4538     break;}
4539 case 452:
4540 #line 2159 "./parse.y"
4541 {
4542                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4543                                     yyvsp[-2].node, yyvsp[0].node); 
4544                 ;
4545     break;}
4546 case 453:
4547 #line 2164 "./parse.y"
4548 {yyerror ("Missing term"); RECOVER;;
4549     break;}
4550 case 454:
4551 #line 2166 "./parse.y"
4552 {yyerror ("Missing term"); RECOVER;;
4553     break;}
4554 case 455:
4555 #line 2168 "./parse.y"
4556 {yyerror ("Missing term"); RECOVER;;
4557     break;}
4558 case 457:
4559 #line 2174 "./parse.y"
4560 {
4561                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4562                                     yyvsp[-2].node, yyvsp[0].node); 
4563                 ;
4564     break;}
4565 case 458:
4566 #line 2179 "./parse.y"
4567 {
4568                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4569                                     yyvsp[-2].node, yyvsp[0].node); 
4570                 ;
4571     break;}
4572 case 459:
4573 #line 2184 "./parse.y"
4574 {
4575                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4576                                     yyvsp[-2].node, yyvsp[0].node); 
4577                 ;
4578     break;}
4579 case 460:
4580 #line 2189 "./parse.y"
4581 {
4582                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4583                                     yyvsp[-2].node, yyvsp[0].node); 
4584                 ;
4585     break;}
4586 case 461:
4587 #line 2194 "./parse.y"
4588 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4589     break;}
4590 case 462:
4591 #line 2196 "./parse.y"
4592 {yyerror ("Missing term"); RECOVER;;
4593     break;}
4594 case 463:
4595 #line 2198 "./parse.y"
4596 {yyerror ("Missing term"); RECOVER;;
4597     break;}
4598 case 464:
4599 #line 2200 "./parse.y"
4600 {yyerror ("Missing term"); RECOVER;;
4601     break;}
4602 case 465:
4603 #line 2202 "./parse.y"
4604 {yyerror ("Missing term"); RECOVER;;
4605     break;}
4606 case 466:
4607 #line 2204 "./parse.y"
4608 {yyerror ("Invalid reference type"); RECOVER;;
4609     break;}
4610 case 468:
4611 #line 2210 "./parse.y"
4612 {
4613                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4614                                     yyvsp[-2].node, yyvsp[0].node); 
4615                 ;
4616     break;}
4617 case 469:
4618 #line 2215 "./parse.y"
4619 {
4620                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4621                                     yyvsp[-2].node, yyvsp[0].node); 
4622                 ;
4623     break;}
4624 case 470:
4625 #line 2220 "./parse.y"
4626 {yyerror ("Missing term"); RECOVER;;
4627     break;}
4628 case 471:
4629 #line 2222 "./parse.y"
4630 {yyerror ("Missing term"); RECOVER;;
4631     break;}
4632 case 473:
4633 #line 2228 "./parse.y"
4634 {
4635                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4636                                     yyvsp[-2].node, yyvsp[0].node); 
4637                 ;
4638     break;}
4639 case 474:
4640 #line 2233 "./parse.y"
4641 {yyerror ("Missing term"); RECOVER;;
4642     break;}
4643 case 476:
4644 #line 2239 "./parse.y"
4645 {
4646                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4647                                     yyvsp[-2].node, yyvsp[0].node); 
4648                 ;
4649     break;}
4650 case 477:
4651 #line 2244 "./parse.y"
4652 {yyerror ("Missing term"); RECOVER;;
4653     break;}
4654 case 479:
4655 #line 2250 "./parse.y"
4656 {
4657                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4658                                     yyvsp[-2].node, yyvsp[0].node); 
4659                 ;
4660     break;}
4661 case 480:
4662 #line 2255 "./parse.y"
4663 {yyerror ("Missing term"); RECOVER;;
4664     break;}
4665 case 482:
4666 #line 2261 "./parse.y"
4667 {
4668                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4669                                     yyvsp[-2].node, yyvsp[0].node); 
4670                 ;
4671     break;}
4672 case 483:
4673 #line 2266 "./parse.y"
4674 {yyerror ("Missing term"); RECOVER;;
4675     break;}
4676 case 485:
4677 #line 2272 "./parse.y"
4678 {
4679                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4680                                     yyvsp[-2].node, yyvsp[0].node); 
4681                 ;
4682     break;}
4683 case 486:
4684 #line 2277 "./parse.y"
4685 {yyerror ("Missing term"); RECOVER;;
4686     break;}
4687 case 488:
4688 #line 2283 "./parse.y"
4689 {
4690                   yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
4691                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4692                 ;
4693     break;}
4694 case 489:
4695 #line 2288 "./parse.y"
4696 {
4697                   YYERROR_NOW;
4698                   yyerror ("Missing term");
4699                   DRECOVER (1);
4700                 ;
4701     break;}
4702 case 490:
4703 #line 2294 "./parse.y"
4704 {yyerror ("Missing term"); DRECOVER (2);;
4705     break;}
4706 case 491:
4707 #line 2296 "./parse.y"
4708 {yyerror ("Missing term"); DRECOVER (3);;
4709     break;}
4710 case 494:
4711 #line 2306 "./parse.y"
4712 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4713     break;}
4714 case 495:
4715 #line 2308 "./parse.y"
4716 {
4717                   if (ctxp->prevent_ese != lineno)
4718                     yyerror ("Missing term");
4719                   DRECOVER (assign);
4720                 ;
4721     break;}
4722 }
4723    /* the action file gets copied in in place of this dollarsign */
4724 #line 498 "/usr/share/misc/bison.simple"
4725 \f
4726   yyvsp -= yylen;
4727   yyssp -= yylen;
4728 #ifdef YYLSP_NEEDED
4729   yylsp -= yylen;
4730 #endif
4731
4732 #if YYDEBUG != 0
4733   if (yydebug)
4734     {
4735       short *ssp1 = yyss - 1;
4736       fprintf (stderr, "state stack now");
4737       while (ssp1 != yyssp)
4738         fprintf (stderr, " %d", *++ssp1);
4739       fprintf (stderr, "\n");
4740     }
4741 #endif
4742
4743   *++yyvsp = yyval;
4744
4745 #ifdef YYLSP_NEEDED
4746   yylsp++;
4747   if (yylen == 0)
4748     {
4749       yylsp->first_line = yylloc.first_line;
4750       yylsp->first_column = yylloc.first_column;
4751       yylsp->last_line = (yylsp-1)->last_line;
4752       yylsp->last_column = (yylsp-1)->last_column;
4753       yylsp->text = 0;
4754     }
4755   else
4756     {
4757       yylsp->last_line = (yylsp+yylen-1)->last_line;
4758       yylsp->last_column = (yylsp+yylen-1)->last_column;
4759     }
4760 #endif
4761
4762   /* Now "shift" the result of the reduction.
4763      Determine what state that goes to,
4764      based on the state we popped back to
4765      and the rule number reduced by.  */
4766
4767   yyn = yyr1[yyn];
4768
4769   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4770   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4771     yystate = yytable[yystate];
4772   else
4773     yystate = yydefgoto[yyn - YYNTBASE];
4774
4775   goto yynewstate;
4776
4777 yyerrlab:   /* here on detecting error */
4778
4779   if (! yyerrstatus)
4780     /* If not already recovering from an error, report this error.  */
4781     {
4782       ++yynerrs;
4783
4784 #ifdef YYERROR_VERBOSE
4785       yyn = yypact[yystate];
4786
4787       if (yyn > YYFLAG && yyn < YYLAST)
4788         {
4789           int size = 0;
4790           char *msg;
4791           int x, count;
4792
4793           count = 0;
4794           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
4795           for (x = (yyn < 0 ? -yyn : 0);
4796                x < (sizeof(yytname) / sizeof(char *)); x++)
4797             if (yycheck[x + yyn] == x)
4798               size += strlen(yytname[x]) + 15, count++;
4799           msg = (char *) malloc(size + 15);
4800           if (msg != 0)
4801             {
4802               strcpy(msg, "parse error");
4803
4804               if (count < 5)
4805                 {
4806                   count = 0;
4807                   for (x = (yyn < 0 ? -yyn : 0);
4808                        x < (sizeof(yytname) / sizeof(char *)); x++)
4809                     if (yycheck[x + yyn] == x)
4810                       {
4811                         strcat(msg, count == 0 ? ", expecting `" : " or `");
4812                         strcat(msg, yytname[x]);
4813                         strcat(msg, "'");
4814                         count++;
4815                       }
4816                 }
4817               yyerror(msg);
4818               free(msg);
4819             }
4820           else
4821             yyerror ("parse error; also virtual memory exceeded");
4822         }
4823       else
4824 #endif /* YYERROR_VERBOSE */
4825         yyerror("parse error");
4826     }
4827
4828   goto yyerrlab1;
4829 yyerrlab1:   /* here on error raised explicitly by an action */
4830
4831   if (yyerrstatus == 3)
4832     {
4833       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
4834
4835       /* return failure if at end of input */
4836       if (yychar == YYEOF)
4837         YYABORT;
4838
4839 #if YYDEBUG != 0
4840       if (yydebug)
4841         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4842 #endif
4843
4844       yychar = YYEMPTY;
4845     }
4846
4847   /* Else will try to reuse lookahead token
4848      after shifting the error token.  */
4849
4850   yyerrstatus = 3;              /* Each real token shifted decrements this */
4851
4852   goto yyerrhandle;
4853
4854 yyerrdefault:  /* current state does not do anything special for the error token. */
4855
4856 #if 0
4857   /* This is wrong; only states that explicitly want error tokens
4858      should shift them.  */
4859   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
4860   if (yyn) goto yydefault;
4861 #endif
4862
4863 yyerrpop:   /* pop the current state because it cannot handle the error token */
4864
4865   if (yyssp == yyss) YYABORT;
4866   yyvsp--;
4867   yystate = *--yyssp;
4868 #ifdef YYLSP_NEEDED
4869   yylsp--;
4870 #endif
4871
4872 #if YYDEBUG != 0
4873   if (yydebug)
4874     {
4875       short *ssp1 = yyss - 1;
4876       fprintf (stderr, "Error: state stack now");
4877       while (ssp1 != yyssp)
4878         fprintf (stderr, " %d", *++ssp1);
4879       fprintf (stderr, "\n");
4880     }
4881 #endif
4882
4883 yyerrhandle:
4884
4885   yyn = yypact[yystate];
4886   if (yyn == YYFLAG)
4887     goto yyerrdefault;
4888
4889   yyn += YYTERROR;
4890   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4891     goto yyerrdefault;
4892
4893   yyn = yytable[yyn];
4894   if (yyn < 0)
4895     {
4896       if (yyn == YYFLAG)
4897         goto yyerrpop;
4898       yyn = -yyn;
4899       goto yyreduce;
4900     }
4901   else if (yyn == 0)
4902     goto yyerrpop;
4903
4904   if (yyn == YYFINAL)
4905     YYACCEPT;
4906
4907 #if YYDEBUG != 0
4908   if (yydebug)
4909     fprintf(stderr, "Shifting error token, ");
4910 #endif
4911
4912   *++yyvsp = yylval;
4913 #ifdef YYLSP_NEEDED
4914   *++yylsp = yylloc;
4915 #endif
4916
4917   yystate = yyn;
4918   goto yynewstate;
4919 }
4920 #line 2334 "./parse.y"
4921
4922 \f
4923
4924 /* Flag for the error report routine to issue the error the first time
4925    it's called (overriding the default behavior which is to drop the
4926    first invocation and honor the second one, taking advantage of a
4927    richer context.  */
4928 static int force_error = 0;
4929
4930 /* Create a new parser context and make it the current one. */
4931
4932 void
4933 java_push_parser_context ()
4934 {
4935   struct parser_ctxt *new = 
4936     (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
4937
4938   bzero ((PTR) new, sizeof (struct parser_ctxt));
4939   new->next = ctxp;
4940   ctxp = new;
4941   if (ctxp->next)
4942     {
4943       ctxp->incomplete_class = ctxp->next->incomplete_class;
4944       ctxp->gclass_list = ctxp->next->gclass_list;
4945     }
4946 }  
4947
4948 /* If the first file of a file list was a class file, no context
4949    exists for a source file to be parsed. This boolean remembers that
4950    java_parser_context_save_global might have created a dummy one, so
4951    that java_parser_context_restore_global can pop it.  */
4952 static int extra_ctxp_pushed_p = 0;
4953
4954 void
4955 java_parser_context_save_global ()
4956 {
4957   if (!ctxp)
4958     {
4959       java_push_parser_context ();
4960       extra_ctxp_pushed_p = 1;
4961     }
4962   ctxp->finput = finput;
4963   ctxp->lineno = lineno;
4964   ctxp->current_class = current_class;
4965   ctxp->filename = input_filename;
4966   ctxp->current_function_decl = current_function_decl;
4967 }
4968
4969 void
4970 java_parser_context_restore_global ()
4971 {
4972   finput = ctxp->finput;
4973   lineno = ctxp->lineno;
4974   current_class = ctxp->current_class;
4975   input_filename = ctxp->filename;
4976   current_function_decl = ctxp->current_function_decl;
4977   if (!ctxp->next && extra_ctxp_pushed_p)
4978     {
4979       java_pop_parser_context (0);
4980       extra_ctxp_pushed_p = 0;
4981     }
4982 }
4983
4984 void 
4985 java_pop_parser_context (generate)
4986      int generate;
4987 {
4988   tree current;
4989   struct parser_ctxt *toFree, *next;
4990
4991   if (!ctxp)
4992     return;
4993
4994   toFree = ctxp;
4995   next = ctxp->next;
4996   if (next)
4997     {
4998       next->incomplete_class = ctxp->incomplete_class;
4999       next->gclass_list = ctxp->gclass_list;
5000       lineno = ctxp->lineno;
5001       finput = ctxp->finput;
5002       current_class = ctxp->current_class;
5003     }
5004
5005   /* Set the single import class file flag to 0 for the current list
5006      of imported things */
5007   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5008     IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
5009
5010   /* And restore those of the previous context */
5011   if ((ctxp = next))            /* Assignment is really meant here */
5012     for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5013       IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
5014
5015   if (generate)
5016     {
5017       toFree->next = ctxp_for_generation;
5018       ctxp_for_generation = toFree;
5019     }
5020   else
5021     free (toFree);
5022 }
5023
5024 /* Reporting JDK1.1 features not implemented */
5025
5026 static tree
5027 parse_jdk1_1_error (msg)
5028     const char *msg;
5029 {
5030   sorry (": `%s' JDK1.1(TM) feature", msg);
5031   java_error_count++;
5032   return empty_stmt_node;
5033 }
5034
5035 static int do_warning = 0;
5036
5037 void
5038 yyerror (msg)
5039      const char *msg;
5040 {
5041   static java_lc elc;
5042   static int  prev_lineno;
5043   static const char *prev_msg;
5044
5045   int save_lineno;
5046   char *remainder, *code_from_source;
5047   extern struct obstack temporary_obstack;
5048   
5049   if (!force_error && prev_lineno == lineno)
5050     return;
5051
5052   /* Save current error location but report latter, when the context is
5053      richer.  */
5054   if (ctxp->java_error_flag == 0)
5055     {
5056       ctxp->java_error_flag = 1;
5057       elc = ctxp->elc;
5058       /* Do something to use the previous line if we're reaching the
5059          end of the file... */
5060 #ifdef VERBOSE_SKELETON
5061       printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5062 #endif
5063       return;
5064     }
5065
5066   /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5067   if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5068     return;
5069
5070   ctxp->java_error_flag = 0;
5071   if (do_warning)
5072     java_warning_count++;
5073   else
5074     java_error_count++;
5075   
5076   if (elc.col == 0 && msg[1] == ';')
5077     {
5078       elc.col  = ctxp->p_line->char_col-1;
5079       elc.line = ctxp->p_line->lineno;
5080     }
5081
5082   save_lineno = lineno;
5083   prev_lineno = lineno = elc.line;
5084   prev_msg = msg;
5085
5086   code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5087   obstack_grow0 (&temporary_obstack, 
5088                  code_from_source, strlen (code_from_source));
5089   remainder = obstack_finish (&temporary_obstack);
5090   if (do_warning)
5091     warning ("%s.\n%s", msg, remainder);
5092   else
5093     error ("%s.\n%s", msg, remainder);
5094
5095   /* This allow us to cheaply avoid an extra 'Invalid expression
5096      statement' error report when errors have been already reported on
5097      the same line. This occurs when we report an error but don't have
5098      a synchronization point other than ';', which
5099      expression_statement is the only one to take care of.  */
5100   ctxp->prevent_ese = lineno = save_lineno;
5101 }
5102
5103 static void
5104 issue_warning_error_from_context (cl, msg, ap)
5105      tree cl;
5106      const char *msg;
5107      va_list ap;
5108 {
5109   char *saved, *saved_input_filename;
5110   char buffer [4096];
5111   vsprintf (buffer, msg, ap);
5112   force_error = 1;
5113
5114   ctxp->elc.line = EXPR_WFL_LINENO (cl);
5115   ctxp->elc.col  = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 : 
5116                     (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5117
5118   /* We have a CL, that's a good reason for using it if it contains data */
5119   saved = ctxp->filename;
5120   if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5121     ctxp->filename = EXPR_WFL_FILENAME (cl);
5122   saved_input_filename = input_filename;
5123   input_filename = ctxp->filename;
5124   java_error (NULL);
5125   java_error (buffer);
5126   ctxp->filename = saved;
5127   input_filename = saved_input_filename;
5128   force_error = 0;
5129 }
5130
5131 /* Issue an error message at a current source line CL */
5132
5133 void
5134 parse_error_context VPROTO ((tree cl, const char *msg, ...))
5135 {
5136 #ifndef ANSI_PROTOTYPES
5137   tree cl;
5138   const char *msg;
5139 #endif
5140   va_list ap;
5141
5142   VA_START (ap, msg);
5143 #ifndef ANSI_PROTOTYPES
5144   cl = va_arg (ap, tree);
5145   msg = va_arg (ap, const char *);
5146 #endif
5147   issue_warning_error_from_context (cl, msg, ap);
5148   va_end (ap);
5149 }
5150
5151 /* Issue a warning at a current source line CL */
5152
5153 static void
5154 parse_warning_context VPROTO ((tree cl, const char *msg, ...))
5155 {
5156 #ifndef ANSI_PROTOTYPES
5157   tree cl;
5158   const char *msg;
5159 #endif
5160   va_list ap;
5161
5162   VA_START (ap, msg);
5163 #ifndef ANSI_PROTOTYPES
5164   cl = va_arg (ap, tree);
5165   msg = va_arg (ap, const char *);
5166 #endif
5167
5168   force_error = do_warning = 1;
5169   issue_warning_error_from_context (cl, msg, ap);
5170   do_warning = force_error = 0;
5171   va_end (ap);
5172 }
5173
5174 static tree
5175 find_expr_with_wfl (node)
5176      tree node;
5177 {
5178   while (node)
5179     {
5180       char code;
5181       tree to_return;
5182
5183       switch (TREE_CODE (node))
5184         {
5185         case BLOCK:
5186           node = BLOCK_EXPR_BODY (node);
5187           continue;
5188
5189         case COMPOUND_EXPR:
5190           to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
5191           if (to_return)
5192             return to_return;
5193           node = TREE_OPERAND (node, 1);
5194           continue;
5195
5196         case LOOP_EXPR:
5197           node = TREE_OPERAND (node, 0);
5198           continue;
5199           
5200         case LABELED_BLOCK_EXPR:
5201           node = TREE_OPERAND (node, 1);
5202           continue;
5203
5204         default:
5205           code = TREE_CODE_CLASS (TREE_CODE (node));
5206           if (((code == '1') || (code == '2') || (code == 'e'))
5207               && EXPR_WFL_LINECOL (node))
5208             return node;
5209           return NULL_TREE;
5210         }
5211     }
5212   return NULL_TREE;
5213 }
5214
5215 /* Issue a missing return statement error. Uses METHOD to figure the
5216    last line of the method the error occurs in.  */
5217
5218 static void
5219 missing_return_error (method)
5220      tree method;
5221 {
5222   EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
5223   parse_error_context (wfl_operator, "Missing return statement");
5224 }
5225
5226 /* Issue an unreachable statement error. From NODE, find the next
5227    statement to report appropriately.  */
5228 static void
5229 unreachable_stmt_error (node)
5230      tree node;
5231 {
5232   /* Browse node to find the next expression node that has a WFL. Use
5233      the location to report the error */
5234   if (TREE_CODE (node) == COMPOUND_EXPR)
5235     node = find_expr_with_wfl (TREE_OPERAND (node, 1));
5236   else
5237     node = find_expr_with_wfl (node);
5238
5239   if (node)
5240     {
5241       EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
5242       parse_error_context (wfl_operator, "Unreachable statement");
5243     }
5244   else
5245     fatal ("Can't get valid statement - unreachable_stmt_error");
5246 }
5247
5248 int
5249 java_report_errors ()
5250 {
5251   if (java_error_count)
5252     fprintf (stderr, "%d error%s", 
5253              java_error_count, (java_error_count == 1 ? "" : "s"));
5254   if (java_warning_count)
5255     fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
5256              java_warning_count, (java_warning_count == 1 ? "" : "s"));
5257   if (java_error_count || java_warning_count)
5258     putc ('\n', stderr);
5259   return java_error_count;
5260 }
5261
5262 static char *
5263 java_accstring_lookup (flags)
5264      int flags;
5265 {
5266   static char buffer [80];
5267 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
5268
5269   /* Access modifier looked-up first for easier report on forbidden
5270      access. */
5271   if (flags & ACC_PUBLIC) COPY_RETURN ("public");
5272   if (flags & ACC_PRIVATE) COPY_RETURN ("private");
5273   if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
5274   if (flags & ACC_STATIC) COPY_RETURN ("static");
5275   if (flags & ACC_FINAL) COPY_RETURN ("final");
5276   if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
5277   if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
5278   if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
5279   if (flags & ACC_NATIVE) COPY_RETURN ("native");
5280   if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
5281   if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
5282
5283   buffer [0] = '\0';
5284   return buffer;
5285 #undef COPY_RETURN
5286 }
5287
5288 /* Issuing error messages upon redefinition of classes, interfaces or
5289    variables. */
5290
5291 static void
5292 classitf_redefinition_error (context, id, decl, cl)
5293      const char *context;
5294      tree id, decl, cl;
5295 {
5296   parse_error_context (cl, "%s `%s' already defined in %s:%d", 
5297                        context, IDENTIFIER_POINTER (id), 
5298                        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5299   /* Here we should point out where its redefined. It's a unicode. FIXME */
5300 }
5301
5302 static void
5303 variable_redefinition_error (context, name, type, line)
5304      tree context, name, type;
5305      int line;
5306 {
5307   const char *type_name;
5308
5309   /* Figure a proper name for type. We might haven't resolved it */
5310   if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
5311     type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
5312   else
5313     type_name = lang_printable_name (type, 0);
5314
5315   parse_error_context (context,
5316                        "Variable `%s' is already defined in this method and "
5317                        "was declared `%s %s' at line %d", 
5318                        IDENTIFIER_POINTER (name),
5319                        type_name, IDENTIFIER_POINTER (name), line);
5320 }
5321
5322 static tree
5323 build_array_from_name (type, type_wfl, name, ret_name)
5324      tree type, type_wfl, name, *ret_name;
5325 {
5326   int more_dims = 0;
5327   const char *string;
5328
5329   /* Eventually get more dims */
5330   string = IDENTIFIER_POINTER (name);
5331   while (string [more_dims] == '[')
5332     more_dims++;
5333   
5334   /* If we have, then craft a new type for this variable */
5335   if (more_dims)
5336     {
5337       name = get_identifier (&string [more_dims]);
5338
5339       /* If we have a pointer, use its type */
5340       if (TREE_CODE (type) == POINTER_TYPE)
5341         type = TREE_TYPE (type);
5342
5343       /* Building the first dimension of a primitive type uses this
5344          function */
5345       if (JPRIMITIVE_TYPE_P (type))
5346         {
5347           type = build_java_array_type (type, -1);
5348           CLASS_LOADED_P (type) = 1;
5349           more_dims--;
5350         }
5351       /* Otherwise, if we have a WFL for this type, use it (the type
5352          is already an array on an unresolved type, and we just keep
5353          on adding dimensions) */
5354       else if (type_wfl)
5355         type = type_wfl;
5356
5357       /* Add all the dimensions */
5358       while (more_dims--)
5359         type = build_unresolved_array_type (type);
5360
5361       /* The type may have been incomplete in the first place */
5362       if (type_wfl)
5363         type = obtain_incomplete_type (type);
5364     }
5365
5366   *ret_name = name;
5367   return type;
5368 }
5369
5370 /* Build something that the type identifier resolver will identify as
5371    being an array to an unresolved type. TYPE_WFL is a WFL on a
5372    identifier. */
5373
5374 static tree
5375 build_unresolved_array_type (type_or_wfl)
5376      tree type_or_wfl;
5377 {
5378   const char *ptr;
5379
5380   /* TYPE_OR_WFL might be an array on a resolved type. In this case,
5381      just create a array type */
5382   if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5383     {
5384       tree type = build_java_array_type (type_or_wfl, -1);
5385       CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5386       return type;
5387     }
5388
5389   obstack_1grow (&temporary_obstack, '[');
5390   obstack_grow0 (&temporary_obstack,
5391                  IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5392                  IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5393   ptr = obstack_finish (&temporary_obstack);
5394   return build_expr_wfl (get_identifier (ptr),
5395                          EXPR_WFL_FILENAME (type_or_wfl),
5396                          EXPR_WFL_LINENO (type_or_wfl),
5397                          EXPR_WFL_COLNO (type_or_wfl));
5398 }
5399
5400 /* Check modifiers. If one doesn't fit, retrieve it in its declaration line
5401   and point it out.  */
5402
5403 static void
5404 check_modifiers (message, value, mask)
5405      const char *message;
5406      int value;
5407      int mask;
5408 {
5409   /* Should point out the one that don't fit. ASCII/unicode,
5410      going backward. FIXME */
5411   if (value & ~mask)
5412     {
5413       int i, remainder = value & ~mask;
5414       for (i = 0; i <= 10; i++)
5415         if ((1 << i) & remainder)
5416           parse_error_context (ctxp->modifier_ctx [i], message, 
5417                                java_accstring_lookup (1 << i));
5418     }
5419 }
5420
5421 static void
5422 parser_add_interface (class_decl, interface_decl, wfl)
5423      tree class_decl, interface_decl, wfl;
5424 {
5425   if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5426     parse_error_context (wfl, "Interface `%s' repeated",
5427                          IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5428 }
5429
5430 /* Bulk of common class/interface checks. Return 1 if an error was
5431    encountered. TAG is 0 for a class, 1 for an interface.  */
5432
5433 static int
5434 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5435      int is_interface, flags;
5436      tree raw_name, qualified_name, decl, cl;
5437 {
5438   tree node;
5439
5440   if (!quiet_flag)
5441     fprintf (stderr, " %s %s", (is_interface ? "interface" : "class"), 
5442              IDENTIFIER_POINTER (qualified_name));
5443
5444   /* Scope of an interface/class type name:
5445        - Can't be imported by a single type import
5446        - Can't already exists in the package */
5447   if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5448       && (node = find_name_in_single_imports (raw_name)))
5449     {
5450       parse_error_context 
5451         (cl, "%s name `%s' clashes with imported type `%s'",
5452          (is_interface ? "Interface" : "Class"),
5453          IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
5454       return 1;
5455     }
5456   if (decl && CLASS_COMPLETE_P (decl))
5457     {
5458       classitf_redefinition_error ((is_interface ? "Interface" : "Class"), 
5459                                    qualified_name, decl, cl);
5460       return 1;
5461     }
5462
5463   /* If public, file name should match class/interface name */
5464   if (flags & ACC_PUBLIC)
5465     {
5466       const char *f;
5467
5468       /* Contains OS dependent assumption on path separator. FIXME */
5469       for (f = &input_filename [strlen (input_filename)]; 
5470            f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR;
5471            f--)
5472         ;
5473       if (f[0] == '/' || f[0] == DIR_SEPARATOR)
5474         f++;
5475       if (strncmp (IDENTIFIER_POINTER (raw_name), 
5476                    f , IDENTIFIER_LENGTH (raw_name)) ||
5477           f [IDENTIFIER_LENGTH (raw_name)] != '.')
5478         parse_error_context (cl, "Public %s `%s' must be defined in a file "
5479                              "called `%s.java'", 
5480                              (is_interface ? "interface" : "class"),
5481                              IDENTIFIER_POINTER (qualified_name),
5482                              IDENTIFIER_POINTER (raw_name));
5483     }
5484
5485   check_modifiers ((is_interface ? 
5486                     "Illegal modifier `%s' for interface declaration" :
5487                     "Illegal modifier `%s' for class declaration"), flags,
5488                    (is_interface ? INTERFACE_MODIFIERS : CLASS_MODIFIERS));
5489   return 0;
5490 }
5491
5492 /* If DECL is NULL, create and push a new DECL, record the current
5493    line CL and do other maintenance things.  */
5494
5495 static tree
5496 maybe_create_class_interface_decl (decl, qualified_name, cl)
5497      tree decl, qualified_name, cl;
5498 {
5499   if (!decl)
5500     decl = push_class (make_class (), qualified_name);
5501   
5502   /* Take care of the file and line business */
5503   DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
5504   /* If we're emiting xrefs, store the line/col number information */
5505   if (flag_emit_xref)
5506     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
5507   else
5508     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
5509   CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
5510   CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
5511     IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
5512
5513   ctxp->current_parsed_class = decl;
5514   
5515   /* Link the declaration to the already seen ones */
5516   TREE_CHAIN (decl) = ctxp->class_list;
5517   ctxp->class_list = decl;
5518
5519   /* Create a new nodes in the global lists */
5520   ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
5521   all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
5522
5523   /* Install a new dependency list element */
5524   create_jdep_list (ctxp);
5525
5526   SOURCE_FRONTEND_DEBUG (("Defining class/interface %s", 
5527                           IDENTIFIER_POINTER (qualified_name)));
5528   return decl;
5529 }
5530
5531 static void
5532 add_superinterfaces (decl, interface_list)
5533      tree decl, interface_list;
5534 {
5535   tree node;
5536   /* Superinterface(s): if present and defined, parser_check_super_interface ()
5537      takes care of ensuring that:
5538        - This is an accessible interface type,
5539        - Circularity detection.
5540    parser_add_interface is then called. If present but not defined,
5541    the check operation is delayed until the super interface gets
5542    defined.  */
5543   for (node = interface_list; node; node = TREE_CHAIN (node))
5544     {
5545       tree current = TREE_PURPOSE (node);
5546       tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
5547       if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
5548         {
5549           if (!parser_check_super_interface (idecl, decl, current))
5550             parser_add_interface (decl, idecl, current);
5551         }
5552       else
5553         register_incomplete_type (JDEP_INTERFACE,
5554                                   current, decl, NULL_TREE);
5555     }
5556 }
5557
5558 /* Create an interface in pass1 and return its decl. Return the
5559    interface's decl in pass 2.  */
5560
5561 static tree
5562 create_interface (flags, id, super)
5563      int flags;
5564      tree id, super;
5565 {
5566   tree raw_name = EXPR_WFL_NODE (id);
5567   tree q_name = parser_qualified_classname (id);
5568   tree decl = IDENTIFIER_CLASS_VALUE (q_name);
5569
5570   EXPR_WFL_NODE (id) = q_name;  /* Keep source location, even if refined. */
5571
5572   /* Basic checks: scope, redefinition, modifiers */ 
5573   if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
5574     return NULL_TREE;
5575
5576   /* Interface modifiers check
5577        - public/abstract allowed (already done at that point)
5578        - abstract is obsolete (comes first, it's a warning, or should be)
5579        - Can't use twice the same (checked in the modifier rule) */
5580   if ((flags & ACC_ABSTRACT) && flag_redundant)
5581     parse_warning_context 
5582       (MODIFIER_WFL (ABSTRACT_TK),
5583        "Redundant use of `abstract' modifier. Interface `%s' is implicitely "
5584        "abstract", IDENTIFIER_POINTER (raw_name));
5585
5586   /* Create a new decl if DECL is NULL, otherwise fix it */
5587   decl = maybe_create_class_interface_decl (decl, q_name, id);
5588
5589   /* Set super info and mark the class a complete */
5590   set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl), 
5591                   object_type_node, ctxp->interface_number);
5592   ctxp->interface_number = 0;
5593   CLASS_COMPLETE_P (decl) = 1;
5594   add_superinterfaces (decl, super);
5595
5596   return decl;
5597 }
5598
5599 /* Create an class in pass1 and return its decl. Return class
5600    interface's decl in pass 2.  */
5601
5602 static tree
5603 create_class (flags, id, super, interfaces)
5604      int flags;
5605      tree id, super, interfaces;
5606 {
5607   tree raw_name = EXPR_WFL_NODE (id);
5608   tree class_id, decl;
5609   tree super_decl_type;
5610
5611   class_id = parser_qualified_classname (id);
5612   decl = IDENTIFIER_CLASS_VALUE (class_id);
5613   ctxp->current_parsed_class_un = EXPR_WFL_NODE (id);
5614   EXPR_WFL_NODE (id) = class_id;
5615
5616   /* Basic check: scope, redefinition, modifiers */
5617   if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
5618     return NULL_TREE;
5619
5620   /* Class modifier check: 
5621        - Allowed modifier (already done at that point)
5622        - abstract AND final forbidden 
5623        - Public classes defined in the correct file */
5624   if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
5625     parse_error_context (id, "Class `%s' can't be declared both abstract "
5626                          "and final", IDENTIFIER_POINTER (raw_name));
5627
5628   /* Create a new decl if DECL is NULL, otherwise fix it */
5629   decl = maybe_create_class_interface_decl (decl, class_id, id);
5630
5631   /* If SUPER exists, use it, otherwise use Object */
5632   if (super)
5633     {
5634       /* Can't extend java.lang.Object */
5635       if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
5636         {
5637           parse_error_context (id, "Can't extend `java.lang.Object'");
5638           return NULL_TREE;
5639         }
5640
5641       super_decl_type = 
5642         register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
5643     }
5644   else if (TREE_TYPE (decl) != object_type_node)
5645     super_decl_type = object_type_node;
5646   /* We're defining java.lang.Object */
5647   else
5648     super_decl_type = NULL_TREE;
5649
5650   /* Set super info and mark the class a complete */
5651   set_super_info (flags, TREE_TYPE (decl), super_decl_type, 
5652                   ctxp->interface_number);
5653   ctxp->interface_number = 0;
5654   CLASS_COMPLETE_P (decl) = 1;
5655   add_superinterfaces (decl, interfaces);
5656
5657   /* If doing xref, store the location at which the inherited class
5658      (if any) was seen. */
5659   if (flag_emit_xref && super)
5660     DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
5661
5662   /* Eventually sets the @deprecated tag flag */
5663   CHECK_DEPRECATED (decl);
5664
5665   return decl;
5666 }
5667
5668 /* Can't use lookup_field () since we don't want to load the class and
5669    can't set the CLASS_LOADED_P flag */
5670
5671 static tree
5672 find_field (class, name)
5673      tree class;
5674      tree name;
5675 {
5676   tree decl;
5677   for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
5678     {
5679       if (DECL_NAME (decl) == name)
5680         return decl;
5681     }
5682   return NULL_TREE;
5683 }
5684
5685 /* Wrap around lookup_field that doesn't potentially upset the value
5686    of CLASS */
5687
5688 static tree
5689 lookup_field_wrapper (class, name)
5690      tree class, name;
5691 {
5692   tree type = class;
5693   tree decl;
5694   java_parser_context_save_global ();
5695   decl = lookup_field (&type, name);
5696   java_parser_context_restore_global ();
5697   return decl == error_mark_node ? NULL : decl;
5698 }
5699
5700 /* Find duplicate field within the same class declarations and report
5701    the error. Returns 1 if a duplicated field was found, 0
5702    otherwise.  */
5703
5704 static int
5705 duplicate_declaration_error_p (new_field_name, new_type, cl)
5706      tree new_field_name, new_type, cl;
5707 {
5708   /* This might be modified to work with method decl as well */
5709   tree decl = find_field (TREE_TYPE (ctxp->current_parsed_class), 
5710                           new_field_name);
5711   if (decl)
5712     {
5713       char *t1 = xstrdup (purify_type_name
5714                          ((TREE_CODE (new_type) == POINTER_TYPE 
5715                            && TREE_TYPE (new_type) == NULL_TREE) ?
5716                           IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
5717                           lang_printable_name (new_type, 1)));
5718       /* The type may not have been completed by the time we report
5719          the error */
5720       char *t2 = xstrdup (purify_type_name
5721                          ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE 
5722                            && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
5723                           IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
5724                           lang_printable_name (TREE_TYPE (decl), 1)));
5725       parse_error_context 
5726         (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)", 
5727          t1, IDENTIFIER_POINTER (new_field_name),
5728          t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
5729          DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5730       free (t1);
5731       free (t2);
5732       return 1;
5733     }
5734   return 0;
5735 }
5736
5737 /* Field registration routine. If TYPE doesn't exist, field
5738    declarations are linked to the undefined TYPE dependency list, to
5739    be later resolved in java_complete_class () */
5740
5741 static void
5742 register_fields (flags, type, variable_list)
5743      int flags;
5744      tree type, variable_list;
5745 {
5746   tree current, saved_type;
5747   tree class_type = TREE_TYPE (ctxp->current_parsed_class);
5748   int saved_lineno = lineno;
5749   int must_chain = 0;
5750   tree wfl = NULL_TREE;
5751
5752   /* If we're adding fields to interfaces, those fields are public,
5753      static, final */
5754   if (CLASS_INTERFACE (TYPE_NAME (class_type)))
5755     {
5756       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
5757                                  flags, ACC_PUBLIC, 
5758                                  "%s", "interface field(s)");
5759       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
5760                                  flags, ACC_STATIC, 
5761                                  "%s", "interface field(s)");
5762       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
5763                                  flags, ACC_FINAL, "%s", "interface field(s)");
5764       check_modifiers ("Illegal interface member modifier `%s'", flags,
5765                        INTERFACE_FIELD_MODIFIERS);
5766       flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
5767     }
5768
5769   /* Obtain a suitable type for resolution, if necessary */
5770   SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
5771
5772   /* If TYPE is fully resolved and we don't have a reference, make one */
5773   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
5774
5775   for (current = variable_list, saved_type = type; current; 
5776        current = TREE_CHAIN (current), type = saved_type)
5777     {
5778       tree real_type;
5779       tree field_decl;
5780       tree cl = TREE_PURPOSE (current);
5781       tree init = TREE_VALUE (current);
5782       tree current_name = EXPR_WFL_NODE (cl);
5783
5784       /* Process NAME, as it may specify extra dimension(s) for it */
5785       type = build_array_from_name (type, wfl, current_name, &current_name);
5786
5787       /* Type adjustment. We may have just readjusted TYPE because
5788          the variable specified more dimensions. Make sure we have
5789          a reference if we can and don't have one already. Also
5790          change the name if we have an init. */
5791       if (type != saved_type)
5792         {
5793           PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
5794           if (init)
5795             EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
5796         }
5797
5798       real_type = GET_REAL_TYPE (type);
5799       /* Check for redeclarations */
5800       if (duplicate_declaration_error_p (current_name, real_type, cl))
5801         continue;
5802
5803       /* Set lineno to the line the field was found and create a
5804          declaration for it. Eventually sets the @deprecated tag flag. */
5805       if (flag_emit_xref)
5806         lineno = EXPR_WFL_LINECOL (cl);
5807       else
5808         lineno = EXPR_WFL_LINENO (cl);
5809       field_decl = add_field (class_type, current_name, real_type, flags);
5810       CHECK_DEPRECATED (field_decl);
5811       
5812       /* Check if we must chain. */
5813       if (must_chain)
5814         register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
5815           
5816       /* If we have an initialization value tied to the field */
5817       if (init)
5818         {
5819           /* The field is declared static */
5820           if (flags & ACC_STATIC)
5821             {
5822               /* We include the field and its initialization part into
5823                  a list used to generate <clinit>. After <clinit> is
5824                  walked, field initializations will be processed and
5825                  fields initialized with known constants will be taken
5826                  out of <clinit> and have their DECL_INITIAL set
5827                  appropriately. */
5828               TREE_CHAIN (init) = ctxp->static_initialized;
5829               ctxp->static_initialized = init;
5830               if (TREE_OPERAND (init, 1) 
5831                   && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
5832                 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
5833             }
5834           /* A non-static field declared with an immediate initialization is
5835              to be initialized in <init>, if any.  This field is remembered
5836              to be processed at the time of the generation of <init>. */
5837           else
5838             {
5839               TREE_CHAIN (init) = ctxp->non_static_initialized;
5840               ctxp->non_static_initialized = init;
5841             }
5842           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
5843           DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
5844         }
5845     }
5846   lineno = saved_lineno;
5847 }
5848
5849 /* Generate the method $finit$ that initializes fields initialized
5850    upon declaration.  */
5851
5852 static void
5853 maybe_generate_finit ()
5854 {
5855   tree mdecl, current;
5856   
5857   if (!ctxp->non_static_initialized || java_error_count)
5858     return;
5859
5860   mdecl = create_artificial_method (TREE_TYPE (ctxp->current_parsed_class),
5861                                     ACC_PRIVATE, void_type_node,
5862                                     finit_identifier_node, end_params_node);
5863   start_artificial_method_body (mdecl);
5864
5865   ctxp->non_static_initialized = nreverse (ctxp->non_static_initialized);
5866   for (current = ctxp->non_static_initialized; current;
5867        current = TREE_CHAIN (current))
5868     java_method_add_stmt (mdecl, 
5869                           build_debugable_stmt (EXPR_WFL_LINECOL (current), 
5870                                                 current));
5871
5872   end_artificial_method_body (mdecl);
5873   CLASS_HAS_FINIT_P (TREE_TYPE (ctxp->current_parsed_class)) = 1;
5874   ctxp->non_static_initialized = NULL_TREE;
5875 }
5876
5877 /* Check whether it is necessary to generate a <clinit> for the class
5878    we just parsed. */
5879
5880 static void
5881 maybe_generate_clinit ()
5882 {
5883   tree mdecl, c;
5884
5885   if (!ctxp->static_initialized || java_error_count)
5886     return;
5887
5888   mdecl = create_artificial_method (TREE_TYPE (ctxp->current_parsed_class),
5889                                     ACC_STATIC, void_type_node,
5890                                     clinit_identifier_node, end_params_node);
5891   start_artificial_method_body (mdecl);
5892
5893   /* Keep initialization in order to enforce 8.5 */
5894   ctxp->static_initialized = nreverse (ctxp->static_initialized);
5895
5896   /* We process the list of assignment we produced as the result of
5897      the declaration of initialized static field and add them as
5898      statement to the <clinit> method. */
5899   for (c = ctxp->static_initialized; c; c = TREE_CHAIN (c))
5900     {
5901       /* We build the assignment expression that will initialize the
5902          field to its value. There are strict rules on static
5903          initializers (8.5). FIXME */
5904       java_method_add_stmt (mdecl, 
5905                             build_debugable_stmt (EXPR_WFL_LINECOL (c), c));
5906     }
5907
5908   end_artificial_method_body (mdecl);
5909   ctxp->static_initialized = NULL_TREE;
5910 }
5911
5912 /* Shared accros method_declarator and method_header to remember the
5913    patch stage that was reached during the declaration of the method.
5914    A method DECL is built differently is there is no patch
5915    (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
5916    pending on the currently defined method.  */
5917
5918 static int patch_stage;
5919
5920 /* Check the method declaration and add the method to its current
5921    class.  If the argument list is known to contain incomplete types,
5922    the method is partially added and the registration will be resume
5923    once the method arguments resolved. If TYPE is NULL, we're dealing
5924    with a constructor.  */
5925
5926 static tree
5927 method_header (flags, type, mdecl, throws)
5928      int flags;
5929      tree type, mdecl, throws;
5930 {
5931   tree meth = TREE_VALUE (mdecl);
5932   tree id = TREE_PURPOSE (mdecl);
5933   tree type_wfl = NULL_TREE;
5934   tree meth_name = NULL_TREE;
5935   tree current, orig_arg, this_class;
5936   int saved_lineno;
5937   int constructor_ok = 0, must_chain;
5938   
5939   check_modifiers_consistency (flags);
5940
5941   if (ctxp->current_parsed_class)
5942     this_class = TREE_TYPE (ctxp->current_parsed_class);
5943   else
5944     return NULL_TREE;
5945   
5946   /* There are some forbidden modifiers for an abstract method and its
5947      class must be abstract as well.  */
5948   if (type && (flags & ACC_ABSTRACT))
5949     {
5950       ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
5951       ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
5952       ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
5953       ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
5954       ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
5955       if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
5956           && !CLASS_INTERFACE (TYPE_NAME (this_class)))
5957         parse_error_context 
5958           (id, "Class `%s' must be declared abstract to define abstract "
5959            "method `%s'", 
5960            IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
5961            IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
5962     }
5963   /* Things to be checked when declaring a constructor */
5964   if (!type)
5965     {
5966       int ec = java_error_count;
5967       /* 8.6: Constructor declarations: we might be trying to define a
5968          method without specifying a return type. */
5969       if (EXPR_WFL_NODE (id) != ctxp->current_parsed_class_un)
5970         parse_error_context 
5971           (id, "Invalid method declaration, return type required");
5972       /* 8.6.3: Constructor modifiers */
5973       else
5974         {
5975           JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
5976           JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
5977           JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
5978           JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
5979           JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
5980         }
5981       /* If we found error here, we don't consider it's OK to tread
5982          the method definition as a constructor, for the rest of this
5983          function */
5984       if (ec == java_error_count)
5985         constructor_ok = 1;
5986     }
5987
5988   /* Method declared within the scope of an interface are implicitly
5989      abstract and public. Conflicts with other erroneously provided
5990      modifiers are checked right after. */
5991
5992   if (CLASS_INTERFACE (TYPE_NAME (this_class)))
5993     {
5994       /* If FLAGS isn't set because of a modifier, turn the
5995          corresponding modifier WFL to NULL so we issue a warning on
5996          the obsolete use of the modifier */
5997       if (!(flags & ACC_PUBLIC))
5998         MODIFIER_WFL (PUBLIC_TK) = NULL;
5999       if (!(flags & ACC_ABSTRACT))
6000         MODIFIER_WFL (ABSTRACT_TK) = NULL;
6001       flags |= ACC_PUBLIC;
6002       flags |= ACC_ABSTRACT;
6003     }
6004
6005   /* Modifiers context reset moved up, so abstract method declaration
6006      modifiers can be later checked.  */
6007
6008   /* Set constructor returned type to void and method name to <init>,
6009      unless we found an error identifier the constructor (in which
6010      case we retain the original name) */
6011   if (!type)
6012     {
6013       type = void_type_node;
6014       if (constructor_ok)
6015         meth_name = init_identifier_node;
6016     }
6017   else
6018     meth_name = EXPR_WFL_NODE (id);
6019
6020   /* Do the returned type resolution and registration if necessary */
6021   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
6022
6023   if (meth_name)
6024     type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
6025   EXPR_WFL_NODE (id) = meth_name;
6026   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6027
6028   if (must_chain)
6029     {
6030       patch_stage = JDEP_METHOD_RETURN;
6031       register_incomplete_type (patch_stage, type_wfl, id, type);
6032       TREE_TYPE (meth) = GET_REAL_TYPE (type);
6033     }
6034   else
6035     TREE_TYPE (meth) = type;
6036
6037   saved_lineno = lineno;
6038   /* When defining an abstract or interface method, the curly
6039      bracket at level 1 doesn't exist because there is no function
6040      body */
6041   lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 : 
6042             EXPR_WFL_LINENO (id));
6043
6044   /* Remember the original argument list */
6045   orig_arg = TYPE_ARG_TYPES (meth);
6046
6047   if (patch_stage)              /* includes ret type and/or all args */
6048     {
6049       jdep *jdep;
6050       meth = add_method_1 (this_class, flags, meth_name, meth);
6051       /* Patch for the return type */
6052       if (patch_stage == JDEP_METHOD_RETURN)
6053         {
6054           jdep = CLASSD_LAST (ctxp->classd_list);
6055           JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
6056         }
6057       /* This is the stop JDEP. METH allows the function's signature
6058          to be computed. */
6059       register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
6060     }
6061   else
6062     meth = add_method (this_class, flags, meth_name, 
6063                        build_java_signature (meth));
6064
6065   /* Fix the method argument list so we have the argument name
6066      information */
6067   fix_method_argument_names (orig_arg, meth);
6068
6069   /* Register the parameter number and re-install the current line
6070      number */
6071   DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
6072   lineno = saved_lineno;
6073
6074   /* Register exception specified by the `throws' keyword for
6075      resolution and set the method decl appropriate field to the list.
6076      Note: the grammar ensures that what we get here are class
6077      types. */
6078   if (throws)
6079     {
6080       throws = nreverse (throws);
6081       for (current = throws; current; current = TREE_CHAIN (current))
6082         {
6083           register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
6084                                     NULL_TREE, NULL_TREE);
6085           JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) = 
6086             &TREE_VALUE (current);
6087         }
6088       DECL_FUNCTION_THROWS (meth) = throws;
6089     }
6090
6091   /* We set the DECL_NAME to ID so we can track the location where
6092      the function was declared. This allow us to report
6093      redefinition error accurately. When method are verified,
6094      DECL_NAME is reinstalled properly (using the content of the
6095      WFL node ID) (see check_method_redefinition). We don't do that
6096      when Object is being defined. Constructor <init> names will be
6097      reinstalled the same way. */
6098   if (TREE_TYPE (ctxp->current_parsed_class) != object_type_node)
6099     DECL_NAME (meth) = id;
6100
6101   /* Set the flag if we correctly processed a constructor */
6102   if (constructor_ok)
6103     DECL_CONSTRUCTOR_P (meth) = 1;
6104
6105   /* Eventually set the @deprecated tag flag */
6106   CHECK_DEPRECATED (meth);
6107
6108   /* If doing xref, store column and line number information instead
6109      of the line number only. */
6110   if (flag_emit_xref)
6111     DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
6112
6113   return meth;
6114 }
6115
6116 static void
6117 fix_method_argument_names (orig_arg, meth)
6118     tree orig_arg, meth;
6119 {
6120   tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
6121   if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
6122     {
6123       TREE_PURPOSE (arg) = this_identifier_node;
6124       arg = TREE_CHAIN (arg);
6125     }
6126   while (orig_arg != end_params_node)
6127     {
6128       TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
6129       orig_arg = TREE_CHAIN (orig_arg);
6130       arg = TREE_CHAIN (arg);
6131     }
6132 }
6133
6134 /* Complete the method declaration with METHOD_BODY.  */
6135
6136 static void
6137 finish_method_declaration (method_body)
6138      tree method_body;
6139 {
6140   int flags;
6141
6142   if (!current_function_decl)
6143     return;
6144
6145   flags = get_access_flags_from_decl (current_function_decl);
6146
6147   /* 8.4.5 Method Body */
6148   if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
6149     {
6150       tree wfl = DECL_NAME (current_function_decl);
6151       parse_error_context (wfl, 
6152                            "%s method `%s' can't have a body defined",
6153                            (METHOD_NATIVE (current_function_decl) ?
6154                             "Native" : "Abstract"),
6155                            IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
6156       method_body = NULL_TREE;
6157     }
6158   else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
6159     {
6160       tree wfl = DECL_NAME (current_function_decl);
6161       parse_error_context (wfl, 
6162                            "Non native and non abstract method `%s' must "
6163                            "have a body defined",
6164                            IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
6165       method_body = NULL_TREE;
6166     }
6167
6168   if (flag_emit_class_files && method_body 
6169       && TREE_CODE (method_body) == NOP_EXPR 
6170       && TREE_TYPE (current_function_decl) 
6171       && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
6172     method_body = build1 (RETURN_EXPR, void_type_node, NULL);
6173     
6174   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
6175   maybe_absorb_scoping_blocks ();
6176   /* Exit function's body */
6177   exit_block ();
6178   /* Merge last line of the function with first line, directly in the
6179      function decl. It will be used to emit correct debug info. */
6180   if (!flag_emit_xref)
6181     DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
6182   /* So we don't have an irrelevant function declaration context for
6183      the next static block we'll see. */
6184   current_function_decl = NULL_TREE;
6185 }
6186
6187 /* Build a an error message for constructor circularity errors.  */
6188
6189 static char *
6190 constructor_circularity_msg (from, to)
6191      tree from, to;
6192 {
6193   static char string [4096];
6194   char *t = xstrdup (lang_printable_name (from, 0));
6195   sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
6196   free (t);
6197   return string;
6198 }
6199
6200 /* Verify a circular call to METH. Return 1 if an error is found, 0
6201    otherwise.  */
6202
6203 static int
6204 verify_constructor_circularity (meth, current)
6205      tree meth, current;
6206 {
6207   static tree list = NULL_TREE;
6208   tree c;
6209   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
6210     {
6211       if (TREE_VALUE (c) == meth)
6212         {
6213           char *t;
6214           if (list)
6215             {
6216               tree liste;
6217               list = nreverse (list);
6218               for (liste = list; liste; liste = TREE_CHAIN (liste))
6219                 {
6220                   parse_error_context 
6221                     (TREE_PURPOSE (TREE_PURPOSE (liste)),
6222                      constructor_circularity_msg
6223                       (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste)))); 
6224                   java_error_count--;
6225                 }
6226             }
6227           t = xstrdup (lang_printable_name (meth, 0));
6228           parse_error_context (TREE_PURPOSE (c), 
6229                                "%s: recursive invocation of constructor `%s'",
6230                                constructor_circularity_msg (current, meth), t);
6231           free (t);
6232           list = NULL_TREE;
6233           return 1;
6234         }
6235     }
6236   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
6237     {
6238       list = tree_cons (c, current, list);
6239       if (verify_constructor_circularity (meth, TREE_VALUE (c)))
6240         return 1;
6241       list = TREE_CHAIN (list);
6242     }
6243   return 0;
6244 }
6245
6246 /* Check modifiers that can be declared but exclusively */
6247
6248 static void
6249 check_modifiers_consistency (flags)
6250      int flags;
6251 {
6252   int acc_count = 0;
6253   tree cl = NULL_TREE;
6254
6255   THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, 0, acc_count, cl);
6256   THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, 1, acc_count, cl);
6257   THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, 2, acc_count, cl);
6258   if (acc_count > 1)
6259     parse_error_context
6260       (cl, "Inconsistent member declaration. At most one of `public', "
6261        "`private', or `protected' may be specified");
6262 }
6263
6264 /* Check the methode header METH for abstract specifics features */
6265
6266 static void
6267 check_abstract_method_header (meth)
6268      tree meth;
6269 {
6270   int flags = get_access_flags_from_decl (meth);
6271   /* DECL_NAME might still be a WFL node */
6272   tree name = GET_METHOD_NAME (meth);
6273
6274   OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (ABSTRACT_TK), flags,
6275                              ACC_ABSTRACT, "abstract method `%s'",
6276                              IDENTIFIER_POINTER (name));
6277   OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK), flags, 
6278                              ACC_PUBLIC, "abstract method `%s'",
6279                              IDENTIFIER_POINTER (name));
6280
6281   check_modifiers ("Illegal modifier `%s' for interface method",
6282                   flags, INTERFACE_METHOD_MODIFIERS);
6283 }
6284
6285 /* Create a FUNCTION_TYPE node and start augmenting it with the
6286    declared function arguments. Arguments type that can't be resolved
6287    are left as they are, but the returned node is marked as containing
6288    incomplete types.  */
6289
6290 static tree
6291 method_declarator (id, list)
6292      tree id, list;
6293 {
6294   tree arg_types = NULL_TREE, current, node;
6295   tree meth = make_node (FUNCTION_TYPE);
6296   jdep *jdep;
6297
6298   patch_stage = JDEP_NO_PATCH;
6299   
6300   for (current = list; current; current = TREE_CHAIN (current))
6301     {
6302       int must_chain = 0;
6303       tree wfl_name = TREE_PURPOSE (current);
6304       tree type = TREE_VALUE (current);
6305       tree name = EXPR_WFL_NODE (wfl_name);
6306       tree already, arg_node;
6307       tree type_wfl = NULL_TREE;
6308       tree real_type;
6309
6310       /* Obtain a suitable type for resolution, if necessary */
6311       SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
6312
6313       /* Process NAME, as it may specify extra dimension(s) for it */
6314       type = build_array_from_name (type, type_wfl, name, &name);
6315       EXPR_WFL_NODE (wfl_name) = name;
6316
6317       real_type = GET_REAL_TYPE (type);
6318       if (TREE_CODE (real_type) == RECORD_TYPE)
6319         {
6320           real_type = promote_type (real_type);
6321           if (TREE_CODE (type) == TREE_LIST)
6322             TREE_PURPOSE (type) = real_type;
6323         }
6324
6325       /* Check redefinition */
6326       for (already = arg_types; already; already = TREE_CHAIN (already))
6327         if (TREE_PURPOSE (already) == name)
6328           {
6329             parse_error_context 
6330               (wfl_name, "Variable `%s' is used more than once in the "
6331                "argument list of method `%s'", IDENTIFIER_POINTER (name),
6332                IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6333             break;
6334           }
6335
6336       /* If we've an incomplete argument type, we know there is a location
6337          to patch when the type get resolved, later.  */
6338       jdep = NULL;
6339       if (must_chain)
6340         {
6341           patch_stage = JDEP_METHOD;
6342           type = register_incomplete_type (patch_stage, 
6343                                            type_wfl, wfl_name, type);
6344           jdep = CLASSD_LAST (ctxp->classd_list);
6345           JDEP_MISC (jdep) = id;
6346         }
6347
6348       /* The argument node: a name and a (possibly) incomplete type */
6349       arg_node = build_tree_list (name, real_type);
6350       if (jdep)
6351         JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
6352       TREE_CHAIN (arg_node) = arg_types;
6353       arg_types = arg_node;
6354     }
6355   TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
6356   node = build_tree_list (id, meth);
6357   return node;
6358 }
6359
6360 static int
6361 unresolved_type_p (wfl, returned)
6362      tree wfl;
6363      tree *returned;
6364      
6365 {
6366   if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
6367     {
6368       tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
6369       if (returned)
6370         *returned = (decl ? TREE_TYPE (decl) : NULL_TREE);
6371       return 1;
6372     }
6373   if (returned)
6374     *returned = wfl;
6375   return 0;
6376 }
6377
6378 /* From NAME, build a qualified identifier node using the
6379    qualification from the current package definition. */
6380
6381 static tree
6382 parser_qualified_classname (name)
6383      tree name;
6384 {
6385   if (ctxp->package)
6386     return merge_qualified_name (ctxp->package, EXPR_WFL_NODE (name));
6387   else 
6388     return EXPR_WFL_NODE (name);
6389 }
6390
6391 /* Called once the type a interface extends is resolved. Returns 0 if
6392    everything is OK.  */
6393
6394 static int
6395 parser_check_super_interface (super_decl, this_decl, this_wfl)
6396      tree super_decl, this_decl, this_wfl;
6397 {
6398   tree super_type = TREE_TYPE (super_decl);
6399
6400   /* Has to be an interface */
6401   if (!CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (super_decl))))
6402     {
6403       parse_error_context 
6404         (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
6405          (TYPE_ARRAY_P (super_type) ? "array" : "class"),
6406          IDENTIFIER_POINTER (DECL_NAME (super_decl)),
6407          (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ? 
6408           "interface" : "class"),
6409          IDENTIFIER_POINTER (DECL_NAME (this_decl)));
6410       return 1;
6411     }
6412
6413   /* Check scope: same package OK, other package: OK if public */
6414   if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
6415     return 1;
6416
6417   SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
6418                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
6419                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
6420   return 0;
6421 }
6422
6423 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
6424    0 if everthing is OK.  */
6425
6426 static int
6427 parser_check_super (super_decl, this_decl, wfl)
6428      tree super_decl, this_decl, wfl;
6429 {
6430   tree super_type = TREE_TYPE (super_decl);
6431
6432   /* SUPER should be a CLASS (neither an array nor an interface) */
6433   if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
6434     {
6435       parse_error_context 
6436         (wfl, "Class `%s' can't subclass %s `%s'",
6437          IDENTIFIER_POINTER (DECL_NAME (this_decl)),
6438          (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
6439          IDENTIFIER_POINTER (DECL_NAME (super_decl)));
6440       return 1;
6441     }
6442
6443   if (CLASS_FINAL (TYPE_NAME (super_type)))
6444     {
6445       parse_error_context (wfl, "Can't subclass final classes: %s",
6446                            IDENTIFIER_POINTER (DECL_NAME (super_decl)));
6447       return 1;
6448     }
6449
6450   /* Check scope: same package OK, other package: OK if public */
6451   if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
6452     return 1;
6453   
6454   SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
6455                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
6456                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
6457   return 0;
6458 }
6459
6460 /* Create a new dependency list and link it (in a LIFO manner) to the
6461    CTXP list of type dependency list.  */
6462
6463 static void
6464 create_jdep_list (ctxp)
6465      struct parser_ctxt *ctxp;
6466 {
6467   jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));      
6468   new->first = new->last = NULL;
6469   new->next = ctxp->classd_list;
6470   ctxp->classd_list = new;
6471 }
6472
6473 static jdeplist *
6474 reverse_jdep_list (ctxp)
6475      struct parser_ctxt *ctxp;
6476 {
6477   register jdeplist *prev = NULL, *current, *next;
6478   for (current = ctxp->classd_list; current; current = next)
6479     {
6480       next = current->next;
6481       current->next = prev;
6482       prev = current;
6483     }
6484   return prev;
6485 }
6486
6487 /* Create a fake pointer based on the ID stored in
6488    TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
6489    registered again. */
6490
6491 static tree
6492 obtain_incomplete_type (type_name)
6493      tree type_name;
6494 {
6495   tree ptr, name;
6496
6497   if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
6498     name = EXPR_WFL_NODE (type_name);
6499   else if (INCOMPLETE_TYPE_P (type_name))
6500     name = TYPE_NAME (type_name);
6501   else
6502     fatal ("invalid type name - obtain_incomplete_type");
6503
6504   for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
6505     if (TYPE_NAME (ptr) == name)
6506       break;
6507
6508   if (!ptr)
6509     {
6510       push_obstacks (&permanent_obstack, &permanent_obstack);
6511       BUILD_PTR_FROM_NAME (ptr, name);
6512       layout_type (ptr);
6513       pop_obstacks ();
6514       TREE_CHAIN (ptr) = ctxp->incomplete_class;
6515       ctxp->incomplete_class = ptr;
6516     }
6517
6518   return ptr;
6519 }
6520
6521 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
6522    non NULL instead of computing a new fake type based on WFL. The new
6523    dependency is inserted in the current type dependency list, in FIFO
6524    manner.  */
6525
6526 static tree
6527 register_incomplete_type (kind, wfl, decl, ptr)
6528      int kind;
6529      tree wfl, decl, ptr;
6530 {
6531   jdep *new = (jdep *)xmalloc (sizeof (jdep));
6532
6533   if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
6534     ptr = obtain_incomplete_type (wfl);
6535
6536   JDEP_KIND (new) = kind;
6537   JDEP_DECL (new) = decl;
6538   JDEP_SOLV (new) = ptr;
6539   JDEP_WFL (new) = wfl;
6540   JDEP_CHAIN (new) = NULL;
6541   JDEP_MISC (new) = NULL_TREE;
6542   JDEP_GET_PATCH (new) = (tree *)NULL;
6543
6544   JDEP_INSERT (ctxp->classd_list, new);
6545
6546   return ptr;
6547 }
6548
6549 void
6550 java_check_circular_reference ()
6551 {
6552   tree current;
6553   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
6554     {
6555       tree type = TREE_TYPE (current);
6556       if (CLASS_INTERFACE (TYPE_NAME (type)))
6557         {
6558           /* Check all interfaces this class extends */
6559           tree basetype_vec = TYPE_BINFO_BASETYPES (type);
6560           int n, i;
6561
6562           if (!basetype_vec)
6563             return;
6564           n = TREE_VEC_LENGTH (basetype_vec);
6565           for (i = 0; i < n; i++)
6566             {
6567               tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
6568               if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node 
6569                   && interface_of_p (type, BINFO_TYPE (vec_elt)))
6570                 parse_error_context (lookup_cl (current),
6571                                      "Cyclic interface inheritance");
6572             }
6573         }
6574       else
6575         if (inherits_from_p (CLASSTYPE_SUPER (type), type))
6576           parse_error_context (lookup_cl (current), 
6577                                "Cyclic class inheritance");
6578     }
6579 }
6580
6581 /* safe_layout_class just makes sure that we can load a class without
6582    disrupting the current_class, input_file, lineno, etc, information
6583    about the class processed currently.  */
6584
6585 void
6586 safe_layout_class (class)
6587      tree class;
6588 {
6589   tree save_current_class = current_class;
6590   char *save_input_filename = input_filename;
6591   int save_lineno = lineno;
6592
6593   push_obstacks (&permanent_obstack, &permanent_obstack);
6594
6595   layout_class (class);
6596   pop_obstacks ();
6597
6598   current_class = save_current_class;
6599   input_filename = save_input_filename;
6600   lineno = save_lineno;
6601   CLASS_LOADED_P (class) = 1;
6602 }
6603
6604 static tree
6605 jdep_resolve_class (dep)
6606      jdep *dep;
6607 {
6608   tree decl;
6609
6610   if (JDEP_RESOLVED_P (dep))
6611     decl = JDEP_RESOLVED_DECL (dep);
6612   else
6613     {
6614       decl = resolve_class (JDEP_TO_RESOLVE (dep), 
6615                             JDEP_DECL (dep), JDEP_WFL (dep));
6616       JDEP_RESOLVED (dep, decl);
6617     }
6618     
6619   if (!decl)
6620     complete_class_report_errors (dep);
6621
6622   return decl;
6623 }
6624
6625 /* Complete unsatisfied class declaration and their dependencies */
6626
6627 void
6628 java_complete_class ()
6629 {
6630   tree cclass;
6631   jdeplist *cclassd;
6632   int error_found;
6633   tree type;
6634
6635   push_obstacks (&permanent_obstack, &permanent_obstack);
6636
6637   /* Process imports and reverse the import on demand list */
6638   process_imports ();
6639   if (ctxp->import_demand_list)
6640     ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
6641
6642   /* Rever things so we have the right order */
6643   ctxp->class_list = nreverse (ctxp->class_list);
6644   ctxp->classd_list = reverse_jdep_list (ctxp);
6645
6646   for (cclassd = ctxp->classd_list, cclass = ctxp->class_list; 
6647        cclass && cclassd; 
6648        cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
6649     {
6650       jdep *dep;
6651       for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
6652         {
6653           tree decl;
6654           if (!(decl = jdep_resolve_class (dep)))
6655             continue;
6656
6657           /* Now it's time to patch */
6658           switch (JDEP_KIND (dep))
6659             {
6660             case JDEP_SUPER:
6661               /* Simply patch super */
6662               if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
6663                 continue;
6664               BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO 
6665                 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
6666               break;
6667
6668             case JDEP_FIELD:
6669               {
6670                 /* We do part of the job done in add_field */
6671                 tree field_decl = JDEP_DECL (dep);
6672                 tree field_type = TREE_TYPE (decl);
6673                 push_obstacks (&permanent_obstack, &permanent_obstack);
6674                 if (TREE_CODE (field_type) == RECORD_TYPE)
6675                   field_type = promote_type (field_type);
6676                 pop_obstacks ();
6677                 TREE_TYPE (field_decl) = field_type;
6678                 DECL_ALIGN (field_decl) = 0;
6679                 layout_decl (field_decl, 0);
6680                 SOURCE_FRONTEND_DEBUG 
6681                   (("Completed field/var decl `%s' with `%s'",
6682                     IDENTIFIER_POINTER (DECL_NAME (field_decl)),
6683                     IDENTIFIER_POINTER (DECL_NAME (decl))));
6684                 break;
6685               }
6686             case JDEP_METHOD:   /* We start patching a method */
6687             case JDEP_METHOD_RETURN:
6688               error_found = 0;
6689               while (1)
6690                 {
6691                   if (decl)
6692                     {
6693                       type = TREE_TYPE(decl);
6694                       if (TREE_CODE (type) == RECORD_TYPE)
6695                         type = promote_type (type);
6696                       JDEP_APPLY_PATCH (dep, type);
6697                       SOURCE_FRONTEND_DEBUG 
6698                         (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
6699                            "Completing fct `%s' with ret type `%s'":
6700                            "Completing arg `%s' with type `%s'"),
6701                           IDENTIFIER_POINTER (EXPR_WFL_NODE 
6702                                               (JDEP_DECL_WFL (dep))),
6703                           IDENTIFIER_POINTER (DECL_NAME (decl))));
6704                     }
6705                   else
6706                     error_found = 1;
6707                   dep = JDEP_CHAIN (dep);
6708                   if (JDEP_KIND (dep) == JDEP_METHOD_END)
6709                     break;
6710                   else
6711                     decl = jdep_resolve_class (dep);
6712                 }
6713               if (!error_found)
6714                 {
6715                   tree mdecl = JDEP_DECL (dep), signature;
6716                   push_obstacks (&permanent_obstack, &permanent_obstack);
6717                   /* Recompute and reset the signature */
6718                   signature = build_java_signature (TREE_TYPE (mdecl));
6719                   set_java_signature (TREE_TYPE (mdecl), signature);
6720                   pop_obstacks ();
6721                 }
6722               else
6723                 continue;
6724               break;
6725
6726             case JDEP_INTERFACE:
6727               if (parser_check_super_interface (decl, JDEP_DECL (dep),
6728                                                 JDEP_WFL (dep)))
6729                 continue;
6730               parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
6731               break;
6732
6733             case JDEP_PARM:
6734             case JDEP_VARIABLE:
6735               type = TREE_TYPE(decl);
6736               if (TREE_CODE (type) == RECORD_TYPE)
6737                 type = promote_type (type);
6738               JDEP_APPLY_PATCH (dep, type);
6739               break;
6740
6741             case JDEP_TYPE:
6742               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
6743               SOURCE_FRONTEND_DEBUG 
6744                 (("Completing a random type dependency on a '%s' node",
6745                   tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
6746               break;
6747
6748             case JDEP_EXCEPTION:
6749               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
6750               SOURCE_FRONTEND_DEBUG 
6751                 (("Completing `%s' `throws' argument node",
6752                   IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
6753               break;
6754
6755             default:
6756               fatal ("Can't handle patch code %d - java_complete_class",
6757                      JDEP_KIND (dep));
6758             }
6759         }
6760     }
6761   pop_obstacks ();
6762   return;
6763 }
6764
6765 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
6766    array.  */
6767
6768 static tree
6769 resolve_class (class_type, decl, cl)
6770      tree class_type, decl, cl;
6771 {
6772   const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
6773   const char *base = name;
6774   tree resolved_type = TREE_TYPE (class_type);
6775   tree resolved_type_decl;
6776   
6777   if (resolved_type != NULL_TREE)
6778     {
6779       tree resolved_type_decl = TYPE_NAME (resolved_type);
6780       if (resolved_type_decl == NULL_TREE
6781           || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
6782         {
6783           resolved_type_decl = build_decl (TYPE_DECL,
6784                                            TYPE_NAME (class_type),
6785                                            resolved_type);
6786         }
6787       return resolved_type_decl;
6788     }
6789
6790   /* 1- Check to see if we have an array. If true, find what we really
6791      want to resolve  */
6792   while (name[0] == '[')
6793     name++;
6794   if (base != name)
6795     TYPE_NAME (class_type) = get_identifier (name);
6796
6797   /* 2- Resolve the bare type */
6798   if (!(resolved_type_decl = do_resolve_class (class_type, decl, cl)))
6799     return NULL_TREE;
6800   resolved_type = TREE_TYPE (resolved_type_decl);
6801
6802   /* 3- If we have and array, reconstruct the array down to its nesting */
6803   if (base != name)
6804     {
6805       while (base != name)
6806         {
6807           if (TREE_CODE (resolved_type) == RECORD_TYPE)
6808             resolved_type  = promote_type (resolved_type);
6809           resolved_type = build_java_array_type (resolved_type, -1);
6810           CLASS_LOADED_P (resolved_type) = 1;
6811           name--;
6812         }
6813       /* Build a fake decl for this, since this is what is expected to
6814          be returned.  */
6815       resolved_type_decl =
6816         build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
6817       /* Figure how those two things are important for error report. FIXME */
6818       DECL_SOURCE_LINE (resolved_type_decl) = 0;
6819       DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
6820       TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
6821     }
6822   TREE_TYPE (class_type) = resolved_type;
6823   return resolved_type_decl;
6824 }
6825
6826 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
6827    are used to report error messages.  */
6828
6829 tree
6830 do_resolve_class (class_type, decl, cl)
6831      tree class_type;
6832      tree decl;
6833      tree cl;
6834 {
6835   tree new_class_decl;
6836   tree original_name = NULL_TREE;
6837
6838   /* Do not try to replace TYPE_NAME (class_type) by a variable, since
6839      its is changed by find_in_imports{_on_demand} */
6840
6841   /* 1- Check for the type in single imports */
6842   if (find_in_imports (class_type))
6843     return NULL_TREE;
6844
6845   /* 2- And check for the type in the current compilation unit. If it fails,
6846      try with a name qualified with the package name if appropriate. */
6847   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6848     {
6849       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6850           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6851         load_class (TYPE_NAME (class_type), 0);
6852       return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6853     }
6854
6855   original_name = TYPE_NAME (class_type);
6856   if (!QUALIFIED_P (TYPE_NAME (class_type)) && ctxp->package)
6857     TYPE_NAME (class_type) = merge_qualified_name (ctxp->package, 
6858                                                    TYPE_NAME (class_type));
6859 #if 1
6860   if (!(new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6861     load_class (TYPE_NAME (class_type), 0);
6862   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6863     {
6864       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6865           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6866         load_class (TYPE_NAME (class_type), 0);
6867       return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6868     }
6869 #else
6870   new_name = TYPE_NAME (class_type);
6871   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (new_name)) != NULL_TREE)
6872     {
6873       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6874           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6875         load_class (new_name, 0);
6876       return IDENTIFIER_CLASS_VALUE (new_name);
6877     }
6878   else
6879     {
6880       tree class = read_class (new_name);
6881       if (class != NULL_TREE)
6882         {
6883           tree decl = IDENTIFIER_CLASS_VALUE (new_name);
6884           if (decl == NULL_TREE)
6885             decl = push_class (class, new_name);
6886           return decl;
6887         }
6888     }
6889 #endif
6890   TYPE_NAME (class_type) = original_name;
6891
6892   /* 3- Check an other compilation unit that bears the name of type */
6893   load_class (TYPE_NAME (class_type), 0);
6894   if (check_pkg_class_access (TYPE_NAME (class_type), 
6895                               (cl ? cl : lookup_cl (decl))))
6896     return NULL_TREE;
6897
6898   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6899     return new_class_decl;
6900
6901   /* 4- Check the import on demands. Don't allow bar.baz to be
6902      imported from foo.* */
6903   if (!QUALIFIED_P (TYPE_NAME (class_type)))
6904     if (find_in_imports_on_demand (class_type))
6905       return NULL_TREE;
6906
6907   /* 5- Last call for a resolution */
6908   return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6909 }
6910
6911 /* Resolve NAME and lay it out (if not done and if not the current
6912    parsed class). Return a decl node. This function is meant to be
6913    called when type resolution is necessary during the walk pass.  */
6914
6915 static tree
6916 resolve_and_layout (something, cl)
6917      tree something;
6918      tree cl;
6919 {
6920   tree decl;
6921
6922   /* Don't do that on the current class */
6923   if (something == current_class)
6924     return TYPE_NAME (current_class);
6925
6926   /* Don't do anything for void and other primitive types */
6927   if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
6928     return NULL_TREE;
6929
6930   /* Pointer types can be reall pointer types or fake pointers. When
6931      finding a real pointer, recheck for primitive types */
6932   if (TREE_CODE (something) == POINTER_TYPE)
6933     {
6934       if (TREE_TYPE (something))
6935         {
6936           something = TREE_TYPE (something);
6937           if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
6938             return NULL_TREE;
6939         }
6940       else
6941         something = TYPE_NAME (something);
6942     }
6943
6944   /* Don't do anything for arrays of primitive types */
6945   if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
6946       && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
6947     return NULL_TREE;
6948
6949   /* If something is not and IDENTIFIER_NODE, it can be a a TYPE_DECL
6950      or a real TYPE */
6951   if (TREE_CODE (something) != IDENTIFIER_NODE)
6952     something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
6953             DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
6954
6955   if (!(decl = resolve_no_layout (something, cl)))
6956     return NULL_TREE;
6957
6958   /* Resolve and layout if necessary */
6959   layout_class_methods (TREE_TYPE (decl));
6960   /* Check methods, but only once */
6961   if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) 
6962       && !CLASS_LOADED_P (TREE_TYPE (decl)))
6963     CHECK_METHODS (decl);
6964   if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
6965     safe_layout_class (TREE_TYPE (decl));
6966
6967   return decl;
6968 }
6969
6970 /* Resolve a class, returns its decl but doesn't perform any
6971    layout. The current parsing context is saved and restored */
6972
6973 static tree
6974 resolve_no_layout (name, cl)
6975      tree name, cl;
6976 {
6977   tree ptr, decl;
6978   BUILD_PTR_FROM_NAME (ptr, name);
6979   java_parser_context_save_global ();
6980   decl = resolve_class (ptr, NULL_TREE, cl);
6981   java_parser_context_restore_global ();
6982   
6983   return decl;
6984 }
6985
6986 /* Called when reporting errors. Skip leader '[' in a complex array
6987    type description that failed to be resolved.  */
6988
6989 static const char *
6990 purify_type_name (name)
6991      const char *name;
6992 {
6993   while (*name && *name == '[')
6994     name++;
6995   return name;
6996 }
6997
6998 /* The type CURRENT refers to can't be found. We print error messages.  */
6999
7000 static void
7001 complete_class_report_errors (dep)
7002      jdep *dep;
7003 {
7004   const char *name;
7005
7006   if (!JDEP_WFL (dep))
7007     return;
7008
7009   name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
7010   switch (JDEP_KIND (dep))
7011     {
7012     case JDEP_SUPER:
7013       parse_error_context  
7014         (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
7015          purify_type_name (name),
7016          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
7017       break;
7018     case JDEP_FIELD:
7019       parse_error_context
7020         (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
7021          purify_type_name (name),
7022          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
7023       break;
7024     case JDEP_METHOD:           /* Covers arguments */
7025       parse_error_context
7026         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
7027          "argument `%s' of method `%s'",
7028          purify_type_name (name),
7029          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
7030          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
7031       break;
7032     case JDEP_METHOD_RETURN:    /* Covers return type */
7033       parse_error_context
7034         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
7035          "return type of method `%s'", 
7036          purify_type_name (name),
7037          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
7038       break;
7039     case JDEP_INTERFACE:
7040       parse_error_context
7041         (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
7042          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
7043          (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
7044          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
7045       break;
7046     case JDEP_VARIABLE:
7047       parse_error_context
7048         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
7049          "local variable `%s'", 
7050          purify_type_name (IDENTIFIER_POINTER 
7051                            (EXPR_WFL_NODE (JDEP_WFL (dep)))),
7052          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
7053       break;
7054     case JDEP_EXCEPTION:        /* As specified by `throws' */
7055       parse_error_context 
7056           (JDEP_WFL (dep), "Class `%s' not found in `throws'",
7057          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
7058       break;
7059     default:
7060       /* Fix for -Wall. Just break doing nothing. The error will be
7061          caught later */
7062       break;
7063     }
7064 }
7065
7066 /* Check uninitialized final.  */
7067
7068 void
7069 java_check_final ()
7070 {
7071 }
7072
7073 /* Return a static string containing the DECL prototype string. If
7074    DECL is a constructor, use the class name instead of the form
7075    <init> */
7076
7077 static const char *
7078 get_printable_method_name (decl)
7079      tree decl;
7080 {
7081   const char *to_return;
7082   tree name = NULL_TREE;
7083
7084   if (DECL_CONSTRUCTOR_P (decl))
7085     {
7086       name = DECL_NAME (decl);
7087       DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
7088     }
7089       
7090   to_return = lang_printable_name (decl, 0);
7091   if (DECL_CONSTRUCTOR_P (decl))
7092     DECL_NAME (decl) = name;
7093   
7094   return to_return;
7095 }
7096
7097 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
7098    nevertheless needs to be verfied, 1 otherwise.  */
7099
7100 static int
7101 reset_method_name (method)
7102      tree method;
7103 {
7104   if (!IS_CLINIT (method) && DECL_NAME (method) != finit_identifier_node)
7105     {
7106       /* NAME is just the plain name when Object is being defined */
7107       if (DECL_CONTEXT (method) != object_type_node)
7108         DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ? 
7109                               init_identifier_node : GET_METHOD_NAME (method));
7110       return 0;
7111     }
7112   else 
7113     return 1;
7114 }
7115
7116 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
7117
7118 tree
7119 java_get_real_method_name (method_decl)
7120      tree method_decl;
7121 {
7122   tree method_name = DECL_NAME (method_decl);
7123   if (DECL_CONSTRUCTOR_P (method_decl))
7124     return init_identifier_node;
7125
7126   /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
7127      and still can be a constructor. FIXME */
7128
7129   /* Don't confuse method only bearing the name of their class as
7130      constructors */
7131   else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
7132            && ctxp
7133            && ctxp->current_parsed_class_un == EXPR_WFL_NODE (method_name)
7134            && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
7135            && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
7136     return init_identifier_node;
7137   else
7138     return EXPR_WFL_NODE (method_name);
7139 }
7140
7141 /* Track method being redefined inside the same class. As a side
7142    effect, set DECL_NAME to an IDENTIFIER (prior entering this
7143    function it's a FWL, so we can track errors more accurately.)  */
7144
7145 static int
7146 check_method_redefinition (class, method)
7147      tree class, method;
7148 {
7149   tree redef, name;
7150   tree cl = DECL_NAME (method);
7151   tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
7152   /* decl name of artificial <clinit> and $finit$ doesn't need to be
7153      fixed and checked */
7154
7155   /* Reset the method name before running the check. If it returns 1,
7156      the method doesn't need to be verified with respect to method
7157      redeclaration and we return 0 */
7158   if (reset_method_name (method))
7159     return 0;
7160
7161   name = DECL_NAME (method);
7162   for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
7163     {
7164       if (redef == method)
7165         break;
7166       if (DECL_NAME (redef) == name 
7167           && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
7168         {
7169           parse_error_context 
7170             (cl, "Duplicate %s declaration `%s'",
7171              (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
7172              get_printable_method_name (redef));
7173           return 1;
7174         }
7175     }
7176   return 0;
7177 }
7178
7179 static void
7180 check_abstract_method_definitions (do_interface, class_decl, type)
7181      int do_interface;
7182      tree class_decl, type;
7183 {
7184   tree class = TREE_TYPE (class_decl);
7185   tree method, end_type;
7186
7187   end_type = (do_interface ? object_type_node : type);
7188   for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
7189     {
7190       tree other_super, other_method, method_sig, method_name;
7191       int found = 0;
7192       
7193       if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
7194         continue;
7195       
7196       /* Now verify that somewhere in between TYPE and CLASS,
7197          abstract method METHOD gets a non abstract definition
7198          that is inherited by CLASS.  */
7199       
7200       method_sig = build_java_signature (TREE_TYPE (method));
7201       method_name = DECL_NAME (method);
7202       if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
7203         method_name = EXPR_WFL_NODE (method_name);
7204
7205       for (other_super = class; other_super != end_type; 
7206            other_super = CLASSTYPE_SUPER (other_super))
7207         {
7208           for (other_method = TYPE_METHODS (other_super); other_method;
7209                other_method = TREE_CHAIN (other_method))
7210             {
7211               tree s = build_java_signature (TREE_TYPE (other_method));
7212               tree other_name = DECL_NAME (other_method);
7213
7214               if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
7215                 other_name = EXPR_WFL_NODE (other_name);
7216               if (!IS_CLINIT (other_method)
7217                   && !DECL_CONSTRUCTOR_P (other_method)
7218                   && method_name == other_name && method_sig == s)
7219                 {
7220                   found = 1;
7221                   break;
7222                 }
7223             }
7224         }
7225       
7226       /* Report that abstract METHOD didn't find an implementation
7227          that CLASS can use. */
7228       if (!found)
7229         {
7230           char *t = xstrdup (lang_printable_name 
7231                             (TREE_TYPE (TREE_TYPE (method)), 0));
7232           tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
7233           tree saved_wfl = NULL_TREE;
7234           
7235           if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION)
7236             {
7237               saved_wfl = DECL_NAME (method);
7238               DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
7239             }
7240           
7241           parse_error_context 
7242             (lookup_cl (class_decl),
7243              "Class `%s' doesn't define the abstract method `%s %s' from "
7244              "%s `%s'. This method must be defined or %s `%s' must be "
7245              "declared abstract",
7246              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
7247              t, lang_printable_name (method, 0), 
7248              (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ? 
7249               "interface" : "class"),
7250              IDENTIFIER_POINTER (ccn),
7251              (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
7252              IDENTIFIER_POINTER (DECL_NAME (class_decl)));
7253           
7254           free (t);
7255           
7256           if (saved_wfl)
7257             DECL_NAME (method) = saved_wfl;
7258         }
7259     }
7260 }
7261
7262 /* Check that CLASS_DECL somehoow implements all inherited abstract
7263    methods.  */
7264
7265 static void
7266 java_check_abstract_method_definitions (class_decl)
7267      tree class_decl;
7268 {
7269   tree class = TREE_TYPE (class_decl);
7270   tree super, vector;
7271   int i;
7272
7273   if (CLASS_ABSTRACT (class_decl))
7274     return;
7275
7276   /* Check for inherited types */
7277   for (super = CLASSTYPE_SUPER (class); super != object_type_node; 
7278        super = CLASSTYPE_SUPER (super))
7279     {
7280       if (!CLASS_ABSTRACT (TYPE_NAME (super)))
7281         continue;
7282
7283       check_abstract_method_definitions (0, class_decl, super);
7284     }
7285
7286   /* Check for implemented interfaces. */
7287   vector = TYPE_BINFO_BASETYPES (class);
7288   for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
7289     {
7290       super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
7291       check_abstract_method_definitions (1, class_decl, super);
7292     }
7293 }
7294
7295 /* Check all the methods of CLASS_DECL. Methods are first completed
7296    then checked according to regular method existance rules.  If no
7297    constructor for CLASS_DECL were encountered, then build its
7298    declaration.  */
7299
7300 static void
7301 java_check_regular_methods (class_decl)
7302      tree class_decl;
7303 {
7304   int saw_constructor = 0;
7305   tree method;
7306   tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
7307   tree super_class = CLASSTYPE_SUPER (class);
7308   tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
7309   tree mthrows;
7310
7311   /* It is not necessary to check methods defined in java.lang.Object */
7312   if (class == object_type_node)
7313     return;
7314
7315   if (!TYPE_NVIRTUALS (class))
7316     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
7317
7318   /* Should take interfaces into account. FIXME */
7319   for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
7320     {
7321       tree sig;
7322       tree method_wfl = DECL_NAME (method);
7323       int aflags;
7324
7325       /* If we previously found something and its name was saved,
7326          reinstall it now */
7327       if (found && saved_found_wfl)
7328         {
7329           DECL_NAME (found) = saved_found_wfl;
7330           saved_found_wfl = NULL_TREE;
7331         }
7332
7333       /* Check for redefinitions */
7334       if (check_method_redefinition (class, method))
7335         continue;
7336
7337       /* If we see one constructor a mark so we don't generate the
7338          default one. Also skip other verifications: constructors
7339          can't be inherited hence hiden or overriden */
7340      if (DECL_CONSTRUCTOR_P (method))
7341        {
7342          saw_constructor = 1;
7343          continue;
7344        }
7345
7346       /* We verify things thrown by the method. They must inherits from
7347          java.lang.Throwable */
7348       for (mthrows = DECL_FUNCTION_THROWS (method);
7349            mthrows; mthrows = TREE_CHAIN (mthrows))
7350         {
7351           if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
7352             parse_error_context 
7353               (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be "
7354                "a subclass of class `java.lang.Throwable'",
7355                IDENTIFIER_POINTER 
7356                  (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
7357         }
7358
7359       sig = build_java_argument_signature (TREE_TYPE (method));
7360       found = lookup_argument_method (super_class, DECL_NAME (method), sig);
7361
7362       /* Nothing overrides or it's a private method. */
7363       if (!found)
7364         continue;
7365       if (METHOD_PRIVATE (found))
7366         {
7367           found = NULL_TREE;
7368           continue;
7369         }
7370
7371       /* If found wasn't verified, it's DECL_NAME won't be set properly. 
7372          We set it temporarily for the sake of the error report. */
7373       saved_found_wfl = DECL_NAME (found);
7374       reset_method_name (found);
7375
7376       /* Can't override a method with the same name and different return
7377          types. */
7378       if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
7379         {
7380           char *t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)),
7381                                                  0));
7382           parse_error_context 
7383             (method_wfl,
7384              "Method `%s' was defined with return type `%s' in class `%s'", 
7385              lang_printable_name (found, 0), t,
7386              IDENTIFIER_POINTER 
7387                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7388           free (t);
7389         }
7390
7391       aflags = get_access_flags_from_decl (found);
7392       /* If the method has default, access in an other package, then
7393          issue a warning that the current method doesn't override the
7394          one that was found elsewhere. Do not issue this warning when
7395          the match was found in java.lang.Object.  */
7396       if (DECL_CONTEXT (found) != object_type_node
7397           && ((aflags & 0x7) == 0)
7398           && !class_in_current_package (DECL_CONTEXT (found))
7399           && DECL_NAME (found) != clinit_identifier_node
7400           && flag_not_overriding)
7401         {
7402           parse_warning_context 
7403             (method_wfl, "Method `%s' in class `%s' does not "
7404              "override the corresponding method in class `%s', which is "
7405              "private to a different package",
7406              lang_printable_name (found, 0),
7407              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
7408              IDENTIFIER_POINTER (DECL_NAME 
7409                                  (TYPE_NAME (DECL_CONTEXT (found)))));
7410           continue;
7411         }
7412
7413       /* Can't override final. Can't override static. */
7414       if (METHOD_FINAL (found) || METHOD_STATIC (found))
7415         {
7416           /* Static *can* override static */
7417           if (METHOD_STATIC (found) && METHOD_STATIC (method))
7418             continue;
7419           parse_error_context 
7420             (method_wfl,
7421              "%s methods can't be overriden. Method `%s' is %s in class `%s'",
7422              (METHOD_FINAL (found) ? "Final" : "Static"),
7423              lang_printable_name (found, 0),
7424              (METHOD_FINAL (found) ? "final" : "static"),
7425              IDENTIFIER_POINTER
7426                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7427           continue;
7428         }
7429
7430       /* Static method can't override instance method. */
7431       if (METHOD_STATIC (method))
7432         {
7433           parse_error_context 
7434             (method_wfl,
7435              "Instance methods can't be overriden by a static method. Method "
7436              "`%s' is an instance method in class `%s'",
7437              lang_printable_name (found, 0),
7438              IDENTIFIER_POINTER
7439                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7440           continue;
7441         }
7442
7443       /* - Overriding/hiding public must be public
7444          - Overriding/hiding protected must be protected or public
7445          - If the overriden or hidden method has default (package)
7446            access, then the overriding or hiding method must not be
7447            private; otherwise, a compile-time error occurs */
7448       if ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method)) 
7449           || (METHOD_PROTECTED (found) 
7450               && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
7451           || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
7452               && METHOD_PRIVATE (method)))
7453         {
7454           parse_error_context 
7455             (method_wfl,
7456              "Methods can't be overridden to be more private. Method `%s' is "
7457              "not %s in class `%s'", lang_printable_name (method, 0),
7458              (METHOD_PUBLIC (method) ? "public" : 
7459               (METHOD_PRIVATE (method) ? "private" : "protected")),
7460              IDENTIFIER_POINTER (DECL_NAME 
7461                                  (TYPE_NAME (DECL_CONTEXT (found)))));
7462           continue;
7463         }
7464
7465       /* Overriding methods must have compatible `throws' clauses on checked
7466          exceptions, if any */
7467       check_throws_clauses (method, method_wfl, found);
7468
7469       /* Inheriting multiple methods with the same signature. FIXME */
7470     }
7471   
7472   /* Don't forget eventual pending found and saved_found_wfl. Take
7473      into account that we might have exited because we saw an
7474      artificial method as the last entry. */
7475
7476   if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
7477     DECL_NAME (found) = saved_found_wfl;
7478
7479   if (!TYPE_NVIRTUALS (class))
7480     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
7481
7482   /* Search for inherited abstract method not yet implemented in this
7483      class.  */
7484   java_check_abstract_method_definitions (class_decl);
7485
7486   if (!saw_constructor)
7487     {
7488       /* No constructor seen, we craft one, at line 0. Since this
7489        operation takes place after we laid methods out
7490        (layout_class_methods), we prepare the its DECL
7491        appropriately. */
7492       int flags;
7493       tree decl;
7494
7495       /* If the class is declared PUBLIC, the default constructor is
7496          PUBLIC otherwise it has default access implied by no access
7497          modifiers. */
7498       flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7499                ACC_PUBLIC : 0);
7500       decl = create_artificial_method (class, flags, void_type_node, 
7501                                        init_identifier_node, end_params_node);
7502       DECL_CONSTRUCTOR_P (decl) = 1;
7503       layout_class_method (TREE_TYPE (class_decl), NULL_TREE, decl, NULL_TREE);
7504     }
7505 }
7506
7507 /* Return a non zero value if the `throws' clause of METHOD (if any)
7508    is incompatible with the `throws' clause of FOUND (if any).  */
7509
7510 static void
7511 check_throws_clauses (method, method_wfl, found)
7512      tree method, method_wfl, found;
7513 {
7514   tree mthrows, fthrows;
7515
7516   /* Can't check these things with class loaded from bytecode. FIXME */
7517   if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
7518     return;
7519
7520   for (mthrows = DECL_FUNCTION_THROWS (method);
7521        mthrows; mthrows = TREE_CHAIN (mthrows))
7522     {
7523       /* We don't verify unchecked expressions */
7524       if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
7525         continue;
7526       /* Checked expression must be compatible */
7527       for (fthrows = DECL_FUNCTION_THROWS (found); 
7528            fthrows; fthrows = TREE_CHAIN (fthrows))
7529         if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
7530           break;
7531       if (!fthrows)
7532         {
7533           parse_error_context 
7534             (method_wfl, "Invalid checked exception class `%s' in "
7535              "`throws' clause. The exception must be a subclass of an "
7536              "exception thrown by `%s' from class `%s'",
7537              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
7538              lang_printable_name (found, 0),
7539              IDENTIFIER_POINTER 
7540                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7541         }
7542     }
7543 }
7544
7545 /* Check abstract method of interface INTERFACE */
7546
7547 static void
7548 java_check_abstract_methods (interface_decl)
7549      tree interface_decl;
7550 {
7551   int i, n;
7552   tree method, basetype_vec, found;
7553   tree interface = TREE_TYPE (interface_decl);
7554
7555   for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
7556     {
7557       tree method_wfl = DECL_NAME (method);
7558
7559       /* 2- Check for double definition inside the defining interface */
7560       if (check_method_redefinition (interface, method))
7561         continue;
7562
7563       /* 3- Overriding is OK as far as we preserve the return type and
7564          the thrown exceptions (FIXME) */
7565       found = lookup_java_interface_method2 (interface, method);
7566       if (found)
7567         {
7568           char *t;
7569           tree saved_found_wfl = DECL_NAME (found);
7570           reset_method_name (found);
7571           t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
7572           parse_error_context 
7573             (method_wfl,
7574              "Method `%s' was defined with return type `%s' in class `%s'",
7575              lang_printable_name (found, 0), t,
7576              IDENTIFIER_POINTER 
7577                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7578           free (t);
7579           continue;
7580           
7581           DECL_NAME (found) = saved_found_wfl;
7582         }
7583     }
7584
7585   /* 4- Inherited methods can't differ by their returned types */
7586   if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
7587     return;
7588   n = TREE_VEC_LENGTH (basetype_vec);
7589   for (i = 0; i < n; i++)
7590     {
7591       tree sub_interface_method, sub_interface;
7592       tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7593       if (!vec_elt)
7594         continue;
7595       sub_interface = BINFO_TYPE (vec_elt);
7596       for (sub_interface_method = TYPE_METHODS (sub_interface); 
7597            sub_interface_method;
7598            sub_interface_method = TREE_CHAIN (sub_interface_method))
7599         {
7600           found = lookup_java_interface_method2 (interface, 
7601                                                  sub_interface_method);
7602           if (found && (found != sub_interface_method))
7603             {
7604               tree saved_found_wfl = DECL_NAME (found);
7605               reset_method_name (found);
7606               parse_error_context 
7607                 (lookup_cl (sub_interface_method),
7608                  "Interface `%s' inherits method `%s' from interface `%s'. "
7609                  "This method is redefined with a different return type in "
7610                  "interface `%s'",
7611                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
7612                  lang_printable_name (found, 0),
7613                  IDENTIFIER_POINTER 
7614                    (DECL_NAME (TYPE_NAME 
7615                                (DECL_CONTEXT (sub_interface_method)))),
7616                  IDENTIFIER_POINTER 
7617                    (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7618               DECL_NAME (found) = saved_found_wfl;
7619             }
7620         }
7621     }
7622 }
7623
7624 /* Lookup methods in interfaces using their name and partial
7625    signature. Return a matching method only if their types differ.  */
7626
7627 static tree
7628 lookup_java_interface_method2 (class, method_decl)
7629      tree class, method_decl;
7630 {
7631   int i, n;
7632   tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
7633
7634   if (!basetype_vec)
7635     return NULL_TREE;
7636
7637   n = TREE_VEC_LENGTH (basetype_vec);
7638   for (i = 0; i < n; i++)
7639     {
7640       tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
7641       if ((BINFO_TYPE (vec_elt) != object_type_node)
7642           && (to_return = 
7643               lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
7644         return to_return;
7645     }
7646   for (i = 0; i < n; i++)
7647     {
7648       to_return = lookup_java_interface_method2 
7649         (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
7650       if (to_return)
7651         return to_return;
7652     }
7653
7654   return NULL_TREE;
7655 }
7656
7657 /* Lookup method using their name and partial signature. Return a
7658    matching method only if their types differ.  */
7659
7660 static tree
7661 lookup_java_method2 (clas, method_decl, do_interface)
7662      tree clas, method_decl;
7663      int do_interface;
7664 {
7665   tree method, method_signature, method_name, method_type, name;
7666
7667   method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
7668   name = DECL_NAME (method_decl);
7669   method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ? 
7670                  EXPR_WFL_NODE (name) : name);
7671   method_type = TREE_TYPE (TREE_TYPE (method_decl));
7672
7673   while (clas != NULL_TREE)
7674     {
7675       for (method = TYPE_METHODS (clas);
7676            method != NULL_TREE;  method = TREE_CHAIN (method))
7677         {
7678           tree method_sig = build_java_argument_signature (TREE_TYPE (method));
7679           tree name = DECL_NAME (method);
7680           if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
7681                EXPR_WFL_NODE (name) : name) == method_name
7682               && method_sig == method_signature 
7683               && TREE_TYPE (TREE_TYPE (method)) != method_type)
7684             return method;
7685         }
7686       clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
7687     }
7688   return NULL_TREE;
7689 }
7690
7691 /* Return the line that matches DECL line number, and try its best to
7692    position the column number. Used during error reports.  */
7693
7694 static tree
7695 lookup_cl (decl)
7696      tree decl;
7697 {
7698   static tree cl = NULL_TREE;
7699   char *line, *found;
7700   
7701   if (!decl)
7702     return NULL_TREE;
7703
7704   if (cl == NULL_TREE)
7705     cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
7706
7707   EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
7708   EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
7709
7710   line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
7711                             EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
7712
7713   found = strstr ((const char *)line, 
7714                   (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
7715   if (found)
7716     EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line);
7717
7718   return cl;
7719 }
7720
7721 /* Look for a simple name in the single-type import list */
7722
7723 static tree
7724 find_name_in_single_imports (name)
7725      tree name;
7726 {
7727   tree node;
7728
7729   for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
7730     if (TREE_VALUE (node) == name)
7731       return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
7732
7733   return NULL_TREE;
7734 }
7735
7736 /* Process all single-type import. */
7737
7738 static int
7739 process_imports ()
7740 {
7741   tree import;
7742   int error_found;
7743
7744   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
7745     {
7746       tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
7747
7748       /* Don't load twice something already defined. */
7749       if (IDENTIFIER_CLASS_VALUE (to_be_found))
7750         continue;
7751       QUALIFIED_P (to_be_found) = 1;
7752       load_class (to_be_found, 0);
7753       error_found =
7754         check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
7755       if (!IDENTIFIER_CLASS_VALUE (to_be_found))
7756         {
7757           parse_error_context (TREE_PURPOSE (import),
7758                                "Class or interface `%s' not found in import",
7759                                IDENTIFIER_POINTER (to_be_found));
7760           return 1;
7761         }
7762       if (error_found)
7763         return 1;
7764     }
7765   return 0;
7766 }
7767
7768 /* Possibly find a class imported by a single-type import statement. Return
7769    1 if an error occured, 0 otherwise. */
7770
7771 static int
7772 find_in_imports (class_type)
7773      tree class_type;
7774 {
7775   tree import;
7776
7777   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
7778     if (TREE_VALUE (import) == TYPE_NAME (class_type))
7779       {
7780         TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
7781         QUALIFIED_P (TYPE_NAME (class_type)) = 1;
7782       }
7783   return 0;
7784 }
7785
7786 static int
7787 note_possible_classname (name, len)
7788      const char *name;
7789      int len;
7790 {
7791   tree node;
7792   if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
7793     len = len - 5;
7794   else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
7795     len = len - 6;
7796   else
7797     return 0;
7798   node = ident_subst (name, len, "", '/', '.', "");
7799   IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
7800   QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
7801   return 1;
7802 }
7803
7804 /* Read a import directory, gathering potential match for further type
7805    references. Indifferently reads a filesystem or a ZIP archive
7806    directory.  */
7807
7808 static void
7809 read_import_dir (wfl)
7810      tree wfl;
7811 {
7812   tree package_id = EXPR_WFL_NODE (wfl);
7813   const char *package_name = IDENTIFIER_POINTER (package_id);
7814   int package_length = IDENTIFIER_LENGTH (package_id);
7815   DIR *dirp = NULL;
7816   JCF *saved_jcf = current_jcf;
7817
7818   int found = 0;
7819   int k;
7820   void *entry;
7821   struct buffer filename[1];
7822
7823
7824   if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
7825     return;
7826   IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
7827
7828   BUFFER_INIT (filename);
7829   buffer_grow (filename, package_length + 100);
7830
7831   for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
7832     {
7833       const char *entry_name = jcf_path_name (entry);
7834       int entry_length = strlen (entry_name);
7835       if (jcf_path_is_zipfile (entry))
7836         {
7837           ZipFile *zipf;
7838           buffer_grow (filename, entry_length);
7839           memcpy (filename->data, entry_name, entry_length - 1);
7840           filename->data[entry_length-1] = '\0';
7841           zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
7842           if (zipf == NULL)
7843             error ("malformed .zip archive in CLASSPATH: %s", entry_name);
7844           else
7845             {
7846               ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
7847               BUFFER_RESET (filename);
7848               for (k = 0; k < package_length; k++)
7849                 {
7850                   char ch = package_name[k];
7851                   *filename->ptr++ = ch == '.' ? '/' : ch;
7852                 }
7853               *filename->ptr++ = '/';
7854
7855               for (k = 0; k < zipf->count;  k++, zipd = ZIPDIR_NEXT (zipd))
7856                 {
7857                   const char *current_entry = ZIPDIR_FILENAME (zipd);
7858                   int current_entry_len = zipd->filename_length;
7859
7860                   if (current_entry_len >= BUFFER_LENGTH (filename)
7861                       && strncmp (filename->data, current_entry, 
7862                                   BUFFER_LENGTH (filename)) != 0)
7863                     continue;
7864                   found |= note_possible_classname (current_entry,
7865                                                     current_entry_len);
7866                 }
7867             }
7868         }
7869       else
7870         {
7871           BUFFER_RESET (filename);
7872           buffer_grow (filename, entry_length + package_length + 4);
7873           strcpy (filename->data, entry_name);
7874           filename->ptr = filename->data + entry_length;
7875           for (k = 0; k < package_length; k++)
7876             {
7877               char ch = package_name[k];
7878               *filename->ptr++ = ch == '.' ? '/' : ch;
7879             }
7880           *filename->ptr = '\0';
7881
7882           dirp = opendir (filename->data);
7883           if (dirp == NULL)
7884             continue;
7885           *filename->ptr++ = '/';
7886           for (;;)
7887             {
7888               int len; 
7889               const char *d_name;
7890               struct dirent *direntp = readdir (dirp);
7891               if (!direntp)
7892                 break;
7893               d_name = direntp->d_name;
7894               len = strlen (direntp->d_name);
7895               buffer_grow (filename, len+1);
7896               strcpy (filename->ptr, d_name);
7897               found |= note_possible_classname (filename->data + entry_length,
7898                                                 package_length+len+1);
7899             }
7900           if (dirp)
7901             closedir (dirp);
7902         }
7903     }
7904
7905   free (filename->data);
7906
7907   /* Here we should have a unified way of retrieving an entry, to be
7908      indexed. */
7909   if (!found)
7910     {
7911       static int first = 1;
7912       if (first)
7913         {
7914           error ("Can't find default package `%s'. Check "
7915                  "the CLASSPATH environment variable and the access to the "
7916                  "archives.", package_name);
7917           java_error_count++;
7918           first = 0;
7919         }
7920       else
7921         parse_error_context (wfl, "Package `%s' not found in import",
7922                              package_name);
7923       current_jcf = saved_jcf;
7924       return;
7925     }
7926   current_jcf = saved_jcf;
7927 }
7928
7929 /* Possibly find a type in the import on demands specified
7930    types. Returns 1 if an error occured, 0 otherwise. Run throught the
7931    entire list, to detected potential double definitions.  */
7932                  
7933 static int
7934 find_in_imports_on_demand (class_type)
7935      tree class_type;
7936 {
7937   tree node, import, node_to_use = NULL_TREE;
7938   int seen_once = -1;
7939   tree cl = NULL_TREE;
7940
7941   for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
7942     {
7943       const char *id_name;
7944       obstack_grow (&temporary_obstack, 
7945                     IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
7946                     IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
7947       obstack_1grow (&temporary_obstack, '.');
7948       obstack_grow0 (&temporary_obstack, 
7949                      IDENTIFIER_POINTER (TYPE_NAME (class_type)),
7950                      IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
7951       id_name = obstack_finish (&temporary_obstack);
7952               
7953       node = maybe_get_identifier (id_name);
7954       if (node && IS_A_CLASSFILE_NAME (node))
7955         {
7956           if (seen_once < 0)
7957             {
7958               cl = TREE_PURPOSE (import);
7959               seen_once = 1;
7960               node_to_use = node;
7961             }
7962           else
7963             {
7964               seen_once++;
7965               parse_error_context 
7966                 (import, "Type `%s' also potentially defined in package `%s'",
7967                  IDENTIFIER_POINTER (TYPE_NAME (class_type)),
7968                  IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
7969             }
7970         }
7971     }
7972
7973   if (seen_once == 1)
7974     {
7975       /* Setup lineno so that it refers to the line of the import (in
7976          case we parse a class file and encounter errors */
7977       tree decl;
7978       int saved_lineno = lineno;
7979       lineno = EXPR_WFL_LINENO (cl);
7980       TYPE_NAME (class_type) = node_to_use;
7981       QUALIFIED_P (TYPE_NAME (class_type)) = 1;
7982       decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
7983       /* If there is no DECL set for the class or if the class isn't
7984          loaded and not seen in source yet, the load */
7985       if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
7986                     && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
7987         load_class (node_to_use, 0);
7988       lineno = saved_lineno;
7989       return check_pkg_class_access (TYPE_NAME (class_type), cl);
7990     }
7991   else
7992     return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
7993 }
7994
7995 static tree
7996 resolve_package (pkg, next)
7997      tree pkg, *next;
7998 {
7999   tree current;
8000   tree type_name = NULL_TREE;
8001   const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
8002
8003   /* The trick is to determine when the package name stops and were
8004      the name of something contained in the package starts. Then we
8005      return a fully qualified name of what we want to get. */
8006
8007   /* Do a quick search on well known package names */
8008   if (!strncmp (name, "java.lang.reflect", 17))
8009     {
8010       *next = 
8011         TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
8012       type_name = lookup_package_type (name, 17);
8013     }
8014   else if (!strncmp (name, "java.lang", 9))
8015     {
8016       *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
8017       type_name = lookup_package_type (name, 9);
8018     }
8019
8020   /* If we found something here, return */
8021   if (type_name)
8022     return type_name; 
8023
8024   *next = EXPR_WFL_QUALIFICATION (pkg);
8025
8026   /* Try the current package. */
8027   if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),  
8028                                  IDENTIFIER_LENGTH (ctxp->package)))
8029     {
8030       type_name = 
8031         lookup_package_type_and_set_next (name, 
8032                                           IDENTIFIER_LENGTH (ctxp->package), 
8033                                           next );
8034       if (type_name)
8035         return type_name;
8036     }
8037
8038   /* Search in imported package */
8039   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
8040     {
8041       tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
8042       int len = IDENTIFIER_LENGTH (current_pkg_name);
8043       if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
8044         {
8045           tree left, dummy;
8046           
8047           breakdown_qualified (&left, &dummy, current_pkg_name);
8048           len = IDENTIFIER_LENGTH (left);
8049           type_name = lookup_package_type_and_set_next (name, len, next);
8050           if (type_name)
8051             break;
8052         }
8053     }
8054
8055   return type_name;
8056 }
8057
8058 static tree
8059 lookup_package_type_and_set_next (name, len, next)
8060      const char *name;
8061      int len;
8062      tree *next;
8063 {
8064   const char *ptr;
8065   tree type_name = lookup_package_type (name, len);
8066
8067   if (!type_name)
8068     return NULL;
8069   
8070   ptr = IDENTIFIER_POINTER (type_name);
8071   while (ptr && (ptr = strchr (ptr, '.'))) 
8072     {
8073       *next = TREE_CHAIN (*next);
8074       ptr++;
8075     }
8076   return type_name;
8077 }
8078
8079 static tree
8080 lookup_package_type (name, from)
8081      const char *name;
8082      int from;
8083 {
8084   char subname [128];
8085   const char *sub = &name[from+1];
8086   while (*sub != '.' && *sub)
8087     sub++;
8088   strncpy (subname, name, sub-name);
8089   subname [sub-name] = '\0';
8090   return get_identifier (subname);
8091 }
8092
8093 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
8094    access violations were found, 1 otherwise.  */
8095
8096 static int
8097 check_pkg_class_access (class_name, cl)
8098      tree class_name;
8099      tree cl;
8100 {
8101   tree type;
8102
8103   if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
8104     return 0;
8105
8106   if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
8107     return 0;
8108
8109   if (!CLASS_PUBLIC (TYPE_NAME (type)))
8110     {
8111       /* Access to a private class within the same package is
8112          allowed. */
8113       tree l, r;
8114       breakdown_qualified (&l, &r, class_name);
8115       if (l == ctxp->package)
8116         return 0;
8117
8118       parse_error_context 
8119         (cl, "Can't access %s `%s'. Only public classes and interfaces in "
8120          "other packages can be accessed",
8121          (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
8122          IDENTIFIER_POINTER (class_name));
8123       return 1;
8124     }
8125   return 0;
8126 }
8127
8128 /* Local variable declaration. */
8129
8130 static void
8131 declare_local_variables (modifier, type, vlist)
8132      int modifier;
8133      tree type;
8134      tree vlist;
8135 {
8136   tree decl, current, saved_type;
8137   tree type_wfl = NULL_TREE;
8138   int must_chain = 0;
8139
8140   /* Push a new block if statements were seen between the last time we
8141      pushed a block and now. Keep a cound of block to close */
8142   if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
8143     {
8144       tree body = GET_CURRENT_BLOCK (current_function_decl);
8145       tree b = enter_block ();
8146       BLOCK_EXPR_ORIGIN (b) = body;
8147     }
8148
8149   if (modifier)
8150     {
8151       int i;
8152       for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
8153       if (modifier == ACC_FINAL)
8154         {
8155           if (flag_static_local_jdk1_1)
8156             parse_warning_context (ctxp->modifier_ctx [i], 
8157                                    "Unsupported JDK1.1 `final' local variable "
8158                                    "(treated as non final)");
8159         }
8160       else 
8161         {
8162           parse_error_context 
8163             (ctxp->modifier_ctx [i], 
8164              "Only `final' is allowed as a local variables modifier");
8165           return;
8166         }
8167     }
8168
8169   /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
8170      hold the TYPE value if a new incomplete has to be created (as
8171      opposed to being found already existing and reused). */
8172   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
8173
8174   /* If TYPE is fully resolved and we don't have a reference, make one */
8175   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
8176
8177   /* Go through all the declared variables */
8178   for (current = vlist, saved_type = type; current;
8179        current = TREE_CHAIN (current), type = saved_type)
8180     {
8181       tree other, real_type;
8182       tree wfl  = TREE_PURPOSE (current);
8183       tree name = EXPR_WFL_NODE (wfl);
8184       tree init = TREE_VALUE (current);
8185
8186       /* Process NAME, as it may specify extra dimension(s) for it */
8187       type = build_array_from_name (type, type_wfl, name, &name);
8188
8189       /* Variable redefinition check */
8190       if ((other = lookup_name_in_blocks (name)))
8191         {
8192           variable_redefinition_error (wfl, name, TREE_TYPE (other),
8193                                        DECL_SOURCE_LINE (other));
8194           continue;
8195         }
8196
8197       /* Type adjustment. We may have just readjusted TYPE because
8198          the variable specified more dimensions. Make sure we have
8199          a reference if we can and don't have one already. */
8200       PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
8201
8202       real_type = GET_REAL_TYPE (type);
8203       /* Never layout this decl. This will be done when its scope
8204          will be entered */
8205       decl = build_decl (VAR_DECL, name, real_type);
8206       BLOCK_CHAIN_DECL (decl);
8207       
8208       /* If doing xreferencing, replace the line number with the WFL
8209          compound value */
8210       if (flag_emit_xref)
8211         DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
8212       
8213       /* Don't try to use an INIT statement when an error was found */
8214       if (init && java_error_count)
8215         init = NULL_TREE;
8216       
8217       /* Add the initialization function to the current function's code */
8218       if (init)
8219         {
8220           /* Name might have been readjusted */
8221           EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
8222           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
8223           java_method_add_stmt (current_function_decl,
8224                                 build_debugable_stmt (EXPR_WFL_LINECOL (init),
8225                                                       init));
8226         }
8227     
8228       /* Setup dependency the type of the decl */
8229       if (must_chain)
8230         {
8231           jdep *dep;
8232           register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
8233           dep = CLASSD_LAST (ctxp->classd_list);
8234           JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
8235         }
8236     }
8237   SOURCE_FRONTEND_DEBUG (("Defined locals"));
8238 }
8239
8240 /* Called during parsing. Build decls from argument list.  */
8241
8242 static void
8243 source_start_java_method (fndecl)
8244      tree fndecl;
8245 {
8246   tree tem;
8247   tree parm_decl;
8248   int i;
8249
8250   if (!fndecl)
8251     return;
8252
8253   current_function_decl = fndecl;
8254
8255   /* New scope for the function */
8256   enter_block ();
8257   for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
8258        tem != end_params_node; tem = TREE_CHAIN (tem), i++)
8259     {
8260       tree type = TREE_VALUE (tem);
8261       tree name = TREE_PURPOSE (tem);
8262       
8263       /* If type is incomplete. Create an incomplete decl and ask for
8264          the decl to be patched later */
8265       if (INCOMPLETE_TYPE_P (type))
8266         {
8267           jdep *jdep;
8268           tree real_type = GET_REAL_TYPE (type);
8269           parm_decl = build_decl (PARM_DECL, name, real_type);
8270           type = obtain_incomplete_type (type);
8271           register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
8272           jdep = CLASSD_LAST (ctxp->classd_list);
8273           JDEP_MISC (jdep) = name;
8274           JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
8275         }
8276       else
8277         parm_decl = build_decl (PARM_DECL, name, type);
8278
8279       BLOCK_CHAIN_DECL (parm_decl);
8280     }
8281   tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
8282   BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
8283     nreverse (tem);
8284   DECL_ARG_SLOT_COUNT (current_function_decl) = i;
8285 }
8286
8287 /* Called during parsing. Creates an artificial method declaration.  */
8288
8289 static tree
8290 create_artificial_method (class, flags, type, name, args)
8291      tree class;
8292      int flags;
8293      tree type, name, args;
8294 {
8295   int saved_lineno = lineno;                                        
8296   tree mdecl;
8297
8298   lineno = 0;                                                               
8299   mdecl = make_node (FUNCTION_TYPE);                                
8300   TREE_TYPE (mdecl) = type;
8301   TYPE_ARG_TYPES (mdecl) = args;
8302   mdecl = add_method (class, flags, name, build_java_signature (mdecl)); 
8303   lineno = saved_lineno;                                                    
8304   DECL_ARTIFICIAL (mdecl) = 1;                                      
8305   return mdecl;
8306 }
8307
8308 /* Starts the body if an artifical method.  */
8309
8310 static void
8311 start_artificial_method_body (mdecl)
8312      tree mdecl;
8313 {
8314   DECL_SOURCE_LINE (mdecl) = 1;
8315   DECL_SOURCE_LINE_MERGE (mdecl, 1);
8316   source_start_java_method (mdecl);
8317   enter_block ();
8318 }
8319
8320 static void
8321 end_artificial_method_body (mdecl)
8322      tree mdecl;
8323 {
8324   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
8325   exit_block ();
8326 }
8327
8328 /* Called during expansion. Push decls formerly built from argument
8329    list so they're usable during expansion. */
8330
8331 static void
8332 expand_start_java_method (fndecl)
8333      tree fndecl;
8334 {
8335   tree tem, *ptr;
8336
8337   current_function_decl = fndecl;
8338
8339   announce_function (fndecl);
8340   pushlevel (1);                /* Push parameters */
8341   ptr = &DECL_ARGUMENTS (fndecl);
8342   tem  = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
8343   while (tem)
8344     {
8345       tree next = TREE_CHAIN (tem);
8346       tree type = TREE_TYPE (tem);
8347       if (PROMOTE_PROTOTYPES
8348           && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
8349           && INTEGRAL_TYPE_P (type))
8350         type = integer_type_node;
8351       DECL_ARG_TYPE (tem) = type;
8352       layout_decl (tem, 0);
8353       pushdecl (tem);
8354       *ptr = tem;
8355       ptr = &TREE_CHAIN (tem);
8356       tem = next;
8357     }
8358   *ptr = NULL_TREE;
8359   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
8360   lineno = DECL_SOURCE_LINE_FIRST (fndecl);
8361 }
8362
8363 /* Terminate a function and expand its body.  */
8364
8365 static void
8366 source_end_java_method ()
8367 {
8368   tree fndecl = current_function_decl;
8369   int flag_asynchronous_exceptions = asynchronous_exceptions;
8370
8371   if (!fndecl)
8372     return;
8373
8374   java_parser_context_save_global ();
8375   lineno = ctxp->last_ccb_indent1;
8376
8377   /* Set EH language codes */
8378   java_set_exception_lang_code ();
8379
8380   /* Turn function bodies with only a NOP expr null, so they don't get
8381      generated at all and we won't get warnings when using the -W
8382      -Wall flags. */
8383   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
8384     BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
8385
8386   /* Generate function's code */
8387   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
8388       && ! flag_emit_class_files
8389       && ! flag_emit_xref)
8390     expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
8391
8392   /* pop out of its parameters */
8393   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
8394   poplevel (1, 0, 1);
8395   BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
8396
8397   /* Generate rtl for function exit.  */
8398   if (! flag_emit_class_files && ! flag_emit_xref)
8399     {
8400       lineno = DECL_SOURCE_LINE_LAST (fndecl);
8401       /* Emit catch-finally clauses */
8402       emit_handlers ();
8403       expand_function_end (input_filename, lineno, 0);
8404
8405       /* FIXME: If the current method contains any exception handlers,
8406          force asynchronous_exceptions: this is necessary because signal
8407          handlers in libjava may throw exceptions.  This is far from being
8408          a perfect solution, but it's better than doing nothing at all.*/
8409       if (catch_clauses)
8410         asynchronous_exceptions = 1;
8411
8412       /* Run the optimizers and output assembler code for this function. */
8413       rest_of_compilation (fndecl);
8414     }
8415
8416   current_function_decl = NULL_TREE;
8417   /*  permanent_allocation (1); */
8418   java_parser_context_restore_global ();
8419   asynchronous_exceptions = flag_asynchronous_exceptions;
8420 }
8421
8422 /* Record EXPR in the current function block. Complements compound
8423    expression second operand if necessary.  */
8424
8425 tree
8426 java_method_add_stmt (fndecl, expr)
8427      tree fndecl, expr;
8428 {
8429   if (!GET_CURRENT_BLOCK (fndecl))
8430     return NULL_TREE;
8431   return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
8432 }
8433
8434 static tree
8435 add_stmt_to_block (b, type, stmt)
8436      tree b, type, stmt;
8437 {
8438   tree body = BLOCK_EXPR_BODY (b), c;
8439   
8440   if (java_error_count)
8441     return body;
8442     
8443   if ((c = add_stmt_to_compound (body, type, stmt)) == body)
8444     return body;
8445
8446   BLOCK_EXPR_BODY (b) = c;
8447   TREE_SIDE_EFFECTS (c) = 1;
8448   return c;
8449 }
8450
8451 /* Add STMT to EXISTING if possible, otherwise create a new
8452    COMPOUND_EXPR and add STMT to it. */
8453
8454 static tree
8455 add_stmt_to_compound (existing, type, stmt)
8456      tree existing, type, stmt;
8457 {
8458   if (existing)
8459     return build (COMPOUND_EXPR, type, existing, stmt);
8460   else
8461     return stmt;
8462 }
8463
8464 /* Hold THIS for the scope of the current public method decl.  */
8465 static tree current_this;
8466
8467 void java_layout_seen_class_methods ()
8468 {
8469   tree previous_list = all_class_list;
8470   tree end = NULL_TREE;
8471   tree current;
8472
8473   while (1)
8474     {
8475       for (current = previous_list; 
8476            current != end; current = TREE_CHAIN (current))
8477         layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
8478       
8479       if (previous_list != all_class_list)
8480         {
8481           end = previous_list;
8482           previous_list = all_class_list;
8483         }
8484       else
8485         break;
8486     }
8487 }
8488
8489 /* Layout the methods of all classes loaded in one way on an
8490    other. Check methods of source parsed classes. Then reorder the
8491    fields and layout the classes or the type of all source parsed
8492    classes */
8493
8494 void
8495 java_layout_classes ()
8496 {
8497   tree current;
8498   int save_error_count = java_error_count;
8499
8500   /* Layout the methods of all classes seen so far */
8501   java_layout_seen_class_methods ();
8502   java_parse_abort_on_error ();
8503   all_class_list = NULL_TREE;
8504
8505   /* Then check the methods of all parsed classes */
8506   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
8507     if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
8508       CHECK_METHODS (TREE_VALUE (current));
8509   java_parse_abort_on_error ();
8510
8511   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
8512     {
8513       current_class = TREE_TYPE (TREE_VALUE (current));
8514
8515       /* Reverse the fields, but leave the dummy field in front.
8516          Fields are already ordered for Object and Class */
8517       if (TYPE_FIELDS (current_class) && current_class != object_type_node
8518           && current_class != class_type_node)
8519       {
8520         /* If the dummy field is there, reverse the right fields and
8521            just layout the type for proper fields offset */
8522         if (!DECL_NAME (TYPE_FIELDS (current_class)))
8523           {
8524             tree fields = TYPE_FIELDS (current_class);
8525             TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
8526             TYPE_SIZE (current_class) = NULL_TREE;
8527             layout_type (current_class);
8528           }
8529         /* We don't have a dummy field, we need to layout the class,
8530            after having reversed the fields */
8531         else
8532           {
8533             TYPE_FIELDS (current_class) = 
8534               nreverse (TYPE_FIELDS (current_class));
8535             TYPE_SIZE (current_class) = NULL_TREE;
8536             layout_class (current_class);
8537           }
8538       }
8539       else
8540         layout_class (current_class);
8541
8542       /* From now on, the class is considered completely loaded */
8543       CLASS_LOADED_P (current_class) = 1;
8544
8545       /* Error reported by the caller */
8546       if (java_error_count)
8547         return;
8548     }
8549
8550   /* We might have reloaded classes durign the process of laying out
8551      classes for code generation. We must layout the methods of those
8552      late additions, as constructor checks might use them */
8553   java_layout_seen_class_methods ();
8554   java_parse_abort_on_error ();
8555 }
8556
8557 /* Expand all methods in all registered classes.  */
8558
8559 static void
8560 java_complete_expand_methods ()
8561 {
8562   tree current;
8563
8564   do_not_fold = flag_emit_xref;
8565   
8566   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
8567     {
8568       int is_interface;
8569       tree class_type = CLASS_TO_HANDLE_TYPE (TREE_TYPE (current));
8570       tree decl;
8571
8572       current_class = TREE_TYPE (current);
8573       is_interface = CLASS_INTERFACE (TYPE_NAME (current_class));
8574
8575       /* Initialize a new constant pool */
8576       init_outgoing_cpool ();
8577
8578       /* We want <clinit> (if any) to be processed first. */
8579       decl = tree_last (TYPE_METHODS (class_type));
8580       if (IS_CLINIT (decl))
8581         {
8582           tree fbody = DECL_FUNCTION_BODY (decl);
8583           tree list;
8584           if (fbody != NULL_TREE)
8585             {
8586               /* First check if we can ignore empty <clinit> */
8587               tree block_body = BLOCK_EXPR_BODY (fbody);
8588
8589               current_this = NULL_TREE;
8590               current_function_decl = decl;
8591               if (block_body != NULL_TREE)
8592                 {
8593                   /* Prevent the use of `this' inside <clinit> */
8594                   ctxp->explicit_constructor_p = 1;
8595
8596                   block_body = java_complete_tree (block_body);
8597                   ctxp->explicit_constructor_p = 0;
8598                   BLOCK_EXPR_BODY (fbody) = block_body;
8599                   if (block_body != NULL_TREE
8600                       && TREE_CODE (block_body) == BLOCK
8601                       && BLOCK_EXPR_BODY (block_body) == empty_stmt_node)
8602                     decl = NULL_TREE;
8603                 }
8604             }
8605           list = nreverse (TREE_CHAIN (nreverse (TYPE_METHODS (class_type))));
8606           if (decl != NULL_TREE)
8607             {
8608               TREE_CHAIN (decl) = list;
8609               TYPE_METHODS (class_type) = decl;
8610             }
8611             else
8612               TYPE_METHODS (class_type) = list;
8613         }
8614       
8615       for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
8616         {
8617           current_function_decl = decl;
8618           /* Don't generate debug info on line zero when expanding a
8619              generated constructor. */
8620           if (DECL_CONSTRUCTOR_P (decl) && !DECL_FUNCTION_BODY (decl))
8621             {
8622               /* If we found errors, it's too dangerous to try to
8623                  generate and expand a constructor */
8624               if (!java_error_count)
8625                 {
8626                   restore_line_number_status (1);
8627                   java_complete_expand_method (decl);
8628                   restore_line_number_status (0);
8629                   }
8630             }
8631           else if (METHOD_ABSTRACT (decl) || METHOD_NATIVE (decl))
8632             continue;
8633           else 
8634             java_complete_expand_method (decl);
8635         }
8636
8637       /* Now verify constructor circularity (stop after the first one
8638          we find) */
8639       if (!is_interface)
8640         for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
8641           if (DECL_CONSTRUCTOR_P (decl) && 
8642               verify_constructor_circularity (decl, decl))
8643             break;
8644
8645       /* Make the class data, register it and run the rest of decl
8646          compilation on it */
8647       if (!java_error_count)
8648         {
8649           if (flag_emit_class_files)
8650             write_classfile (current_class);
8651           if (flag_emit_xref)
8652             expand_xref (current_class);
8653           else if (! flag_syntax_only)
8654             finish_class ();
8655         }
8656     }
8657 }
8658
8659 /* Hold a list of catch clauses list. The first element of this list is
8660    the list of the catch clauses of the currently analysed try block. */
8661 static tree currently_caught_type_list;
8662
8663 /* Complete and expand a method.  */
8664
8665 static void
8666 java_complete_expand_method (mdecl)
8667      tree mdecl;
8668 {
8669   /* Fix constructors before expanding them */
8670   if (DECL_CONSTRUCTOR_P (mdecl))
8671     fix_constructors (mdecl);
8672   
8673   /* Expand functions that have a body */
8674   if (DECL_FUNCTION_BODY (mdecl))
8675     {
8676       tree fbody = DECL_FUNCTION_BODY (mdecl);
8677       tree block_body = BLOCK_EXPR_BODY (fbody);
8678       tree exception_copy = NULL_TREE;
8679       expand_start_java_method (mdecl);
8680       build_result_decl (mdecl);
8681
8682       current_this 
8683         = (!METHOD_STATIC (mdecl) ? 
8684            BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
8685
8686       /* Purge the `throws' list of unchecked exceptions. If we're
8687          doing xref, save a copy of the list and re-install it
8688          later. */
8689       if (flag_emit_xref)
8690         exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
8691
8692       purge_unchecked_exceptions (mdecl);
8693
8694       /* Install exceptions thrown with `throws' */
8695       PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
8696
8697       if (block_body != NULL_TREE)
8698         {
8699           block_body = java_complete_tree (block_body);
8700           if (!flag_emit_xref)
8701             check_for_initialization (block_body);
8702           ctxp->explicit_constructor_p = 0;
8703         }
8704       BLOCK_EXPR_BODY (fbody) = block_body;
8705
8706       if ((block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
8707           && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
8708           && !flag_emit_xref)
8709         missing_return_error (current_function_decl);
8710
8711       complete_start_java_method (mdecl); 
8712
8713       /* Don't go any further if we've found error(s) during the
8714          expansion */
8715       if (!java_error_count)
8716         source_end_java_method ();
8717       else
8718         {
8719           pushdecl_force_head (DECL_ARGUMENTS (mdecl));
8720           poplevel (1, 0, 1);
8721         }
8722
8723       /* Pop the exceptions and sanity check */
8724       POP_EXCEPTIONS();
8725       if (currently_caught_type_list)
8726         fatal ("Exception list non empty - java_complete_expand_method");
8727
8728       if (flag_emit_xref)
8729         DECL_FUNCTION_THROWS (mdecl) = exception_copy;
8730     }
8731 }
8732
8733 /* Craft a body for default constructor. Patch existing constructor
8734    bodies with call to super() and field initialization statements if
8735    necessary.  */
8736
8737 static void
8738 fix_constructors (mdecl)
8739      tree mdecl;
8740 {
8741   tree body = DECL_FUNCTION_BODY (mdecl);
8742
8743   if (!body)
8744     {
8745       /* The constructor body must be crafted by hand. It's the
8746          constructor we defined when we realize we didn't have the
8747          CLASSNAME() constructor */
8748
8749       tree compound;
8750
8751       /* It is an error for the compiler to generate a default
8752          constructor if the superclass doesn't have a constructor that
8753          takes no argument */
8754       if (verify_constructor_super ())
8755         {
8756           tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (current_class));
8757           const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
8758           parse_error_context (lookup_cl (TYPE_NAME (current_class)), 
8759                                "No constructor matching `%s()' found in "
8760                                "class `%s'", n, n);
8761         }
8762       
8763       start_artificial_method_body (mdecl);
8764       
8765       /* We don't generate a super constructor invocation if we're
8766          compiling java.lang.Object. build_super_invocation takes care
8767          of that. */
8768       compound = java_method_add_stmt (mdecl, build_super_invocation ());
8769
8770       end_artificial_method_body (mdecl);
8771     }
8772   /* Search for an explicit constructor invocation */
8773   else 
8774     {
8775       int found = 0;
8776       tree main_block = BLOCK_EXPR_BODY (body);
8777       tree compound = NULL_TREE;
8778       
8779       while (body)
8780         switch (TREE_CODE (body))
8781           {
8782           case CALL_EXPR:
8783             found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
8784             body = NULL_TREE;
8785             break;
8786           case COMPOUND_EXPR:
8787           case EXPR_WITH_FILE_LOCATION:
8788             body = TREE_OPERAND (body, 0);
8789             break;
8790           case BLOCK:
8791             body = BLOCK_EXPR_BODY (body);
8792             break;
8793           default:
8794             found = 0;
8795             body = NULL_TREE;
8796           }
8797       /* The constructor is missing an invocation of super() */
8798       if (!found)
8799         compound = add_stmt_to_compound (compound, NULL_TREE,
8800                                          build_super_invocation ());
8801       
8802       /* Fix the constructor main block if we're adding extra stmts */
8803       if (compound)
8804         {
8805           compound = add_stmt_to_compound (compound, NULL_TREE,
8806                                            BLOCK_EXPR_BODY (main_block));
8807           BLOCK_EXPR_BODY (main_block) = compound;
8808         }
8809     }
8810 }
8811
8812 /* Browse constructors in the super class, searching for a constructor
8813    that doesn't take any argument. Return 0 if one is found, 1
8814    otherwise. */
8815
8816 static int
8817 verify_constructor_super ()
8818 {
8819   tree class = CLASSTYPE_SUPER (current_class);
8820   if (!class)
8821     return 0;
8822
8823   if (class)
8824     {
8825       tree mdecl;
8826       for (mdecl = TYPE_METHODS (class); mdecl; mdecl = TREE_CHAIN (mdecl))
8827         {
8828           if (DECL_CONSTRUCTOR_P (mdecl)
8829               && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (mdecl))) 
8830                  == end_params_node)
8831             return 0;
8832         }
8833     }
8834   return 1;
8835 }
8836
8837 /* Expand finals.  */
8838
8839 static void
8840 java_expand_finals ()
8841 {
8842 }
8843
8844 /* Generate code for all context remembered for code generation.  */
8845
8846 void
8847 java_expand_classes ()
8848 {
8849   int save_error_count = 0;
8850   java_parse_abort_on_error ();
8851   if (!(ctxp = ctxp_for_generation))
8852     return;
8853   java_layout_classes ();
8854   java_parse_abort_on_error ();
8855
8856   for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
8857     {
8858       ctxp = ctxp_for_generation;
8859       lang_init_source (2);            /* Error msgs have method prototypes */
8860       java_complete_expand_methods (); /* Complete and expand method bodies */
8861       java_parse_abort_on_error ();
8862       java_expand_finals ();          /* Expand and check the finals */
8863       java_parse_abort_on_error ();
8864       java_check_final ();            /* Check unitialized final  */
8865       java_parse_abort_on_error ();
8866     }
8867 }
8868
8869 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
8870    a tree list node containing RIGHT. Fore coming RIGHTs will be
8871    chained to this hook. LOCATION contains the location of the
8872    separating `.' operator.  */
8873
8874 static tree
8875 make_qualified_primary (primary, right, location)
8876      tree primary, right;
8877      int location;
8878 {
8879   tree wfl;
8880
8881   /* We want to process THIS . xxx symbolicaly, to keep it consistent
8882      with the way we're processing SUPER. A THIS from a primary as a
8883      different form than a SUPER. Turn THIS into something symbolic */
8884   if (TREE_CODE (primary) == THIS_EXPR)
8885     {
8886       wfl = build_wfl_node (this_identifier_node);
8887       EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (primary);
8888       wfl = make_qualified_name (wfl, right, location);
8889       PRIMARY_P (wfl) = 1;
8890       return wfl;
8891     }
8892   /* Other non WFL node are wrapped around a WFL */
8893   else if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
8894     {
8895       wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
8896       EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (primary);
8897       EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (primary, NULL_TREE);
8898     }
8899   else
8900     {
8901       wfl = primary;
8902       if (!EXPR_WFL_QUALIFICATION (primary))
8903         EXPR_WFL_QUALIFICATION (primary) = 
8904           build_tree_list (primary, NULL_TREE);
8905     }
8906
8907   EXPR_WFL_LINECOL (right) = location;
8908   chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
8909   PRIMARY_P (wfl) =  1;
8910   return wfl;
8911 }
8912
8913 /* Simple merge of two name separated by a `.' */
8914
8915 static tree
8916 merge_qualified_name (left, right)
8917      tree left, right;
8918 {
8919   tree node;
8920   obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
8921                 IDENTIFIER_LENGTH (left));
8922   obstack_1grow (&temporary_obstack, '.');
8923   obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
8924                  IDENTIFIER_LENGTH (right));
8925   node =  get_identifier (obstack_base (&temporary_obstack));
8926   obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
8927   QUALIFIED_P (node) = 1;
8928   return node;
8929 }
8930
8931 /* Merge the two parts of a qualified name into LEFT.  Set the
8932    location information of the resulting node to LOCATION, usually
8933    inherited from the location information of the `.' operator. */
8934
8935 static tree
8936 make_qualified_name (left, right, location)
8937      tree left, right;
8938      int location;
8939 {
8940 #ifdef USE_COMPONENT_REF
8941   tree node = build (COMPONENT_REF, NULL_TREE, left, right);
8942   EXPR_WFL_LINECOL (node) = location;
8943   return node;
8944 #else
8945   tree left_id = EXPR_WFL_NODE (left);
8946   tree right_id = EXPR_WFL_NODE (right);
8947   tree wfl, merge;
8948
8949   merge = merge_qualified_name (left_id, right_id);
8950
8951   /* Left wasn't qualified and is now qualified */
8952   if (!QUALIFIED_P (left_id))
8953     {
8954       tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
8955       EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
8956       EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
8957     }
8958   
8959   wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
8960   EXPR_WFL_LINECOL (wfl) = location;
8961   chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
8962
8963   EXPR_WFL_NODE (left) = merge;
8964   return left;
8965 #endif
8966 }
8967
8968 /* Extract the last identifier component of the qualified in WFL. The
8969    last identifier is removed from the linked list */
8970
8971 static tree
8972 cut_identifier_in_qualified (wfl)
8973      tree wfl;
8974 {
8975   tree q;
8976   tree previous = NULL_TREE;
8977   for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
8978     if (!TREE_CHAIN (q))
8979       {
8980         if (!previous)
8981           fatal ("Operating on a non qualified qualified WFL - "
8982                  "cut_identifier_in_qualified");
8983         TREE_CHAIN (previous) = NULL_TREE;
8984         return TREE_PURPOSE (q);
8985       }
8986 }
8987
8988 /* Resolve the expression name NAME. Return its decl.  */
8989
8990 static tree
8991 resolve_expression_name (id, orig)
8992      tree id;
8993      tree *orig;
8994 {
8995   tree name = EXPR_WFL_NODE (id);
8996   tree decl;
8997
8998   /* 6.5.5.1: Simple expression names */
8999   if (!PRIMARY_P (id) && !QUALIFIED_P (name))
9000     {
9001       /* 15.13.1: NAME can appear within the scope of a local variable
9002          declaration */
9003       if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
9004         return decl;
9005
9006       /* 15.13.1: NAME can appear within a class declaration */
9007       else 
9008         {
9009           decl = lookup_field_wrapper (current_class, name);
9010           if (decl)
9011             {
9012               int fs = FIELD_STATIC (decl);
9013               /* Instance variable (8.3.1.1) can't appear within
9014                  static method, static initializer or initializer for
9015                  a static variable. */
9016               if (!fs && METHOD_STATIC (current_function_decl))
9017                 {
9018                   static_ref_err (id, name, current_class);
9019                   return error_mark_node;
9020                 }
9021               /* Instance variables can't appear as an argument of
9022                  an explicit constructor invocation */
9023               if (!fs && ctxp->explicit_constructor_p)
9024                 {
9025                   parse_error_context
9026                     (id, "Can't reference `%s' before the superclass "
9027                      "constructor has been called", IDENTIFIER_POINTER (name));
9028                   return error_mark_node;
9029                 }
9030
9031               /* Otherwise build what it takes to access the field */
9032               decl = build_field_ref ((fs ? NULL_TREE : current_this),
9033                                       DECL_CONTEXT (decl), name);
9034               if (fs && !flag_emit_class_files && !flag_emit_xref)
9035                 decl = build_class_init (DECL_CONTEXT (decl), decl);
9036               /* We may be asked to save the real field access node */
9037               if (orig)
9038                 *orig = decl;
9039               /* And we return what we got */
9040               return decl;
9041             }
9042           /* Fall down to error report on undefined variable */
9043         }
9044     }
9045   /* 6.5.5.2 Qualified Expression Names */
9046   else
9047     {
9048       if (orig)
9049         *orig = NULL_TREE;
9050       qualify_ambiguous_name (id);
9051       /* 15.10.1 Field Access Using a Primary and/or Expression Name */
9052       /* 15.10.2: Accessing Superclass Members using super */
9053       return resolve_field_access (id, NULL, NULL);
9054     }
9055
9056   /* We've got an error here */
9057   parse_error_context (id, "Undefined variable `%s'", 
9058                        IDENTIFIER_POINTER (name));
9059
9060   return error_mark_node;
9061 }
9062
9063 static void
9064 static_ref_err (wfl, field_id, class_type)
9065     tree wfl, field_id, class_type;
9066 {
9067   parse_error_context 
9068     (wfl, 
9069      "Can't make a static reference to nonstatic variable `%s' in class `%s'",
9070      IDENTIFIER_POINTER (field_id), 
9071      IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
9072 }
9073
9074 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
9075    We return something suitable to generate the field access. We also
9076    return the field decl in FIELD_DECL and its type in FIELD_TYPE.  If
9077    recipient's address can be null. */
9078
9079 static tree
9080 resolve_field_access (qual_wfl, field_decl, field_type)
9081      tree qual_wfl;
9082      tree *field_decl, *field_type;
9083 {
9084   int is_static = 0;
9085   tree field_ref;
9086   tree decl, where_found, type_found;
9087
9088   if (resolve_qualified_expression_name (qual_wfl, &decl,
9089                                          &where_found, &type_found))
9090     return error_mark_node;
9091
9092   /* Resolve the LENGTH field of an array here */
9093   if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
9094       && ! flag_emit_class_files && ! flag_emit_xref)
9095     {
9096       tree length = build_java_array_length_access (where_found);
9097       field_ref =
9098         build_java_arraynull_check (type_found, length, int_type_node);
9099     }
9100   /* We might have been trying to resolve field.method(). In which
9101      case, the resolution is over and decl is the answer */
9102   else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
9103     field_ref = decl;
9104   else if (JDECL_P (decl))
9105     {
9106       int static_final_found = 0;
9107       if (!type_found)
9108         type_found = DECL_CONTEXT (decl);
9109       is_static = JDECL_P (decl) && FIELD_STATIC (decl);
9110       if (FIELD_FINAL (decl) 
9111           && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
9112           && DECL_LANG_SPECIFIC (decl)
9113           && DECL_INITIAL (decl))
9114         {
9115           field_ref = DECL_INITIAL (decl);
9116           static_final_found = 1;
9117         }
9118       else
9119         field_ref = build_field_ref ((is_static && !flag_emit_xref? 
9120                                       NULL_TREE : where_found), 
9121                                      type_found, DECL_NAME (decl));
9122       if (field_ref == error_mark_node)
9123         return error_mark_node;
9124       if (is_static && !static_final_found 
9125           && !flag_emit_class_files && !flag_emit_xref)
9126         {
9127           field_ref = build_class_init (type_found, field_ref);
9128           /* If the static field was identified by an expression that
9129              needs to be generated, make the field access a compound
9130              expression whose first part is the evaluation of the
9131              field selector part. */
9132           if (where_found && TREE_CODE (where_found) != TYPE_DECL 
9133               && TREE_CODE (where_found) != RECORD_TYPE)
9134             {
9135               tree type = QUAL_DECL_TYPE (field_ref);
9136               if (TREE_CODE (type) == RECORD_TYPE)
9137                 type = build_pointer_type (type);
9138               field_ref = build (COMPOUND_EXPR, type, where_found, field_ref);
9139             }
9140         }
9141     }
9142   else
9143     field_ref = decl;
9144
9145   if (field_decl)
9146     *field_decl = decl;
9147   if (field_type)
9148     *field_type = (QUAL_DECL_TYPE (decl) ? 
9149                    QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
9150   return field_ref;
9151 }
9152
9153 /* If NODE is an access to f static field, strip out the class
9154    initialization part and return the field decl, otherwise, return
9155    NODE. */
9156
9157 static tree
9158 strip_out_static_field_access_decl (node)
9159     tree node;
9160 {
9161   if (TREE_CODE (node) == COMPOUND_EXPR)
9162     {
9163       tree op1 = TREE_OPERAND (node, 1);
9164       if (TREE_CODE (op1) == COMPOUND_EXPR)
9165          {
9166            tree call = TREE_OPERAND (op1, 0);
9167            if (TREE_CODE (call) == CALL_EXPR
9168                && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
9169                && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
9170                == soft_initclass_node)
9171              return TREE_OPERAND (op1, 1);
9172          }
9173       else if (JDECL_P (op1))
9174         return op1;
9175     }
9176   return node;
9177 }
9178
9179 /* 6.5.5.2: Qualified Expression Names */
9180
9181 static int
9182 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
9183      tree wfl;
9184      tree *found_decl, *type_found, *where_found;
9185 {
9186   int from_type = 0;            /* Field search initiated from a type */
9187   int from_super = 0, from_cast = 0;
9188   int previous_call_static = 0;
9189   int is_static;
9190   tree decl = NULL_TREE, type = NULL_TREE, q;
9191   *type_found = *where_found = NULL_TREE;
9192
9193   for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
9194     {
9195       tree qual_wfl = QUAL_WFL (q);
9196       tree ret_decl;            /* for EH checking */
9197       int location;             /* for EH checking */
9198
9199       /* 15.10.1 Field Access Using a Primary */
9200       switch (TREE_CODE (qual_wfl))
9201         {
9202         case CALL_EXPR:
9203         case NEW_CLASS_EXPR:
9204           /* If the access to the function call is a non static field,
9205              build the code to access it. */
9206           if (JDECL_P (decl) && !FIELD_STATIC (decl))
9207             {
9208               decl = maybe_access_field (decl, *where_found, 
9209                                          DECL_CONTEXT (decl));
9210               if (decl == error_mark_node)
9211                 return 1;
9212             }
9213           /* And code for the function call */
9214           if (complete_function_arguments (qual_wfl))
9215             return 1;
9216           
9217           if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
9218             CALL_USING_SUPER (qual_wfl) = 1;
9219           location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
9220                       EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
9221           *where_found = patch_method_invocation (qual_wfl, decl, type, 
9222                                                   &is_static, &ret_decl);
9223           if (*where_found == error_mark_node)
9224             return 1;
9225           *type_found = type = QUAL_DECL_TYPE (*where_found);
9226
9227           /* EH check */
9228           if (location)
9229             check_thrown_exceptions (location, ret_decl);
9230
9231           /* If the previous call was static and this one is too,
9232              build a compound expression to hold the two (because in
9233              that case, previous function calls aren't transported as
9234              forcoming function's argument. */
9235           if (previous_call_static && is_static)
9236             {
9237               decl = build (COMPOUND_EXPR, type, decl, *where_found);
9238               TREE_SIDE_EFFECTS (decl) = 1;
9239             }
9240           else
9241             {
9242               previous_call_static = is_static;
9243               decl = *where_found;
9244             }
9245           continue;
9246
9247         case NEW_ARRAY_EXPR:
9248           *where_found = decl = java_complete_tree (qual_wfl);
9249           if (decl == error_mark_node)
9250             return 1;
9251           *type_found = type = QUAL_DECL_TYPE (decl);
9252           CLASS_LOADED_P (type) = 1;
9253           continue;
9254
9255         case CONVERT_EXPR:
9256           *where_found = decl = java_complete_tree (qual_wfl);
9257           if (decl == error_mark_node)
9258             return 1;
9259           *type_found = type = QUAL_DECL_TYPE (decl);
9260           from_cast = 1;
9261           continue;
9262
9263         case CONDITIONAL_EXPR:
9264         case STRING_CST:
9265         case MODIFY_EXPR:
9266           *where_found = decl = java_complete_tree (qual_wfl);
9267           if (decl == error_mark_node)
9268             return 1;
9269           *type_found = type = QUAL_DECL_TYPE (decl);
9270           continue;
9271
9272         case ARRAY_REF:
9273           /* If the access to the function call is a non static field,
9274              build the code to access it. */
9275           if (JDECL_P (decl) && !FIELD_STATIC (decl))
9276             {
9277               decl = maybe_access_field (decl, *where_found, type);
9278               if (decl == error_mark_node)
9279                 return 1;
9280             }
9281           /* And code for the array reference expression */
9282           decl = java_complete_tree (qual_wfl);
9283           if (decl == error_mark_node)
9284             return 1;
9285           type = QUAL_DECL_TYPE (decl);
9286           continue;
9287
9288         default:
9289           /* Fix for -Wall Just go to the next statement. Don't
9290              continue */
9291           break;
9292         }
9293
9294       /* If we fall here, we weren't processing a (static) function call. */
9295       previous_call_static = 0;
9296
9297       /* It can be the keyword THIS */
9298       if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
9299         {
9300           if (!current_this)
9301             {
9302               parse_error_context 
9303                 (wfl, "Keyword `this' used outside allowed context");
9304               return 1;
9305             }
9306           /* We have to generate code for intermediate acess */
9307           *where_found = decl = current_this;
9308           *type_found = type = QUAL_DECL_TYPE (decl);
9309           continue;
9310         }
9311
9312       /* 15.10.2 Accessing Superclass Members using SUPER */
9313       if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
9314         {
9315           tree node;
9316           /* Check on the restricted use of SUPER */
9317           if (METHOD_STATIC (current_function_decl)
9318               || current_class == object_type_node)
9319             {
9320               parse_error_context 
9321                 (wfl, "Keyword `super' used outside allowed context");
9322               return 1;
9323             }
9324           /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
9325           node = build_cast (EXPR_WFL_LINECOL (qual_wfl), 
9326                              CLASSTYPE_SUPER (current_class),
9327                              build_this (EXPR_WFL_LINECOL (qual_wfl)));
9328           *where_found = decl = java_complete_tree (node);
9329           if (decl == error_mark_node)
9330             return 1;
9331           *type_found = type = QUAL_DECL_TYPE (decl);
9332           from_super = from_type = 1;
9333           continue;
9334         }
9335
9336       /* 15.13.1: Can't search for field name in packages, so we
9337          assume a variable/class name was meant. */
9338       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
9339         {
9340           tree name = resolve_package (wfl, &q);
9341           if (name)
9342             {
9343               *where_found = decl = resolve_no_layout (name, qual_wfl);
9344               /* We wan't to be absolutely that the class is laid
9345                  out. We're going to search something inside it. */
9346               *type_found = type = TREE_TYPE (decl);
9347               layout_class (type);
9348               from_type = 1;
9349               /* Should be a list, really. FIXME */
9350               RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (TREE_CHAIN (q))) = 1;
9351               RESOLVE_PACKAGE_NAME_P (QUAL_WFL (TREE_CHAIN (q))) = 0;
9352             }
9353           else
9354             {
9355               if (from_super || from_cast)
9356                 parse_error_context 
9357                   ((from_cast ? qual_wfl : wfl),
9358                    "No variable `%s' defined in class `%s'",
9359                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
9360                    lang_printable_name (type, 0));
9361               else
9362                 parse_error_context
9363                   (qual_wfl, "Undefined variable or class name: `%s'",
9364                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
9365               return 1;
9366             }
9367         }
9368
9369       /* We have a type name. It's been already resolved when the
9370          expression was qualified. */
9371       else if (RESOLVE_TYPE_NAME_P (qual_wfl))
9372         {
9373           if (!(decl = QUAL_RESOLUTION (q)))
9374             return 1;           /* Error reported already */
9375
9376           if (not_accessible_p (TREE_TYPE (decl), decl, 0))
9377             {
9378               parse_error_context 
9379                 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
9380                  java_accstring_lookup (get_access_flags_from_decl (decl)),
9381                  GET_TYPE_NAME (type),
9382                  IDENTIFIER_POINTER (DECL_NAME (decl)),
9383                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
9384               return 1;
9385             }
9386           check_deprecation (qual_wfl, decl);
9387           
9388           type = TREE_TYPE (decl);
9389           from_type = 1;
9390         }
9391       /* We resolve and expression name */
9392       else 
9393         {
9394           tree field_decl = NULL_TREE;
9395
9396           /* If there exists an early resolution, use it. That occurs
9397              only once and we know that there are more things to
9398              come. Don't do that when processing something after SUPER
9399              (we need more thing to be put in place below */
9400           if (!from_super && QUAL_RESOLUTION (q))
9401             {
9402               decl = QUAL_RESOLUTION (q);
9403               if (!type)
9404                 {
9405                   if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
9406                     {
9407                       if (current_this)
9408                         *where_found = current_this;
9409                       else
9410                         {
9411                           static_ref_err (qual_wfl, DECL_NAME (decl),
9412                                           current_class);
9413                           return 1;
9414                         }
9415                     }
9416                   else
9417                     {
9418                       *where_found = TREE_TYPE (decl);
9419                       if (TREE_CODE (*where_found) == POINTER_TYPE)
9420                         *where_found = TREE_TYPE (*where_found);
9421                     }
9422                 }
9423             }
9424
9425           /* We have to search for a field, knowing the type of its
9426              container. The flag FROM_TYPE indicates that we resolved
9427              the last member of the expression as a type name, which
9428              means that for the resolution of this field, we'll look
9429              for other errors than if it was resolved as a member of
9430              an other field. */
9431           else
9432             {
9433               int is_static;
9434               tree field_decl_type; /* For layout */
9435
9436               if (!from_type && !JREFERENCE_TYPE_P (type))
9437                 {
9438                   parse_error_context 
9439                     (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
9440                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
9441                      lang_printable_name (type, 0),
9442                      IDENTIFIER_POINTER (DECL_NAME (field_decl)));
9443                   return 1;
9444                 }
9445               
9446               field_decl = lookup_field_wrapper (type,
9447                                                  EXPR_WFL_NODE (qual_wfl));
9448               if (field_decl == NULL_TREE)
9449                 {
9450                   parse_error_context 
9451                     (qual_wfl, "No variable `%s' defined in type `%s'",
9452                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)), 
9453                      GET_TYPE_NAME (type));
9454                   return 1;
9455                 }
9456               if (field_decl == error_mark_node)
9457                 return 1;
9458
9459               /* Layout the type of field_decl, since we may need
9460                  it. Don't do primitive types or loaded classes. The
9461                  situation of non primitive arrays may not handled
9462                  properly here. FIXME */
9463               if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
9464                 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
9465               else
9466                 field_decl_type = TREE_TYPE (field_decl);
9467               if (!JPRIMITIVE_TYPE_P (field_decl_type) 
9468                   && !CLASS_LOADED_P (field_decl_type)
9469                   && !TYPE_ARRAY_P (field_decl_type))
9470                 resolve_and_layout (field_decl_type, NULL_TREE);
9471               if (TYPE_ARRAY_P (field_decl_type))
9472                 CLASS_LOADED_P (field_decl_type) = 1;
9473               
9474               /* Check on accessibility here */
9475               if (not_accessible_p (type, field_decl, from_super))
9476                 {
9477                   parse_error_context 
9478                     (qual_wfl,
9479                      "Can't access %s field `%s.%s' from `%s'",
9480                      java_accstring_lookup 
9481                        (get_access_flags_from_decl (field_decl)),
9482                      GET_TYPE_NAME (type),
9483                      IDENTIFIER_POINTER (DECL_NAME (field_decl)),
9484                      IDENTIFIER_POINTER 
9485                        (DECL_NAME (TYPE_NAME (current_class))));
9486                   return 1;
9487                 }
9488               check_deprecation (qual_wfl, field_decl);
9489               
9490               /* There are things to check when fields are accessed
9491                  from type. There are no restrictions on a static
9492                  declaration of the field when it is accessed from an
9493                  interface */
9494               is_static = FIELD_STATIC (field_decl);
9495               if (!from_super && from_type 
9496                   && !TYPE_INTERFACE_P (type) && !is_static)
9497                 {
9498                   static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
9499                   return 1;
9500                 }
9501               from_cast = from_super = 0;
9502
9503               /* If we need to generate something to get a proper
9504                  handle on what this field is accessed from, do it
9505                  now. */
9506               if (!is_static)
9507                 {
9508                   decl = maybe_access_field (decl, *where_found, *type_found);
9509                   if (decl == error_mark_node)
9510                     return 1;
9511                 }
9512
9513               /* We want to keep the location were found it, and the type
9514                  we found. */
9515               *where_found = decl;
9516               *type_found = type;
9517
9518               /* This is the decl found and eventually the next one to
9519                  search from */
9520               decl = field_decl;
9521             }
9522           from_type = 0;
9523           type = QUAL_DECL_TYPE (decl);
9524         }
9525     }
9526   *found_decl = decl;
9527   return 0;
9528 }
9529
9530 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
9531    can't be accessed from REFERENCE (a record type). */
9532
9533 static int
9534 not_accessible_p (reference, member, from_super)
9535      tree reference, member;
9536      int from_super;
9537 {
9538   int access_flag = get_access_flags_from_decl (member);
9539
9540   /* Access always granted for members declared public */
9541   if (access_flag & ACC_PUBLIC)
9542     return 0;
9543   
9544   /* Check access on protected members */
9545   if (access_flag & ACC_PROTECTED)
9546     {
9547       /* Access granted if it occurs from within the package
9548          containing the class in which the protected member is
9549          declared */
9550       if (class_in_current_package (DECL_CONTEXT (member)))
9551         return 0;
9552
9553       /* If accessed with the form `super.member', then access is granted */
9554       if (from_super)
9555         return 0;
9556
9557       /* Otherwise, access is granted if occuring from the class where
9558          member is declared or a subclass of it */
9559       if (inherits_from_p (reference, current_class))
9560         return 0;
9561       return 1;
9562     }
9563
9564   /* Check access on private members. Access is granted only if it
9565      occurs from within the class in witch it is declared */
9566   if (access_flag & ACC_PRIVATE)
9567     return (current_class == DECL_CONTEXT (member) ? 0 : 1);
9568
9569   /* Default access are permitted only when occuring within the
9570      package in which the type (REFERENCE) is declared. In other words,
9571      REFERENCE is defined in the current package */
9572   if (ctxp->package)
9573     return !class_in_current_package (reference);
9574   
9575   /* Otherwise, access is granted */
9576   return 0;
9577 }
9578
9579 /* Test deprecated decl access.  */
9580 static void
9581 check_deprecation (wfl, decl)
9582      tree wfl, decl;
9583 {
9584   const char *file = DECL_SOURCE_FILE (decl);
9585   /* Complain if the field is deprecated and the file it was defined
9586      in isn't compiled at the same time the file which contains its
9587      use is */
9588   if (DECL_DEPRECATED (decl) 
9589       && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
9590     {
9591       char the [20];
9592       switch (TREE_CODE (decl))
9593         {
9594         case FUNCTION_DECL:
9595           strcpy (the, "method");
9596           break;
9597         case FIELD_DECL:
9598           strcpy (the, "field");
9599           break;
9600         case TYPE_DECL:
9601           strcpy (the, "class");
9602           break;
9603         default:
9604           fatal ("unexpected DECL code - check_deprecation");
9605         }
9606       parse_warning_context 
9607         (wfl, "The %s `%s' in class `%s' has been deprecated", 
9608          the, lang_printable_name (decl, 0),
9609          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
9610     }
9611 }
9612
9613 /* Returns 1 if class was declared in the current package, 0 otherwise */
9614
9615 static int
9616 class_in_current_package (class)
9617      tree class;
9618 {
9619   static tree cache = NULL_TREE;
9620   int qualified_flag;
9621   tree left;
9622
9623   if (cache == class)
9624     return 1;
9625
9626   qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
9627
9628   /* If the current package is empty and the name of CLASS is
9629      qualified, class isn't in the current package.  If there is a
9630      current package and the name of the CLASS is not qualified, class
9631      isn't in the current package */
9632   if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
9633     return 0;
9634
9635   /* If there is not package and the name of CLASS isn't qualified,
9636      they belong to the same unnamed package */
9637   if (!ctxp->package && !qualified_flag)
9638     return 1;
9639
9640   /* Compare the left part of the name of CLASS with the package name */
9641   breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
9642   if (ctxp->package == left)
9643     {
9644       cache = class;
9645       return 1;
9646     }
9647   return 0;
9648 }
9649
9650 /* This function may generate code to access DECL from WHERE. This is
9651    done only if certain conditions meet.  */
9652
9653 static tree
9654 maybe_access_field (decl, where, type)
9655   tree decl, where, type;
9656 {
9657   if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
9658       && !FIELD_STATIC (decl))
9659     decl = build_field_ref (where ? where : current_this, 
9660                             (type ? type : DECL_CONTEXT (decl)),
9661                             DECL_NAME (decl));
9662   return decl;
9663 }
9664
9665 /* Build a method invocation, by patching PATCH. If non NULL
9666    and according to the situation, PRIMARY and WHERE may be
9667    used. IS_STATIC is set to 1 if the invoked function is static. */
9668
9669 static tree
9670 patch_method_invocation (patch, primary, where, is_static, ret_decl)
9671      tree patch, primary, where;
9672      int *is_static;
9673      tree *ret_decl;
9674 {
9675   tree wfl = TREE_OPERAND (patch, 0);
9676   tree args = TREE_OPERAND (patch, 1);
9677   tree name = EXPR_WFL_NODE (wfl);
9678   tree list;
9679   int is_static_flag = 0;
9680   int is_super_init = 0;
9681   tree this_arg = NULL_TREE;
9682   
9683   /* Should be overriden if everything goes well. Otherwise, if
9684      something fails, it should keep this value. It stop the
9685      evaluation of a bogus assignment. See java_complete_tree,
9686      MODIFY_EXPR: for the reasons why we sometimes want to keep on
9687      evaluating an assignment */
9688   TREE_TYPE (patch) = error_mark_node;
9689
9690   /* Since lookup functions are messing with line numbers, save the
9691      context now.  */
9692   java_parser_context_save_global ();
9693
9694   /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
9695
9696   /* Resolution of qualified name, excluding constructors */
9697   if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
9698     {
9699       tree class_decl, identifier, identifier_wfl;
9700       /* Extract the last IDENTIFIER of the qualified
9701          expression. This is a wfl and we will use it's location
9702          data during error report. */
9703       identifier_wfl = cut_identifier_in_qualified (wfl);
9704       identifier = EXPR_WFL_NODE (identifier_wfl);
9705       
9706       /* Given the context, IDENTIFIER is syntactically qualified
9707          as a MethodName. We need to qualify what's before */
9708       qualify_ambiguous_name (wfl);
9709
9710       /* Package resolution */
9711       if (RESOLVE_PACKAGE_NAME_P (wfl))
9712         {
9713           tree next, decl, name = resolve_package (wfl, &next);
9714           
9715           if (!name)
9716             {
9717               tree remainder;
9718               breakdown_qualified (&remainder, NULL, EXPR_WFL_NODE (wfl));
9719               parse_error_context (wfl, "Can't search method `%s' in package "
9720                                    "`%s'",IDENTIFIER_POINTER (identifier),
9721                                    IDENTIFIER_POINTER (remainder));
9722               PATCH_METHOD_RETURN_ERROR ();
9723             }
9724           RESOLVE_PACKAGE_NAME_P (wfl) = 0;
9725           if ((decl = resolve_no_layout (name, QUAL_WFL (next))))
9726             {
9727               QUAL_RESOLUTION (EXPR_WFL_QUALIFICATION (wfl)) = decl;
9728               RESOLVE_EXPRESSION_NAME_P (wfl) = 0;
9729               RESOLVE_TYPE_NAME_P (wfl) = 1;
9730             }
9731           else
9732             {
9733               RESOLVE_EXPRESSION_NAME_P (wfl) = 1;
9734               RESOLVE_TYPE_NAME_P (wfl) = 0;
9735             }
9736         }
9737
9738       /* We're resolving a call from a type */
9739       if (RESOLVE_TYPE_NAME_P (wfl))
9740         {
9741           tree decl = QUAL_RESOLUTION (EXPR_WFL_QUALIFICATION (wfl));
9742           tree name = DECL_NAME (decl);
9743           tree type;
9744
9745           class_decl = resolve_and_layout (name, wfl);
9746           if (CLASS_INTERFACE (decl))
9747             {
9748               parse_error_context
9749                 (identifier_wfl, "Can't make static reference to method "
9750                  "`%s' in interface `%s'", IDENTIFIER_POINTER (identifier), 
9751                  IDENTIFIER_POINTER (name));
9752               PATCH_METHOD_RETURN_ERROR ();
9753             }
9754           /* Look the method up in the type selector. The method ought
9755              to be static. */
9756           type = TREE_TYPE (class_decl);
9757           list = lookup_method_invoke (0, wfl, type, identifier, args);
9758           if (list && !METHOD_STATIC (list))
9759             {
9760               char *fct_name = xstrdup (lang_printable_name (list, 0));
9761               parse_error_context 
9762                 (identifier_wfl,
9763                  "Can't make static reference to method `%s %s' in class `%s'",
9764                  lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
9765                  fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
9766               free (fct_name);
9767               PATCH_METHOD_RETURN_ERROR ();
9768             }
9769           args = nreverse (args);
9770         }
9771       /* We're resolving an expression name */
9772       else
9773         {
9774           tree field, type;
9775           
9776           /* 1- Find the field to which the call applies */
9777           field = resolve_field_access (wfl, NULL, &type);
9778           if (field == error_mark_node)
9779             PATCH_METHOD_RETURN_ERROR ();
9780           /* field is used in lieu of a primary. It alows us not to
9781            report errors on erroneous use of `this' in
9782            constructors. */
9783           primary = field;      
9784           
9785           /* 2- Do the layout of the class where the last field
9786              was found, so we can search it. */
9787           class_decl = resolve_and_layout (type, NULL_TREE);
9788           if (class_decl != NULL_TREE)
9789           type = TREE_TYPE (class_decl);
9790
9791           /* 3- Retrieve a filtered list of method matches, Refine
9792              if necessary. In any cases, point out errors.  */
9793           list = lookup_method_invoke (0, identifier_wfl, type, 
9794                                        identifier, args);
9795
9796           /* 4- Add the field as an argument */
9797           args = nreverse (args);
9798           this_arg = field;
9799         }
9800
9801       /* IDENTIFIER_WFL will be used to report any problem further */
9802       wfl = identifier_wfl;
9803     }
9804   /* Resolution of simple names, names generated after a primary: or
9805      constructors */
9806   else
9807     {
9808       tree class_to_search = NULL_TREE;
9809       int lc;           /* Looking for Constructor */
9810       
9811       /* We search constructor in their target class */
9812       if (CALL_CONSTRUCTOR_P (patch))
9813         {
9814           if (TREE_CODE (patch) == NEW_CLASS_EXPR)
9815             class_to_search = EXPR_WFL_NODE (wfl);
9816           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) == 
9817                    this_identifier_node)
9818             class_to_search = NULL_TREE;
9819           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
9820                    super_identifier_node)
9821             {
9822               is_super_init = 1;
9823               if (CLASSTYPE_SUPER (current_class))
9824                 class_to_search = 
9825                   DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
9826               else
9827                 {
9828                   parse_error_context (wfl, "Can't invoke super constructor "
9829                                        "on java.lang.Object");
9830                   PATCH_METHOD_RETURN_ERROR ();
9831                 }
9832             }
9833
9834           /* Class to search is NULL if we're searching the current one */
9835           if (class_to_search)
9836             {
9837               class_to_search = resolve_and_layout (class_to_search, 
9838                                                     NULL_TREE);
9839               if (!class_to_search)
9840                 {
9841                   parse_error_context 
9842                     (wfl, "Class `%s' not found in type declaration",
9843                      IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
9844                   PATCH_METHOD_RETURN_ERROR ();
9845                 }
9846               
9847               /* Can't instantiate an abstract class, but we can
9848                  invoke it's constructor. It's use within the `new'
9849                  context is denied here. */
9850               if (CLASS_ABSTRACT (class_to_search) 
9851                   && TREE_CODE (patch) == NEW_CLASS_EXPR)
9852                 {
9853                   parse_error_context 
9854                     (wfl, "Class `%s' is an abstract class. It can't be "
9855                      "instantiated", IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
9856                   PATCH_METHOD_RETURN_ERROR ();
9857                 }
9858               class_to_search = TREE_TYPE (class_to_search);
9859             }
9860           else
9861             class_to_search = current_class;
9862           lc = 1;
9863         }
9864       /* This is a regular search in the local class, unless an
9865          alternate class is specified. */
9866       else
9867         {
9868           class_to_search = (where ? where : current_class);
9869           lc = 0;
9870         }
9871       
9872       /* NAME is a simple identifier or comes from a primary. Search
9873          in the class whose declaration contain the method being
9874          invoked. */
9875       resolve_and_layout (class_to_search, NULL_TREE);
9876       list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
9877
9878       /* Don't continue if no method were found, as the next statement
9879          can't be executed then. */
9880       if (!list)
9881         PATCH_METHOD_RETURN_ERROR ();
9882
9883       /* Check for static reference if non static methods */
9884       if (check_for_static_method_reference (wfl, patch, list, 
9885                                              class_to_search, primary))
9886         PATCH_METHOD_RETURN_ERROR ();
9887
9888       /* Non static methods are called with the current object extra
9889          argument. If patch a `new TYPE()', the argument is the value
9890          returned by the object allocator. If method is resolved as a
9891          primary, use the primary otherwise use the current THIS. */
9892       args = nreverse (args);
9893       if (TREE_CODE (patch) != NEW_CLASS_EXPR)
9894         this_arg = primary ? primary : current_this;
9895     }
9896
9897   /* Merge point of all resolution schemes. If we have nothing, this
9898      is an error, already signaled */
9899   if (!list) 
9900     PATCH_METHOD_RETURN_ERROR ();
9901
9902   /* Check accessibility, position the is_static flag, build and
9903      return the call */
9904   if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
9905     {
9906       char *fct_name = xstrdup (lang_printable_name (list, 0));
9907       parse_error_context 
9908         (wfl, "Can't access %s method `%s %s.%s' from `%s'",
9909          java_accstring_lookup (get_access_flags_from_decl (list)),
9910          lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
9911          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))), 
9912          fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
9913       free (fct_name);
9914       PATCH_METHOD_RETURN_ERROR ();
9915     }
9916   check_deprecation (wfl, list);
9917
9918   is_static_flag = METHOD_STATIC (list);
9919   if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
9920     args = tree_cons (NULL_TREE, this_arg, args);
9921
9922   /* In the context of an explicit constructor invocation, we can't
9923      invoke any method relying on `this'. Exceptions are: we're
9924      invoking a static function, primary exists and is not the current
9925      this, we're creating a new object. */
9926   if (ctxp->explicit_constructor_p 
9927       && !is_static_flag 
9928       && (!primary || primary == current_this)
9929       && (TREE_CODE (patch) != NEW_CLASS_EXPR))
9930     {
9931       parse_error_context 
9932         (wfl, "Can't reference `this' before the superclass constructor has "
9933          "been called");
9934       PATCH_METHOD_RETURN_ERROR ();
9935     }
9936   java_parser_context_restore_global ();
9937   if (is_static) 
9938     *is_static = is_static_flag;
9939   /* Sometimes, we want the decl of the selected method. Such as for
9940      EH checking */
9941   if (ret_decl)
9942     *ret_decl = list;
9943   patch = patch_invoke (patch, list, args);
9944   if (is_super_init && CLASS_HAS_FINIT_P (current_class))
9945     {
9946       /* Generate the code used to initialize fields declared with an
9947          initialization statement. For now, it returns a call the the
9948          artificial function $finit$, if required. */
9949
9950       tree finit_call =
9951         build_method_invocation (build_expr_wfl (finit_identifier_node,  
9952                                                  input_filename, 0, 0),  
9953                                  NULL_TREE);
9954       patch = build (COMPOUND_EXPR, void_type_node, patch,
9955                      java_complete_tree (finit_call));
9956       CAN_COMPLETE_NORMALLY (patch) = 1;
9957     }
9958   return patch;
9959 }
9960
9961 /* Check that we're not trying to do a static reference to a method in
9962    non static method. Return 1 if it's the case, 0 otherwise. */
9963
9964 static int
9965 check_for_static_method_reference (wfl, node, method, where, primary)
9966      tree wfl, node, method, where, primary;
9967 {
9968   if (METHOD_STATIC (current_function_decl) 
9969       && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
9970     {
9971       char *fct_name = xstrdup (lang_printable_name (method, 0));
9972       parse_error_context 
9973         (wfl, "Can't make static reference to method `%s %s' in class `%s'", 
9974          lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
9975          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
9976       free (fct_name);
9977       return 1;
9978     }
9979   return 0;
9980 }
9981
9982 /* Patch an invoke expression METHOD and ARGS, based on its invocation
9983    mode.  */
9984
9985 static tree
9986 patch_invoke (patch, method, args)
9987      tree patch, method, args;
9988 {
9989   tree dtable, func;
9990   tree original_call, t, ta;
9991
9992   /* Last step for args: convert build-in types. If we're dealing with
9993      a new TYPE() type call, the first argument to the constructor
9994      isn't found in the incomming argument list, but delivered by
9995      `new' */
9996   t = TYPE_ARG_TYPES (TREE_TYPE (method));
9997   if (TREE_CODE (patch) == NEW_CLASS_EXPR)
9998     t = TREE_CHAIN (t);
9999   for (ta = args; t != end_params_node && ta; 
10000        t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
10001     if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
10002         TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
10003       TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
10004
10005   /* Resolve unresolved returned type isses */
10006   t = TREE_TYPE (TREE_TYPE (method));
10007   if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
10008     resolve_and_layout (TREE_TYPE (t), NULL);
10009   
10010   if (flag_emit_class_files || flag_emit_xref)
10011     func = method;
10012   else
10013     {
10014       tree signature = build_java_signature (TREE_TYPE (method));
10015       switch (invocation_mode (method, CALL_USING_SUPER (patch)))
10016         {
10017         case INVOKE_VIRTUAL:
10018           dtable = invoke_build_dtable (0, args);
10019           func = build_invokevirtual (dtable, method);
10020           break;
10021
10022         case INVOKE_SUPER:
10023         case INVOKE_STATIC:
10024           func = build_known_method_ref (method, TREE_TYPE (method),
10025                                          DECL_CONTEXT (method),
10026                                          signature, args);
10027           break;
10028
10029         case INVOKE_INTERFACE:
10030           dtable = invoke_build_dtable (1, args);
10031           func = build_invokeinterface (dtable, DECL_NAME (method), signature);
10032           break;
10033
10034         default:
10035           fatal ("internal error - unknown invocation_mode result");
10036         }
10037
10038       /* Ensure self_type is initialized, (invokestatic). FIXME */
10039       func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
10040     }
10041
10042   TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
10043   TREE_OPERAND (patch, 0) = func;
10044   TREE_OPERAND (patch, 1) = args;
10045   original_call = patch;
10046
10047   /* We're processing a `new TYPE ()' form. New is called an its
10048      returned value is the first argument to the constructor. We build
10049      a COMPOUND_EXPR and use saved expression so that the overall NEW
10050      expression value is a pointer to a newly created and initialized
10051      class. */
10052   if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
10053     {
10054       tree class = DECL_CONTEXT (method);
10055       tree c1, saved_new, size, new;
10056       if (flag_emit_class_files || flag_emit_xref)
10057         {
10058           TREE_TYPE (patch) = build_pointer_type (class);
10059           return patch;
10060         }
10061       if (!TYPE_SIZE (class))
10062         safe_layout_class (class);
10063       size = size_in_bytes (class);
10064       new = build (CALL_EXPR, promote_type (class),
10065                    build_address_of (alloc_object_node),
10066                    tree_cons (NULL_TREE, build_class_ref (class),
10067                               build_tree_list (NULL_TREE, 
10068                                                size_in_bytes (class))),
10069                    NULL_TREE);
10070       saved_new = save_expr (new);
10071       c1 = build_tree_list (NULL_TREE, saved_new);
10072       TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
10073       TREE_OPERAND (original_call, 1) = c1;
10074       TREE_SET_CODE (original_call, CALL_EXPR);
10075       patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
10076     }
10077   return patch;
10078 }
10079
10080 static int
10081 invocation_mode (method, super)
10082      tree method;
10083      int super;
10084 {
10085   int access = get_access_flags_from_decl (method);
10086
10087   if (super)
10088     return INVOKE_SUPER;
10089
10090   if (access & ACC_STATIC || access & ACC_FINAL || access & ACC_PRIVATE)
10091     return INVOKE_STATIC;
10092
10093   if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
10094     return INVOKE_STATIC;
10095   
10096   if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
10097     return INVOKE_INTERFACE;
10098   
10099   if (DECL_CONSTRUCTOR_P (method))
10100     return INVOKE_STATIC;
10101
10102   return INVOKE_VIRTUAL;
10103 }
10104
10105 /* Retrieve a refined list of matching methods. It covers the step
10106    15.11.2 (Compile-Time Step 2) */
10107
10108 static tree
10109 lookup_method_invoke (lc, cl, class, name, arg_list)
10110      int lc;
10111      tree cl;
10112      tree class, name, arg_list;
10113 {
10114   tree atl = end_params_node;           /* Arg Type List */
10115   tree method, signature, list, node;
10116   const char *candidates;               /* Used for error report */
10117
10118   /* Fix the arguments */
10119   for (node = arg_list; node; node = TREE_CHAIN (node))
10120     {
10121       tree current_arg = TREE_TYPE (TREE_VALUE (node));
10122       /* Non primitive type may have to be resolved */
10123       if (!JPRIMITIVE_TYPE_P (current_arg))
10124         resolve_and_layout (current_arg, NULL_TREE);
10125       /* And promoted */
10126       if (TREE_CODE (current_arg) == RECORD_TYPE)
10127         current_arg = promote_type (current_arg);
10128       atl = tree_cons (NULL_TREE, current_arg, atl);
10129     }
10130
10131   /* Find all candidates and then refine the list, searching for the
10132      most specific method. */
10133   list = find_applicable_accessible_methods_list (lc, class, name, atl);
10134   list = find_most_specific_methods_list (list);
10135   if (list && !TREE_CHAIN (list))
10136     return TREE_VALUE (list);
10137
10138   /* Issue an error. List candidates if any. Candidates are listed
10139      only if accessible (non accessible methods may end-up here for
10140      the sake of a better error report). */
10141   candidates = NULL;
10142   if (list)
10143     {
10144       tree current;
10145       obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
10146       for (current = list; current; current = TREE_CHAIN (current))
10147         {
10148           tree cm = TREE_VALUE (current);
10149           char string [4096];
10150           if (!cm || not_accessible_p (class, cm, 0))
10151             continue;
10152           sprintf 
10153             (string, "  `%s' in `%s'%s",
10154              get_printable_method_name (cm),
10155              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
10156              (TREE_CHAIN (current) ? "\n" : ""));
10157           obstack_grow (&temporary_obstack, string, strlen (string));
10158         }
10159       obstack_1grow (&temporary_obstack, '\0');
10160       candidates = obstack_finish (&temporary_obstack);
10161     }
10162   /* Issue the error message */
10163   method = make_node (FUNCTION_TYPE);
10164   TYPE_ARG_TYPES (method) = atl;
10165   signature = build_java_argument_signature (method);
10166   parse_error_context (cl, "Can't find %s `%s(%s)' in class `%s'%s",
10167                        (lc ? "constructor" : "method"),
10168                        (lc ? 
10169                         IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class))) :
10170                         IDENTIFIER_POINTER (name)),
10171                        IDENTIFIER_POINTER (signature),
10172                        IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class))),
10173                        (candidates ? candidates : ""));
10174   return NULL_TREE;
10175 }
10176
10177 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
10178    when we're looking for a constructor. */
10179
10180 static tree
10181 find_applicable_accessible_methods_list (lc, class, name, arglist)
10182      int lc;
10183      tree class, name, arglist;
10184 {
10185   tree list = NULL_TREE, all_list = NULL_TREE;
10186
10187   /* Search interfaces */
10188   if (CLASS_INTERFACE (TYPE_NAME (class)) 
10189       || CLASS_ABSTRACT (TYPE_NAME (class)))
10190     {
10191       static tree searched_interfaces = NULL_TREE;
10192       static int search_not_done = 0;
10193       int i, n;
10194       tree basetype_vec = TYPE_BINFO_BASETYPES (class);
10195
10196       /* Have we searched this interface already? */
10197       if (searched_interfaces)
10198         {  
10199           tree current;  
10200           for (current = searched_interfaces; 
10201                current; current = TREE_CHAIN (current))
10202             if (TREE_VALUE (current) == class)
10203               return NULL;
10204         }
10205       searched_interfaces = tree_cons (NULL_TREE, class, searched_interfaces);
10206
10207       search_applicable_methods_list 
10208         (lc, TYPE_METHODS (class), name, arglist, &list, &all_list);
10209
10210       n = TREE_VEC_LENGTH (basetype_vec);
10211       for (i = 0; i < n; i++)
10212         {
10213           tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
10214           tree rlist;
10215
10216           /* Skip java.lang.Object (we'll search it once later.) */
10217           if (t == object_type_node)
10218             continue;
10219
10220           search_not_done++;
10221           rlist = find_applicable_accessible_methods_list (lc,  t, name, 
10222                                                            arglist);
10223           all_list = chainon (rlist, (list ? list : all_list)); 
10224           search_not_done--;
10225         }
10226
10227       /* We're done. Reset the searched interfaces list and finally search
10228          java.lang.Object */
10229       if (!search_not_done)
10230         {  
10231           searched_interfaces = NULL_TREE;  
10232           search_applicable_methods_list (lc, TYPE_METHODS (object_type_node),
10233                                           name, arglist, &list, &all_list);
10234         }
10235     }
10236   /* Search classes */
10237   else
10238     while (class != NULL_TREE)
10239       {
10240         search_applicable_methods_list 
10241           (lc, TYPE_METHODS (class), name, arglist, &list, &all_list);
10242         class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class));
10243       }
10244
10245   /* Either return the list obtained or all selected (but
10246      inaccessible) methods for better error report. */
10247   return (!list ? all_list : list);
10248 }
10249
10250 /* Effectively search for the approriate method in method */
10251
10252 static void 
10253 search_applicable_methods_list(lc, method, name, arglist, list, all_list)
10254      int lc;
10255      tree method, name, arglist;
10256      tree *list, *all_list;
10257 {
10258   for (; method; method = TREE_CHAIN (method))
10259     {
10260       /* When dealing with constructor, stop here, otherwise search
10261          other classes */
10262       if (lc && !DECL_CONSTRUCTOR_P (method))
10263         continue;
10264       else if (!lc && (DECL_CONSTRUCTOR_P (method) 
10265                        || (GET_METHOD_NAME (method) != name)))
10266         continue;
10267           
10268       if (argument_types_convertible (method, arglist))
10269         {
10270           /* Retain accessible methods only */
10271           if (!not_accessible_p (DECL_CONTEXT (current_function_decl), 
10272                                  method, 0))
10273             *list = tree_cons (NULL_TREE, method, *list);
10274           else
10275             /* Also retain all selected method here */
10276             *all_list = tree_cons (NULL_TREE, method, *list);
10277         }
10278     }
10279 }    
10280
10281 /* 15.11.2.2 Choose the Most Specific Method */
10282
10283 static tree
10284 find_most_specific_methods_list (list)
10285      tree list;
10286 {
10287   int max = 0;
10288   tree current, new_list = NULL_TREE;
10289   for (current = list; current; current = TREE_CHAIN (current))
10290     {
10291       tree method;
10292       DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
10293
10294       for (method = list; method; method = TREE_CHAIN (method))
10295         {
10296           /* Don't test a method against itself */
10297           if (method == current)
10298             continue;
10299
10300           /* Compare arguments and location where method where declared */
10301           if (argument_types_convertible (TREE_VALUE (method), 
10302                                           TREE_VALUE (current))
10303               && valid_method_invocation_conversion_p 
10304                    (DECL_CONTEXT (TREE_VALUE (method)), 
10305                     DECL_CONTEXT (TREE_VALUE (current))))
10306             {
10307               int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
10308               max = (v > max ? v : max);
10309             }
10310         }
10311     }
10312
10313   /* Review the list and select the maximally specific methods */
10314   for (current = list; current; current = TREE_CHAIN (current))
10315     if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
10316       new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
10317
10318   /* If we can't find one, lower expectations and try to gather multiple
10319      maximally specific methods */
10320   while (!new_list)
10321     {
10322       while (--max > 0)
10323         {
10324           if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
10325             new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
10326         }
10327       return new_list;
10328     }
10329
10330   return new_list;
10331 }
10332
10333 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
10334    converted by method invocation conversion (5.3) to the type of the
10335    corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
10336    to change less often than M1. */
10337
10338 static int
10339 argument_types_convertible (m1, m2_or_arglist)
10340     tree m1, m2_or_arglist;
10341 {
10342   static tree m2_arg_value = NULL_TREE;
10343   static tree m2_arg_cache = NULL_TREE;
10344
10345   register tree m1_arg, m2_arg;
10346
10347   m1_arg = TYPE_ARG_TYPES (TREE_TYPE (m1));
10348   if (!METHOD_STATIC (m1))
10349     m1_arg = TREE_CHAIN (m1_arg);
10350
10351   if (m2_arg_value == m2_or_arglist)
10352     m2_arg = m2_arg_cache;
10353   else
10354     {
10355       /* M2_OR_ARGLIST can be a function DECL or a raw list of
10356          argument types */
10357       if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
10358         {
10359           m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
10360           if (!METHOD_STATIC (m2_or_arglist))
10361             m2_arg = TREE_CHAIN (m2_arg);
10362         }
10363       else
10364         m2_arg = m2_or_arglist;
10365
10366       m2_arg_value = m2_or_arglist;
10367       m2_arg_cache = m2_arg;
10368     }
10369
10370   while (m1_arg != end_params_node && m2_arg != end_params_node)
10371     {
10372       resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
10373       if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
10374                                                  TREE_VALUE (m2_arg)))
10375         break;
10376       m1_arg = TREE_CHAIN (m1_arg);
10377       m2_arg = TREE_CHAIN (m2_arg);
10378     }
10379   return m1_arg == end_params_node && m2_arg == end_params_node;
10380 }
10381
10382 /* Qualification routines */
10383
10384 static void
10385 qualify_ambiguous_name (id)
10386      tree id;
10387 {
10388   tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
10389     saved_current_class;
10390   int again, super_found = 0, this_found = 0, new_array_found = 0;
10391   int code;
10392
10393   /* We first qualify the first element, then derive qualification of
10394      others based on the first one. If the first element is qualified
10395      by a resolution (field or type), this resolution is stored in the
10396      QUAL_RESOLUTION of the qual element being examined. We need to
10397      save the current_class since the use of SUPER might change the
10398      its value. */
10399   saved_current_class = current_class;
10400   qual = EXPR_WFL_QUALIFICATION (id);
10401   do {
10402
10403     /* Simple qualified expression feature a qual_wfl that is a
10404        WFL. Expression derived from a primary feature more complicated
10405        things like a CALL_EXPR. Expression from primary need to be
10406        worked out to extract the part on which the qualification will
10407        take place. */
10408     qual_wfl = QUAL_WFL (qual);
10409     switch (TREE_CODE (qual_wfl))
10410       {
10411       case CALL_EXPR:
10412         qual_wfl = TREE_OPERAND (qual_wfl, 0);
10413         if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
10414           {
10415             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
10416             qual_wfl = QUAL_WFL (qual);
10417           }
10418         break;
10419       case NEW_ARRAY_EXPR:
10420         qual = TREE_CHAIN (qual);
10421         again = new_array_found = 1;
10422         continue;
10423       case NEW_CLASS_EXPR:
10424       case CONVERT_EXPR:
10425         qual_wfl = TREE_OPERAND (qual_wfl, 0);
10426         break;
10427       case ARRAY_REF:
10428         while (TREE_CODE (qual_wfl) == ARRAY_REF)
10429           qual_wfl = TREE_OPERAND (qual_wfl, 0);
10430         break;
10431       case STRING_CST:
10432         qual = TREE_CHAIN (qual);
10433         qual_wfl = QUAL_WFL (qual);
10434         break;
10435       default:
10436         /* Fix for -Wall. Just break doing nothing */
10437         break;
10438       }
10439
10440     ptr_type = current_class;
10441     again = 0;
10442     code = TREE_CODE (qual_wfl);
10443
10444     /* Pos evaluation: non WFL leading expression nodes */
10445     if (code == CONVERT_EXPR
10446         && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
10447       name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
10448
10449     else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
10450              TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
10451       name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
10452
10453     else if (code == STRING_CST || code == CONDITIONAL_EXPR)
10454       {
10455         qual = TREE_CHAIN (qual);
10456         qual_wfl = QUAL_WFL (qual);
10457         again = 1;
10458       }
10459     else 
10460       {
10461         name = EXPR_WFL_NODE (qual_wfl);
10462         if (!name)
10463           {
10464             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
10465             again = 1;
10466           }
10467       }
10468
10469     /* If we have a THIS (from a primary), we set the context accordingly */
10470     if (name == this_identifier_node)
10471       {
10472         qual = TREE_CHAIN (qual);
10473         qual_wfl = QUAL_WFL (qual);
10474         if (TREE_CODE (qual_wfl) == CALL_EXPR)
10475           again = 1;
10476         else
10477           name = EXPR_WFL_NODE (qual_wfl);
10478         this_found = 1;
10479       }
10480     /* If we have a SUPER, we set the context accordingly */
10481     if (name == super_identifier_node)
10482       {
10483         current_class = CLASSTYPE_SUPER (ptr_type);
10484         /* Check that there is such a thing as a super class. If not,
10485            return.  The error will be caught later on, during the
10486            resolution */
10487         if (!current_class)
10488           {
10489             current_class = saved_current_class;
10490             return;
10491           }
10492         qual = TREE_CHAIN (qual);
10493         /* Do one more interation to set things up */
10494         super_found = again = 1;
10495       }
10496   } while (again);
10497   
10498   /* If name appears within the scope of a location variable
10499      declaration or parameter declaration, then it is an expression
10500      name. We don't carry this test out if we're in the context of the
10501      use of SUPER or THIS */
10502   if (!this_found && !super_found && 
10503       TREE_CODE (name) != STRING_CST && (decl = IDENTIFIER_LOCAL_VALUE (name)))
10504     {
10505       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
10506       QUAL_RESOLUTION (qual) = decl;
10507     }
10508
10509   /* If within the class/interface NAME was found to be used there
10510      exists a (possibly inherited) field named NAME, then this is an
10511      expression name. If we saw a NEW_ARRAY_EXPR before and want to
10512      address length, it is OK. */
10513   else if ((decl = lookup_field_wrapper (ptr_type, name))
10514            || (new_array_found && name == length_identifier_node))
10515     {
10516       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
10517       QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
10518     }
10519
10520   /* We reclassify NAME as yielding to a type name resolution if:
10521      - NAME is a class/interface declared within the compilation
10522        unit containing NAME,
10523      - NAME is imported via a single-type-import declaration,
10524      - NAME is declared in an another compilation unit of the package
10525        of the compilation unit containing NAME,
10526      - NAME is declared by exactly on type-import-on-demand declaration
10527      of the compilation unit containing NAME. 
10528      - NAME is actually a STRING_CST. */
10529   else if (TREE_CODE (name) == STRING_CST ||
10530            (decl = resolve_and_layout (name, NULL_TREE)))
10531     {
10532       RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
10533       QUAL_RESOLUTION (qual) = decl;
10534     }
10535
10536   /* Method call are expression name */
10537   else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
10538            || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
10539            || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
10540     RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
10541
10542   /* Check here that NAME isn't declared by more than one
10543      type-import-on-demand declaration of the compilation unit
10544      containing NAME. FIXME */
10545
10546   /* Otherwise, NAME is reclassified as a package name */
10547   else 
10548     RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
10549
10550   /* Propagate the qualification accross other components of the
10551      qualified name */
10552   for (qual = TREE_CHAIN (qual); qual;
10553        qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
10554     {
10555       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
10556         RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
10557       else 
10558         RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
10559     }
10560
10561   /* Store the global qualification for the ambiguous part of ID back
10562      into ID fields */
10563   if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
10564     RESOLVE_EXPRESSION_NAME_P (id) = 1;
10565   else if (RESOLVE_TYPE_NAME_P (qual_wfl))
10566     RESOLVE_TYPE_NAME_P (id) = 1;
10567   else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
10568     RESOLVE_PACKAGE_NAME_P (id) = 1;
10569
10570   /* Restore the current class */
10571   current_class = saved_current_class;
10572 }
10573
10574 static int
10575 breakdown_qualified (left, right, source)
10576     tree *left, *right, source;
10577 {
10578   char *p = IDENTIFIER_POINTER (source), *base;
10579   int   l = IDENTIFIER_LENGTH (source);
10580
10581   /* Breakdown NAME into REMAINDER . IDENTIFIER */
10582   base = p;
10583   p += (l-1);
10584   while (*p != '.' && p != base)
10585     p--;
10586
10587   /* We didn't find a '.'. Return an error */
10588   if (p == base)
10589     return 1;
10590
10591   *p = '\0';
10592   if (right)
10593     *right = get_identifier (p+1);
10594   *left = get_identifier (IDENTIFIER_POINTER (source));
10595   *p = '.';
10596   
10597   return 0;
10598 }
10599
10600 /* Patch tree nodes in a function body. When a BLOCK is found, push
10601    local variable decls if present.
10602    Same as java_complete_lhs, but does resolve static finals to values. */
10603
10604 static tree
10605 java_complete_tree (node)
10606      tree node;
10607 {
10608   node = java_complete_lhs (node);
10609   if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
10610       && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
10611       && !flag_emit_xref)
10612     {
10613       tree value = DECL_INITIAL (node);
10614       DECL_INITIAL (node) = NULL_TREE;
10615       push_obstacks (&permanent_obstack, &permanent_obstack);
10616       value = fold_constant_for_init (value, node);
10617       pop_obstacks ();
10618       DECL_INITIAL (node) = value;
10619       if (value != NULL_TREE)
10620         return value;
10621     }
10622   return node;
10623 }
10624
10625 static tree
10626 java_stabilize_reference (node)
10627      tree node;
10628 {
10629   if (TREE_CODE (node) == COMPOUND_EXPR)
10630     {
10631       tree op0 = TREE_OPERAND (node, 0);
10632       tree op1 = TREE_OPERAND (node, 1);
10633       TREE_OPERAND (node, 0) = save_expr (op0);
10634       TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
10635       return node;
10636     }
10637   return stabilize_reference (node);
10638 }
10639
10640 /* Patch tree nodes in a function body. When a BLOCK is found, push
10641    local variable decls if present.
10642    Same as java_complete_tree, but does not resolve static finals to values. */
10643
10644 static tree
10645 java_complete_lhs (node)
10646      tree node;
10647 {
10648   tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
10649   int flag;
10650
10651   /* CONVERT_EXPR always has its type set, even though it needs to be
10652      worked out. */
10653   if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
10654     return node;
10655
10656   /* The switch block implements cases processing container nodes
10657      first.  Contained nodes are always written back. Leaves come
10658      next and return a value. */
10659   switch (TREE_CODE (node))
10660     {
10661     case BLOCK:
10662
10663       /* 1- Block section.
10664          Set the local values on decl names so we can identify them
10665          faster when they're referenced. At that stage, identifiers
10666          are legal so we don't check for declaration errors. */
10667       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
10668         {
10669           DECL_CONTEXT (cn) = current_function_decl;
10670           IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
10671         }
10672       if (BLOCK_EXPR_BODY (node) == NULL_TREE)
10673           CAN_COMPLETE_NORMALLY (node) = 1;
10674       else
10675         {
10676           tree stmt = BLOCK_EXPR_BODY (node);
10677           tree *ptr;
10678           int error_seen = 0;
10679           if (TREE_CODE (stmt) == COMPOUND_EXPR)
10680             {
10681               /* Re-order from (((A; B); C); ...; Z) to 
10682                  (A; (B; (C ; (...; Z)))).
10683                  This makes it easier to scan the statements left-to-right
10684                  without using recursion (which might overflow the stack
10685                  if the block has many statements. */
10686               for (;;)
10687                 {
10688                   tree left = TREE_OPERAND (stmt, 0);
10689                   if (TREE_CODE (left) != COMPOUND_EXPR)
10690                     break;
10691                   TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
10692                   TREE_OPERAND (left, 1) = stmt;
10693                   stmt = left;
10694                 }
10695               BLOCK_EXPR_BODY (node) = stmt;
10696             }
10697
10698           /* Now do the actual complete, without deep recursion for
10699              long blocks. */
10700           ptr = &BLOCK_EXPR_BODY (node);
10701           while (TREE_CODE (*ptr) == COMPOUND_EXPR
10702                  && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
10703             {
10704               tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
10705               tree *next = &TREE_OPERAND (*ptr, 1);
10706               TREE_OPERAND (*ptr, 0) = cur;
10707               if (cur == empty_stmt_node)
10708                 {
10709                   /* Optimization;  makes it easier to detect empty bodies.
10710                      Most useful for <clinit> with all-constant initializer. */
10711                   *ptr = *next;
10712                   continue;
10713                 }
10714               if (TREE_CODE (cur) == ERROR_MARK)
10715                 error_seen++;
10716               else if (! CAN_COMPLETE_NORMALLY (cur))
10717                 {
10718                   wfl_op2 = *next;
10719                   for (;;)
10720                     {
10721                       if (TREE_CODE (wfl_op2) == BLOCK)
10722                         wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
10723                       else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
10724                         wfl_op2 = TREE_OPERAND (wfl_op2, 0);
10725                       else
10726                         break;
10727                     }
10728                   if (TREE_CODE (wfl_op2) != CASE_EXPR
10729                       && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
10730                     unreachable_stmt_error (*ptr);
10731                 }
10732               ptr = next;
10733             }
10734           *ptr = java_complete_tree (*ptr);
10735
10736           if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
10737             return error_mark_node;
10738           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
10739         }
10740       /* Turn local bindings to null */
10741       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
10742         IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
10743
10744       TREE_TYPE (node) = void_type_node;
10745       break;
10746
10747       /* 2- They are expressions but ultimately deal with statements */
10748
10749     case THROW_EXPR:
10750       wfl_op1 = TREE_OPERAND (node, 0);
10751       COMPLETE_CHECK_OP_0 (node);
10752       /* CAN_COMPLETE_NORMALLY (node) = 0; */
10753       return patch_throw_statement (node, wfl_op1);
10754
10755     case SYNCHRONIZED_EXPR:
10756       wfl_op1 = TREE_OPERAND (node, 0);
10757       return patch_synchronized_statement (node, wfl_op1);
10758
10759     case TRY_EXPR:
10760       return patch_try_statement (node);
10761
10762     case TRY_FINALLY_EXPR:
10763       COMPLETE_CHECK_OP_0 (node);
10764       COMPLETE_CHECK_OP_1 (node);
10765       CAN_COMPLETE_NORMALLY (node)
10766         = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
10767            && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
10768       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
10769       return node;
10770
10771     case CLEANUP_POINT_EXPR:
10772       COMPLETE_CHECK_OP_0 (node);
10773       TREE_TYPE (node) = void_type_node;
10774       CAN_COMPLETE_NORMALLY (node) = 
10775         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
10776       return node;
10777
10778     case WITH_CLEANUP_EXPR:
10779       COMPLETE_CHECK_OP_0 (node);
10780       COMPLETE_CHECK_OP_2 (node);
10781       CAN_COMPLETE_NORMALLY (node) = 
10782         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
10783       TREE_TYPE (node) = void_type_node;
10784       return node;
10785
10786     case LABELED_BLOCK_EXPR:
10787       PUSH_LABELED_BLOCK (node);
10788       if (LABELED_BLOCK_BODY (node))
10789         COMPLETE_CHECK_OP_1 (node);
10790       TREE_TYPE (node) = void_type_node;
10791       POP_LABELED_BLOCK ();
10792
10793       if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
10794         {
10795           LABELED_BLOCK_BODY (node) = NULL_TREE;
10796           CAN_COMPLETE_NORMALLY (node) = 1;
10797         }
10798       else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
10799         CAN_COMPLETE_NORMALLY (node) = 1;
10800       return node;
10801
10802     case EXIT_BLOCK_EXPR:
10803       /* We don't complete operand 1, because it's the return value of
10804          the EXIT_BLOCK_EXPR which doesn't exist it Java */
10805       return patch_bc_statement (node);
10806
10807     case CASE_EXPR:
10808       cn = java_complete_tree (TREE_OPERAND (node, 0));
10809       if (cn == error_mark_node)
10810         return cn;
10811
10812       /* First, the case expression must be constant. Values of final
10813          fields are accepted. */
10814       cn = fold (cn);
10815       if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
10816           && JDECL_P (TREE_OPERAND (cn, 1))
10817           && FIELD_FINAL (TREE_OPERAND (cn, 1))
10818           && DECL_INITIAL (TREE_OPERAND (cn, 1)))
10819         {
10820           push_obstacks (&permanent_obstack, &permanent_obstack);
10821           cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
10822                                        TREE_OPERAND (cn, 1));
10823           pop_obstacks ();
10824         }
10825
10826       if (!TREE_CONSTANT (cn) && !flag_emit_xref)
10827         {
10828           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10829           parse_error_context (node, "Constant expression required");
10830           return error_mark_node;
10831         }
10832
10833       nn = ctxp->current_loop;
10834
10835       /* It must be assignable to the type of the switch expression. */
10836       if (!try_builtin_assignconv (NULL_TREE, 
10837                                    TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
10838         {
10839           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10840           parse_error_context 
10841             (wfl_operator,
10842              "Incompatible type for case. Can't convert `%s' to `int'",
10843              lang_printable_name (TREE_TYPE (cn), 0));
10844           return error_mark_node;
10845         }
10846
10847       cn = fold (convert (int_type_node, cn));
10848
10849       /* Multiple instance of a case label bearing the same
10850          value is checked during code generation. The case
10851          expression is allright so far. */
10852       TREE_OPERAND (node, 0) = cn;
10853       TREE_TYPE (node) = void_type_node;
10854       CAN_COMPLETE_NORMALLY (node) = 1;
10855       TREE_SIDE_EFFECTS (node) = 1;
10856       break;
10857
10858     case DEFAULT_EXPR:
10859       nn = ctxp->current_loop;
10860       /* Only one default label is allowed per switch statement */
10861       if (SWITCH_HAS_DEFAULT (nn))
10862         {
10863           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10864           parse_error_context (wfl_operator, 
10865                                "Duplicate case label: `default'");
10866           return error_mark_node;
10867         }
10868       else
10869         SWITCH_HAS_DEFAULT (nn) = 1;
10870       TREE_TYPE (node) = void_type_node;
10871       TREE_SIDE_EFFECTS (node) = 1;
10872       CAN_COMPLETE_NORMALLY (node) = 1;
10873       break;
10874
10875     case SWITCH_EXPR:
10876     case LOOP_EXPR:
10877       PUSH_LOOP (node);
10878       /* Check whether the loop was enclosed in a labeled
10879          statement. If not, create one, insert the loop in it and
10880          return the node */
10881       nn = patch_loop_statement (node);
10882
10883       /* Anyways, walk the body of the loop */
10884       if (TREE_CODE (node) == LOOP_EXPR)
10885         TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10886       /* Switch statement: walk the switch expression and the cases */
10887       else
10888         node = patch_switch_statement (node);
10889
10890       if (TREE_OPERAND (node, 0) == error_mark_node)
10891         nn = error_mark_node;
10892       else
10893         {
10894           TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
10895           /* If we returned something different, that's because we
10896              inserted a label. Pop the label too. */
10897           if (nn != node)
10898             {
10899               if (CAN_COMPLETE_NORMALLY (node))
10900                 CAN_COMPLETE_NORMALLY (nn) = 1;
10901               POP_LABELED_BLOCK ();
10902             }
10903         }
10904       POP_LOOP ();
10905       return nn;
10906
10907     case EXIT_EXPR:
10908       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10909       return patch_exit_expr (node);
10910
10911     case COND_EXPR:
10912       /* Condition */
10913       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10914       if (TREE_OPERAND (node, 0) == error_mark_node)
10915         return error_mark_node;
10916       /* then-else branches */
10917       TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
10918       if (TREE_OPERAND (node, 1) == error_mark_node)
10919         return error_mark_node;
10920       TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
10921       if (TREE_OPERAND (node, 2) == error_mark_node)
10922         return error_mark_node;
10923       return patch_if_else_statement (node);
10924       break;
10925
10926     case CONDITIONAL_EXPR:
10927       /* Condition */
10928       wfl_op1 = TREE_OPERAND (node, 0);
10929       COMPLETE_CHECK_OP_0 (node);
10930       wfl_op2 = TREE_OPERAND (node, 1);
10931       COMPLETE_CHECK_OP_1 (node);
10932       wfl_op3 = TREE_OPERAND (node, 2);
10933       COMPLETE_CHECK_OP_2 (node);
10934       return patch_conditional_expr (node, wfl_op1, wfl_op2);
10935
10936       /* 3- Expression section */
10937     case COMPOUND_EXPR:
10938       wfl_op2 = TREE_OPERAND (node, 1);
10939       TREE_OPERAND (node, 0) = nn = 
10940         java_complete_tree (TREE_OPERAND (node, 0));
10941       if (wfl_op2 == empty_stmt_node)
10942         CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
10943       else
10944         {
10945           if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
10946             {
10947               /* An unreachable condition in a do-while statement
10948                  is *not* (technically) an unreachable statement. */
10949               nn = wfl_op2;
10950               if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
10951                 nn = EXPR_WFL_NODE (nn);
10952               if (TREE_CODE (nn) != EXIT_EXPR)
10953                 {
10954                   SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
10955                   parse_error_context (wfl_operator, "Unreachable statement");
10956                 }
10957             }
10958           TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
10959           if (TREE_OPERAND (node, 1) == error_mark_node)
10960             return error_mark_node;
10961           CAN_COMPLETE_NORMALLY (node)
10962             = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
10963         }
10964       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
10965       break;
10966
10967     case RETURN_EXPR:
10968       /* CAN_COMPLETE_NORMALLY (node) = 0; */
10969       return patch_return (node);
10970
10971     case EXPR_WITH_FILE_LOCATION:
10972       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
10973           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
10974         {
10975           tree wfl = node;
10976           node = resolve_expression_name (node, NULL);
10977           if (node == error_mark_node)
10978             return node;
10979           /* Keep line number information somewhere were it doesn't
10980              disrupt the completion process. */
10981           if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
10982             {
10983               EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
10984               TREE_OPERAND (node, 1) = wfl;
10985             }
10986           CAN_COMPLETE_NORMALLY (node) = 1;
10987         }
10988       else
10989         {
10990           tree body;
10991           int save_lineno = lineno;
10992           lineno = EXPR_WFL_LINENO (node);
10993           body = java_complete_tree (EXPR_WFL_NODE (node));
10994           lineno = save_lineno;
10995           EXPR_WFL_NODE (node) = body;
10996           TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
10997           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
10998           if (body == empty_stmt_node)
10999             {
11000               /* Optimization;  makes it easier to detect empty bodies. */
11001               return body;
11002             }
11003           if (body == error_mark_node)
11004             {
11005               /* Its important for the evaluation of assignment that
11006                  this mark on the TREE_TYPE is propagated. */
11007               TREE_TYPE (node) = error_mark_node;
11008               return error_mark_node;
11009             }
11010           else
11011             TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
11012           
11013         }
11014       break;
11015
11016     case NEW_ARRAY_EXPR:
11017       /* Patch all the dimensions */
11018       flag = 0;
11019       for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
11020         {
11021           int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
11022           tree dim = java_complete_tree (TREE_VALUE (cn));
11023           if (dim == error_mark_node)
11024             {
11025               flag = 1;
11026               continue;
11027             }
11028           else
11029             {
11030               TREE_VALUE (cn) = dim;
11031               /* Setup the location of the current dimension, for
11032                  later error report. */
11033               TREE_PURPOSE (cn) = 
11034                 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
11035               EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
11036             }
11037         }
11038       /* They complete the array creation expression, if no errors
11039          were found. */
11040       CAN_COMPLETE_NORMALLY (node) = 1;
11041       return (flag ? error_mark_node
11042               : force_evaluation_order (patch_newarray (node)));
11043
11044     case NEW_CLASS_EXPR:
11045     case CALL_EXPR:
11046       /* Complete function's argument(s) first */
11047       if (complete_function_arguments (node))
11048         return error_mark_node;
11049       else
11050         {
11051           tree decl, wfl = TREE_OPERAND (node, 0);
11052           int in_this = CALL_THIS_CONSTRUCTOR_P (node);
11053
11054           node = patch_method_invocation (node, NULL_TREE, 
11055                                           NULL_TREE, 0, &decl);
11056           if (node == error_mark_node)
11057             return error_mark_node;
11058
11059           check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
11060           /* If we call this(...), register signature and positions */
11061           if (in_this)
11062             DECL_CONSTRUCTOR_CALLS (current_function_decl) = 
11063               tree_cons (wfl, decl, 
11064                          DECL_CONSTRUCTOR_CALLS (current_function_decl));
11065           CAN_COMPLETE_NORMALLY (node) = 1;
11066           return force_evaluation_order (node);
11067         }
11068
11069     case MODIFY_EXPR:
11070       /* Save potential wfls */
11071       wfl_op1 = TREE_OPERAND (node, 0);
11072       TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
11073       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
11074           && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
11075           && DECL_INITIAL (nn) != NULL_TREE)
11076         {
11077           tree value;
11078           
11079           push_obstacks (&permanent_obstack, &permanent_obstack);
11080           value = fold_constant_for_init (nn, nn);
11081           pop_obstacks ();
11082           if (value != NULL_TREE)
11083             {
11084               tree type = TREE_TYPE (value);
11085               if (JPRIMITIVE_TYPE_P (type) || type == string_ptr_type_node)
11086                 return empty_stmt_node;
11087             }
11088           DECL_INITIAL (nn) = NULL_TREE;
11089         }
11090       wfl_op2 = TREE_OPERAND (node, 1);
11091
11092       if (TREE_OPERAND (node, 0) == error_mark_node)
11093         return error_mark_node;
11094
11095       flag = COMPOUND_ASSIGN_P (wfl_op2);
11096       if (flag)
11097         {
11098           tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0)); 
11099
11100           /* Hand stablize the lhs on both places */
11101           TREE_OPERAND (node, 0) = lvalue;
11102           TREE_OPERAND (TREE_OPERAND (node, 1), 0) = 
11103             (flag_emit_class_files ? lvalue : save_expr (lvalue));
11104
11105           /* 15.25.2.a: Left hand is not an array access. FIXME */
11106           /* Now complete the RHS. We write it back later on. */
11107           nn = java_complete_tree (TREE_OPERAND (node, 1));
11108
11109           if ((cn = patch_string (nn)))
11110             nn = cn;
11111
11112           /* The last part of the rewrite for E1 op= E2 is to have 
11113              E1 = (T)(E1 op E2), with T being the type of E1. */
11114           nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2), 
11115                                                TREE_TYPE (lvalue), nn));
11116
11117           /* 15.25.2.b: Left hand is an array access. FIXME */
11118         }
11119
11120       /* If we're about to patch a NEW_ARRAY_INIT, we call a special
11121          function to complete this RHS */
11122       else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT)
11123         nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
11124                                    TREE_OPERAND (node, 1));
11125       /* Otherwise we simply complete the RHS */
11126       else
11127         nn = java_complete_tree (TREE_OPERAND (node, 1));
11128
11129       if (nn == error_mark_node)
11130         return error_mark_node;
11131
11132       /* Write back the RHS as we evaluated it. */
11133       TREE_OPERAND (node, 1) = nn;
11134
11135       /* In case we're handling = with a String as a RHS, we need to
11136          produce a String out of the RHS (it might still be a
11137          STRING_CST or a StringBuffer at this stage */
11138       if ((nn = patch_string (TREE_OPERAND (node, 1))))
11139         TREE_OPERAND (node, 1) = nn;
11140       node = patch_assignment (node, wfl_op1, wfl_op2);
11141       /* Reorganize the tree if necessary. */
11142       if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node)) 
11143                    || JSTRING_P (TREE_TYPE (node))))
11144         node = java_refold (node);
11145       CAN_COMPLETE_NORMALLY (node) = 1;
11146       return node;
11147
11148     case MULT_EXPR:
11149     case PLUS_EXPR:
11150     case MINUS_EXPR:
11151     case LSHIFT_EXPR:
11152     case RSHIFT_EXPR:
11153     case URSHIFT_EXPR:
11154     case BIT_AND_EXPR:
11155     case BIT_XOR_EXPR:
11156     case BIT_IOR_EXPR:
11157     case TRUNC_MOD_EXPR:
11158     case RDIV_EXPR:
11159     case TRUTH_ANDIF_EXPR:
11160     case TRUTH_ORIF_EXPR:
11161     case EQ_EXPR: 
11162     case NE_EXPR:
11163     case GT_EXPR:
11164     case GE_EXPR:
11165     case LT_EXPR:
11166     case LE_EXPR:
11167       /* Operands 0 and 1 are WFL in certain cases only. patch_binop
11168          knows how to handle those cases. */
11169       wfl_op1 = TREE_OPERAND (node, 0);
11170       wfl_op2 = TREE_OPERAND (node, 1);
11171
11172       CAN_COMPLETE_NORMALLY (node) = 1;
11173       /* Don't complete string nodes if dealing with the PLUS operand. */
11174       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
11175         {
11176           nn = java_complete_tree (wfl_op1);
11177           if (nn == error_mark_node)
11178             return error_mark_node;
11179           if ((cn = patch_string (nn)))
11180             nn = cn;
11181           TREE_OPERAND (node, 0) = nn;
11182         }
11183       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
11184         {
11185           nn = java_complete_tree (wfl_op2);
11186           if (nn == error_mark_node)
11187             return error_mark_node;
11188           if ((cn = patch_string (nn)))
11189             nn = cn;
11190           TREE_OPERAND (node, 1) = nn;
11191         }
11192       return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
11193
11194     case INSTANCEOF_EXPR:
11195       wfl_op1 = TREE_OPERAND (node, 0);
11196       COMPLETE_CHECK_OP_0 (node);
11197       if (flag_emit_xref)
11198         {
11199           TREE_TYPE (node) = boolean_type_node;
11200           return node;
11201         }
11202       return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
11203
11204     case UNARY_PLUS_EXPR:
11205     case NEGATE_EXPR:
11206     case TRUTH_NOT_EXPR:
11207     case BIT_NOT_EXPR:
11208     case PREDECREMENT_EXPR:
11209     case PREINCREMENT_EXPR:
11210     case POSTDECREMENT_EXPR:
11211     case POSTINCREMENT_EXPR:
11212     case CONVERT_EXPR:
11213       /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
11214          how to handle those cases. */
11215       wfl_op1 = TREE_OPERAND (node, 0);
11216       CAN_COMPLETE_NORMALLY (node) = 1;
11217       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
11218       if (TREE_OPERAND (node, 0) == error_mark_node)
11219         return error_mark_node;
11220       node = patch_unaryop (node, wfl_op1);
11221       CAN_COMPLETE_NORMALLY (node) = 1;
11222       break;
11223
11224     case ARRAY_REF:
11225       /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
11226          how to handle those cases. */
11227       wfl_op1 = TREE_OPERAND (node, 0);
11228       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
11229       if (TREE_OPERAND (node, 0) == error_mark_node)
11230         return error_mark_node;
11231       if (!flag_emit_class_files && !flag_emit_xref)
11232         TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
11233       /* The same applies to wfl_op2 */
11234       wfl_op2 = TREE_OPERAND (node, 1);
11235       TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
11236       if (TREE_OPERAND (node, 1) == error_mark_node)
11237         return error_mark_node;
11238       if (!flag_emit_class_files && !flag_emit_xref)
11239         TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
11240       return patch_array_ref (node);
11241
11242     case RECORD_TYPE:
11243       return node;;
11244
11245     case COMPONENT_REF:
11246       /* The first step in the re-write of qualified name handling.  FIXME.
11247          So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
11248       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
11249       if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
11250         {
11251           tree name = TREE_OPERAND (node, 1);
11252           tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
11253           if (field == NULL_TREE)
11254             {
11255               error ("missing static field `%s'", IDENTIFIER_POINTER (name));
11256               return error_mark_node;
11257             }
11258           if (! FIELD_STATIC (field))
11259             {
11260               error ("not a static field `%s'", IDENTIFIER_POINTER (name));
11261               return error_mark_node;
11262             }
11263           return field;
11264         }
11265       else
11266         fatal ("unimplemented java_complete_tree for COMPONENT_REF");
11267       break;
11268
11269     case THIS_EXPR:
11270       /* Can't use THIS in a static environment */
11271       if (!current_this)
11272         {
11273           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
11274           parse_error_context (wfl_operator, "Keyword `this' used outside "
11275                                "allowed context");
11276           TREE_TYPE (node) = error_mark_node;
11277           return error_mark_node;
11278         }
11279       if (ctxp->explicit_constructor_p)
11280         {
11281           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
11282           parse_error_context 
11283             (wfl_operator, "Can't reference `this' or `super' before the "
11284              "superclass constructor has been called");
11285           TREE_TYPE (node) = error_mark_node;
11286           return error_mark_node;
11287         }
11288       return current_this;
11289
11290     default:
11291       CAN_COMPLETE_NORMALLY (node) = 1;
11292       /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
11293          and it's time to turn it into the appropriate String object
11294          */
11295       if ((node = patch_string (node)))
11296         return node;
11297       fatal ("No case for tree code `%s' - java_complete_tree\n",
11298              tree_code_name [TREE_CODE (node)]);
11299     }
11300   return node;
11301 }
11302
11303 /* Complete function call's argument. Return a non zero value is an
11304    error was found.  */
11305
11306 static int
11307 complete_function_arguments (node)
11308      tree node;
11309 {
11310   int flag = 0;
11311   tree cn;
11312
11313   ctxp->explicit_constructor_p += (CALL_THIS_CONSTRUCTOR_P (node) ? 1 : 0);
11314   for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
11315     {
11316       tree wfl = TREE_VALUE (cn), parm, temp;
11317       parm = java_complete_tree (wfl);
11318       if (parm == error_mark_node)
11319         {
11320           flag = 1;
11321           continue;
11322         }
11323       /* If have a string literal that we haven't transformed yet or a
11324          crafted string buffer, as a result of use of the the String
11325          `+' operator. Build `parm.toString()' and expand it. */
11326       if ((temp = patch_string (parm)))
11327         parm = temp;
11328       /* Inline PRIMTYPE.TYPE read access */
11329       parm = maybe_build_primttype_type_ref (parm, wfl);
11330
11331       TREE_VALUE (cn) = parm;
11332     }
11333   ctxp->explicit_constructor_p -= (CALL_THIS_CONSTRUCTOR_P (node) ? 1 : 0);
11334   return flag;
11335 }
11336
11337 /* Sometimes (for loops and variable initialized during their
11338    declaration), we want to wrap a statement around a WFL and turn it
11339    debugable.  */
11340
11341 static tree
11342 build_debugable_stmt (location, stmt)
11343     int location;
11344     tree stmt;
11345 {
11346   if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
11347     {
11348       stmt = build_expr_wfl (stmt, input_filename, 0, 0);
11349       EXPR_WFL_LINECOL (stmt) = location;
11350     }
11351   JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
11352   return stmt;
11353 }
11354
11355 static tree
11356 build_expr_block (body, decls)
11357      tree body, decls;
11358 {
11359   tree node = make_node (BLOCK);
11360   BLOCK_EXPR_DECLS (node) = decls;
11361   BLOCK_EXPR_BODY (node) = body;
11362   if (body)
11363     TREE_TYPE (node) = TREE_TYPE (body);
11364   TREE_SIDE_EFFECTS (node) = 1;
11365   return node;
11366 }
11367
11368 /* Create a new function block and link it approriately to current
11369    function block chain */
11370
11371 static tree
11372 enter_block ()
11373 {
11374   return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
11375 }
11376
11377 /* Link block B supercontext to the previous block. The current
11378    function DECL is used as supercontext when enter_a_block is called
11379    for the first time for a given function. The current function body
11380    (DECL_FUNCTION_BODY) is set to be block B.  */
11381
11382 static tree
11383 enter_a_block (b)
11384      tree b;
11385 {
11386   tree fndecl = current_function_decl; 
11387
11388   if (!fndecl) {
11389     BLOCK_SUPERCONTEXT (b) = current_static_block;
11390     current_static_block = b;
11391   }
11392
11393   else if (!DECL_FUNCTION_BODY (fndecl))
11394     {
11395       BLOCK_SUPERCONTEXT (b) = fndecl;
11396       DECL_FUNCTION_BODY (fndecl) = b;
11397     }
11398   else
11399     {
11400       BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
11401       DECL_FUNCTION_BODY (fndecl) = b;
11402     }
11403   return b;
11404 }
11405
11406 /* Exit a block by changing the current function body
11407    (DECL_FUNCTION_BODY) to the current block super context, only if
11408    the block being exited isn't the method's top level one.  */
11409
11410 static tree
11411 exit_block ()
11412 {
11413   tree b;
11414   if (current_function_decl)
11415     {
11416       b = DECL_FUNCTION_BODY (current_function_decl);
11417       if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
11418         DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
11419     }
11420   else
11421     {
11422       b = current_static_block;
11423
11424       if (BLOCK_SUPERCONTEXT (b))
11425         current_static_block = BLOCK_SUPERCONTEXT (b);
11426     }
11427   return b;
11428 }
11429
11430 /* Lookup for NAME in the nested function's blocks, all the way up to
11431    the current toplevel one. It complies with Java's local variable
11432    scoping rules.  */
11433
11434 static tree
11435 lookup_name_in_blocks (name)
11436      tree name;
11437 {
11438   tree b = GET_CURRENT_BLOCK (current_function_decl);
11439
11440   while (b != current_function_decl)
11441     {
11442       tree current;
11443
11444       /* Paranoid sanity check. To be removed */
11445       if (TREE_CODE (b) != BLOCK)
11446         fatal ("non block expr function body - lookup_name_in_blocks");
11447
11448       for (current = BLOCK_EXPR_DECLS (b); current; 
11449            current = TREE_CHAIN (current))
11450         if (DECL_NAME (current) == name)
11451           return current;
11452       b = BLOCK_SUPERCONTEXT (b);
11453     }
11454   return NULL_TREE;
11455 }
11456
11457 static void
11458 maybe_absorb_scoping_blocks ()
11459 {
11460   while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
11461     {
11462       tree b = exit_block ();
11463       java_method_add_stmt (current_function_decl, b);
11464       SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
11465     }
11466 }
11467
11468 \f
11469 /* This section of the source is reserved to build_* functions that
11470    are building incomplete tree nodes and the patch_* functions that
11471    are completing them.  */
11472
11473 /* Build a super() constructor invocation. Returns empty_stmt_node if
11474    we're currently dealing with the class java.lang.Object. */
11475
11476 static tree
11477 build_super_invocation ()
11478 {
11479   if (current_class == object_type_node)
11480     return empty_stmt_node;
11481   else
11482     {
11483       tree super_wfl = build_wfl_node (super_identifier_node);
11484       return build_method_invocation (super_wfl, NULL_TREE);
11485     }
11486 }
11487
11488 /* Build a SUPER/THIS qualified method invocation.  */
11489
11490 static tree
11491 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
11492      int use_this;
11493      tree name, args;
11494      int lloc, rloc;
11495
11496 {
11497   tree invok;
11498   tree wfl = 
11499     build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
11500   EXPR_WFL_LINECOL (wfl) = lloc;
11501   invok = build_method_invocation (name, args);
11502   return make_qualified_primary (wfl, invok, rloc);
11503 }
11504
11505 /* Build an incomplete CALL_EXPR node. */
11506
11507 static tree
11508 build_method_invocation (name, args)
11509     tree name;
11510     tree args;
11511 {
11512   tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
11513   TREE_SIDE_EFFECTS (call) = 1;
11514   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
11515   return call;
11516 }
11517
11518 /* Build an incomplete new xxx(...) node. */
11519
11520 static tree
11521 build_new_invocation (name, args)
11522     tree name, args;
11523 {
11524   tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
11525   TREE_SIDE_EFFECTS (call) = 1;
11526   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
11527   return call;
11528 }
11529
11530 /* Build an incomplete assignment expression. */
11531
11532 static tree
11533 build_assignment (op, op_location, lhs, rhs)
11534      int op, op_location;
11535      tree lhs, rhs;
11536 {
11537   tree assignment;
11538   /* Build the corresponding binop if we deal with a Compound
11539      Assignment operator. Mark the binop sub-tree as part of a
11540      Compound Assignment expression */
11541   if (op != ASSIGN_TK)
11542     {
11543       rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
11544       COMPOUND_ASSIGN_P (rhs) = 1;
11545     }
11546   assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
11547   TREE_SIDE_EFFECTS (assignment) = 1;
11548   EXPR_WFL_LINECOL (assignment) = op_location;
11549   return assignment;
11550 }
11551
11552 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
11553
11554 char *
11555 print_int_node (node)
11556     tree node;
11557 {
11558   static char buffer [80];
11559   if (TREE_CONSTANT_OVERFLOW (node))
11560     sprintf (buffer, "<overflow>");
11561     
11562   if (TREE_INT_CST_HIGH (node) == 0)
11563     sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
11564              TREE_INT_CST_LOW (node));
11565   else if (TREE_INT_CST_HIGH (node) == -1
11566            && TREE_INT_CST_LOW (node) != 0)
11567     {
11568       buffer [0] = '-';
11569       sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
11570                -TREE_INT_CST_LOW (node));
11571     }
11572   else
11573     sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
11574              TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
11575
11576   return buffer;
11577 }
11578
11579 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
11580    context.  */
11581
11582 static int
11583 check_final_assignment (lvalue, wfl)
11584      tree lvalue, wfl;
11585 {
11586   if (JDECL_P (lvalue) 
11587       && FIELD_FINAL (lvalue) && !IS_CLINIT (current_function_decl))
11588     {
11589       parse_error_context 
11590         (wfl, "Can't assign a value to the final variable `%s'",
11591          IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11592       return 1;
11593     }
11594   return 0;
11595 }
11596
11597 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
11598    read. This is needed to avoid circularities in the implementation
11599    of these fields in libjava. */
11600
11601 static tree
11602 maybe_build_primttype_type_ref (rhs, wfl)
11603     tree rhs, wfl;
11604 {
11605   tree to_return = NULL_TREE;
11606   tree rhs_type = TREE_TYPE (rhs);
11607   if (TREE_CODE (rhs) == COMPOUND_EXPR)
11608     {
11609       tree n = TREE_OPERAND (rhs, 1);
11610       if (TREE_CODE (n) == VAR_DECL 
11611           && DECL_NAME (n) == TYPE_identifier_node
11612           && rhs_type == class_ptr_type)
11613         {
11614           const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
11615           if (!strncmp (self_name, "java.lang.", 10))
11616             to_return = build_primtype_type_ref (self_name);
11617         }
11618     }
11619   return (to_return ? to_return : rhs );
11620 }
11621
11622 /* 15.25 Assignment operators. */
11623
11624 static tree
11625 patch_assignment (node, wfl_op1, wfl_op2)
11626      tree node;
11627      tree wfl_op1;
11628      tree wfl_op2;
11629 {
11630   tree rhs = TREE_OPERAND (node, 1);
11631   tree lvalue = TREE_OPERAND (node, 0), llvalue;
11632   tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
11633   int error_found = 0;
11634   int lvalue_from_array = 0;
11635
11636   /* Can't assign to a final. */
11637   if (check_final_assignment (lvalue, wfl_op1))
11638     error_found = 1;
11639
11640   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
11641
11642   /* Lhs can be a named variable */
11643   if (JDECL_P (lvalue))
11644     {
11645       lhs_type = TREE_TYPE (lvalue);
11646     }
11647   /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
11648      comment on reason why */
11649   else if (TREE_CODE (wfl_op1) == ARRAY_REF)
11650     {
11651       lhs_type = TREE_TYPE (lvalue);
11652       lvalue_from_array = 1;
11653     }
11654   /* Or a field access */
11655   else if (TREE_CODE (lvalue) == COMPONENT_REF)
11656     lhs_type = TREE_TYPE (lvalue);
11657   /* Or a function return slot */
11658   else if (TREE_CODE (lvalue) == RESULT_DECL)
11659     lhs_type = TREE_TYPE (lvalue);
11660   /* Otherwise, we might want to try to write into an optimized static
11661      final, this is an of a different nature, reported further on. */
11662   else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
11663            && resolve_expression_name (wfl_op1, &llvalue))
11664     {
11665       if (check_final_assignment (llvalue, wfl_op1))
11666         {
11667           /* What we should do instead is resetting the all the flags
11668              previously set, exchange lvalue for llvalue and continue. */
11669           error_found = 1;
11670           return error_mark_node;
11671         }
11672       else 
11673         lhs_type = TREE_TYPE (lvalue);
11674     }
11675   else 
11676     {
11677       parse_error_context (wfl_op1, "Invalid left hand side of assignment");
11678       error_found = 1;
11679     }
11680
11681   rhs_type = TREE_TYPE (rhs);
11682   /* 5.1 Try the assignment conversion for builtin type. */
11683   new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
11684
11685   /* 5.2 If it failed, try a reference conversion */
11686   if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
11687     lhs_type = promote_type (rhs_type);
11688
11689   /* 15.25.2 If we have a compound assignment, convert RHS into the
11690      type of the LHS */
11691   else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
11692     new_rhs = convert (lhs_type, rhs);
11693
11694   /* Explicit cast required. This is an error */
11695   if (!new_rhs)
11696     {
11697       char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
11698       char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
11699       tree wfl;
11700       char operation [32];      /* Max size known */
11701
11702       /* If the assignment is part of a declaration, we use the WFL of
11703          the declared variable to point out the error and call it a
11704          declaration problem. If the assignment is a genuine =
11705          operator, we call is a operator `=' problem, otherwise we
11706          call it an assignment problem. In both of these last cases,
11707          we use the WFL of the operator to indicate the error. */
11708
11709       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
11710         {
11711           wfl = wfl_op1;
11712           strcpy (operation, "declaration");
11713         }
11714       else
11715         {
11716           wfl = wfl_operator;
11717           if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
11718             strcpy (operation, "assignment");
11719           else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
11720             strcpy (operation, "`return'");
11721           else
11722             strcpy (operation, "`='");
11723         }
11724
11725       if (!valid_cast_to_p (rhs_type, lhs_type))
11726         parse_error_context (wfl, "Incompatible type for %s. "
11727                              "Can't convert `%s' to `%s'",
11728                              operation, t1, t2);
11729       else
11730         parse_error_context (wfl, "Incompatible type for %s. "
11731                              "Explicit cast needed to convert `%s' to `%s'",
11732                              operation, t1, t2);
11733       free (t1); free (t2);
11734       error_found = 1;
11735     }
11736
11737   /* Inline read access to java.lang.PRIMTYPE.TYPE */
11738   if (new_rhs)
11739     new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
11740
11741   if (error_found)
11742     return error_mark_node;
11743
11744   /* 10.10: Array Store Exception runtime check */
11745   if (!flag_emit_class_files
11746       && !flag_emit_xref
11747       && lvalue_from_array 
11748       && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type))
11749       && !CLASS_FINAL (TYPE_NAME (GET_SKIP_TYPE (rhs_type))))
11750     {
11751       tree check;
11752       tree base = lvalue;
11753
11754       /* We need to retrieve the right argument for _Jv_CheckArrayStore */
11755       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
11756         base = TREE_OPERAND (lvalue, 0);
11757       else
11758         {
11759           if (flag_bounds_check)
11760             base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
11761           else
11762             base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
11763         }
11764
11765       /* Build the invocation of _Jv_CheckArrayStore */
11766       new_rhs = save_expr (new_rhs);
11767       check = build (CALL_EXPR, void_type_node,
11768                      build_address_of (soft_checkarraystore_node),
11769                      tree_cons (NULL_TREE, base,
11770                                 build_tree_list (NULL_TREE, new_rhs)),
11771                      NULL_TREE);
11772       TREE_SIDE_EFFECTS (check) = 1;
11773
11774       /* We have to decide on an insertion point */
11775       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
11776         {
11777           tree t;
11778           if (flag_bounds_check)
11779             {
11780               t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
11781               TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
11782                 build (COMPOUND_EXPR, void_type_node, t, check);
11783             }
11784           else
11785             TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
11786                                               check, TREE_OPERAND (lvalue, 1));
11787         }
11788       else 
11789         {
11790           /* Make sure the bound check will happen before the store check */
11791           if (flag_bounds_check)
11792             TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
11793               build (COMPOUND_EXPR, void_type_node,
11794                      TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
11795           else
11796             lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
11797         }
11798     }
11799
11800   TREE_OPERAND (node, 0) = lvalue;
11801   TREE_OPERAND (node, 1) = new_rhs;
11802   TREE_TYPE (node) = lhs_type;
11803   return node;
11804 }
11805
11806 /* Check that type SOURCE can be cast into type DEST. If the cast
11807    can't occur at all, return 0 otherwise 1. This function is used to
11808    produce accurate error messages on the reasons why an assignment
11809    failed. */
11810
11811 static tree
11812 try_reference_assignconv (lhs_type, rhs)
11813      tree lhs_type, rhs;
11814 {
11815   tree new_rhs = NULL_TREE;
11816   tree rhs_type = TREE_TYPE (rhs);
11817
11818   if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
11819     {
11820       /* `null' may be assigned to any reference type */
11821       if (rhs == null_pointer_node)
11822         new_rhs = null_pointer_node;
11823       /* Try the reference assignment conversion */
11824       else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
11825         new_rhs = rhs;
11826       /* This is a magic assignment that we process differently */
11827       else if (rhs == soft_exceptioninfo_call_node)
11828         new_rhs = rhs;
11829     }
11830   return new_rhs;
11831 }
11832
11833 /* Check that RHS can be converted into LHS_TYPE by the assignment
11834    conversion (5.2), for the cases of RHS being a builtin type. Return
11835    NULL_TREE if the conversion fails or if because RHS isn't of a
11836    builtin type. Return a converted RHS if the conversion is possible.  */
11837
11838 static tree
11839 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
11840      tree wfl_op1, lhs_type, rhs;
11841 {
11842   tree new_rhs = NULL_TREE;
11843   tree rhs_type = TREE_TYPE (rhs);
11844
11845   /* Zero accepted everywhere */
11846   if (TREE_CODE (rhs) == INTEGER_CST 
11847       && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
11848       && JPRIMITIVE_TYPE_P (rhs_type))
11849     new_rhs = convert (lhs_type, rhs);
11850
11851   /* 5.1.1 Try Identity Conversion,
11852      5.1.2 Try Widening Primitive Conversion */
11853   else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
11854     new_rhs = convert (lhs_type, rhs);
11855
11856   /* Try a narrowing primitive conversion (5.1.3): 
11857        - expression is a constant expression of type int AND
11858        - variable is byte, short or char AND
11859        - The value of the expression is representable in the type of the 
11860          variable */
11861   else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
11862            && (lhs_type == byte_type_node || lhs_type == char_type_node
11863                || lhs_type == short_type_node))
11864     {
11865       if (int_fits_type_p (rhs, lhs_type))
11866         new_rhs = convert (lhs_type, rhs);
11867       else if (wfl_op1)         /* Might be called with a NULL */
11868         parse_warning_context 
11869           (wfl_op1, "Constant expression `%s' to wide for narrowing "
11870            "primitive conversion to `%s'", 
11871            print_int_node (rhs), lang_printable_name (lhs_type, 0));
11872       /* Reported a warning that will turn into an error further
11873          down, so we don't return */
11874     }
11875
11876   return new_rhs;
11877 }
11878
11879 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
11880    conversion (5.1.1) or widening primitve conversion (5.1.2).  Return
11881    0 is the conversion test fails.  This implements parts the method
11882    invocation convertion (5.3).  */
11883
11884 static int
11885 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
11886      tree lhs_type, rhs_type;
11887 {
11888   /* 5.1.1: This is the identity conversion part. */
11889   if (lhs_type == rhs_type)
11890     return 1;
11891
11892   /* Reject non primitive types */
11893   if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
11894     return 0;
11895
11896   /* 5.1.2: widening primitive conversion. byte, even if it's smaller
11897      than a char can't be converted into a char. Short can't too, but
11898      the < test below takes care of that */
11899   if (lhs_type == char_type_node && rhs_type == byte_type_node)
11900     return 0;
11901
11902   /* Accept all promoted type here. Note, we can't use <= in the test
11903      below, because we still need to bounce out assignments of short
11904      to char and the likes */
11905   if (lhs_type == int_type_node
11906       && (rhs_type == promoted_byte_type_node
11907           || rhs_type == promoted_short_type_node
11908           || rhs_type == promoted_char_type_node
11909           || rhs_type == promoted_boolean_type_node))
11910     return 1;
11911
11912   /* From here, an integral is widened if its precision is smaller
11913      than the precision of the LHS or if the LHS is a floating point
11914      type, or the RHS is a float and the RHS a double. */
11915   if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type) 
11916        && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
11917       || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
11918       || (rhs_type == float_type_node && lhs_type == double_type_node))
11919     return 1;
11920
11921   return 0;
11922 }
11923
11924 /* Check that something of SOURCE type can be assigned or cast to
11925    something of DEST type at runtime. Return 1 if the operation is
11926    valid, 0 otherwise. If CAST is set to 1, we're treating the case
11927    were SOURCE is cast into DEST, which borrows a lot of the
11928    assignment check. */
11929
11930 static int
11931 valid_ref_assignconv_cast_p (source, dest, cast)
11932      tree source;
11933      tree dest;
11934      int cast;
11935 {
11936   /* SOURCE or DEST might be null if not from a declared entity. */
11937   if (!source || !dest)
11938     return 0;
11939   if (JNULLP_TYPE_P (source))
11940     return 1;
11941   if (TREE_CODE (source) == POINTER_TYPE)
11942     source = TREE_TYPE (source);
11943   if (TREE_CODE (dest) == POINTER_TYPE)
11944     dest = TREE_TYPE (dest);
11945   /* Case where SOURCE is a class type */
11946   if (TYPE_CLASS_P (source))
11947     {
11948       if (TYPE_CLASS_P (dest))
11949         return  source == dest || inherits_from_p (source, dest)
11950           || (cast && inherits_from_p (dest, source));
11951       if (TYPE_INTERFACE_P (dest))
11952         {
11953           /* If doing a cast and SOURCE is final, the operation is
11954              always correct a compile time (because even if SOURCE
11955              does not implement DEST, a subclass of SOURCE might). */
11956           if (cast && !CLASS_FINAL (TYPE_NAME (source)))
11957             return 1;
11958           /* Otherwise, SOURCE must implement DEST */
11959           return interface_of_p (dest, source);
11960         }
11961       /* DEST is an array, cast permited if SOURCE is of Object type */
11962       return (cast && source == object_type_node ? 1 : 0);
11963     }
11964   if (TYPE_INTERFACE_P (source))
11965     {
11966       if (TYPE_CLASS_P (dest))
11967         {
11968           /* If not casting, DEST must be the Object type */
11969           if (!cast)
11970             return dest == object_type_node;
11971           /* We're doing a cast. The cast is always valid is class
11972              DEST is not final, otherwise, DEST must implement SOURCE */
11973           else if (!CLASS_FINAL (TYPE_NAME (dest)))
11974             return 1;
11975           else
11976             return interface_of_p (source, dest);
11977         }
11978       if (TYPE_INTERFACE_P (dest))
11979         {
11980           /* If doing a cast, then if SOURCE and DEST contain method
11981              with the same signature but different return type, then
11982              this is a (compile time) error */
11983           if (cast)
11984             {
11985               tree method_source, method_dest;
11986               tree source_type;
11987               tree source_sig;
11988               tree source_name;
11989               for (method_source = TYPE_METHODS (source); method_source; 
11990                    method_source = TREE_CHAIN (method_source))
11991                 {
11992                   source_sig = 
11993                     build_java_argument_signature (TREE_TYPE (method_source));
11994                   source_type = TREE_TYPE (TREE_TYPE (method_source));
11995                   source_name = DECL_NAME (method_source);
11996                   for (method_dest = TYPE_METHODS (dest);
11997                        method_dest; method_dest = TREE_CHAIN (method_dest))
11998                     if (source_sig == 
11999                         build_java_argument_signature (TREE_TYPE (method_dest))
12000                         && source_name == DECL_NAME (method_dest)
12001                         && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
12002                       return 0;
12003                 }
12004               return 1;
12005             }
12006           else
12007             return source == dest || interface_of_p (dest, source);
12008         }
12009       else                      /* Array */
12010         return (cast ? 
12011                 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
12012     }
12013   if (TYPE_ARRAY_P (source))
12014     {
12015       if (TYPE_CLASS_P (dest))
12016         return dest == object_type_node;
12017       /* Can't cast an array to an interface unless the interface is
12018          java.lang.Cloneable */
12019       if (TYPE_INTERFACE_P (dest))
12020         return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
12021       else                      /* Arrays */
12022         {
12023           tree source_element_type = TYPE_ARRAY_ELEMENT (source);
12024           tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
12025           
12026           /* In case of severe errors, they turn out null */
12027           if (!dest_element_type || !source_element_type)
12028             return 0;
12029           if (source_element_type == dest_element_type)
12030             return 1;
12031           return valid_ref_assignconv_cast_p (source_element_type,
12032                                               dest_element_type, cast);
12033         }
12034       return 0;
12035     }
12036   return 0;
12037 }
12038
12039 static int
12040 valid_cast_to_p (source, dest)
12041      tree source;
12042      tree dest;
12043 {
12044   if (TREE_CODE (source) == POINTER_TYPE)
12045     source = TREE_TYPE (source);
12046   if (TREE_CODE (dest) == POINTER_TYPE)
12047     dest = TREE_TYPE (dest);
12048
12049   if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
12050     return valid_ref_assignconv_cast_p (source, dest, 1);
12051
12052   else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
12053     return 1;
12054
12055   return 0;
12056 }
12057
12058 /* Method invocation conversion test. Return 1 if type SOURCE can be
12059    converted to type DEST through the methond invocation conversion
12060    process (5.3) */
12061
12062 static tree
12063 do_unary_numeric_promotion (arg)
12064      tree arg;
12065 {
12066   tree type = TREE_TYPE (arg);
12067   if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
12068       : TREE_CODE (type) == CHAR_TYPE)
12069     arg = convert (int_type_node, arg);
12070   return arg;
12071 }
12072
12073 /* Return a non zero value if SOURCE can be converted into DEST using
12074    the method invocation conversion rule (5.3).  */
12075 static int
12076 valid_method_invocation_conversion_p (dest, source)
12077      tree dest, source;
12078 {
12079   return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
12080            && valid_builtin_assignconv_identity_widening_p (dest, source))
12081           || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
12082               && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
12083               && valid_ref_assignconv_cast_p (source, dest, 0)));
12084 }
12085
12086 /* Build an incomplete binop expression. */
12087
12088 static tree
12089 build_binop (op, op_location, op1, op2)
12090      enum tree_code op;
12091      int op_location;
12092      tree op1, op2;
12093 {
12094   tree binop = build (op, NULL_TREE, op1, op2);
12095   TREE_SIDE_EFFECTS (binop) = 1;
12096   /* Store the location of the operator, for better error report. The
12097      string of the operator will be rebuild based on the OP value. */
12098   EXPR_WFL_LINECOL (binop) = op_location;
12099   return binop;
12100 }
12101
12102 /* Build the string of the operator retained by NODE. If NODE is part
12103    of a compound expression, add an '=' at the end of the string. This
12104    function is called when an error needs to be reported on an
12105    operator. The string is returned as a pointer to a static character
12106    buffer. */
12107
12108 static char *
12109 operator_string (node)
12110      tree node;
12111 {
12112 #define BUILD_OPERATOR_STRING(S)                                        \
12113   {                                                                     \
12114     sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
12115     return buffer;                                                      \
12116   }
12117   
12118   static char buffer [10];
12119   switch (TREE_CODE (node))
12120     {
12121     case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
12122     case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
12123     case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
12124     case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
12125     case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
12126     case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
12127     case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
12128     case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
12129     case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
12130     case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
12131     case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
12132     case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
12133     case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
12134     case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
12135     case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
12136     case GT_EXPR: BUILD_OPERATOR_STRING (">");
12137     case GE_EXPR: BUILD_OPERATOR_STRING (">=");
12138     case LT_EXPR: BUILD_OPERATOR_STRING ("<");
12139     case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
12140     case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
12141     case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
12142     case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
12143     case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
12144     case PREINCREMENT_EXPR:     /* Fall through */
12145     case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
12146     case PREDECREMENT_EXPR:     /* Fall through */
12147     case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
12148     default:
12149       fatal ("unregistered operator %s - operator_string",
12150              tree_code_name [TREE_CODE (node)]);
12151     }
12152   return NULL;
12153 #undef BUILD_OPERATOR_STRING
12154 }
12155
12156 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2.  */
12157
12158 static int
12159 java_decl_equiv (var_acc1, var_acc2)
12160      tree var_acc1, var_acc2;
12161 {
12162   if (JDECL_P (var_acc1))
12163     return (var_acc1 == var_acc2);
12164   
12165   return (TREE_CODE (var_acc1) == COMPONENT_REF
12166           && TREE_CODE (var_acc2) == COMPONENT_REF
12167           && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
12168              == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
12169           && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
12170 }
12171
12172 /* Return a non zero value if CODE is one of the operators that can be
12173    used in conjunction with the `=' operator in a compound assignment.  */
12174
12175 static int
12176 binop_compound_p (code)
12177     enum tree_code code;
12178 {
12179   int i;
12180   for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
12181     if (binop_lookup [i] == code)
12182       break;
12183
12184   return i < BINOP_COMPOUND_CANDIDATES;
12185 }
12186
12187 /* Reorganize after a fold to get SAVE_EXPR to generate what we want.  */
12188
12189 static tree
12190 java_refold (t)
12191      tree t;
12192 {
12193   tree c, b, ns, decl;
12194
12195   if (TREE_CODE (t) != MODIFY_EXPR)
12196     return t;
12197
12198   c = TREE_OPERAND (t, 1);
12199   if (! (c && TREE_CODE (c) == COMPOUND_EXPR
12200          && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
12201          && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
12202     return t;
12203
12204   /* Now the left branch of the binary operator. */
12205   b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
12206   if (! (b && TREE_CODE (b) == NOP_EXPR 
12207          && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
12208     return t;
12209
12210   ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
12211   if (! (ns && TREE_CODE (ns) == NOP_EXPR
12212          && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
12213     return t;
12214
12215   decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
12216   if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
12217       /* It's got to be the an equivalent decl */
12218       && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
12219     {
12220       /* Shorten the NOP_EXPR/SAVE_EXPR path. */
12221       TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
12222       /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
12223       TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
12224       /* Change the right part of the BINOP_EXPR */
12225       TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
12226     }
12227
12228   return t;
12229 }
12230
12231 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
12232    errors but we modify NODE so that it contains the type computed
12233    according to the expression, when it's fixed. Otherwise, we write
12234    error_mark_node as the type. It allows us to further the analysis
12235    of remaining nodes and detects more errors in certain cases.  */
12236
12237 static tree
12238 patch_binop (node, wfl_op1, wfl_op2)
12239      tree node;
12240      tree wfl_op1;
12241      tree wfl_op2;
12242 {
12243   tree op1 = TREE_OPERAND (node, 0);
12244   tree op2 = TREE_OPERAND (node, 1);
12245   tree op1_type = TREE_TYPE (op1);
12246   tree op2_type = TREE_TYPE (op2);
12247   tree prom_type = NULL_TREE;
12248   int code = TREE_CODE (node);
12249
12250   /* If 1, tell the routine that we have to return error_mark_node
12251      after checking for the initialization of the RHS */
12252   int error_found = 0;
12253
12254   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
12255
12256   switch (code)
12257     {
12258     /* 15.16 Multiplicative operators */
12259     case MULT_EXPR:             /* 15.16.1 Multiplication Operator * */
12260     case RDIV_EXPR:             /* 15.16.2 Division Operator / */
12261     case TRUNC_MOD_EXPR:        /* 15.16.3 Remainder operator % */
12262       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
12263         {
12264           if (!JPRIMITIVE_TYPE_P (op1_type))
12265             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
12266           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
12267             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
12268           TREE_TYPE (node) = error_mark_node;
12269           error_found = 1;
12270           break;
12271         }
12272       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12273       /* Change the division operator if necessary */
12274       if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
12275         TREE_SET_CODE (node, TRUNC_DIV_EXPR);
12276
12277       if (TREE_CODE (prom_type) == INTEGER_TYPE
12278           && flag_use_divide_subroutine
12279           && ! flag_emit_class_files
12280           && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
12281         return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
12282  
12283       /* This one is more complicated. FLOATs are processed by a
12284          function call to soft_fmod. Duplicate the value of the
12285          COMPOUND_ASSIGN_P flag. */
12286       if (code == TRUNC_MOD_EXPR)
12287         {
12288           tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
12289           COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
12290           TREE_SIDE_EFFECTS (mod)
12291             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
12292           return mod;
12293         }
12294       break;
12295
12296     /* 15.17 Additive Operators */
12297     case PLUS_EXPR:             /* 15.17.1 String Concatenation Operator + */
12298
12299       /* Operation is valid if either one argument is a string
12300          constant, a String object or a StringBuffer crafted for the
12301          purpose of the a previous usage of the String concatenation
12302          operator */
12303
12304       if (TREE_CODE (op1) == STRING_CST 
12305           || TREE_CODE (op2) == STRING_CST
12306           || JSTRING_TYPE_P (op1_type)
12307           || JSTRING_TYPE_P (op2_type)
12308           || IS_CRAFTED_STRING_BUFFER_P (op1)
12309           || IS_CRAFTED_STRING_BUFFER_P (op2))
12310         return build_string_concatenation (op1, op2);
12311
12312     case MINUS_EXPR:            /* 15.17.2 Additive Operators (+ and -) for
12313                                    Numeric Types */
12314       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
12315         {
12316           if (!JPRIMITIVE_TYPE_P (op1_type))
12317             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
12318           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
12319             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
12320           TREE_TYPE (node) = error_mark_node;
12321           error_found = 1;
12322           break;
12323         }
12324       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12325       break;
12326
12327     /* 15.18 Shift Operators */
12328     case LSHIFT_EXPR:
12329     case RSHIFT_EXPR:
12330     case URSHIFT_EXPR:
12331       if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
12332         {
12333           if (!JINTEGRAL_TYPE_P (op1_type))
12334             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
12335           else
12336             {
12337               if (JPRIMITIVE_TYPE_P (op2_type))
12338                 parse_error_context (wfl_operator,
12339                                      "Incompatible type for `%s'. "
12340                                      "Explicit cast needed to convert "
12341                                      "shift distance from `%s' to integral",
12342                                      operator_string (node),
12343                                      lang_printable_name (op2_type, 0));
12344               else
12345                 parse_error_context (wfl_operator, "Incompatible type for `%s'."
12346                                      " Can't convert shift distance from "
12347                                      "`%s' to integral", 
12348                                      operator_string (node),
12349                                      lang_printable_name (op2_type, 0));
12350             }
12351           TREE_TYPE (node) = error_mark_node;
12352           error_found = 1;
12353           break;
12354         }
12355
12356       /* Unary numeric promotion (5.6.1) is performed on each operand
12357          separatly */
12358       op1 = do_unary_numeric_promotion (op1);
12359       op2 = do_unary_numeric_promotion (op2);
12360
12361       /* The type of the shift expression is the type of the promoted
12362          type of the left-hand operand */
12363       prom_type = TREE_TYPE (op1);
12364
12365       /* Shift int only up to 0x1f and long up to 0x3f */
12366       if (prom_type == int_type_node)
12367         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
12368                            build_int_2 (0x1f, 0)));
12369       else
12370         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
12371                            build_int_2 (0x3f, 0)));
12372
12373       /* The >>> operator is a >> operating on unsigned quantities */
12374       if (code == URSHIFT_EXPR && ! flag_emit_class_files)
12375         {
12376           tree to_return;
12377           tree utype = unsigned_type (prom_type);
12378           op1 = convert (utype, op1);
12379           TREE_SET_CODE (node, RSHIFT_EXPR);
12380           TREE_OPERAND (node, 0) = op1;
12381           TREE_OPERAND (node, 1) = op2;
12382           TREE_TYPE (node) = utype;
12383           to_return = convert (prom_type, node);
12384           /* Copy the original value of the COMPOUND_ASSIGN_P flag */
12385           COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
12386           TREE_SIDE_EFFECTS (to_return)
12387             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
12388           return to_return;
12389         }
12390       break;
12391
12392       /* 15.19.1 Type Comparison Operator instaceof */
12393     case INSTANCEOF_EXPR:
12394
12395       TREE_TYPE (node) = boolean_type_node;
12396
12397       if (!(op2_type = resolve_type_during_patch (op2)))
12398         return error_mark_node;
12399
12400       /* The first operand must be a reference type or the null type */
12401       if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
12402         error_found = 1;        /* Error reported further below */
12403
12404       /* The second operand must be a reference type */
12405       if (!JREFERENCE_TYPE_P (op2_type))
12406         {
12407           SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
12408           parse_error_context
12409             (wfl_operator, "Invalid argument `%s' for `instanceof'",
12410              lang_printable_name (op2_type, 0));
12411           error_found = 1;
12412         }
12413
12414       if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
12415         {
12416           /* If the first operand is null, the result is always false */
12417           if (op1 == null_pointer_node)
12418             return boolean_false_node;
12419           else if (flag_emit_class_files)
12420             {
12421               TREE_OPERAND (node, 1) = op2_type;
12422               TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
12423               return node;
12424             }
12425           /* Otherwise we have to invoke instance of to figure it out */
12426           else
12427             {
12428               tree call =
12429                 build (CALL_EXPR, boolean_type_node,
12430                        build_address_of (soft_instanceof_node),
12431                        tree_cons 
12432                        (NULL_TREE, op1,
12433                         build_tree_list (NULL_TREE,
12434                                          build_class_ref (op2_type))),
12435                        NULL_TREE);
12436               TREE_SIDE_EFFECTS (call) = TREE_SIDE_EFFECTS (op1);
12437               return call;
12438             }
12439         }
12440       /* There is no way the expression operand can be an instance of
12441          the type operand. This is a compile time error. */
12442       else
12443         {
12444           char *t1 = xstrdup (lang_printable_name (op1_type, 0));
12445           SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
12446           parse_error_context 
12447             (wfl_operator, "Impossible for `%s' to be instance of `%s'",
12448              t1, lang_printable_name (op2_type, 0));
12449           free (t1);
12450           error_found = 1;
12451         }
12452       
12453       break;
12454
12455       /* 15.21 Bitwise and Logical Operators */
12456     case BIT_AND_EXPR:
12457     case BIT_XOR_EXPR:
12458     case BIT_IOR_EXPR:
12459       if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
12460         /* Binary numeric promotion is performed on both operand and the
12461            expression retain that type */
12462         prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12463
12464       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE 
12465                && TREE_CODE (op1_type) == BOOLEAN_TYPE)
12466         /* The type of the bitwise operator expression is BOOLEAN */
12467         prom_type = boolean_type_node;
12468       else
12469         {
12470           if (!JINTEGRAL_TYPE_P (op1_type))
12471             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
12472           if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
12473             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
12474           TREE_TYPE (node) = error_mark_node;
12475           error_found = 1;
12476           /* Insert a break here if adding thing before the switch's
12477              break for this case */
12478         }
12479       break;
12480
12481       /* 15.22 Conditional-And Operator */
12482     case TRUTH_ANDIF_EXPR:
12483       /* 15.23 Conditional-Or Operator */
12484     case TRUTH_ORIF_EXPR:
12485       /* Operands must be of BOOLEAN type */
12486       if (TREE_CODE (op1_type) != BOOLEAN_TYPE || 
12487           TREE_CODE (op2_type) != BOOLEAN_TYPE)
12488         {
12489           if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
12490             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
12491           if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
12492             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
12493           TREE_TYPE (node) = boolean_type_node;
12494           error_found = 1;
12495           break;
12496         }
12497       /* The type of the conditional operators is BOOLEAN */
12498       prom_type = boolean_type_node;
12499       break;
12500
12501       /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
12502     case LT_EXPR:
12503     case GT_EXPR:
12504     case LE_EXPR:
12505     case GE_EXPR:
12506       /* The type of each of the operands must be a primitive numeric
12507          type */
12508       if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
12509         {
12510           if (!JNUMERIC_TYPE_P (op1_type))
12511             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
12512           if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
12513             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
12514           TREE_TYPE (node) = boolean_type_node;
12515           error_found = 1;
12516           break;
12517         }
12518       /* Binary numeric promotion is performed on the operands */
12519       binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12520       /* The type of the relation expression is always BOOLEAN */
12521       prom_type = boolean_type_node;
12522       break;
12523
12524       /* 15.20 Equality Operator */
12525     case EQ_EXPR:
12526     case NE_EXPR:
12527       /* 15.20.1 Numerical Equality Operators == and != */
12528       /* Binary numeric promotion is performed on the operands */
12529       if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
12530         binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12531       
12532       /* 15.20.2 Boolean Equality Operators == and != */
12533       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
12534           TREE_CODE (op2_type) == BOOLEAN_TYPE)
12535         ;                       /* Nothing to do here */
12536       
12537       /* 15.20.3 Reference Equality Operators == and != */
12538       /* Types have to be either references or the null type. If
12539          they're references, it must be possible to convert either
12540          type to the other by casting conversion. */
12541       else if (op1 == null_pointer_node || op2 == null_pointer_node 
12542                || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
12543                    && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
12544                        || valid_ref_assignconv_cast_p (op2_type, 
12545                                                        op1_type, 1))))
12546         ;                       /* Nothing to do here */
12547           
12548       /* Else we have an error figure what can't be converted into
12549          what and report the error */
12550       else
12551         {
12552           char *t1;
12553           t1 = xstrdup (lang_printable_name (op1_type, 0));
12554           parse_error_context 
12555             (wfl_operator, "Incompatible type for `%s'. Can't convert `%s' "
12556              "to `%s'", operator_string (node), t1, 
12557              lang_printable_name (op2_type, 0));
12558           free (t1);
12559           TREE_TYPE (node) = boolean_type_node;
12560           error_found = 1;
12561           break;
12562         }
12563       prom_type = boolean_type_node;
12564       break;
12565     }
12566
12567   if (error_found)
12568     return error_mark_node;
12569
12570   TREE_OPERAND (node, 0) = op1;
12571   TREE_OPERAND (node, 1) = op2;
12572   TREE_TYPE (node) = prom_type;
12573   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
12574   
12575   if (flag_emit_xref)
12576     return node;
12577
12578   /* fold does not respect side-effect order as required for Java but not C.
12579    * Also, it sometimes create SAVE_EXPRs which are bad when emitting
12580    * bytecode.
12581    */
12582   if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
12583       : ! TREE_SIDE_EFFECTS (node))
12584     node = fold (node);
12585   return node;
12586 }
12587
12588 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
12589    zero value, the value of CSTE comes after the valude of STRING */
12590
12591 static tree
12592 do_merge_string_cste (cste, string, string_len, after)
12593      tree cste;
12594      const char *string;
12595      int string_len, after;
12596 {
12597   int len = TREE_STRING_LENGTH (cste) + string_len;
12598   const char *old = TREE_STRING_POINTER (cste);
12599   TREE_STRING_LENGTH (cste) = len;
12600   TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
12601   if (after)
12602     {
12603       strcpy (TREE_STRING_POINTER (cste), string);
12604       strcat (TREE_STRING_POINTER (cste), old);
12605     }
12606   else
12607     {
12608       strcpy (TREE_STRING_POINTER (cste), old);
12609       strcat (TREE_STRING_POINTER (cste), string);
12610     }
12611   return cste;
12612 }
12613
12614 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
12615    new STRING_CST on success, NULL_TREE on failure */
12616
12617 static tree
12618 merge_string_cste (op1, op2, after)
12619      tree op1, op2;
12620      int after;
12621 {
12622   /* Handle two string constants right away */
12623   if (TREE_CODE (op2) == STRING_CST)
12624     return do_merge_string_cste (op1, TREE_STRING_POINTER (op2), 
12625                                  TREE_STRING_LENGTH (op2), after);
12626   
12627   /* Reasonable integer constant can be treated right away */
12628   if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
12629     {
12630       static const char *boolean_true = "true";
12631       static const char *boolean_false = "false";
12632       static const char *null_pointer = "null";
12633       char ch[3];
12634       const char *string;
12635       
12636       if (op2 == boolean_true_node)
12637         string = boolean_true;
12638       else if (op2 == boolean_false_node)
12639         string = boolean_false;
12640       else if (op2 == null_pointer_node)
12641         string = null_pointer;
12642       else if (TREE_TYPE (op2) == char_type_node)
12643         {
12644           ch[0] = (char )TREE_INT_CST_LOW (op2);
12645           ch[1] = '\0';
12646           string = ch;
12647         }
12648       else
12649           string = print_int_node (op2);
12650       
12651       return do_merge_string_cste (op1, string, strlen (string), after);
12652     }
12653   return NULL_TREE;
12654 }
12655
12656 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
12657    has to be a STRING_CST and the other part must be a STRING_CST or a
12658    INTEGRAL constant. Return a new STRING_CST if the operation
12659    succeed, NULL_TREE otherwise.
12660
12661    If the case we want to optimize for space, we might want to return
12662    NULL_TREE for each invocation of this routine. FIXME */
12663
12664 static tree
12665 string_constant_concatenation (op1, op2)
12666      tree op1, op2;
12667 {
12668   if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
12669     {
12670       tree string, rest;
12671       int invert;
12672       
12673       string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
12674       rest   = (string == op1 ? op2 : op1);
12675       invert = (string == op1 ? 0 : 1 );
12676       
12677       /* Walk REST, only if it looks reasonable */
12678       if (TREE_CODE (rest) != STRING_CST
12679           && !IS_CRAFTED_STRING_BUFFER_P (rest)
12680           && !JSTRING_TYPE_P (TREE_TYPE (rest))
12681           && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
12682         {
12683           rest = java_complete_tree (rest);
12684           if (rest == error_mark_node)
12685             return error_mark_node;
12686           rest = fold (rest);
12687         }
12688       return merge_string_cste (string, rest, invert);
12689     }
12690   return NULL_TREE;
12691 }
12692
12693 /* Implement the `+' operator. Does static optimization if possible,
12694    otherwise create (if necessary) and append elements to a
12695    StringBuffer. The StringBuffer will be carried around until it is
12696    used for a function call or an assignment. Then toString() will be
12697    called on it to turn it into a String object. */
12698
12699 static tree
12700 build_string_concatenation (op1, op2)
12701      tree op1, op2;
12702 {
12703   tree result;
12704   int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
12705
12706   if (flag_emit_xref)
12707     return build (PLUS_EXPR, string_type_node, op1, op2);
12708   
12709   /* Try to do some static optimization */
12710   if ((result = string_constant_concatenation (op1, op2)))
12711     return result;
12712
12713   /* Discard empty strings on either side of the expression */
12714   if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
12715     {
12716       op1 = op2;
12717       op2 = NULL_TREE;
12718     }
12719   else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
12720     op2 = NULL_TREE;
12721
12722   /* If operands are string constant, turn then into object references */
12723   if (TREE_CODE (op1) == STRING_CST)
12724     op1 = patch_string_cst (op1);
12725   if (op2 && TREE_CODE (op2) == STRING_CST)
12726     op2 = patch_string_cst (op2);
12727
12728   /* If either one of the constant is null and the other non null
12729      operand is a String object, return it. */
12730   if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
12731     return op1;
12732
12733   /* If OP1 isn't already a StringBuffer, create and
12734      initialize a new one */
12735   if (!IS_CRAFTED_STRING_BUFFER_P (op1))
12736     {
12737       /* Two solutions here: 
12738          1) OP1 is a string reference, we call new StringBuffer(OP1)
12739          2) OP1 is something else, we call new StringBuffer().append(OP1). */
12740       if (JSTRING_TYPE_P (TREE_TYPE (op1)))
12741         op1 = BUILD_STRING_BUFFER (op1);
12742       else
12743         {
12744           tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
12745           op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
12746         }
12747     }
12748
12749   if (op2)
12750     {
12751       /* OP1 is no longer the last node holding a crafted StringBuffer */
12752       IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
12753       /* Create a node for `{new...,xxx}.append (op2)' */
12754       if (op2)
12755         op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
12756     }
12757
12758   /* Mark the last node holding a crafted StringBuffer */
12759   IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
12760
12761   TREE_SIDE_EFFECTS (op1) = side_effects;
12762   return op1;
12763 }
12764
12765 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
12766    StringBuffer. If no string were found to be patched, return
12767    NULL. */
12768
12769 static tree
12770 patch_string (node)
12771     tree node;
12772 {
12773   if (node == error_mark_node)
12774     return error_mark_node;
12775   if (TREE_CODE (node) == STRING_CST)
12776     return patch_string_cst (node);
12777   else if (IS_CRAFTED_STRING_BUFFER_P (node))
12778     {
12779       int saved = ctxp->explicit_constructor_p;
12780       tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
12781       tree ret;
12782       /* Temporary disable forbid the use of `this'. */
12783       ctxp->explicit_constructor_p = 0;
12784       ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
12785       /* Restore it at its previous value */
12786       ctxp->explicit_constructor_p = saved;
12787       return ret;
12788     }
12789   return NULL_TREE;
12790 }
12791
12792 /* Build the internal representation of a string constant.  */
12793
12794 static tree
12795 patch_string_cst (node)
12796      tree node;
12797 {
12798   int location;
12799   if (! flag_emit_class_files)
12800     {
12801       push_obstacks (&permanent_obstack, &permanent_obstack);
12802       node = get_identifier (TREE_STRING_POINTER (node));
12803       location = alloc_name_constant (CONSTANT_String, node);
12804       node = build_ref_from_constant_pool (location);
12805     }
12806   TREE_TYPE (node) = string_ptr_type_node;
12807   TREE_CONSTANT (node) = 1;
12808   return node;
12809 }
12810
12811 /* Build an incomplete unary operator expression. */
12812
12813 static tree
12814 build_unaryop (op_token, op_location, op1)
12815      int op_token, op_location;
12816      tree op1;
12817 {
12818   enum tree_code op;
12819   tree unaryop;
12820   switch (op_token)
12821     {
12822     case PLUS_TK: op = UNARY_PLUS_EXPR; break;
12823     case MINUS_TK: op = NEGATE_EXPR; break;
12824     case NEG_TK: op = TRUTH_NOT_EXPR; break;
12825     case NOT_TK: op = BIT_NOT_EXPR; break;
12826     default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
12827                     op_token);
12828     }
12829
12830   unaryop = build1 (op, NULL_TREE, op1);
12831   TREE_SIDE_EFFECTS (unaryop) = 1;
12832   /* Store the location of the operator, for better error report. The
12833      string of the operator will be rebuild based on the OP value. */
12834   EXPR_WFL_LINECOL (unaryop) = op_location;
12835   return unaryop;
12836 }
12837
12838 /* Special case for the ++/-- operators, since they require an extra
12839    argument to build, which is set to NULL and patched
12840    later. IS_POST_P is 1 if the operator, 0 otherwise.  */
12841
12842 static tree
12843 build_incdec (op_token, op_location, op1, is_post_p)
12844      int op_token, op_location;
12845      tree op1;
12846      int is_post_p;
12847 {
12848   static enum tree_code lookup [2][2] = 
12849     {
12850       { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
12851       { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
12852     };
12853   tree node = build (lookup [is_post_p][(op_token - DECR_TK)], 
12854                      NULL_TREE, op1, NULL_TREE);
12855   TREE_SIDE_EFFECTS (node) = 1;
12856   /* Store the location of the operator, for better error report. The
12857      string of the operator will be rebuild based on the OP value. */
12858   EXPR_WFL_LINECOL (node) = op_location;
12859   return node;
12860 }     
12861
12862 /* Build an incomplete cast operator, based on the use of the
12863    CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
12864    set. java_complete_tree is trained to walk a CONVERT_EXPR even
12865    though its type is already set.  */
12866
12867 static tree
12868 build_cast (location, type, exp)
12869      int location;
12870      tree type, exp;
12871 {
12872   tree node = build1 (CONVERT_EXPR, type, exp);
12873   EXPR_WFL_LINECOL (node) = location;
12874   return node;
12875 }
12876
12877 /* 15.14 Unary operators. We return error_mark_node in case of error,
12878    but preserve the type of NODE if the type is fixed.  */
12879
12880 static tree
12881 patch_unaryop (node, wfl_op)
12882      tree node;
12883      tree wfl_op;
12884 {
12885   tree op = TREE_OPERAND (node, 0);
12886   tree op_type = TREE_TYPE (op);
12887   tree prom_type = NULL_TREE, value, decl;
12888   int code = TREE_CODE (node);
12889   int error_found = 0;
12890
12891   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
12892
12893   switch (code)
12894     {
12895       /* 15.13.2 Postfix Increment Operator ++ */
12896     case POSTINCREMENT_EXPR:
12897       /* 15.13.3 Postfix Increment Operator -- */
12898     case POSTDECREMENT_EXPR:
12899       /* 15.14.1 Prefix Increment Operator ++ */
12900     case PREINCREMENT_EXPR:
12901       /* 15.14.2 Prefix Decrement Operator -- */
12902     case PREDECREMENT_EXPR:
12903       op = decl = strip_out_static_field_access_decl (op);
12904       /* We really should have a JAVA_ARRAY_EXPR to avoid this */
12905       if (!JDECL_P (decl) 
12906           && TREE_CODE (decl) != COMPONENT_REF
12907           && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
12908           && TREE_CODE (decl) != INDIRECT_REF
12909           && !(TREE_CODE (decl) == COMPOUND_EXPR
12910                && TREE_OPERAND (decl, 1)
12911                && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
12912         {
12913           tree lvalue;
12914           /* Before screaming, check that we're not in fact trying to
12915              increment a optimized static final access, in which case
12916              we issue an different error message. */
12917           if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
12918                 && resolve_expression_name (wfl_op, &lvalue)
12919                 && check_final_assignment (lvalue, wfl_op)))
12920             parse_error_context (wfl_operator, "Invalid argument to `%s'",
12921                                  operator_string (node));
12922           TREE_TYPE (node) = error_mark_node;
12923           error_found = 1;
12924         }
12925       else if (check_final_assignment (op, wfl_op))
12926         error_found = 1;
12927
12928       /* From now on, we know that op if a variable and that it has a
12929          valid wfl. We use wfl_op to locate errors related to the
12930          ++/-- operand. */
12931       else if (!JNUMERIC_TYPE_P (op_type))
12932         {
12933           parse_error_context
12934             (wfl_op, "Invalid argument type `%s' to `%s'",
12935              lang_printable_name (op_type, 0), operator_string (node));
12936           TREE_TYPE (node) = error_mark_node;
12937           error_found = 1;
12938         }
12939       else
12940         {
12941           /* Before the addition, binary numeric promotion is performed on
12942              both operands, if really necessary */
12943           if (JINTEGRAL_TYPE_P (op_type))
12944             {
12945               value = build_int_2 (1, 0);
12946               TREE_TYPE (value) = TREE_TYPE (node) = op_type;
12947             }
12948           else
12949             {
12950               value = build_int_2 (1, 0);
12951               TREE_TYPE (node) = 
12952                 binary_numeric_promotion (op_type, 
12953                                           TREE_TYPE (value), &op, &value);
12954             }
12955           /* And write back into the node. */
12956           TREE_OPERAND (node, 0) = op;
12957           TREE_OPERAND (node, 1) = value;
12958           /* Convert the overall back into its original type, if
12959              necessary, and return */
12960           if (JINTEGRAL_TYPE_P (op_type))
12961             return fold (node);
12962           else
12963             return fold (convert (op_type, node));
12964         }
12965       break;
12966
12967       /* 15.14.3 Unary Plus Operator + */
12968     case UNARY_PLUS_EXPR:
12969       /* 15.14.4 Unary Minus Operator - */
12970     case NEGATE_EXPR:
12971       if (!JNUMERIC_TYPE_P (op_type))
12972         {
12973           ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
12974           TREE_TYPE (node) = error_mark_node;
12975           error_found = 1;
12976         }
12977       /* Unary numeric promotion is performed on operand */
12978       else
12979         {
12980           op = do_unary_numeric_promotion (op);
12981           prom_type = TREE_TYPE (op);
12982           if (code == UNARY_PLUS_EXPR)
12983             return fold (op);
12984         }
12985       break;
12986
12987       /* 15.14.5 Bitwise Complement Operator ~ */
12988     case BIT_NOT_EXPR:
12989       if (!JINTEGRAL_TYPE_P (op_type))
12990         {
12991           ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
12992           TREE_TYPE (node) = error_mark_node;
12993           error_found = 1;
12994         }
12995       else
12996         {
12997           op = do_unary_numeric_promotion (op);
12998           prom_type = TREE_TYPE (op);
12999         }
13000       break;
13001
13002       /* 15.14.6 Logical Complement Operator ! */
13003     case TRUTH_NOT_EXPR:
13004       if (TREE_CODE (op_type) != BOOLEAN_TYPE)
13005         {
13006           ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
13007           /* But the type is known. We will report an error if further
13008              attempt of a assignment is made with this rhs */
13009           TREE_TYPE (node) = boolean_type_node;
13010           error_found = 1;
13011         }
13012       else
13013         prom_type = boolean_type_node;
13014       break;
13015
13016       /* 15.15 Cast Expression */
13017     case CONVERT_EXPR:
13018       value = patch_cast (node, wfl_operator);
13019       if (value == error_mark_node)
13020         {
13021           /* If this cast is part of an assignment, we tell the code
13022              that deals with it not to complain about a mismatch,
13023              because things have been cast, anyways */
13024           TREE_TYPE (node) = error_mark_node;
13025           error_found = 1;
13026         }
13027       else
13028         {
13029           value = fold (value);
13030           TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
13031           return value;
13032         }
13033       break;
13034     }
13035   
13036   if (error_found)
13037     return error_mark_node;
13038
13039   /* There are cases where node has been replaced by something else
13040      and we don't end up returning here: UNARY_PLUS_EXPR,
13041      CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
13042   TREE_OPERAND (node, 0) = fold (op);
13043   TREE_TYPE (node) = prom_type;
13044   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
13045   return fold (node);
13046 }
13047
13048 /* Generic type resolution that sometimes takes place during node
13049    patching. Returned the resolved type or generate an error
13050    message. Return the resolved type or NULL_TREE.  */
13051
13052 static tree
13053 resolve_type_during_patch (type)
13054      tree type;
13055 {
13056   if (unresolved_type_p (type, NULL))
13057     {
13058       tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
13059       if (!type_decl)
13060         {
13061           parse_error_context (type, 
13062                                "Class `%s' not found in type declaration",
13063                                IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
13064           return NULL_TREE;
13065         }
13066       else
13067         {
13068           CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
13069           return TREE_TYPE (type_decl);
13070         }
13071     }
13072   return type;
13073 }
13074 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
13075    found. Otherwise NODE or something meant to replace it is returned.  */
13076
13077 static tree
13078 patch_cast (node, wfl_operator)
13079      tree node;
13080      tree wfl_operator;
13081 {
13082   tree op = TREE_OPERAND (node, 0);
13083   tree op_type = TREE_TYPE (op);
13084   tree cast_type = TREE_TYPE (node);
13085   char *t1;
13086
13087   /* First resolve OP_TYPE if unresolved */
13088   if (!(cast_type = resolve_type_during_patch (cast_type)))
13089     return error_mark_node;
13090
13091   /* Check on cast that are proven correct at compile time */
13092   if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
13093     {
13094       /* Same type */
13095       if (cast_type == op_type)
13096         return node;
13097
13098       /* float and double type are converted to the original type main
13099          variant and then to the target type. */
13100       if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
13101         op = convert (integer_type_node, op);
13102
13103       /* Try widening/narowwing convertion. Potentially, things need
13104          to be worked out in gcc so we implement the extreme cases
13105          correctly. fold_convert() needs to be fixed. */
13106       return convert (cast_type, op);
13107     }
13108
13109   /* It's also valid to cast a boolean into a boolean */
13110   if (op_type == boolean_type_node && cast_type == boolean_type_node)
13111     return node;
13112
13113   /* null can be casted to references */
13114   if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
13115     return build_null_of_type (cast_type);
13116
13117   /* The remaining legal casts involve conversion between reference
13118      types. Check for their compile time correctness. */
13119   if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type) 
13120       && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
13121     {
13122       TREE_TYPE (node) = promote_type (cast_type);
13123       /* Now, the case can be determined correct at compile time if
13124          OP_TYPE can be converted into CAST_TYPE by assignment
13125          conversion (5.2) */
13126
13127       if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
13128         {
13129           TREE_SET_CODE (node, NOP_EXPR);
13130           return node;
13131         }
13132
13133       if (flag_emit_class_files)
13134         {
13135           TREE_SET_CODE (node, CONVERT_EXPR);
13136           return node;
13137         }
13138
13139       /* The cast requires a run-time check */
13140       return build (CALL_EXPR, promote_type (cast_type),
13141                     build_address_of (soft_checkcast_node),
13142                     tree_cons (NULL_TREE, build_class_ref (cast_type),
13143                                build_tree_list (NULL_TREE, op)),
13144                     NULL_TREE);
13145     }
13146
13147   /* Any other casts are proven incorrect at compile time */
13148   t1 = xstrdup (lang_printable_name (op_type, 0));
13149   parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
13150                        t1, lang_printable_name (cast_type, 0));
13151   free (t1);
13152   return error_mark_node;
13153 }
13154
13155 /* Build a null constant and give it the type TYPE.  */
13156
13157 static tree
13158 build_null_of_type (type)
13159      tree type;
13160 {
13161   tree node = build_int_2 (0, 0);
13162   TREE_TYPE (node) = promote_type (type);
13163   return node;
13164 }
13165
13166 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
13167    a list of indices. */
13168 static tree
13169 build_array_ref (location, array, index)
13170      int location;
13171      tree array, index;
13172 {
13173   tree node = build (ARRAY_REF, NULL_TREE, array, index);
13174   EXPR_WFL_LINECOL (node) = location;
13175   return node;
13176 }
13177
13178 /* 15.12 Array Access Expression */
13179
13180 static tree
13181 patch_array_ref (node)
13182      tree node;
13183 {
13184   tree array = TREE_OPERAND (node, 0);
13185   tree array_type  = TREE_TYPE (array);
13186   tree index = TREE_OPERAND (node, 1);
13187   tree index_type = TREE_TYPE (index);
13188   int error_found = 0;
13189
13190   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13191
13192   if (TREE_CODE (array_type) == POINTER_TYPE)
13193     array_type = TREE_TYPE (array_type);
13194
13195   /* The array reference must be an array */
13196   if (!TYPE_ARRAY_P (array_type))
13197     {
13198       parse_error_context 
13199         (wfl_operator, "`[]' can only be applied to arrays. It can't be "
13200          "applied to `%s'", lang_printable_name (array_type, 0));
13201       TREE_TYPE (node) = error_mark_node;
13202       error_found = 1;
13203     }
13204
13205   /* The array index underdoes unary numeric promotion. The promoted
13206      type must be int */
13207   index = do_unary_numeric_promotion (index);
13208   if (TREE_TYPE (index) != int_type_node)
13209     {
13210       if (valid_cast_to_p (index_type, int_type_node))
13211         parse_error_context (wfl_operator, "Incompatible type for `[]'. "
13212                              "Explicit cast needed to convert `%s' to `int'",
13213                              lang_printable_name (index_type, 0));
13214       else
13215         parse_error_context (wfl_operator, "Incompatible type for `[]'. "
13216                              "Can't convert `%s' to `int'",
13217                              lang_printable_name (index_type, 0));
13218       TREE_TYPE (node) = error_mark_node;
13219       error_found = 1;
13220     }
13221
13222   if (error_found)
13223     return error_mark_node;
13224
13225   array_type = TYPE_ARRAY_ELEMENT (array_type);
13226
13227   if (flag_emit_class_files || flag_emit_xref)
13228     {
13229       TREE_OPERAND (node, 0) = array;
13230       TREE_OPERAND (node, 1) = index;
13231     }
13232   else
13233     {
13234       /* The save_expr is for correct evaluation order.  It would be cleaner
13235          to use force_evaluation_order (see comment there), but that is
13236          difficult when we also have to deal with bounds checking. */
13237       if (TREE_SIDE_EFFECTS (index))
13238         array = save_expr (array);
13239       node = build_java_arrayaccess (array, array_type, index);
13240       if (TREE_SIDE_EFFECTS (index))
13241         node = build (COMPOUND_EXPR, array_type, array, node);
13242     }
13243   TREE_TYPE (node) = array_type;
13244   return node;
13245 }
13246
13247 /* 15.9 Array Creation Expressions */
13248
13249 static tree
13250 build_newarray_node (type, dims, extra_dims)
13251      tree type;
13252      tree dims;
13253      int extra_dims;
13254 {
13255   tree node =
13256     build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims), 
13257            build_int_2 (extra_dims, 0));
13258   return node;
13259 }
13260
13261 static tree
13262 patch_newarray (node)
13263      tree node;
13264 {
13265   tree type = TREE_OPERAND (node, 0);
13266   tree dims = TREE_OPERAND (node, 1);
13267   tree cdim, array_type;
13268   int error_found = 0;
13269   int ndims = 0;
13270   int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
13271
13272   /* Dimension types are verified. It's better for the types to be
13273      verified in order. */
13274   for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
13275     {
13276       int dim_error = 0;
13277       tree dim = TREE_VALUE (cdim);
13278
13279       /* Dim might have been saved during its evaluation */
13280       dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
13281
13282       /* The type of each specified dimension must be an integral type. */
13283       if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
13284         dim_error = 1;
13285
13286       /* Each expression undergoes an unary numeric promotion (5.6.1) and the
13287          promoted type must be int. */
13288       else
13289         {
13290           dim = do_unary_numeric_promotion (dim);
13291           if (TREE_TYPE (dim) != int_type_node)
13292             dim_error = 1;
13293         }
13294
13295       /* Report errors on types here */
13296       if (dim_error)
13297         {
13298           parse_error_context 
13299             (TREE_PURPOSE (cdim), 
13300              "Incompatible type for dimension in array creation expression. "
13301              "%s convert `%s' to `int'", 
13302              (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
13303               "Explicit cast needed to" : "Can't"),
13304              lang_printable_name (TREE_TYPE (dim), 0));
13305           error_found = 1;
13306         }
13307
13308       TREE_PURPOSE (cdim) = NULL_TREE;
13309     }
13310
13311   /* Resolve array base type if unresolved */
13312   if (!(type = resolve_type_during_patch (type)))
13313     error_found = 1;
13314
13315   if (error_found)
13316     {
13317       /* We don't want further evaluation of this bogus array creation
13318          operation */
13319       TREE_TYPE (node) = error_mark_node;
13320       return error_mark_node;
13321     }
13322
13323   /* Set array_type to the actual (promoted) array type of the result. */
13324   if (TREE_CODE (type) == RECORD_TYPE)
13325     type = build_pointer_type (type);
13326   while (--xdims >= 0)
13327     {
13328       type = promote_type (build_java_array_type (type, -1));
13329     }
13330   dims = nreverse (dims);
13331   array_type = type;
13332   for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
13333     {
13334       type = array_type;
13335       array_type = build_java_array_type (type,
13336                                           TREE_CODE (cdim) == INTEGER_CST ?
13337                                           TREE_INT_CST_LOW (cdim) : -1);
13338       array_type = promote_type (array_type);
13339     }
13340   dims = nreverse (dims);
13341
13342   /* The node is transformed into a function call. Things are done
13343      differently according to the number of dimensions. If the number
13344      of dimension is equal to 1, then the nature of the base type
13345      (primitive or not) matters. */
13346   if (ndims == 1)
13347     return build_new_array (type, TREE_VALUE (dims));
13348   
13349   /* Can't reuse what's already written in expr.c because it uses the
13350      JVM stack representation. Provide a build_multianewarray. FIXME */
13351   return build (CALL_EXPR, array_type,
13352                 build_address_of (soft_multianewarray_node),
13353                 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
13354                            tree_cons (NULL_TREE, 
13355                                       build_int_2 (ndims, 0), dims )),
13356                 NULL_TREE);
13357 }
13358
13359 /* 10.6 Array initializer.  */
13360
13361 /* Build a wfl for array element that don't have one, so we can
13362    pin-point errors.  */
13363
13364 static tree
13365 maybe_build_array_element_wfl (node)
13366      tree node;
13367 {
13368   if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
13369     return build_expr_wfl (NULL_TREE, ctxp->filename,
13370                            ctxp->elc.line, ctxp->elc.prev_col);
13371   else
13372     return NULL_TREE;
13373 }
13374
13375 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
13376    identification of initialized arrays easier to detect during walk
13377    and expansion.  */
13378
13379 static tree
13380 build_new_array_init (location, values)
13381      int location;
13382      tree values;
13383 {
13384   tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
13385   tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
13386   EXPR_WFL_LINECOL (to_return) = location;
13387   return to_return;
13388 }
13389
13390 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
13391    occurred.  Otherwise return NODE after having set its type
13392    appropriately.  */
13393
13394 static tree
13395 patch_new_array_init (type, node)
13396      tree type, node;
13397 {
13398   int error_seen = 0;
13399   tree current, element_type;
13400   HOST_WIDE_INT length;
13401   int all_constant = 1;
13402   tree init = TREE_OPERAND (node, 0);
13403
13404   if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
13405     {
13406       parse_error_context (node,
13407                            "Invalid array initializer for non-array type `%s'",
13408                            lang_printable_name (type, 1));
13409       return error_mark_node;
13410     }
13411   type = TREE_TYPE (type);
13412   element_type = TYPE_ARRAY_ELEMENT (type);
13413
13414   CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
13415
13416   for (length = 0, current = CONSTRUCTOR_ELTS (init);
13417        current;  length++, current = TREE_CHAIN (current))
13418     {
13419       tree elt = TREE_VALUE (current);
13420       if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
13421         {
13422           error_seen |= array_constructor_check_entry (element_type, current);
13423           elt = TREE_VALUE (current);
13424           /* When compiling to native code, STRING_CST is converted to
13425              INDIRECT_REF, but still with a TREE_CONSTANT flag. */
13426           if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
13427             all_constant = 0;
13428         }
13429       else
13430         {
13431           TREE_VALUE (current) = patch_new_array_init (element_type, elt);
13432           TREE_PURPOSE (current) = NULL_TREE;
13433           all_constant = 0;
13434         }
13435       if (elt && TREE_VALUE (elt) == error_mark_node)
13436         error_seen = 1;
13437     }
13438
13439   if (error_seen)
13440     return error_mark_node;
13441
13442   /* Create a new type. We can't reuse the one we have here by
13443      patching its dimension because it originally is of dimension -1
13444      hence reused by gcc. This would prevent triangular arrays. */
13445   type = build_java_array_type (element_type, length);
13446   TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
13447   TREE_TYPE (node) = promote_type (type);
13448   TREE_CONSTANT (init) = all_constant;
13449   TREE_CONSTANT (node) = all_constant;
13450   return node;
13451 }
13452
13453 /* Verify that one entry of the initializer element list can be
13454    assigned to the array base type. Report 1 if an error occurred, 0
13455    otherwise.  */
13456
13457 static int
13458 array_constructor_check_entry (type, entry)
13459      tree type, entry;
13460 {
13461   char *array_type_string = NULL;       /* For error reports */
13462   tree value, type_value, new_value, wfl_value, patched;
13463   int error_seen = 0;
13464
13465   new_value = NULL_TREE;
13466   wfl_value = TREE_VALUE (entry);
13467
13468   push_obstacks (&permanent_obstack, &permanent_obstack);
13469   value = java_complete_tree (TREE_VALUE (entry));
13470   /* patch_string return error_mark_node if arg is error_mark_node */
13471   if ((patched = patch_string (value)))
13472     value = patched;
13473   if (value == error_mark_node)
13474     return 1;
13475   
13476   type_value = TREE_TYPE (value);
13477   
13478   /* At anytime, try_builtin_assignconv can report a warning on
13479      constant overflow during narrowing. */
13480   SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
13481   new_value = try_builtin_assignconv (wfl_operator, type, value);
13482   if (!new_value && (new_value = try_reference_assignconv (type, value)))
13483     type_value = promote_type (type);
13484
13485   pop_obstacks ();
13486   /* Check and report errors */
13487   if (!new_value)
13488     {
13489       const char *msg = (!valid_cast_to_p (type_value, type) ?
13490                    "Can't" : "Explicit cast needed to");
13491       if (!array_type_string)
13492         array_type_string = xstrdup (lang_printable_name (type, 1));
13493       parse_error_context 
13494         (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
13495          msg, lang_printable_name (type_value, 1), array_type_string);
13496       error_seen = 1;
13497     }
13498   
13499   if (new_value)
13500     {
13501       new_value = maybe_build_primttype_type_ref (new_value, wfl_operator);
13502       TREE_VALUE (entry) = new_value;
13503     }
13504
13505   if (array_type_string)
13506     free (array_type_string);
13507
13508   TREE_PURPOSE (entry) = NULL_TREE;
13509   return error_seen;
13510 }
13511
13512 static tree
13513 build_this (location)
13514      int location;
13515 {
13516   tree node = build_wfl_node (this_identifier_node);
13517   TREE_SET_CODE (node, THIS_EXPR);
13518   EXPR_WFL_LINECOL (node) = location;
13519   return node;
13520 }
13521
13522 /* 14.15 The return statement. It builds a modify expression that
13523    assigns the returned value to the RESULT_DECL that hold the value
13524    to be returned. */
13525
13526 static tree
13527 build_return (location, op)
13528      int location;
13529      tree op;
13530 {
13531   tree node = build1 (RETURN_EXPR, NULL_TREE, op);
13532   EXPR_WFL_LINECOL (node) = location;
13533   node = build_debugable_stmt (location, node);
13534   return node;
13535 }
13536
13537 static tree
13538 patch_return (node)
13539      tree node;
13540 {
13541   tree return_exp = TREE_OPERAND (node, 0);
13542   tree meth = current_function_decl;
13543   tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
13544   int error_found = 0;
13545
13546   TREE_TYPE (node) = error_mark_node;
13547   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13548
13549   /* It's invalid to have a return value within a function that is
13550      declared with the keyword void or that is a constructor */
13551   if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
13552     error_found = 1;
13553
13554   /* It's invalid to use a return statement in a static block */
13555   if (IS_CLINIT (current_function_decl))
13556     error_found = 1;
13557
13558   /* It's invalid to have a no return value within a function that
13559      isn't declared with the keyword `void' */
13560   if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
13561     error_found = 2;
13562
13563   if (error_found)
13564     {
13565       if (IS_CLINIT (current_function_decl))
13566         parse_error_context (wfl_operator,
13567                              "`return' inside static initializer.");
13568
13569       else if (!DECL_CONSTRUCTOR_P (meth))
13570         {
13571           char *t = xstrdup (lang_printable_name (mtype, 0));
13572           parse_error_context (wfl_operator, 
13573                                "`return' with%s value from `%s %s'",
13574                                (error_found == 1 ? "" : "out"), 
13575                                t, lang_printable_name (meth, 0));
13576           free (t);
13577         }
13578       else
13579         parse_error_context (wfl_operator, 
13580                              "`return' with value from constructor `%s'",
13581                              lang_printable_name (meth, 0));
13582       return error_mark_node;
13583     }
13584
13585   /* If we have a return_exp, build a modify expression and expand
13586      it. Note: at that point, the assignment is declared valid, but we
13587      may want to carry some more hacks */
13588   if (return_exp)
13589     {
13590       tree exp = java_complete_tree (return_exp);
13591       tree modify, patched;
13592
13593       /* If the function returned value and EXP are booleans, EXP has
13594       to be converted into the type of DECL_RESULT, which is integer
13595       (see complete_start_java_method) */
13596       if (TREE_TYPE (exp) == boolean_type_node &&
13597           TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
13598         exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
13599
13600       /* `null' can be assigned to a function returning a reference */
13601       if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
13602           exp == null_pointer_node)
13603         exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
13604
13605       if ((patched = patch_string (exp)))
13606         exp = patched;
13607       
13608       modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
13609       EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
13610       modify = java_complete_tree (modify);
13611
13612       if (modify != error_mark_node)
13613         {
13614           TREE_SIDE_EFFECTS (modify) = 1;
13615           TREE_OPERAND (node, 0) = modify;
13616         }
13617       else
13618         return error_mark_node;
13619     }
13620   TREE_TYPE (node) = void_type_node;
13621   TREE_SIDE_EFFECTS (node) = 1;
13622   return node;
13623 }
13624
13625 /* 14.8 The if Statement */
13626
13627 static tree
13628 build_if_else_statement (location, expression, if_body, else_body)
13629      int location;
13630      tree expression, if_body, else_body;
13631 {
13632   tree node;
13633   if (!else_body)
13634     else_body = empty_stmt_node;
13635   node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
13636   EXPR_WFL_LINECOL (node) = location;
13637   node = build_debugable_stmt (location, node);
13638   return node;
13639 }
13640
13641 static tree
13642 patch_if_else_statement (node)
13643      tree node;
13644 {
13645   tree expression = TREE_OPERAND (node, 0);
13646
13647   TREE_TYPE (node) = error_mark_node;
13648   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13649
13650   /* The type of expression must be boolean */
13651   if (TREE_TYPE (expression) != boolean_type_node
13652       && TREE_TYPE (expression) != promoted_boolean_type_node)
13653     {
13654       parse_error_context 
13655         (wfl_operator, 
13656          "Incompatible type for `if'. Can't convert `%s' to `boolean'", 
13657          lang_printable_name (TREE_TYPE (expression), 0));
13658       return error_mark_node;
13659     }
13660   
13661   TREE_TYPE (node) = void_type_node;
13662   TREE_SIDE_EFFECTS (node) = 1;
13663   CAN_COMPLETE_NORMALLY (node)
13664     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
13665     | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
13666   return node;
13667 }
13668
13669 /* 14.6 Labeled Statements */
13670
13671 /* Action taken when a lableled statement is parsed. a new
13672    LABELED_BLOCK_EXPR is created. No statement is attached to the
13673    label, yet.  LABEL can be NULL_TREE for artificially-generated blocks. */
13674
13675 static tree
13676 build_labeled_block (location, label)
13677      int location;
13678      tree label;
13679 {
13680   tree label_name ;
13681   tree label_decl, node;
13682   if (label == NULL_TREE || label == continue_identifier_node)
13683     label_name = label;
13684   else
13685     {
13686       label_name = merge_qualified_name (label_id, label);
13687       /* Issue an error if we try to reuse a label that was previously
13688          declared */
13689       if (IDENTIFIER_LOCAL_VALUE (label_name))
13690         {
13691           EXPR_WFL_LINECOL (wfl_operator) = location;
13692           parse_error_context (wfl_operator, "Declaration of `%s' shadows "
13693                                "a previous label declaration",
13694                                IDENTIFIER_POINTER (label));
13695           EXPR_WFL_LINECOL (wfl_operator) = 
13696             EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
13697           parse_error_context (wfl_operator, "This is the location of the "
13698                                "previous declaration of label `%s'",
13699                                IDENTIFIER_POINTER (label));
13700           java_error_count--;
13701         }
13702     }
13703
13704   label_decl = create_label_decl (label_name);
13705   node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
13706   EXPR_WFL_LINECOL (node) = location;
13707   TREE_SIDE_EFFECTS (node) = 1;
13708   return node;
13709 }
13710
13711 /* A labeled statement LBE is attached a statement.  */
13712
13713 static tree
13714 finish_labeled_statement (lbe, statement)
13715      tree lbe;                  /* Labeled block expr */
13716      tree statement;
13717 {
13718   /* In anyways, tie the loop to its statement */
13719   LABELED_BLOCK_BODY (lbe) = statement;
13720   pop_labeled_block ();
13721   POP_LABELED_BLOCK ();
13722   return lbe;
13723 }
13724
13725 /* 14.10, 14.11, 14.12 Loop Statements */
13726
13727 /* Create an empty LOOP_EXPR and make it the last in the nested loop
13728    list. */
13729
13730 static tree
13731 build_new_loop (loop_body)
13732      tree loop_body;
13733 {
13734   tree loop =  build (LOOP_EXPR, NULL_TREE, loop_body);
13735   TREE_SIDE_EFFECTS (loop) = 1;
13736   PUSH_LOOP (loop);
13737   return loop;
13738 }
13739
13740 /* Create a loop body according to the following structure:
13741      COMPOUND_EXPR
13742        COMPOUND_EXPR            (loop main body)
13743          EXIT_EXPR              (this order is for while/for loops.
13744          LABELED_BLOCK_EXPR      the order is reversed for do loops)
13745            LABEL_DECL           (a continue occuring here branches at the 
13746            BODY                  end of this labeled block)
13747        INCREMENT                (if any)
13748
13749   REVERSED, if non zero, tells that the loop condition expr comes
13750   after the body, like in the do-while loop.
13751
13752   To obtain a loop, the loop body structure described above is
13753   encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
13754
13755    LABELED_BLOCK_EXPR
13756      LABEL_DECL                   (use this label to exit the loop)
13757      LOOP_EXPR
13758        <structure described above> */
13759
13760 static tree
13761 build_loop_body (location, condition, reversed)
13762      int location;
13763      tree condition;
13764      int reversed;
13765 {
13766   tree first, second, body;
13767
13768   condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
13769   EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
13770   condition = build_debugable_stmt (location, condition);
13771   TREE_SIDE_EFFECTS (condition) = 1;
13772
13773   body = build_labeled_block (0, continue_identifier_node);
13774   first = (reversed ? body : condition);
13775   second = (reversed ? condition : body);
13776   return 
13777     build (COMPOUND_EXPR, NULL_TREE, 
13778            build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
13779 }
13780
13781 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
13782    their order) on the current loop. Unlink the current loop from the
13783    loop list.  */
13784
13785 static tree
13786 finish_loop_body (location, condition, body, reversed)
13787      int location;
13788      tree condition, body;
13789      int reversed;
13790 {
13791   tree to_return = ctxp->current_loop;
13792   tree loop_body = LOOP_EXPR_BODY (to_return);
13793   if (condition)
13794     {
13795       tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
13796       /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
13797          The real EXIT_EXPR is one operand further. */
13798       EXPR_WFL_LINECOL (cnode) = location;
13799       /* This one is for accurate error reports */
13800       EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
13801       TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
13802     }
13803   LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
13804   POP_LOOP ();
13805   return to_return;
13806 }
13807
13808 /* Tailored version of finish_loop_body for FOR loops, when FOR
13809    loops feature the condition part */
13810
13811 static tree
13812 finish_for_loop (location, condition, update, body)
13813     int location;
13814     tree condition, update, body;
13815 {
13816   /* Put the condition and the loop body in place */
13817   tree loop = finish_loop_body (location, condition, body, 0);
13818   /* LOOP is the current loop which has been now popped of the loop
13819      stack. Install the update block */
13820   LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
13821   return loop;
13822 }
13823
13824 /* Try to find the loop a block might be related to. This comprises
13825    the case where the LOOP_EXPR is found as the second operand of a
13826    COMPOUND_EXPR, because the loop happens to have an initialization
13827    part, then expressed as the first operand of the COMPOUND_EXPR. If
13828    the search finds something, 1 is returned. Otherwise, 0 is
13829    returned. The search is assumed to start from a
13830    LABELED_BLOCK_EXPR's block.  */
13831
13832 static tree
13833 search_loop (statement)
13834     tree statement;
13835 {
13836   if (TREE_CODE (statement) == LOOP_EXPR)
13837     return statement;
13838
13839   if (TREE_CODE (statement) == BLOCK)
13840     statement = BLOCK_SUBBLOCKS (statement);
13841   else
13842     return NULL_TREE;
13843
13844   if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
13845     while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
13846       statement = TREE_OPERAND (statement, 1);
13847
13848   return (TREE_CODE (statement) == LOOP_EXPR
13849           && IS_FOR_LOOP_P (statement) ? statement : NULL_TREE);
13850 }
13851
13852 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
13853    returned otherwise.  */
13854
13855 static int
13856 labeled_block_contains_loop_p (block, loop)
13857     tree block, loop;
13858 {
13859   if (!block)
13860     return 0;
13861
13862   if (LABELED_BLOCK_BODY (block) == loop)
13863     return 1;
13864
13865   if (IS_FOR_LOOP_P (loop) 
13866       && search_loop (LABELED_BLOCK_BODY (block)) == loop)
13867     return 1;
13868
13869   return 0;
13870 }
13871
13872 /* If the loop isn't surrounded by a labeled statement, create one and
13873    insert LOOP as its body.  */
13874
13875 static tree
13876 patch_loop_statement (loop)
13877      tree loop;
13878 {
13879   tree loop_label;
13880
13881   TREE_TYPE (loop) = void_type_node;
13882   if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
13883     return loop;
13884
13885   loop_label = build_labeled_block (0, NULL_TREE);
13886   /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
13887      that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
13888   LABELED_BLOCK_BODY (loop_label) = loop;
13889   PUSH_LABELED_BLOCK (loop_label);
13890   return loop_label;
13891 }
13892
13893 /* 14.13, 14.14: break and continue Statements */
13894
13895 /* Build a break or a continue statement. a null NAME indicates an
13896    unlabeled break/continue statement.  */
13897
13898 static tree
13899 build_bc_statement (location, is_break, name)
13900      int location, is_break;
13901      tree name;
13902 {
13903   tree break_continue, label_block_expr = NULL_TREE;
13904
13905   if (name)
13906     {
13907       if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE 
13908             (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
13909         /* Null means that we don't have a target for this named
13910            break/continue. In this case, we make the target to be the
13911            label name, so that the error can be reported accuratly in
13912            patch_bc_statement. */
13913         label_block_expr = EXPR_WFL_NODE (name);
13914     }
13915   /* Unlabeled break/continue will be handled during the
13916      break/continue patch operation */
13917   break_continue 
13918     = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
13919
13920   IS_BREAK_STMT_P (break_continue) = is_break;
13921   TREE_SIDE_EFFECTS (break_continue) = 1;
13922   EXPR_WFL_LINECOL (break_continue) = location;
13923   break_continue = build_debugable_stmt (location, break_continue);
13924   return break_continue;
13925 }
13926
13927 /* Verification of a break/continue statement. */
13928
13929 static tree
13930 patch_bc_statement (node)
13931      tree node;
13932 {
13933   tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
13934   tree labeled_block = ctxp->current_labeled_block;
13935   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13936  
13937   /* Having an identifier here means that the target is unknown. */
13938   if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
13939     {
13940       parse_error_context (wfl_operator, "No label definition found for `%s'",
13941                            IDENTIFIER_POINTER (bc_label));
13942       return error_mark_node;
13943     }
13944   if (! IS_BREAK_STMT_P (node))
13945     {
13946       /* It's a continue statement. */
13947       for (;; labeled_block = TREE_CHAIN (labeled_block))
13948         {
13949           if (labeled_block == NULL_TREE)
13950             {
13951               if (bc_label == NULL_TREE)
13952                 parse_error_context (wfl_operator,
13953                                      "`continue' must be in loop");
13954               else
13955                 parse_error_context 
13956                   (wfl_operator, "continue label `%s' does not name a loop",
13957                    IDENTIFIER_POINTER (bc_label));
13958               return error_mark_node;
13959             }
13960           if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
13961                == continue_identifier_node)
13962               && (bc_label == NULL_TREE
13963                   || TREE_CHAIN (labeled_block) == bc_label))
13964             {
13965               bc_label = labeled_block;
13966               break;
13967             }
13968         }
13969     }
13970   else if (!bc_label)
13971     { 
13972       for (;; labeled_block = TREE_CHAIN (labeled_block))
13973         {
13974           if (labeled_block == NULL_TREE)
13975             {
13976               parse_error_context (wfl_operator,
13977                                      "`break' must be in loop or switch");
13978               return error_mark_node;
13979             }
13980           target_stmt = LABELED_BLOCK_BODY (labeled_block);
13981           if (TREE_CODE (target_stmt) == SWITCH_EXPR
13982               || search_loop (target_stmt))
13983             {
13984               bc_label = labeled_block;
13985               break;
13986             }
13987         }
13988     }
13989
13990   EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
13991   CAN_COMPLETE_NORMALLY (bc_label) = 1;
13992
13993   /* Our break/continue don't return values. */
13994   TREE_TYPE (node) = void_type_node;
13995   /* Encapsulate the break within a compound statement so that it's
13996      expanded all the times by expand_expr (and not clobbered
13997      sometimes, like after a if statement) */
13998   node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
13999   TREE_SIDE_EFFECTS (node) = 1;
14000   return node;
14001 }
14002
14003 /* Process the exit expression belonging to a loop. Its type must be
14004    boolean.  */
14005
14006 static tree
14007 patch_exit_expr (node)
14008      tree node;
14009 {
14010   tree expression = TREE_OPERAND (node, 0);
14011   TREE_TYPE (node) = error_mark_node;
14012   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14013
14014   /* The type of expression must be boolean */
14015   if (TREE_TYPE (expression) != boolean_type_node)
14016     {
14017       parse_error_context 
14018         (wfl_operator, 
14019          "Incompatible type for loop conditional. Can't convert `%s' to "
14020          "`boolean'", 
14021          lang_printable_name (TREE_TYPE (expression), 0));
14022       return error_mark_node;
14023     }
14024   /* Now we know things are allright, invert the condition, fold and
14025      return */
14026   TREE_OPERAND (node, 0) = 
14027     fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
14028
14029   if (! integer_zerop (TREE_OPERAND (node, 0))
14030       && ctxp->current_loop != NULL_TREE
14031       && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
14032     CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
14033   if (! integer_onep (TREE_OPERAND (node, 0)))
14034     CAN_COMPLETE_NORMALLY (node) = 1;
14035
14036
14037   TREE_TYPE (node) = void_type_node;
14038   return node;
14039 }
14040
14041 /* 14.9 Switch statement */
14042
14043 static tree
14044 patch_switch_statement (node)
14045      tree node;
14046 {
14047   tree se = TREE_OPERAND (node, 0), se_type;
14048
14049   /* Complete the switch expression */
14050   se = TREE_OPERAND (node, 0) = java_complete_tree (se);
14051   se_type = TREE_TYPE (se);
14052   /* The type of the switch expression must be char, byte, short or
14053      int */
14054   if (!JINTEGRAL_TYPE_P (se_type))
14055     {
14056       EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14057       parse_error_context (wfl_operator, "Incompatible type for `switch'. "
14058                            "Can't convert `%s' to `int'",
14059                            lang_printable_name (se_type, 0));
14060       /* This is what java_complete_tree will check */
14061       TREE_OPERAND (node, 0) = error_mark_node;
14062       return error_mark_node;
14063     }
14064
14065   TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
14066
14067   /* Ready to return */
14068   if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
14069     {
14070       TREE_TYPE (node) = error_mark_node;
14071       return error_mark_node;
14072     }
14073   TREE_TYPE (node) = void_type_node;
14074   TREE_SIDE_EFFECTS (node) = 1;
14075   CAN_COMPLETE_NORMALLY (node)
14076     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)) 
14077       || ! SWITCH_HAS_DEFAULT (node);
14078   return node;
14079 }
14080
14081 /* 14.18 The try statement */
14082
14083 static tree
14084 build_try_statement (location, try_block, catches)
14085      int location;
14086      tree try_block, catches;
14087 {
14088   tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
14089   EXPR_WFL_LINECOL (node) = location;
14090   return node;
14091 }
14092
14093 static tree
14094 build_try_finally_statement (location, try_block, finally)
14095      int location;
14096      tree try_block, finally;
14097 {
14098   tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
14099   EXPR_WFL_LINECOL (node) = location;
14100   return node;
14101 }
14102
14103 static tree
14104 patch_try_statement (node)
14105      tree node;
14106 {
14107   int error_found = 0;
14108   tree try = TREE_OPERAND (node, 0);
14109   /* Exception handlers are considered in left to right order */
14110   tree catch = nreverse (TREE_OPERAND (node, 1));
14111   tree current, caught_type_list = NULL_TREE;
14112
14113   /* Check catch clauses, if any. Every time we find an error, we try
14114      to process the next catch clause. We process the catch clause before
14115      the try block so that when processing the try block we can check thrown
14116      exceptions againts the caught type list. */
14117   for (current = catch; current; current = TREE_CHAIN (current))
14118     {
14119       tree carg_decl, carg_type;
14120       tree sub_current, catch_block, catch_clause;
14121       int unreachable;
14122
14123       /* At this point, the structure of the catch clause is
14124            CATCH_EXPR           (catch node)
14125              BLOCK              (with the decl of the parameter)
14126                COMPOUND_EXPR
14127                  MODIFY_EXPR   (assignment of the catch parameter)
14128                  BLOCK          (catch clause block)
14129        */
14130       catch_clause = TREE_OPERAND (current, 0);
14131       carg_decl = BLOCK_EXPR_DECLS (catch_clause);
14132       carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
14133
14134       /* Catch clauses can't have more than one parameter declared,
14135          but it's already enforced by the grammar. Make sure that the
14136          only parameter of the clause statement in of class Throwable
14137          or a subclass of Throwable, but that was done earlier. The
14138          catch clause parameter type has also been resolved. */
14139       
14140       /* Just make sure that the catch clause parameter type inherits
14141          from java.lang.Throwable */
14142       if (!inherits_from_p (carg_type, throwable_type_node))
14143         {
14144           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
14145           parse_error_context (wfl_operator,
14146                                "Can't catch class `%s'. Catch clause "
14147                                "parameter type must be a subclass of "
14148                                "class `java.lang.Throwable'",
14149                                lang_printable_name (carg_type, 0));
14150           error_found = 1;
14151           continue;
14152         }
14153       
14154       /* Partial check for unreachable catch statement: The catch
14155          clause is reachable iff is no earlier catch block A in
14156          the try statement such that the type of the catch
14157          clause's parameter is the same as or a subclass of the
14158          type of A's parameter */
14159       unreachable = 0;
14160       for (sub_current = catch;
14161            sub_current != current; sub_current = TREE_CHAIN (sub_current))
14162         {
14163           tree sub_catch_clause, decl;
14164           sub_catch_clause = TREE_OPERAND (sub_current, 0);
14165           decl = BLOCK_EXPR_DECLS (sub_catch_clause);
14166
14167           if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
14168             {
14169               EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
14170               parse_error_context 
14171                 (wfl_operator, "`catch' not reached because of the catch "
14172                  "clause at line %d", EXPR_WFL_LINENO (sub_current));
14173               unreachable = error_found = 1;
14174               break;
14175             }
14176         }
14177       /* Complete the catch clause block */
14178       catch_block = java_complete_tree (TREE_OPERAND (current, 0));
14179       if (catch_block == error_mark_node)
14180         {
14181           error_found = 1;
14182           continue;
14183         }
14184       if (CAN_COMPLETE_NORMALLY (catch_block))
14185         CAN_COMPLETE_NORMALLY (node) = 1;
14186       TREE_OPERAND (current, 0) = catch_block;
14187
14188       if (unreachable)
14189         continue;
14190
14191       /* Things to do here: the exception must be thrown */
14192
14193       /* Link this type to the caught type list */
14194       caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
14195     }
14196
14197   PUSH_EXCEPTIONS (caught_type_list);
14198   if ((try = java_complete_tree (try)) == error_mark_node)
14199     error_found = 1;
14200   if (CAN_COMPLETE_NORMALLY (try))
14201     CAN_COMPLETE_NORMALLY (node) = 1;
14202   POP_EXCEPTIONS ();
14203
14204   /* Verification ends here */
14205   if (error_found) 
14206     return error_mark_node;
14207
14208   TREE_OPERAND (node, 0) = try;
14209   TREE_OPERAND (node, 1) = catch;
14210   TREE_TYPE (node) = void_type_node;
14211   return node;
14212 }
14213
14214 /* 14.17 The synchronized Statement */
14215
14216 static tree
14217 patch_synchronized_statement (node, wfl_op1)
14218     tree node, wfl_op1;
14219 {
14220   tree expr = java_complete_tree (TREE_OPERAND (node, 0));
14221   tree block = TREE_OPERAND (node, 1);
14222
14223   tree enter, exit, expr_decl, assignment;
14224
14225   if (expr == error_mark_node)
14226     {
14227       block = java_complete_tree (block);
14228       return expr;
14229     }
14230
14231   /* The TYPE of expr must be a reference type */
14232   if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
14233     {
14234       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
14235       parse_error_context (wfl_operator, "Incompatible type for `synchronized'"
14236                            ". Can't convert `%s' to `java.lang.Object'",
14237                            lang_printable_name (TREE_TYPE (expr), 0));
14238       return error_mark_node;
14239     }
14240
14241   if (flag_emit_xref)
14242     {
14243       TREE_OPERAND (node, 0) = expr;
14244       TREE_OPERAND (node, 1) = java_complete_tree (block);
14245       CAN_COMPLETE_NORMALLY (node) = 1;
14246       return node;
14247     }
14248
14249   /* Generate a try-finally for the synchronized statement, except
14250      that the handler that catches all throw exception calls
14251      _Jv_MonitorExit and then rethrow the exception.
14252      The synchronized statement is then implemented as:
14253      TRY 
14254        {
14255          _Jv_MonitorEnter (expression)
14256          synchronized_block
14257          _Jv_MonitorExit (expression)
14258        }
14259      CATCH_ALL
14260        {
14261          e = _Jv_exception_info ();
14262          _Jv_MonitorExit (expression)
14263          Throw (e);
14264        } */
14265
14266   expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
14267   BUILD_MONITOR_ENTER (enter, expr_decl);
14268   BUILD_MONITOR_EXIT (exit, expr_decl);
14269   CAN_COMPLETE_NORMALLY (enter) = 1;
14270   CAN_COMPLETE_NORMALLY (exit) = 1;
14271   assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
14272   TREE_SIDE_EFFECTS (assignment) = 1;
14273   node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
14274                  build (COMPOUND_EXPR, NULL_TREE,
14275                         build (WITH_CLEANUP_EXPR, NULL_TREE,
14276                                build (COMPOUND_EXPR, NULL_TREE,
14277                                       assignment, enter),
14278                                NULL_TREE, exit),
14279                         block));
14280   node = build_expr_block (node, expr_decl);
14281
14282   return java_complete_tree (node);
14283 }
14284
14285 /* 14.16 The throw Statement */
14286
14287 static tree
14288 patch_throw_statement (node, wfl_op1)
14289     tree node, wfl_op1;
14290 {
14291   tree expr = TREE_OPERAND (node, 0);
14292   tree type = TREE_TYPE (expr);
14293   int unchecked_ok = 0, tryblock_throws_ok = 0;
14294
14295   /* Thrown expression must be assignable to java.lang.Throwable */
14296   if (!try_reference_assignconv (throwable_type_node, expr))
14297     {
14298       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
14299       parse_error_context (wfl_operator, "Can't throw `%s'; it must be a "
14300                            "subclass of class `java.lang.Throwable'",
14301                            lang_printable_name (type, 0));
14302       /* If the thrown expression was a reference, we further the
14303          compile-time check. */
14304       if (!JREFERENCE_TYPE_P (type))
14305         return error_mark_node;
14306     }
14307
14308   /* At least one of the following must be true */
14309
14310   /* The type of the throw expression is a not checked exception,
14311      i.e. is a unchecked expression. */
14312   unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
14313
14314   /* Throw is contained in a try statement and at least one catch
14315      clause can receive the thrown expression or the current method is
14316      declared to throw such an exception. Or, the throw statement is
14317      contained in a method or constructor declaration and the type of
14318      the Expression is assignable to at least one type listed in the
14319      throws clause the declaration. */
14320   SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
14321   if (!unchecked_ok)
14322     tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
14323   if (!(unchecked_ok || tryblock_throws_ok))
14324     {
14325       /* If there is a surrounding try block that has no matching
14326          clatch clause, report it first. A surrounding try block exits
14327          only if there is something after the list of checked
14328          exception thrown by the current function (if any). */
14329       if (IN_TRY_BLOCK_P ())
14330         parse_error_context (wfl_operator, "Checked exception `%s' can't be "
14331                              "caught by any of the catch clause(s) "
14332                              "of the surrounding `try' block",
14333                              lang_printable_name (type, 0));
14334       /* If we have no surrounding try statement and the method doesn't have
14335          any throws, report it now. FIXME */
14336
14337       /* We report that the exception can't be throw from a try block
14338          in all circumstances but when the `throw' is inside a static
14339          block. */
14340       else if (!EXCEPTIONS_P (currently_caught_type_list) 
14341                && !tryblock_throws_ok)
14342         {
14343           if (IS_CLINIT (current_function_decl))
14344             parse_error_context (wfl_operator, "Checked exception `%s' can't "
14345                                  "be thrown in initializer",
14346                                  lang_printable_name (type, 0));
14347           else
14348             parse_error_context (wfl_operator, "Checked exception `%s' isn't "
14349                                  "thrown from a `try' block", 
14350                                  lang_printable_name (type, 0));
14351         }
14352       /* Otherwise, the current method doesn't have the appropriate
14353          throws declaration */
14354       else
14355         parse_error_context (wfl_operator, "Checked exception `%s' doesn't "
14356                              "match any of current method's `throws' "
14357                              "declaration(s)", 
14358                              lang_printable_name (type, 0));
14359       return error_mark_node;
14360     }
14361
14362   if (! flag_emit_class_files && ! flag_emit_xref)
14363     BUILD_THROW (node, expr);
14364
14365   /* If doing xrefs, keep the location where the `throw' was seen. */
14366   if (flag_emit_xref)
14367     EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
14368   return node;
14369 }
14370
14371 /* Check that exception said to be thrown by method DECL can be
14372    effectively caught from where DECL is invoked.  */
14373
14374 static void
14375 check_thrown_exceptions (location, decl)
14376      int location;
14377      tree decl;
14378 {
14379   tree throws;
14380   /* For all the unchecked exceptions thrown by DECL */
14381   for (throws = DECL_FUNCTION_THROWS (decl); throws; 
14382        throws = TREE_CHAIN (throws)) 
14383     if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
14384       {
14385 #if 1
14386         /* Temporary hack to suppresses errors about cloning arrays. FIXME */
14387         if (DECL_NAME (decl) == get_identifier ("clone"))
14388           continue;
14389 #endif
14390         EXPR_WFL_LINECOL (wfl_operator) = location;
14391         if (DECL_NAME (current_function_decl) == finit_identifier_node)
14392           parse_error_context
14393             (wfl_operator, "Exception `%s' can't be thrown in initializer",
14394              lang_printable_name (TREE_VALUE (throws), 0));
14395         else 
14396           {
14397             parse_error_context 
14398               (wfl_operator, "Exception `%s' must be caught, or it must be "
14399                "declared in the `throws' clause of `%s'", 
14400                lang_printable_name (TREE_VALUE (throws), 0),
14401                (DECL_NAME (current_function_decl) == init_identifier_node ?
14402                 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
14403                 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
14404           }
14405       }
14406 }
14407
14408 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
14409    try-catch blocks, OR is listed in the `throws' clause of the
14410    current method.  */
14411
14412 static int
14413 check_thrown_exceptions_do (exception)
14414      tree exception;
14415 {
14416   tree list = currently_caught_type_list;
14417   resolve_and_layout (exception, NULL_TREE);
14418   /* First, all the nested try-catch-finally at that stage. The
14419      last element contains `throws' clause exceptions, if any. */
14420   if (IS_UNCHECKED_EXCEPTION_P (exception))
14421     return 1;
14422   while (list)
14423     {
14424       tree caught;
14425       for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
14426         if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
14427           return 1;
14428       list = TREE_CHAIN (list);
14429     }
14430   return 0;
14431 }
14432
14433 static void
14434 purge_unchecked_exceptions (mdecl)
14435      tree mdecl;
14436 {
14437   tree throws = DECL_FUNCTION_THROWS (mdecl);
14438   tree new = NULL_TREE;
14439
14440   while (throws)
14441     {
14442       tree next = TREE_CHAIN (throws);
14443       if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
14444         {
14445           TREE_CHAIN (throws) = new;
14446           new = throws;
14447         }
14448       throws = next;
14449     }
14450   /* List is inverted here, but it doesn't matter */
14451   DECL_FUNCTION_THROWS (mdecl) = new;
14452 }
14453
14454 /* 15.24 Conditional Operator ?: */
14455
14456 static tree
14457 patch_conditional_expr (node, wfl_cond, wfl_op1)
14458      tree node, wfl_cond, wfl_op1;
14459 {
14460   tree cond = TREE_OPERAND (node, 0);
14461   tree op1 = TREE_OPERAND (node, 1);
14462   tree op2 = TREE_OPERAND (node, 2);
14463   tree resulting_type = NULL_TREE;
14464   tree t1, t2, patched;
14465   int error_found = 0;
14466
14467   /* Operands of ?: might be StringBuffers crafted as a result of a
14468      string concatenation. Obtain a descent operand here.  */
14469   if ((patched = patch_string (op1)))
14470     TREE_OPERAND (node, 1) = op1 = patched;
14471   if ((patched = patch_string (op2)))
14472     TREE_OPERAND (node, 2) = op2 = patched;
14473
14474   t1 = TREE_TYPE (op1);
14475   t2 = TREE_TYPE (op2);
14476
14477   /* The first expression must be a boolean */
14478   if (TREE_TYPE (cond) != boolean_type_node)
14479     {
14480       SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
14481       parse_error_context (wfl_operator, "Incompatible type for `?:'. Can't "
14482                            "convert `%s' to `boolean'",
14483                            lang_printable_name (TREE_TYPE (cond), 0));
14484       error_found = 1;
14485     }
14486
14487   /* Second and third can be numeric, boolean (i.e. primitive),
14488      references or null. Anything else results in an error */
14489   if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
14490         || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node) 
14491             && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
14492         || (t1 == boolean_type_node && t2 == boolean_type_node)))
14493     error_found = 1;
14494
14495   /* Determine the type of the conditional expression. Same types are
14496      easy to deal with */
14497   else if (t1 == t2)
14498     resulting_type = t1;
14499
14500   /* There are different rules for numeric types */
14501   else if (JNUMERIC_TYPE_P (t1))
14502     {
14503       /* if byte/short found, the resulting type is short */
14504       if ((t1 == byte_type_node && t2 == short_type_node)
14505           || (t1 == short_type_node && t2 == byte_type_node))
14506         resulting_type = short_type_node;
14507
14508       /* If t1 is a constant int and t2 is of type byte, short or char
14509          and t1's value fits in t2, then the resulting type is t2 */
14510       else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
14511           && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
14512         resulting_type = t2;
14513
14514       /* If t2 is a constant int and t1 is of type byte, short or char
14515          and t2's value fits in t1, then the resulting type is t1 */
14516       else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
14517           && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
14518         resulting_type = t1;
14519
14520       /* Otherwise, binary numeric promotion is applied and the
14521          resulting type is the promoted type of operand 1 and 2 */
14522       else 
14523         resulting_type = binary_numeric_promotion (t1, t2, 
14524                                                    &TREE_OPERAND (node, 1), 
14525                                                    &TREE_OPERAND (node, 2));
14526     }
14527
14528   /* Cases of a reference and a null type */
14529   else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
14530     resulting_type = t1;
14531
14532   else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
14533     resulting_type = t2;
14534
14535   /* Last case: different reference types. If a type can be converted
14536      into the other one by assignment conversion, the latter
14537      determines the type of the expression */
14538   else if ((resulting_type = try_reference_assignconv (t1, op2)))
14539     resulting_type = promote_type (t1);
14540
14541   else if ((resulting_type = try_reference_assignconv (t2, op1)))
14542     resulting_type = promote_type (t2);
14543
14544   /* If we don't have any resulting type, we're in trouble */
14545   if (!resulting_type)
14546     {
14547       char *t = xstrdup (lang_printable_name (t1, 0));
14548       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
14549       parse_error_context (wfl_operator, "Incompatible type for `?:'. Can't "
14550                            "convert `%s' to `%s'", t,
14551                            lang_printable_name (t2, 0));
14552       free (t);
14553       error_found = 1;
14554     }
14555
14556   if (error_found)
14557     {
14558       TREE_TYPE (node) = error_mark_node;
14559       return error_mark_node;
14560     }
14561
14562   TREE_TYPE (node) = resulting_type;
14563   TREE_SET_CODE (node, COND_EXPR);
14564   CAN_COMPLETE_NORMALLY (node) = 1;
14565   return node;
14566 }
14567
14568 /* Try to constant fold NODE.
14569    If NODE is not a constant expression, return NULL_EXPR.
14570    CONTEXT is a static final VAR_DECL whose initializer we are folding. */
14571
14572 static tree
14573 fold_constant_for_init (node, context)
14574      tree node;
14575      tree context;
14576 {
14577   tree op0, op1, val;
14578   enum tree_code code = TREE_CODE (node);
14579
14580   if (code == STRING_CST)
14581     return node;
14582
14583   if (code == INTEGER_CST || code == REAL_CST)
14584     return convert (TREE_TYPE (context), node);
14585   if (TREE_TYPE (node) != NULL_TREE && code != VAR_DECL && code != FIELD_DECL)
14586     return NULL_TREE;
14587
14588   switch (code)
14589     {
14590     case PLUS_EXPR:
14591     case MINUS_EXPR:
14592     case MULT_EXPR:
14593     case TRUNC_MOD_EXPR:
14594     case RDIV_EXPR:
14595     case LSHIFT_EXPR:
14596     case RSHIFT_EXPR:
14597     case URSHIFT_EXPR:
14598     case BIT_AND_EXPR:
14599     case BIT_XOR_EXPR:
14600     case BIT_IOR_EXPR:
14601     case TRUTH_ANDIF_EXPR:
14602     case TRUTH_ORIF_EXPR:
14603     case EQ_EXPR: 
14604     case NE_EXPR:
14605     case GT_EXPR:
14606     case GE_EXPR:
14607     case LT_EXPR:
14608     case LE_EXPR:
14609       op0 = TREE_OPERAND (node, 0);
14610       op1 = TREE_OPERAND (node, 1);
14611       val = fold_constant_for_init (op0, context);
14612       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14613         return NULL_TREE;
14614       TREE_OPERAND (node, 0) = val;
14615       val = fold_constant_for_init (op1, context);
14616       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14617         return NULL_TREE;
14618       TREE_OPERAND (node, 1) = val;
14619       return patch_binop (node, op0, op1);
14620
14621     case UNARY_PLUS_EXPR:
14622     case NEGATE_EXPR:
14623     case TRUTH_NOT_EXPR:
14624     case BIT_NOT_EXPR:
14625     case CONVERT_EXPR:
14626       op0 = TREE_OPERAND (node, 0);
14627       val = fold_constant_for_init (op0, context);
14628       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14629         return NULL_TREE;
14630       TREE_OPERAND (node, 0) = val;
14631       return patch_unaryop (node, op0);
14632       break;
14633
14634     case COND_EXPR:
14635       val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
14636       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14637         return NULL_TREE;
14638       TREE_OPERAND (node, 0) = val;
14639       val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
14640       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14641         return NULL_TREE;
14642       TREE_OPERAND (node, 1) = val;
14643       val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
14644       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14645         return NULL_TREE;
14646       TREE_OPERAND (node, 2) = val;
14647       return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
14648         : TREE_OPERAND (node, 2);
14649
14650     case VAR_DECL:
14651     case FIELD_DECL:
14652       if (! FIELD_FINAL (node)
14653           || DECL_INITIAL (node) == NULL_TREE)
14654         return NULL_TREE;
14655       val = DECL_INITIAL (node);
14656       /* Guard against infinite recursion. */
14657       DECL_INITIAL (node) = NULL_TREE;
14658       val = fold_constant_for_init (val, node);
14659       DECL_INITIAL (node) = val;
14660       return val;
14661
14662     case EXPR_WITH_FILE_LOCATION:
14663       /* Compare java_complete_tree and resolve_expression_name. */
14664       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
14665           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
14666         {
14667           tree name = EXPR_WFL_NODE (node);
14668           tree decl;
14669           if (PRIMARY_P (node))
14670             return NULL_TREE;
14671           else if (! QUALIFIED_P (name))
14672             {
14673               decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
14674               if (decl == NULL_TREE 
14675                   || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
14676                 return NULL_TREE;
14677               return fold_constant_for_init (decl, decl);
14678             }
14679           else
14680             {
14681               /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
14682               qualify_ambiguous_name (node);
14683               if (resolve_field_access (node, &decl, NULL)
14684                   && decl != NULL_TREE)
14685                 return fold_constant_for_init (decl, decl);
14686               return NULL_TREE;
14687             }
14688         }
14689       else
14690         {
14691           op0 = TREE_OPERAND (node, 0);
14692           val = fold_constant_for_init (op0, context);
14693           if (val == NULL_TREE || ! TREE_CONSTANT (val))
14694             return NULL_TREE;
14695           TREE_OPERAND (node, 0) = val;
14696           return val;
14697         }
14698
14699 #ifdef USE_COMPONENT_REF
14700     case IDENTIFIER:
14701     case COMPONENT_REF:
14702       ?;
14703 #endif
14704
14705     default:
14706       return NULL_TREE;
14707     }
14708 }
14709
14710 #ifdef USE_COMPONENT_REF
14711 /* Context is 'T' for TypeName, 'P' for PackageName,
14712    'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
14713
14714 tree
14715 resolve_simple_name (name, context)
14716      tree name;
14717      int context;
14718 {
14719 }
14720
14721 tree
14722 resolve_qualified_name (name, context)
14723      tree name;
14724      int context;
14725 {
14726 }
14727 #endif