OSDN Git Service

Mon Jun 7 16:09:51 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 "except.h"
142
143 #ifndef DIR_SEPARATOR
144 #define DIR_SEPARATOR '/'
145 #endif
146
147 /* Local function prototypes */
148 static char *java_accstring_lookup PROTO ((int));
149 static void  classitf_redefinition_error PROTO ((char *,tree, tree, tree));
150 static void  variable_redefinition_error PROTO ((tree, tree, tree, int));
151 static void  check_modifiers PROTO ((char *, int, int));
152 static tree  create_class PROTO ((int, tree, tree, tree));
153 static tree  create_interface PROTO ((int, tree, tree));
154 static tree  find_field PROTO ((tree, tree));
155 static tree lookup_field_wrapper PROTO ((tree, tree));
156 static int   duplicate_declaration_error_p PROTO ((tree, tree, tree));
157 static void  register_fields PROTO ((int, tree, tree));
158 static tree parser_qualified_classname PROTO ((tree));
159 static int  parser_check_super PROTO ((tree, tree, tree));
160 static int  parser_check_super_interface PROTO ((tree, tree, tree));
161 static void check_modifiers_consistency PROTO ((int));
162 static tree lookup_cl PROTO ((tree));
163 static tree lookup_java_method2 PROTO ((tree, tree, int));
164 static tree method_header PROTO ((int, tree, tree, tree));
165 static void fix_method_argument_names PROTO ((tree ,tree));
166 static tree method_declarator PROTO ((tree, tree));
167 static void parse_warning_context PVPROTO ((tree cl, const char *msg, ...))
168   ATTRIBUTE_PRINTF_2;
169 static void issue_warning_error_from_context PROTO ((tree, const char *msg, va_list));
170 static tree parse_jdk1_1_error PROTO ((char *));
171 static void complete_class_report_errors PROTO ((jdep *));
172 static int process_imports PROTO ((void));
173 static void read_import_dir PROTO ((tree));
174 static int find_in_imports_on_demand PROTO ((tree));
175 static int find_in_imports PROTO ((tree));
176 static int check_pkg_class_access PROTO ((tree, tree));
177 static tree resolve_package PROTO ((tree, tree *));
178 static tree lookup_package_type PROTO ((char *, int));
179 static tree resolve_class PROTO ((tree, tree, tree));
180 static void declare_local_variables PROTO ((int, tree, tree));
181 static void source_start_java_method PROTO ((tree));
182 static void source_end_java_method PROTO ((void));
183 static void expand_start_java_method PROTO ((tree));
184 static tree find_name_in_single_imports PROTO ((tree));
185 static void check_abstract_method_header PROTO ((tree));
186 static tree lookup_java_interface_method2 PROTO ((tree, tree));
187 static tree resolve_expression_name PROTO ((tree, tree *));
188 static tree maybe_create_class_interface_decl PROTO ((tree, tree, tree));
189 static int check_class_interface_creation PROTO ((int, int, tree, 
190                                                   tree, tree, tree));
191 static tree patch_method_invocation PROTO ((tree, tree, tree, 
192                                             int *, tree *));
193 static int breakdown_qualified PROTO ((tree *, tree *, tree));
194 static tree resolve_and_layout PROTO ((tree, tree));
195 static tree resolve_no_layout PROTO ((tree, tree));
196 static int invocation_mode PROTO ((tree, int));
197 static tree find_applicable_accessible_methods_list PROTO ((int, tree, 
198                                                             tree, tree));
199 static void search_applicable_methods_list PROTO ((int, tree, tree, tree, 
200                                                    tree *, tree *));
201 static tree find_most_specific_methods_list PROTO ((tree));
202 static int argument_types_convertible PROTO ((tree, tree));
203 static tree patch_invoke PROTO ((tree, tree, tree));
204 static tree lookup_method_invoke PROTO ((int, tree, tree, tree, tree));
205 static tree register_incomplete_type PROTO ((int, tree, tree, tree));
206 static tree obtain_incomplete_type PROTO ((tree));
207 static tree java_complete_lhs PROTO ((tree));
208 static tree java_complete_tree PROTO ((tree));
209 static void java_complete_expand_method PROTO ((tree));
210 static int  unresolved_type_p PROTO ((tree, tree *));
211 static void create_jdep_list PROTO ((struct parser_ctxt *));
212 static tree build_expr_block PROTO ((tree, tree));
213 static tree enter_block PROTO ((void));
214 static tree enter_a_block PROTO ((tree));
215 static tree exit_block PROTO ((void));
216 static tree lookup_name_in_blocks PROTO ((tree));
217 static void maybe_absorb_scoping_blocks PROTO ((void));
218 static tree build_method_invocation PROTO ((tree, tree));
219 static tree build_new_invocation PROTO ((tree, tree));
220 static tree build_assignment PROTO ((int, int, tree, tree));
221 static tree build_binop PROTO ((enum tree_code, int, tree, tree));
222 static int check_final_assignment PROTO ((tree ,tree));
223 static tree patch_assignment PROTO ((tree, tree, tree ));
224 static tree patch_binop PROTO ((tree, tree, tree));
225 static tree build_unaryop PROTO ((int, int, tree));
226 static tree build_incdec PROTO ((int, int, tree, int));
227 static tree patch_unaryop PROTO ((tree, tree));
228 static tree build_cast PROTO ((int, tree, tree));
229 static tree build_null_of_type PROTO ((tree));
230 static tree patch_cast PROTO ((tree, tree));
231 static int valid_ref_assignconv_cast_p PROTO ((tree, tree, int));
232 static int valid_builtin_assignconv_identity_widening_p PROTO ((tree, tree));
233 static int valid_cast_to_p PROTO ((tree, tree));
234 static int valid_method_invocation_conversion_p PROTO ((tree, tree));
235 static tree try_builtin_assignconv PROTO ((tree, tree, tree));
236 static tree try_reference_assignconv PROTO ((tree, tree));
237 static tree build_unresolved_array_type PROTO ((tree));
238 static tree build_array_from_name PROTO ((tree, tree, tree, tree *));
239 static tree build_array_ref PROTO ((int, tree, tree));
240 static tree patch_array_ref PROTO ((tree));
241 static tree make_qualified_name PROTO ((tree, tree, int));
242 static tree merge_qualified_name PROTO ((tree, tree));
243 static tree make_qualified_primary PROTO ((tree, tree, int));
244 static int resolve_qualified_expression_name PROTO ((tree, tree *, 
245                                                      tree *, tree *));
246 static void qualify_ambiguous_name PROTO ((tree));
247 static void maybe_generate_clinit PROTO ((void));
248 static tree resolve_field_access PROTO ((tree, tree *, tree *));
249 static tree build_newarray_node PROTO ((tree, tree, int));
250 static tree patch_newarray PROTO ((tree));
251 static tree resolve_type_during_patch PROTO ((tree));
252 static tree build_this PROTO ((int));
253 static tree build_return PROTO ((int, tree));
254 static tree patch_return PROTO ((tree));
255 static tree maybe_access_field PROTO ((tree, tree, tree));
256 static int complete_function_arguments PROTO ((tree));
257 static int check_for_static_method_reference PROTO ((tree, tree, tree, tree, tree));
258 static int not_accessible_p PROTO ((tree, tree, int));
259 static void check_deprecation PROTO ((tree, tree));
260 static int class_in_current_package PROTO ((tree));
261 static tree build_if_else_statement PROTO ((int, tree, tree, tree));
262 static tree patch_if_else_statement PROTO ((tree));
263 static tree add_stmt_to_compound PROTO ((tree, tree, tree));
264 static tree add_stmt_to_block PROTO ((tree, tree, tree));
265 static tree patch_exit_expr PROTO ((tree));
266 static tree build_labeled_block PROTO ((int, tree));
267 static tree finish_labeled_statement PROTO ((tree, tree));
268 static tree build_bc_statement PROTO ((int, int, tree));
269 static tree patch_bc_statement PROTO ((tree));
270 static tree patch_loop_statement PROTO ((tree));
271 static tree build_new_loop PROTO ((tree));
272 static tree build_loop_body PROTO ((int, tree, int));
273 static tree finish_loop_body PROTO ((int, tree, tree, int));
274 static tree build_debugable_stmt PROTO ((int, tree));
275 static tree finish_for_loop PROTO ((int, tree, tree, tree));
276 static tree patch_switch_statement PROTO ((tree));
277 static tree string_constant_concatenation PROTO ((tree, tree));
278 static tree build_string_concatenation PROTO ((tree, tree));
279 static tree patch_string_cst PROTO ((tree));
280 static tree patch_string PROTO ((tree));
281 static tree build_try_statement PROTO ((int, tree, tree));
282 static tree build_try_finally_statement PROTO ((int, tree, tree));
283 static tree patch_try_statement PROTO ((tree));
284 static tree patch_synchronized_statement PROTO ((tree, tree));
285 static tree patch_throw_statement PROTO ((tree, tree));
286 static void check_thrown_exceptions PROTO ((int, tree));
287 static int check_thrown_exceptions_do PROTO ((tree));
288 static void purge_unchecked_exceptions PROTO ((tree));
289 static void check_throws_clauses PROTO ((tree, tree, tree));
290 static void finish_method_declaration PROTO ((tree));
291 static tree build_super_invocation PROTO (());
292 static int verify_constructor_circularity PROTO ((tree, tree));
293 static char *constructor_circularity_msg PROTO ((tree, tree));
294 static tree build_this_super_qualified_invocation PROTO ((int, tree, tree,
295                                                           int, int));
296 static char *get_printable_method_name PROTO ((tree));
297 static tree patch_conditional_expr PROTO ((tree, tree, tree));
298 static void maybe_generate_finit PROTO (());
299 static void fix_constructors PROTO ((tree));
300 static int verify_constructor_super PROTO (());
301 static tree create_artificial_method PROTO ((tree, int, tree, tree, tree));
302 static void start_artificial_method_body PROTO ((tree));
303 static void end_artificial_method_body PROTO ((tree));
304 static int check_method_redefinition PROTO ((tree, tree));
305 static int reset_method_name PROTO ((tree));
306 static void java_check_regular_methods PROTO ((tree));
307 static void java_check_abstract_methods PROTO ((tree));
308 static tree maybe_build_primttype_type_ref PROTO ((tree, tree));
309 static void unreachable_stmt_error PROTO ((tree));
310 static tree find_expr_with_wfl PROTO ((tree));
311 static void missing_return_error PROTO ((tree));
312 static tree build_new_array_init PROTO ((int, tree));
313 static tree patch_new_array_init PROTO ((tree, tree));
314 static tree maybe_build_array_element_wfl PROTO ((tree));
315 static int array_constructor_check_entry PROTO ((tree, tree));
316 static char *purify_type_name PROTO ((char *));
317 static tree fold_constant_for_init PROTO ((tree, tree));
318 static tree strip_out_static_field_access_decl PROTO ((tree));
319 static jdeplist *reverse_jdep_list PROTO ((struct parser_ctxt *));
320 static void static_ref_err PROTO ((tree, tree, tree));
321
322 /* Number of error found so far. */
323 int java_error_count; 
324 /* Number of warning found so far. */
325 int java_warning_count;
326 /* Tell when not to fold, when doing xrefs */
327 int do_not_fold;
328
329 /* The current parser context */
330 struct parser_ctxt *ctxp;
331
332 /* List of things that were analyzed for which code will be generated */
333 static struct parser_ctxt *ctxp_for_generation = NULL;
334
335 /* binop_lookup maps token to tree_code. It is used where binary
336    operations are involved and required by the parser. RDIV_EXPR
337    covers both integral/floating point division. The code is changed
338    once the type of both operator is worked out.  */
339
340 static enum tree_code binop_lookup[19] = 
341   { 
342     PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
343     LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR, 
344     BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
345     TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
346     EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
347    };
348 #define BINOP_LOOKUP(VALUE)                                             \
349   binop_lookup [((VALUE) - PLUS_TK)%                                    \
350                 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
351
352 /* Fake WFL used to report error message. It is initialized once if
353    needed and reused with it's location information is overriden.  */
354 tree wfl_operator = NULL_TREE;
355
356 /* The "$L" identifier we use to create labels.  */
357 static tree label_id = NULL_TREE;
358
359 /* The "StringBuffer" identifier used for the String `+' operator. */
360 static tree wfl_string_buffer = NULL_TREE; 
361
362 /* The "append" identifier used for String `+' operator.  */
363 static tree wfl_append = NULL_TREE;
364
365 /* The "toString" identifier used for String `+' operator. */
366 static tree wfl_to_string = NULL_TREE;
367
368 /* The "java.lang" import qualified name.  */
369 static tree java_lang_id = NULL_TREE;
370
371 /* The "java.lang.Cloneable" qualified name.  */
372 static tree java_lang_cloneable = NULL_TREE;
373
374 /* Context and flag for static blocks */
375 static tree current_static_block = NULL_TREE;
376
377
378 #line 303 "./parse.y"
379 typedef union {
380   tree node;
381   int sub_token;
382   struct {
383     int token;
384     int location;
385   } operator;
386   int value;
387 } YYSTYPE;
388 #line 313 "./parse.y"
389
390 #include "lex.c"
391 #ifndef YYDEBUG
392 #define YYDEBUG 1
393 #endif
394
395 #include <stdio.h>
396
397 #ifndef __cplusplus
398 #ifndef __STDC__
399 #define const
400 #endif
401 #endif
402
403
404
405 #define YYFINAL         777
406 #define YYFLAG          -32768
407 #define YYNTBASE        110
408
409 #define YYTRANSLATE(x) ((unsigned)(x) <= 364 ? yytranslate[x] : 266)
410
411 static const char yytranslate[] = {     0,
412      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
413      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
414      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
415      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
416      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
417      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
418      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
419      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
420      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
421      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
422      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
423      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
424      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
425      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
426      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
427      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
428      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
429      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
430      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
431      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
432      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
433      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
434      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
435      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
436      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
437      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
438      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
439     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
440     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
441     36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
442     46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
443     56,    57,    58,    59,    60,    61,    62,    63,    64,    65,
444     66,    67,    68,    69,    70,    71,    72,    73,    74,    75,
445     76,    77,    78,    79,    80,    81,    82,    83,    84,    85,
446     86,    87,    88,    89,    90,    91,    92,    93,    94,    95,
447     96,    97,    98,    99,   100,   101,   102,   103,   104,   105,
448    106,   107,   108,   109
449 };
450
451 #if YYDEBUG != 0
452 static const short yyprhs[] = {     0,
453      0,     2,     4,     6,     8,    10,    12,    14,    16,    18,
454     20,    22,    24,    26,    28,    30,    32,    34,    38,    42,
455     46,    50,    54,    56,    58,    60,    64,    66,    67,    69,
456     71,    73,    76,    79,    82,    86,    88,    91,    93,    96,
457    100,   103,   107,   109,   111,   115,   118,   122,   128,   133,
458    139,   141,   143,   145,   147,   149,   152,   153,   161,   162,
459    169,   173,   176,   180,   185,   186,   189,   193,   196,   197,
460    200,   203,   205,   209,   213,   216,   220,   222,   225,   227,
461    229,   231,   233,   235,   238,   240,   242,   244,   248,   253,
462    255,   259,   263,   265,   269,   273,   278,   280,   284,   287,
463    291,   295,   297,   299,   300,   304,   307,   311,   315,   320,
464    325,   328,   332,   335,   339,   342,   346,   351,   355,   359,
465    363,   365,   369,   373,   376,   380,   383,   387,   388,   391,
466    394,   396,   400,   404,   406,   409,   411,   414,   418,   420,
467    421,   425,   428,   432,   436,   441,   444,   448,   452,   457,
468    459,   462,   467,   473,   481,   488,   490,   492,   493,   498,
469    499,   505,   506,   512,   513,   520,   524,   529,   532,   536,
470    539,   543,   546,   550,   552,   555,   557,   559,   561,   563,
471    565,   568,   571,   574,   578,   583,   585,   589,   593,   596,
472    600,   602,   604,   606,   609,   611,   613,   615,   618,   621,
473    625,   627,   629,   631,   633,   635,   637,   639,   641,   643,
474    645,   647,   649,   651,   653,   655,   657,   659,   661,   663,
475    665,   667,   669,   671,   674,   677,   680,   683,   686,   689,
476    692,   695,   699,   704,   709,   715,   720,   726,   733,   741,
477    748,   750,   752,   754,   756,   758,   760,   762,   768,   771,
478    775,   780,   788,   796,   797,   801,   806,   809,   813,   819,
479    822,   826,   830,   835,   837,   840,   843,   845,   848,   852,
480    855,   858,   862,   865,   870,   873,   876,   880,   885,   888,
481    890,   898,   906,   913,   917,   923,   928,   936,   943,   946,
482    949,   953,   956,   957,   959,   961,   964,   965,   967,   969,
483    973,   977,   980,   984,   987,   991,   994,   998,  1001,  1005,
484   1008,  1012,  1015,  1019,  1023,  1026,  1030,  1036,  1042,  1045,
485   1050,  1054,  1056,  1060,  1064,  1069,  1072,  1074,  1077,  1080,
486   1085,  1088,  1092,  1097,  1100,  1103,  1105,  1107,  1109,  1111,
487   1115,  1117,  1119,  1121,  1123,  1127,  1131,  1135,  1139,  1143,
488   1147,  1151,  1155,  1161,  1166,  1173,  1179,  1184,  1190,  1196,
489   1203,  1207,  1211,  1216,  1222,  1225,  1229,  1233,  1237,  1239,
490   1243,  1247,  1251,  1255,  1260,  1265,  1270,  1275,  1279,  1283,
491   1285,  1288,  1292,  1296,  1299,  1302,  1306,  1310,  1314,  1318,
492   1321,  1325,  1330,  1336,  1343,  1349,  1356,  1361,  1366,  1371,
493   1376,  1380,  1385,  1389,  1394,  1396,  1398,  1400,  1402,  1405,
494   1408,  1410,  1412,  1415,  1418,  1420,  1423,  1426,  1429,  1432,
495   1435,  1438,  1440,  1443,  1446,  1448,  1451,  1454,  1460,  1465,
496   1470,  1476,  1481,  1484,  1490,  1495,  1501,  1503,  1507,  1511,
497   1515,  1519,  1523,  1527,  1529,  1533,  1537,  1541,  1545,  1547,
498   1551,  1555,  1559,  1563,  1567,  1571,  1573,  1577,  1581,  1585,
499   1589,  1593,  1597,  1601,  1605,  1609,  1613,  1615,  1619,  1623,
500   1627,  1631,  1633,  1637,  1641,  1643,  1647,  1651,  1653,  1657,
501   1661,  1663,  1667,  1671,  1673,  1677,  1681,  1683,  1689,  1694,
502   1698,  1704,  1706,  1708,  1712,  1716,  1718,  1720,  1722,  1724,
503   1726,  1728
504 };
505
506 static const short yyrhs[] = {   123,
507      0,   104,     0,   105,     0,   108,     0,   103,     0,   102,
508      0,   109,     0,   113,     0,   114,     0,    82,     0,    85,
509      0,    50,     0,   115,     0,   118,     0,   119,     0,   115,
510      0,   115,     0,   113,    97,    98,     0,   119,    97,    98,
511      0,   118,    97,    98,     0,   113,    97,     1,     0,   118,
512     97,     1,     0,   120,     0,   121,     0,   122,     0,   119,
513    101,   122,     0,    86,     0,     0,   126,     0,   124,     0,
514    125,     0,   126,   124,     0,   126,   125,     0,   124,   125,
515      0,   126,   124,   125,     0,   127,     0,   124,   127,     0,
516    130,     0,   125,   130,     0,    75,   119,    99,     0,    75,
517      1,     0,    75,   119,     1,     0,   128,     0,   129,     0,
518     55,   119,    99,     0,    55,     1,     0,    55,   119,     1,
519      0,    55,   119,   101,     5,    99,     0,    55,   119,   101,
520      1,     0,    55,   119,   101,     5,     1,     0,   132,     0,
521    166,     0,    99,     0,     1,     0,    44,     0,   131,    44,
522      0,     0,   131,    67,   122,   135,   136,   133,   138,     0,
523      0,    67,   122,   135,   136,   134,   138,     0,   131,    67,
524      1,     0,    67,     1,     0,    67,   122,     1,     0,   131,
525     67,   122,     1,     0,     0,    63,   116,     0,    63,   116,
526      1,     0,    63,     1,     0,     0,    52,   137,     0,    52,
527      1,     0,   117,     0,   137,   100,   117,     0,   137,   100,
528      1,     0,    95,    96,     0,    95,   139,    96,     0,   140,
529      0,   139,   140,     0,   141,     0,   156,     0,   158,     0,
530    179,     0,   142,     0,   142,    99,     0,   147,     0,   132,
531      0,   166,     0,   112,   143,    99,     0,   131,   112,   143,
532     99,     0,   144,     0,   143,   100,   144,     0,   143,   100,
533      1,     0,   145,     0,   145,    92,   146,     0,   145,    92,
534      1,     0,   145,    92,   146,     1,     0,   122,     0,   145,
535     97,    98,     0,   122,     1,     0,   145,    97,     1,     0,
536    145,    98,     1,     0,   264,     0,   177,     0,     0,   149,
537    148,   155,     0,   149,     1,     0,   112,   150,   153,     0,
538     59,   150,   153,     0,   131,   112,   150,   153,     0,   131,
539     59,   150,   153,     0,   112,     1,     0,   131,   112,     1,
540      0,    59,     1,     0,   131,    59,     1,     0,   131,     1,
541      0,   122,    93,    94,     0,   122,    93,   151,    94,     0,
542    150,    97,    98,     0,   122,    93,     1,     0,   150,    97,
543      1,     0,   152,     0,   151,   100,   152,     0,   151,   100,
544      1,     0,   112,   145,     0,   131,   112,   145,     0,   112,
545      1,     0,   131,   112,     1,     0,     0,    53,   154,     0,
546     53,     1,     0,   116,     0,   154,   100,   116,     0,   154,
547    100,     1,     0,   179,     0,   179,    99,     0,    99,     0,
548    157,   179,     0,   157,   179,    99,     0,    44,     0,     0,
549    160,   159,   162,     0,   161,   153,     0,   131,   161,   153,
550      0,   120,    93,    94,     0,   120,    93,   151,    94,     0,
551    180,   163,     0,   180,   164,   163,     0,   180,   182,   163,
552      0,   180,   164,   182,   163,     0,   181,     0,   181,    99,
553      0,   165,    93,    94,    99,     0,   165,    93,   233,    94,
554     99,     0,   119,   101,    65,    93,   233,    94,    99,     0,
555    119,   101,    65,    93,    94,    99,     0,    76,     0,    65,
556      0,     0,    61,   122,   167,   172,     0,     0,   131,    61,
557    122,   168,   172,     0,     0,    61,   122,   171,   169,   172,
558      0,     0,   131,    61,   122,   171,   170,   172,     0,    61,
559    122,     1,     0,   131,    61,   122,     1,     0,    63,   117,
560      0,   171,   100,   117,     0,    63,     1,     0,   171,   100,
561      1,     0,    95,    96,     0,    95,   173,    96,     0,   174,
562      0,   173,   174,     0,   175,     0,   176,     0,   132,     0,
563    166,     0,   142,     0,   149,    99,     0,   149,     1,     0,
564     95,    96,     0,    95,   178,    96,     0,    95,   178,   100,
565     96,     0,   146,     0,   178,   100,   146,     0,   178,   100,
566      1,     0,    95,    96,     0,   180,   182,   181,     0,    95,
567      0,    96,     0,   183,     0,   182,   183,     0,   184,     0,
568    186,     0,   132,     0,   185,    99,     0,   112,   143,     0,
569    131,   112,   143,     0,   188,     0,   191,     0,   195,     0,
570    196,     0,   207,     0,   211,     0,   188,     0,   192,     0,
571    197,     0,   208,     0,   212,     0,   179,     0,   189,     0,
572    193,     0,   198,     0,   210,     0,   218,     0,   219,     0,
573    220,     0,   222,     0,   221,     0,   224,     0,    99,     0,
574    122,    88,     0,   190,   186,     0,   122,     1,     0,   190,
575    187,     0,   194,    99,     0,     1,    99,     0,     1,    95,
576      0,     1,    96,     0,   165,    93,     1,     0,   165,    93,
577     94,     1,     0,   165,    93,   233,     1,     0,   165,    93,
578    233,    94,     1,     0,   119,   101,    65,     1,     0,   119,
579    101,    65,    93,     1,     0,   119,   101,    65,    93,   233,
580      1,     0,   119,   101,    65,    93,   233,    94,     1,     0,
581    119,   101,    65,    93,    94,     1,     0,   261,     0,   245,
582      0,   246,     0,   242,     0,   243,     0,   239,     0,   231,
583      0,    48,    93,   264,    94,   186,     0,    48,     1,     0,
584     48,    93,     1,     0,    48,    93,   264,     1,     0,    48,
585     93,   264,    94,   187,    56,   186,     0,    48,    93,   264,
586     94,   187,    56,   187,     0,     0,   200,   199,   201,     0,
587     68,    93,   264,    94,     0,    68,     1,     0,    68,    93,
588      1,     0,    68,    93,   264,    94,     1,     0,    95,    96,
589      0,    95,   204,    96,     0,    95,   202,    96,     0,    95,
590    202,   204,    96,     0,   203,     0,   202,   203,     0,   204,
591    182,     0,   205,     0,   204,   205,     0,    62,   265,    88,
592      0,    47,    88,     0,    62,     1,     0,    62,   265,     1,
593      0,    47,     1,     0,    66,    93,   264,    94,     0,   206,
594    186,     0,    66,     1,     0,    66,    93,     1,     0,    66,
595     93,   264,     1,     0,   206,   187,     0,    51,     0,   209,
596    186,    66,    93,   264,    94,    99,     0,   214,    99,   264,
597     99,   216,    94,   186,     0,   214,    99,    99,   216,    94,
598    186,     0,   214,    99,     1,     0,   214,    99,   264,    99,
599      1,     0,   214,    99,    99,     1,     0,   214,    99,   264,
600     99,   216,    94,   187,     0,   214,    99,    99,   216,    94,
601    187,     0,    71,    93,     0,    71,     1,     0,    71,    93,
602      1,     0,   213,   215,     0,     0,   217,     0,   185,     0,
603    217,     1,     0,     0,   217,     0,   194,     0,   217,   100,
604    194,     0,   217,   100,     1,     0,    54,    99,     0,    54,
605    122,    99,     0,    54,     1,     0,    54,   122,     1,     0,
606     73,    99,     0,    73,   122,    99,     0,    73,     1,     0,
607     73,   122,     1,     0,    58,    99,     0,    58,   264,    99,
608      0,    58,     1,     0,    58,   264,     1,     0,    49,   264,
609     99,     0,    49,     1,     0,    49,   264,     1,     0,   223,
610     93,   264,    94,   179,     0,   223,    93,   264,    94,     1,
611      0,   223,     1,     0,   223,    93,     1,    94,     0,   223,
612     93,     1,     0,    44,     0,    70,   179,   225,     0,    70,
613    179,   228,     0,    70,   179,   225,   228,     0,    70,     1,
614      0,   226,     0,   225,   226,     0,   227,   179,     0,    60,
615     93,   152,    94,     0,    60,     1,     0,    60,    93,     1,
616      0,    60,    93,     1,    94,     0,    64,   179,     0,    64,
617      1,     0,   230,     0,   234,     0,   111,     0,    76,     0,
618     93,   264,    94,     0,   231,     0,   238,     0,   239,     0,
619    240,     0,   119,   101,    67,     0,   113,   101,    67,     0,
620     59,   101,    67,     0,   119,   101,    76,     0,    93,   264,
621      1,     0,   119,   101,     1,     0,   113,   101,     1,     0,
622     59,   101,     1,     0,    72,   116,    93,   233,    94,     0,
623     72,   116,    93,    94,     0,    72,   116,    93,   233,    94,
624    138,     0,    72,   116,    93,    94,   138,     0,   232,   122,
625     93,    94,     0,   232,   122,    93,    94,   138,     0,   232,
626    122,    93,   233,    94,     0,   232,   122,    93,   233,    94,
627    138,     0,    72,     1,    99,     0,    72,   116,     1,     0,
628     72,   116,    93,     1,     0,    72,   116,    93,   233,     1,
629      0,   232,     1,     0,   232,   122,     1,     0,   119,   101,
630     72,     0,   229,   101,    72,     0,   264,     0,   233,   100,
631    264,     0,   233,   100,     1,     0,    72,   113,   235,     0,
632     72,   115,   235,     0,    72,   113,   235,   237,     0,    72,
633    115,   235,   237,     0,    72,   115,   237,   177,     0,    72,
634    113,   237,   177,     0,    72,     1,    98,     0,    72,     1,
635     97,     0,   236,     0,   235,   236,     0,    97,   264,    98,
636      0,    97,   264,     1,     0,    97,     1,     0,    97,    98,
637      0,   237,    97,    98,     0,   237,    97,     1,     0,   229,
638    101,   122,     0,    65,   101,   122,     0,    65,     1,     0,
639    119,    93,    94,     0,   119,    93,   233,    94,     0,   229,
640    101,   122,    93,    94,     0,   229,   101,   122,    93,   233,
641     94,     0,    65,   101,   122,    93,    94,     0,    65,   101,
642    122,    93,   233,    94,     0,    65,   101,     1,    94,     0,
643     65,   101,     1,   101,     0,   119,    97,   264,    98,     0,
644    230,    97,   264,    98,     0,   119,    97,     1,     0,   119,
645     97,   264,     1,     0,   230,    97,     1,     0,   230,    97,
646    264,     1,     0,   229,     0,   119,     0,   242,     0,   243,
647      0,   241,    46,     0,   241,    45,     0,   245,     0,   246,
648      0,     3,   244,     0,     4,   244,     0,   247,     0,     3,
649      1,     0,     4,     1,     0,    46,   244,     0,    46,     1,
650      0,    45,   244,     0,    45,     1,     0,   241,     0,    89,
651    244,     0,    90,   244,     0,   248,     0,    89,     1,     0,
652     90,     1,     0,    93,   113,   237,    94,   244,     0,    93,
653    113,    94,   244,     0,    93,   264,    94,   247,     0,    93,
654    119,   237,    94,   247,     0,    93,   113,    97,     1,     0,
655     93,     1,     0,    93,   113,   237,    94,     1,     0,    93,
656    113,    94,     1,     0,    93,   119,   237,    94,     1,     0,
657    244,     0,   249,     5,   244,     0,   249,     6,   244,     0,
658    249,     7,   244,     0,   249,     5,     1,     0,   249,     6,
659      1,     0,   249,     7,     1,     0,   249,     0,   250,     3,
660    249,     0,   250,     4,   249,     0,   250,     3,     1,     0,
661    250,     4,     1,     0,   250,     0,   251,     8,   250,     0,
662    251,     9,   250,     0,   251,    10,   250,     0,   251,     8,
663      1,     0,   251,     9,     1,     0,   251,    10,     1,     0,
664    251,     0,   252,    20,   251,     0,   252,    18,   251,     0,
665    252,    21,   251,     0,   252,    19,   251,     0,   252,    57,
666    114,     0,   252,    20,     1,     0,   252,    18,     1,     0,
667    252,    21,     1,     0,   252,    19,     1,     0,   252,    57,
668      1,     0,   252,     0,   253,    16,   252,     0,   253,    17,
669    252,     0,   253,    16,     1,     0,   253,    17,     1,     0,
670    253,     0,   254,    11,   253,     0,   254,    11,     1,     0,
671    254,     0,   255,    12,   254,     0,   255,    12,     1,     0,
672    255,     0,   256,    13,   255,     0,   256,    13,     1,     0,
673    256,     0,   257,    14,   256,     0,   257,    14,     1,     0,
674    257,     0,   258,    15,   257,     0,   258,    15,     1,     0,
675    258,     0,   258,    87,   264,    88,   259,     0,   258,    87,
676     88,     1,     0,   258,    87,     1,     0,   258,    87,   264,
677     88,     1,     0,   259,     0,   261,     0,   262,   263,   260,
678      0,   262,   263,     1,     0,   119,     0,   238,     0,   240,
679      0,    91,     0,    92,     0,   260,     0,   264,     0
680 };
681
682 #endif
683
684 #if YYDEBUG != 0
685 static const short yyrline[] = { 0,
686    457,   463,   465,   466,   467,   468,   469,   473,   475,   478,
687    480,   481,   484,   486,   489,   493,   497,   501,   507,   509,
688    511,   513,   518,   520,   523,   527,   532,   537,   539,   540,
689    541,   542,   543,   544,   545,   548,   553,   559,   561,   564,
690    567,   569,   573,   575,   578,   605,   607,   611,   624,   626,
691    630,   637,   642,   644,   654,   659,   674,   678,   681,   684,
692    687,   689,   691,   696,   700,   702,   704,   706,   710,   712,
693    714,   721,   727,   732,   736,   745,   755,   757,   760,   762,
694    763,   764,   768,   770,   772,   773,   775,   780,   783,   793,
695    796,   798,   802,   805,   812,   818,   826,   828,   830,   832,
696    834,   838,   840,   844,   851,   852,   856,   859,   861,   863,
697    865,   867,   869,   871,   873,   880,   883,   885,   894,   896,
698    900,   905,   910,   914,   919,   924,   926,   933,   935,   937,
699    941,   944,   946,   950,   952,   953,   958,   964,   971,   979,
700    986,   989,   992,   996,   999,  1003,  1012,  1014,  1016,  1020,
701   1022,  1025,  1032,  1040,  1042,  1046,  1053,  1063,  1067,  1070,
702   1073,  1076,  1079,  1082,  1085,  1088,  1090,  1094,  1100,  1105,
703   1107,  1111,  1114,  1118,  1120,  1123,  1125,  1126,  1128,  1132,
704   1136,  1142,  1147,  1150,  1152,  1156,  1162,  1166,  1171,  1180,
705   1184,  1189,  1201,  1203,  1206,  1208,  1210,  1214,  1218,  1221,
706   1225,  1227,  1228,  1229,  1230,  1231,  1235,  1237,  1238,  1239,
707   1240,  1244,  1246,  1247,  1248,  1249,  1250,  1251,  1252,  1253,
708   1254,  1255,  1258,  1263,  1274,  1277,  1281,  1288,  1298,  1304,
709   1310,  1316,  1318,  1324,  1326,  1332,  1334,  1336,  1338,  1340,
710   1344,  1346,  1347,  1348,  1349,  1350,  1351,  1354,  1360,  1362,
711   1364,  1368,  1373,  1378,  1384,  1394,  1400,  1402,  1404,  1411,
712   1414,  1416,  1418,  1422,  1424,  1427,  1431,  1433,  1436,  1443,
713   1449,  1451,  1453,  1457,  1465,  1468,  1470,  1472,  1476,  1481,
714   1490,  1495,  1498,  1505,  1507,  1509,  1513,  1516,  1525,  1532,
715   1534,  1538,  1551,  1553,  1559,  1565,  1569,  1571,  1575,  1578,
716   1580,  1584,  1587,  1589,  1591,  1595,  1598,  1600,  1602,  1606,
717   1609,  1611,  1613,  1617,  1623,  1625,  1629,  1636,  1638,  1640,
718   1642,  1646,  1654,  1657,  1659,  1664,  1668,  1670,  1677,  1685,
719   1702,  1704,  1706,  1710,  1713,  1718,  1720,  1723,  1725,  1727,
720   1729,  1730,  1731,  1732,  1736,  1738,  1740,  1745,  1747,  1749,
721   1751,  1753,  1757,  1760,  1765,  1767,  1772,  1773,  1774,  1775,
722   1776,  1778,  1780,  1782,  1784,  1786,  1790,  1792,  1795,  1801,
723   1806,  1810,  1813,  1815,  1817,  1821,  1823,  1825,  1827,  1831,
724   1834,  1838,  1844,  1846,  1854,  1881,  1883,  1887,  1892,  1899,
725   1903,  1906,  1908,  1919,  1930,  1935,  1944,  1946,  1950,  1953,
726   1955,  1960,  1965,  1970,  1977,  1979,  1980,  1981,  1984,  1989,
727   1994,  1996,  1997,  1999,  2001,  2002,  2004,  2008,  2011,  2015,
728   2018,  2022,  2024,  2026,  2028,  2029,  2031,  2035,  2044,  2046,
729   2048,  2061,  2063,  2069,  2071,  2073,  2077,  2079,  2084,  2089,
730   2094,  2096,  2098,  2102,  2104,  2109,  2114,  2116,  2120,  2122,
731   2127,  2132,  2137,  2139,  2141,  2145,  2147,  2152,  2157,  2162,
732   2167,  2169,  2171,  2173,  2175,  2177,  2181,  2183,  2188,  2193,
733   2195,  2199,  2201,  2206,  2210,  2212,  2217,  2221,  2223,  2228,
734   2232,  2234,  2239,  2243,  2245,  2250,  2254,  2256,  2261,  2267,
735   2269,  2273,  2275,  2278,  2281,  2289,  2291,  2292,  2295,  2297,
736   2300,  2304
737 };
738 #endif
739
740
741 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
742
743 static const char * const yytname[] = {   "$","error","$undefined.","PLUS_TK",
744 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
745 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
746 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
747 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
748 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
749 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
750 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
751 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
752 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
753 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
754 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
755 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
756 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
757 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
758 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
759 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
760 "class_type","interface_type","array_type","name","simple_name","qualified_name",
761 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
762 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
763 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
764 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
765 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
766 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
767 "method_declarator","formal_parameter_list","formal_parameter","throws","class_type_list",
768 "method_body","static_initializer","static","constructor_declaration","@4","constructor_header",
769 "constructor_declarator","constructor_body","constructor_block_end","explicit_constructor_invocation",
770 "this_or_super","interface_declaration","@5","@6","@7","@8","extends_interfaces",
771 "interface_body","interface_member_declarations","interface_member_declaration",
772 "constant_declaration","abstract_method_declaration","array_initializer","variable_initializers",
773 "block","block_begin","block_end","block_statements","block_statement","local_variable_declaration_statement",
774 "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement",
775 "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
776 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
777 "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups",
778 "switch_block_statement_group","switch_labels","switch_label","while_expression",
779 "while_statement","while_statement_nsi","do_statement_begin","do_statement",
780 "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update",
781 "statement_expression_list","break_statement","continue_statement","return_statement",
782 "throw_statement","synchronized_statement","synchronized","try_statement","catches",
783 "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array",
784 "class_instance_creation_expression","something_dot_new","argument_list","array_creation_expression",
785 "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access",
786 "postfix_expression","post_increment_expression","post_decrement_expression",
787 "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus",
788 "cast_expression","multiplicative_expression","additive_expression","shift_expression",
789 "relational_expression","equality_expression","and_expression","exclusive_or_expression",
790 "inclusive_or_expression","conditional_and_expression","conditional_or_expression",
791 "conditional_expression","assignment_expression","assignment","left_hand_side",
792 "assignment_operator","expression","constant_expression", NULL
793 };
794 #endif
795
796 static const short yyr1[] = {     0,
797    110,   111,   111,   111,   111,   111,   111,   112,   112,   113,
798    113,   113,   114,   114,   115,   116,   117,   118,   118,   118,
799    118,   118,   119,   119,   120,   121,   122,   123,   123,   123,
800    123,   123,   123,   123,   123,   124,   124,   125,   125,   126,
801    126,   126,   127,   127,   128,   128,   128,   129,   129,   129,
802    130,   130,   130,   130,   131,   131,   133,   132,   134,   132,
803    132,   132,   132,   132,   135,   135,   135,   135,   136,   136,
804    136,   137,   137,   137,   138,   138,   139,   139,   140,   140,
805    140,   140,   141,   141,   141,   141,   141,   142,   142,   143,
806    143,   143,   144,   144,   144,   144,   145,   145,   145,   145,
807    145,   146,   146,   148,   147,   147,   149,   149,   149,   149,
808    149,   149,   149,   149,   149,   150,   150,   150,   150,   150,
809    151,   151,   151,   152,   152,   152,   152,   153,   153,   153,
810    154,   154,   154,   155,   155,   155,   156,   156,   157,   159,
811    158,   160,   160,   161,   161,   162,   162,   162,   162,   163,
812    163,   164,   164,   164,   164,   165,   165,   167,   166,   168,
813    166,   169,   166,   170,   166,   166,   166,   171,   171,   171,
814    171,   172,   172,   173,   173,   174,   174,   174,   174,   175,
815    176,   176,   177,   177,   177,   178,   178,   178,   179,   179,
816    180,   181,   182,   182,   183,   183,   183,   184,   185,   185,
817    186,   186,   186,   186,   186,   186,   187,   187,   187,   187,
818    187,   188,   188,   188,   188,   188,   188,   188,   188,   188,
819    188,   188,   189,   190,   191,   191,   192,   193,   193,   193,
820    193,   193,   193,   193,   193,   193,   193,   193,   193,   193,
821    194,   194,   194,   194,   194,   194,   194,   195,   195,   195,
822    195,   196,   197,   199,   198,   200,   200,   200,   200,   201,
823    201,   201,   201,   202,   202,   203,   204,   204,   205,   205,
824    205,   205,   205,   206,   207,   207,   207,   207,   208,   209,
825    210,   211,   211,   211,   211,   211,   212,   212,   213,   213,
826    213,   214,   215,   215,   215,   215,   216,   216,   217,   217,
827    217,   218,   218,   218,   218,   219,   219,   219,   219,   220,
828    220,   220,   220,   221,   221,   221,   222,   222,   222,   222,
829    222,   223,   224,   224,   224,   224,   225,   225,   226,   227,
830    227,   227,   227,   228,   228,   229,   229,   230,   230,   230,
831    230,   230,   230,   230,   230,   230,   230,   230,   230,   230,
832    230,   230,   231,   231,   231,   231,   231,   231,   231,   231,
833    231,   231,   231,   231,   231,   231,   232,   232,   233,   233,
834    233,   234,   234,   234,   234,   234,   234,   234,   234,   235,
835    235,   236,   236,   236,   237,   237,   237,   238,   238,   238,
836    239,   239,   239,   239,   239,   239,   239,   239,   240,   240,
837    240,   240,   240,   240,   241,   241,   241,   241,   242,   243,
838    244,   244,   244,   244,   244,   244,   244,   245,   245,   246,
839    246,   247,   247,   247,   247,   247,   247,   248,   248,   248,
840    248,   248,   248,   248,   248,   248,   249,   249,   249,   249,
841    249,   249,   249,   250,   250,   250,   250,   250,   251,   251,
842    251,   251,   251,   251,   251,   252,   252,   252,   252,   252,
843    252,   252,   252,   252,   252,   252,   253,   253,   253,   253,
844    253,   254,   254,   254,   255,   255,   255,   256,   256,   256,
845    257,   257,   257,   258,   258,   258,   259,   259,   259,   259,
846    259,   260,   260,   261,   261,   262,   262,   262,   263,   263,
847    264,   265
848 };
849
850 static const short yyr2[] = {     0,
851      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
852      1,     1,     1,     1,     1,     1,     1,     3,     3,     3,
853      3,     3,     1,     1,     1,     3,     1,     0,     1,     1,
854      1,     2,     2,     2,     3,     1,     2,     1,     2,     3,
855      2,     3,     1,     1,     3,     2,     3,     5,     4,     5,
856      1,     1,     1,     1,     1,     2,     0,     7,     0,     6,
857      3,     2,     3,     4,     0,     2,     3,     2,     0,     2,
858      2,     1,     3,     3,     2,     3,     1,     2,     1,     1,
859      1,     1,     1,     2,     1,     1,     1,     3,     4,     1,
860      3,     3,     1,     3,     3,     4,     1,     3,     2,     3,
861      3,     1,     1,     0,     3,     2,     3,     3,     4,     4,
862      2,     3,     2,     3,     2,     3,     4,     3,     3,     3,
863      1,     3,     3,     2,     3,     2,     3,     0,     2,     2,
864      1,     3,     3,     1,     2,     1,     2,     3,     1,     0,
865      3,     2,     3,     3,     4,     2,     3,     3,     4,     1,
866      2,     4,     5,     7,     6,     1,     1,     0,     4,     0,
867      5,     0,     5,     0,     6,     3,     4,     2,     3,     2,
868      3,     2,     3,     1,     2,     1,     1,     1,     1,     1,
869      2,     2,     2,     3,     4,     1,     3,     3,     2,     3,
870      1,     1,     1,     2,     1,     1,     1,     2,     2,     3,
871      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
872      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
873      1,     1,     1,     2,     2,     2,     2,     2,     2,     2,
874      2,     3,     4,     4,     5,     4,     5,     6,     7,     6,
875      1,     1,     1,     1,     1,     1,     1,     5,     2,     3,
876      4,     7,     7,     0,     3,     4,     2,     3,     5,     2,
877      3,     3,     4,     1,     2,     2,     1,     2,     3,     2,
878      2,     3,     2,     4,     2,     2,     3,     4,     2,     1,
879      7,     7,     6,     3,     5,     4,     7,     6,     2,     2,
880      3,     2,     0,     1,     1,     2,     0,     1,     1,     3,
881      3,     2,     3,     2,     3,     2,     3,     2,     3,     2,
882      3,     2,     3,     3,     2,     3,     5,     5,     2,     4,
883      3,     1,     3,     3,     4,     2,     1,     2,     2,     4,
884      2,     3,     4,     2,     2,     1,     1,     1,     1,     3,
885      1,     1,     1,     1,     3,     3,     3,     3,     3,     3,
886      3,     3,     5,     4,     6,     5,     4,     5,     5,     6,
887      3,     3,     4,     5,     2,     3,     3,     3,     1,     3,
888      3,     3,     3,     4,     4,     4,     4,     3,     3,     1,
889      2,     3,     3,     2,     2,     3,     3,     3,     3,     2,
890      3,     4,     5,     6,     5,     6,     4,     4,     4,     4,
891      3,     4,     3,     4,     1,     1,     1,     1,     2,     2,
892      1,     1,     2,     2,     1,     2,     2,     2,     2,     2,
893      2,     1,     2,     2,     1,     2,     2,     5,     4,     4,
894      5,     4,     2,     5,     4,     5,     1,     3,     3,     3,
895      3,     3,     3,     1,     3,     3,     3,     3,     1,     3,
896      3,     3,     3,     3,     3,     1,     3,     3,     3,     3,
897      3,     3,     3,     3,     3,     3,     1,     3,     3,     3,
898      3,     1,     3,     3,     1,     3,     3,     1,     3,     3,
899      1,     3,     3,     1,     3,     3,     1,     5,     4,     3,
900      5,     1,     1,     3,     3,     1,     1,     1,     1,     1,
901      1,     1
902 };
903
904 static const short yydefact[] = {     0,
905     54,    55,     0,     0,     0,     0,    53,     1,     0,     0,
906      0,    36,    43,    44,    38,     0,    51,    52,    46,    27,
907      0,    23,    24,    25,     0,    62,     0,    41,     0,     0,
908     37,    39,     0,     0,    56,     0,     0,    47,    45,     0,
909    166,     0,     0,   162,    63,     0,    69,    42,    40,     0,
910      0,     0,    61,     0,    49,     0,    26,   170,    17,   168,
911     15,     0,   159,     0,     0,    68,    16,     0,     0,    59,
912    167,     0,   164,    64,    69,    50,    48,    12,     0,    10,
913     11,   172,     0,     8,     9,    13,    14,    15,     0,   178,
914    180,     0,   179,     0,   174,   176,   177,   171,   169,   163,
915     67,    71,    72,    70,     0,   161,     0,    57,   113,     0,
916    128,   111,     0,     0,    90,    93,   128,     0,     0,     0,
917    115,     0,     0,   182,   181,   173,   175,     0,     0,    60,
918    165,     0,     0,     0,     0,   108,    99,    88,     0,     0,
919      0,     0,   107,    21,    18,    22,    20,    19,   114,   128,
920    112,     0,   128,    74,    73,    55,   191,    75,    23,     0,
921     86,     0,    77,    79,    83,    85,     0,    80,     0,    81,
922    140,   128,    87,    82,     0,    58,   119,   116,     0,     0,
923      0,   121,   130,   131,   129,   120,   118,    92,     0,    91,
924     95,     0,     0,     0,     0,     0,     0,     0,   339,     0,
925      0,     0,     0,     6,     5,     2,     3,     4,     7,   338,
926      0,   406,     0,   103,   405,   336,   341,     0,   337,   342,
927    343,   344,   422,   407,   408,   437,   411,   412,   415,   425,
928    444,   449,   456,   467,   472,   475,   478,   481,   484,   487,
929    492,   501,   493,     0,   102,   100,    98,   101,   110,    89,
930    109,   189,     0,   128,    76,    78,    84,   106,     0,   137,
931      0,   142,     0,    55,     0,     0,   280,     0,     0,     0,
932      0,     0,     0,     0,     0,   339,     0,   223,     0,     8,
933    406,     0,     0,   197,     0,   212,     0,   193,   195,     0,
934    196,   201,   213,     0,   202,   214,     0,   203,   204,   215,
935    254,     0,   205,     0,   216,   206,   293,     0,   217,   218,
936    219,   221,   220,     0,   222,   247,   246,     0,   244,   245,
937    242,   243,   241,   126,   124,     0,   117,     0,     0,   416,
938    406,   342,   344,   413,   417,   414,   421,   420,   419,   418,
939      0,   390,     0,     0,     0,    16,     0,   426,   423,   427,
940    424,   433,     0,   406,     0,   183,   186,     0,     0,     0,
941      0,     0,    96,     0,     0,   365,     0,   410,   409,     0,
942      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
943      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
944    499,   500,     0,   144,     0,   143,   136,   105,   134,   138,
945    191,   141,     0,   230,   231,   229,   249,     0,   315,     0,
946    304,   302,     0,   312,   310,     0,   276,     0,   257,     0,
947    326,     0,   290,     0,   308,   306,     0,     0,   199,     0,
948      0,   226,   224,     0,     0,   192,   190,   194,   198,   322,
949    406,   225,   228,     0,   275,     0,   406,     0,   295,   299,
950    292,     0,     0,   319,     0,   127,   125,   123,   122,   133,
951    132,   352,   347,     0,   389,   379,   378,   361,     0,   372,
952    380,     0,   373,     0,   362,     0,     0,     0,     0,     0,
953      0,   349,   340,   184,     0,   351,   346,   391,     0,   369,
954    401,     0,   350,   345,   367,   348,   368,   388,   403,     0,
955    366,     0,   441,   438,   442,   439,   443,   440,   447,   445,
956    448,   446,   453,   450,   454,   451,   455,   452,   463,   458,
957    465,   460,   462,   457,   464,   459,   466,     0,   461,   470,
958    468,   471,   469,   474,   473,   477,   476,   480,   479,   483,
959    482,   486,   485,   490,     0,     0,   495,   494,   145,   135,
960    406,   146,     0,     0,   150,     0,   250,     0,   316,   314,
961    305,   303,   313,   311,   277,     0,   258,     0,     0,     0,
962    323,   327,     0,   324,   291,   309,   307,   340,     0,   200,
963    232,     0,     0,     0,   255,     0,   296,     0,   284,     0,
964      0,   321,     0,   397,   398,     0,   384,   385,     0,   381,
965    374,     0,   377,   375,   376,   363,   354,     0,   435,   429,
966    432,     0,     0,   430,   188,   185,   187,   392,     0,   402,
967    399,     0,   404,   400,   357,     0,   489,     0,     0,   147,
968      0,     0,   151,   148,   251,     0,   278,   274,     0,   331,
969      0,   335,   334,   328,   325,   329,   236,     0,   233,   234,
970      0,     0,     0,   260,     0,   264,     0,   267,     0,   301,
971    300,   286,     0,   298,     0,   320,     0,   395,     0,   383,
972    382,   387,   386,   356,   364,   353,   434,   428,   436,   431,
973    371,   370,   393,     0,   358,   359,   491,   488,     0,   149,
974      0,     0,     0,   248,     0,   201,     0,   208,   209,     0,
975    210,   211,     0,   259,   332,     0,   237,     0,     0,   235,
976    273,   270,   271,   502,     0,   262,   265,     0,   261,     0,
977    268,     0,     0,   285,     0,   318,   317,   396,   355,   394,
978    360,     0,   152,     0,     0,     0,   227,   279,     0,   333,
979    330,   240,   238,     0,   272,   269,   263,     0,   283,     0,
980      0,     0,   153,     0,   252,     0,     0,   239,   281,   282,
981    155,     0,     0,     0,     0,   154,     0,     0,     0,     0,
982    288,     0,   253,   287,     0,     0,     0
983 };
984
985 static const short yydefgoto[] = {   775,
986    210,   279,   211,    85,    86,    68,    60,    87,   212,    22,
987     23,    24,     8,     9,    10,    11,    12,    13,    14,    15,
988    283,   284,   132,   105,    47,    70,   104,   130,   162,   163,
989    164,    91,   114,   115,   116,   213,   166,   259,    92,   111,
990    181,   182,   136,   185,   398,   168,   169,   170,   261,   171,
991    172,   402,   552,   553,   285,    18,    43,    72,    65,   107,
992     44,    63,    94,    95,    96,    97,   214,   358,   286,   175,
993    555,   720,   288,   289,   290,   291,   695,   292,   293,   294,
994    295,   698,   296,   297,   298,   299,   699,   300,   444,   301,
995    585,   655,   656,   657,   658,   302,   303,   701,   304,   305,
996    306,   702,   307,   308,   451,   663,   664,   309,   310,   311,
997    312,   313,   314,   315,   571,   572,   573,   574,   215,   216,
998    217,   218,   489,   219,   470,   471,   472,   220,   221,   222,
999    223,   224,   225,   226,   227,   228,   229,   230,   231,   232,
1000    233,   234,   235,   236,   237,   238,   239,   240,   241,   242,
1001    243,   244,   393,   490,   715
1002 };
1003
1004 static const short yypact[] = {   507,
1005 -32768,-32768,    15,   -30,    18,   244,-32768,-32768,   414,   443,
1006    556,-32768,-32768,-32768,-32768,   714,-32768,-32768,-32768,-32768,
1007     23,-32768,-32768,-32768,   359,-32768,   340,-32768,    49,   601,
1008 -32768,-32768,   585,   603,-32768,   -30,   417,-32768,-32768,    92,
1009 -32768,   489,   -24,   107,-32768,   529,   295,-32768,-32768,   -30,
1010    710,   452,-32768,   344,-32768,    40,-32768,-32768,-32768,-32768,
1011    192,  1047,-32768,   530,   -24,-32768,-32768,   388,   534,-32768,
1012 -32768,   -24,   107,-32768,   295,-32768,-32768,-32768,   540,-32768,
1013 -32768,-32768,   548,   258,-32768,-32768,   307,   442,   736,-32768,
1014 -32768,    77,-32768,  1638,-32768,-32768,-32768,-32768,-32768,-32768,
1015 -32768,-32768,-32768,   312,   406,-32768,   -24,-32768,-32768,   379,
1016    -18,-32768,   426,   331,-32768,   693,   -18,   120,   210,   429,
1017 -32768,   564,   587,-32768,-32768,-32768,-32768,   593,   951,-32768,
1018 -32768,   406,   607,   617,   214,-32768,-32768,-32768,   618,  1077,
1019    219,   531,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   -18,
1020 -32768,   361,   -18,-32768,-32768,   460,   471,-32768,   494,   736,
1021 -32768,  1204,-32768,-32768,   500,-32768,   180,-32768,   535,-32768,
1022 -32768,   591,-32768,-32768,  1759,-32768,-32768,-32768,   620,   728,
1023    377,-32768,-32768,-32768,   613,-32768,-32768,-32768,   157,-32768,
1024 -32768,  2663,  2728,  2779,  2844,   655,    32,   707,-32768,  2895,
1025   2960,  3011,  5025,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1026    673,   881,    56,-32768,   678,   746,-32768,   640,-32768,   671,
1027 -32768,   715,   866,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1028    899,   921,  1006,   838,   920,   654,   814,   820,   847,   263,
1029 -32768,-32768,-32768,   850,-32768,-32768,-32768,-32768,-32768,-32768,
1030 -32768,-32768,   963,   591,-32768,-32768,-32768,-32768,   484,   769,
1031    775,-32768,    -1,   306,   353,  3076,-32768,   232,  1357,    35,
1032    392,   419,   228,   424,   234,   779,  5324,-32768,   -30,   538,
1033    974,   265,   872,-32768,   784,-32768,  1691,-32768,-32768,   789,
1034 -32768,-32768,-32768,  1827,-32768,-32768,   797,-32768,-32768,-32768,
1035 -32768,  1827,-32768,  1827,-32768,-32768,  5375,   802,-32768,-32768,
1036 -32768,-32768,-32768,   427,-32768,   737,   806,   866,   902,   916,
1037 -32768,-32768,-32768,-32768,   891,   642,-32768,   592,   660,-32768,
1038    189,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1039    409,-32768,   666,   964,   793,   793,   428,-32768,-32768,-32768,
1040 -32768,-32768,   777,  1121,    66,-32768,-32768,   622,   432,  5092,
1041   3127,   729,-32768,   -28,  3192,-32768,   435,-32768,-32768,  3243,
1042   3308,  3359,  3424,  3475,  3540,  3591,  3656,  3707,  3772,  3823,
1043   3888,   864,  3939,  4004,  4055,  4120,  4171,  4236,  4287,  2032,
1044 -32768,-32768,  4352,-32768,   605,-32768,-32768,-32768,   810,-32768,
1045 -32768,-32768,  1691,-32768,-32768,-32768,-32768,  4403,-32768,    95,
1046 -32768,-32768,   126,-32768,-32768,   174,-32768,  4468,-32768,  4519,
1047 -32768,   785,-32768,  4933,-32768,-32768,   182,   269,   815,  2083,
1048    604,-32768,-32768,   -30,  2148,-32768,-32768,-32768,-32768,-32768,
1049   1158,-32768,-32768,   823,-32768,   861,  1018,   728,-32768,-32768,
1050 -32768,    86,  2199,-32768,  4584,-32768,   891,-32768,-32768,-32768,
1051 -32768,-32768,-32768,   565,   836,-32768,-32768,-32768,  2264,   793,
1052 -32768,   590,   793,   590,-32768,  2315,  4635,   223,   -43,  2380,
1053    191,-32768,   894,-32768,  1967,-32768,-32768,-32768,   649,-32768,
1054 -32768,   237,-32768,-32768,-32768,-32768,-32768,   839,-32768,   239,
1055 -32768,  5143,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   899,
1056 -32768,   899,-32768,   921,-32768,   921,-32768,   921,-32768,  1006,
1057 -32768,  1006,-32768,  1006,-32768,  1006,-32768,   258,-32768,-32768,
1058    838,-32768,   838,-32768,   920,-32768,   654,-32768,   814,-32768,
1059    820,-32768,   847,-32768,   933,   857,-32768,-32768,-32768,-32768,
1060   1254,-32768,  1691,   859,   856,  1691,-32768,   314,-32768,-32768,
1061 -32768,-32768,-32768,-32768,-32768,   348,-32768,   870,   461,   229,
1062    785,-32768,   535,-32768,-32768,-32768,-32768,-32768,   467,   815,
1063 -32768,   967,    14,   444,-32768,   878,-32768,  5067,-32768,  4958,
1064    876,   887,   892,-32768,-32768,  5208,-32768,-32768,   241,-32768,
1065    895,   299,-32768,   895,-32768,-32768,   406,    17,-32768,-32768,
1066 -32768,  4700,   487,-32768,-32768,-32768,-32768,-32768,  4751,-32768,
1067 -32768,  5259,-32768,-32768,   406,   704,-32768,  4816,   662,-32768,
1068   1691,  2431,-32768,-32768,-32768,  1893,-32768,-32768,   343,-32768,
1069    835,-32768,-32768,-32768,-32768,-32768,-32768,  2496,-32768,-32768,
1070    999,    91,  4867,-32768,   674,-32768,  1467,-32768,  5324,-32768,
1071 -32768,-32768,   928,   923,  5000,-32768,   410,-32768,   723,-32768,
1072 -32768,-32768,-32768,-32768,-32768,   406,-32768,-32768,-32768,-32768,
1073 -32768,-32768,-32768,   731,-32768,   406,-32768,-32768,   477,-32768,
1074    243,   108,   485,-32768,   978,   979,  1893,-32768,-32768,  1893,
1075 -32768,-32768,   942,-32768,   948,   950,-32768,  1053,   128,-32768,
1076 -32768,-32768,-32768,-32768,   328,-32768,-32768,  1540,-32768,  1608,
1077 -32768,   961,  1827,-32768,   970,-32768,-32768,-32768,-32768,-32768,
1078 -32768,  2547,-32768,   262,  4403,  1827,-32768,-32768,  2612,-32768,
1079 -32768,-32768,-32768,  1071,-32768,-32768,-32768,   980,-32768,  1827,
1080    296,   202,-32768,   358,-32768,  4958,   983,-32768,-32768,-32768,
1081 -32768,   302,  1893,   990,  5000,-32768,  1021,  1893,   992,  1893,
1082 -32768,  1893,-32768,-32768,  1087,  1089,-32768
1083 };
1084
1085 static const short yypgoto[] = {-32768,
1086 -32768,   -57,   -60,   711,   -16,  -123,   568,-32768,    -3,   552,
1087 -32768,   130,-32768,  1085,   791,-32768,    22,-32768,-32768,   778,
1088     12,   154,-32768,-32768,  1044,  1030,-32768,  -128,-32768,   945,
1089 -32768,   382,  -106,   973,  -165,  -193,-32768,-32768,   469,   -58,
1090    865,  -327,   -40,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1091    957,-32768,   142,-32768,   718,   -10,-32768,-32768,-32768,-32768,
1092   1072,   584,-32768,  1031,-32768,-32768,   372,-32768,  -122,   867,
1093    843,  -166,  -279,-32768,   819,  -234,   197,  -551,-32768,  -529,
1094 -32768,-32768,-32768,  -301,-32768,-32768,-32768,-32768,-32768,-32768,
1095 -32768,-32768,   476,   486,  -619,  -496,-32768,-32768,-32768,-32768,
1096 -32768,-32768,-32768,  -436,-32768,  -603,   832,-32768,-32768,-32768,
1097 -32768,-32768,-32768,-32768,-32768,   569,-32768,   573,-32768,-32768,
1098    119,-32768,  -386,-32768,   799,   362,  -326,   858,   163,  1120,
1099    320,   437,   438,  -112,   560,   636,  -470,-32768,   632,   724,
1100    651,   625,   761,   765,   760,   764,   776,-32768,   526,   771,
1101    717,-32768,-32768,    29,-32768
1102 };
1103
1104
1105 #define YYLAST          5484
1106
1107
1108 static const short yytable[] = {    21,
1109    459,    84,    29,   176,    83,   450,   174,   438,   287,   357,
1110    184,    16,   614,   325,   650,    19,   152,   675,    26,   474,
1111     16,    16,    16,    38,   117,    59,   479,   481,    84,    67,
1112     31,   123,   342,    84,   134,   342,    83,   721,    61,   174,
1113     76,    16,    61,   497,    16,    16,   260,    59,   583,    48,
1114    612,    93,    59,   602,    31,    20,   363,    20,    88,   442,
1115     61,   725,    16,   150,   153,    61,   482,   445,    84,   446,
1116     62,    83,    84,    89,   347,   179,   143,   124,   135,   334,
1117    336,   338,   340,    93,   696,    88,   587,   349,   351,   608,
1118     88,   711,    55,   404,   405,   559,    56,   406,   721,    84,
1119     20,    84,   123,    20,    83,    89,   697,   651,   650,   249,
1120    676,    59,   251,   619,   280,   626,   619,    67,   173,    84,
1121    144,    39,   326,    40,    61,    88,   561,  -157,   743,    88,
1122     61,   262,   343,    25,    27,   343,   399,   345,    77,   700,
1123    160,   353,   680,   601,   180,   696,   604,    49,   696,    50,
1124    422,   173,   764,    17,   -94,   -94,    88,   137,    88,   483,
1125    457,   769,    17,    17,    17,    52,    54,   697,   245,    57,
1126    697,   281,   429,   160,   563,   125,    88,    20,   712,    57,
1127    258,   346,   576,    17,  -294,   588,    17,    17,   331,   331,
1128    331,   331,    84,   560,    61,   179,   331,   331,   354,   703,
1129    700,   734,   743,   700,    17,   461,    64,   619,   110,   669,
1130    146,   696,   113,   396,   186,    90,   696,   145,   696,   246,
1131    696,   744,    84,   611,   562,   434,   280,   619,   421,   642,
1132    355,   245,   411,   697,   425,   684,   556,   620,   697,   623,
1133    697,   670,   697,   649,    28,   692,   280,    90,   -97,    88,
1134    -97,   110,   113,   -97,   -97,   -97,   -97,   504,   506,   508,
1135    703,   709,   710,   703,   180,   432,   700,    84,   189,   482,
1136    179,   700,   564,   700,  -104,   700,   438,   389,  -104,    88,
1137    577,   360,   161,   281,   613,   361,   661,   602,   450,   362,
1138    441,   617,    50,   316,   410,   762,   742,   416,   441,   672,
1139    441,   619,   758,   447,   282,   428,  -322,   147,   189,   -25,
1140    -25,   187,    67,   706,   635,   161,   247,    20,   448,    20,
1141    598,   528,   157,   157,    88,    61,   703,   580,   745,    20,
1142    412,   703,   426,   703,   621,   703,   624,   317,   671,   180,
1143     45,   733,   280,   704,    74,   752,    69,   367,   637,   390,
1144    -25,   438,   433,   407,   118,   -25,   -25,   -25,   635,    41,
1145    753,   -25,   578,   450,   610,   -25,   331,   331,   331,   331,
1146    331,   331,   331,   331,   331,   331,   331,   331,    88,   331,
1147    331,   331,   331,   331,   331,   331,   631,    84,   101,   492,
1148    434,   -65,   417,   500,   761,   -65,   673,   413,  -322,   551,
1149    766,   694,    46,   119,   427,   316,    46,   636,   189,   462,
1150    726,   128,   316,   -30,     1,   746,   282,    53,   546,   419,
1151    316,    42,   316,   282,   423,   316,   137,   454,   475,   138,
1152    139,   282,   486,   282,   -65,   501,   558,  -256,   -65,   -66,
1153    438,   638,   -31,     1,    88,   408,   566,   643,   568,   317,
1154    646,   763,    71,  -158,   450,   189,   317,     2,   492,   250,
1155    139,   640,   442,   450,   317,   445,   317,   647,     3,   317,
1156    327,   133,   465,   331,     4,   463,   328,   647,   674,   331,
1157      5,   591,   -66,   593,   418,   407,     2,   679,   749,    58,
1158    652,    57,   280,   498,   318,   280,   685,   599,   487,   678,
1159    129,   755,    20,     4,   157,   653,   -28,     1,   492,     5,
1160    165,   420,     7,   245,    42,   760,   424,   -97,   133,   455,
1161    476,   316,   -97,   -97,   -97,   -97,   148,   502,   694,    66,
1162     98,   248,   282,   749,   102,   755,    78,   760,   120,   654,
1163    109,     7,    50,   165,   727,   196,  -160,   729,   112,   281,
1164      2,   197,   281,   641,  -139,   -29,     1,   731,   198,   648,
1165     57,     3,   199,   189,   149,   317,   252,     4,    80,   732,
1166    280,    81,    20,     5,    20,   200,   201,   735,   157,   202,
1167     84,     6,   397,   179,   -32,     1,   253,   151,   204,   205,
1168    206,   207,   458,   154,   208,   209,   280,   167,   257,     2,
1169    -34,     1,   -33,     1,   493,     7,   318,   177,   331,   331,
1170      3,   319,   320,   318,    20,    20,     4,   183,   188,    20,
1171    324,   318,     5,   318,   331,    20,   318,   281,     2,   157,
1172    167,    99,   441,    20,   118,     2,   103,    88,   359,     3,
1173    366,    78,   456,   134,     2,     4,     2,   682,   100,    20,
1174      2,     5,   180,   281,     7,   106,    78,   280,   594,   280,
1175    460,     4,   493,     4,   385,   595,   464,     5,   579,     5,
1176    494,   316,    20,    80,   316,   495,    81,    20,    20,   496,
1177    159,   714,   282,     7,   203,   282,   602,   722,    80,    20,
1178    131,    81,    20,   441,   630,   155,   441,   634,   549,     7,
1179    178,     7,    20,    20,   328,    20,   316,   344,   316,   -35,
1180      1,   159,   329,   159,   281,   317,   281,   484,   317,   441,
1181    652,   485,   318,   319,   320,    20,   689,    20,   494,   493,
1182    319,   320,   441,   495,   321,   653,   121,   496,   319,   320,
1183    319,   320,   618,   319,   320,    20,   441,    20,   619,   316,
1184    317,    20,   317,     2,   316,   341,    78,    35,    57,   441,
1185    282,  -497,  -497,   754,   441,   282,   441,   757,   441,   716,
1186      4,    35,   690,   359,    36,   316,     5,    78,   364,    35,
1187     37,  -341,  -341,   316,   140,    78,   282,    32,    80,   141,
1188    142,    81,    20,   317,   122,   494,    36,   686,   317,    30,
1189    495,    34,    37,   619,   496,  -498,  -498,    32,     7,    80,
1190    322,    32,    81,    20,    20,   316,   728,    80,   316,   317,
1191     81,    20,   619,    51,   730,   386,   282,   317,    32,   282,
1192    619,   600,   387,  -341,   600,   705,   316,  -341,   316,   319,
1193    320,   316,   365,   603,   569,   605,   321,   282,   570,   282,
1194   -343,  -343,   282,   321,   316,   378,   379,   380,   381,   317,
1195    388,   321,   317,   321,   527,   282,   321,   400,   316,   401,
1196    477,  -156,   318,   478,   316,   318,   435,   359,     2,   282,
1197    317,   316,   317,   316,    78,   317,   316,   439,   316,   469,
1198    316,   323,   282,   737,   382,   443,   738,   282,   317,   282,
1199    453,   282,  -343,   370,   371,   372,  -343,   318,   550,   318,
1200    368,   369,   317,    78,   139,    35,    80,   584,   317,    81,
1201     20,    78,   322,   373,   374,   317,   586,   317,   596,   322,
1202    317,   622,   317,   627,   317,   383,   384,   322,    37,   322,
1203    391,   392,   322,    78,   628,    80,  -407,  -407,    81,    20,
1204    318,   632,   196,    80,   633,   318,    81,    20,   197,   767,
1205   -408,  -408,   321,   639,   771,   198,   773,   649,   774,   199,
1206    659,  -496,  -496,   360,   665,    80,   318,   361,    81,    20,
1207    666,   362,   200,   201,   318,   667,   202,   141,   142,   319,
1208    320,   602,   319,   320,   156,   204,   205,   206,   207,   710,
1209     78,   208,   209,   323,   510,   512,     2,   531,   533,    79,
1210    323,     4,    78,   375,   376,   377,   318,     5,   323,   318,
1211    323,   723,   588,   323,   319,   320,   319,   320,   520,   522,
1212    524,   526,    80,   736,  -207,    81,    20,   318,   322,   318,
1213    739,   740,   318,   741,    80,   157,   158,    81,    20,   332,
1214    332,   332,   332,   742,   748,   318,   394,   332,   332,   -15,
1215    466,   467,   468,   750,  -496,  -496,   360,   319,   320,   318,
1216    430,   758,   319,   320,   431,   318,   770,   191,   759,   192,
1217    193,   765,   318,   768,   318,   772,   776,   318,   777,   318,
1218      2,   318,   529,   319,   320,    33,    78,    75,   514,   516,
1219    518,   319,   320,   -15,   108,    79,   256,     4,  -496,  -496,
1220    360,   190,   321,     5,   430,   321,   254,   395,   362,   323,
1221    554,   194,   195,    73,   127,   449,    78,   403,    80,   437,
1222    717,    81,    20,   319,   320,   196,   319,   320,   452,   644,
1223    718,   197,    82,   645,   473,   535,   539,   321,   198,   321,
1224    537,   541,   199,   688,   319,   320,   319,   320,    80,   319,
1225    320,    81,    20,   548,   543,   200,   201,     0,     0,   202,
1226      0,   203,   319,   320,     0,     0,     0,     0,   204,   205,
1227    206,   207,     0,     0,   208,   209,   319,   320,   322,     0,
1228    321,   322,   319,   320,     0,   321,     0,     0,     0,   319,
1229    320,   319,   320,     0,   319,   320,   319,   320,   319,   320,
1230      0,  -496,  -496,   360,     0,     0,   321,   480,     0,     0,
1231      0,   362,     0,   322,   321,   322,     0,   332,   332,   332,
1232    332,   332,   332,   332,   332,   332,   332,   332,   332,     0,
1233    332,   332,   332,   332,   332,   332,   332,   156,  -496,  -496,
1234    360,     0,     0,    78,   361,     0,   321,     0,   431,   321,
1235      0,     0,    79,     0,     4,     0,   322,     0,     0,   323,
1236      5,   322,   323,     0,     0,     0,     0,   321,     0,   321,
1237      0,     0,   321,     0,     0,    80,     0,     0,    81,    20,
1238      0,     0,   322,     0,     0,   321,     0,     0,   157,   255,
1239    322,     0,     0,     0,   323,     0,   323,     0,     0,   321,
1240      0,   333,   333,   333,   333,   321,     0,     0,     0,   333,
1241    333,     0,   321,     0,   321,     0,     0,   321,     0,   321,
1242      0,   321,   322,     0,   332,   322,     0,     0,     0,   -15,
1243    332,     0,     0,     0,  -496,  -496,   360,   323,     0,     0,
1244    430,     0,   323,   322,   629,   322,     0,   414,   322,   192,
1245    193,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1246      0,   322,     0,   323,     0,     0,     0,     0,     0,     0,
1247      0,   323,     0,     0,     0,   322,     0,     0,     0,     0,
1248      0,   322,     0,     0,     0,     0,     0,     0,   322,     0,
1249    322,   194,   195,   322,     0,   322,    78,   322,     0,     0,
1250      0,     0,     0,   323,     0,   196,   323,     0,     0,     0,
1251      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1252      0,     0,   199,     0,   323,     0,   323,     0,    80,   323,
1253      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1254      0,     0,   323,     0,     0,   415,     0,     0,   204,   205,
1255    206,   207,     0,     0,   208,   209,   323,   263,     0,   332,
1256    332,     0,   323,     0,     0,     0,     0,     0,     0,   323,
1257      0,   323,     0,     0,   323,   332,   323,     0,   323,   333,
1258    333,   333,   333,   333,   333,   333,   333,   333,   333,   333,
1259    333,     0,   333,   333,   333,   333,   333,   333,   333,     0,
1260    264,   194,   195,   652,   265,   266,    78,   267,     0,     0,
1261    268,     0,     0,     0,   269,   196,     0,     0,   653,     0,
1262      0,   270,   271,     5,   272,     0,   273,   274,   198,   275,
1263    263,     0,   276,     0,     0,     0,     0,     0,    80,     0,
1264      0,    81,    20,     0,     0,     0,     0,     0,     0,   277,
1265      0,   157,   719,     0,     0,   278,     0,     0,   204,   205,
1266    206,   207,     0,     0,   208,   209,     0,     0,     0,     0,
1267      0,     0,     0,   264,   194,   195,   652,   265,   266,    78,
1268    267,     0,     0,   268,     0,     0,   333,   269,   196,     0,
1269      0,   653,   333,     0,   270,   271,     5,   272,   263,   273,
1270    274,   198,   275,     0,     0,   276,     0,     0,     0,     0,
1271      0,    80,     0,     0,    81,    20,     0,     0,     0,     0,
1272      0,     0,   277,     0,   157,   747,     0,     0,   278,     0,
1273      0,   204,   205,   206,   207,     0,     0,   208,   209,     0,
1274      0,   264,   194,   195,  -266,   265,   266,    78,   267,     0,
1275      0,   268,     0,     0,     0,   269,   196,     0,     0,  -266,
1276      0,     0,   270,   271,     5,   272,     0,   273,   274,   198,
1277    275,     2,     0,   276,     0,     0,     0,    78,     0,    80,
1278      0,   263,    81,    20,     0,     0,    79,     0,     4,     0,
1279    277,     0,   157,  -266,     5,     0,   278,     0,     0,   204,
1280    205,   206,   207,     0,     0,   208,   209,     0,     0,    80,
1281      0,     0,    81,    20,     0,     0,     0,     0,     0,     0,
1282      0,   333,   333,   126,   264,   194,   195,     0,   265,   266,
1283     78,   267,     0,     0,   268,     0,     0,   333,   269,   196,
1284      0,     0,     0,     0,     0,   270,   271,     5,   272,   263,
1285    273,   274,   198,   275,     0,     0,   276,     0,     0,     0,
1286      0,     0,    80,     0,     0,    81,    20,     0,     0,     0,
1287      0,     0,     0,   277,     0,   157,   436,     0,     0,   278,
1288      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1289      0,     0,   264,   194,   195,     0,   265,   266,    78,   267,
1290      0,     0,   268,     0,     0,     0,   269,   196,     0,     0,
1291      0,     0,     0,   270,   271,     5,   272,   263,   273,   274,
1292    198,   275,     0,     0,   276,     0,     0,     0,     0,     0,
1293     80,     0,     0,    81,    20,     0,     0,     0,     0,     0,
1294      0,   277,     0,   157,     0,     0,     0,   278,     0,     0,
1295    204,   205,   206,   207,     0,     0,   208,   209,     0,     0,
1296    440,   194,   195,     0,   265,   266,    78,   267,     0,     0,
1297    268,     0,     0,     0,   269,   196,     0,     0,     0,     0,
1298      0,   270,   271,   263,   272,     0,   273,   274,   198,   275,
1299      0,     0,   276,     0,     0,     0,     0,     0,    80,     0,
1300      0,    81,    20,     0,     0,     0,     0,     0,     0,   277,
1301      0,   157,     0,     0,     0,   278,     0,     0,   204,   205,
1302    206,   207,     0,     0,   208,   209,   440,   194,   195,     0,
1303    693,   266,    78,   267,     0,     0,   268,     0,     0,     0,
1304    269,   196,     0,     0,     0,     0,     0,   270,   271,     0,
1305    272,     0,   273,   274,   198,   275,     0,   615,   276,   192,
1306    193,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1307      0,     0,     0,     0,     0,   277,     0,   157,     0,     0,
1308      0,   278,     0,     0,   204,   205,   206,   207,     0,     0,
1309    208,   209,     0,     0,     0,     0,     0,     0,     0,     0,
1310      0,   194,   195,     0,     0,     0,    78,     0,     0,     0,
1311      0,     0,     0,     0,     0,   196,     0,     0,     0,     0,
1312      0,   197,   544,     0,   192,   193,     0,     0,   198,     0,
1313      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1314      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1315      0,   203,   616,     0,     0,     0,     0,     0,   204,   205,
1316    206,   207,     0,     0,   208,   209,   194,   195,     0,     0,
1317      0,    78,     0,   491,     0,   192,   193,     0,     0,     0,
1318    196,     0,     0,     0,     0,     0,   197,     0,     0,     0,
1319      0,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1320      0,     0,     0,    80,     0,     0,    81,    20,     0,   545,
1321    200,   201,     0,     0,   202,     0,     0,   194,   195,     0,
1322      0,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1323    209,   196,     0,     0,     0,     0,     0,   197,   581,     0,
1324    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1325      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1326      0,   200,   201,     0,     0,   202,     0,     0,     0,     0,
1327    148,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1328    208,   209,   194,   195,     0,     0,     0,    78,     0,   589,
1329      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1330      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1331      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1332      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1333    202,   582,     0,   194,   195,     0,     0,     0,    78,   204,
1334    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1335      0,     0,     0,   197,   597,     0,   192,   193,     0,     0,
1336    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1337     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1338      0,   202,     0,     0,     0,     0,     0,   590,     0,     0,
1339    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1340      0,     0,     0,    78,     0,   606,     0,   192,   193,     0,
1341      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1342      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1343      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1344      0,     0,   200,   201,     0,     0,   202,     0,     0,   194,
1345    195,   598,     0,     0,    78,   204,   205,   206,   207,     0,
1346      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1347    491,     0,   192,   193,     0,     0,   198,     0,     0,     0,
1348    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1349     20,     0,     0,   200,   201,     0,     0,   202,   607,     0,
1350      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1351      0,     0,   208,   209,   194,   195,     0,     0,     0,    78,
1352      0,   581,     0,   192,   193,     0,     0,     0,   196,     0,
1353      0,     0,     0,     0,   197,     0,     0,     0,     0,     0,
1354      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1355      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1356      0,     0,   202,     0,     0,   194,   195,   598,     0,     0,
1357     78,   204,   205,   206,   207,     0,     0,   208,   209,   196,
1358      0,     0,     0,     0,     0,   197,   707,     0,   192,   193,
1359      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1360      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1361    201,     0,     0,   202,   691,     0,     0,     0,     0,     0,
1362      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1363    194,   195,     0,     0,     0,    78,     0,   707,     0,   192,
1364    193,     0,     0,     0,   196,     0,     0,     0,     0,     0,
1365    197,     0,     0,     0,     0,     0,     0,   198,     0,     0,
1366      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1367     81,    20,     0,     0,   200,   201,     0,     0,   202,   708,
1368      0,   194,   195,     0,     0,     0,    78,   204,   205,   206,
1369    207,     0,     0,   208,   209,   196,     0,     0,     0,     0,
1370      0,   197,   589,     0,   192,   193,     0,     0,   198,     0,
1371      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1372      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1373    751,     0,     0,     0,     0,     0,     0,     0,   204,   205,
1374    206,   207,     0,     0,   208,   209,   194,   195,     0,     0,
1375      0,    78,     0,   330,     0,   192,   193,     0,     0,     0,
1376    196,     0,     0,     0,     0,     0,   197,     0,     0,     0,
1377      0,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1378      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1379    200,   201,     0,     0,   202,     0,     0,   194,   195,     0,
1380    756,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1381    209,   196,     0,     0,     0,     0,     0,   197,   335,     0,
1382    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1383      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1384      0,   200,   201,     0,     0,   202,     0,     0,     0,     0,
1385      0,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1386    208,   209,   194,   195,     0,     0,     0,    78,     0,   337,
1387      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1388      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1389      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1390      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1391    202,     0,     0,   194,   195,     0,     0,     0,    78,   204,
1392    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1393      0,     0,     0,   197,   339,     0,   192,   193,     0,     0,
1394    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1395     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1396      0,   202,     0,     0,     0,     0,     0,     0,     0,     0,
1397    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1398      0,     0,     0,    78,     0,   348,     0,   192,   193,     0,
1399      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1400      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1401      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1402      0,     0,   200,   201,     0,     0,   202,     0,     0,   194,
1403    195,     0,     0,     0,    78,   204,   205,   206,   207,     0,
1404      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1405    350,     0,   192,   193,     0,     0,   198,     0,     0,     0,
1406    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1407     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1408      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1409      0,     0,   208,   209,   194,   195,     0,     0,     0,    78,
1410      0,   352,     0,   192,   193,     0,     0,     0,   196,     0,
1411      0,     0,     0,     0,   197,     0,     0,     0,     0,     0,
1412      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1413      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1414      0,     0,   202,     0,     0,   194,   195,     0,     0,     0,
1415     78,   204,   205,   206,   207,     0,     0,   208,   209,   196,
1416      0,     0,     0,     0,     0,   197,   409,     0,   192,   193,
1417      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1418      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1419    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1420      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1421    194,   195,     0,     0,     0,    78,     0,   491,     0,   192,
1422    193,     0,     0,     0,   196,     0,     0,     0,     0,     0,
1423    197,     0,     0,     0,     0,     0,     0,   198,     0,     0,
1424      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1425     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1426      0,   194,   195,     0,     0,     0,    78,   204,   205,   206,
1427    207,     0,     0,   208,   209,   196,     0,     0,     0,     0,
1428      0,   197,   499,     0,   192,   193,     0,     0,   198,     0,
1429      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1430      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1431      0,     0,     0,     0,     0,     0,     0,     0,   204,   205,
1432    206,   207,     0,     0,   208,   209,   194,   195,     0,     0,
1433      0,    78,     0,   503,     0,   192,   193,     0,     0,     0,
1434    196,     0,     0,     0,     0,     0,   197,     0,     0,     0,
1435      0,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1436      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1437    200,   201,     0,     0,   202,     0,     0,   194,   195,     0,
1438      0,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1439    209,   196,     0,     0,     0,     0,     0,   197,   505,     0,
1440    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1441      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1442      0,   200,   201,     0,     0,   202,     0,     0,     0,     0,
1443      0,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1444    208,   209,   194,   195,     0,     0,     0,    78,     0,   507,
1445      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1446      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1447      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1448      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1449    202,     0,     0,   194,   195,     0,     0,     0,    78,   204,
1450    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1451      0,     0,     0,   197,   509,     0,   192,   193,     0,     0,
1452    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1453     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1454      0,   202,     0,     0,     0,     0,     0,     0,     0,     0,
1455    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1456      0,     0,     0,    78,     0,   511,     0,   192,   193,     0,
1457      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1458      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1459      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1460      0,     0,   200,   201,     0,     0,   202,     0,     0,   194,
1461    195,     0,     0,     0,    78,   204,   205,   206,   207,     0,
1462      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1463    513,     0,   192,   193,     0,     0,   198,     0,     0,     0,
1464    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1465     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1466      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1467      0,     0,   208,   209,   194,   195,     0,     0,     0,    78,
1468      0,   515,     0,   192,   193,     0,     0,     0,   196,     0,
1469      0,     0,     0,     0,   197,     0,     0,     0,     0,     0,
1470      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1471      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1472      0,     0,   202,     0,     0,   194,   195,     0,     0,     0,
1473     78,   204,   205,   206,   207,     0,     0,   208,   209,   196,
1474      0,     0,     0,     0,     0,   197,   517,     0,   192,   193,
1475      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1476      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1477    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1478      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1479    194,   195,     0,     0,     0,    78,     0,   519,     0,   192,
1480    193,     0,     0,     0,   196,     0,     0,     0,     0,     0,
1481    197,     0,     0,     0,     0,     0,     0,   198,     0,     0,
1482      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1483     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1484      0,   194,   195,     0,     0,     0,    78,   204,   205,   206,
1485    207,     0,     0,   208,   209,   196,     0,     0,     0,     0,
1486      0,   197,   521,     0,   192,   193,     0,     0,   198,     0,
1487      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1488      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1489      0,     0,     0,     0,     0,     0,     0,     0,   204,   205,
1490    206,   207,     0,     0,   208,   209,   194,   195,     0,     0,
1491      0,    78,     0,   523,     0,   192,   193,     0,     0,     0,
1492    196,     0,     0,     0,     0,     0,   197,     0,     0,     0,
1493      0,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1494      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1495    200,   201,     0,     0,   202,     0,     0,   194,   195,     0,
1496      0,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1497    209,   196,     0,     0,     0,     0,     0,   197,   525,     0,
1498    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1499      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1500      0,   200,   201,     0,     0,   202,     0,     0,     0,     0,
1501      0,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1502    208,   209,   194,   195,     0,     0,     0,    78,     0,   530,
1503      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1504      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1505      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1506      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1507    202,     0,     0,   194,   195,     0,     0,     0,    78,   204,
1508    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1509      0,     0,     0,   197,   532,     0,   192,   193,     0,     0,
1510    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1511     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1512      0,   202,     0,     0,     0,     0,     0,     0,     0,     0,
1513    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1514      0,     0,     0,    78,     0,   534,     0,   192,   193,     0,
1515      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1516      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1517      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1518      0,     0,   200,   201,     0,     0,   202,     0,     0,   194,
1519    195,     0,     0,     0,    78,   204,   205,   206,   207,     0,
1520      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1521    536,     0,   192,   193,     0,     0,   198,     0,     0,     0,
1522    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1523     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1524      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1525      0,     0,   208,   209,   194,   195,     0,     0,     0,    78,
1526      0,   538,     0,   192,   193,     0,     0,     0,   196,     0,
1527      0,     0,     0,     0,   197,     0,     0,     0,     0,     0,
1528      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1529      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1530      0,     0,   202,     0,     0,   194,   195,     0,     0,     0,
1531     78,   204,   205,   206,   207,     0,     0,   208,   209,   196,
1532      0,     0,     0,     0,     0,   197,   540,     0,   192,   193,
1533      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1534      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1535    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1536      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1537    194,   195,     0,     0,     0,    78,     0,   542,     0,   192,
1538    193,     0,     0,     0,   196,     0,     0,     0,     0,     0,
1539    197,     0,     0,     0,     0,     0,     0,   198,     0,     0,
1540      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1541     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1542      0,   194,   195,     0,     0,     0,    78,   204,   205,   206,
1543    207,     0,     0,   208,   209,   196,     0,     0,     0,     0,
1544      0,   197,   547,     0,   192,   193,     0,     0,   198,     0,
1545      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1546      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1547      0,     0,     0,     0,     0,     0,     0,     0,   204,   205,
1548    206,   207,     0,     0,   208,   209,   194,   195,     0,     0,
1549      0,    78,     0,   557,     0,   192,   193,     0,     0,     0,
1550    196,     0,     0,     0,     0,     0,   197,     0,     0,     0,
1551      0,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1552      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1553    200,   201,     0,     0,   202,     0,     0,   194,   195,     0,
1554      0,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1555    209,   196,     0,     0,     0,     0,     0,   197,   565,     0,
1556    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1557      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1558      0,   200,   201,     0,     0,   202,     0,     0,     0,     0,
1559      0,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1560    208,   209,   194,   195,     0,     0,     0,    78,     0,   567,
1561      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1562      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1563      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1564      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1565    202,     0,     0,   194,   195,     0,     0,     0,    78,   204,
1566    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1567      0,     0,     0,   197,   592,     0,   192,   193,     0,     0,
1568    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1569     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1570      0,   202,     0,     0,     0,     0,     0,     0,     0,     0,
1571    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1572      0,     0,     0,    78,     0,   609,     0,   192,   193,     0,
1573      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1574      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1575      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1576      0,     0,   200,   201,     0,     0,   202,     0,     0,   194,
1577    195,     0,     0,     0,    78,   204,   205,   206,   207,     0,
1578      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1579    677,     0,   192,   193,     0,     0,   198,     0,     0,     0,
1580    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1581     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1582      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1583      0,     0,   208,   209,   194,   195,     0,     0,     0,    78,
1584      0,   681,     0,   192,   193,     0,     0,     0,   196,     0,
1585      0,     0,     0,     0,   197,     0,     0,     0,     0,     0,
1586      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1587      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1588      0,     0,   202,     0,     0,   194,   195,     0,     0,     0,
1589     78,   204,   205,   206,   207,     0,     0,   208,   209,   196,
1590      0,     0,     0,     0,     0,   197,   687,     0,   192,   193,
1591      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1592      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1593    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1594      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1595    194,   195,     0,     0,     0,    78,     0,   713,     0,   192,
1596    193,     0,     0,     0,   196,     0,     0,     0,     0,     0,
1597    197,     0,     0,     0,     0,     0,     0,   198,     0,     0,
1598      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1599     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1600      0,   194,   195,     0,     0,     0,    78,   204,   205,   206,
1601    207,     0,     0,   208,   209,   196,     0,     0,     0,     0,
1602      0,   197,     0,   575,     0,     0,     0,     0,   198,     0,
1603      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1604      0,    81,    20,     0,     0,   200,   201,     0,   662,   202,
1605      0,     0,     0,     0,     0,     0,     0,     0,   204,   205,
1606    206,   207,     0,     0,   208,   209,  -289,  -289,  -289,     0,
1607      0,     0,  -289,     0,     0,     0,     0,     0,     0,     0,
1608      0,  -289,     0,     0,     0,     0,     0,  -289,     0,     0,
1609    724,     0,   194,   195,  -289,     0,     0,    78,  -289,     0,
1610      0,     0,     0,     0,  -289,     0,   196,  -289,  -289,     0,
1611      0,     0,   197,     0,     0,  -289,     0,   192,   193,   198,
1612      0,  -289,     0,   199,  -289,  -289,  -289,  -289,     0,    80,
1613   -289,  -289,    81,    20,   194,   195,     0,     0,     0,    78,
1614    277,  -297,     0,     0,     0,     0,     0,     0,   196,   204,
1615    205,   206,   207,     0,   197,   208,   209,   660,     0,   194,
1616    195,   198,     0,     0,    78,   199,     0,     0,     0,     0,
1617      0,    80,     0,   196,    81,    20,     0,     0,     0,   197,
1618      0,     0,   277,  -297,   192,   193,   198,     0,     0,     0,
1619    199,   204,   205,   206,   207,     0,    80,   208,   209,    81,
1620     20,   194,   195,   200,   201,     0,    78,   202,     0,   203,
1621    356,     0,     0,     0,     0,   196,   204,   205,   206,   207,
1622      0,   197,   208,   209,     0,     0,   194,   195,   198,     0,
1623      0,    78,   199,     0,     0,   192,   193,     0,    80,     0,
1624    196,    81,    20,     0,     0,     0,   197,     0,     0,   277,
1625      0,     0,     0,   198,     0,     0,     0,   199,   204,   205,
1626    206,   207,     0,    80,   208,   209,    81,    20,     0,     0,
1627    200,   201,     0,     0,   202,   488,     0,   194,   195,     0,
1628      0,     0,    78,   204,   205,   206,   207,     0,     0,   208,
1629    209,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1630    192,   193,     0,     0,   198,     0,     0,     0,   199,     0,
1631      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1632      0,   200,   201,     0,     0,   202,   625,     0,     0,     0,
1633      0,     0,     0,     0,   204,   205,   206,   207,     0,     0,
1634    208,   209,   194,   195,     0,     0,     0,    78,     0,     0,
1635      0,   192,   193,     0,     0,     0,   196,     0,     0,     0,
1636      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1637      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1638      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1639    202,   668,     0,   194,   195,     0,     0,     0,    78,   204,
1640    205,   206,   207,     0,     0,   208,   209,   196,     0,     0,
1641      0,     0,     0,   197,     0,     0,   192,   193,     0,     0,
1642    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1643     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1644      0,   202,   683,     0,     0,     0,     0,     0,     0,     0,
1645    204,   205,   206,   207,     0,     0,   208,   209,   194,   195,
1646      0,     0,     0,    78,     0,     0,     0,     0,     0,     0,
1647      0,     0,   196,     0,     0,     0,     0,     0,   197,     0,
1648      0,     0,     0,     0,     0,   198,     0,     0,     0,   199,
1649      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1650      0,     0,   200,   201,     0,     0,   202,     0,     2,   194,
1651    195,     0,     0,     0,    78,   204,   205,   206,   207,     0,
1652      0,   208,   209,   196,     0,     0,     0,     0,     0,   197,
1653      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1654    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1655     20,     0,     0,     0,     0,     0,     0,   277,     0,     0,
1656      0,     0,     0,     0,     0,     0,   204,   205,   206,   207,
1657      0,     0,   208,   209
1658 };
1659
1660 static const short yycheck[] = {     3,
1661    328,    62,     6,   132,    62,   307,   129,   287,   175,   203,
1662    134,     0,   483,   179,     1,     1,   123,     1,     1,   346,
1663      9,    10,    11,     1,    83,    42,   353,   354,    89,    46,
1664      9,    89,     1,    94,    53,     1,    94,   657,    42,   162,
1665      1,    30,    46,    72,    33,    34,   169,    64,   435,     1,
1666     94,    62,    69,    97,    33,    86,     1,    86,    62,   294,
1667     64,   665,    51,   122,   123,    69,     1,   302,   129,   304,
1668     95,   129,   133,    62,   198,   133,   117,     1,    97,   192,
1669    193,   194,   195,    94,   636,    89,     1,   200,   201,   476,
1670     94,     1,     1,    95,    96,     1,     5,    99,   718,   160,
1671     86,   162,   160,    86,   162,    94,   636,    94,     1,   150,
1672     94,   128,   153,   100,   175,   502,   100,   134,   129,   180,
1673      1,    99,   180,   101,   128,   129,     1,    93,     1,   133,
1674    134,   172,   101,     4,     5,   101,   259,   198,    99,   636,
1675    129,   202,   613,   470,   133,   697,   473,    99,   700,   101,
1676    273,   162,   756,     0,    99,   100,   160,     1,   162,    94,
1677    326,   765,     9,    10,    11,    36,    37,   697,   140,    40,
1678    700,   175,   279,   162,     1,    99,   180,    86,    88,    50,
1679      1,   198,     1,    30,    99,   100,    33,    34,   192,   193,
1680    194,   195,   253,    99,   198,   253,   200,   201,   202,   636,
1681    697,    94,     1,   700,    51,   329,   100,   100,    79,   596,
1682      1,   763,    83,   254,     1,    62,   768,    98,   770,     1,
1683    772,    94,   283,     1,    99,   283,   287,   100,     1,     1,
1684    202,   203,     1,   763,     1,   622,   403,     1,   768,     1,
1685    770,     1,   772,     1,     1,   632,   307,    94,    92,   253,
1686     94,   122,   123,    97,    98,    99,   100,   370,   371,   372,
1687    697,   648,     1,   700,   253,     1,   763,   328,   139,     1,
1688    328,   768,    99,   770,    95,   772,   556,    15,    99,   283,
1689     99,    93,   129,   287,    94,    97,   588,    97,   590,   101,
1690    294,   485,   101,   175,   266,    94,     1,   269,   302,     1,
1691    304,   100,     1,   307,   175,   277,     1,    98,   179,    45,
1692     46,    98,   329,   641,     1,   162,    98,    86,   307,    86,
1693     98,   382,    95,    95,   328,   329,   763,   434,     1,    86,
1694     99,   768,    99,   770,    98,   772,    98,   175,    98,   328,
1695      1,    99,   403,     1,     1,   732,    52,   218,     1,    87,
1696     86,   631,    88,     1,    97,    91,    92,    93,     1,     1,
1697     99,    97,    94,   665,   477,   101,   370,   371,   372,   373,
1698    374,   375,   376,   377,   378,   379,   380,   381,   382,   383,
1699    384,   385,   386,   387,   388,   389,   553,   448,     1,   361,
1700    448,    52,     1,   365,    99,    52,    98,   268,    93,   403,
1701     99,   636,    63,    97,   275,   287,    63,    94,   279,     1,
1702      1,   100,   294,     0,     1,    88,   287,     1,   390,     1,
1703    302,    63,   304,   294,     1,   307,     1,     1,     1,    99,
1704    100,   302,     1,   304,    95,     1,   408,    95,    95,    52,
1705    720,    94,     0,     1,   448,    93,   418,   570,   420,   287,
1706    573,    94,     1,    95,   756,   326,   294,    44,   430,    99,
1707    100,     1,   697,   765,   302,   700,   304,     1,    55,   307,
1708     94,    93,   343,   477,    61,    67,   100,     1,   607,   483,
1709     67,   453,    95,   455,    93,     1,    44,     1,   723,     1,
1710     47,   362,   553,   364,   175,   556,   625,   469,    67,   612,
1711     95,   736,    86,    61,    95,    62,     0,     1,   480,    67,
1712    129,    93,    99,   485,    63,   750,    93,    92,    93,    93,
1713     93,   403,    97,    98,    99,   100,    98,    93,   763,     1,
1714      1,     1,   403,   768,     1,   770,    50,   772,    97,    96,
1715      1,    99,   101,   162,   667,    59,    95,   676,     1,   553,
1716     44,    65,   556,    93,    95,     0,     1,   686,    72,    93,
1717    431,    55,    76,   434,     1,   403,    96,    61,    82,    93,
1718    631,    85,    86,    67,    86,    89,    90,    93,    95,    93,
1719    641,    75,    99,   641,     0,     1,    93,     1,   102,   103,
1720    104,   105,     1,     1,   108,   109,   657,   129,    99,    44,
1721      0,     1,     0,     1,     1,    99,   287,     1,   612,   613,
1722     55,   175,   175,   294,    86,    86,    61,     1,     1,    86,
1723      1,   302,    67,   304,   628,    86,   307,   631,    44,    95,
1724    162,    64,   636,    86,    97,    44,    69,   641,   101,    55,
1725      1,    50,     1,    53,    44,    61,    44,   619,    65,    86,
1726     44,    67,   641,   657,    99,    72,    50,   718,    94,   720,
1727      1,    61,     1,    61,    11,   101,     1,    67,    65,    67,
1728     67,   553,    86,    82,   556,    72,    85,    86,    86,    76,
1729    129,   653,   553,    99,    95,   556,    97,   659,    82,    86,
1730    107,    85,    86,   697,   553,   128,   700,   556,    94,    99,
1731     94,    99,    86,    86,   100,    86,   588,     1,   590,     0,
1732      1,   160,   100,   162,   718,   553,   720,    96,   556,   723,
1733     47,   100,   403,   287,   287,    86,    65,    86,    67,     1,
1734    294,   294,   736,    72,   175,    62,     1,    76,   302,   302,
1735    304,   304,    94,   307,   307,    86,   750,    86,   100,   631,
1736    588,    86,   590,    44,   636,   101,    50,    44,   629,   763,
1737    631,    91,    92,   735,   768,   636,   770,   739,   772,    96,
1738     61,    44,   631,   101,    61,   657,    67,    50,   101,    44,
1739     67,    45,    46,   665,    92,    50,   657,    10,    82,    97,
1740     98,    85,    86,   631,    59,    67,    61,    94,   636,     9,
1741     72,    11,    67,   100,    76,    91,    92,    30,    99,    82,
1742    175,    34,    85,    86,    86,   697,    94,    82,   700,   657,
1743     85,    86,   100,    33,    94,    12,   697,   665,    51,   700,
1744    100,   470,    13,    97,   473,     1,   718,   101,   720,   403,
1745    403,   723,    97,   472,    60,   474,   287,   718,    64,   720,
1746     45,    46,   723,   294,   736,    18,    19,    20,    21,   697,
1747     14,   302,   700,   304,     1,   736,   307,    99,   750,    95,
1748     94,    93,   553,    97,   756,   556,    93,   101,    44,   750,
1749    718,   763,   720,   765,    50,   723,   768,    99,   770,    97,
1750    772,   175,   763,   697,    57,    99,   700,   768,   736,   770,
1751     99,   772,    97,     5,     6,     7,   101,   588,    99,   590,
1752     45,    46,   750,    50,   100,    44,    82,    95,   756,    85,
1753     86,    50,   287,     3,     4,   763,    66,   765,    93,   294,
1754    768,    93,   770,     1,   772,    16,    17,   302,    67,   304,
1755     91,    92,   307,    50,    88,    82,    45,    46,    85,    86,
1756    631,    93,    59,    82,    99,   636,    85,    86,    65,   763,
1757     45,    46,   403,    94,   768,    72,   770,     1,   772,    76,
1758     93,    91,    92,    93,    99,    82,   657,    97,    85,    86,
1759     94,   101,    89,    90,   665,    94,    93,    97,    98,   553,
1760    553,    97,   556,   556,    44,   102,   103,   104,   105,     1,
1761     50,   108,   109,   287,   373,   374,    44,   383,   384,    59,
1762    294,    61,    50,     8,     9,    10,   697,    67,   302,   700,
1763    304,    94,   100,   307,   588,   588,   590,   590,   378,   379,
1764    380,   381,    82,    56,    56,    85,    86,   718,   403,   720,
1765     99,    94,   723,    94,    82,    95,    96,    85,    86,   192,
1766    193,   194,   195,     1,    94,   736,    94,   200,   201,    86,
1767     97,    98,    99,    94,    91,    92,    93,   631,   631,   750,
1768     97,     1,   636,   636,   101,   756,    56,     1,    99,     3,
1769      4,    99,   763,    94,   765,    94,     0,   768,     0,   770,
1770     44,   772,   382,   657,   657,    11,    50,    54,   375,   376,
1771    377,   665,   665,    86,    75,    59,   162,    61,    91,    92,
1772     93,   139,   553,    67,    97,   556,   160,   253,   101,   403,
1773    403,    45,    46,    52,    94,   307,    50,   261,    82,   287,
1774    655,    85,    86,   697,   697,    59,   700,   700,   307,   571,
1775    655,    65,    96,   571,   346,   385,   387,   588,    72,   590,
1776    386,   388,    76,   628,   718,   718,   720,   720,    82,   723,
1777    723,    85,    86,   393,   389,    89,    90,    -1,    -1,    93,
1778     -1,    95,   736,   736,    -1,    -1,    -1,    -1,   102,   103,
1779    104,   105,    -1,    -1,   108,   109,   750,   750,   553,    -1,
1780    631,   556,   756,   756,    -1,   636,    -1,    -1,    -1,   763,
1781    763,   765,   765,    -1,   768,   768,   770,   770,   772,   772,
1782     -1,    91,    92,    93,    -1,    -1,   657,    97,    -1,    -1,
1783     -1,   101,    -1,   588,   665,   590,    -1,   370,   371,   372,
1784    373,   374,   375,   376,   377,   378,   379,   380,   381,    -1,
1785    383,   384,   385,   386,   387,   388,   389,    44,    91,    92,
1786     93,    -1,    -1,    50,    97,    -1,   697,    -1,   101,   700,
1787     -1,    -1,    59,    -1,    61,    -1,   631,    -1,    -1,   553,
1788     67,   636,   556,    -1,    -1,    -1,    -1,   718,    -1,   720,
1789     -1,    -1,   723,    -1,    -1,    82,    -1,    -1,    85,    86,
1790     -1,    -1,   657,    -1,    -1,   736,    -1,    -1,    95,    96,
1791    665,    -1,    -1,    -1,   588,    -1,   590,    -1,    -1,   750,
1792     -1,   192,   193,   194,   195,   756,    -1,    -1,    -1,   200,
1793    201,    -1,   763,    -1,   765,    -1,    -1,   768,    -1,   770,
1794     -1,   772,   697,    -1,   477,   700,    -1,    -1,    -1,    86,
1795    483,    -1,    -1,    -1,    91,    92,    93,   631,    -1,    -1,
1796     97,    -1,   636,   718,   101,   720,    -1,     1,   723,     3,
1797      4,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1798     -1,   736,    -1,   657,    -1,    -1,    -1,    -1,    -1,    -1,
1799     -1,   665,    -1,    -1,    -1,   750,    -1,    -1,    -1,    -1,
1800     -1,   756,    -1,    -1,    -1,    -1,    -1,    -1,   763,    -1,
1801    765,    45,    46,   768,    -1,   770,    50,   772,    -1,    -1,
1802     -1,    -1,    -1,   697,    -1,    59,   700,    -1,    -1,    -1,
1803     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
1804     -1,    -1,    76,    -1,   718,    -1,   720,    -1,    82,   723,
1805     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
1806     -1,    -1,   736,    -1,    -1,    99,    -1,    -1,   102,   103,
1807    104,   105,    -1,    -1,   108,   109,   750,     1,    -1,   612,
1808    613,    -1,   756,    -1,    -1,    -1,    -1,    -1,    -1,   763,
1809     -1,   765,    -1,    -1,   768,   628,   770,    -1,   772,   370,
1810    371,   372,   373,   374,   375,   376,   377,   378,   379,   380,
1811    381,    -1,   383,   384,   385,   386,   387,   388,   389,    -1,
1812     44,    45,    46,    47,    48,    49,    50,    51,    -1,    -1,
1813     54,    -1,    -1,    -1,    58,    59,    -1,    -1,    62,    -1,
1814     -1,    65,    66,    67,    68,    -1,    70,    71,    72,    73,
1815      1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
1816     -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    93,
1817     -1,    95,    96,    -1,    -1,    99,    -1,    -1,   102,   103,
1818    104,   105,    -1,    -1,   108,   109,    -1,    -1,    -1,    -1,
1819     -1,    -1,    -1,    44,    45,    46,    47,    48,    49,    50,
1820     51,    -1,    -1,    54,    -1,    -1,   477,    58,    59,    -1,
1821     -1,    62,   483,    -1,    65,    66,    67,    68,     1,    70,
1822     71,    72,    73,    -1,    -1,    76,    -1,    -1,    -1,    -1,
1823     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,
1824     -1,    -1,    93,    -1,    95,    96,    -1,    -1,    99,    -1,
1825     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    -1,
1826     -1,    44,    45,    46,    47,    48,    49,    50,    51,    -1,
1827     -1,    54,    -1,    -1,    -1,    58,    59,    -1,    -1,    62,
1828     -1,    -1,    65,    66,    67,    68,    -1,    70,    71,    72,
1829     73,    44,    -1,    76,    -1,    -1,    -1,    50,    -1,    82,
1830     -1,     1,    85,    86,    -1,    -1,    59,    -1,    61,    -1,
1831     93,    -1,    95,    96,    67,    -1,    99,    -1,    -1,   102,
1832    103,   104,   105,    -1,    -1,   108,   109,    -1,    -1,    82,
1833     -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,
1834     -1,   612,   613,    96,    44,    45,    46,    -1,    48,    49,
1835     50,    51,    -1,    -1,    54,    -1,    -1,   628,    58,    59,
1836     -1,    -1,    -1,    -1,    -1,    65,    66,    67,    68,     1,
1837     70,    71,    72,    73,    -1,    -1,    76,    -1,    -1,    -1,
1838     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,
1839     -1,    -1,    -1,    93,    -1,    95,    96,    -1,    -1,    99,
1840     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
1841     -1,    -1,    44,    45,    46,    -1,    48,    49,    50,    51,
1842     -1,    -1,    54,    -1,    -1,    -1,    58,    59,    -1,    -1,
1843     -1,    -1,    -1,    65,    66,    67,    68,     1,    70,    71,
1844     72,    73,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
1845     82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,
1846     -1,    93,    -1,    95,    -1,    -1,    -1,    99,    -1,    -1,
1847    102,   103,   104,   105,    -1,    -1,   108,   109,    -1,    -1,
1848     44,    45,    46,    -1,    48,    49,    50,    51,    -1,    -1,
1849     54,    -1,    -1,    -1,    58,    59,    -1,    -1,    -1,    -1,
1850     -1,    65,    66,     1,    68,    -1,    70,    71,    72,    73,
1851     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
1852     -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    93,
1853     -1,    95,    -1,    -1,    -1,    99,    -1,    -1,   102,   103,
1854    104,   105,    -1,    -1,   108,   109,    44,    45,    46,    -1,
1855     48,    49,    50,    51,    -1,    -1,    54,    -1,    -1,    -1,
1856     58,    59,    -1,    -1,    -1,    -1,    -1,    65,    66,    -1,
1857     68,    -1,    70,    71,    72,    73,    -1,     1,    76,     3,
1858      4,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
1859     -1,    -1,    -1,    -1,    -1,    93,    -1,    95,    -1,    -1,
1860     -1,    99,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
1861    108,   109,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1862     -1,    45,    46,    -1,    -1,    -1,    50,    -1,    -1,    -1,
1863     -1,    -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
1864     -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,
1865     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
1866     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
1867     -1,    95,    96,    -1,    -1,    -1,    -1,    -1,   102,   103,
1868    104,   105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,
1869     -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,
1870     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,
1871     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
1872     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    88,
1873     89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,
1874     -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
1875    109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,
1876      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
1877     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
1878     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,
1879     98,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
1880    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,
1881     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
1882     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
1883     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
1884     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
1885     93,    94,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
1886    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
1887     -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,
1888     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
1889     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
1890     -1,    93,    -1,    -1,    -1,    -1,    -1,    99,    -1,    -1,
1891    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
1892     -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,
1893     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
1894     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
1895     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
1896     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,
1897     46,    98,    -1,    -1,    50,   102,   103,   104,   105,    -1,
1898     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
1899      1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,
1900     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
1901     86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,    -1,
1902     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
1903     -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,
1904     -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,
1905     -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,
1906     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
1907     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
1908     -1,    -1,    93,    -1,    -1,    45,    46,    98,    -1,    -1,
1909     50,   102,   103,   104,   105,    -1,    -1,   108,   109,    59,
1910     -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,
1911     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
1912     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
1913     90,    -1,    -1,    93,    94,    -1,    -1,    -1,    -1,    -1,
1914     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
1915     45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,
1916      4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
1917     65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,
1918     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
1919     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,
1920     -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,   104,
1921    105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,
1922     -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,
1923     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
1924     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
1925     94,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,
1926    104,   105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,
1927     -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,
1928     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,
1929     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
1930     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
1931     89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,
1932     99,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
1933    109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,
1934      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
1935     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
1936     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,
1937     -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
1938    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,
1939     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
1940     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
1941     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
1942     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
1943     93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
1944    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
1945     -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,
1946     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
1947     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
1948     -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1949    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
1950     -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,
1951     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
1952     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
1953     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
1954     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,
1955     46,    -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,
1956     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
1957      1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,
1958     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
1959     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
1960     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
1961     -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,
1962     -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,
1963     -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,
1964     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
1965     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
1966     -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,
1967     50,   102,   103,   104,   105,    -1,    -1,   108,   109,    59,
1968     -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,
1969     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
1970     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
1971     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
1972     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
1973     45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,
1974      4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
1975     65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,
1976     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
1977     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
1978     -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,   104,
1979    105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,
1980     -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,
1981     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
1982     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
1983     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,
1984    104,   105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,
1985     -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,
1986     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,
1987     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
1988     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
1989     89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,
1990     -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
1991    109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,
1992      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
1993     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
1994     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,
1995     -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
1996    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,
1997     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
1998     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
1999     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2000     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2001     93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
2002    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
2003     -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,
2004     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2005     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2006     -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2007    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
2008     -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,
2009     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
2010     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
2011     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2012     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,
2013     46,    -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,
2014     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
2015      1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,
2016     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2017     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2018     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
2019     -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,
2020     -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,
2021     -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,
2022     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2023     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2024     -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,
2025     50,   102,   103,   104,   105,    -1,    -1,   108,   109,    59,
2026     -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,
2027     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2028     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2029     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
2030     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
2031     45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,
2032      4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
2033     65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,
2034     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2035     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2036     -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,   104,
2037    105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,
2038     -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,
2039     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2040     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2041     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,
2042    104,   105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,
2043     -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,
2044     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,
2045     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2046     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2047     89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,
2048     -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
2049    109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,
2050      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2051     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2052     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,
2053     -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
2054    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,
2055     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
2056     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
2057     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2058     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2059     93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
2060    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
2061     -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,
2062     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2063     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2064     -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2065    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
2066     -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,
2067     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
2068     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
2069     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2070     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,
2071     46,    -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,
2072     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
2073      1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,
2074     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2075     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2076     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
2077     -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,
2078     -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,
2079     -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,
2080     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2081     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2082     -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,
2083     50,   102,   103,   104,   105,    -1,    -1,   108,   109,    59,
2084     -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,
2085     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2086     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2087     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
2088     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
2089     45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,
2090      4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
2091     65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,
2092     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2093     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2094     -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,   104,
2095    105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,
2096     -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,
2097     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2098     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2099     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,
2100    104,   105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,
2101     -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,
2102     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,
2103     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2104     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2105     89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,
2106     -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
2107    109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,
2108      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2109     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2110     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,
2111     -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
2112    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,
2113     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
2114     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
2115     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2116     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2117     93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
2118    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
2119     -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,
2120     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2121     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2122     -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2123    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
2124     -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,
2125     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
2126     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
2127     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2128     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,
2129     46,    -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,
2130     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
2131      1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,
2132     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2133     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2134     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
2135     -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,
2136     -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,
2137     -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,
2138     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2139     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2140     -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,
2141     50,   102,   103,   104,   105,    -1,    -1,   108,   109,    59,
2142     -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,
2143     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2144     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2145     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
2146     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
2147     45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,
2148      4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
2149     65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,
2150     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2151     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2152     -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,   104,
2153    105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,
2154     -1,    65,    -1,     1,    -1,    -1,    -1,    -1,    72,    -1,
2155     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2156     -1,    85,    86,    -1,    -1,    89,    90,    -1,     1,    93,
2157     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,
2158    104,   105,    -1,    -1,   108,   109,    44,    45,    46,    -1,
2159     -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2160     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2161      1,    -1,    45,    46,    72,    -1,    -1,    50,    76,    -1,
2162     -1,    -1,    -1,    -1,    82,    -1,    59,    85,    86,    -1,
2163     -1,    -1,    65,    -1,    -1,    93,    -1,     3,     4,    72,
2164     -1,    99,    -1,    76,   102,   103,   104,   105,    -1,    82,
2165    108,   109,    85,    86,    45,    46,    -1,    -1,    -1,    50,
2166     93,    94,    -1,    -1,    -1,    -1,    -1,    -1,    59,   102,
2167    103,   104,   105,    -1,    65,   108,   109,     1,    -1,    45,
2168     46,    72,    -1,    -1,    50,    76,    -1,    -1,    -1,    -1,
2169     -1,    82,    -1,    59,    85,    86,    -1,    -1,    -1,    65,
2170     -1,    -1,    93,    94,     3,     4,    72,    -1,    -1,    -1,
2171     76,   102,   103,   104,   105,    -1,    82,   108,   109,    85,
2172     86,    45,    46,    89,    90,    -1,    50,    93,    -1,    95,
2173     96,    -1,    -1,    -1,    -1,    59,   102,   103,   104,   105,
2174     -1,    65,   108,   109,    -1,    -1,    45,    46,    72,    -1,
2175     -1,    50,    76,    -1,    -1,     3,     4,    -1,    82,    -1,
2176     59,    85,    86,    -1,    -1,    -1,    65,    -1,    -1,    93,
2177     -1,    -1,    -1,    72,    -1,    -1,    -1,    76,   102,   103,
2178    104,   105,    -1,    82,   108,   109,    85,    86,    -1,    -1,
2179     89,    90,    -1,    -1,    93,    94,    -1,    45,    46,    -1,
2180     -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,   108,
2181    109,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2182      3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2183     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2184     -1,    89,    90,    -1,    -1,    93,    94,    -1,    -1,    -1,
2185     -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,
2186    108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,    -1,
2187     -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,
2188     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
2189     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2190     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2191     93,    94,    -1,    45,    46,    -1,    -1,    -1,    50,   102,
2192    103,   104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,
2193     -1,    -1,    -1,    65,    -1,    -1,     3,     4,    -1,    -1,
2194     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2195     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2196     -1,    93,    94,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2197    102,   103,   104,   105,    -1,    -1,   108,   109,    45,    46,
2198     -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,
2199     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,
2200     -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,
2201     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2202     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    44,    45,
2203     46,    -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,
2204     -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,
2205     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2206     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2207     86,    -1,    -1,    -1,    -1,    -1,    -1,    93,    -1,    -1,
2208     -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,
2209     -1,    -1,   108,   109
2210 };
2211 #define YYPURE 1
2212
2213 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
2214 #line 3 "/usr/lib/bison.simple"
2215
2216 /* Skeleton output parser for bison,
2217    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2218
2219    This program is free software; you can redistribute it and/or modify
2220    it under the terms of the GNU General Public License as published by
2221    the Free Software Foundation; either version 2, or (at your option)
2222    any later version.
2223
2224    This program is distributed in the hope that it will be useful,
2225    but WITHOUT ANY WARRANTY; without even the implied warranty of
2226    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2227    GNU General Public License for more details.
2228
2229    You should have received a copy of the GNU General Public License
2230    along with this program; if not, write to the Free Software
2231    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
2232
2233 /* As a special exception, when this file is copied by Bison into a
2234    Bison output file, you may use that output file without restriction.
2235    This special exception was added by the Free Software Foundation
2236    in version 1.24 of Bison.  */
2237
2238 #ifndef alloca
2239 #ifdef __GNUC__
2240 #define alloca __builtin_alloca
2241 #else /* not GNU C.  */
2242 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
2243 #include <alloca.h>
2244 #else /* not sparc */
2245 #if defined (MSDOS) && !defined (__TURBOC__)
2246 #include <malloc.h>
2247 #else /* not MSDOS, or __TURBOC__ */
2248 #if defined(_AIX)
2249 #include <malloc.h>
2250  #pragma alloca
2251 #else /* not MSDOS, __TURBOC__, or _AIX */
2252 #ifdef __hpux
2253 #ifdef __cplusplus
2254 extern "C" {
2255 void *alloca (unsigned int);
2256 };
2257 #else /* not __cplusplus */
2258 void *alloca ();
2259 #endif /* not __cplusplus */
2260 #endif /* __hpux */
2261 #endif /* not _AIX */
2262 #endif /* not MSDOS, or __TURBOC__ */
2263 #endif /* not sparc.  */
2264 #endif /* not GNU C.  */
2265 #endif /* alloca not defined.  */
2266
2267 /* This is the parser code that is written into each bison parser
2268   when the %semantic_parser declaration is not specified in the grammar.
2269   It was written by Richard Stallman by simplifying the hairy parser
2270   used when %semantic_parser is specified.  */
2271
2272 /* Note: there must be only one dollar sign in this file.
2273    It is replaced by the list of actions, each action
2274    as one case of the switch.  */
2275
2276 #define yyerrok         (yyerrstatus = 0)
2277 #define yyclearin       (yychar = YYEMPTY)
2278 #define YYEMPTY         -2
2279 #define YYEOF           0
2280 #define YYACCEPT        return(0)
2281 #define YYABORT         return(1)
2282 #define YYERROR         goto yyerrlab1
2283 /* Like YYERROR except do call yyerror.
2284    This remains here temporarily to ease the
2285    transition to the new meaning of YYERROR, for GCC.
2286    Once GCC version 2 has supplanted version 1, this can go.  */
2287 #define YYFAIL          goto yyerrlab
2288 #define YYRECOVERING()  (!!yyerrstatus)
2289 #define YYBACKUP(token, value) \
2290 do                                                              \
2291   if (yychar == YYEMPTY && yylen == 1)                          \
2292     { yychar = (token), yylval = (value);                       \
2293       yychar1 = YYTRANSLATE (yychar);                           \
2294       YYPOPSTACK;                                               \
2295       goto yybackup;                                            \
2296     }                                                           \
2297   else                                                          \
2298     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
2299 while (0)
2300
2301 #define YYTERROR        1
2302 #define YYERRCODE       256
2303
2304 #ifndef YYPURE
2305 #define YYLEX           yylex()
2306 #endif
2307
2308 #ifdef YYPURE
2309 #ifdef YYLSP_NEEDED
2310 #ifdef YYLEX_PARAM
2311 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
2312 #else
2313 #define YYLEX           yylex(&yylval, &yylloc)
2314 #endif
2315 #else /* not YYLSP_NEEDED */
2316 #ifdef YYLEX_PARAM
2317 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
2318 #else
2319 #define YYLEX           yylex(&yylval)
2320 #endif
2321 #endif /* not YYLSP_NEEDED */
2322 #endif
2323
2324 /* If nonreentrant, generate the variables here */
2325
2326 #ifndef YYPURE
2327
2328 int     yychar;                 /*  the lookahead symbol                */
2329 YYSTYPE yylval;                 /*  the semantic value of the           */
2330                                 /*  lookahead symbol                    */
2331
2332 #ifdef YYLSP_NEEDED
2333 YYLTYPE yylloc;                 /*  location data for the lookahead     */
2334                                 /*  symbol                              */
2335 #endif
2336
2337 int yynerrs;                    /*  number of parse errors so far       */
2338 #endif  /* not YYPURE */
2339
2340 #if YYDEBUG != 0
2341 int yydebug;                    /*  nonzero means print parse trace     */
2342 /* Since this is uninitialized, it does not stop multiple parsers
2343    from coexisting.  */
2344 #endif
2345
2346 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
2347
2348 #ifndef YYINITDEPTH
2349 #define YYINITDEPTH 200
2350 #endif
2351
2352 /*  YYMAXDEPTH is the maximum size the stacks can grow to
2353     (effective only if the built-in stack extension method is used).  */
2354
2355 #if YYMAXDEPTH == 0
2356 #undef YYMAXDEPTH
2357 #endif
2358
2359 #ifndef YYMAXDEPTH
2360 #define YYMAXDEPTH 10000
2361 #endif
2362
2363 /* Prevent warning if -Wstrict-prototypes.  */
2364 #ifdef __GNUC__
2365 int yyparse (void);
2366 #endif
2367 \f
2368 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
2369 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
2370 #else                           /* not GNU C or C++ */
2371 #ifndef __cplusplus
2372
2373 /* This is the most reliable way to avoid incompatibilities
2374    in available built-in functions on various systems.  */
2375 static void
2376 __yy_memcpy (to, from, count)
2377      char *to;
2378      char *from;
2379      int count;
2380 {
2381   register char *f = from;
2382   register char *t = to;
2383   register int i = count;
2384
2385   while (i-- > 0)
2386     *t++ = *f++;
2387 }
2388
2389 #else /* __cplusplus */
2390
2391 /* This is the most reliable way to avoid incompatibilities
2392    in available built-in functions on various systems.  */
2393 static void
2394 __yy_memcpy (char *to, char *from, int count)
2395 {
2396   register char *f = from;
2397   register char *t = to;
2398   register int i = count;
2399
2400   while (i-- > 0)
2401     *t++ = *f++;
2402 }
2403
2404 #endif
2405 #endif
2406 \f
2407 #line 196 "/usr/lib/bison.simple"
2408
2409 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2410    into yyparse.  The argument should have type void *.
2411    It should actually point to an object.
2412    Grammar actions can access the variable by casting it
2413    to the proper pointer type.  */
2414
2415 #ifdef YYPARSE_PARAM
2416 #ifdef __cplusplus
2417 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2418 #define YYPARSE_PARAM_DECL
2419 #else /* not __cplusplus */
2420 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2421 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2422 #endif /* not __cplusplus */
2423 #else /* not YYPARSE_PARAM */
2424 #define YYPARSE_PARAM_ARG
2425 #define YYPARSE_PARAM_DECL
2426 #endif /* not YYPARSE_PARAM */
2427
2428 int
2429 yyparse(YYPARSE_PARAM_ARG)
2430      YYPARSE_PARAM_DECL
2431 {
2432   register int yystate;
2433   register int yyn;
2434   register short *yyssp;
2435   register YYSTYPE *yyvsp;
2436   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
2437   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
2438
2439   short yyssa[YYINITDEPTH];     /*  the state stack                     */
2440   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
2441
2442   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
2443   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
2444
2445 #ifdef YYLSP_NEEDED
2446   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
2447   YYLTYPE *yyls = yylsa;
2448   YYLTYPE *yylsp;
2449
2450 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
2451 #else
2452 #define YYPOPSTACK   (yyvsp--, yyssp--)
2453 #endif
2454
2455   int yystacksize = YYINITDEPTH;
2456
2457 #ifdef YYPURE
2458   int yychar;
2459   YYSTYPE yylval;
2460   int yynerrs;
2461 #ifdef YYLSP_NEEDED
2462   YYLTYPE yylloc;
2463 #endif
2464 #endif
2465
2466   YYSTYPE yyval;                /*  the variable used to return         */
2467                                 /*  semantic values from the action     */
2468                                 /*  routines                            */
2469
2470   int yylen;
2471
2472 #if YYDEBUG != 0
2473   if (yydebug)
2474     fprintf(stderr, "Starting parse\n");
2475 #endif
2476
2477   yystate = 0;
2478   yyerrstatus = 0;
2479   yynerrs = 0;
2480   yychar = YYEMPTY;             /* Cause a token to be read.  */
2481
2482   /* Initialize stack pointers.
2483      Waste one element of value and location stack
2484      so that they stay on the same level as the state stack.
2485      The wasted elements are never initialized.  */
2486
2487   yyssp = yyss - 1;
2488   yyvsp = yyvs;
2489 #ifdef YYLSP_NEEDED
2490   yylsp = yyls;
2491 #endif
2492
2493 /* Push a new state, which is found in  yystate  .  */
2494 /* In all cases, when you get here, the value and location stacks
2495    have just been pushed. so pushing a state here evens the stacks.  */
2496 yynewstate:
2497
2498   *++yyssp = yystate;
2499
2500   if (yyssp >= yyss + yystacksize - 1)
2501     {
2502       /* Give user a chance to reallocate the stack */
2503       /* Use copies of these so that the &'s don't force the real ones into memory. */
2504       YYSTYPE *yyvs1 = yyvs;
2505       short *yyss1 = yyss;
2506 #ifdef YYLSP_NEEDED
2507       YYLTYPE *yyls1 = yyls;
2508 #endif
2509
2510       /* Get the current used size of the three stacks, in elements.  */
2511       int size = yyssp - yyss + 1;
2512
2513 #ifdef yyoverflow
2514       /* Each stack pointer address is followed by the size of
2515          the data in use in that stack, in bytes.  */
2516 #ifdef YYLSP_NEEDED
2517       /* This used to be a conditional around just the two extra args,
2518          but that might be undefined if yyoverflow is a macro.  */
2519       yyoverflow("parser stack overflow",
2520                  &yyss1, size * sizeof (*yyssp),
2521                  &yyvs1, size * sizeof (*yyvsp),
2522                  &yyls1, size * sizeof (*yylsp),
2523                  &yystacksize);
2524 #else
2525       yyoverflow("parser stack overflow",
2526                  &yyss1, size * sizeof (*yyssp),
2527                  &yyvs1, size * sizeof (*yyvsp),
2528                  &yystacksize);
2529 #endif
2530
2531       yyss = yyss1; yyvs = yyvs1;
2532 #ifdef YYLSP_NEEDED
2533       yyls = yyls1;
2534 #endif
2535 #else /* no yyoverflow */
2536       /* Extend the stack our own way.  */
2537       if (yystacksize >= YYMAXDEPTH)
2538         {
2539           yyerror("parser stack overflow");
2540           return 2;
2541         }
2542       yystacksize *= 2;
2543       if (yystacksize > YYMAXDEPTH)
2544         yystacksize = YYMAXDEPTH;
2545       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
2546       __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
2547       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
2548       __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
2549 #ifdef YYLSP_NEEDED
2550       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
2551       __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
2552 #endif
2553 #endif /* no yyoverflow */
2554
2555       yyssp = yyss + size - 1;
2556       yyvsp = yyvs + size - 1;
2557 #ifdef YYLSP_NEEDED
2558       yylsp = yyls + size - 1;
2559 #endif
2560
2561 #if YYDEBUG != 0
2562       if (yydebug)
2563         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2564 #endif
2565
2566       if (yyssp >= yyss + yystacksize - 1)
2567         YYABORT;
2568     }
2569
2570 #if YYDEBUG != 0
2571   if (yydebug)
2572     fprintf(stderr, "Entering state %d\n", yystate);
2573 #endif
2574
2575   goto yybackup;
2576  yybackup:
2577
2578 /* Do appropriate processing given the current state.  */
2579 /* Read a lookahead token if we need one and don't already have one.  */
2580 /* yyresume: */
2581
2582   /* First try to decide what to do without reference to lookahead token.  */
2583
2584   yyn = yypact[yystate];
2585   if (yyn == YYFLAG)
2586     goto yydefault;
2587
2588   /* Not known => get a lookahead token if don't already have one.  */
2589
2590   /* yychar is either YYEMPTY or YYEOF
2591      or a valid token in external form.  */
2592
2593   if (yychar == YYEMPTY)
2594     {
2595 #if YYDEBUG != 0
2596       if (yydebug)
2597         fprintf(stderr, "Reading a token: ");
2598 #endif
2599       yychar = YYLEX;
2600     }
2601
2602   /* Convert token to internal form (in yychar1) for indexing tables with */
2603
2604   if (yychar <= 0)              /* This means end of input. */
2605     {
2606       yychar1 = 0;
2607       yychar = YYEOF;           /* Don't call YYLEX any more */
2608
2609 #if YYDEBUG != 0
2610       if (yydebug)
2611         fprintf(stderr, "Now at end of input.\n");
2612 #endif
2613     }
2614   else
2615     {
2616       yychar1 = YYTRANSLATE(yychar);
2617
2618 #if YYDEBUG != 0
2619       if (yydebug)
2620         {
2621           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2622           /* Give the individual parser a way to print the precise meaning
2623              of a token, for further debugging info.  */
2624 #ifdef YYPRINT
2625           YYPRINT (stderr, yychar, yylval);
2626 #endif
2627           fprintf (stderr, ")\n");
2628         }
2629 #endif
2630     }
2631
2632   yyn += yychar1;
2633   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2634     goto yydefault;
2635
2636   yyn = yytable[yyn];
2637
2638   /* yyn is what to do for this token type in this state.
2639      Negative => reduce, -yyn is rule number.
2640      Positive => shift, yyn is new state.
2641        New state is final state => don't bother to shift,
2642        just return success.
2643      0, or most negative number => error.  */
2644
2645   if (yyn < 0)
2646     {
2647       if (yyn == YYFLAG)
2648         goto yyerrlab;
2649       yyn = -yyn;
2650       goto yyreduce;
2651     }
2652   else if (yyn == 0)
2653     goto yyerrlab;
2654
2655   if (yyn == YYFINAL)
2656     YYACCEPT;
2657
2658   /* Shift the lookahead token.  */
2659
2660 #if YYDEBUG != 0
2661   if (yydebug)
2662     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2663 #endif
2664
2665   /* Discard the token being shifted unless it is eof.  */
2666   if (yychar != YYEOF)
2667     yychar = YYEMPTY;
2668
2669   *++yyvsp = yylval;
2670 #ifdef YYLSP_NEEDED
2671   *++yylsp = yylloc;
2672 #endif
2673
2674   /* count tokens shifted since error; after three, turn off error status.  */
2675   if (yyerrstatus) yyerrstatus--;
2676
2677   yystate = yyn;
2678   goto yynewstate;
2679
2680 /* Do the default action for the current state.  */
2681 yydefault:
2682
2683   yyn = yydefact[yystate];
2684   if (yyn == 0)
2685     goto yyerrlab;
2686
2687 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
2688 yyreduce:
2689   yylen = yyr2[yyn];
2690   if (yylen > 0)
2691     yyval = yyvsp[1-yylen]; /* implement default value of the action */
2692
2693 #if YYDEBUG != 0
2694   if (yydebug)
2695     {
2696       int i;
2697
2698       fprintf (stderr, "Reducing via rule %d (line %d), ",
2699                yyn, yyrline[yyn]);
2700
2701       /* Print the symbols being reduced, and their result.  */
2702       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2703         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2704       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2705     }
2706 #endif
2707
2708
2709   switch (yyn) {
2710
2711 case 1:
2712 #line 459 "./parse.y"
2713 {;
2714     break;}
2715 case 18:
2716 #line 503 "./parse.y"
2717
2718                   yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2719                   CLASS_LOADED_P (yyval.node) = 1;
2720                 ;
2721     break;}
2722 case 19:
2723 #line 508 "./parse.y"
2724 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2725     break;}
2726 case 20:
2727 #line 510 "./parse.y"
2728 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2729     break;}
2730 case 21:
2731 #line 512 "./parse.y"
2732 {RULE ("']' expected"); RECOVER;;
2733     break;}
2734 case 22:
2735 #line 514 "./parse.y"
2736 {RULE ("']' expected"); RECOVER;;
2737     break;}
2738 case 26:
2739 #line 529 "./parse.y"
2740 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2741     break;}
2742 case 28:
2743 #line 538 "./parse.y"
2744 {yyval.node = NULL;;
2745     break;}
2746 case 36:
2747 #line 550 "./parse.y"
2748 {
2749                   yyval.node = NULL;
2750                 ;
2751     break;}
2752 case 37:
2753 #line 554 "./parse.y"
2754 {
2755                   yyval.node = NULL;
2756                 ;
2757     break;}
2758 case 40:
2759 #line 566 "./parse.y"
2760 { ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node); ;
2761     break;}
2762 case 41:
2763 #line 568 "./parse.y"
2764 {yyerror ("Missing name"); RECOVER;;
2765     break;}
2766 case 42:
2767 #line 570 "./parse.y"
2768 {yyerror ("';' expected"); RECOVER;;
2769     break;}
2770 case 45:
2771 #line 580 "./parse.y"
2772 {
2773                   tree name = EXPR_WFL_NODE (yyvsp[-1].node), node, last_name;
2774                   int   i = IDENTIFIER_LENGTH (name)-1;
2775                   char *last = &IDENTIFIER_POINTER (name)[i];
2776                   while (last != IDENTIFIER_POINTER (name))
2777                     {
2778                       if (last [0] == '.')
2779                         break;
2780                       last--;
2781                     }
2782                   last_name = get_identifier (++last);
2783                   if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
2784                     {
2785                       tree err = find_name_in_single_imports (last_name);
2786                       if (err && err != name)
2787                         parse_error_context
2788                           (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
2789                            IDENTIFIER_POINTER (name), 
2790                            IDENTIFIER_POINTER (err));
2791                       else
2792                         REGISTER_IMPORT (yyvsp[-1].node, last_name)
2793                     }
2794                   else
2795                     REGISTER_IMPORT (yyvsp[-1].node, last_name);
2796                 ;
2797     break;}
2798 case 46:
2799 #line 606 "./parse.y"
2800 {yyerror ("Missing name"); RECOVER;;
2801     break;}
2802 case 47:
2803 #line 608 "./parse.y"
2804 {yyerror ("';' expected"); RECOVER;;
2805     break;}
2806 case 48:
2807 #line 613 "./parse.y"
2808 {
2809                   tree name = EXPR_WFL_NODE (yyvsp[-3].node);
2810                   /* Don't import java.lang.* twice. */
2811                   if (name != java_lang_id)
2812                     {
2813                       tree node = build_tree_list (yyvsp[-3].node, NULL_TREE);
2814                       read_import_dir (yyvsp[-3].node);
2815                       TREE_CHAIN (node) = ctxp->import_demand_list;
2816                       ctxp->import_demand_list = node;
2817                     }
2818                 ;
2819     break;}
2820 case 49:
2821 #line 625 "./parse.y"
2822 {yyerror ("'*' expected"); RECOVER;;
2823     break;}
2824 case 50:
2825 #line 627 "./parse.y"
2826 {yyerror ("';' expected"); RECOVER;;
2827     break;}
2828 case 51:
2829 #line 632 "./parse.y"
2830 {
2831                   maybe_generate_finit ();
2832                   maybe_generate_clinit ();
2833                   yyval.node = yyvsp[0].node;
2834                 ;
2835     break;}
2836 case 52:
2837 #line 638 "./parse.y"
2838 {
2839                   maybe_generate_clinit ();
2840                   yyval.node = yyvsp[0].node;
2841                 ;
2842     break;}
2843 case 53:
2844 #line 643 "./parse.y"
2845 { yyval.node = NULL; ;
2846     break;}
2847 case 54:
2848 #line 645 "./parse.y"
2849 {
2850                   YYERROR_NOW;
2851                   yyerror ("Class or interface declaration expected");
2852                 ;
2853     break;}
2854 case 55:
2855 #line 656 "./parse.y"
2856 {
2857                   yyval.value = (1 << yyvsp[0].value);
2858                 ;
2859     break;}
2860 case 56:
2861 #line 660 "./parse.y"
2862 {
2863                   int acc = (1 << yyvsp[0].value);
2864                   if (yyval.value & acc)
2865                     parse_error_context 
2866                       (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
2867                        java_accstring_lookup (acc));
2868                   else
2869                     {
2870                       yyval.value |= acc;
2871                     }
2872                 ;
2873     break;}
2874 case 57:
2875 #line 676 "./parse.y"
2876 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
2877     break;}
2878 case 58:
2879 #line 678 "./parse.y"
2880
2881                   yyval.node = yyvsp[0].node;
2882                 ;
2883     break;}
2884 case 59:
2885 #line 682 "./parse.y"
2886 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
2887     break;}
2888 case 60:
2889 #line 684 "./parse.y"
2890 {       
2891                   yyval.node = yyvsp[0].node;
2892                 ;
2893     break;}
2894 case 61:
2895 #line 688 "./parse.y"
2896 {yyerror ("Missing class name"); RECOVER;;
2897     break;}
2898 case 62:
2899 #line 690 "./parse.y"
2900 {yyerror ("Missing class name"); RECOVER;;
2901     break;}
2902 case 63:
2903 #line 692 "./parse.y"
2904 {
2905                   if (!ctxp->class_err) yyerror ("'{' expected"); 
2906                   DRECOVER(class1);
2907                 ;
2908     break;}
2909 case 64:
2910 #line 697 "./parse.y"
2911 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
2912     break;}
2913 case 65:
2914 #line 701 "./parse.y"
2915 { yyval.node = NULL; ;
2916     break;}
2917 case 66:
2918 #line 703 "./parse.y"
2919 { yyval.node = yyvsp[0].node; ;
2920     break;}
2921 case 67:
2922 #line 705 "./parse.y"
2923 {yyerror ("'{' expected"); ctxp->class_err=1;;
2924     break;}
2925 case 68:
2926 #line 707 "./parse.y"
2927 {yyerror ("Missing super class name"); ctxp->class_err=1;;
2928     break;}
2929 case 69:
2930 #line 711 "./parse.y"
2931 { yyval.node = NULL_TREE; ;
2932     break;}
2933 case 70:
2934 #line 713 "./parse.y"
2935 { yyval.node = yyvsp[0].node; ;
2936     break;}
2937 case 71:
2938 #line 715 "./parse.y"
2939 {
2940                   ctxp->class_err=1;
2941                   yyerror ("Missing interface name"); 
2942                 ;
2943     break;}
2944 case 72:
2945 #line 723 "./parse.y"
2946
2947                   ctxp->interface_number = 1;
2948                   yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
2949                 ;
2950     break;}
2951 case 73:
2952 #line 728 "./parse.y"
2953
2954                   ctxp->interface_number++;
2955                   yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
2956                 ;
2957     break;}
2958 case 74:
2959 #line 733 "./parse.y"
2960 {yyerror ("Missing interface name"); RECOVER;;
2961     break;}
2962 case 75:
2963 #line 738 "./parse.y"
2964
2965                   /* Store the location of the `}' when doing xrefs */
2966                   if (flag_emit_xref)
2967                     DECL_END_SOURCE_LINE (ctxp->current_parsed_class) = 
2968                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
2969                   yyval.node = ctxp->current_parsed_class;
2970                 ;
2971     break;}
2972 case 76:
2973 #line 746 "./parse.y"
2974
2975                   /* Store the location of the `}' when doing xrefs */
2976                   if (flag_emit_xref)
2977                     DECL_END_SOURCE_LINE (ctxp->current_parsed_class) = 
2978                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
2979                   yyval.node = ctxp->current_parsed_class;
2980                 ;
2981     break;}
2982 case 82:
2983 #line 765 "./parse.y"
2984 { yyval.node = parse_jdk1_1_error ("instance initializer"); ;
2985     break;}
2986 case 84:
2987 #line 771 "./parse.y"
2988 { yyval.node = yyvsp[-1].node; ;
2989     break;}
2990 case 86:
2991 #line 774 "./parse.y"
2992 { yyval.node = parse_jdk1_1_error ("inner classe declaration"); ;
2993     break;}
2994 case 87:
2995 #line 776 "./parse.y"
2996 { yyval.node = parse_jdk1_1_error ("inner interface declaration"); ;
2997     break;}
2998 case 88:
2999 #line 782 "./parse.y"
3000 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3001     break;}
3002 case 89:
3003 #line 784 "./parse.y"
3004 {
3005                   check_modifiers 
3006                     ("Illegal modifier `%s' for field declaration",
3007                      yyvsp[-3].value, FIELD_MODIFIERS);
3008                   check_modifiers_consistency (yyvsp[-3].value);
3009                   register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3010                 ;
3011     break;}
3012 case 91:
3013 #line 797 "./parse.y"
3014 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3015     break;}
3016 case 92:
3017 #line 799 "./parse.y"
3018 {yyerror ("Missing term"); RECOVER;;
3019     break;}
3020 case 93:
3021 #line 804 "./parse.y"
3022 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3023     break;}
3024 case 94:
3025 #line 806 "./parse.y"
3026
3027                   if (java_error_count)
3028                     yyvsp[0].node = NULL_TREE;
3029                   yyval.node = build_tree_list 
3030                     (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3031                 ;
3032     break;}
3033 case 95:
3034 #line 813 "./parse.y"
3035 {
3036                   yyerror ("Missing variable initializer");
3037                   yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3038                   RECOVER;
3039                 ;
3040     break;}
3041 case 96:
3042 #line 819 "./parse.y"
3043 {
3044                   yyerror ("';' expected");
3045                   yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3046                   RECOVER;
3047                 ;
3048     break;}
3049 case 98:
3050 #line 829 "./parse.y"
3051 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3052     break;}
3053 case 99:
3054 #line 831 "./parse.y"
3055 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3056     break;}
3057 case 100:
3058 #line 833 "./parse.y"
3059 {yyerror ("']' expected"); DRECOVER(vdi);;
3060     break;}
3061 case 101:
3062 #line 835 "./parse.y"
3063 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3064     break;}
3065 case 104:
3066 #line 846 "./parse.y"
3067 {
3068                   current_function_decl = yyvsp[0].node;
3069                   source_start_java_method (current_function_decl);
3070                 ;
3071     break;}
3072 case 105:
3073 #line 851 "./parse.y"
3074 { finish_method_declaration (yyvsp[0].node); ;
3075     break;}
3076 case 106:
3077 #line 853 "./parse.y"
3078 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3079     break;}
3080 case 107:
3081 #line 858 "./parse.y"
3082 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3083     break;}
3084 case 108:
3085 #line 860 "./parse.y"
3086 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3087     break;}
3088 case 109:
3089 #line 862 "./parse.y"
3090 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3091     break;}
3092 case 110:
3093 #line 864 "./parse.y"
3094 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3095     break;}
3096 case 111:
3097 #line 866 "./parse.y"
3098 {RECOVER;;
3099     break;}
3100 case 112:
3101 #line 868 "./parse.y"
3102 {RECOVER;;
3103     break;}
3104 case 113:
3105 #line 870 "./parse.y"
3106 {yyerror ("Identifier expected"); RECOVER;;
3107     break;}
3108 case 114:
3109 #line 872 "./parse.y"
3110 {yyerror ("Identifier expected"); RECOVER;;
3111     break;}
3112 case 115:
3113 #line 874 "./parse.y"
3114 {
3115                   yyerror ("Invalid method declaration, return type required");
3116                   RECOVER;
3117                 ;
3118     break;}
3119 case 116:
3120 #line 882 "./parse.y"
3121 { yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE); ;
3122     break;}
3123 case 117:
3124 #line 884 "./parse.y"
3125 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3126     break;}
3127 case 118:
3128 #line 886 "./parse.y"
3129 {
3130                   EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3131                   TREE_PURPOSE (yyvsp[-2].node) = 
3132                     build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3133                   parse_warning_context 
3134                     (wfl_operator, 
3135                      "Discouraged form of returned type specification");
3136                 ;
3137     break;}
3138 case 119:
3139 #line 895 "./parse.y"
3140 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3141     break;}
3142 case 120:
3143 #line 897 "./parse.y"
3144 {yyerror ("']' expected"); RECOVER;;
3145     break;}
3146 case 121:
3147 #line 902 "./parse.y"
3148 {
3149                   ctxp->formal_parameter_number = 1;
3150                 ;
3151     break;}
3152 case 122:
3153 #line 906 "./parse.y"
3154 {
3155                   ctxp->formal_parameter_number += 1;
3156                   yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3157                 ;
3158     break;}
3159 case 123:
3160 #line 911 "./parse.y"
3161 {yyerror ("Missing formal parameter term"); RECOVER;;
3162     break;}
3163 case 124:
3164 #line 916 "./parse.y"
3165 {
3166                   yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3167                 ;
3168     break;}
3169 case 125:
3170 #line 920 "./parse.y"
3171
3172                   parse_jdk1_1_error ("final parameters");
3173                   yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3174                 ;
3175     break;}
3176 case 126:
3177 #line 925 "./parse.y"
3178 {yyerror ("Missing identifier"); RECOVER;;
3179     break;}
3180 case 127:
3181 #line 927 "./parse.y"
3182 {
3183                   SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[-2].value));
3184                   yyerror ("Missing identifier"); RECOVER;
3185                 ;
3186     break;}
3187 case 128:
3188 #line 934 "./parse.y"
3189 { yyval.node = NULL_TREE; ;
3190     break;}
3191 case 129:
3192 #line 936 "./parse.y"
3193 { yyval.node = yyvsp[0].node; ;
3194     break;}
3195 case 130:
3196 #line 938 "./parse.y"
3197 {yyerror ("Missing class type term"); RECOVER;;
3198     break;}
3199 case 131:
3200 #line 943 "./parse.y"
3201 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3202     break;}
3203 case 132:
3204 #line 945 "./parse.y"
3205 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3206     break;}
3207 case 133:
3208 #line 947 "./parse.y"
3209 {yyerror ("Missing class type term"); RECOVER;;
3210     break;}
3211 case 136:
3212 #line 954 "./parse.y"
3213 { yyval.node = NULL_TREE; ;
3214     break;}
3215 case 137:
3216 #line 960 "./parse.y"
3217 {
3218                   TREE_CHAIN (yyvsp[0].node) = ctxp->static_initialized;
3219                   ctxp->static_initialized = yyvsp[0].node;
3220                 ;
3221     break;}
3222 case 138:
3223 #line 965 "./parse.y"
3224 {
3225                   TREE_CHAIN (yyvsp[-1].node) = ctxp->static_initialized;
3226                   ctxp->static_initialized = yyvsp[-1].node;
3227                 ;
3228     break;}
3229 case 139:
3230 #line 973 "./parse.y"
3231 {
3232                   SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3233                 ;
3234     break;}
3235 case 140:
3236 #line 981 "./parse.y"
3237 {
3238                   current_function_decl = yyvsp[0].node;
3239                   source_start_java_method (current_function_decl);
3240                 ;
3241     break;}
3242 case 141:
3243 #line 986 "./parse.y"
3244 { finish_method_declaration (yyvsp[0].node); ;
3245     break;}
3246 case 142:
3247 #line 991 "./parse.y"
3248 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3249     break;}
3250 case 143:
3251 #line 993 "./parse.y"
3252 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3253     break;}
3254 case 144:
3255 #line 998 "./parse.y"
3256 { yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE); ;
3257     break;}
3258 case 145:
3259 #line 1000 "./parse.y"
3260 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3261     break;}
3262 case 146:
3263 #line 1008 "./parse.y"
3264
3265                   BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3266                   yyval.node = yyvsp[0].node;
3267                 ;
3268     break;}
3269 case 147:
3270 #line 1013 "./parse.y"
3271 { yyval.node = yyvsp[0].node; ;
3272     break;}
3273 case 148:
3274 #line 1015 "./parse.y"
3275 { yyval.node = yyvsp[0].node; ;
3276     break;}
3277 case 149:
3278 #line 1017 "./parse.y"
3279 { yyval.node = yyvsp[0].node; ;
3280     break;}
3281 case 152:
3282 #line 1027 "./parse.y"
3283
3284                   yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE); 
3285                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3286                   yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3287                 ;
3288     break;}
3289 case 153:
3290 #line 1033 "./parse.y"
3291
3292                   yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node); 
3293                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3294                   yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3295                 ;
3296     break;}
3297 case 154:
3298 #line 1041 "./parse.y"
3299 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3300     break;}
3301 case 155:
3302 #line 1043 "./parse.y"
3303 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3304     break;}
3305 case 156:
3306 #line 1048 "./parse.y"
3307 {
3308                   tree wfl = build_wfl_node (this_identifier_node);
3309                   EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3310                   yyval.node = wfl;
3311                 ;
3312     break;}
3313 case 157:
3314 #line 1054 "./parse.y"
3315 {
3316                   tree wfl = build_wfl_node (super_identifier_node);
3317                   EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3318                   yyval.node = wfl;
3319                 ;
3320     break;}
3321 case 158:
3322 #line 1065 "./parse.y"
3323 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3324     break;}
3325 case 159:
3326 #line 1067 "./parse.y"
3327 {
3328                   yyval.node = yyvsp[0].node;
3329                 ;
3330     break;}
3331 case 160:
3332 #line 1071 "./parse.y"
3333 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3334     break;}
3335 case 161:
3336 #line 1073 "./parse.y"
3337 {
3338                   yyval.node = yyvsp[0].node;
3339                 ;
3340     break;}
3341 case 162:
3342 #line 1077 "./parse.y"
3343 { create_interface (0, yyvsp[-1].node, yyvsp[0].node);  ;
3344     break;}
3345 case 163:
3346 #line 1079 "./parse.y"
3347 {
3348                   yyval.node = yyvsp[0].node;
3349                 ;
3350     break;}
3351 case 164:
3352 #line 1083 "./parse.y"
3353 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3354     break;}
3355 case 165:
3356 #line 1085 "./parse.y"
3357 {
3358                   yyval.node = yyvsp[0].node;
3359                 ;
3360     break;}
3361 case 166:
3362 #line 1089 "./parse.y"
3363 {yyerror ("'{' expected"); RECOVER;;
3364     break;}
3365 case 167:
3366 #line 1091 "./parse.y"
3367 {yyerror ("'{' expected"); RECOVER;;
3368     break;}
3369 case 168:
3370 #line 1096 "./parse.y"
3371
3372                   ctxp->interface_number = 1;
3373                   yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3374                 ;
3375     break;}
3376 case 169:
3377 #line 1101 "./parse.y"
3378
3379                   ctxp->interface_number++;
3380                   yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3381                 ;
3382     break;}
3383 case 170:
3384 #line 1106 "./parse.y"
3385 {yyerror ("Invalid interface type"); RECOVER;;
3386     break;}
3387 case 171:
3388 #line 1108 "./parse.y"
3389 {yyerror ("Missing term"); RECOVER;;
3390     break;}
3391 case 172:
3392 #line 1113 "./parse.y"
3393 { yyval.node = NULL_TREE; ;
3394     break;}
3395 case 173:
3396 #line 1115 "./parse.y"
3397 { yyval.node = NULL_TREE; ;
3398     break;}
3399 case 178:
3400 #line 1127 "./parse.y"
3401 { yyval.node = parse_jdk1_1_error ("inner class declaration"); ;
3402     break;}
3403 case 179:
3404 #line 1129 "./parse.y"
3405 { yyval.node = parse_jdk1_1_error ("inner interface declaration"); ;
3406     break;}
3407 case 181:
3408 #line 1138 "./parse.y"
3409
3410                   check_abstract_method_header (yyvsp[-1].node);
3411                   current_function_decl = NULL_TREE; /* FIXME ? */
3412                 ;
3413     break;}
3414 case 182:
3415 #line 1143 "./parse.y"
3416 {yyerror ("';' expected"); RECOVER;;
3417     break;}
3418 case 183:
3419 #line 1149 "./parse.y"
3420 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3421     break;}
3422 case 184:
3423 #line 1151 "./parse.y"
3424 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3425     break;}
3426 case 185:
3427 #line 1153 "./parse.y"
3428 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3429     break;}
3430 case 186:
3431 #line 1158 "./parse.y"
3432
3433                   yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), 
3434                                   yyvsp[0].node, NULL_TREE);
3435                 ;
3436     break;}
3437 case 187:
3438 #line 1163 "./parse.y"
3439 {
3440                   yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3441                 ;
3442     break;}
3443 case 188:
3444 #line 1167 "./parse.y"
3445 {yyerror ("Missing term"); RECOVER;;
3446     break;}
3447 case 189:
3448 #line 1173 "./parse.y"
3449
3450                   /* Store the location of the `}' when doing xrefs */
3451                   if (current_function_decl && flag_emit_xref)
3452                     DECL_END_SOURCE_LINE (current_function_decl) = 
3453                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3454                   yyval.node = empty_stmt_node; 
3455                 ;
3456     break;}
3457 case 190:
3458 #line 1181 "./parse.y"
3459 { yyval.node = yyvsp[0].node; ;
3460     break;}
3461 case 191:
3462 #line 1186 "./parse.y"
3463 { enter_block (); ;
3464     break;}
3465 case 192:
3466 #line 1191 "./parse.y"
3467
3468                   maybe_absorb_scoping_blocks ();
3469                   /* Store the location of the `}' when doing xrefs */
3470                   if (current_function_decl && flag_emit_xref)
3471                     DECL_END_SOURCE_LINE (current_function_decl) = 
3472                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);           
3473                   yyval.node = exit_block ();
3474                 ;
3475     break;}
3476 case 196:
3477 #line 1209 "./parse.y"
3478 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3479     break;}
3480 case 197:
3481 #line 1211 "./parse.y"
3482 { parse_jdk1_1_error ("inner class declaration"); ;
3483     break;}
3484 case 199:
3485 #line 1220 "./parse.y"
3486 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3487     break;}
3488 case 200:
3489 #line 1222 "./parse.y"
3490 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3491     break;}
3492 case 206:
3493 #line 1232 "./parse.y"
3494 { yyval.node = exit_block (); ;
3495     break;}
3496 case 211:
3497 #line 1241 "./parse.y"
3498 { yyval.node = exit_block (); ;
3499     break;}
3500 case 223:
3501 #line 1260 "./parse.y"
3502 { yyval.node = empty_stmt_node; ;
3503     break;}
3504 case 224:
3505 #line 1265 "./parse.y"
3506 {
3507                   yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node), 
3508                                             EXPR_WFL_NODE (yyvsp[-1].node));
3509                   pushlevel (2);
3510                   push_labeled_block (yyval.node);
3511                   PUSH_LABELED_BLOCK (yyval.node);
3512                 ;
3513     break;}
3514 case 225:
3515 #line 1276 "./parse.y"
3516 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3517     break;}
3518 case 226:
3519 #line 1278 "./parse.y"
3520 {yyerror ("':' expected"); RECOVER;;
3521     break;}
3522 case 227:
3523 #line 1283 "./parse.y"
3524 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3525     break;}
3526 case 228:
3527 #line 1290 "./parse.y"
3528 {
3529                   /* We have a statement. Generate a WFL around it so
3530                      we can debug it */
3531                   yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3532                   /* We know we have a statement, so set the debug
3533                      info to be eventually generate here. */
3534                   yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3535                 ;
3536     break;}
3537 case 229:
3538 #line 1299 "./parse.y"
3539 {
3540                   if (ctxp->prevent_ese != lineno)
3541                     yyerror ("Invalid expression statement");
3542                   DRECOVER (expr_stmt);
3543                 ;
3544     break;}
3545 case 230:
3546 #line 1305 "./parse.y"
3547 {
3548                   if (ctxp->prevent_ese != lineno)
3549                     yyerror ("Invalid expression statement");
3550                   DRECOVER (expr_stmt);
3551                 ;
3552     break;}
3553 case 231:
3554 #line 1311 "./parse.y"
3555 {
3556                   if (ctxp->prevent_ese != lineno)
3557                     yyerror ("Invalid expression statement");
3558                   DRECOVER (expr_stmt);
3559                 ;
3560     break;}
3561 case 232:
3562 #line 1317 "./parse.y"
3563 {yyerror ("')' expected"); RECOVER;;
3564     break;}
3565 case 233:
3566 #line 1319 "./parse.y"
3567 {
3568                   yyerror ("Constructor invocation must be first "
3569                            "thing in a constructor"); 
3570                   RECOVER;
3571                 ;
3572     break;}
3573 case 234:
3574 #line 1325 "./parse.y"
3575 {yyerror ("')' expected"); RECOVER;;
3576     break;}
3577 case 235:
3578 #line 1327 "./parse.y"
3579 {
3580                   yyerror ("Constructor invocation must be first "
3581                            "thing in a constructor"); 
3582                   RECOVER;
3583                 ;
3584     break;}
3585 case 236:
3586 #line 1333 "./parse.y"
3587 {yyerror ("'(' expected"); RECOVER;;
3588     break;}
3589 case 237:
3590 #line 1335 "./parse.y"
3591 {yyerror ("')' expected"); RECOVER;;
3592     break;}
3593 case 238:
3594 #line 1337 "./parse.y"
3595 {yyerror ("')' expected"); RECOVER;;
3596     break;}
3597 case 239:
3598 #line 1339 "./parse.y"
3599 {yyerror ("';' expected"); RECOVER;;
3600     break;}
3601 case 240:
3602 #line 1341 "./parse.y"
3603 {yyerror ("';' expected"); RECOVER;;
3604     break;}
3605 case 248:
3606 #line 1356 "./parse.y"
3607
3608                   yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node, 
3609                                                 yyvsp[0].node, NULL_TREE);
3610                 ;
3611     break;}
3612 case 249:
3613 #line 1361 "./parse.y"
3614 {yyerror ("'(' expected"); RECOVER;;
3615     break;}
3616 case 250:
3617 #line 1363 "./parse.y"
3618 {yyerror ("Missing term"); RECOVER;;
3619     break;}
3620 case 251:
3621 #line 1365 "./parse.y"
3622 {yyerror ("')' expected"); RECOVER;;
3623     break;}
3624 case 252:
3625 #line 1370 "./parse.y"
3626 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3627     break;}
3628 case 253:
3629 #line 1375 "./parse.y"
3630 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3631     break;}
3632 case 254:
3633 #line 1380 "./parse.y"
3634 {
3635                   enter_block ();
3636                 ;
3637     break;}
3638 case 255:
3639 #line 1384 "./parse.y"
3640
3641                   /* Make into "proper list" of COMPOUND_EXPRs.
3642                      I.e. make the last statment also have its own
3643                      COMPOUND_EXPR. */
3644                   maybe_absorb_scoping_blocks ();
3645                   TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
3646                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
3647                 ;
3648     break;}
3649 case 256:
3650 #line 1396 "./parse.y"
3651
3652                   yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3653                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3654                 ;
3655     break;}
3656 case 257:
3657 #line 1401 "./parse.y"
3658 {yyerror ("'(' expected"); RECOVER;;
3659     break;}
3660 case 258:
3661 #line 1403 "./parse.y"
3662 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3663     break;}
3664 case 259:
3665 #line 1405 "./parse.y"
3666 {yyerror ("'{' expected"); RECOVER;;
3667     break;}
3668 case 260:
3669 #line 1413 "./parse.y"
3670 { yyval.node = NULL_TREE; ;
3671     break;}
3672 case 261:
3673 #line 1415 "./parse.y"
3674 { yyval.node = NULL_TREE; ;
3675     break;}
3676 case 262:
3677 #line 1417 "./parse.y"
3678 { yyval.node = NULL_TREE; ;
3679     break;}
3680 case 263:
3681 #line 1419 "./parse.y"
3682 { yyval.node = NULL_TREE; ;
3683     break;}
3684 case 269:
3685 #line 1438 "./parse.y"
3686
3687                   tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3688                   EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
3689                   java_method_add_stmt (current_function_decl, lab);
3690                 ;
3691     break;}
3692 case 270:
3693 #line 1444 "./parse.y"
3694
3695                   tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3696                   EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
3697                   java_method_add_stmt (current_function_decl, lab);
3698                 ;
3699     break;}
3700 case 271:
3701 #line 1450 "./parse.y"
3702 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3703     break;}
3704 case 272:
3705 #line 1452 "./parse.y"
3706 {yyerror ("':' expected"); RECOVER;;
3707     break;}
3708 case 273:
3709 #line 1454 "./parse.y"
3710 {yyerror ("':' expected"); RECOVER;;
3711     break;}
3712 case 274:
3713 #line 1459 "./parse.y"
3714
3715                   tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3716                   yyval.node = build_new_loop (body);
3717                 ;
3718     break;}
3719 case 275:
3720 #line 1467 "./parse.y"
3721 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3722     break;}
3723 case 276:
3724 #line 1469 "./parse.y"
3725 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3726     break;}
3727 case 277:
3728 #line 1471 "./parse.y"
3729 {yyerror ("Missing term and ')' expected"); RECOVER;;
3730     break;}
3731 case 278:
3732 #line 1473 "./parse.y"
3733 {yyerror ("')' expected"); RECOVER;;
3734     break;}
3735 case 279:
3736 #line 1478 "./parse.y"
3737 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3738     break;}
3739 case 280:
3740 #line 1483 "./parse.y"
3741
3742                   tree body = build_loop_body (0, NULL_TREE, 1);
3743                   yyval.node = build_new_loop (body);
3744                 ;
3745     break;}
3746 case 281:
3747 #line 1492 "./parse.y"
3748 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3749     break;}
3750 case 282:
3751 #line 1497 "./parse.y"
3752 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3753     break;}
3754 case 283:
3755 #line 1499 "./parse.y"
3756
3757                   yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3758                   /* We have not condition, so we get rid of the EXIT_EXPR */
3759                   LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = 
3760                     empty_stmt_node;
3761                 ;
3762     break;}
3763 case 284:
3764 #line 1506 "./parse.y"
3765 {yyerror ("Invalid control expression"); RECOVER;;
3766     break;}
3767 case 285:
3768 #line 1508 "./parse.y"
3769 {yyerror ("Invalid update expression"); RECOVER;;
3770     break;}
3771 case 286:
3772 #line 1510 "./parse.y"
3773 {yyerror ("Invalid update expression"); RECOVER;;
3774     break;}
3775 case 287:
3776 #line 1515 "./parse.y"
3777 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
3778     break;}
3779 case 288:
3780 #line 1517 "./parse.y"
3781
3782                   yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3783                   /* We have not condition, so we get rid of the EXIT_EXPR */
3784                   LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = 
3785                     empty_stmt_node;
3786                 ;
3787     break;}
3788 case 289:
3789 #line 1527 "./parse.y"
3790
3791                   /* This scope defined for local variable that may be
3792                      defined within the scope of the for loop */
3793                   enter_block (); 
3794                 ;
3795     break;}
3796 case 290:
3797 #line 1533 "./parse.y"
3798 {yyerror ("'(' expected"); DRECOVER(for_1);;
3799     break;}
3800 case 291:
3801 #line 1535 "./parse.y"
3802 {yyerror ("Invalid init statement"); RECOVER;;
3803     break;}
3804 case 292:
3805 #line 1540 "./parse.y"
3806
3807                   /* We now declare the loop body. The loop is
3808                      declared as a for loop. */
3809                   tree body = build_loop_body (0, NULL_TREE, 0);
3810                   yyval.node =  build_new_loop (body);
3811                   IS_FOR_LOOP_P (yyval.node) = 1;
3812                   /* The loop is added to the current block the for
3813                      statement is defined within */
3814                   java_method_add_stmt (current_function_decl, yyval.node);
3815                 ;
3816     break;}
3817 case 293:
3818 #line 1552 "./parse.y"
3819 { yyval.node = empty_stmt_node; ;
3820     break;}
3821 case 294:
3822 #line 1554 "./parse.y"
3823
3824                   /* Init statement recorded within the previously
3825                      defined block scope */
3826                   yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
3827                 ;
3828     break;}
3829 case 295:
3830 #line 1560 "./parse.y"
3831
3832                   /* Local variable are recorded within the previously
3833                      defined block scope */
3834                   yyval.node = NULL_TREE;
3835                 ;
3836     break;}
3837 case 296:
3838 #line 1566 "./parse.y"
3839 {yyerror ("';' expected"); DRECOVER(for_init_1);;
3840     break;}
3841 case 297:
3842 #line 1570 "./parse.y"
3843 {yyval.node = empty_stmt_node;;
3844     break;}
3845 case 298:
3846 #line 1572 "./parse.y"
3847 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
3848     break;}
3849 case 299:
3850 #line 1577 "./parse.y"
3851 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
3852     break;}
3853 case 300:
3854 #line 1579 "./parse.y"
3855 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
3856     break;}
3857 case 301:
3858 #line 1581 "./parse.y"
3859 {yyerror ("Missing term"); RECOVER;;
3860     break;}
3861 case 302:
3862 #line 1586 "./parse.y"
3863 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
3864     break;}
3865 case 303:
3866 #line 1588 "./parse.y"
3867 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
3868     break;}
3869 case 304:
3870 #line 1590 "./parse.y"
3871 {yyerror ("Missing term"); RECOVER;;
3872     break;}
3873 case 305:
3874 #line 1592 "./parse.y"
3875 {yyerror ("';' expected"); RECOVER;;
3876     break;}
3877 case 306:
3878 #line 1597 "./parse.y"
3879 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
3880     break;}
3881 case 307:
3882 #line 1599 "./parse.y"
3883 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
3884     break;}
3885 case 308:
3886 #line 1601 "./parse.y"
3887 {yyerror ("Missing term"); RECOVER;;
3888     break;}
3889 case 309:
3890 #line 1603 "./parse.y"
3891 {yyerror ("';' expected"); RECOVER;;
3892     break;}
3893 case 310:
3894 #line 1608 "./parse.y"
3895 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
3896     break;}
3897 case 311:
3898 #line 1610 "./parse.y"
3899 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3900     break;}
3901 case 312:
3902 #line 1612 "./parse.y"
3903 {yyerror ("Missing term"); RECOVER;;
3904     break;}
3905 case 313:
3906 #line 1614 "./parse.y"
3907 {yyerror ("';' expected"); RECOVER;;
3908     break;}
3909 case 314:
3910 #line 1619 "./parse.y"
3911
3912                   yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
3913                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3914                 ;
3915     break;}
3916 case 315:
3917 #line 1624 "./parse.y"
3918 {yyerror ("Missing term"); RECOVER;;
3919     break;}
3920 case 316:
3921 #line 1626 "./parse.y"
3922 {yyerror ("';' expected"); RECOVER;;
3923     break;}
3924 case 317:
3925 #line 1631 "./parse.y"
3926
3927                   yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3928                   EXPR_WFL_LINECOL (yyval.node) = 
3929                     EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
3930                 ;
3931     break;}
3932 case 318:
3933 #line 1637 "./parse.y"
3934 {yyerror ("'{' expected"); RECOVER;;
3935     break;}
3936 case 319:
3937 #line 1639 "./parse.y"
3938 {yyerror ("'(' expected"); RECOVER;;
3939     break;}
3940 case 320:
3941 #line 1641 "./parse.y"
3942 {yyerror ("Missing term"); RECOVER;;
3943     break;}
3944 case 321:
3945 #line 1643 "./parse.y"
3946 {yyerror ("Missing term"); RECOVER;;
3947     break;}
3948 case 322:
3949 #line 1648 "./parse.y"
3950 {
3951                   if ((1 << yyvsp[0].value) != ACC_SYNCHRONIZED)
3952                     fatal ("synchronized was '%d' - yyparse", (1 << yyvsp[0].value));
3953                 ;
3954     break;}
3955 case 323:
3956 #line 1656 "./parse.y"
3957 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
3958     break;}
3959 case 324:
3960 #line 1658 "./parse.y"
3961 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
3962     break;}
3963 case 325:
3964 #line 1660 "./parse.y"
3965 { yyval.node = build_try_finally_statement 
3966                     (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
3967                                                        yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
3968                 ;
3969     break;}
3970 case 326:
3971 #line 1665 "./parse.y"
3972 {yyerror ("'{' expected"); DRECOVER (try_statement);;
3973     break;}
3974 case 328:
3975 #line 1671 "./parse.y"
3976
3977                   TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
3978                   yyval.node = yyvsp[0].node;
3979                 ;
3980     break;}
3981 case 329:
3982 #line 1679 "./parse.y"
3983
3984                   java_method_add_stmt (current_function_decl, yyvsp[0].node);
3985                   exit_block ();
3986                   yyval.node = yyvsp[-1].node;
3987                 ;
3988     break;}
3989 case 330:
3990 #line 1687 "./parse.y"
3991
3992                   /* We add a block to define a scope for
3993                      formal_parameter (CCBP). The formal parameter is
3994                      declared initialized by the appropriate function
3995                      call */
3996                   tree ccpb = enter_block ();
3997                   tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location, 
3998                                                 TREE_PURPOSE (yyvsp[-1].node), 
3999                                                 soft_exceptioninfo_call_node);
4000                   declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4001                                            build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
4002                                                             init));
4003                   yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4004                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4005                 ;
4006     break;}
4007 case 331:
4008 #line 1703 "./parse.y"
4009 {yyerror ("'(' expected"); RECOVER;;
4010     break;}
4011 case 332:
4012 #line 1705 "./parse.y"
4013 {yyerror ("Missing term or ')' expected"); DRECOVER (2);;
4014     break;}
4015 case 333:
4016 #line 1707 "./parse.y"
4017 {yyerror ("')' expected"); DRECOVER (1);;
4018     break;}
4019 case 334:
4020 #line 1712 "./parse.y"
4021 { yyval.node = yyvsp[0].node; ;
4022     break;}
4023 case 335:
4024 #line 1714 "./parse.y"
4025 {yyerror ("'{' expected"); RECOVER; ;
4026     break;}
4027 case 339:
4028 #line 1726 "./parse.y"
4029 { yyval.node = build_this (yyvsp[0].operator.location); ;
4030     break;}
4031 case 340:
4032 #line 1728 "./parse.y"
4033 {yyval.node = yyvsp[-1].node;;
4034     break;}
4035 case 345:
4036 #line 1737 "./parse.y"
4037 { yyval.node = parse_jdk1_1_error ("named class literals"); ;
4038     break;}
4039 case 346:
4040 #line 1739 "./parse.y"
4041 { yyval.node = build_class_ref (yyvsp[-2].node); ;
4042     break;}
4043 case 347:
4044 #line 1741 "./parse.y"
4045 { yyval.node = build_class_ref (void_type_node); ;
4046     break;}
4047 case 348:
4048 #line 1746 "./parse.y"
4049 { yyval.node = parse_jdk1_1_error ("class literals"); ;
4050     break;}
4051 case 349:
4052 #line 1748 "./parse.y"
4053 {yyerror ("')' expected"); RECOVER;;
4054     break;}
4055 case 350:
4056 #line 1750 "./parse.y"
4057 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4058     break;}
4059 case 351:
4060 #line 1752 "./parse.y"
4061 {yyerror ("'class' expected" ); RECOVER;;
4062     break;}
4063 case 352:
4064 #line 1754 "./parse.y"
4065 {yyerror ("'class' expected" ); RECOVER;;
4066     break;}
4067 case 353:
4068 #line 1759 "./parse.y"
4069 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4070     break;}
4071 case 354:
4072 #line 1761 "./parse.y"
4073 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4074     break;}
4075 case 355:
4076 #line 1766 "./parse.y"
4077 { yyval.node = parse_jdk1_1_error ("inner class instance creation"); ;
4078     break;}
4079 case 356:
4080 #line 1768 "./parse.y"
4081 { yyval.node = parse_jdk1_1_error ("inner class instance creation"); ;
4082     break;}
4083 case 361:
4084 #line 1777 "./parse.y"
4085 {yyerror ("'(' expected"); DRECOVER(new_1);;
4086     break;}
4087 case 362:
4088 #line 1779 "./parse.y"
4089 {yyerror ("'(' expected"); RECOVER;;
4090     break;}
4091 case 363:
4092 #line 1781 "./parse.y"
4093 {yyerror ("')' or term expected"); RECOVER;;
4094     break;}
4095 case 364:
4096 #line 1783 "./parse.y"
4097 {yyerror ("')' expected"); RECOVER;;
4098     break;}
4099 case 365:
4100 #line 1785 "./parse.y"
4101 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4102     break;}
4103 case 366:
4104 #line 1787 "./parse.y"
4105 {yyerror ("'(' expected"); RECOVER;;
4106     break;}
4107 case 369:
4108 #line 1797 "./parse.y"
4109
4110                   yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4111                   ctxp->formal_parameter_number = 1; 
4112                 ;
4113     break;}
4114 case 370:
4115 #line 1802 "./parse.y"
4116 {
4117                   ctxp->formal_parameter_number += 1;
4118                   yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4119                 ;
4120     break;}
4121 case 371:
4122 #line 1807 "./parse.y"
4123 {yyerror ("Missing term"); RECOVER;;
4124     break;}
4125 case 372:
4126 #line 1812 "./parse.y"
4127 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4128     break;}
4129 case 373:
4130 #line 1814 "./parse.y"
4131 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4132     break;}
4133 case 374:
4134 #line 1816 "./parse.y"
4135 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4136     break;}
4137 case 375:
4138 #line 1818 "./parse.y"
4139 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4140     break;}
4141 case 376:
4142 #line 1822 "./parse.y"
4143 { yyval.node = parse_jdk1_1_error ("anonymous array"); ;
4144     break;}
4145 case 377:
4146 #line 1824 "./parse.y"
4147 { yyval.node = parse_jdk1_1_error ("anonymous array"); ;
4148     break;}
4149 case 378:
4150 #line 1826 "./parse.y"
4151 {yyerror ("'[' expected"); DRECOVER ("]");;
4152     break;}
4153 case 379:
4154 #line 1828 "./parse.y"
4155 {yyerror ("']' expected"); RECOVER;;
4156     break;}
4157 case 380:
4158 #line 1833 "./parse.y"
4159 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4160     break;}
4161 case 381:
4162 #line 1835 "./parse.y"
4163 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4164     break;}
4165 case 382:
4166 #line 1840 "./parse.y"
4167
4168                   EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4169                   yyval.node = yyvsp[-1].node;
4170                 ;
4171     break;}
4172 case 383:
4173 #line 1845 "./parse.y"
4174 {yyerror ("']' expected"); RECOVER;;
4175     break;}
4176 case 384:
4177 #line 1847 "./parse.y"
4178 {
4179                   yyerror ("Missing term");
4180                   yyerror ("']' expected");
4181                   RECOVER;
4182                 ;
4183     break;}
4184 case 385:
4185 #line 1856 "./parse.y"
4186
4187                   int allocate = 0;
4188                   /* If not initialized, allocate memory for the osb
4189                      numbers stack */
4190                   if (!ctxp->osb_limit)
4191                     {
4192                       allocate = ctxp->osb_limit = 32;
4193                       ctxp->osb_depth = -1;
4194                     }
4195                   /* If capacity overflown, reallocate a bigger chuck */
4196                   else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4197                     allocate = ctxp->osb_limit << 1;
4198                   
4199                   if (allocate)
4200                     {
4201                       allocate *= sizeof (int);
4202                       if (ctxp->osb_number)
4203                         ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
4204                                                             allocate);
4205                       else
4206                         ctxp->osb_number = (int *)xmalloc (allocate);
4207                     }
4208                   ctxp->osb_depth++;
4209                   CURRENT_OSB (ctxp) = 1;
4210                 ;
4211     break;}
4212 case 386:
4213 #line 1882 "./parse.y"
4214 { CURRENT_OSB (ctxp)++; ;
4215     break;}
4216 case 387:
4217 #line 1884 "./parse.y"
4218 { yyerror ("']' expected"); RECOVER;;
4219     break;}
4220 case 388:
4221 #line 1889 "./parse.y"
4222 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4223     break;}
4224 case 389:
4225 #line 1893 "./parse.y"
4226 {
4227                   tree super_wfl = 
4228                     build_wfl_node (super_identifier_node);
4229                   EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4230                   yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4231                 ;
4232     break;}
4233 case 390:
4234 #line 1900 "./parse.y"
4235 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4236     break;}
4237 case 391:
4238 #line 1905 "./parse.y"
4239 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4240     break;}
4241 case 392:
4242 #line 1907 "./parse.y"
4243 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4244     break;}
4245 case 393:
4246 #line 1909 "./parse.y"
4247
4248                   if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4249                     yyval.node = build_this_super_qualified_invocation 
4250                       (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4251                   else
4252                     {
4253                       tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4254                       yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4255                     }
4256                 ;
4257     break;}
4258 case 394:
4259 #line 1920 "./parse.y"
4260
4261                   if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4262                     yyval.node = build_this_super_qualified_invocation 
4263                       (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4264                   else
4265                     {
4266                       tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4267                       yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4268                     }
4269                 ;
4270     break;}
4271 case 395:
4272 #line 1931 "./parse.y"
4273
4274                   yyval.node = build_this_super_qualified_invocation 
4275                     (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4276                 ;
4277     break;}
4278 case 396:
4279 #line 1936 "./parse.y"
4280 {
4281                   yyval.node = build_this_super_qualified_invocation 
4282                     (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4283                 ;
4284     break;}
4285 case 397:
4286 #line 1945 "./parse.y"
4287 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4288     break;}
4289 case 398:
4290 #line 1947 "./parse.y"
4291 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4292     break;}
4293 case 399:
4294 #line 1952 "./parse.y"
4295 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4296     break;}
4297 case 400:
4298 #line 1954 "./parse.y"
4299 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4300     break;}
4301 case 401:
4302 #line 1956 "./parse.y"
4303 {
4304                   yyerror ("Missing term and ']' expected");
4305                   DRECOVER(array_access);
4306                 ;
4307     break;}
4308 case 402:
4309 #line 1961 "./parse.y"
4310 {
4311                   yyerror ("']' expected");
4312                   DRECOVER(array_access);
4313                 ;
4314     break;}
4315 case 403:
4316 #line 1966 "./parse.y"
4317 {
4318                   yyerror ("Missing term and ']' expected");
4319                   DRECOVER(array_access);
4320                 ;
4321     break;}
4322 case 404:
4323 #line 1971 "./parse.y"
4324 {
4325                   yyerror ("']' expected");
4326                   DRECOVER(array_access);
4327                 ;
4328     break;}
4329 case 409:
4330 #line 1986 "./parse.y"
4331 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4332     break;}
4333 case 410:
4334 #line 1991 "./parse.y"
4335 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4336     break;}
4337 case 413:
4338 #line 1998 "./parse.y"
4339 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4340     break;}
4341 case 414:
4342 #line 2000 "./parse.y"
4343 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4344     break;}
4345 case 416:
4346 #line 2003 "./parse.y"
4347 {yyerror ("Missing term"); RECOVER;
4348     break;}
4349 case 417:
4350 #line 2005 "./parse.y"
4351 {yyerror ("Missing term"); RECOVER;
4352     break;}
4353 case 418:
4354 #line 2010 "./parse.y"
4355 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4356     break;}
4357 case 419:
4358 #line 2012 "./parse.y"
4359 {yyerror ("Missing term"); RECOVER;
4360     break;}
4361 case 420:
4362 #line 2017 "./parse.y"
4363 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4364     break;}
4365 case 421:
4366 #line 2019 "./parse.y"
4367 {yyerror ("Missing term"); RECOVER;
4368     break;}
4369 case 423:
4370 #line 2025 "./parse.y"
4371 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4372     break;}
4373 case 424:
4374 #line 2027 "./parse.y"
4375 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4376     break;}
4377 case 426:
4378 #line 2030 "./parse.y"
4379 {yyerror ("Missing term"); RECOVER;
4380     break;}
4381 case 427:
4382 #line 2032 "./parse.y"
4383 {yyerror ("Missing term"); RECOVER;
4384     break;}
4385 case 428:
4386 #line 2037 "./parse.y"
4387
4388                   tree type = yyvsp[-3].node;
4389                   while (CURRENT_OSB (ctxp)--)
4390                     type = build_java_array_type (type, -1);
4391                   ctxp->osb_depth--;
4392                   yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node); 
4393                 ;
4394     break;}
4395 case 429:
4396 #line 2045 "./parse.y"
4397 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4398     break;}
4399 case 430:
4400 #line 2047 "./parse.y"
4401 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4402     break;}
4403 case 431:
4404 #line 2049 "./parse.y"
4405
4406                   char *ptr;
4407                   while (CURRENT_OSB (ctxp)--)
4408                     obstack_1grow (&temporary_obstack, '[');
4409                   ctxp->osb_depth--;
4410                   obstack_grow0 (&temporary_obstack, 
4411                                  IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4412                                  IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4413                   ptr = obstack_finish (&temporary_obstack);
4414                   EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4415                   yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4416                 ;
4417     break;}
4418 case 432:
4419 #line 2062 "./parse.y"
4420 {yyerror ("']' expected, invalid type expression");;
4421     break;}
4422 case 433:
4423 #line 2064 "./parse.y"
4424 {
4425                   if (ctxp->prevent_ese != lineno)
4426                     yyerror ("Invalid type expression"); RECOVER;
4427                   RECOVER;
4428                 ;
4429     break;}
4430 case 434:
4431 #line 2070 "./parse.y"
4432 {yyerror ("Missing term"); RECOVER;;
4433     break;}
4434 case 435:
4435 #line 2072 "./parse.y"
4436 {yyerror ("Missing term"); RECOVER;;
4437     break;}
4438 case 436:
4439 #line 2074 "./parse.y"
4440 {yyerror ("Missing term"); RECOVER;;
4441     break;}
4442 case 438:
4443 #line 2080 "./parse.y"
4444
4445                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), 
4446                                     yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4447                 ;
4448     break;}
4449 case 439:
4450 #line 2085 "./parse.y"
4451 {
4452                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4453                                     yyvsp[-2].node, yyvsp[0].node); 
4454                 ;
4455     break;}
4456 case 440:
4457 #line 2090 "./parse.y"
4458 {
4459                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4460                                     yyvsp[-2].node, yyvsp[0].node); 
4461                 ;
4462     break;}
4463 case 441:
4464 #line 2095 "./parse.y"
4465 {yyerror ("Missing term"); RECOVER;;
4466     break;}
4467 case 442:
4468 #line 2097 "./parse.y"
4469 {yyerror ("Missing term"); RECOVER;;
4470     break;}
4471 case 443:
4472 #line 2099 "./parse.y"
4473 {yyerror ("Missing term"); RECOVER;;
4474     break;}
4475 case 445:
4476 #line 2105 "./parse.y"
4477 {
4478                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4479                                     yyvsp[-2].node, yyvsp[0].node); 
4480                 ;
4481     break;}
4482 case 446:
4483 #line 2110 "./parse.y"
4484 {
4485                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4486                                     yyvsp[-2].node, yyvsp[0].node); 
4487                 ;
4488     break;}
4489 case 447:
4490 #line 2115 "./parse.y"
4491 {yyerror ("Missing term"); RECOVER;;
4492     break;}
4493 case 448:
4494 #line 2117 "./parse.y"
4495 {yyerror ("Missing term"); RECOVER;;
4496     break;}
4497 case 450:
4498 #line 2123 "./parse.y"
4499 {
4500                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4501                                     yyvsp[-2].node, yyvsp[0].node); 
4502                 ;
4503     break;}
4504 case 451:
4505 #line 2128 "./parse.y"
4506 {
4507                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4508                                     yyvsp[-2].node, yyvsp[0].node); 
4509                 ;
4510     break;}
4511 case 452:
4512 #line 2133 "./parse.y"
4513 {
4514                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4515                                     yyvsp[-2].node, yyvsp[0].node); 
4516                 ;
4517     break;}
4518 case 453:
4519 #line 2138 "./parse.y"
4520 {yyerror ("Missing term"); RECOVER;;
4521     break;}
4522 case 454:
4523 #line 2140 "./parse.y"
4524 {yyerror ("Missing term"); RECOVER;;
4525     break;}
4526 case 455:
4527 #line 2142 "./parse.y"
4528 {yyerror ("Missing term"); RECOVER;;
4529     break;}
4530 case 457:
4531 #line 2148 "./parse.y"
4532 {
4533                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4534                                     yyvsp[-2].node, yyvsp[0].node); 
4535                 ;
4536     break;}
4537 case 458:
4538 #line 2153 "./parse.y"
4539 {
4540                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4541                                     yyvsp[-2].node, yyvsp[0].node); 
4542                 ;
4543     break;}
4544 case 459:
4545 #line 2158 "./parse.y"
4546 {
4547                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4548                                     yyvsp[-2].node, yyvsp[0].node); 
4549                 ;
4550     break;}
4551 case 460:
4552 #line 2163 "./parse.y"
4553 {
4554                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4555                                     yyvsp[-2].node, yyvsp[0].node); 
4556                 ;
4557     break;}
4558 case 461:
4559 #line 2168 "./parse.y"
4560 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4561     break;}
4562 case 462:
4563 #line 2170 "./parse.y"
4564 {yyerror ("Missing term"); RECOVER;;
4565     break;}
4566 case 463:
4567 #line 2172 "./parse.y"
4568 {yyerror ("Missing term"); RECOVER;;
4569     break;}
4570 case 464:
4571 #line 2174 "./parse.y"
4572 {yyerror ("Missing term"); RECOVER;;
4573     break;}
4574 case 465:
4575 #line 2176 "./parse.y"
4576 {yyerror ("Missing term"); RECOVER;;
4577     break;}
4578 case 466:
4579 #line 2178 "./parse.y"
4580 {yyerror ("Invalid reference type"); RECOVER;;
4581     break;}
4582 case 468:
4583 #line 2184 "./parse.y"
4584 {
4585                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4586                                     yyvsp[-2].node, yyvsp[0].node); 
4587                 ;
4588     break;}
4589 case 469:
4590 #line 2189 "./parse.y"
4591 {
4592                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4593                                     yyvsp[-2].node, yyvsp[0].node); 
4594                 ;
4595     break;}
4596 case 470:
4597 #line 2194 "./parse.y"
4598 {yyerror ("Missing term"); RECOVER;;
4599     break;}
4600 case 471:
4601 #line 2196 "./parse.y"
4602 {yyerror ("Missing term"); RECOVER;;
4603     break;}
4604 case 473:
4605 #line 2202 "./parse.y"
4606 {
4607                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4608                                     yyvsp[-2].node, yyvsp[0].node); 
4609                 ;
4610     break;}
4611 case 474:
4612 #line 2207 "./parse.y"
4613 {yyerror ("Missing term"); RECOVER;;
4614     break;}
4615 case 476:
4616 #line 2213 "./parse.y"
4617 {
4618                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4619                                     yyvsp[-2].node, yyvsp[0].node); 
4620                 ;
4621     break;}
4622 case 477:
4623 #line 2218 "./parse.y"
4624 {yyerror ("Missing term"); RECOVER;;
4625     break;}
4626 case 479:
4627 #line 2224 "./parse.y"
4628 {
4629                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4630                                     yyvsp[-2].node, yyvsp[0].node); 
4631                 ;
4632     break;}
4633 case 480:
4634 #line 2229 "./parse.y"
4635 {yyerror ("Missing term"); RECOVER;;
4636     break;}
4637 case 482:
4638 #line 2235 "./parse.y"
4639 {
4640                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4641                                     yyvsp[-2].node, yyvsp[0].node); 
4642                 ;
4643     break;}
4644 case 483:
4645 #line 2240 "./parse.y"
4646 {yyerror ("Missing term"); RECOVER;;
4647     break;}
4648 case 485:
4649 #line 2246 "./parse.y"
4650 {
4651                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4652                                     yyvsp[-2].node, yyvsp[0].node); 
4653                 ;
4654     break;}
4655 case 486:
4656 #line 2251 "./parse.y"
4657 {yyerror ("Missing term"); RECOVER;;
4658     break;}
4659 case 488:
4660 #line 2257 "./parse.y"
4661 {
4662                   yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
4663                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4664                 ;
4665     break;}
4666 case 489:
4667 #line 2262 "./parse.y"
4668 {
4669                   YYERROR_NOW;
4670                   yyerror ("Missing term");
4671                   DRECOVER (1);
4672                 ;
4673     break;}
4674 case 490:
4675 #line 2268 "./parse.y"
4676 {yyerror ("Missing term"); DRECOVER (2);;
4677     break;}
4678 case 491:
4679 #line 2270 "./parse.y"
4680 {yyerror ("Missing term"); DRECOVER (3);;
4681     break;}
4682 case 494:
4683 #line 2280 "./parse.y"
4684 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4685     break;}
4686 case 495:
4687 #line 2282 "./parse.y"
4688 {
4689                   if (ctxp->prevent_ese != lineno)
4690                     yyerror ("Missing term");
4691                   DRECOVER (assign);
4692                 ;
4693     break;}
4694 }
4695    /* the action file gets copied in in place of this dollarsign */
4696 #line 498 "/usr/lib/bison.simple"
4697 \f
4698   yyvsp -= yylen;
4699   yyssp -= yylen;
4700 #ifdef YYLSP_NEEDED
4701   yylsp -= yylen;
4702 #endif
4703
4704 #if YYDEBUG != 0
4705   if (yydebug)
4706     {
4707       short *ssp1 = yyss - 1;
4708       fprintf (stderr, "state stack now");
4709       while (ssp1 != yyssp)
4710         fprintf (stderr, " %d", *++ssp1);
4711       fprintf (stderr, "\n");
4712     }
4713 #endif
4714
4715   *++yyvsp = yyval;
4716
4717 #ifdef YYLSP_NEEDED
4718   yylsp++;
4719   if (yylen == 0)
4720     {
4721       yylsp->first_line = yylloc.first_line;
4722       yylsp->first_column = yylloc.first_column;
4723       yylsp->last_line = (yylsp-1)->last_line;
4724       yylsp->last_column = (yylsp-1)->last_column;
4725       yylsp->text = 0;
4726     }
4727   else
4728     {
4729       yylsp->last_line = (yylsp+yylen-1)->last_line;
4730       yylsp->last_column = (yylsp+yylen-1)->last_column;
4731     }
4732 #endif
4733
4734   /* Now "shift" the result of the reduction.
4735      Determine what state that goes to,
4736      based on the state we popped back to
4737      and the rule number reduced by.  */
4738
4739   yyn = yyr1[yyn];
4740
4741   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4742   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4743     yystate = yytable[yystate];
4744   else
4745     yystate = yydefgoto[yyn - YYNTBASE];
4746
4747   goto yynewstate;
4748
4749 yyerrlab:   /* here on detecting error */
4750
4751   if (! yyerrstatus)
4752     /* If not already recovering from an error, report this error.  */
4753     {
4754       ++yynerrs;
4755
4756 #ifdef YYERROR_VERBOSE
4757       yyn = yypact[yystate];
4758
4759       if (yyn > YYFLAG && yyn < YYLAST)
4760         {
4761           int size = 0;
4762           char *msg;
4763           int x, count;
4764
4765           count = 0;
4766           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
4767           for (x = (yyn < 0 ? -yyn : 0);
4768                x < (sizeof(yytname) / sizeof(char *)); x++)
4769             if (yycheck[x + yyn] == x)
4770               size += strlen(yytname[x]) + 15, count++;
4771           msg = (char *) malloc(size + 15);
4772           if (msg != 0)
4773             {
4774               strcpy(msg, "parse error");
4775
4776               if (count < 5)
4777                 {
4778                   count = 0;
4779                   for (x = (yyn < 0 ? -yyn : 0);
4780                        x < (sizeof(yytname) / sizeof(char *)); x++)
4781                     if (yycheck[x + yyn] == x)
4782                       {
4783                         strcat(msg, count == 0 ? ", expecting `" : " or `");
4784                         strcat(msg, yytname[x]);
4785                         strcat(msg, "'");
4786                         count++;
4787                       }
4788                 }
4789               yyerror(msg);
4790               free(msg);
4791             }
4792           else
4793             yyerror ("parse error; also virtual memory exceeded");
4794         }
4795       else
4796 #endif /* YYERROR_VERBOSE */
4797         yyerror("parse error");
4798     }
4799
4800   goto yyerrlab1;
4801 yyerrlab1:   /* here on error raised explicitly by an action */
4802
4803   if (yyerrstatus == 3)
4804     {
4805       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
4806
4807       /* return failure if at end of input */
4808       if (yychar == YYEOF)
4809         YYABORT;
4810
4811 #if YYDEBUG != 0
4812       if (yydebug)
4813         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4814 #endif
4815
4816       yychar = YYEMPTY;
4817     }
4818
4819   /* Else will try to reuse lookahead token
4820      after shifting the error token.  */
4821
4822   yyerrstatus = 3;              /* Each real token shifted decrements this */
4823
4824   goto yyerrhandle;
4825
4826 yyerrdefault:  /* current state does not do anything special for the error token. */
4827
4828 #if 0
4829   /* This is wrong; only states that explicitly want error tokens
4830      should shift them.  */
4831   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
4832   if (yyn) goto yydefault;
4833 #endif
4834
4835 yyerrpop:   /* pop the current state because it cannot handle the error token */
4836
4837   if (yyssp == yyss) YYABORT;
4838   yyvsp--;
4839   yystate = *--yyssp;
4840 #ifdef YYLSP_NEEDED
4841   yylsp--;
4842 #endif
4843
4844 #if YYDEBUG != 0
4845   if (yydebug)
4846     {
4847       short *ssp1 = yyss - 1;
4848       fprintf (stderr, "Error: state stack now");
4849       while (ssp1 != yyssp)
4850         fprintf (stderr, " %d", *++ssp1);
4851       fprintf (stderr, "\n");
4852     }
4853 #endif
4854
4855 yyerrhandle:
4856
4857   yyn = yypact[yystate];
4858   if (yyn == YYFLAG)
4859     goto yyerrdefault;
4860
4861   yyn += YYTERROR;
4862   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4863     goto yyerrdefault;
4864
4865   yyn = yytable[yyn];
4866   if (yyn < 0)
4867     {
4868       if (yyn == YYFLAG)
4869         goto yyerrpop;
4870       yyn = -yyn;
4871       goto yyreduce;
4872     }
4873   else if (yyn == 0)
4874     goto yyerrpop;
4875
4876   if (yyn == YYFINAL)
4877     YYACCEPT;
4878
4879 #if YYDEBUG != 0
4880   if (yydebug)
4881     fprintf(stderr, "Shifting error token, ");
4882 #endif
4883
4884   *++yyvsp = yylval;
4885 #ifdef YYLSP_NEEDED
4886   *++yylsp = yylloc;
4887 #endif
4888
4889   yystate = yyn;
4890   goto yynewstate;
4891 }
4892 #line 2308 "./parse.y"
4893
4894 \f
4895
4896 /* Flag for the error report routine to issue the error the first time
4897    it's called (overriding the default behavior which is to drop the
4898    first invocation and honor the second one, taking advantage of a
4899    richer context.  */
4900 static int force_error = 0;
4901
4902 /* Create a new parser context and make it the current one. */
4903
4904 void
4905 java_push_parser_context ()
4906 {
4907   struct parser_ctxt *new = 
4908     (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
4909
4910   bzero ((PTR) new, sizeof (struct parser_ctxt));
4911   new->next = ctxp;
4912   ctxp = new;
4913   if (ctxp->next)
4914     {
4915       ctxp->incomplete_class = ctxp->next->incomplete_class;
4916       ctxp->gclass_list = ctxp->next->gclass_list;
4917     }
4918 }  
4919
4920 /* If the first file of a file list was a class file, no context
4921    exists for a source file to be parsed. This boolean remembers that
4922    java_parser_context_save_global might have created a dummy one, so
4923    that java_parser_context_restore_global can pop it.  */
4924 static int extra_ctxp_pushed_p = 0;
4925
4926 void
4927 java_parser_context_save_global ()
4928 {
4929   if (!ctxp)
4930     {
4931       java_push_parser_context ();
4932       extra_ctxp_pushed_p = 1;
4933     }
4934   ctxp->finput = finput;
4935   ctxp->lineno = lineno;
4936   ctxp->current_class = current_class;
4937   ctxp->filename = input_filename;
4938   ctxp->current_function_decl = current_function_decl;
4939 }
4940
4941 void
4942 java_parser_context_restore_global ()
4943 {
4944   finput = ctxp->finput;
4945   lineno = ctxp->lineno;
4946   current_class = ctxp->current_class;
4947   input_filename = ctxp->filename;
4948   current_function_decl = ctxp->current_function_decl;
4949   if (!ctxp->next && extra_ctxp_pushed_p)
4950     {
4951       java_pop_parser_context (0);
4952       extra_ctxp_pushed_p = 0;
4953     }
4954 }
4955
4956 void 
4957 java_pop_parser_context (generate)
4958      int generate;
4959 {
4960   tree current;
4961   struct parser_ctxt *toFree, *next;
4962
4963   if (!ctxp)
4964     return;
4965
4966   toFree = ctxp;
4967   next = ctxp->next;
4968   if (next)
4969     {
4970       next->incomplete_class = ctxp->incomplete_class;
4971       next->gclass_list = ctxp->gclass_list;
4972       lineno = ctxp->lineno;
4973       finput = ctxp->finput;
4974       current_class = ctxp->current_class;
4975     }
4976
4977   /* Set the single import class file flag to 0 for the current list
4978      of imported things */
4979   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
4980     IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
4981
4982   /* And restore those of the previous context */
4983   if ((ctxp = next))            /* Assignment is really meant here */
4984     for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
4985       IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
4986
4987   if (generate)
4988     {
4989       toFree->next = ctxp_for_generation;
4990       ctxp_for_generation = toFree;
4991     }
4992   else
4993     free (toFree);
4994 }
4995
4996 /* Reporting JDK1.1 features not implemented */
4997
4998 static tree
4999 parse_jdk1_1_error (msg)
5000     char *msg;
5001 {
5002   sorry (": `%s' JDK1.1(TM) feature", msg);
5003   java_error_count++;
5004   return empty_stmt_node;
5005 }
5006
5007 static int do_warning = 0;
5008
5009 void
5010 yyerror (msg)
5011      char *msg;
5012 {
5013   static java_lc elc;
5014   static int  prev_lineno;
5015   static char *prev_msg;
5016
5017   int save_lineno;
5018   char *remainder, *code_from_source;
5019   extern struct obstack temporary_obstack;
5020   
5021   if (!force_error && prev_lineno == lineno)
5022     return;
5023
5024   /* Save current error location but report latter, when the context is
5025      richer.  */
5026   if (ctxp->java_error_flag == 0)
5027     {
5028       ctxp->java_error_flag = 1;
5029       elc = ctxp->elc;
5030       /* Do something to use the previous line if we're reaching the
5031          end of the file... */
5032 #ifdef VERBOSE_SKELETON
5033       printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5034 #endif
5035       return;
5036     }
5037
5038   /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5039   if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5040     return;
5041
5042   ctxp->java_error_flag = 0;
5043   if (do_warning)
5044     java_warning_count++;
5045   else
5046     java_error_count++;
5047   
5048   if (elc.col == 0 && msg[1] == ';')
5049     {
5050       elc.col  = ctxp->p_line->char_col-1;
5051       elc.line = ctxp->p_line->lineno;
5052     }
5053
5054   save_lineno = lineno;
5055   prev_lineno = lineno = elc.line;
5056   prev_msg = msg;
5057
5058   code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5059   obstack_grow0 (&temporary_obstack, 
5060                  code_from_source, strlen (code_from_source));
5061   remainder = obstack_finish (&temporary_obstack);
5062   if (do_warning)
5063     warning ("%s.\n%s", msg, remainder);
5064   else
5065     error ("%s.\n%s", msg, remainder);
5066
5067   /* This allow us to cheaply avoid an extra 'Invalid expression
5068      statement' error report when errors have been already reported on
5069      the same line. This occurs when we report an error but don't have
5070      a synchronization point other than ';', which
5071      expression_statement is the only one to take care of.  */
5072   ctxp->prevent_ese = lineno = save_lineno;
5073 }
5074
5075 static void
5076 issue_warning_error_from_context (cl, msg, ap)
5077      tree cl;
5078      const char *msg;
5079      va_list ap;
5080 {
5081   char *saved, *saved_input_filename;
5082   char buffer [4096];
5083   vsprintf (buffer, msg, ap);
5084   force_error = 1;
5085
5086   ctxp->elc.line = EXPR_WFL_LINENO (cl);
5087   ctxp->elc.col  = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 : 
5088                     (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5089
5090   /* We have a CL, that's a good reason for using it if it contains data */
5091   saved = ctxp->filename;
5092   if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5093     ctxp->filename = EXPR_WFL_FILENAME (cl);
5094   saved_input_filename = input_filename;
5095   input_filename = ctxp->filename;
5096   java_error (NULL);
5097   java_error (buffer);
5098   ctxp->filename = saved;
5099   input_filename = saved_input_filename;
5100   force_error = 0;
5101 }
5102
5103 /* Issue an error message at a current source line CL */
5104
5105 void
5106 parse_error_context VPROTO ((tree cl, const char *msg, ...))
5107 {
5108 #ifndef ANSI_PROTOTYPES
5109   tree cl;
5110   const char *msg;
5111 #endif
5112   va_list ap;
5113
5114   VA_START (ap, msg);
5115 #ifndef ANSI_PROTOTYPES
5116   cl = va_arg (ap, tree);
5117   msg = va_arg (ap, const char *);
5118 #endif
5119   issue_warning_error_from_context (cl, msg, ap);
5120   va_end (ap);
5121 }
5122
5123 /* Issue a warning at a current source line CL */
5124
5125 static void
5126 parse_warning_context VPROTO ((tree cl, const char *msg, ...))
5127 {
5128 #ifndef ANSI_PROTOTYPES
5129   tree cl;
5130   const char *msg;
5131 #endif
5132   va_list ap;
5133
5134   VA_START (ap, msg);
5135 #ifndef ANSI_PROTOTYPES
5136   cl = va_arg (ap, tree);
5137   msg = va_arg (ap, const char *);
5138 #endif
5139
5140   force_error = do_warning = 1;
5141   issue_warning_error_from_context (cl, msg, ap);
5142   do_warning = force_error = 0;
5143   va_end (ap);
5144 }
5145
5146 static tree
5147 find_expr_with_wfl (node)
5148      tree node;
5149 {
5150   while (node)
5151     {
5152       char code;
5153       tree to_return;
5154
5155       switch (TREE_CODE (node))
5156         {
5157         case BLOCK:
5158           node = BLOCK_EXPR_BODY (node);
5159           continue;
5160
5161         case COMPOUND_EXPR:
5162           to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
5163           if (to_return)
5164             return to_return;
5165           node = TREE_OPERAND (node, 1);
5166           continue;
5167
5168         case LOOP_EXPR:
5169           node = TREE_OPERAND (node, 0);
5170           continue;
5171           
5172         case LABELED_BLOCK_EXPR:
5173           node = TREE_OPERAND (node, 1);
5174           continue;
5175
5176         default:
5177           code = TREE_CODE_CLASS (TREE_CODE (node));
5178           if (((code == '1') || (code == '2') || (code == 'e'))
5179               && EXPR_WFL_LINECOL (node))
5180             return node;
5181           return NULL_TREE;
5182         }
5183     }
5184   return NULL_TREE;
5185 }
5186
5187 /* Issue a missing return statement error. Uses METHOD to figure the
5188    last line of the method the error occurs in.  */
5189
5190 static void
5191 missing_return_error (method)
5192      tree method;
5193 {
5194   EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
5195   parse_error_context (wfl_operator, "Missing return statement");
5196 }
5197
5198 /* Issue an unreachable statement error. From NODE, find the next
5199    statement to report appropriately.  */
5200 static void
5201 unreachable_stmt_error (node)
5202      tree node;
5203 {
5204   /* Browse node to find the next expression node that has a WFL. Use
5205      the location to report the error */
5206   if (TREE_CODE (node) == COMPOUND_EXPR)
5207     node = find_expr_with_wfl (TREE_OPERAND (node, 1));
5208   else
5209     node = find_expr_with_wfl (node);
5210
5211   if (node)
5212     {
5213       EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
5214       parse_error_context (wfl_operator, "Unreachable statement");
5215     }
5216   else
5217     fatal ("Can't get valid statement - unreachable_stmt_error");
5218 }
5219
5220 int
5221 java_report_errors ()
5222 {
5223   if (java_error_count)
5224     fprintf (stderr, "%d error%s", 
5225              java_error_count, (java_error_count == 1 ? "" : "s"));
5226   if (java_warning_count)
5227     fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
5228              java_warning_count, (java_warning_count == 1 ? "" : "s"));
5229   if (java_error_count || java_warning_count)
5230     putc ('\n', stderr);
5231   return java_error_count;
5232 }
5233
5234 static char *
5235 java_accstring_lookup (flags)
5236      int flags;
5237 {
5238   static char buffer [80];
5239 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
5240
5241   /* Access modifier looked-up first for easier report on forbidden
5242      access. */
5243   if (flags & ACC_PUBLIC) COPY_RETURN ("public");
5244   if (flags & ACC_PRIVATE) COPY_RETURN ("private");
5245   if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
5246   if (flags & ACC_STATIC) COPY_RETURN ("static");
5247   if (flags & ACC_FINAL) COPY_RETURN ("final");
5248   if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
5249   if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
5250   if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
5251   if (flags & ACC_NATIVE) COPY_RETURN ("native");
5252   if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
5253   if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
5254
5255   buffer [0] = '\0';
5256   return buffer;
5257 #undef COPY_RETURN
5258 }
5259
5260 /* Issuing error messages upon redefinition of classes, interfaces or
5261    variables. */
5262
5263 static void
5264 classitf_redefinition_error (context, id, decl, cl)
5265      char *context;
5266      tree id, decl, cl;
5267 {
5268   parse_error_context (cl, "%s `%s' already defined in %s:%d", 
5269                        context, IDENTIFIER_POINTER (id), 
5270                        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5271   /* Here we should point out where its redefined. It's a unicode. FIXME */
5272 }
5273
5274 static void
5275 variable_redefinition_error (context, name, type, line)
5276      tree context, name, type;
5277      int line;
5278 {
5279   char *type_name;
5280
5281   /* Figure a proper name for type. We might haven't resolved it */
5282   if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
5283     type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
5284   else
5285     type_name = lang_printable_name (type, 0);
5286
5287   parse_error_context (context,
5288                        "Variable `%s' is already defined in this method and "
5289                        "was declared `%s %s' at line %d", 
5290                        IDENTIFIER_POINTER (name),
5291                        type_name, IDENTIFIER_POINTER (name), line);
5292 }
5293
5294 static tree
5295 build_array_from_name (type, type_wfl, name, ret_name)
5296      tree type, type_wfl, name, *ret_name;
5297 {
5298   int more_dims = 0;
5299   char *string;
5300
5301   /* Eventually get more dims */
5302   string = IDENTIFIER_POINTER (name);
5303   while (string [more_dims] == '[')
5304     more_dims++;
5305   
5306   /* If we have, then craft a new type for this variable */
5307   if (more_dims)
5308     {
5309       name = get_identifier (&string [more_dims]);
5310
5311       /* If we have a pointer, use its type */
5312       if (TREE_CODE (type) == POINTER_TYPE)
5313         type = TREE_TYPE (type);
5314
5315       /* Building the first dimension of a primitive type uses this
5316          function */
5317       if (JPRIMITIVE_TYPE_P (type))
5318         {
5319           type = build_java_array_type (type, -1);
5320           CLASS_LOADED_P (type) = 1;
5321           more_dims--;
5322         }
5323       /* Otherwise, if we have a WFL for this type, use it (the type
5324          is already an array on an unresolved type, and we just keep
5325          on adding dimensions) */
5326       else if (type_wfl)
5327         type = type_wfl;
5328
5329       /* Add all the dimensions */
5330       while (more_dims--)
5331         type = build_unresolved_array_type (type);
5332
5333       /* The type may have been incomplete in the first place */
5334       if (type_wfl)
5335         type = obtain_incomplete_type (type);
5336     }
5337
5338   *ret_name = name;
5339   return type;
5340 }
5341
5342 /* Build something that the type identifier resolver will identify as
5343    being an array to an unresolved type. TYPE_WFL is a WFL on a
5344    identifier. */
5345
5346 static tree
5347 build_unresolved_array_type (type_or_wfl)
5348      tree type_or_wfl;
5349 {
5350   char *ptr;
5351
5352   /* TYPE_OR_WFL might be an array on a resolved type. In this case,
5353      just create a array type */
5354   if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5355     {
5356       tree type = build_java_array_type (type_or_wfl, -1);
5357       CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5358       return type;
5359     }
5360
5361   obstack_1grow (&temporary_obstack, '[');
5362   obstack_grow0 (&temporary_obstack,
5363                  IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5364                  IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5365   ptr = obstack_finish (&temporary_obstack);
5366   return build_expr_wfl (get_identifier (ptr),
5367                          EXPR_WFL_FILENAME (type_or_wfl),
5368                          EXPR_WFL_LINENO (type_or_wfl),
5369                          EXPR_WFL_COLNO (type_or_wfl));
5370 }
5371
5372 /* Check modifiers. If one doesn't fit, retrieve it in its declaration line
5373   and point it out.  */
5374
5375 static void
5376 check_modifiers (message, value, mask)
5377      char *message;
5378      int value;
5379      int mask;
5380 {
5381   /* Should point out the one that don't fit. ASCII/unicode,
5382      going backward. FIXME */
5383   if (value & ~mask)
5384     {
5385       int i, remainder = value & ~mask;
5386       for (i = 0; i <= 10; i++)
5387         if ((1 << i) & remainder)
5388           parse_error_context (ctxp->modifier_ctx [i], message, 
5389                                java_accstring_lookup (1 << i));
5390     }
5391 }
5392
5393 static void
5394 parser_add_interface (class_decl, interface_decl, wfl)
5395      tree class_decl, interface_decl, wfl;
5396 {
5397   if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5398     parse_error_context (wfl, "Interface `%s' repeated",
5399                          IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5400 }
5401
5402 /* Bulk of common class/interface checks. Return 1 if an error was
5403    encountered. TAG is 0 for a class, 1 for an interface.  */
5404
5405 static int
5406 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5407      int is_interface, flags;
5408      tree raw_name, qualified_name, decl, cl;
5409 {
5410   tree node;
5411
5412   if (!quiet_flag)
5413     fprintf (stderr, " %s %s", (is_interface ? "interface" : "class"), 
5414              IDENTIFIER_POINTER (qualified_name));
5415
5416   /* Scope of an interface/class type name:
5417        - Can't be imported by a single type import
5418        - Can't already exists in the package */
5419   if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5420       && (node = find_name_in_single_imports (raw_name)))
5421     {
5422       parse_error_context 
5423         (cl, "%s name `%s' clashes with imported type `%s'",
5424          (is_interface ? "Interface" : "Class"),
5425          IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
5426       return 1;
5427     }
5428   if (decl && CLASS_COMPLETE_P (decl))
5429     {
5430       classitf_redefinition_error ((is_interface ? "Interface" : "Class"), 
5431                                    qualified_name, decl, cl);
5432       return 1;
5433     }
5434
5435   /* If public, file name should match class/interface name */
5436   if (flags & ACC_PUBLIC)
5437     {
5438       char *f;
5439
5440       /* Contains OS dependent assumption on path separator. FIXME */
5441       for (f = &input_filename [strlen (input_filename)]; 
5442            f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR;
5443            f--)
5444         ;
5445       if (f[0] == '/' || f[0] == DIR_SEPARATOR)
5446         f++;
5447       if (strncmp (IDENTIFIER_POINTER (raw_name), 
5448                    f , IDENTIFIER_LENGTH (raw_name)) ||
5449           f [IDENTIFIER_LENGTH (raw_name)] != '.')
5450         parse_error_context (cl, "Public %s `%s' must be defined in a file "
5451                              "called `%s.java'", 
5452                              (is_interface ? "interface" : "class"),
5453                              IDENTIFIER_POINTER (qualified_name),
5454                              IDENTIFIER_POINTER (raw_name));
5455     }
5456
5457   check_modifiers ((is_interface ? 
5458                     "Illegal modifier `%s' for interface declaration" :
5459                     "Illegal modifier `%s' for class declaration"), flags,
5460                    (is_interface ? INTERFACE_MODIFIERS : CLASS_MODIFIERS));
5461   return 0;
5462 }
5463
5464 /* If DECL is NULL, create and push a new DECL, record the current
5465    line CL and do other maintenance things.  */
5466
5467 static tree
5468 maybe_create_class_interface_decl (decl, qualified_name, cl)
5469      tree decl, qualified_name, cl;
5470 {
5471   if (!decl)
5472     decl = push_class (make_class (), qualified_name);
5473   
5474   /* Take care of the file and line business */
5475   DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
5476   /* If we're emiting xrefs, store the line/col number information */
5477   if (flag_emit_xref)
5478     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
5479   else
5480     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
5481   CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
5482   CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
5483     IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
5484
5485   ctxp->current_parsed_class = decl;
5486   
5487   /* Link the declaration to the already seen ones */
5488   TREE_CHAIN (decl) = ctxp->class_list;
5489   ctxp->class_list = decl;
5490
5491   /* Create a new nodes in the global lists */
5492   ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
5493   all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
5494
5495   /* Install a new dependency list element */
5496   create_jdep_list (ctxp);
5497
5498   SOURCE_FRONTEND_DEBUG (("Defining class/interface %s", 
5499                           IDENTIFIER_POINTER (qualified_name)));
5500   return decl;
5501 }
5502
5503 static void
5504 add_superinterfaces (decl, interface_list)
5505      tree decl, interface_list;
5506 {
5507   tree node;
5508   /* Superinterface(s): if present and defined, parser_check_super_interface ()
5509      takes care of ensuring that:
5510        - This is an accessible interface type,
5511        - Circularity detection.
5512    parser_add_interface is then called. If present but not defined,
5513    the check operation is delayed until the super interface gets
5514    defined.  */
5515   for (node = interface_list; node; node = TREE_CHAIN (node))
5516     {
5517       tree current = TREE_PURPOSE (node);
5518       tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
5519       if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
5520         {
5521           if (!parser_check_super_interface (idecl, decl, current))
5522             parser_add_interface (decl, idecl, current);
5523         }
5524       else
5525         register_incomplete_type (JDEP_INTERFACE,
5526                                   current, decl, NULL_TREE);
5527     }
5528 }
5529
5530 /* Create an interface in pass1 and return its decl. Return the
5531    interface's decl in pass 2.  */
5532
5533 static tree
5534 create_interface (flags, id, super)
5535      int flags;
5536      tree id, super;
5537 {
5538   tree raw_name = EXPR_WFL_NODE (id);
5539   tree q_name = parser_qualified_classname (id);
5540   tree decl = IDENTIFIER_CLASS_VALUE (q_name);
5541
5542   EXPR_WFL_NODE (id) = q_name;  /* Keep source location, even if refined. */
5543
5544   /* Basic checks: scope, redefinition, modifiers */ 
5545   if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
5546     return NULL_TREE;
5547
5548   /* Interface modifiers check
5549        - public/abstract allowed (already done at that point)
5550        - abstract is obsolete (comes first, it's a warning, or should be)
5551        - Can't use twice the same (checked in the modifier rule) */
5552   if ((flags & ACC_ABSTRACT) && flag_redundant)
5553     parse_warning_context 
5554       (MODIFIER_WFL (ABSTRACT_TK),
5555        "Redundant use of `abstract' modifier. Interface `%s' is implicitely "
5556        "abstract", IDENTIFIER_POINTER (raw_name));
5557
5558   /* Create a new decl if DECL is NULL, otherwise fix it */
5559   decl = maybe_create_class_interface_decl (decl, q_name, id);
5560
5561   /* Set super info and mark the class a complete */
5562   set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl), 
5563                   object_type_node, ctxp->interface_number);
5564   ctxp->interface_number = 0;
5565   CLASS_COMPLETE_P (decl) = 1;
5566   add_superinterfaces (decl, super);
5567
5568   return decl;
5569 }
5570
5571 /* Create an class in pass1 and return its decl. Return class
5572    interface's decl in pass 2.  */
5573
5574 static tree
5575 create_class (flags, id, super, interfaces)
5576      int flags;
5577      tree id, super, interfaces;
5578 {
5579   tree raw_name = EXPR_WFL_NODE (id);
5580   tree class_id, decl;
5581   tree super_decl_type;
5582
5583   class_id = parser_qualified_classname (id);
5584   decl = IDENTIFIER_CLASS_VALUE (class_id);
5585   ctxp->current_parsed_class_un = EXPR_WFL_NODE (id);
5586   EXPR_WFL_NODE (id) = class_id;
5587
5588   /* Basic check: scope, redefinition, modifiers */
5589   if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
5590     return NULL_TREE;
5591
5592   /* Class modifier check: 
5593        - Allowed modifier (already done at that point)
5594        - abstract AND final forbidden 
5595        - Public classes defined in the correct file */
5596   if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
5597     parse_error_context (id, "Class `%s' can't be declared both abstract "
5598                          "and final", IDENTIFIER_POINTER (raw_name));
5599
5600   /* Create a new decl if DECL is NULL, otherwise fix it */
5601   decl = maybe_create_class_interface_decl (decl, class_id, id);
5602
5603   /* If SUPER exists, use it, otherwise use Object */
5604   if (super)
5605     {
5606       /* Can't extend java.lang.Object */
5607       if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
5608         {
5609           parse_error_context (id, "Can't extend `java.lang.Object'");
5610           return NULL_TREE;
5611         }
5612
5613       super_decl_type = 
5614         register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
5615     }
5616   else if (TREE_TYPE (decl) != object_type_node)
5617     super_decl_type = object_type_node;
5618   /* We're defining java.lang.Object */
5619   else
5620     super_decl_type = NULL_TREE;
5621
5622   /* Set super info and mark the class a complete */
5623   set_super_info (flags, TREE_TYPE (decl), super_decl_type, 
5624                   ctxp->interface_number);
5625   ctxp->interface_number = 0;
5626   CLASS_COMPLETE_P (decl) = 1;
5627   add_superinterfaces (decl, interfaces);
5628
5629   /* If doing xref, store the location at which the inherited class
5630      (if any) was seen. */
5631   if (flag_emit_xref && super)
5632     DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
5633
5634   /* Eventually sets the @deprecated tag flag */
5635   CHECK_DEPRECATED (decl);
5636
5637   return decl;
5638 }
5639
5640 /* Can't use lookup_field () since we don't want to load the class and
5641    can't set the CLASS_LOADED_P flag */
5642
5643 static tree
5644 find_field (class, name)
5645      tree class;
5646      tree name;
5647 {
5648   tree decl;
5649   for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
5650     {
5651       if (DECL_NAME (decl) == name)
5652         return decl;
5653     }
5654   return NULL_TREE;
5655 }
5656
5657 /* Wrap around lookup_field that doesn't potentially upset the value
5658    of CLASS */
5659
5660 static tree
5661 lookup_field_wrapper (class, name)
5662      tree class, name;
5663 {
5664   tree type = class;
5665   tree decl;
5666   java_parser_context_save_global ();
5667   decl = lookup_field (&type, name);
5668   java_parser_context_restore_global ();
5669   return decl == error_mark_node ? NULL : decl;
5670 }
5671
5672 /* Find duplicate field within the same class declarations and report
5673    the error. Returns 1 if a duplicated field was found, 0
5674    otherwise.  */
5675
5676 static int
5677 duplicate_declaration_error_p (new_field_name, new_type, cl)
5678      tree new_field_name, new_type, cl;
5679 {
5680   /* This might be modified to work with method decl as well */
5681   tree decl = find_field (TREE_TYPE (ctxp->current_parsed_class), 
5682                           new_field_name);
5683   if (decl)
5684     {
5685       char *t1 = strdup (purify_type_name
5686                          ((TREE_CODE (new_type) == POINTER_TYPE 
5687                            && TREE_TYPE (new_type) == NULL_TREE) ?
5688                           IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
5689                           lang_printable_name (new_type, 1)));
5690       /* The type may not have been completed by the time we report
5691          the error */
5692       char *t2 = strdup (purify_type_name
5693                          ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE 
5694                            && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
5695                           IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
5696                           lang_printable_name (TREE_TYPE (decl), 1)));
5697       parse_error_context 
5698         (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)", 
5699          t1, IDENTIFIER_POINTER (new_field_name),
5700          t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
5701          DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5702       free (t1);
5703       free (t2);
5704       return 1;
5705     }
5706   return 0;
5707 }
5708
5709 /* Field registration routine. If TYPE doesn't exist, field
5710    declarations are linked to the undefined TYPE dependency list, to
5711    be later resolved in java_complete_class () */
5712
5713 static void
5714 register_fields (flags, type, variable_list)
5715      int flags;
5716      tree type, variable_list;
5717 {
5718   tree current, saved_type;
5719   tree class_type = TREE_TYPE (ctxp->current_parsed_class);
5720   int saved_lineno = lineno;
5721   int must_chain = 0;
5722   tree wfl = NULL_TREE;
5723
5724   /* If we're adding fields to interfaces, those fields are public,
5725      static, final */
5726   if (CLASS_INTERFACE (TYPE_NAME (class_type)))
5727     {
5728       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
5729                                  flags, ACC_PUBLIC, 
5730                                  "%s", "interface field(s)");
5731       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
5732                                  flags, ACC_STATIC, 
5733                                  "%s", "interface field(s)");
5734       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
5735                                  flags, ACC_FINAL, "%s", "interface field(s)");
5736       check_modifiers ("Illegal interface member modifier `%s'", flags,
5737                        INTERFACE_FIELD_MODIFIERS);
5738       flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
5739     }
5740
5741   /* Obtain a suitable type for resolution, if necessary */
5742   SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
5743
5744   /* If TYPE is fully resolved and we don't have a reference, make one */
5745   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
5746
5747   for (current = variable_list, saved_type = type; current; 
5748        current = TREE_CHAIN (current), type = saved_type)
5749     {
5750       tree real_type;
5751       tree field_decl;
5752       tree cl = TREE_PURPOSE (current);
5753       tree init = TREE_VALUE (current);
5754       tree current_name = EXPR_WFL_NODE (cl);
5755
5756       /* Process NAME, as it may specify extra dimension(s) for it */
5757       type = build_array_from_name (type, wfl, current_name, &current_name);
5758
5759       /* Type adjustment. We may have just readjusted TYPE because
5760          the variable specified more dimensions. Make sure we have
5761          a reference if we can and don't have one already. Also
5762          change the name if we have an init. */
5763       if (type != saved_type)
5764         {
5765           PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
5766           if (init)
5767             EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
5768         }
5769
5770       real_type = GET_REAL_TYPE (type);
5771       /* Check for redeclarations */
5772       if (duplicate_declaration_error_p (current_name, real_type, cl))
5773         continue;
5774
5775       /* Set lineno to the line the field was found and create a
5776          declaration for it. Eventually sets the @deprecated tag flag. */
5777       if (flag_emit_xref)
5778         lineno = EXPR_WFL_LINECOL (cl);
5779       else
5780         lineno = EXPR_WFL_LINENO (cl);
5781       field_decl = add_field (class_type, current_name, real_type, flags);
5782       CHECK_DEPRECATED (field_decl);
5783       
5784       /* Check if we must chain. */
5785       if (must_chain)
5786         register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
5787           
5788       /* If we have an initialization value tied to the field */
5789       if (init)
5790         {
5791           /* The field is declared static */
5792           if (flags & ACC_STATIC)
5793             {
5794               /* We include the field and its initialization part into
5795                  a list used to generate <clinit>. After <clinit> is
5796                  walked, field initializations will be processed and
5797                  fields initialized with known constants will be taken
5798                  out of <clinit> and have their DECL_INITIAL set
5799                  appropriately. */
5800               TREE_CHAIN (init) = ctxp->static_initialized;
5801               ctxp->static_initialized = init;
5802               DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
5803               if (TREE_OPERAND (init, 1) 
5804                   && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
5805                 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
5806             }
5807           /* A non-static field declared with an immediate initialization is
5808              to be initialized in <init>, if any.  This field is remembered
5809              to be processed at the time of the generation of <init>. */
5810           else
5811             {
5812               TREE_CHAIN (init) = ctxp->non_static_initialized;
5813               ctxp->non_static_initialized = init;
5814             }
5815           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
5816         }
5817     }
5818   lineno = saved_lineno;
5819 }
5820
5821 /* Generate the method $finit$ that initializes fields initialized
5822    upon declaration.  */
5823
5824 static void
5825 maybe_generate_finit ()
5826 {
5827   tree mdecl, current;
5828   
5829   if (!ctxp->non_static_initialized || java_error_count)
5830     return;
5831
5832   mdecl = create_artificial_method (TREE_TYPE (ctxp->current_parsed_class),
5833                                     ACC_PRIVATE, void_type_node,
5834                                     finit_identifier_node, end_params_node);
5835   start_artificial_method_body (mdecl);
5836
5837   ctxp->non_static_initialized = nreverse (ctxp->non_static_initialized);
5838   for (current = ctxp->non_static_initialized; current;
5839        current = TREE_CHAIN (current))
5840     java_method_add_stmt (mdecl, 
5841                           build_debugable_stmt (EXPR_WFL_LINECOL (current), 
5842                                                 current));
5843
5844   end_artificial_method_body (mdecl);
5845   CLASS_HAS_FINIT_P (TREE_TYPE (ctxp->current_parsed_class)) = 1;
5846   ctxp->non_static_initialized = NULL_TREE;
5847 }
5848
5849 /* Check whether it is necessary to generate a <clinit> for the class
5850    we just parsed. */
5851
5852 static void
5853 maybe_generate_clinit ()
5854 {
5855   tree mdecl, c;
5856
5857   if (!ctxp->static_initialized || java_error_count)
5858     return;
5859
5860   mdecl = create_artificial_method (TREE_TYPE (ctxp->current_parsed_class),
5861                                     ACC_STATIC, void_type_node,
5862                                     clinit_identifier_node, end_params_node);
5863   start_artificial_method_body (mdecl);
5864
5865   /* Keep initialization in order to enforce 8.5 */
5866   ctxp->static_initialized = nreverse (ctxp->static_initialized);
5867
5868   /* We process the list of assignment we produced as the result of
5869      the declaration of initialized static field and add them as
5870      statement to the <clinit> method. */
5871   for (c = ctxp->static_initialized; c; c = TREE_CHAIN (c))
5872     {
5873       /* We build the assignment expression that will initialize the
5874          field to its value. There are strict rules on static
5875          initializers (8.5). FIXME */
5876       java_method_add_stmt (mdecl, 
5877                             build_debugable_stmt (EXPR_WFL_LINECOL (c), c));
5878     }
5879
5880   end_artificial_method_body (mdecl);
5881   ctxp->static_initialized = NULL_TREE;
5882 }
5883
5884 /* Shared accros method_declarator and method_header to remember the
5885    patch stage that was reached during the declaration of the method.
5886    A method DECL is built differently is there is no patch
5887    (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
5888    pending on the currently defined method.  */
5889
5890 static int patch_stage;
5891
5892 /* Check the method declaration and add the method to its current
5893    class.  If the argument list is known to contain incomplete types,
5894    the method is partially added and the registration will be resume
5895    once the method arguments resolved. If TYPE is NULL, we're dealing
5896    with a constructor.  */
5897
5898 static tree
5899 method_header (flags, type, mdecl, throws)
5900      int flags;
5901      tree type, mdecl, throws;
5902 {
5903   tree meth = TREE_VALUE (mdecl);
5904   tree id = TREE_PURPOSE (mdecl);
5905   tree this_class = TREE_TYPE (ctxp->current_parsed_class);
5906   tree type_wfl = NULL_TREE;
5907   tree meth_name = NULL_TREE, current, orig_arg;
5908   int saved_lineno;
5909   int constructor_ok = 0, must_chain;
5910   
5911   check_modifiers_consistency (flags);
5912   
5913   /* There are some forbidden modifiers for an abstract method and its
5914      class must be abstract as well.  */
5915   if (type && (flags & ACC_ABSTRACT))
5916     {
5917       ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
5918       ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
5919       ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
5920       ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
5921       ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
5922       if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
5923           && !CLASS_INTERFACE (TYPE_NAME (this_class)))
5924         parse_error_context 
5925           (id, "Class `%s' must be declared abstract to define abstract "
5926            "method `%s'", 
5927            IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
5928            IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
5929     }
5930   /* Things to be checked when declaring a constructor */
5931   if (!type)
5932     {
5933       int ec = java_error_count;
5934       /* 8.6: Constructor declarations: we might be trying to define a
5935          method without specifying a return type. */
5936       if (EXPR_WFL_NODE (id) != ctxp->current_parsed_class_un)
5937         parse_error_context 
5938           (id, "Invalid method declaration, return type required");
5939       /* 8.6.3: Constructor modifiers */
5940       else
5941         {
5942           JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
5943           JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
5944           JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
5945           JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
5946           JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
5947         }
5948       /* If we found error here, we don't consider it's OK to tread
5949          the method definition as a constructor, for the rest of this
5950          function */
5951       if (ec == java_error_count)
5952         constructor_ok = 1;
5953     }
5954
5955   /* Method declared within the scope of an interface are implicitly
5956      abstract and public. Conflicts with other erroneously provided
5957      modifiers are checked right after. */
5958
5959   if (CLASS_INTERFACE (TYPE_NAME (this_class)))
5960     {
5961       /* If FLAGS isn't set because of a modifier, turn the
5962          corresponding modifier WFL to NULL so we issue a warning on
5963          the obsolete use of the modifier */
5964       if (!(flags & ACC_PUBLIC))
5965         MODIFIER_WFL (PUBLIC_TK) = NULL;
5966       if (!(flags & ACC_ABSTRACT))
5967         MODIFIER_WFL (ABSTRACT_TK) = NULL;
5968       flags |= ACC_PUBLIC;
5969       flags |= ACC_ABSTRACT;
5970     }
5971
5972   /* Modifiers context reset moved up, so abstract method declaration
5973      modifiers can be later checked.  */
5974
5975   /* Set constructor returned type to void and method name to <init>,
5976      unless we found an error identifier the constructor (in which
5977      case we retain the original name) */
5978   if (!type)
5979     {
5980       type = void_type_node;
5981       if (constructor_ok)
5982         meth_name = init_identifier_node;
5983     }
5984   else
5985     meth_name = EXPR_WFL_NODE (id);
5986
5987   /* Do the returned type resolution and registration if necessary */
5988   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
5989
5990   if (meth_name)
5991     type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
5992   EXPR_WFL_NODE (id) = meth_name;
5993   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
5994
5995   if (must_chain)
5996     {
5997       patch_stage = JDEP_METHOD_RETURN;
5998       register_incomplete_type (patch_stage, type_wfl, id, type);
5999       TREE_TYPE (meth) = GET_REAL_TYPE (type);
6000     }
6001   else
6002     TREE_TYPE (meth) = type;
6003
6004   saved_lineno = lineno;
6005   /* When defining an abstract or interface method, the curly
6006      bracket at level 1 doesn't exist because there is no function
6007      body */
6008   lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 : 
6009             EXPR_WFL_LINENO (id));
6010
6011   /* Remember the original argument list */
6012   orig_arg = TYPE_ARG_TYPES (meth);
6013
6014   if (patch_stage)              /* includes ret type and/or all args */
6015     {
6016       jdep *jdep;
6017       meth = add_method_1 (this_class, flags, meth_name, meth);
6018       /* Patch for the return type */
6019       if (patch_stage == JDEP_METHOD_RETURN)
6020         {
6021           jdep = CLASSD_LAST (ctxp->classd_list);
6022           JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
6023         }
6024       /* This is the stop JDEP. METH allows the function's signature
6025          to be computed. */
6026       register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
6027     }
6028   else
6029     meth = add_method (this_class, flags, meth_name, 
6030                        build_java_signature (meth));
6031
6032   /* Fix the method argument list so we have the argument name
6033      information */
6034   fix_method_argument_names (orig_arg, meth);
6035
6036   /* Register the parameter number and re-install the current line
6037      number */
6038   DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
6039   lineno = saved_lineno;
6040
6041   /* Register exception specified by the `throws' keyword for
6042      resolution and set the method decl appropriate field to the list.
6043      Note: the grammar ensures that what we get here are class
6044      types. */
6045   if (throws)
6046     {
6047       throws = nreverse (throws);
6048       for (current = throws; current; current = TREE_CHAIN (current))
6049         {
6050           register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
6051                                     NULL_TREE, NULL_TREE);
6052           JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) = 
6053             &TREE_VALUE (current);
6054         }
6055       DECL_FUNCTION_THROWS (meth) = throws;
6056     }
6057
6058   /* We set the DECL_NAME to ID so we can track the location where
6059      the function was declared. This allow us to report
6060      redefinition error accurately. When method are verified,
6061      DECL_NAME is reinstalled properly (using the content of the
6062      WFL node ID) (see check_method_redefinition). We don't do that
6063      when Object is being defined. Constructor <init> names will be
6064      reinstalled the same way. */
6065   if (TREE_TYPE (ctxp->current_parsed_class) != object_type_node)
6066     DECL_NAME (meth) = id;
6067
6068   /* Set the flag if we correctly processed a constructor */
6069   if (constructor_ok)
6070     DECL_CONSTRUCTOR_P (meth) = 1;
6071
6072   /* Eventually set the @deprecated tag flag */
6073   CHECK_DEPRECATED (meth);
6074
6075   /* If doing xref, store column and line number information instead
6076      of the line number only. */
6077   if (flag_emit_xref)
6078     DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
6079
6080   return meth;
6081 }
6082
6083 static void
6084 fix_method_argument_names (orig_arg, meth)
6085     tree orig_arg, meth;
6086 {
6087   tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
6088   if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
6089     {
6090       TREE_PURPOSE (arg) = this_identifier_node;
6091       arg = TREE_CHAIN (arg);
6092     }
6093   while (orig_arg != end_params_node)
6094     {
6095       TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
6096       orig_arg = TREE_CHAIN (orig_arg);
6097       arg = TREE_CHAIN (arg);
6098     }
6099 }
6100
6101 /* Complete the method declaration with METHOD_BODY.  */
6102
6103 static void
6104 finish_method_declaration (method_body)
6105      tree method_body;
6106 {
6107   int flags = get_access_flags_from_decl (current_function_decl);
6108
6109   /* 8.4.5 Method Body */
6110   if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
6111     {
6112       tree wfl = DECL_NAME (current_function_decl);
6113       parse_error_context (wfl, 
6114                            "%s method `%s' can't have a body defined",
6115                            (METHOD_NATIVE (current_function_decl) ?
6116                             "Native" : "Abstract"),
6117                            IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
6118       method_body = NULL_TREE;
6119     }
6120   else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
6121     {
6122       tree wfl = DECL_NAME (current_function_decl);
6123       parse_error_context (wfl, 
6124                            "Non native and non abstract method `%s' must "
6125                            "have a body defined",
6126                            IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
6127       method_body = NULL_TREE;
6128     }
6129
6130   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
6131   maybe_absorb_scoping_blocks ();
6132   /* Exit function's body */
6133   exit_block ();
6134   /* Merge last line of the function with first line, directly in the
6135      function decl. It will be used to emit correct debug info. */
6136   if (!flag_emit_xref)
6137     DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
6138   /* So we don't have an irrelevant function declaration context for
6139      the next static block we'll see. */
6140   current_function_decl = NULL_TREE;
6141 }
6142
6143 /* Build a an error message for constructor circularity errors.  */
6144
6145 static char *
6146 constructor_circularity_msg (from, to)
6147      tree from, to;
6148 {
6149   static char string [4096];
6150   char *t = strdup (lang_printable_name (from, 0));
6151   sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
6152   free (t);
6153   return string;
6154 }
6155
6156 /* Verify a circular call to METH. Return 1 if an error is found, 0
6157    otherwise.  */
6158
6159 static int
6160 verify_constructor_circularity (meth, current)
6161      tree meth, current;
6162 {
6163   static tree list = NULL_TREE;
6164   tree c;
6165   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
6166     {
6167       if (TREE_VALUE (c) == meth)
6168         {
6169           char *t;
6170           if (list)
6171             {
6172               tree liste;
6173               list = nreverse (list);
6174               for (liste = list; liste; liste = TREE_CHAIN (liste))
6175                 {
6176                   parse_error_context 
6177                     (TREE_PURPOSE (TREE_PURPOSE (liste)),
6178                      constructor_circularity_msg
6179                       (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste)))); 
6180                   java_error_count--;
6181                 }
6182             }
6183           t = strdup (lang_printable_name (meth, 0));
6184           parse_error_context (TREE_PURPOSE (c), 
6185                                "%s: recursive invocation of constructor `%s'",
6186                                constructor_circularity_msg (current, meth), t);
6187           free (t);
6188           list = NULL_TREE;
6189           return 1;
6190         }
6191     }
6192   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
6193     {
6194       list = tree_cons (c, current, list);
6195       if (verify_constructor_circularity (meth, TREE_VALUE (c)))
6196         return 1;
6197       list = TREE_CHAIN (list);
6198     }
6199   return 0;
6200 }
6201
6202 /* Check modifiers that can be declared but exclusively */
6203
6204 static void
6205 check_modifiers_consistency (flags)
6206      int flags;
6207 {
6208   int acc_count = 0;
6209   tree cl = NULL_TREE;
6210
6211   THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, 0, acc_count, cl);
6212   THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, 1, acc_count, cl);
6213   THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, 2, acc_count, cl);
6214   if (acc_count > 1)
6215     parse_error_context
6216       (cl, "Inconsistent member declaration. At most one of `public', "
6217        "`private', or `protected' may be specified");
6218 }
6219
6220 /* Check the methode header METH for abstract specifics features */
6221
6222 static void
6223 check_abstract_method_header (meth)
6224      tree meth;
6225 {
6226   int flags = get_access_flags_from_decl (meth);
6227   /* DECL_NAME might still be a WFL node */
6228   tree name = GET_METHOD_NAME (meth);
6229
6230   OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (ABSTRACT_TK), flags,
6231                              ACC_ABSTRACT, "abstract method `%s'",
6232                              IDENTIFIER_POINTER (name));
6233   OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK), flags, 
6234                              ACC_PUBLIC, "abstract method `%s'",
6235                              IDENTIFIER_POINTER (name));
6236
6237   check_modifiers ("Illegal modifier `%s' for interface method",
6238                   flags, INTERFACE_METHOD_MODIFIERS);
6239 }
6240
6241 /* Create a FUNCTION_TYPE node and start augmenting it with the
6242    declared function arguments. Arguments type that can't be resolved
6243    are left as they are, but the returned node is marked as containing
6244    incomplete types.  */
6245
6246 static tree
6247 method_declarator (id, list)
6248      tree id, list;
6249 {
6250   tree arg_types = NULL_TREE, current, node;
6251   tree meth = make_node (FUNCTION_TYPE);
6252   jdep *jdep;
6253
6254   patch_stage = JDEP_NO_PATCH;
6255   
6256   for (current = list; current; current = TREE_CHAIN (current))
6257     {
6258       int must_chain = 0;
6259       tree wfl_name = TREE_PURPOSE (current);
6260       tree type = TREE_VALUE (current);
6261       tree name = EXPR_WFL_NODE (wfl_name);
6262       tree already, arg_node;
6263       tree type_wfl = NULL_TREE;
6264       tree real_type;
6265
6266       /* Obtain a suitable type for resolution, if necessary */
6267       SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
6268
6269       /* Process NAME, as it may specify extra dimension(s) for it */
6270       type = build_array_from_name (type, type_wfl, name, &name);
6271       EXPR_WFL_NODE (wfl_name) = name;
6272
6273       real_type = GET_REAL_TYPE (type);
6274       if (TREE_CODE (real_type) == RECORD_TYPE)
6275         {
6276           real_type = promote_type (real_type);
6277           if (TREE_CODE (type) == TREE_LIST)
6278             TREE_PURPOSE (type) = real_type;
6279         }
6280
6281       /* Check redefinition */
6282       for (already = arg_types; already; already = TREE_CHAIN (already))
6283         if (TREE_PURPOSE (already) == name)
6284           {
6285             parse_error_context 
6286               (wfl_name, "Variable `%s' is used more than once in the "
6287                "argument list of method `%s'", IDENTIFIER_POINTER (name),
6288                IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6289             break;
6290           }
6291
6292       /* If we've an incomplete argument type, we know there is a location
6293          to patch when the type get resolved, later.  */
6294       jdep = NULL;
6295       if (must_chain)
6296         {
6297           patch_stage = JDEP_METHOD;
6298           type = register_incomplete_type (patch_stage, 
6299                                            type_wfl, wfl_name, type);
6300           jdep = CLASSD_LAST (ctxp->classd_list);
6301           JDEP_MISC (jdep) = id;
6302         }
6303
6304       /* The argument node: a name and a (possibly) incomplete type */
6305       arg_node = build_tree_list (name, real_type);
6306       if (jdep)
6307         JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
6308       TREE_CHAIN (arg_node) = arg_types;
6309       arg_types = arg_node;
6310     }
6311   TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
6312   node = build_tree_list (id, meth);
6313   return node;
6314 }
6315
6316 static int
6317 unresolved_type_p (wfl, returned)
6318      tree wfl;
6319      tree *returned;
6320      
6321 {
6322   if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
6323     {
6324       tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
6325       if (returned)
6326         *returned = (decl ? TREE_TYPE (decl) : NULL_TREE);
6327       return 1;
6328     }
6329   if (returned)
6330     *returned = wfl;
6331   return 0;
6332 }
6333
6334 /* From NAME, build a qualified identifier node using the
6335    qualification from the current package definition. */
6336
6337 static tree
6338 parser_qualified_classname (name)
6339      tree name;
6340 {
6341   if (ctxp->package)
6342     return merge_qualified_name (ctxp->package, EXPR_WFL_NODE (name));
6343   else 
6344     return EXPR_WFL_NODE (name);
6345 }
6346
6347 /* Called once the type a interface extends is resolved. Returns 0 if
6348    everything is OK.  */
6349
6350 static int
6351 parser_check_super_interface (super_decl, this_decl, this_wfl)
6352      tree super_decl, this_decl, this_wfl;
6353 {
6354   tree super_type = TREE_TYPE (super_decl);
6355
6356   /* Has to be an interface */
6357   if (!CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (super_decl))))
6358     {
6359       parse_error_context 
6360         (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
6361          (TYPE_ARRAY_P (super_type) ? "array" : "class"),
6362          IDENTIFIER_POINTER (DECL_NAME (super_decl)),
6363          (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ? 
6364           "interface" : "class"),
6365          IDENTIFIER_POINTER (DECL_NAME (this_decl)));
6366       return 1;
6367     }
6368
6369   /* Check scope: same package OK, other package: OK if public */
6370   if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
6371     return 1;
6372
6373   SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
6374                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
6375                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
6376   return 0;
6377 }
6378
6379 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
6380    0 if everthing is OK.  */
6381
6382 static int
6383 parser_check_super (super_decl, this_decl, wfl)
6384      tree super_decl, this_decl, wfl;
6385 {
6386   tree super_type = TREE_TYPE (super_decl);
6387
6388   /* SUPER should be a CLASS (neither an array nor an interface) */
6389   if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
6390     {
6391       parse_error_context 
6392         (wfl, "Class `%s' can't subclass %s `%s'",
6393          IDENTIFIER_POINTER (DECL_NAME (this_decl)),
6394          (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
6395          IDENTIFIER_POINTER (DECL_NAME (super_decl)));
6396       return 1;
6397     }
6398
6399   if (CLASS_FINAL (TYPE_NAME (super_type)))
6400     {
6401       parse_error_context (wfl, "Can't subclass final classes: %s",
6402                            IDENTIFIER_POINTER (DECL_NAME (super_decl)));
6403       return 1;
6404     }
6405
6406   /* Check scope: same package OK, other package: OK if public */
6407   if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
6408     return 1;
6409   
6410   SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
6411                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
6412                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
6413   return 0;
6414 }
6415
6416 /* Create a new dependency list and link it (in a LIFO manner) to the
6417    CTXP list of type dependency list.  */
6418
6419 static void
6420 create_jdep_list (ctxp)
6421      struct parser_ctxt *ctxp;
6422 {
6423   jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));      
6424   new->first = new->last = NULL;
6425   new->next = ctxp->classd_list;
6426   ctxp->classd_list = new;
6427 }
6428
6429 static jdeplist *
6430 reverse_jdep_list (ctxp)
6431      struct parser_ctxt *ctxp;
6432 {
6433   register jdeplist *prev = NULL, *current, *next;
6434   for (current = ctxp->classd_list; current; current = next)
6435     {
6436       next = current->next;
6437       current->next = prev;
6438       prev = current;
6439     }
6440   return prev;
6441 }
6442
6443 /* Create a fake pointer based on the ID stored in
6444    TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
6445    registered again. */
6446
6447 static tree
6448 obtain_incomplete_type (type_name)
6449      tree type_name;
6450 {
6451   tree ptr, name;
6452
6453   if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
6454     name = EXPR_WFL_NODE (type_name);
6455   else if (INCOMPLETE_TYPE_P (type_name))
6456     name = TYPE_NAME (type_name);
6457   else
6458     fatal ("invalid type name - obtain_incomplete_type");
6459
6460   for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
6461     if (TYPE_NAME (ptr) == name)
6462       break;
6463
6464   if (!ptr)
6465     {
6466       push_obstacks (&permanent_obstack, &permanent_obstack);
6467       BUILD_PTR_FROM_NAME (ptr, name);
6468       layout_type (ptr);
6469       pop_obstacks ();
6470       TREE_CHAIN (ptr) = ctxp->incomplete_class;
6471       ctxp->incomplete_class = ptr;
6472     }
6473
6474   return ptr;
6475 }
6476
6477 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
6478    non NULL instead of computing a new fake type based on WFL. The new
6479    dependency is inserted in the current type dependency list, in FIFO
6480    manner.  */
6481
6482 static tree
6483 register_incomplete_type (kind, wfl, decl, ptr)
6484      int kind;
6485      tree wfl, decl, ptr;
6486 {
6487   jdep *new = (jdep *)xmalloc (sizeof (jdep));
6488
6489   if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
6490     ptr = obtain_incomplete_type (wfl);
6491
6492   JDEP_KIND (new) = kind;
6493   JDEP_DECL (new) = decl;
6494   JDEP_SOLV (new) = ptr;
6495   JDEP_WFL (new) = wfl;
6496   JDEP_CHAIN (new) = NULL;
6497   JDEP_MISC (new) = NULL_TREE;
6498   JDEP_GET_PATCH (new) = (tree *)NULL;
6499
6500   JDEP_INSERT (ctxp->classd_list, new);
6501
6502   return ptr;
6503 }
6504
6505 void
6506 java_check_circular_reference ()
6507 {
6508   tree current;
6509   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
6510     {
6511       tree type = TREE_TYPE (current);
6512       if (CLASS_INTERFACE (TYPE_NAME (type)))
6513         {
6514           /* Check all interfaces this class extends */
6515           tree basetype_vec = TYPE_BINFO_BASETYPES (type);
6516           int n, i;
6517
6518           if (!basetype_vec)
6519             return;
6520           n = TREE_VEC_LENGTH (basetype_vec);
6521           for (i = 0; i < n; i++)
6522             {
6523               tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
6524               if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node 
6525                   && interface_of_p (type, BINFO_TYPE (vec_elt)))
6526                 parse_error_context (lookup_cl (current),
6527                                      "Cyclic interface inheritance");
6528             }
6529         }
6530       else
6531         if (inherits_from_p (CLASSTYPE_SUPER (type), type))
6532           parse_error_context (lookup_cl (current), 
6533                                "Cyclic class inheritance");
6534     }
6535 }
6536
6537 /* safe_layout_class just makes sure that we can load a class without
6538    disrupting the current_class, input_file, lineno, etc, information
6539    about the class processed currently.  */
6540
6541 void
6542 safe_layout_class (class)
6543      tree class;
6544 {
6545   tree save_current_class = current_class;
6546   char *save_input_filename = input_filename;
6547   int save_lineno = lineno;
6548
6549   push_obstacks (&permanent_obstack, &permanent_obstack);
6550
6551   layout_class (class);
6552   pop_obstacks ();
6553
6554   current_class = save_current_class;
6555   input_filename = save_input_filename;
6556   lineno = save_lineno;
6557   CLASS_LOADED_P (class) = 1;
6558 }
6559
6560 static tree
6561 jdep_resolve_class (dep)
6562      jdep *dep;
6563 {
6564   tree decl;
6565
6566   if (JDEP_RESOLVED_P (dep))
6567     decl = JDEP_RESOLVED_DECL (dep);
6568   else
6569     {
6570       decl = resolve_class (JDEP_TO_RESOLVE (dep), 
6571                             JDEP_DECL (dep), JDEP_WFL (dep));
6572       JDEP_RESOLVED (dep, decl);
6573     }
6574     
6575   if (!decl)
6576     complete_class_report_errors (dep);
6577
6578   return decl;
6579 }
6580
6581 /* Complete unsatisfied class declaration and their dependencies */
6582
6583 void
6584 java_complete_class ()
6585 {
6586   tree cclass;
6587   jdeplist *cclassd;
6588   int error_found;
6589   tree type;
6590
6591   push_obstacks (&permanent_obstack, &permanent_obstack);
6592
6593   /* Process imports and reverse the import on demand list */
6594   process_imports ();
6595   if (ctxp->import_demand_list)
6596     ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
6597
6598   /* Rever things so we have the right order */
6599   ctxp->class_list = nreverse (ctxp->class_list);
6600   ctxp->classd_list = reverse_jdep_list (ctxp);
6601
6602   for (cclassd = ctxp->classd_list, cclass = ctxp->class_list; 
6603        cclass && cclassd; 
6604        cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
6605     {
6606       jdep *dep;
6607       for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
6608         {
6609           tree decl;
6610           if (!(decl = jdep_resolve_class (dep)))
6611             continue;
6612
6613           /* Now it's time to patch */
6614           switch (JDEP_KIND (dep))
6615             {
6616             case JDEP_SUPER:
6617               /* Simply patch super */
6618               if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
6619                 continue;
6620               BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO 
6621                 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
6622               break;
6623
6624             case JDEP_FIELD:
6625               {
6626                 /* We do part of the job done in add_field */
6627                 tree field_decl = JDEP_DECL (dep);
6628                 tree field_type = TREE_TYPE (decl);
6629                 push_obstacks (&permanent_obstack, &permanent_obstack);
6630                 if (TREE_CODE (field_type) == RECORD_TYPE)
6631                   field_type = promote_type (field_type);
6632                 pop_obstacks ();
6633                 TREE_TYPE (field_decl) = field_type;
6634                 DECL_ALIGN (field_decl) = 0;
6635                 layout_decl (field_decl, 0);
6636                 SOURCE_FRONTEND_DEBUG 
6637                   (("Completed field/var decl `%s' with `%s'",
6638                     IDENTIFIER_POINTER (DECL_NAME (field_decl)),
6639                     IDENTIFIER_POINTER (DECL_NAME (decl))));
6640                 break;
6641               }
6642             case JDEP_METHOD:   /* We start patching a method */
6643             case JDEP_METHOD_RETURN:
6644               error_found = 0;
6645               while (1)
6646                 {
6647                   if (decl)
6648                     {
6649                       type = TREE_TYPE(decl);
6650                       if (TREE_CODE (type) == RECORD_TYPE)
6651                         type = promote_type (type);
6652                       JDEP_APPLY_PATCH (dep, type);
6653                       SOURCE_FRONTEND_DEBUG 
6654                         (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
6655                            "Completing fct `%s' with ret type `%s'":
6656                            "Completing arg `%s' with type `%s'"),
6657                           IDENTIFIER_POINTER (EXPR_WFL_NODE 
6658                                               (JDEP_DECL_WFL (dep))),
6659                           IDENTIFIER_POINTER (DECL_NAME (decl))));
6660                     }
6661                   else
6662                     error_found = 1;
6663                   dep = JDEP_CHAIN (dep);
6664                   if (JDEP_KIND (dep) == JDEP_METHOD_END)
6665                     break;
6666                   else
6667                     decl = jdep_resolve_class (dep);
6668                 }
6669               if (!error_found)
6670                 {
6671                   tree mdecl = JDEP_DECL (dep), signature;
6672                   push_obstacks (&permanent_obstack, &permanent_obstack);
6673                   /* Recompute and reset the signature */
6674                   signature = build_java_signature (TREE_TYPE (mdecl));
6675                   set_java_signature (TREE_TYPE (mdecl), signature);
6676                   pop_obstacks ();
6677                 }
6678               else
6679                 continue;
6680               break;
6681
6682             case JDEP_INTERFACE:
6683               if (parser_check_super_interface (decl, JDEP_DECL (dep),
6684                                                 JDEP_WFL (dep)))
6685                 continue;
6686               parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
6687               break;
6688
6689             case JDEP_PARM:
6690             case JDEP_VARIABLE:
6691               type = TREE_TYPE(decl);
6692               if (TREE_CODE (type) == RECORD_TYPE)
6693                 type = promote_type (type);
6694               JDEP_APPLY_PATCH (dep, type);
6695               break;
6696
6697             case JDEP_TYPE:
6698               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
6699               SOURCE_FRONTEND_DEBUG 
6700                 (("Completing a random type dependency on a '%s' node",
6701                   tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
6702               break;
6703
6704             case JDEP_EXCEPTION:
6705               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
6706               SOURCE_FRONTEND_DEBUG 
6707                 (("Completing `%s' `throws' argument node",
6708                   IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
6709               break;
6710
6711             default:
6712               fatal ("Can't handle patch code %d - java_complete_class",
6713                      JDEP_KIND (dep));
6714             }
6715         }
6716     }
6717   pop_obstacks ();
6718   return;
6719 }
6720
6721 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
6722    array.  */
6723
6724 static tree
6725 resolve_class (class_type, decl, cl)
6726      tree class_type, decl, cl;
6727 {
6728   char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
6729   char *base = name;
6730   tree resolved_type = TREE_TYPE (class_type);
6731   tree resolved_type_decl;
6732   
6733   if (resolved_type != NULL_TREE)
6734     {
6735       tree resolved_type_decl = TYPE_NAME (resolved_type);
6736       if (resolved_type_decl == NULL_TREE
6737           || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
6738         {
6739           resolved_type_decl = build_decl (TYPE_DECL,
6740                                            TYPE_NAME (class_type),
6741                                            resolved_type);
6742         }
6743       return resolved_type_decl;
6744     }
6745
6746   /* 1- Check to see if we have an array. If true, find what we really
6747      want to resolve  */
6748   while (name[0] == '[')
6749     name++;
6750   if (base != name)
6751     TYPE_NAME (class_type) = get_identifier (name);
6752
6753   /* 2- Resolve the bare type */
6754   if (!(resolved_type_decl = do_resolve_class (class_type, decl, cl)))
6755     return NULL_TREE;
6756   resolved_type = TREE_TYPE (resolved_type_decl);
6757
6758   /* 3- If we have and array, reconstruct the array down to its nesting */
6759   if (base != name)
6760     {
6761       while (base != name)
6762         {
6763           if (TREE_CODE (resolved_type) == RECORD_TYPE)
6764             resolved_type  = promote_type (resolved_type);
6765           resolved_type = build_java_array_type (resolved_type, -1);
6766           CLASS_LOADED_P (resolved_type) = 1;
6767           name--;
6768         }
6769       /* Build a fake decl for this, since this is what is expected to
6770          be returned.  */
6771       resolved_type_decl =
6772         build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
6773       /* Figure how those two things are important for error report. FIXME */
6774       DECL_SOURCE_LINE (resolved_type_decl) = 0;
6775       DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
6776       TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
6777     }
6778   TREE_TYPE (class_type) = resolved_type;
6779   return resolved_type_decl;
6780 }
6781
6782 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
6783    are used to report error messages.  */
6784
6785 tree
6786 do_resolve_class (class_type, decl, cl)
6787      tree class_type;
6788      tree decl;
6789      tree cl;
6790 {
6791   tree new_class_decl;
6792   tree original_name = NULL_TREE;
6793
6794   /* Do not try to replace TYPE_NAME (class_type) by a variable, since
6795      its is changed by find_in_imports{_on_demand} */
6796
6797   /* 1- Check for the type in single imports */
6798   if (find_in_imports (class_type))
6799     return NULL_TREE;
6800
6801   /* 2- And check for the type in the current compilation unit. If it fails,
6802      try with a name qualified with the package name if appropriate. */
6803   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6804     {
6805       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6806           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6807         load_class (TYPE_NAME (class_type), 0);
6808       return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6809     }
6810
6811   original_name = TYPE_NAME (class_type);
6812   if (!QUALIFIED_P (TYPE_NAME (class_type)) && ctxp->package)
6813     TYPE_NAME (class_type) = merge_qualified_name (ctxp->package, 
6814                                                    TYPE_NAME (class_type));
6815 #if 1
6816   if (!(new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6817     load_class (TYPE_NAME (class_type), 0);
6818   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6819     {
6820       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6821           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6822         load_class (TYPE_NAME (class_type), 0);
6823       return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6824     }
6825 #else
6826   new_name = TYPE_NAME (class_type);
6827   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (new_name)) != NULL_TREE)
6828     {
6829       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6830           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6831         load_class (new_name, 0);
6832       return IDENTIFIER_CLASS_VALUE (new_name);
6833     }
6834   else
6835     {
6836       tree class = read_class (new_name);
6837       if (class != NULL_TREE)
6838         {
6839           tree decl = IDENTIFIER_CLASS_VALUE (new_name);
6840           if (decl == NULL_TREE)
6841             decl = push_class (class, new_name);
6842           return decl;
6843         }
6844     }
6845 #endif
6846   TYPE_NAME (class_type) = original_name;
6847
6848   /* 3- Check an other compilation unit that bears the name of type */
6849   load_class (TYPE_NAME (class_type), 0);
6850   if (check_pkg_class_access (TYPE_NAME (class_type), 
6851                               (cl ? cl : lookup_cl (decl))))
6852     return NULL_TREE;
6853
6854   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6855     return new_class_decl;
6856
6857   /* 4- Check the import on demands. Don't allow bar.baz to be
6858      imported from foo.* */
6859   if (!QUALIFIED_P (TYPE_NAME (class_type)))
6860     if (find_in_imports_on_demand (class_type))
6861       return NULL_TREE;
6862
6863   /* 5- Last call for a resolution */
6864   return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6865 }
6866
6867 /* Resolve NAME and lay it out (if not done and if not the current
6868    parsed class). Return a decl node. This function is meant to be
6869    called when type resolution is necessary during the walk pass.  */
6870
6871 static tree
6872 resolve_and_layout (something, cl)
6873      tree something;
6874      tree cl;
6875 {
6876   tree decl;
6877
6878   /* Don't do that on the current class */
6879   if (something == current_class)
6880     return TYPE_NAME (current_class);
6881
6882   /* Don't do anything for void and other primitive types */
6883   if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
6884     return NULL_TREE;
6885
6886   /* Pointer types can be reall pointer types or fake pointers. When
6887      finding a real pointer, recheck for primitive types */
6888   if (TREE_CODE (something) == POINTER_TYPE)
6889     {
6890       if (TREE_TYPE (something))
6891         {
6892           something = TREE_TYPE (something);
6893           if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
6894             return NULL_TREE;
6895         }
6896       else
6897         something = TYPE_NAME (something);
6898     }
6899
6900   /* Don't do anything for arrays of primitive types */
6901   if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
6902       && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
6903     return NULL_TREE;
6904
6905   /* If something is not and IDENTIFIER_NODE, it can be a a TYPE_DECL
6906      or a real TYPE */
6907   if (TREE_CODE (something) != IDENTIFIER_NODE)
6908     something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
6909             DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
6910
6911   if (!(decl = resolve_no_layout (something, cl)))
6912     return NULL_TREE;
6913
6914   /* Resolve and layout if necessary */
6915   layout_class_methods (TREE_TYPE (decl));
6916   if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl)))
6917     CHECK_METHODS (decl);
6918   if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
6919     safe_layout_class (TREE_TYPE (decl));
6920
6921   return decl;
6922 }
6923
6924 /* Resolve a class, returns its decl but doesn't perform any
6925    layout. The current parsing context is saved and restored */
6926
6927 static tree
6928 resolve_no_layout (name, cl)
6929      tree name, cl;
6930 {
6931   tree ptr, decl;
6932   BUILD_PTR_FROM_NAME (ptr, name);
6933   java_parser_context_save_global ();
6934   decl = resolve_class (ptr, NULL_TREE, cl);
6935   java_parser_context_restore_global ();
6936   
6937   return decl;
6938 }
6939
6940 /* Called when reporting errors. Skip leader '[' in a complex array
6941    type description that failed to be resolved.  */
6942
6943 static char *
6944 purify_type_name (name)
6945      char *name;
6946 {
6947   while (*name && *name == '[')
6948     name++;
6949   return name;
6950 }
6951
6952 /* The type CURRENT refers to can't be found. We print error messages.  */
6953
6954 static void
6955 complete_class_report_errors (dep)
6956      jdep *dep;
6957 {
6958   char *name;
6959
6960   if (!JDEP_WFL (dep))
6961     return;
6962
6963   name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
6964   switch (JDEP_KIND (dep))
6965     {
6966     case JDEP_SUPER:
6967       parse_error_context  
6968         (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
6969          purify_type_name (name),
6970          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
6971       break;
6972     case JDEP_FIELD:
6973       parse_error_context
6974         (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
6975          purify_type_name (name),
6976          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
6977       break;
6978     case JDEP_METHOD:           /* Covers arguments */
6979       parse_error_context
6980         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
6981          "argument `%s' of method `%s'",
6982          purify_type_name (name),
6983          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
6984          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
6985       break;
6986     case JDEP_METHOD_RETURN:    /* Covers return type */
6987       parse_error_context
6988         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
6989          "return type of method `%s'", 
6990          purify_type_name (name),
6991          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
6992       break;
6993     case JDEP_INTERFACE:
6994       parse_error_context
6995         (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
6996          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
6997          (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
6998          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
6999       break;
7000     case JDEP_VARIABLE:
7001       parse_error_context
7002         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
7003          "local variable `%s'", 
7004          purify_type_name (IDENTIFIER_POINTER 
7005                            (EXPR_WFL_NODE (JDEP_WFL (dep)))),
7006          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
7007       break;
7008     case JDEP_EXCEPTION:        /* As specified by `throws' */
7009       parse_error_context 
7010           (JDEP_WFL (dep), "Class `%s' not found in `throws'",
7011          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
7012       break;
7013     default:
7014       /* Fix for -Wall. Just break doing nothing. The error will be
7015          caught later */
7016       break;
7017     }
7018 }
7019
7020 /* Check uninitialized final.  */
7021
7022 void
7023 java_check_final ()
7024 {
7025 }
7026
7027 /* Return a static string containing the DECL prototype string. If
7028    DECL is a constructor, use the class name instead of the form
7029    <init> */
7030
7031 static char *
7032 get_printable_method_name (decl)
7033      tree decl;
7034 {
7035   char *to_return;
7036   tree name = NULL_TREE;
7037
7038   if (DECL_CONSTRUCTOR_P (decl))
7039     {
7040       name = DECL_NAME (decl);
7041       DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
7042     }
7043       
7044   to_return = lang_printable_name (decl, 0);
7045   if (DECL_CONSTRUCTOR_P (decl))
7046     DECL_NAME (decl) = name;
7047   
7048   return to_return;
7049 }
7050
7051 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
7052    nevertheless needs to be verfied, 1 otherwise.  */
7053
7054 static int
7055 reset_method_name (method)
7056      tree method;
7057 {
7058   if (!IS_CLINIT (method) && DECL_NAME (method) != finit_identifier_node)
7059     {
7060       /* NAME is just the plain name when Object is being defined */
7061       if (DECL_CONTEXT (method) != object_type_node)
7062         DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ? 
7063                               init_identifier_node : GET_METHOD_NAME (method));
7064       return 0;
7065     }
7066   else 
7067     return 1;
7068 }
7069
7070 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
7071
7072 tree
7073 java_get_real_method_name (method_decl)
7074      tree method_decl;
7075 {
7076   tree method_name = DECL_NAME (method_decl);
7077   if (DECL_CONSTRUCTOR_P (method_decl))
7078     return init_identifier_node;
7079
7080   /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
7081      and still can be a constructor. FIXME */
7082
7083   /* Don't confuse method only bearing the name of their class as
7084      constructors */
7085   else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
7086            && ctxp
7087            && ctxp->current_parsed_class_un == EXPR_WFL_NODE (method_name)
7088            && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
7089            && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
7090     return init_identifier_node;
7091   else
7092     return EXPR_WFL_NODE (method_name);
7093 }
7094
7095 /* Track method being redefined inside the same class. As a side
7096    effect, set DECL_NAME to an IDENTIFIER (prior entering this
7097    function it's a FWL, so we can track errors more accurately */
7098
7099 static int
7100 check_method_redefinition (class, method)
7101      tree class, method;
7102 {
7103   tree redef, name;
7104   tree cl = DECL_NAME (method);
7105   tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
7106   /* decl name of artificial <clinit> and $finit$ doesn't need to be
7107      fixed and checked */
7108
7109   /* Reset the method name before running the check. If it returns 1,
7110      the method doesn't need to be verified with respect to method
7111      redeclaration and we return 0 */
7112   if (reset_method_name (method))
7113     return 0;
7114
7115   name = DECL_NAME (method);
7116   for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
7117     {
7118       if (redef == method)
7119         break;
7120       if (DECL_NAME (redef) == name 
7121           && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
7122         {
7123           parse_error_context 
7124             (cl, "Duplicate %s declaration `%s'",
7125              (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
7126              get_printable_method_name (redef));
7127           return 1;
7128         }
7129     }
7130   return 0;
7131 }
7132
7133 /* Check all the methods of CLASS. Methods are first completed then
7134    checked according to regular method existance rules.
7135    If no constructor were encountered, then build its declaration. */
7136
7137 static void
7138 java_check_regular_methods (class_decl)
7139      tree class_decl;
7140 {
7141   int saw_constructor = 0;
7142   tree method;
7143   tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
7144   tree super_class = CLASSTYPE_SUPER (class);
7145   tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
7146   tree mthrows;
7147
7148   /* It is not necessary to check methods defined in java.lang.Object */
7149   if (class == object_type_node)
7150     return;
7151
7152   if (!TYPE_NVIRTUALS (class))
7153     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
7154
7155   /* Should take interfaces into account. FIXME */
7156   for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
7157     {
7158       tree sig;
7159       tree method_wfl = DECL_NAME (method);
7160       int aflags;
7161
7162       /* If we previously found something and its name was saved,
7163          reinstall it now */
7164       if (found && saved_found_wfl)
7165         {
7166           DECL_NAME (found) = saved_found_wfl;
7167           saved_found_wfl = NULL_TREE;
7168         }
7169
7170       /* Check for redefinitions */
7171       if (check_method_redefinition (class, method))
7172         continue;
7173
7174       /* If we see one constructor a mark so we don't generate the
7175          default one. Also skip other verifications: constructors
7176          can't be inherited hence hiden or overriden */
7177      if (DECL_CONSTRUCTOR_P (method))
7178        {
7179          saw_constructor = 1;
7180          continue;
7181        }
7182
7183       /* We verify things thrown by the method. They must inherits from
7184          java.lang.Throwable */
7185       for (mthrows = DECL_FUNCTION_THROWS (method);
7186            mthrows; mthrows = TREE_CHAIN (mthrows))
7187         {
7188           if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
7189             parse_error_context 
7190               (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be "
7191                "a subclass of class `java.lang.Throwable'",
7192                IDENTIFIER_POINTER 
7193                  (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
7194         }
7195
7196       sig = build_java_argument_signature (TREE_TYPE (method));
7197       found = lookup_argument_method (super_class, DECL_NAME (method), sig);
7198
7199       /* Nothing overrides or it's a private method. */
7200       if (!found)
7201         continue;
7202       if (METHOD_PRIVATE (found))
7203         {
7204           found = NULL_TREE;
7205           continue;
7206         }
7207
7208       /* If found wasn't verified, it's DECL_NAME won't be set properly. 
7209          We set it temporarily for the sake of the error report. */
7210       saved_found_wfl = DECL_NAME (found);
7211       reset_method_name (found);
7212
7213       /* Can't override a method with the same name and different return
7214          types. */
7215       if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
7216         {
7217           char *t = strdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)),
7218                                                  0));
7219           parse_error_context 
7220             (method_wfl,
7221              "Method `%s' was defined with return type `%s' in class `%s'", 
7222              lang_printable_name (found, 0), t,
7223              IDENTIFIER_POINTER 
7224                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7225           free (t);
7226         }
7227
7228       aflags = get_access_flags_from_decl (found);
7229       /* If the method has default, access in an other package, then
7230          issue a warning that the current method doesn't override the
7231          one that was found elsewhere. Do not issue this warning when
7232          the match was found in java.lang.Object.  */
7233       if (DECL_CONTEXT (found) != object_type_node
7234           && ((aflags & 0x7) == 0)
7235           && !class_in_current_package (DECL_CONTEXT (found))
7236           && DECL_NAME (found) != clinit_identifier_node
7237           && flag_not_overriding)
7238         {
7239           parse_warning_context 
7240             (method_wfl, "Method `%s' in class `%s' does not "
7241              "override the corresponding method in class `%s', which is "
7242              "private to a different package",
7243              lang_printable_name (found, 0),
7244              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
7245              IDENTIFIER_POINTER (DECL_NAME 
7246                                  (TYPE_NAME (DECL_CONTEXT (found)))));
7247           continue;
7248         }
7249
7250       /* Can't override final. Can't override static. */
7251       if (METHOD_FINAL (found) || METHOD_STATIC (found))
7252         {
7253           /* Static *can* override static */
7254           if (METHOD_STATIC (found) && METHOD_STATIC (method))
7255             continue;
7256           parse_error_context 
7257             (method_wfl,
7258              "%s methods can't be overriden. Method `%s' is %s in class `%s'",
7259              (METHOD_FINAL (found) ? "Final" : "Static"),
7260              lang_printable_name (found, 0),
7261              (METHOD_FINAL (found) ? "final" : "static"),
7262              IDENTIFIER_POINTER
7263                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7264           continue;
7265         }
7266
7267       /* Static method can't override instance method. */
7268       if (METHOD_STATIC (method))
7269         {
7270           parse_error_context 
7271             (method_wfl,
7272              "Instance methods can't be overriden by a static method. Method "
7273              "`%s' is an instance method in class `%s'",
7274              lang_printable_name (found, 0),
7275              IDENTIFIER_POINTER
7276                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7277           continue;
7278         }
7279
7280       /* - Overriding/hiding public must be public
7281          - Overriding/hiding protected must be protected or public
7282          - If the overriden or hidden method has default (package)
7283            access, then the overriding or hiding method must not be
7284            private; otherwise, a compile-time error occurs */
7285       if ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method)) 
7286           || (METHOD_PROTECTED (found) 
7287               && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
7288           || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
7289               && METHOD_PRIVATE (method)))
7290         {
7291           parse_error_context 
7292             (method_wfl,
7293              "Methods can't be overridden to be more private. Method `%s' is "
7294              "not %s in class `%s'", lang_printable_name (method, 0),
7295              (METHOD_PUBLIC (method) ? "public" : 
7296               (METHOD_PRIVATE (method) ? "private" : "protected")),
7297              IDENTIFIER_POINTER (DECL_NAME 
7298                                  (TYPE_NAME (DECL_CONTEXT (found)))));
7299           continue;
7300         }
7301
7302       /* Overriding methods must have compatible `throws' clauses on checked
7303          exceptions, if any */
7304       check_throws_clauses (method, method_wfl, found);
7305
7306       /* Inheriting multiple methods with the same signature. FIXME */
7307     }
7308   
7309   /* Don't forget eventual pending found and saved_found_wfl. Take
7310      into account that we might have exited because we saw an
7311      aritifical method as the last entry. */
7312
7313   if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
7314     DECL_NAME (found) = saved_found_wfl;
7315
7316   if (!TYPE_NVIRTUALS (class))
7317     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
7318
7319   if (!saw_constructor)
7320     {
7321       /* No constructor seen, we craft one, at line 0. Since this
7322        operation takes place after we laid methods out
7323        (layout_class_methods), we prepare the its DECL
7324        appropriately. */
7325       int flags;
7326       tree decl;
7327
7328       /* If the class is declared PUBLIC, the default constructor is
7329          PUBLIC otherwise it has default access implied by no access
7330          modifiers. */
7331       flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7332                ACC_PUBLIC : 0);
7333       decl = create_artificial_method (class, flags, void_type_node, 
7334                                        init_identifier_node, end_params_node);
7335       DECL_CONSTRUCTOR_P (decl) = 1;
7336       layout_class_method (TREE_TYPE (class_decl), NULL_TREE, decl, NULL_TREE);
7337     }
7338 }
7339
7340 /* Return a non zero value if the `throws' clause of METHOD (if any)
7341    is incompatible with the `throws' clause of FOUND (if any).  */
7342
7343 static void
7344 check_throws_clauses (method, method_wfl, found)
7345      tree method, method_wfl, found;
7346 {
7347   tree mthrows, fthrows;
7348
7349   /* Can't check these things with class loaded from bytecode. FIXME */
7350   if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
7351     return;
7352
7353   for (mthrows = DECL_FUNCTION_THROWS (method);
7354        mthrows; mthrows = TREE_CHAIN (mthrows))
7355     {
7356       /* We don't verify unchecked expressions */
7357       if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
7358         continue;
7359       /* Checked expression must be compatible */
7360       for (fthrows = DECL_FUNCTION_THROWS (found); 
7361            fthrows; fthrows = TREE_CHAIN (fthrows))
7362         if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
7363           break;
7364       if (!fthrows)
7365         {
7366           parse_error_context 
7367             (method_wfl, "Invalid checked exception class `%s' in "
7368              "`throws' clause. The exception must be a subclass of an "
7369              "exception thrown by `%s' from class `%s'",
7370              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
7371              lang_printable_name (found, 0),
7372              IDENTIFIER_POINTER 
7373                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7374         }
7375     }
7376 }
7377
7378 /* Check abstract method of interface INTERFACE */
7379
7380 static void
7381 java_check_abstract_methods (interface_decl)
7382      tree interface_decl;
7383 {
7384   int i, n;
7385   tree method, basetype_vec, found;
7386   tree interface = TREE_TYPE (interface_decl);
7387
7388   for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
7389     {
7390       tree method_wfl = DECL_NAME (method);
7391
7392       /* 2- Check for double definition inside the defining interface */
7393       if (check_method_redefinition (interface, method))
7394         continue;
7395
7396       /* 3- Overriding is OK as far as we preserve the return type and
7397          the thrown exceptions (FIXME) */
7398       found = lookup_java_interface_method2 (interface, method);
7399       if (found)
7400         {
7401           char *t;
7402           tree saved_found_wfl = DECL_NAME (found);
7403           reset_method_name (found);
7404           t = strdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
7405           parse_error_context 
7406             (method_wfl,
7407              "Method `%s' was defined with return type `%s' in class `%s'",
7408              lang_printable_name (found, 0), t,
7409              IDENTIFIER_POINTER 
7410                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7411           free (t);
7412           continue;
7413           
7414           DECL_NAME (found) = saved_found_wfl;
7415         }
7416     }
7417
7418   /* 4- Inherited methods can't differ by their returned types */
7419   if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
7420     return;
7421   n = TREE_VEC_LENGTH (basetype_vec);
7422   for (i = 0; i < n; i++)
7423     {
7424       tree sub_interface_method, sub_interface;
7425       tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7426       if (!vec_elt)
7427         continue;
7428       sub_interface = BINFO_TYPE (vec_elt);
7429       for (sub_interface_method = TYPE_METHODS (sub_interface); 
7430            sub_interface_method;
7431            sub_interface_method = TREE_CHAIN (sub_interface_method))
7432         {
7433           found = lookup_java_interface_method2 (interface, 
7434                                                  sub_interface_method);
7435           if (found && (found != sub_interface_method))
7436             {
7437               tree saved_found_wfl = DECL_NAME (found);
7438               reset_method_name (found);
7439               parse_error_context 
7440                 (lookup_cl (sub_interface_method),
7441                  "Interface `%s' inherits method `%s' from interface `%s'. "
7442                  "This method is redefined with a different return type in "
7443                  "interface `%s'",
7444                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
7445                  lang_printable_name (found, 0),
7446                  IDENTIFIER_POINTER 
7447                    (DECL_NAME (TYPE_NAME 
7448                                (DECL_CONTEXT (sub_interface_method)))),
7449                  IDENTIFIER_POINTER 
7450                    (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7451               DECL_NAME (found) = saved_found_wfl;
7452             }
7453         }
7454     }
7455 }
7456
7457 /* Lookup methods in interfaces using their name and partial
7458    signature. Return a matching method only if their types differ.  */
7459
7460 static tree
7461 lookup_java_interface_method2 (class, method_decl)
7462      tree class, method_decl;
7463 {
7464   int i, n;
7465   tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
7466
7467   if (!basetype_vec)
7468     return NULL_TREE;
7469
7470   n = TREE_VEC_LENGTH (basetype_vec);
7471   for (i = 0; i < n; i++)
7472     {
7473       tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
7474       if ((BINFO_TYPE (vec_elt) != object_type_node)
7475           && (to_return = 
7476               lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
7477         return to_return;
7478     }
7479   for (i = 0; i < n; i++)
7480     {
7481       to_return = lookup_java_interface_method2 
7482         (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
7483       if (to_return)
7484         return to_return;
7485     }
7486
7487   return NULL_TREE;
7488 }
7489
7490 /* Lookup method using their name and partial signature. Return a
7491    matching method only if their types differ.  */
7492
7493 static tree
7494 lookup_java_method2 (clas, method_decl, do_interface)
7495      tree clas, method_decl;
7496      int do_interface;
7497 {
7498   tree method, method_signature, method_name, method_type, name;
7499
7500   method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
7501   name = DECL_NAME (method_decl);
7502   method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ? 
7503                  EXPR_WFL_NODE (name) : name);
7504   method_type = TREE_TYPE (TREE_TYPE (method_decl));
7505
7506   while (clas != NULL_TREE)
7507     {
7508       for (method = TYPE_METHODS (clas);
7509            method != NULL_TREE;  method = TREE_CHAIN (method))
7510         {
7511           tree method_sig = build_java_argument_signature (TREE_TYPE (method));
7512           tree name = DECL_NAME (method);
7513           if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
7514                EXPR_WFL_NODE (name) : name) == method_name
7515               && method_sig == method_signature 
7516               && TREE_TYPE (TREE_TYPE (method)) != method_type)
7517             return method;
7518         }
7519       clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
7520     }
7521   return NULL_TREE;
7522 }
7523
7524 /* Return the line that matches DECL line number. Used during error
7525    report */
7526
7527 static tree
7528 lookup_cl (decl)
7529      tree decl;
7530 {
7531   static tree cl = NULL_TREE;
7532   
7533   if (!decl)
7534     return NULL_TREE;
7535
7536   if (cl == NULL_TREE)
7537     cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
7538
7539   EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
7540   EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
7541
7542   return cl;
7543 }
7544
7545 /* Look for a simple name in the single-type import list */
7546
7547 static tree
7548 find_name_in_single_imports (name)
7549      tree name;
7550 {
7551   tree node;
7552
7553   for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
7554     if (TREE_VALUE (node) == name)
7555       return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
7556
7557   return NULL_TREE;
7558 }
7559
7560 /* Process all single-type import. */
7561
7562 static int
7563 process_imports ()
7564 {
7565   tree import;
7566   int error_found;
7567
7568   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
7569     {
7570       tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
7571
7572       /* Don't load twice something already defined. */
7573       if (IDENTIFIER_CLASS_VALUE (to_be_found))
7574         continue;
7575       QUALIFIED_P (to_be_found) = 1;
7576       load_class (to_be_found, 0);
7577       error_found =
7578         check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
7579       if (!IDENTIFIER_CLASS_VALUE (to_be_found))
7580         {
7581           parse_error_context (TREE_PURPOSE (import),
7582                                "Class or interface `%s' not found in import",
7583                                IDENTIFIER_POINTER (to_be_found));
7584           return 1;
7585         }
7586       if (error_found)
7587         return 1;
7588     }
7589   return 0;
7590 }
7591
7592 /* Possibly find a class imported by a single-type import statement. Return
7593    1 if an error occured, 0 otherwise. */
7594
7595 static int
7596 find_in_imports (class_type)
7597      tree class_type;
7598 {
7599   tree import;
7600
7601   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
7602     if (TREE_VALUE (import) == TYPE_NAME (class_type))
7603       {
7604         TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
7605         QUALIFIED_P (TYPE_NAME (class_type)) = 1;
7606       }
7607   return 0;
7608 }
7609
7610 static int
7611 note_possible_classname (name, len)
7612      char *name;
7613      int len;
7614 {
7615   tree node;
7616   if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
7617     len = len - 5;
7618   else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
7619     len = len - 6;
7620   else
7621     return 0;
7622   node = ident_subst (name, len, "", '/', '.', "");
7623   IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
7624   QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
7625   return 1;
7626 }
7627
7628 /* Read a import directory, gathering potential match for further type
7629    references. Indifferently reads a filesystem or a ZIP archive
7630    directory.  */
7631
7632 static void
7633 read_import_dir (wfl)
7634      tree wfl;
7635 {
7636   tree package_id = EXPR_WFL_NODE (wfl);
7637   char *package_name = IDENTIFIER_POINTER (package_id);
7638   int package_length = IDENTIFIER_LENGTH (package_id);
7639   DIR *dirp = NULL;
7640   JCF *saved_jcf = current_jcf;
7641
7642   int found = 0;
7643   int k;
7644   void *entry;
7645   struct buffer filename[1];
7646
7647
7648   if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
7649     return;
7650   IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
7651
7652   BUFFER_INIT (filename);
7653   buffer_grow (filename, package_length + 100);
7654
7655   for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
7656     {
7657       char *entry_name = jcf_path_name (entry);
7658       int entry_length = strlen (entry_name);
7659       if (jcf_path_is_zipfile (entry))
7660         {
7661           ZipFile *zipf;
7662           buffer_grow (filename, entry_length);
7663           memcpy (filename->data, entry_name, entry_length - 1);
7664           filename->data[entry_length-1] = '\0';
7665           zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
7666           if (zipf == NULL)
7667             error ("malformed .zip archive in CLASSPATH: %s", entry_name);
7668           else
7669             {
7670               ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
7671               BUFFER_RESET (filename);
7672               for (k = 0; k < package_length; k++)
7673                 {
7674                   char ch = package_name[k];
7675                   *filename->ptr++ = ch == '.' ? '/' : ch;
7676                 }
7677               *filename->ptr++ = '/';
7678
7679               for (k = 0; k < zipf->count;  k++, zipd = ZIPDIR_NEXT (zipd))
7680                 {
7681                   char *current_entry = ZIPDIR_FILENAME (zipd);
7682                   int current_entry_len = zipd->filename_length;
7683
7684                   if (current_entry_len >= BUFFER_LENGTH (filename)
7685                       && strncmp (filename->data, current_entry, 
7686                                   BUFFER_LENGTH (filename)) != 0)
7687                     continue;
7688                   found |= note_possible_classname (current_entry,
7689                                                     current_entry_len);
7690                 }
7691             }
7692         }
7693       else
7694         {
7695           BUFFER_RESET (filename);
7696           buffer_grow (filename, entry_length + package_length + 4);
7697           strcpy (filename->data, entry_name);
7698           filename->ptr = filename->data + entry_length;
7699           for (k = 0; k < package_length; k++)
7700             {
7701               char ch = package_name[k];
7702               *filename->ptr++ = ch == '.' ? '/' : ch;
7703             }
7704           *filename->ptr = '\0';
7705
7706           dirp = opendir (filename->data);
7707           if (dirp == NULL)
7708             continue;
7709           *filename->ptr++ = '/';
7710           for (;;)
7711             {
7712               int len; 
7713               char *d_name;
7714               struct dirent *direntp = readdir (dirp);
7715               if (!direntp)
7716                 break;
7717               d_name = direntp->d_name;
7718               len = strlen (direntp->d_name);
7719               buffer_grow (filename, len+1);
7720               strcpy (filename->ptr, d_name);
7721               found |= note_possible_classname (filename->data + entry_length,
7722                                                 package_length+len+1);
7723             }
7724           if (dirp)
7725             closedir (dirp);
7726         }
7727     }
7728
7729   free (filename->data);
7730
7731   /* Here we should have a unified way of retrieving an entry, to be
7732      indexed. */
7733   if (!found)
7734     {
7735       static int first = 1;
7736       if (first)
7737         {
7738           char buffer [256];
7739           sprintf (buffer, "Can't find default package `%s'. Check "
7740                    "the CLASSPATH environment variable and the access to the "
7741                    "archives.", package_name);
7742           error (buffer);
7743           java_error_count++;
7744           first = 0;
7745         }
7746       else
7747         parse_error_context (wfl, "Package `%s' not found in import",
7748                              package_name);
7749       current_jcf = saved_jcf;
7750       return;
7751     }
7752   current_jcf = saved_jcf;
7753 }
7754
7755 /* Possibly find a type in the import on demands specified
7756    types. Returns 1 if an error occured, 0 otherwise. Run throught the
7757    entire list, to detected potential double definitions.  */
7758                  
7759 static int
7760 find_in_imports_on_demand (class_type)
7761      tree class_type;
7762 {
7763   tree node, import, node_to_use = NULL_TREE;
7764   int seen_once = -1;
7765   tree cl = NULL_TREE;
7766
7767   for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
7768     {
7769       char *id_name;
7770       obstack_grow (&temporary_obstack, 
7771                     IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
7772                     IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
7773       obstack_1grow (&temporary_obstack, '.');
7774       obstack_grow0 (&temporary_obstack, 
7775                      IDENTIFIER_POINTER (TYPE_NAME (class_type)),
7776                      IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
7777       id_name = obstack_finish (&temporary_obstack);
7778               
7779       node = maybe_get_identifier (id_name);
7780       if (node && IS_A_CLASSFILE_NAME (node))
7781         {
7782           if (seen_once < 0)
7783             {
7784               cl = TREE_PURPOSE (import);
7785               seen_once = 1;
7786               node_to_use = node;
7787             }
7788           else
7789             {
7790               seen_once++;
7791               parse_error_context 
7792                 (import, "Type `%s' also potentially defined in package `%s'",
7793                  IDENTIFIER_POINTER (TYPE_NAME (class_type)),
7794                  IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
7795             }
7796         }
7797     }
7798
7799   if (seen_once == 1)
7800     {
7801       /* Setup lineno so that it refers to the line of the import (in
7802          case we parse a class file and encounter errors */
7803       tree decl;
7804       int saved_lineno = lineno;
7805       lineno = EXPR_WFL_LINENO (cl);
7806       TYPE_NAME (class_type) = node_to_use;
7807       QUALIFIED_P (TYPE_NAME (class_type)) = 1;
7808       decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
7809       /* If there is no DECL set for the class or if the class isn't
7810          loaded and not seen in source yet, the load */
7811       if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
7812                     && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
7813         load_class (node_to_use, 0);
7814       lineno = saved_lineno;
7815       return check_pkg_class_access (TYPE_NAME (class_type), cl);
7816     }
7817   else
7818     return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
7819 }
7820
7821 static tree
7822 resolve_package (pkg, next)
7823      tree pkg, *next;
7824 {
7825   tree type_name = NULL_TREE;
7826   char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
7827
7828   /* The trick is to determine when the package name stops and were
7829      the name of something contained in the package starts. Then we
7830      return a fully qualified name of what we want to get. */
7831
7832   /* Do a quick search on well known package names */
7833   if (!strncmp (name, "java.lang.reflect", 17))
7834     {
7835       *next = 
7836         TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
7837       type_name = lookup_package_type (name, 17);
7838     }
7839   else if (!strncmp (name, "java.lang", 9))
7840     {
7841       *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
7842       type_name = lookup_package_type (name, 9);
7843     }
7844   else
7845     return NULL_TREE;           /* FIXME, search all imported packages. */
7846
7847   return type_name;
7848 }
7849
7850 static tree
7851 lookup_package_type (name, from)
7852      char *name;
7853      int from;
7854 {
7855   char subname [128];
7856   char *sub = &name[from+1];
7857   while (*sub != '.' && *sub)
7858     sub++;
7859   strncpy (subname, name, sub-name);
7860   subname [sub-name] = '\0';
7861   return get_identifier (subname);
7862 }
7863
7864 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
7865    access violations were found, 1 otherwise.  */
7866
7867 static int
7868 check_pkg_class_access (class_name, cl)
7869      tree class_name;
7870      tree cl;
7871 {
7872   tree type;
7873
7874   if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
7875     return 0;
7876
7877   if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
7878     return 0;
7879
7880   if (!CLASS_PUBLIC (TYPE_NAME (type)))
7881     {
7882       /* Access to a private class within the same package is
7883          allowed. */
7884       tree l, r;
7885       breakdown_qualified (&l, &r, class_name);
7886       if (l == ctxp->package)
7887         return 0;
7888
7889       parse_error_context 
7890         (cl, "Can't access %s `%s'. Only public classes and interfaces in "
7891          "other packages can be accessed",
7892          (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
7893          IDENTIFIER_POINTER (class_name));
7894       return 1;
7895     }
7896   return 0;
7897 }
7898
7899 /* Local variable declaration. */
7900
7901 static void
7902 declare_local_variables (modifier, type, vlist)
7903      int modifier;
7904      tree type;
7905      tree vlist;
7906 {
7907   tree decl, current, saved_type;
7908   tree type_wfl = NULL_TREE;
7909   int must_chain = 0;
7910
7911   /* Push a new block if statements were seen between the last time we
7912      pushed a block and now. Keep a cound of block to close */
7913   if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
7914     {
7915       tree body = GET_CURRENT_BLOCK (current_function_decl);
7916       tree b = enter_block ();
7917       BLOCK_EXPR_ORIGIN (b) = body;
7918     }
7919
7920   if (modifier)
7921     {
7922       int i;
7923       for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
7924       if (modifier == ACC_FINAL)
7925         {
7926           if (flag_static_local_jdk1_1)
7927             parse_warning_context (ctxp->modifier_ctx [i], 
7928                                    "Unsupported JDK1.1 `final' local variable "
7929                                    "(treated as non final)");
7930         }
7931       else 
7932         {
7933           parse_error_context 
7934             (ctxp->modifier_ctx [i], 
7935              "Only `final' is allowed as a local variables modifier");
7936           return;
7937         }
7938     }
7939
7940   /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
7941      hold the TYPE value if a new incomplete has to be created (as
7942      opposed to being found already existing and reused). */
7943   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7944
7945   /* If TYPE is fully resolved and we don't have a reference, make one */
7946   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7947
7948   /* Go through all the declared variables */
7949   for (current = vlist, saved_type = type; current;
7950        current = TREE_CHAIN (current), type = saved_type)
7951     {
7952       tree other, real_type;
7953       tree wfl  = TREE_PURPOSE (current);
7954       tree name = EXPR_WFL_NODE (wfl);
7955       tree init = TREE_VALUE (current);
7956
7957       /* Process NAME, as it may specify extra dimension(s) for it */
7958       type = build_array_from_name (type, type_wfl, name, &name);
7959
7960       /* Variable redefinition check */
7961       if ((other = lookup_name_in_blocks (name)))
7962         {
7963           variable_redefinition_error (wfl, name, TREE_TYPE (other),
7964                                        DECL_SOURCE_LINE (other));
7965           continue;
7966         }
7967
7968       /* Type adjustment. We may have just readjusted TYPE because
7969          the variable specified more dimensions. Make sure we have
7970          a reference if we can and don't have one already. */
7971       PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7972
7973       real_type = GET_REAL_TYPE (type);
7974       /* Never layout this decl. This will be done when its scope
7975          will be entered */
7976       decl = build_decl (VAR_DECL, name, real_type);
7977       BLOCK_CHAIN_DECL (decl);
7978       
7979       /* If doing xreferencing, replace the line number with the WFL
7980          compound value */
7981       if (flag_emit_xref)
7982         DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
7983       
7984       /* Don't try to use an INIT statement when an error was found */
7985       if (init && java_error_count)
7986         init = NULL_TREE;
7987       
7988       /* Add the initialization function to the current function's code */
7989       if (init)
7990         {
7991           /* Name might have been readjusted */
7992           EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
7993           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
7994           java_method_add_stmt (current_function_decl,
7995                                 build_debugable_stmt (EXPR_WFL_LINECOL (init),
7996                                                       init));
7997         }
7998     
7999       /* Setup dependency the type of the decl */
8000       if (must_chain)
8001         {
8002           jdep *dep;
8003           register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
8004           dep = CLASSD_LAST (ctxp->classd_list);
8005           JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
8006         }
8007     }
8008   SOURCE_FRONTEND_DEBUG (("Defined locals"));
8009 }
8010
8011 /* Called during parsing. Build decls from argument list.  */
8012
8013 static void
8014 source_start_java_method (fndecl)
8015      tree fndecl;
8016 {
8017   tree tem;
8018   tree parm_decl;
8019   int i;
8020
8021   current_function_decl = fndecl;
8022
8023   /* New scope for the function */
8024   enter_block ();
8025   for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
8026        tem != end_params_node; tem = TREE_CHAIN (tem), i++)
8027     {
8028       tree type = TREE_VALUE (tem);
8029       tree name = TREE_PURPOSE (tem);
8030       
8031       /* If type is incomplete. Create an incomplete decl and ask for
8032          the decl to be patched later */
8033       if (INCOMPLETE_TYPE_P (type))
8034         {
8035           jdep *jdep;
8036           tree real_type = GET_REAL_TYPE (type);
8037           parm_decl = build_decl (PARM_DECL, name, real_type);
8038           type = obtain_incomplete_type (type);
8039           register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
8040           jdep = CLASSD_LAST (ctxp->classd_list);
8041           JDEP_MISC (jdep) = name;
8042           JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
8043         }
8044       else
8045         parm_decl = build_decl (PARM_DECL, name, type);
8046
8047       BLOCK_CHAIN_DECL (parm_decl);
8048     }
8049   tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
8050   BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
8051     nreverse (tem);
8052   DECL_ARG_SLOT_COUNT (current_function_decl) = i;
8053 }
8054
8055 /* Called during parsing. Creates an artificial method declaration.  */
8056
8057 static tree
8058 create_artificial_method (class, flags, type, name, args)
8059      tree class;
8060      int flags;
8061      tree type, name, args;
8062 {
8063   int saved_lineno = lineno;                                        
8064   tree mdecl;
8065
8066   lineno = 0;                                                               
8067   mdecl = make_node (FUNCTION_TYPE);                                
8068   TREE_TYPE (mdecl) = type;
8069   TYPE_ARG_TYPES (mdecl) = args;
8070   mdecl = add_method (class, flags, name, build_java_signature (mdecl)); 
8071   lineno = saved_lineno;                                                    
8072   DECL_ARTIFICIAL (mdecl) = 1;                                      
8073   return mdecl;
8074 }
8075
8076 /* Starts the body if an artifical method.  */
8077
8078 static void
8079 start_artificial_method_body (mdecl)
8080      tree mdecl;
8081 {
8082   DECL_SOURCE_LINE (mdecl) = 1;
8083   DECL_SOURCE_LINE_MERGE (mdecl, 1);
8084   source_start_java_method (mdecl);
8085   enter_block ();
8086 }
8087
8088 static void
8089 end_artificial_method_body (mdecl)
8090      tree mdecl;
8091 {
8092   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
8093   exit_block ();
8094 }
8095
8096 /* Called during expansion. Push decls formerly built from argument
8097    list so they're usable during expansion. */
8098
8099 static void
8100 expand_start_java_method (fndecl)
8101      tree fndecl;
8102 {
8103   tree tem, *ptr;
8104
8105   current_function_decl = fndecl;
8106
8107   announce_function (fndecl);
8108   pushlevel (1);                /* Push parameters */
8109   ptr = &DECL_ARGUMENTS (fndecl);
8110   tem  = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
8111   while (tem)
8112     {
8113       tree next = TREE_CHAIN (tem);
8114       tree type = TREE_TYPE (tem);
8115 #ifdef PROMOTE_PROTOTYPES
8116       if (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
8117           && INTEGRAL_TYPE_P (type))
8118         type = integer_type_node;
8119 #endif
8120       DECL_ARG_TYPE (tem) = type;
8121       layout_decl (tem, 0);
8122       pushdecl (tem);
8123       *ptr = tem;
8124       ptr = &TREE_CHAIN (tem);
8125       tem = next;
8126     }
8127   *ptr = NULL_TREE;
8128   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
8129   lineno = DECL_SOURCE_LINE_FIRST (fndecl);
8130 }
8131
8132 /* Terminate a function and expand its body.  */
8133
8134 static void
8135 source_end_java_method ()
8136 {
8137   tree fndecl = current_function_decl;
8138   int flag_asynchronous_exceptions = asynchronous_exceptions;
8139
8140   java_parser_context_save_global ();
8141   lineno = ctxp->last_ccb_indent1;
8142
8143   /* Set EH language codes */
8144   java_set_exception_lang_code ();
8145
8146   /* Turn function bodies with only a NOP expr null, so they don't get
8147      generated at all and we won't get warnings when using the -W
8148      -Wall flags. */
8149   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
8150     BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
8151
8152   /* Generate function's code */
8153   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
8154       && ! flag_emit_class_files
8155       && ! flag_emit_xref)
8156     expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
8157
8158   /* pop out of its parameters */
8159   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
8160   poplevel (1, 0, 1);
8161   BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
8162
8163   /* Generate rtl for function exit.  */
8164   if (! flag_emit_class_files && ! flag_emit_xref)
8165     {
8166       lineno = DECL_SOURCE_LINE_LAST (fndecl);
8167       /* Emit catch-finally clauses */
8168       emit_handlers ();
8169       expand_function_end (input_filename, lineno, 0);
8170
8171       /* FIXME: If the current method contains any exception handlers,
8172          force asynchronous_exceptions: this is necessary because signal
8173          handlers in libjava may throw exceptions.  This is far from being
8174          a perfect solution, but it's better than doing nothing at all.*/
8175       if (catch_clauses)
8176         asynchronous_exceptions = 1;
8177
8178       /* Run the optimizers and output assembler code for this function. */
8179       rest_of_compilation (fndecl);
8180     }
8181
8182   current_function_decl = NULL_TREE;
8183   /*  permanent_allocation (1); */
8184   java_parser_context_restore_global ();
8185   asynchronous_exceptions = flag_asynchronous_exceptions;
8186 }
8187
8188 /* Record EXPR in the current function block. Complements compound
8189    expression second operand if necessary.  */
8190
8191 tree
8192 java_method_add_stmt (fndecl, expr)
8193      tree fndecl, expr;
8194 {
8195   return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
8196 }
8197
8198 static tree
8199 add_stmt_to_block (b, type, stmt)
8200      tree b, type, stmt;
8201 {
8202   tree body = BLOCK_EXPR_BODY (b), c;
8203   
8204   if (java_error_count)
8205     return body;
8206     
8207   if ((c = add_stmt_to_compound (body, type, stmt)) == body)
8208     return body;
8209
8210   BLOCK_EXPR_BODY (b) = c;
8211   TREE_SIDE_EFFECTS (c) = 1;
8212   return c;
8213 }
8214
8215 /* Add STMT to EXISTING if possible, otherwise create a new
8216    COMPOUND_EXPR and add STMT to it. */
8217
8218 static tree
8219 add_stmt_to_compound (existing, type, stmt)
8220      tree existing, type, stmt;
8221 {
8222   if (existing)
8223     return build (COMPOUND_EXPR, type, existing, stmt);
8224   else
8225     return stmt;
8226 }
8227
8228 /* Hold THIS for the scope of the current public method decl.  */
8229 static tree current_this;
8230
8231 void java_layout_seen_class_methods ()
8232 {
8233   tree previous_list = all_class_list;
8234   tree end = NULL_TREE;
8235   tree current;
8236
8237   while (1)
8238     {
8239       for (current = previous_list; 
8240            current != end; current = TREE_CHAIN (current))
8241         layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
8242       
8243       if (previous_list != all_class_list)
8244         {
8245           end = previous_list;
8246           previous_list = all_class_list;
8247         }
8248       else
8249         break;
8250     }
8251 }
8252
8253 /* Layout the methods of all classes loaded in one way on an
8254    other. Check methods of source parsed classes. Then reorder the
8255    fields and layout the classes or the type of all source parsed
8256    classes */
8257
8258 void
8259 java_layout_classes ()
8260 {
8261   tree current;
8262   int save_error_count = java_error_count;
8263
8264   /* Layout the methods of all classes seen so far */
8265   java_layout_seen_class_methods ();
8266   java_parse_abort_on_error ();
8267   all_class_list = NULL_TREE;
8268
8269   /* Then check the methods of all parsed classes */
8270   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
8271     if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
8272       CHECK_METHODS (TREE_VALUE (current));
8273   java_parse_abort_on_error ();
8274
8275   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
8276     {
8277       current_class = TREE_TYPE (TREE_VALUE (current));
8278
8279       /* Reverse the fields, but leave the dummy field in front.
8280          Fields are already ordered for Object and Class */
8281       if (TYPE_FIELDS (current_class) && current_class != object_type_node
8282           && current_class != class_type_node)
8283       {
8284         /* If the dummy field is there, reverse the right fields and
8285            just layout the type for proper fields offset */
8286         if (!DECL_NAME (TYPE_FIELDS (current_class)))
8287           {
8288             tree fields = TYPE_FIELDS (current_class);
8289             TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
8290             TYPE_SIZE (current_class) = NULL_TREE;
8291             layout_type (current_class);
8292           }
8293         /* We don't have a dummy field, we need to layout the class,
8294            after having reversed the fields */
8295         else
8296           {
8297             TYPE_FIELDS (current_class) = 
8298               nreverse (TYPE_FIELDS (current_class));
8299             TYPE_SIZE (current_class) = NULL_TREE;
8300             layout_class (current_class);
8301           }
8302       }
8303       else
8304         layout_class (current_class);
8305
8306       /* From now on, the class is considered completely loaded */
8307       CLASS_LOADED_P (current_class) = 1;
8308
8309       /* Error reported by the caller */
8310       if (java_error_count)
8311         return;
8312     }
8313
8314   /* We might have reloaded classes durign the process of laying out
8315      classes for code generation. We must layout the methods of those
8316      late additions, as constructor checks might use them */
8317   java_layout_seen_class_methods ();
8318   java_parse_abort_on_error ();
8319 }
8320
8321 /* Expand all methods in all registered classes.  */
8322
8323 void
8324 java_complete_expand_methods ()
8325 {
8326   tree current;
8327
8328   do_not_fold = flag_emit_xref;
8329   
8330   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
8331     {
8332       int is_interface;
8333       tree class_type = CLASS_TO_HANDLE_TYPE (TREE_TYPE (current));
8334       tree decl;
8335
8336       current_class = TREE_TYPE (current);
8337       is_interface = CLASS_INTERFACE (TYPE_NAME (current_class));
8338
8339       /* Initialize a new constant pool */
8340       init_outgoing_cpool ();
8341
8342       /* We want <clinit> (if any) to be processed first. */
8343       decl = tree_last (TYPE_METHODS (class_type));
8344       if (IS_CLINIT (decl))
8345         {
8346           tree fbody = DECL_FUNCTION_BODY (decl);
8347           tree list;
8348           if (fbody != NULL_TREE)
8349             {
8350               /* First check if we can ignore empty <clinit> */
8351               tree block_body = BLOCK_EXPR_BODY (fbody);
8352
8353               current_this = NULL_TREE;
8354               current_function_decl = decl;
8355               if (block_body != NULL_TREE)
8356                 {
8357                   /* Prevent the use of `this' inside <clinit> */
8358                   ctxp->explicit_constructor_p = 1;
8359
8360                   block_body = java_complete_tree (block_body);
8361                   ctxp->explicit_constructor_p = 0;
8362                   BLOCK_EXPR_BODY (fbody) = block_body;
8363                   if (block_body != NULL_TREE
8364                       && TREE_CODE (block_body) == BLOCK
8365                       && BLOCK_EXPR_BODY (block_body) == empty_stmt_node)
8366                     decl = NULL_TREE;
8367                 }
8368             }
8369           list = nreverse (TREE_CHAIN (nreverse (TYPE_METHODS (class_type))));
8370           if (decl != NULL_TREE)
8371             {
8372               TREE_CHAIN (decl) = list;
8373               TYPE_METHODS (class_type) = decl;
8374             }
8375             else
8376               TYPE_METHODS (class_type) = list;
8377         }
8378       
8379       for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
8380         {
8381           current_function_decl = decl;
8382           /* Don't generate debug info on line zero when expanding a
8383              generated constructor. */
8384           if (DECL_CONSTRUCTOR_P (decl) && !DECL_FUNCTION_BODY (decl))
8385             {
8386               /* If we found errors, it's too dangerous to try to
8387                  generate and expand a constructor */
8388               if (!java_error_count)
8389                 {
8390                   restore_line_number_status (1);
8391                   java_complete_expand_method (decl);
8392                   restore_line_number_status (0);
8393                   }
8394             }
8395           else if (METHOD_ABSTRACT (decl) || METHOD_NATIVE (decl))
8396             continue;
8397           else 
8398             java_complete_expand_method (decl);
8399         }
8400
8401       /* Now verify constructor circularity (stop after the first one
8402          we find) */
8403       if (!is_interface)
8404         for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
8405           if (DECL_CONSTRUCTOR_P (decl) && 
8406               verify_constructor_circularity (decl, decl))
8407             break;
8408
8409       /* Make the class data, register it and run the rest of decl
8410          compilation on it */
8411       if (!java_error_count)
8412         {
8413           if (flag_emit_class_files)
8414             write_classfile (current_class);
8415           if (flag_emit_xref)
8416             expand_xref (current_class);
8417           else if (! flag_syntax_only)
8418             finish_class (current_class);
8419         }
8420     }
8421 }
8422
8423 /* Hold a list of catch clauses list. The first element of this list is
8424    the list of the catch clauses of the currently analysed try block. */
8425 static tree currently_caught_type_list;
8426
8427 /* Complete and expand a method.  */
8428
8429 static void
8430 java_complete_expand_method (mdecl)
8431      tree mdecl;
8432 {
8433   /* Fix constructors before expanding them */
8434   if (DECL_CONSTRUCTOR_P (mdecl))
8435     fix_constructors (mdecl);
8436   
8437   /* Expand functions that have a body */
8438   if (DECL_FUNCTION_BODY (mdecl))
8439     {
8440       tree fbody = DECL_FUNCTION_BODY (mdecl);
8441       tree block_body = BLOCK_EXPR_BODY (fbody);
8442       tree exception_copy;
8443       expand_start_java_method (mdecl);
8444       build_result_decl (mdecl);
8445
8446       current_this 
8447         = (!METHOD_STATIC (mdecl) ? 
8448            BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
8449
8450       /* Purge the `throws' list of unchecked exceptions. If we're
8451          doing xref, save a copy of the list and re-install it
8452          later. */
8453       if (flag_emit_xref)
8454         exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
8455
8456       purge_unchecked_exceptions (mdecl);
8457
8458       /* Install exceptions thrown with `throws' */
8459       PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
8460
8461       if (block_body != NULL_TREE)
8462         {
8463           block_body = java_complete_tree (block_body);
8464           if (!flag_emit_xref)
8465             check_for_initialization (block_body);
8466           ctxp->explicit_constructor_p = 0;
8467         }
8468       BLOCK_EXPR_BODY (fbody) = block_body;
8469
8470       if ((block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
8471           && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
8472           && !flag_emit_xref)
8473         missing_return_error (current_function_decl);
8474
8475       complete_start_java_method (mdecl); 
8476
8477       /* Don't go any further if we've found error(s) during the
8478          expansion */
8479       if (!java_error_count)
8480         source_end_java_method ();
8481       else
8482         {
8483           pushdecl_force_head (DECL_ARGUMENTS (mdecl));
8484           poplevel (1, 0, 1);
8485         }
8486
8487       /* Pop the exceptions and sanity check */
8488       POP_EXCEPTIONS();
8489       if (currently_caught_type_list)
8490         fatal ("Exception list non empty - java_complete_expand_method");
8491
8492       if (flag_emit_xref)
8493         DECL_FUNCTION_THROWS (mdecl) = exception_copy;
8494     }
8495 }
8496
8497 /* Craft a body for default constructor. Patch existing constructor
8498    bodies with call to super() and field initialization statements if
8499    necessary.  */
8500
8501 static void
8502 fix_constructors (mdecl)
8503      tree mdecl;
8504 {
8505   tree body = DECL_FUNCTION_BODY (mdecl);
8506
8507   if (!body)
8508     {
8509       /* The constructor body must be crafted by hand. It's the
8510          constructor we defined when we realize we didn't have the
8511          CLASSNAME() constructor */
8512
8513       tree compound;
8514
8515       /* It is an error for the compiler to generate a default
8516          constructor if the superclass doesn't have a constructor that
8517          takes no argument */
8518       if (verify_constructor_super ())
8519         {
8520           tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (current_class));
8521           char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
8522           parse_error_context (lookup_cl (TYPE_NAME (current_class)), 
8523                                "No constructor matching `%s()' found in "
8524                                "class `%s'", n, n);
8525         }
8526       
8527       start_artificial_method_body (mdecl);
8528       
8529       /* We don't generate a super constructor invocation if we're
8530          compiling java.lang.Object. build_super_invocation takes care
8531          of that. */
8532       compound = java_method_add_stmt (mdecl, build_super_invocation ());
8533
8534       end_artificial_method_body (mdecl);
8535     }
8536   /* Search for an explicit constructor invocation */
8537   else 
8538     {
8539       int found = 0;
8540       tree main_block = BLOCK_EXPR_BODY (body);
8541       tree compound = NULL_TREE;
8542       
8543       while (body)
8544         switch (TREE_CODE (body))
8545           {
8546           case CALL_EXPR:
8547             found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
8548             body = NULL_TREE;
8549             break;
8550           case COMPOUND_EXPR:
8551           case EXPR_WITH_FILE_LOCATION:
8552             body = TREE_OPERAND (body, 0);
8553             break;
8554           case BLOCK:
8555             body = BLOCK_EXPR_BODY (body);
8556             break;
8557           default:
8558             found = 0;
8559             body = NULL_TREE;
8560           }
8561       /* The constructor is missing an invocation of super() */
8562       if (!found)
8563         compound = add_stmt_to_compound (compound, NULL_TREE,
8564                                          build_super_invocation ());
8565       
8566       /* Fix the constructor main block if we're adding extra stmts */
8567       if (compound)
8568         {
8569           compound = add_stmt_to_compound (compound, NULL_TREE,
8570                                            BLOCK_EXPR_BODY (main_block));
8571           BLOCK_EXPR_BODY (main_block) = compound;
8572         }
8573     }
8574 }
8575
8576 /* Browse constructors in the super class, searching for a constructor
8577    that doesn't take any argument. Return 0 if one is found, 1
8578    otherwise. */
8579
8580 static int
8581 verify_constructor_super ()
8582 {
8583   tree class = CLASSTYPE_SUPER (current_class);
8584   if (!class)
8585     return 0;
8586
8587   if (class)
8588     {
8589       tree mdecl;
8590       for (mdecl = TYPE_METHODS (class); mdecl; mdecl = TREE_CHAIN (mdecl))
8591         {
8592           if (DECL_CONSTRUCTOR_P (mdecl)
8593               && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (mdecl))) == end_params_node)
8594             return 0;
8595         }
8596     }
8597   return 1;
8598 }
8599
8600 /* Expand finals.  */
8601
8602 void
8603 java_expand_finals ()
8604 {
8605 }
8606
8607 /* Generate code for all context remembered for code generation.  */
8608
8609 void
8610 java_expand_classes ()
8611 {
8612   int save_error_count = 0;
8613   java_parse_abort_on_error ();
8614   if (!(ctxp = ctxp_for_generation))
8615     return;
8616   java_layout_classes ();
8617   java_parse_abort_on_error ();
8618
8619   for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
8620     {
8621       ctxp = ctxp_for_generation;
8622       lang_init_source (2);            /* Error msgs have method prototypes */
8623       java_complete_expand_methods (); /* Complete and expand method bodies */
8624       java_parse_abort_on_error ();
8625       java_expand_finals ();          /* Expand and check the finals */
8626       java_parse_abort_on_error ();
8627       java_check_final ();            /* Check unitialized final  */
8628       java_parse_abort_on_error ();
8629     }
8630 }
8631
8632 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
8633    a tree list node containing RIGHT. Fore coming RIGHTs will be
8634    chained to this hook. LOCATION contains the location of the
8635    separating `.' operator.  */
8636
8637 static tree
8638 make_qualified_primary (primary, right, location)
8639      tree primary, right;
8640      int location;
8641 {
8642   tree wfl;
8643
8644   /* We want to process THIS . xxx symbolicaly, to keep it consistent
8645      with the way we're processing SUPER. A THIS from a primary as a
8646      different form than a SUPER. Turn THIS into something symbolic */
8647   if (TREE_CODE (primary) == THIS_EXPR)
8648     {
8649       wfl = build_wfl_node (this_identifier_node);
8650       EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (primary);
8651       wfl = make_qualified_name (wfl, right, location);
8652       PRIMARY_P (wfl) = 1;
8653       return wfl;
8654     }
8655   /* Other non WFL node are wrapped around a WFL */
8656   else if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
8657     {
8658       wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
8659       EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (primary);
8660       EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (primary, NULL_TREE);
8661     }
8662   else
8663     {
8664       wfl = primary;
8665       if (!EXPR_WFL_QUALIFICATION (primary))
8666         EXPR_WFL_QUALIFICATION (primary) = 
8667           build_tree_list (primary, NULL_TREE);
8668     }
8669
8670   EXPR_WFL_LINECOL (right) = location;
8671   chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
8672   PRIMARY_P (wfl) =  1;
8673   return wfl;
8674 }
8675
8676 /* Simple merge of two name separated by a `.' */
8677
8678 static tree
8679 merge_qualified_name (left, right)
8680      tree left, right;
8681 {
8682   tree node;
8683   obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
8684                 IDENTIFIER_LENGTH (left));
8685   obstack_1grow (&temporary_obstack, '.');
8686   obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
8687                  IDENTIFIER_LENGTH (right));
8688   node =  get_identifier (obstack_base (&temporary_obstack));
8689   obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
8690   QUALIFIED_P (node) = 1;
8691   return node;
8692 }
8693
8694 /* Merge the two parts of a qualified name into LEFT.  Set the
8695    location information of the resulting node to LOCATION, usually
8696    inherited from the location information of the `.' operator. */
8697
8698 static tree
8699 make_qualified_name (left, right, location)
8700      tree left, right;
8701      int location;
8702 {
8703 #ifdef USE_COMPONENT_REF
8704   tree node = build (COMPONENT_REF, NULL_TREE, left, right);
8705   EXPR_WFL_LINECOL (node) = location;
8706   return node;
8707 #else
8708   tree left_id = EXPR_WFL_NODE (left);
8709   tree right_id = EXPR_WFL_NODE (right);
8710   tree wfl, merge;
8711
8712   merge = merge_qualified_name (left_id, right_id);
8713
8714   /* Left wasn't qualified and is now qualified */
8715   if (!QUALIFIED_P (left_id))
8716     {
8717       tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
8718       EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
8719       EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
8720     }
8721   
8722   wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
8723   EXPR_WFL_LINECOL (wfl) = location;
8724   chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
8725
8726   EXPR_WFL_NODE (left) = merge;
8727   return left;
8728 #endif
8729 }
8730
8731 /* Extract the last identifier component of the qualified in WFL. The
8732    last identifier is removed from the linked list */
8733
8734 static tree
8735 cut_identifier_in_qualified (wfl)
8736      tree wfl;
8737 {
8738   tree q;
8739   tree previous = NULL_TREE;
8740   for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
8741     if (!TREE_CHAIN (q))
8742       {
8743         if (!previous)
8744           fatal ("Operating on a non qualified qualified WFL - "
8745                  "cut_identifier_in_qualified");
8746         TREE_CHAIN (previous) = NULL_TREE;
8747         return TREE_PURPOSE (q);
8748       }
8749 }
8750
8751 /* Resolve the expression name NAME. Return its decl.  */
8752
8753 static tree
8754 resolve_expression_name (id, orig)
8755      tree id;
8756      tree *orig;
8757 {
8758   tree name = EXPR_WFL_NODE (id);
8759   tree decl;
8760
8761   /* 6.5.5.1: Simple expression names */
8762   if (!PRIMARY_P (id) && !QUALIFIED_P (name))
8763     {
8764       /* 15.13.1: NAME can appear within the scope of a local variable
8765          declaration */
8766       if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
8767         return decl;
8768
8769       /* 15.13.1: NAME can appear within a class declaration */
8770       else 
8771         {
8772           decl = lookup_field_wrapper (current_class, name);
8773           if (decl)
8774             {
8775               int fs = FIELD_STATIC (decl);
8776               /* Instance variable (8.3.1.1) can't appear within
8777                  static method, static initializer or initializer for
8778                  a static variable. */
8779               if (!fs && METHOD_STATIC (current_function_decl))
8780                 {
8781                   static_ref_err (id, name, current_class);
8782                   return error_mark_node;
8783                 }
8784               /* Instance variables can't appear as an argument of
8785                  an explicit constructor invocation */
8786               if (!fs && ctxp->explicit_constructor_p)
8787                 {
8788                   parse_error_context
8789                     (id, "Can't reference `%s' before the superclass "
8790                      "constructor has been called", IDENTIFIER_POINTER (name));
8791                   return error_mark_node;
8792                 }
8793
8794               /* Otherwise build what it takes to access the field */
8795               decl = build_field_ref ((fs ? NULL_TREE : current_this),
8796                                       DECL_CONTEXT (decl), name);
8797               if (fs && !flag_emit_class_files && !flag_emit_xref)
8798                 decl = build_class_init (DECL_CONTEXT (decl), decl);
8799               /* We may be asked to save the real field access node */
8800               if (orig)
8801                 *orig = decl;
8802               /* And we return what we got */
8803               return decl;
8804             }
8805           /* Fall down to error report on undefined variable */
8806         }
8807     }
8808   /* 6.5.5.2 Qualified Expression Names */
8809   else
8810     {
8811       if (orig)
8812         *orig = NULL_TREE;
8813       qualify_ambiguous_name (id);
8814       /* 15.10.1 Field Access Using a Primary and/or Expression Name */
8815       /* 15.10.2: Accessing Superclass Members using super */
8816       return resolve_field_access (id, NULL, NULL);
8817     }
8818
8819   /* We've got an error here */
8820   parse_error_context (id, "Undefined variable `%s'", 
8821                        IDENTIFIER_POINTER (name));
8822
8823   return error_mark_node;
8824 }
8825
8826 static void
8827 static_ref_err (wfl, field_id, class_type)
8828     tree wfl, field_id, class_type;
8829 {
8830   parse_error_context 
8831     (wfl, 
8832      "Can't make a static reference to nonstatic variable `%s' in class `%s'",
8833      IDENTIFIER_POINTER (field_id), 
8834      IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
8835 }
8836
8837 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
8838    We return something suitable to generate the field access. We also
8839    return the field decl in FIELD_DECL and its type in FIELD_TYPE.  If
8840    recipient's address can be null. */
8841
8842 static tree
8843 resolve_field_access (qual_wfl, field_decl, field_type)
8844      tree qual_wfl;
8845      tree *field_decl, *field_type;
8846 {
8847   int is_static = 0;
8848   tree field_ref;
8849   tree decl, where_found, type_found;
8850
8851   if (resolve_qualified_expression_name (qual_wfl, &decl,
8852                                          &where_found, &type_found))
8853     return error_mark_node;
8854
8855   /* Resolve the LENGTH field of an array here */
8856   if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
8857       && ! flag_emit_class_files && ! flag_emit_xref)
8858     {
8859       tree length = build_java_array_length_access (where_found);
8860       field_ref =
8861         build_java_arraynull_check (type_found, length, int_type_node);
8862     }
8863   /* We might have been trying to resolve field.method(). In which
8864      case, the resolution is over and decl is the answer */
8865   else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
8866     field_ref = decl;
8867   else if (JDECL_P (decl))
8868     {
8869       int static_final_found = 0;
8870       if (!type_found)
8871         type_found = DECL_CONTEXT (decl);
8872       is_static = JDECL_P (decl) && FIELD_STATIC (decl);
8873       if (FIELD_FINAL (decl) 
8874           && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
8875           && DECL_LANG_SPECIFIC (decl)
8876           && DECL_INITIAL (decl))
8877         {
8878           field_ref = DECL_INITIAL (decl);
8879           static_final_found = 1;
8880         }
8881       else
8882         field_ref = build_field_ref ((is_static && !flag_emit_xref? 
8883                                       NULL_TREE : where_found), 
8884                                      type_found, DECL_NAME (decl));
8885       if (field_ref == error_mark_node)
8886         return error_mark_node;
8887       if (is_static && !static_final_found 
8888           && !flag_emit_class_files && !flag_emit_xref)
8889         {
8890           field_ref = build_class_init (type_found, field_ref);
8891           /* If the static field was identified by an expression that
8892              needs to be generated, make the field access a compound
8893              expression whose first part is the evaluation of the
8894              field selector part. */
8895           if (where_found && TREE_CODE (where_found) != TYPE_DECL 
8896               && TREE_CODE (where_found) != RECORD_TYPE)
8897             {
8898               tree type = QUAL_DECL_TYPE (field_ref);
8899               field_ref = build (COMPOUND_EXPR, type, where_found, field_ref);
8900             }
8901         }
8902     }
8903   else
8904     field_ref = decl;
8905
8906   if (field_decl)
8907     *field_decl = decl;
8908   if (field_type)
8909     *field_type = (QUAL_DECL_TYPE (decl) ? 
8910                    QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
8911   return field_ref;
8912 }
8913
8914 /* If NODE is an access to f static field, strip out the class
8915    initialization part and return the field decl, otherwise, return
8916    NODE. */
8917
8918 static tree
8919 strip_out_static_field_access_decl (node)
8920     tree node;
8921 {
8922   if (TREE_CODE (node) == COMPOUND_EXPR)
8923     {
8924       tree op1 = TREE_OPERAND (node, 1);
8925       if (TREE_CODE (op1) == COMPOUND_EXPR)
8926          {
8927            tree call = TREE_OPERAND (op1, 0);
8928            if (TREE_CODE (call) == CALL_EXPR
8929                && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
8930                && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
8931                == soft_initclass_node)
8932              return TREE_OPERAND (op1, 1);
8933          }
8934     }
8935   return node;
8936 }
8937
8938 /* 6.5.5.2: Qualified Expression Names */
8939
8940 static int
8941 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
8942      tree wfl;
8943      tree *found_decl, *type_found, *where_found;
8944 {
8945   int from_type = 0;            /* Field search initiated from a type */
8946   int from_super = 0, from_cast = 0;
8947   int previous_call_static = 0;
8948   int is_static;
8949   tree decl = NULL_TREE, type = NULL_TREE, q;
8950   *type_found = *where_found = NULL_TREE;
8951
8952   for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
8953     {
8954       tree qual_wfl = QUAL_WFL (q);
8955
8956       /* 15.10.1 Field Access Using a Primary */
8957       switch (TREE_CODE (qual_wfl))
8958         {
8959         case CALL_EXPR:
8960         case NEW_CLASS_EXPR:
8961           /* If the access to the function call is a non static field,
8962              build the code to access it. */
8963           if (JDECL_P (decl) && !FIELD_STATIC (decl))
8964             {
8965               decl = maybe_access_field (decl, *where_found, 
8966                                          DECL_CONTEXT (decl));
8967               if (decl == error_mark_node)
8968                 return 1;
8969             }
8970           /* And code for the function call */
8971           if (complete_function_arguments (qual_wfl))
8972             return 1;
8973           if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
8974             CALL_USING_SUPER (qual_wfl) = 1;
8975           *where_found = 
8976             patch_method_invocation (qual_wfl, decl, type, &is_static, NULL);
8977           if (*where_found == error_mark_node)
8978             return 1;
8979           *type_found = type = QUAL_DECL_TYPE (*where_found);
8980
8981           /* If the previous call was static and this one is too,
8982              build a compound expression to hold the two (because in
8983              that case, previous function calls aren't transported as
8984              forcoming function's argument. */
8985           if (previous_call_static && is_static)
8986             {
8987               decl = build (COMPOUND_EXPR, type, decl, *where_found);
8988               TREE_SIDE_EFFECTS (decl) = 1;
8989             }
8990           else
8991             {
8992               previous_call_static = is_static;
8993               decl = *where_found;
8994             }
8995           continue;
8996
8997         case NEW_ARRAY_EXPR:
8998           *where_found = decl = java_complete_tree (qual_wfl);
8999           if (decl == error_mark_node)
9000             return 1;
9001           *type_found = type = QUAL_DECL_TYPE (decl);
9002           CLASS_LOADED_P (type) = 1;
9003           continue;
9004
9005         case CONVERT_EXPR:
9006           *where_found = decl = java_complete_tree (qual_wfl);
9007           if (decl == error_mark_node)
9008             return 1;
9009           *type_found = type = QUAL_DECL_TYPE (decl);
9010           from_cast = 1;
9011           continue;
9012
9013         case CONDITIONAL_EXPR:
9014         case STRING_CST:
9015           *where_found = decl = java_complete_tree (qual_wfl);
9016           if (decl == error_mark_node)
9017             return 1;
9018           *type_found = type = QUAL_DECL_TYPE (decl);
9019           continue;
9020
9021         case ARRAY_REF:
9022           /* If the access to the function call is a non static field,
9023              build the code to access it. */
9024           if (JDECL_P (decl) && !FIELD_STATIC (decl))
9025             {
9026               decl = maybe_access_field (decl, *where_found, type);
9027               if (decl == error_mark_node)
9028                 return 1;
9029             }
9030           /* And code for the array reference expression */
9031           decl = java_complete_tree (qual_wfl);
9032           if (decl == error_mark_node)
9033             return 1;
9034           type = QUAL_DECL_TYPE (decl);
9035           continue;
9036
9037         default:
9038           /* Fix for -Wall Just go to the next statement. Don't
9039              continue */
9040           break;
9041         }
9042
9043       /* If we fall here, we weren't processing a (static) function call. */
9044       previous_call_static = 0;
9045
9046       /* It can be the keyword THIS */
9047       if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
9048         {
9049           if (!current_this)
9050             {
9051               parse_error_context 
9052                 (wfl, "Keyword `this' used outside allowed context");
9053               return 1;
9054             }
9055           /* We have to generate code for intermediate acess */
9056           *where_found = decl = current_this;
9057           *type_found = type = QUAL_DECL_TYPE (decl);
9058           continue;
9059         }
9060
9061       /* 15.10.2 Accessing Superclass Members using SUPER */
9062       if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
9063         {
9064           tree node;
9065           /* Check on the restricted use of SUPER */
9066           if (METHOD_STATIC (current_function_decl)
9067               || current_class == object_type_node)
9068             {
9069               parse_error_context 
9070                 (wfl, "Keyword `super' used outside allowed context");
9071               return 1;
9072             }
9073           /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
9074           node = build_cast (EXPR_WFL_LINECOL (qual_wfl), 
9075                              CLASSTYPE_SUPER (current_class),
9076                              build_this (EXPR_WFL_LINECOL (qual_wfl)));
9077           *where_found = decl = java_complete_tree (node);
9078           if (decl == error_mark_node)
9079             return 1;
9080           *type_found = type = QUAL_DECL_TYPE (decl);
9081           from_super = from_type = 1;
9082           continue;
9083         }
9084
9085       /* 15.13.1: Can't search for field name in packages, so we
9086          assume a variable/class name was meant. */
9087       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
9088         {
9089           tree name = resolve_package (wfl, &q);
9090           if (name)
9091             {
9092               *where_found = decl = resolve_no_layout (name, qual_wfl);
9093               /* We wan't to be absolutely that the class is laid
9094                  out. We're going to search something inside it. */
9095               *type_found = type = TREE_TYPE (decl);
9096               layout_class (type);
9097               from_type = 1;
9098               /* Should be a list, really. FIXME */
9099               RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (TREE_CHAIN (q))) = 1;
9100               RESOLVE_PACKAGE_NAME_P (QUAL_WFL (TREE_CHAIN (q))) = 0;
9101             }
9102           else
9103             {
9104               if (from_super || from_cast)
9105                 parse_error_context 
9106                   ((from_cast ? qual_wfl : wfl),
9107                    "No variable `%s' defined in class `%s'",
9108                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
9109                    lang_printable_name (type, 0));
9110               else
9111                 parse_error_context
9112                   (qual_wfl, "Undefined variable or class name: `%s'",
9113                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
9114               return 1;
9115             }
9116         }
9117
9118       /* We have a type name. It's been already resolved when the
9119          expression was qualified. */
9120       else if (RESOLVE_TYPE_NAME_P (qual_wfl))
9121         {
9122           if (!(decl = QUAL_RESOLUTION (q)))
9123             return 1;           /* Error reported already */
9124
9125           if (not_accessible_p (TREE_TYPE (decl), decl, 0))
9126             {
9127               parse_error_context 
9128                 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
9129                  java_accstring_lookup (get_access_flags_from_decl (decl)),
9130                  GET_TYPE_NAME (type),
9131                  IDENTIFIER_POINTER (DECL_NAME (decl)),
9132                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
9133               return 1;
9134             }
9135           check_deprecation (qual_wfl, decl);
9136           
9137           type = TREE_TYPE (decl);
9138           from_type = 1;
9139         }
9140       /* We resolve and expression name */
9141       else 
9142         {
9143           tree field_decl;
9144
9145           /* If there exists an early resolution, use it. That occurs
9146              only once and we know that there are more things to
9147              come. Don't do that when processing something after SUPER
9148              (we need more thing to be put in place below */
9149           if (!from_super && QUAL_RESOLUTION (q))
9150             {
9151               decl = QUAL_RESOLUTION (q);
9152               if (!type)
9153                 {
9154                   if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
9155                     {
9156                       if (current_this)
9157                         *where_found = current_this;
9158                       else
9159                         {
9160                           static_ref_err (qual_wfl, DECL_NAME (decl),
9161                                           current_class);
9162                           return 1;
9163                         }
9164                     }
9165                   else
9166                     {
9167                       *where_found = TREE_TYPE (decl);
9168                       if (TREE_CODE (*where_found) == POINTER_TYPE)
9169                         *where_found = TREE_TYPE (*where_found);
9170                     }
9171                 }
9172             }
9173
9174           /* We have to search for a field, knowing the type of its
9175              container. The flag FROM_TYPE indicates that we resolved
9176              the last member of the expression as a type name, which
9177              means that for the resolution of this field, we'll look
9178              for other errors than if it was resolved as a member of
9179              an other field. */
9180           else
9181             {
9182               int is_static;
9183               tree field_decl_type; /* For layout */
9184
9185               if (!from_type && !JREFERENCE_TYPE_P (type))
9186                 {
9187                   parse_error_context 
9188                     (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
9189                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
9190                      lang_printable_name (type, 0),
9191                      IDENTIFIER_POINTER (DECL_NAME (field_decl)));
9192                   return 1;
9193                 }
9194               
9195               field_decl = lookup_field_wrapper (type,
9196                                                  EXPR_WFL_NODE (qual_wfl));
9197               if (field_decl == NULL_TREE)
9198                 {
9199                   parse_error_context 
9200                     (qual_wfl, "No variable `%s' defined in type `%s'",
9201                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)), 
9202                      GET_TYPE_NAME (type));
9203                   return 1;
9204                 }
9205               if (field_decl == error_mark_node)
9206                 return 1;
9207
9208               /* Layout the type of field_decl, since we may need
9209                  it. Don't do primitive types or loaded classes. The
9210                  situation of non primitive arrays may not handled
9211                  properly here. FIXME */
9212               if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
9213                 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
9214               else
9215                 field_decl_type = TREE_TYPE (field_decl);
9216               if (!JPRIMITIVE_TYPE_P (field_decl_type) 
9217                   && !CLASS_LOADED_P (field_decl_type)
9218                   && !TYPE_ARRAY_P (field_decl_type))
9219                 resolve_and_layout (field_decl_type, NULL_TREE);
9220               if (TYPE_ARRAY_P (field_decl_type))
9221                 CLASS_LOADED_P (field_decl_type) = 1;
9222               
9223               /* Check on accessibility here */
9224               if (not_accessible_p (type, field_decl, from_super))
9225                 {
9226                   parse_error_context 
9227                     (qual_wfl,
9228                      "Can't access %s field `%s.%s' from `%s'",
9229                      java_accstring_lookup 
9230                        (get_access_flags_from_decl (field_decl)),
9231                      GET_TYPE_NAME (type),
9232                      IDENTIFIER_POINTER (DECL_NAME (field_decl)),
9233                      IDENTIFIER_POINTER 
9234                        (DECL_NAME (TYPE_NAME (current_class))));
9235                   return 1;
9236                 }
9237               check_deprecation (qual_wfl, field_decl);
9238               
9239               /* There are things to check when fields are accessed
9240                  from type. There are no restrictions on a static
9241                  declaration of the field when it is accessed from an
9242                  interface */
9243               is_static = FIELD_STATIC (field_decl);
9244               if (!from_super && from_type 
9245                   && !TYPE_INTERFACE_P (type) && !is_static)
9246                 {
9247                   static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
9248                   return 1;
9249                 }
9250               from_cast = from_super = 0;
9251
9252               /* If we need to generate something to get a proper
9253                  handle on what this field is accessed from, do it
9254                  now. */
9255               if (!is_static)
9256                 {
9257                   decl = maybe_access_field (decl, *where_found, *type_found);
9258                   if (decl == error_mark_node)
9259                     return 1;
9260                 }
9261
9262               /* We want to keep the location were found it, and the type
9263                  we found. */
9264               *where_found = decl;
9265               *type_found = type;
9266
9267               /* This is the decl found and eventually the next one to
9268                  search from */
9269               decl = field_decl;
9270             }
9271           from_type = 0;
9272           type = QUAL_DECL_TYPE (decl);
9273         }
9274     }
9275   *found_decl = decl;
9276   return 0;
9277 }
9278
9279 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
9280    can't be accessed from REFERENCE (a record type). */
9281
9282 int not_accessible_p (reference, member, from_super)
9283      tree reference, member;
9284      int from_super;
9285 {
9286   int access_flag = get_access_flags_from_decl (member);
9287
9288   /* Access always granted for members declared public */
9289   if (access_flag & ACC_PUBLIC)
9290     return 0;
9291   
9292   /* Check access on protected members */
9293   if (access_flag & ACC_PROTECTED)
9294     {
9295       /* Access granted if it occurs from within the package
9296          containing the class in which the protected member is
9297          declared */
9298       if (class_in_current_package (DECL_CONTEXT (member)))
9299         return 0;
9300
9301       /* If accessed with the form `super.member', then access is granted */
9302       if (from_super)
9303         return 0;
9304
9305       /* Otherwise, access is granted if occuring from the class where
9306          member is declared or a subclass of it */
9307       if (inherits_from_p (reference, current_class))
9308         return 0;
9309       return 1;
9310     }
9311
9312   /* Check access on private members. Access is granted only if it
9313      occurs from within the class in witch it is declared */
9314   if (access_flag & ACC_PRIVATE)
9315     return (current_class == DECL_CONTEXT (member) ? 0 : 1);
9316
9317   /* Default access are permitted only when occuring within the
9318      package in which the type (REFERENCE) is declared. In other words,
9319      REFERENCE is defined in the current package */
9320   if (ctxp->package)
9321     return !class_in_current_package (reference);
9322   
9323   /* Otherwise, access is granted */
9324   return 0;
9325 }
9326
9327 /* Test deprecated decl access.  */
9328 static void
9329 check_deprecation (wfl, decl)
9330      tree wfl, decl;
9331 {
9332   char *file = DECL_SOURCE_FILE (decl);
9333   /* Complain if the field is deprecated and the file it was defined
9334      in isn't compiled at the same time the file which contains its
9335      use is */
9336   if (DECL_DEPRECATED (decl) 
9337       && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
9338     {
9339       char the [20];
9340       switch (TREE_CODE (decl))
9341         {
9342         case FUNCTION_DECL:
9343           strcpy (the, "method");
9344           break;
9345         case FIELD_DECL:
9346           strcpy (the, "field");
9347           break;
9348         case TYPE_DECL:
9349           strcpy (the, "class");
9350           break;
9351         default:
9352           fatal ("unexpected DECL code - check_deprecation");
9353         }
9354       parse_warning_context 
9355         (wfl, "The %s `%s' in class `%s' has been deprecated", 
9356          the, lang_printable_name (decl, 0),
9357          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
9358     }
9359 }
9360
9361 /* Returns 1 if class was declared in the current package, 0 otherwise */
9362
9363 static int
9364 class_in_current_package (class)
9365      tree class;
9366 {
9367   static tree cache = NULL_TREE;
9368   int qualified_flag;
9369   tree left;
9370
9371   if (cache == class)
9372     return 1;
9373
9374   qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
9375
9376   /* If the current package is empty and the name of CLASS is
9377      qualified, class isn't in the current package.  If there is a
9378      current package and the name of the CLASS is not qualified, class
9379      isn't in the current package */
9380   if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
9381     return 0;
9382
9383   /* If there is not package and the name of CLASS isn't qualified,
9384      they belong to the same unnamed package */
9385   if (!ctxp->package && !qualified_flag)
9386     return 1;
9387
9388   /* Compare the left part of the name of CLASS with the package name */
9389   breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
9390   if (ctxp->package == left)
9391     {
9392       cache = class;
9393       return 1;
9394     }
9395   return 0;
9396 }
9397
9398 /* This function may generate code to access DECL from WHERE. This is
9399    done only if certain conditions meet.  */
9400
9401 static tree
9402 maybe_access_field (decl, where, type)
9403   tree decl, where, type;
9404 {
9405   if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
9406       && !FIELD_STATIC (decl))
9407     decl = build_field_ref (where ? where : current_this, 
9408                             (type ? type : DECL_CONTEXT (decl)),
9409                             DECL_NAME (decl));
9410   return decl;
9411 }
9412
9413 /* Build a method invocation, by patching PATCH. If non NULL
9414    and according to the situation, PRIMARY and WHERE may be
9415    used. IS_STATIC is set to 1 if the invoked function is static. */
9416
9417 static tree
9418 patch_method_invocation (patch, primary, where, is_static, ret_decl)
9419      tree patch, primary, where;
9420      int *is_static;
9421      tree *ret_decl;
9422 {
9423   tree wfl = TREE_OPERAND (patch, 0);
9424   tree args = TREE_OPERAND (patch, 1);
9425   tree name = EXPR_WFL_NODE (wfl);
9426   tree list;
9427   int is_static_flag = 0;
9428   int is_super_init = 0;
9429   tree this_arg = NULL_TREE;
9430   
9431   /* Should be overriden if everything goes well. Otherwise, if
9432      something fails, it should keep this value. It stop the
9433      evaluation of a bogus assignment. See java_complete_tree,
9434      MODIFY_EXPR: for the reasons why we sometimes want to keep on
9435      evaluating an assignment */
9436   TREE_TYPE (patch) = error_mark_node;
9437
9438   /* Since lookup functions are messing with line numbers, save the
9439      context now.  */
9440   java_parser_context_save_global ();
9441
9442   /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
9443
9444   /* Resolution of qualified name, excluding constructors */
9445   if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
9446     {
9447       tree class_decl, identifier, identifier_wfl;
9448       /* Extract the last IDENTIFIER of the qualified
9449          expression. This is a wfl and we will use it's location
9450          data during error report. */
9451       identifier_wfl = cut_identifier_in_qualified (wfl);
9452       identifier = EXPR_WFL_NODE (identifier_wfl);
9453       
9454       /* Given the context, IDENTIFIER is syntactically qualified
9455          as a MethodName. We need to qualify what's before */
9456       qualify_ambiguous_name (wfl);
9457
9458       /* Package resolution are erroneous */
9459       if (RESOLVE_PACKAGE_NAME_P (wfl))
9460         {
9461           tree remainder;
9462           breakdown_qualified (&remainder, NULL, EXPR_WFL_NODE (wfl));
9463           parse_error_context (wfl, "Can't search method `%s' in package "
9464                                "`%s'",IDENTIFIER_POINTER (identifier),
9465                                IDENTIFIER_POINTER (remainder));
9466           PATCH_METHOD_RETURN_ERROR ();
9467         }
9468       /* We're resolving a call from a type */
9469       else if (RESOLVE_TYPE_NAME_P (wfl))
9470         {
9471           tree decl = QUAL_RESOLUTION (EXPR_WFL_QUALIFICATION (wfl));
9472           tree name = DECL_NAME (decl);
9473           tree type;
9474
9475           class_decl = resolve_and_layout (name, wfl);
9476           if (CLASS_INTERFACE (decl))
9477             {
9478               parse_error_context
9479                 (identifier_wfl, "Can't make static reference to method "
9480                  "`%s' in interface `%s'", IDENTIFIER_POINTER (identifier), 
9481                  IDENTIFIER_POINTER (name));
9482               PATCH_METHOD_RETURN_ERROR ();
9483             }
9484           /* Look the method up in the type selector. The method ought
9485              to be static. */
9486           type = TREE_TYPE (class_decl);
9487           list = lookup_method_invoke (0, wfl, type, identifier, args);
9488           if (list && !METHOD_STATIC (list))
9489             {
9490               char *fct_name = strdup (lang_printable_name (list, 0));
9491               parse_error_context 
9492                 (identifier_wfl,
9493                  "Can't make static reference to method `%s %s' in class `%s'",
9494                  lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
9495                  fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
9496               free (fct_name);
9497               PATCH_METHOD_RETURN_ERROR ();
9498             }
9499           args = nreverse (args);
9500         }
9501       /* We're resolving an expression name */
9502       else
9503         {
9504           tree field, type;
9505           
9506           /* 1- Find the field to which the call applies */
9507           field = resolve_field_access (wfl, NULL, &type);
9508           if (field == error_mark_node)
9509             PATCH_METHOD_RETURN_ERROR ();
9510           /* field is used in lieu of a primary. It alows us not to
9511            report errors on erroneous use of `this' in
9512            constructors. */
9513           primary = field;      
9514           
9515           /* 2- Do the layout of the class where the last field
9516              was found, so we can search it. */
9517           class_decl = resolve_and_layout (type, NULL_TREE);
9518           if (class_decl != NULL_TREE)
9519           type = TREE_TYPE (class_decl);
9520
9521           /* 3- Retrieve a filtered list of method matches, Refine
9522              if necessary. In any cases, point out errors.  */
9523           list = lookup_method_invoke (0, identifier_wfl, type, 
9524                                        identifier, args);
9525
9526           /* 4- Add the field as an argument */
9527           args = nreverse (args);
9528           this_arg = field;
9529         }
9530
9531       /* IDENTIFIER_WFL will be used to report any problem further */
9532       wfl = identifier_wfl;
9533     }
9534   /* Resolution of simple names, names generated after a primary: or
9535      constructors */
9536   else
9537     {
9538       tree class_to_search;
9539       int lc;           /* Looking for Constructor */
9540       
9541       /* We search constructor in their target class */
9542       if (CALL_CONSTRUCTOR_P (patch))
9543         {
9544           if (TREE_CODE (patch) == NEW_CLASS_EXPR)
9545             class_to_search = EXPR_WFL_NODE (wfl);
9546           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) == 
9547                    this_identifier_node)
9548             class_to_search = NULL_TREE;
9549           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
9550                    super_identifier_node)
9551             {
9552               is_super_init = 1;
9553               if (CLASSTYPE_SUPER (current_class))
9554                 class_to_search = 
9555                   DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
9556               else
9557                 {
9558                   parse_error_context (wfl, "Can't invoke super constructor "
9559                                        "on java.lang.Object");
9560                   PATCH_METHOD_RETURN_ERROR ();
9561                 }
9562             }
9563
9564           /* Class to search is NULL if we're searching the current one */
9565           if (class_to_search)
9566             {
9567               class_to_search = resolve_and_layout (class_to_search, 
9568                                                     NULL_TREE);
9569               if (!class_to_search)
9570                 {
9571                   parse_error_context 
9572                     (wfl, "Class `%s' not found in type declaration",
9573                      IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
9574                   PATCH_METHOD_RETURN_ERROR ();
9575                 }
9576               
9577               /* Can't instantiate an abstract class, but we can
9578                  invoke it's constructor. It's use within the `new'
9579                  context is denied here. */
9580               if (CLASS_ABSTRACT (class_to_search) 
9581                   && TREE_CODE (patch) == NEW_CLASS_EXPR)
9582                 {
9583                   parse_error_context 
9584                     (wfl, "Class `%s' is an abstract class. It can't be "
9585                      "instantiated", IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
9586                   PATCH_METHOD_RETURN_ERROR ();
9587                 }
9588               class_to_search = TREE_TYPE (class_to_search);
9589             }
9590           else
9591             class_to_search = current_class;
9592           lc = 1;
9593         }
9594       /* This is a regular search in the local class, unless an
9595          alternate class is specified. */
9596       else
9597         {
9598           class_to_search = (where ? where : current_class);
9599           lc = 0;
9600         }
9601       
9602       /* NAME is a simple identifier or comes from a primary. Search
9603          in the class whose declaration contain the method being
9604          invoked. */
9605       resolve_and_layout (class_to_search, NULL_TREE);
9606       list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
9607
9608       /* Don't continue if no method were found, as the next statement
9609          can't be executed then. */
9610       if (!list)
9611         PATCH_METHOD_RETURN_ERROR ();
9612
9613       /* Check for static reference if non static methods */
9614       if (check_for_static_method_reference (wfl, patch, list, 
9615                                              class_to_search, primary))
9616         PATCH_METHOD_RETURN_ERROR ();
9617
9618       /* Non static methods are called with the current object extra
9619          argument. If patch a `new TYPE()', the argument is the value
9620          returned by the object allocator. If method is resolved as a
9621          primary, use the primary otherwise use the current THIS. */
9622       args = nreverse (args);
9623       if (TREE_CODE (patch) != NEW_CLASS_EXPR)
9624         this_arg = primary ? primary : current_this;
9625     }
9626
9627   /* Merge point of all resolution schemes. If we have nothing, this
9628      is an error, already signaled */
9629   if (!list) 
9630     PATCH_METHOD_RETURN_ERROR ();
9631
9632   /* Check accessibility, position the is_static flag, build and
9633      return the call */
9634   if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
9635     {
9636       char *fct_name = strdup (lang_printable_name (list, 0));
9637       parse_error_context 
9638         (wfl, "Can't access %s method `%s %s.%s' from `%s'",
9639          java_accstring_lookup (get_access_flags_from_decl (list)),
9640          lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
9641          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))), 
9642          fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
9643       free (fct_name);
9644       PATCH_METHOD_RETURN_ERROR ();
9645     }
9646   check_deprecation (wfl, list);
9647
9648   is_static_flag = METHOD_STATIC (list);
9649   if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
9650     args = tree_cons (NULL_TREE, this_arg, args);
9651
9652   /* In the context of an explicit constructor invocation, we can't
9653      invoke any method relying on `this'. Exceptions are: we're
9654      invoking a static function, primary exists and is not the current
9655      this, we're creating a new object. */
9656   if (ctxp->explicit_constructor_p 
9657       && !is_static_flag 
9658       && (!primary || primary == current_this)
9659       && (TREE_CODE (patch) != NEW_CLASS_EXPR))
9660     {
9661       parse_error_context 
9662         (wfl, "Can't reference `this' before the superclass constructor has "
9663          "been called");
9664       PATCH_METHOD_RETURN_ERROR ();
9665     }
9666   java_parser_context_restore_global ();
9667   if (is_static) 
9668     *is_static = is_static_flag;
9669   /* Sometimes, we want the decl of the selected method. Such as for
9670      EH checking */
9671   if (ret_decl)
9672     *ret_decl = list;
9673   patch = patch_invoke (patch, list, args);
9674   if (is_super_init && CLASS_HAS_FINIT_P (current_class))
9675     {
9676       /* Generate the code used to initialize fields declared with an
9677          initialization statement. For now, it returns a call the the
9678          artificial function $finit$, if required. */
9679
9680       tree finit_call =
9681         build_method_invocation (build_expr_wfl (finit_identifier_node,  
9682                                                  input_filename, 0, 0),  
9683                                  NULL_TREE);
9684       patch = build (COMPOUND_EXPR, void_type_node, patch,
9685                      java_complete_tree (finit_call));
9686       CAN_COMPLETE_NORMALLY (patch) = 1;
9687     }
9688   return patch;
9689 }
9690
9691 /* Check that we're not trying to do a static reference to a method in
9692    non static method. Return 1 if it's the case, 0 otherwise. */
9693
9694 static int
9695 check_for_static_method_reference (wfl, node, method, where, primary)
9696      tree wfl, node, method, where, primary;
9697 {
9698   if (METHOD_STATIC (current_function_decl) 
9699       && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
9700     {
9701       char *fct_name = strdup (lang_printable_name (method, 0));
9702       parse_error_context 
9703         (wfl, "Can't make static reference to method `%s %s' in class `%s'", 
9704          lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
9705          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
9706       free (fct_name);
9707       return 1;
9708     }
9709   return 0;
9710 }
9711
9712 /* Patch an invoke expression METHOD and ARGS, based on its invocation
9713    mode.  */
9714
9715 static tree
9716 patch_invoke (patch, method, args)
9717      tree patch, method, args;
9718 {
9719   tree dtable, func;
9720   tree original_call, t, ta;
9721
9722   /* Last step for args: convert build-in types. If we're dealing with
9723      a new TYPE() type call, the first argument to the constructor
9724      isn't found in the incomming argument list, but delivered by
9725      `new' */
9726   t = TYPE_ARG_TYPES (TREE_TYPE (method));
9727   if (TREE_CODE (patch) == NEW_CLASS_EXPR)
9728     t = TREE_CHAIN (t);
9729   for (ta = args; t != end_params_node && ta; 
9730        t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
9731     if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
9732         TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
9733       TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
9734   
9735   if (flag_emit_class_files || flag_emit_xref)
9736     func = method;
9737   else
9738     {
9739       tree signature = build_java_signature (TREE_TYPE (method));
9740       switch (invocation_mode (method, CALL_USING_SUPER (patch)))
9741         {
9742         case INVOKE_VIRTUAL:
9743           dtable = invoke_build_dtable (0, args);
9744           func = build_invokevirtual (dtable, method);
9745           break;
9746
9747         case INVOKE_SUPER:
9748         case INVOKE_STATIC:
9749           func = build_known_method_ref (method, TREE_TYPE (method),
9750                                          DECL_CONTEXT (method),
9751                                          signature, args);
9752           break;
9753
9754         case INVOKE_INTERFACE:
9755           dtable = invoke_build_dtable (1, args);
9756           func = build_invokeinterface (dtable, DECL_NAME (method), signature);
9757           break;
9758
9759         default:
9760           fatal ("internal error - unknown invocation_mode result");
9761         }
9762
9763       /* Ensure self_type is initialized, (invokestatic). FIXME */
9764       func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
9765     }
9766
9767   TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
9768   TREE_OPERAND (patch, 0) = func;
9769   TREE_OPERAND (patch, 1) = args;
9770   original_call = patch;
9771
9772   /* We're processing a `new TYPE ()' form. New is called an its
9773      returned value is the first argument to the constructor. We build
9774      a COMPOUND_EXPR and use saved expression so that the overall NEW
9775      expression value is a pointer to a newly created and initialized
9776      class. */
9777   if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
9778     {
9779       tree class = DECL_CONTEXT (method);
9780       tree c1, saved_new, size, new;
9781       if (flag_emit_class_files || flag_emit_xref)
9782         {
9783           TREE_TYPE (patch) = build_pointer_type (class);
9784           return patch;
9785         }
9786       if (!TYPE_SIZE (class))
9787         safe_layout_class (class);
9788       size = size_in_bytes (class);
9789       new = build (CALL_EXPR, promote_type (class),
9790                    build_address_of (alloc_object_node),
9791                    tree_cons (NULL_TREE, build_class_ref (class),
9792                               build_tree_list (NULL_TREE, 
9793                                                size_in_bytes (class))),
9794                    NULL_TREE);
9795       saved_new = save_expr (new);
9796       c1 = build_tree_list (NULL_TREE, saved_new);
9797       TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
9798       TREE_OPERAND (original_call, 1) = c1;
9799       TREE_SET_CODE (original_call, CALL_EXPR);
9800       patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
9801     }
9802   return patch;
9803 }
9804
9805 static int
9806 invocation_mode (method, super)
9807      tree method;
9808      int super;
9809 {
9810   int access = get_access_flags_from_decl (method);
9811
9812   if (super)
9813     return INVOKE_SUPER;
9814
9815   if (access & ACC_STATIC || access & ACC_FINAL || access & ACC_PRIVATE)
9816     return INVOKE_STATIC;
9817
9818   if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
9819     return INVOKE_STATIC;
9820   
9821   if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
9822     return INVOKE_INTERFACE;
9823   
9824   if (DECL_CONSTRUCTOR_P (method))
9825     return INVOKE_STATIC;
9826
9827   return INVOKE_VIRTUAL;
9828 }
9829
9830 /* Retrieve a refined list of matching methods. It covers the step
9831    15.11.2 (Compile-Time Step 2) */
9832
9833 static tree
9834 lookup_method_invoke (lc, cl, class, name, arg_list)
9835      int lc;
9836      tree cl;
9837      tree class, name, arg_list;
9838 {
9839   tree atl = end_params_node;           /* Arg Type List */
9840   tree method, signature, list, node;
9841   char *candidates;             /* Used for error report */
9842
9843   /* Fix the arguments */
9844   for (node = arg_list; node; node = TREE_CHAIN (node))
9845     {
9846       tree current_arg = TREE_TYPE (TREE_VALUE (node));
9847       /* Non primitive type may have to be resolved */
9848       if (!JPRIMITIVE_TYPE_P (current_arg))
9849         resolve_and_layout (current_arg, NULL_TREE);
9850       /* And promoted */
9851       if (TREE_CODE (current_arg) == RECORD_TYPE)
9852         current_arg = promote_type (current_arg);
9853       atl = tree_cons (NULL_TREE, current_arg, atl);
9854     }
9855
9856   /* Find all candidates and then refine the list, searching for the
9857      most specific method. */
9858   list = find_applicable_accessible_methods_list (lc, class, name, atl);
9859   list = find_most_specific_methods_list (list);
9860   if (list && !TREE_CHAIN (list))
9861     return TREE_VALUE (list);
9862
9863   /* Issue an error. List candidates if any. Candidates are listed
9864      only if accessible (non accessible methods may end-up here for
9865      the sake of a better error report). */
9866   candidates = NULL;
9867   if (list)
9868     {
9869       tree current;
9870       obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
9871       for (current = list; current; current = TREE_CHAIN (current))
9872         {
9873           tree cm = TREE_VALUE (current);
9874           char string [4096];
9875           if (!cm || not_accessible_p (class, cm, 0))
9876             continue;
9877           sprintf 
9878             (string, "  `%s' in `%s'%s",
9879              get_printable_method_name (cm),
9880              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
9881              (TREE_CHAIN (current) ? "\n" : ""));
9882           obstack_grow (&temporary_obstack, string, strlen (string));
9883         }
9884       obstack_1grow (&temporary_obstack, '\0');
9885       candidates = obstack_finish (&temporary_obstack);
9886     }
9887   /* Issue the error message */
9888   method = make_node (FUNCTION_TYPE);
9889   TYPE_ARG_TYPES (method) = atl;
9890   signature = build_java_argument_signature (method);
9891   parse_error_context (cl, "Can't find %s `%s(%s)' in class `%s'%s",
9892                        (lc ? "constructor" : "method"),
9893                        (lc ? 
9894                         IDENTIFIER_POINTER(DECL_NAME (TYPE_NAME (class))) :
9895                         IDENTIFIER_POINTER (name)),
9896                        IDENTIFIER_POINTER (signature),
9897                        IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class))),
9898                        (candidates ? candidates : ""));
9899   return NULL_TREE;
9900 }
9901
9902 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
9903    when we're looking for a constructor. */
9904
9905 static tree
9906 find_applicable_accessible_methods_list (lc, class, name, arglist)
9907      int lc;
9908      tree class, name, arglist;
9909 {
9910   tree list = NULL_TREE, all_list = NULL_TREE;
9911
9912   /* Search interfaces */
9913   if (CLASS_INTERFACE (TYPE_NAME (class)))
9914     {
9915       static tree searched_interfaces = NULL_TREE;
9916       static int search_not_done = 0;
9917       int i, n;
9918       tree basetype_vec = TYPE_BINFO_BASETYPES (class);
9919
9920       /* Have we searched this interface already? */
9921       if (searched_interfaces)
9922         {  
9923           tree current;  
9924           for (current = searched_interfaces; 
9925                current; current = TREE_CHAIN (current))
9926             if (TREE_VALUE (current) == class)
9927               return NULL;
9928         }
9929       searched_interfaces = tree_cons (NULL_TREE, class, searched_interfaces);
9930
9931       search_applicable_methods_list 
9932         (lc, TYPE_METHODS (class), name, arglist, &list, &all_list);
9933
9934       n = TREE_VEC_LENGTH (basetype_vec);
9935       for (i = 0; i < n; i++)
9936         {
9937           tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
9938           tree rlist;
9939
9940           /* Skip java.lang.Object (we'll search it once later.) */
9941           if (t == object_type_node)
9942             continue;
9943
9944           search_not_done++;
9945           rlist = find_applicable_accessible_methods_list (lc,  t, name, 
9946                                                            arglist);
9947           all_list = chainon (rlist, (list ? list : all_list)); 
9948           search_not_done--;
9949         }
9950
9951       /* We're done. Reset the searched interfaces list and finally search
9952          java.lang.Object */
9953       if (!search_not_done)
9954         {  
9955           searched_interfaces = NULL_TREE;  
9956           search_applicable_methods_list (lc, TYPE_METHODS (object_type_node),
9957                                           name, arglist, &list, &all_list);
9958         }
9959     }
9960   /* Search classes */
9961   else
9962     while (class != NULL_TREE)
9963       {
9964         search_applicable_methods_list 
9965           (lc, TYPE_METHODS (class), name, arglist, &list, &all_list);
9966         class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class));
9967       }
9968
9969   /* Either return the list obtained or all selected (but
9970      inaccessible) methods for better error report. */
9971   return (!list ? all_list : list);
9972 }
9973
9974 /* Effectively search for the approriate method in method */
9975
9976 static void 
9977 search_applicable_methods_list(lc, method, name, arglist, list, all_list)
9978      int lc;
9979      tree method, name, arglist;
9980      tree *list, *all_list;
9981 {
9982   for (; method; method = TREE_CHAIN (method))
9983     {
9984       /* When dealing with constructor, stop here, otherwise search
9985          other classes */
9986       if (lc && !DECL_CONSTRUCTOR_P (method))
9987         continue;
9988       else if (!lc && (DECL_CONSTRUCTOR_P (method) 
9989                        || (GET_METHOD_NAME (method) != name)))
9990         continue;
9991           
9992       if (argument_types_convertible (method, arglist))
9993         {
9994           /* Retain accessible methods only */
9995           if (!not_accessible_p (DECL_CONTEXT (current_function_decl), 
9996                                  method, 0))
9997             *list = tree_cons (NULL_TREE, method, *list);
9998           else
9999             /* Also retain all selected method here */
10000             *all_list = tree_cons (NULL_TREE, method, *list);
10001         }
10002     }
10003 }    
10004
10005 /* 15.11.2.2 Choose the Most Specific Method */
10006
10007 static tree
10008 find_most_specific_methods_list (list)
10009      tree list;
10010 {
10011   int max = 0;
10012   tree current, new_list = NULL_TREE;
10013   for (current = list; current; current = TREE_CHAIN (current))
10014     {
10015       tree method;
10016       DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
10017
10018       for (method = list; method; method = TREE_CHAIN (method))
10019         {
10020           /* Don't test a method against itself */
10021           if (method == current)
10022             continue;
10023
10024           /* Compare arguments and location where method where declared */
10025           if (argument_types_convertible (TREE_VALUE (method), 
10026                                           TREE_VALUE (current))
10027               && valid_method_invocation_conversion_p 
10028                    (DECL_CONTEXT (TREE_VALUE (method)), 
10029                     DECL_CONTEXT (TREE_VALUE (current))))
10030             {
10031               int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
10032               max = (v > max ? v : max);
10033             }
10034         }
10035     }
10036
10037   /* Review the list and select the maximally specific methods */
10038   for (current = list; current; current = TREE_CHAIN (current))
10039     if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
10040       new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
10041
10042   /* If we can't find one, lower expectations and try to gather multiple
10043      maximally specific methods */
10044   while (!new_list)
10045     {
10046       while (--max > 0)
10047         {
10048           if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
10049             new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
10050         }
10051       return new_list;
10052     }
10053
10054   return new_list;
10055 }
10056
10057 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
10058    converted by method invocation conversion (5.3) to the type of the
10059    corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
10060    to change less often than M1. */
10061
10062 static int
10063 argument_types_convertible (m1, m2_or_arglist)
10064     tree m1, m2_or_arglist;
10065 {
10066   static tree m2_arg_value = NULL_TREE;
10067   static tree m2_arg_cache = NULL_TREE;
10068
10069   register tree m1_arg, m2_arg;
10070
10071   m1_arg = TYPE_ARG_TYPES (TREE_TYPE (m1));
10072   if (!METHOD_STATIC (m1))
10073     m1_arg = TREE_CHAIN (m1_arg);
10074
10075   if (m2_arg_value == m2_or_arglist)
10076     m2_arg = m2_arg_cache;
10077   else
10078     {
10079       /* M2_OR_ARGLIST can be a function DECL or a raw list of
10080          argument types */
10081       if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
10082         {
10083           m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
10084           if (!METHOD_STATIC (m2_or_arglist))
10085             m2_arg = TREE_CHAIN (m2_arg);
10086         }
10087       else
10088         m2_arg = m2_or_arglist;
10089
10090       m2_arg_value = m2_or_arglist;
10091       m2_arg_cache = m2_arg;
10092     }
10093
10094   while (m1_arg != end_params_node && m2_arg != end_params_node)
10095     {
10096       resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
10097       if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
10098                                                  TREE_VALUE (m2_arg)))
10099         break;
10100       m1_arg = TREE_CHAIN (m1_arg);
10101       m2_arg = TREE_CHAIN (m2_arg);
10102     }
10103   return m1_arg == end_params_node && m2_arg == end_params_node;
10104 }
10105
10106 /* Qualification routines */
10107
10108 static void
10109 qualify_ambiguous_name (id)
10110      tree id;
10111 {
10112   tree qual, qual_wfl, name, decl, ptr_type, saved_current_class;
10113   int again, super_found = 0, this_found = 0, new_array_found = 0;
10114
10115   /* We first qualify the first element, then derive qualification of
10116      others based on the first one. If the first element is qualified
10117      by a resolution (field or type), this resolution is stored in the
10118      QUAL_RESOLUTION of the qual element being examined. We need to
10119      save the current_class since the use of SUPER might change the
10120      its value. */
10121   saved_current_class = current_class;
10122   qual = EXPR_WFL_QUALIFICATION (id);
10123   do {
10124
10125     /* Simple qualified expression feature a qual_wfl that is a
10126        WFL. Expression derived from a primary feature more complicated
10127        things like a CALL_EXPR. Expression from primary need to be
10128        worked out to extract the part on which the qualification will
10129        take place. */
10130     qual_wfl = QUAL_WFL (qual);
10131     switch (TREE_CODE (qual_wfl))
10132       {
10133       case CALL_EXPR:
10134         qual_wfl = TREE_OPERAND (qual_wfl, 0);
10135         if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
10136           {
10137             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
10138             qual_wfl = QUAL_WFL (qual);
10139           }
10140         break;
10141       case NEW_ARRAY_EXPR:
10142         qual = TREE_CHAIN (qual);
10143         new_array_found = again = 1;
10144         continue;
10145       case NEW_CLASS_EXPR:
10146       case CONVERT_EXPR:
10147         qual_wfl = TREE_OPERAND (qual_wfl, 0);
10148         break;
10149       case ARRAY_REF:
10150         while (TREE_CODE (qual_wfl) == ARRAY_REF)
10151           qual_wfl = TREE_OPERAND (qual_wfl, 0);
10152         break;
10153       default:
10154         /* Fix for -Wall. Just break doing nothing */
10155         break;
10156       }
10157     name = EXPR_WFL_NODE (qual_wfl);
10158     ptr_type = current_class;
10159     again = 0;
10160     /* If we have a THIS (from a primary), we set the context accordingly */
10161     if (name == this_identifier_node)
10162       {
10163         qual = TREE_CHAIN (qual);
10164         qual_wfl = QUAL_WFL (qual);
10165         if (TREE_CODE (qual_wfl) == CALL_EXPR)
10166           again = 1;
10167         else
10168           name = EXPR_WFL_NODE (qual_wfl);
10169         this_found = 1;
10170       }
10171     /* If we have a SUPER, we set the context accordingly */
10172     if (name == super_identifier_node)
10173       {
10174         current_class = CLASSTYPE_SUPER (ptr_type);
10175         /* Check that there is such a thing as a super class. If not,
10176            return.  The error will be caught later on, during the
10177            resolution */
10178         if (!current_class)
10179           {
10180             current_class = saved_current_class;
10181             return;
10182           }
10183         qual = TREE_CHAIN (qual);
10184         /* Do one more interation to set things up */
10185         super_found = again = 1;
10186       }
10187     /* Loop one more time if we're dealing with ?: or a string
10188        constant, or a convert expression */
10189     if (TREE_CODE (qual_wfl) == CONDITIONAL_EXPR
10190         || TREE_CODE (qual_wfl) == STRING_CST
10191         || TREE_CODE (qual_wfl) == CONVERT_EXPR)
10192       {
10193         if (TREE_CODE (qual_wfl) == CONVERT_EXPR
10194             && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
10195             name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
10196         else
10197           {
10198             qual = TREE_CHAIN (qual);
10199             qual_wfl = QUAL_WFL (qual);
10200             again = 1;
10201           }
10202       }
10203   } while (again);
10204   
10205   /* If name appears within the scope of a location variable
10206      declaration or parameter declaration, then it is an expression
10207      name. We don't carry this test out if we're in the context of the
10208      use of SUPER or THIS */
10209   if (!this_found && !super_found && (decl = IDENTIFIER_LOCAL_VALUE (name)))
10210     {
10211       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
10212       QUAL_RESOLUTION (qual) = decl;
10213     }
10214
10215   /* If within the class/interface NAME was found to be used there
10216      exists a (possibly inherited) field named NAME, then this is an
10217      expression name. If we saw a NEW_ARRAY_EXPR before and want to
10218      address length, it is OK. */
10219   else if ((decl = lookup_field_wrapper (ptr_type, name))
10220            || (new_array_found && name == length_identifier_node))
10221     {
10222       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
10223       QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
10224     }
10225
10226   /* We reclassify NAME as a type name if:
10227      - NAME is a class/interface declared within the compilation
10228        unit containing NAME,
10229      - NAME is imported via a single-type-import declaration,
10230      - NAME is declared in an another compilation unit of the package
10231        of the compilation unit containing NAME,
10232      - NAME is declared by exactly on type-import-on-demand declaration
10233      of the compilation unit containing NAME. */
10234   else if ((decl = resolve_and_layout (name, NULL_TREE)))
10235     {
10236       RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
10237       QUAL_RESOLUTION (qual) = decl;
10238     }
10239
10240   /* Method call are expression name */
10241   else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
10242            || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF)
10243     RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
10244
10245   /* Check here that NAME isn't declared by more than one
10246      type-import-on-demand declaration of the compilation unit
10247      containing NAME. FIXME */
10248
10249   /* Otherwise, NAME is reclassified as a package name */
10250   else 
10251     RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
10252
10253   /* Propagate the qualification accross other components of the
10254      qualified name */
10255   for (qual = TREE_CHAIN (qual); qual;
10256        qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
10257     {
10258       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
10259         RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
10260       else 
10261         RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
10262     }
10263
10264   /* Store the global qualification for the ambiguous part of ID back
10265      into ID fields */
10266   if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
10267     RESOLVE_EXPRESSION_NAME_P (id) = 1;
10268   else if (RESOLVE_TYPE_NAME_P (qual_wfl))
10269     RESOLVE_TYPE_NAME_P (id) = 1;
10270   else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
10271     RESOLVE_PACKAGE_NAME_P (id) = 1;
10272
10273   /* Restore the current class */
10274   current_class = saved_current_class;
10275 }
10276
10277 static int
10278 breakdown_qualified (left, right, source)
10279     tree *left, *right, source;
10280 {
10281   char *p = IDENTIFIER_POINTER (source), *base;
10282   int   l = IDENTIFIER_LENGTH (source);
10283
10284   /* Breakdown NAME into REMAINDER . IDENTIFIER */
10285   base = p;
10286   p += (l-1);
10287   while (*p != '.' && p != base)
10288     p--;
10289
10290   /* We didn't find a '.'. Return an error */
10291   if (p == base)
10292     return 1;
10293
10294   *p = '\0';
10295   if (right)
10296     *right = get_identifier (p+1);
10297   *left = get_identifier (IDENTIFIER_POINTER (source));
10298   *p = '.';
10299   
10300   return 0;
10301 }
10302
10303 /* Patch tree nodes in a function body. When a BLOCK is found, push
10304    local variable decls if present.
10305    Same as java_complete_lhs, but does resolve static finals to values. */
10306
10307 static tree
10308 java_complete_tree (node)
10309      tree node;
10310 {
10311   node = java_complete_lhs (node);
10312   if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
10313       && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
10314       && !flag_emit_xref)
10315     {
10316       tree value = DECL_INITIAL (node);
10317       DECL_INITIAL (node) = NULL_TREE;
10318       value = fold_constant_for_init (value, node);
10319       DECL_INITIAL (node) = value;
10320       if (value != NULL_TREE)
10321         return value;
10322     }
10323   return node;
10324 }
10325
10326 static tree
10327 java_stabilize_reference (node)
10328      tree node;
10329 {
10330   if (TREE_CODE (node) == COMPOUND_EXPR)
10331     {
10332       tree op0 = TREE_OPERAND (node, 0);
10333       tree op1 = TREE_OPERAND (node, 1);
10334       TREE_OPERAND (node, 0) = save_expr (op0);
10335       TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
10336       return node;
10337     }
10338   else
10339     return stabilize_reference (node);
10340 }
10341
10342 /* Patch tree nodes in a function body. When a BLOCK is found, push
10343    local variable decls if present.
10344    Same as java_complete_tree, but does not resolve static finals to values. */
10345
10346 static tree
10347 java_complete_lhs (node)
10348      tree node;
10349 {
10350   tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
10351   int flag;
10352
10353   /* CONVERT_EXPR always has its type set, even though it needs to be
10354      worked out. */
10355   if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
10356     return node;
10357
10358   /* The switch block implements cases processing container nodes
10359      first.  Contained nodes are always written back. Leaves come
10360      next and return a value. */
10361   switch (TREE_CODE (node))
10362     {
10363     case BLOCK:
10364
10365       /* 1- Block section.
10366          Set the local values on decl names so we can identify them
10367          faster when they're referenced. At that stage, identifiers
10368          are legal so we don't check for declaration errors. */
10369       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
10370         {
10371           DECL_CONTEXT (cn) = current_function_decl;
10372           IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
10373         }
10374       if (BLOCK_EXPR_BODY (node) == NULL_TREE)
10375           CAN_COMPLETE_NORMALLY (node) = 1;
10376       else
10377         {
10378           tree stmt = BLOCK_EXPR_BODY (node);
10379           tree *ptr;
10380           int error_seen = 0;
10381           if (TREE_CODE (stmt) == COMPOUND_EXPR)
10382             {
10383               /* Re-order from (((A; B); C); ...; Z) to 
10384                  (A; (B; (C ; (...; Z)))).
10385                  This makes it easier to scan the statements left-to-right
10386                  without using recursion (which might overflow the stack
10387                  if the block has many statements. */
10388               for (;;)
10389                 {
10390                   tree left = TREE_OPERAND (stmt, 0);
10391                   if (TREE_CODE (left) != COMPOUND_EXPR)
10392                     break;
10393                   TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
10394                   TREE_OPERAND (left, 1) = stmt;
10395                   stmt = left;
10396                 }
10397               BLOCK_EXPR_BODY (node) = stmt;
10398             }
10399
10400           /* Now do the actual complete, without deep recursion for
10401              long blocks. */
10402           ptr = &BLOCK_EXPR_BODY (node);
10403           while (TREE_CODE (*ptr) == COMPOUND_EXPR
10404                  && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
10405             {
10406               tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
10407               tree *next = &TREE_OPERAND (*ptr, 1);
10408               TREE_OPERAND (*ptr, 0) = cur;
10409               if (cur == empty_stmt_node)
10410                 {
10411                   /* Optimization;  makes it easier to detect empty bodies.
10412                      Most useful for <clinit> with all-constant initializer. */
10413                   *ptr = *next;
10414                   continue;
10415                 }
10416               if (TREE_CODE (cur) == ERROR_MARK)
10417                 error_seen++;
10418               else if (! CAN_COMPLETE_NORMALLY (cur))
10419                 {
10420                   wfl_op2 = *next;
10421                   for (;;)
10422                     {
10423                       if (TREE_CODE (wfl_op2) == BLOCK)
10424                         wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
10425                       else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
10426                         wfl_op2 = TREE_OPERAND (wfl_op2, 0);
10427                       else
10428                         break;
10429                     }
10430                   if (TREE_CODE (wfl_op2) != CASE_EXPR
10431                       && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
10432                     unreachable_stmt_error (*ptr);
10433                 }
10434               ptr = next;
10435             }
10436           *ptr = java_complete_tree (*ptr);
10437
10438           if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
10439             return error_mark_node;
10440           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
10441         }
10442       /* Turn local bindings to null */
10443       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
10444         IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
10445
10446       TREE_TYPE (node) = void_type_node;
10447       break;
10448
10449       /* 2- They are expressions but ultimately deal with statements */
10450
10451     case THROW_EXPR:
10452       wfl_op1 = TREE_OPERAND (node, 0);
10453       COMPLETE_CHECK_OP_0 (node);
10454       /* CAN_COMPLETE_NORMALLY (node) = 0; */
10455       return patch_throw_statement (node, wfl_op1);
10456
10457     case SYNCHRONIZED_EXPR:
10458       wfl_op1 = TREE_OPERAND (node, 0);
10459       return patch_synchronized_statement (node, wfl_op1);
10460
10461     case TRY_EXPR:
10462       return patch_try_statement (node);
10463
10464     case TRY_FINALLY_EXPR:
10465       COMPLETE_CHECK_OP_0 (node);
10466       COMPLETE_CHECK_OP_1 (node);
10467       CAN_COMPLETE_NORMALLY (node)
10468         = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
10469            && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
10470       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
10471       return node;
10472
10473     case CLEANUP_POINT_EXPR:
10474       COMPLETE_CHECK_OP_0 (node);
10475       TREE_TYPE (node) = void_type_node;
10476       CAN_COMPLETE_NORMALLY (node) = 
10477         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
10478       return node;
10479
10480     case WITH_CLEANUP_EXPR:
10481       COMPLETE_CHECK_OP_0 (node);
10482       COMPLETE_CHECK_OP_2 (node);
10483       CAN_COMPLETE_NORMALLY (node) = 
10484         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
10485       TREE_TYPE (node) = void_type_node;
10486       return node;
10487
10488     case LABELED_BLOCK_EXPR:
10489       PUSH_LABELED_BLOCK (node);
10490       if (LABELED_BLOCK_BODY (node))
10491         COMPLETE_CHECK_OP_1 (node);
10492       TREE_TYPE (node) = void_type_node;
10493       POP_LABELED_BLOCK ();
10494
10495       if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
10496         {
10497           LABELED_BLOCK_BODY (node) = NULL_TREE;
10498           CAN_COMPLETE_NORMALLY (node) = 1;
10499         }
10500       else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
10501         CAN_COMPLETE_NORMALLY (node) = 1;
10502       return node;
10503
10504     case EXIT_BLOCK_EXPR:
10505       /* We don't complete operand 1, because it's the return value of
10506          the EXIT_BLOCK_EXPR which doesn't exist it Java */
10507       return patch_bc_statement (node);
10508
10509     case CASE_EXPR:
10510       cn = java_complete_tree (TREE_OPERAND (node, 0));
10511       if (cn == error_mark_node)
10512         return cn;
10513
10514       /* First, the case expression must be constant */
10515       cn = fold (cn);
10516
10517       if (!TREE_CONSTANT (cn) && !flag_emit_xref)
10518         {
10519           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10520           parse_error_context (node, "Constant expression required");
10521           return error_mark_node;
10522         }
10523
10524       nn = ctxp->current_loop;
10525
10526       /* It must be assignable to the type of the switch expression. */
10527       if (!try_builtin_assignconv (NULL_TREE, 
10528                                    TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
10529         {
10530           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10531           parse_error_context 
10532             (wfl_operator,
10533              "Incompatible type for case. Can't convert `%s' to `int'",
10534              lang_printable_name (TREE_TYPE (cn), 0));
10535           return error_mark_node;
10536         }
10537
10538       cn = fold (convert (int_type_node, cn));
10539
10540       /* Multiple instance of a case label bearing the same
10541          value is checked during code generation. The case
10542          expression is allright so far. */
10543       TREE_OPERAND (node, 0) = cn;
10544       TREE_TYPE (node) = void_type_node;
10545       CAN_COMPLETE_NORMALLY (node) = 1;
10546       TREE_SIDE_EFFECTS (node) = 1;
10547       break;
10548
10549     case DEFAULT_EXPR:
10550       nn = ctxp->current_loop;
10551       /* Only one default label is allowed per switch statement */
10552       if (SWITCH_HAS_DEFAULT (nn))
10553         {
10554           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10555           parse_error_context (wfl_operator, 
10556                                "Duplicate case label: `default'");
10557           return error_mark_node;
10558         }
10559       else
10560         SWITCH_HAS_DEFAULT (nn) = 1;
10561       TREE_TYPE (node) = void_type_node;
10562       TREE_SIDE_EFFECTS (node) = 1;
10563       CAN_COMPLETE_NORMALLY (node) = 1;
10564       break;
10565
10566     case SWITCH_EXPR:
10567     case LOOP_EXPR:
10568       PUSH_LOOP (node);
10569       /* Check whether the loop was enclosed in a labeled
10570          statement. If not, create one, insert the loop in it and
10571          return the node */
10572       nn = patch_loop_statement (node);
10573
10574       /* Anyways, walk the body of the loop */
10575       if (TREE_CODE (node) == LOOP_EXPR)
10576         TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10577       /* Switch statement: walk the switch expression and the cases */
10578       else
10579         node = patch_switch_statement (node);
10580
10581       if (TREE_OPERAND (node, 0) == error_mark_node)
10582         nn = error_mark_node;
10583       else
10584         {
10585           TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
10586           /* If we returned something different, that's because we
10587              inserted a label. Pop the label too. */
10588           if (nn != node)
10589             {
10590               if (CAN_COMPLETE_NORMALLY (node))
10591                 CAN_COMPLETE_NORMALLY (nn) = 1;
10592               POP_LABELED_BLOCK ();
10593             }
10594         }
10595       POP_LOOP ();
10596       return nn;
10597
10598     case EXIT_EXPR:
10599       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10600       return patch_exit_expr (node);
10601
10602     case COND_EXPR:
10603       /* Condition */
10604       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10605       if (TREE_OPERAND (node, 0) == error_mark_node)
10606         return error_mark_node;
10607       /* then-else branches */
10608       TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
10609       if (TREE_OPERAND (node, 1) == error_mark_node)
10610         return error_mark_node;
10611       TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
10612       if (TREE_OPERAND (node, 2) == error_mark_node)
10613         return error_mark_node;
10614       return patch_if_else_statement (node);
10615       break;
10616
10617     case CONDITIONAL_EXPR:
10618       /* Condition */
10619       wfl_op1 = TREE_OPERAND (node, 0);
10620       COMPLETE_CHECK_OP_0 (node);
10621       wfl_op2 = TREE_OPERAND (node, 1);
10622       COMPLETE_CHECK_OP_1 (node);
10623       wfl_op3 = TREE_OPERAND (node, 2);
10624       COMPLETE_CHECK_OP_2 (node);
10625       return patch_conditional_expr (node, wfl_op1, wfl_op2);
10626
10627       /* 3- Expression section */
10628     case COMPOUND_EXPR:
10629       wfl_op2 = TREE_OPERAND (node, 1);
10630       TREE_OPERAND (node, 0) = nn = 
10631         java_complete_tree (TREE_OPERAND (node, 0));
10632       if (wfl_op2 == empty_stmt_node)
10633         CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
10634       else
10635         {
10636           if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
10637             {
10638               /* An unreachable condition in a do-while statement
10639                  is *not* (technically) an unreachable statement. */
10640               nn = wfl_op2;
10641               if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
10642                 nn = EXPR_WFL_NODE (nn);
10643               if (TREE_CODE (nn) != EXIT_EXPR)
10644                 {
10645                   SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
10646                   parse_error_context (wfl_operator, "Unreachable statement");
10647                 }
10648             }
10649           TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
10650           if (TREE_OPERAND (node, 1) == error_mark_node)
10651             return error_mark_node;
10652           CAN_COMPLETE_NORMALLY (node)
10653             = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
10654         }
10655       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
10656       break;
10657
10658     case RETURN_EXPR:
10659       /* CAN_COMPLETE_NORMALLY (node) = 0; */
10660       return patch_return (node);
10661
10662     case EXPR_WITH_FILE_LOCATION:
10663       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
10664           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
10665         {
10666           tree wfl = node;
10667           node = resolve_expression_name (node, NULL);
10668           if (node == error_mark_node)
10669             return node;
10670           /* Keep line number information somewhere were it doesn't
10671              disrupt the completion process. */
10672           if (flag_emit_xref)
10673             {
10674               EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
10675               TREE_OPERAND (node, 1) = wfl;
10676             }
10677           CAN_COMPLETE_NORMALLY (node) = 1;
10678         }
10679       else
10680         {
10681           tree body;
10682           int save_lineno = lineno;
10683           lineno = EXPR_WFL_LINENO (node);
10684           body = java_complete_tree (EXPR_WFL_NODE (node));
10685           lineno = save_lineno;
10686           EXPR_WFL_NODE (node) = body;
10687           TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
10688           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
10689           if (body == empty_stmt_node)
10690             {
10691               /* Optimization;  makes it easier to detect empty bodies. */
10692               return body;
10693             }
10694           if (body == error_mark_node)
10695             {
10696               /* Its important for the evaluation of assignment that
10697                  this mark on the TREE_TYPE is propagated. */
10698               TREE_TYPE (node) = error_mark_node;
10699               return error_mark_node;
10700             }
10701           else
10702             TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
10703           
10704         }
10705       break;
10706
10707     case NEW_ARRAY_EXPR:
10708       /* Patch all the dimensions */
10709       flag = 0;
10710       for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
10711         {
10712           int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
10713           tree dim = java_complete_tree (TREE_VALUE (cn));
10714           if (dim == error_mark_node)
10715             {
10716               flag = 1;
10717               continue;
10718             }
10719           else
10720             {
10721               TREE_VALUE (cn) = dim;
10722               /* Setup the location of the current dimension, for
10723                  later error report. */
10724               TREE_PURPOSE (cn) = 
10725                 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
10726               EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
10727             }
10728         }
10729       /* They complete the array creation expression, if no errors
10730          were found. */
10731       CAN_COMPLETE_NORMALLY (node) = 1;
10732       return (flag ? error_mark_node
10733               : force_evaluation_order (patch_newarray (node)));
10734
10735     case NEW_CLASS_EXPR:
10736     case CALL_EXPR:
10737       /* Complete function's argument(s) first */
10738       if (complete_function_arguments (node))
10739         return error_mark_node;
10740       else
10741         {
10742           tree decl, wfl = TREE_OPERAND (node, 0);
10743           int in_this = CALL_THIS_CONSTRUCTOR_P (node);
10744
10745           node = patch_method_invocation (node, NULL_TREE, 
10746                                           NULL_TREE, 0, &decl);
10747           if (node == error_mark_node)
10748             return error_mark_node;
10749
10750           check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
10751           /* If we call this(...), register signature and positions */
10752           if (in_this)
10753             DECL_CONSTRUCTOR_CALLS (current_function_decl) = 
10754               tree_cons (wfl, decl, 
10755                          DECL_CONSTRUCTOR_CALLS (current_function_decl));
10756           CAN_COMPLETE_NORMALLY (node) = 1;
10757           return force_evaluation_order (node);
10758         }
10759
10760     case MODIFY_EXPR:
10761       /* Save potential wfls */
10762       wfl_op1 = TREE_OPERAND (node, 0);
10763       TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
10764       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
10765           && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
10766           && DECL_INITIAL (nn) != NULL_TREE)
10767         {
10768           tree value = fold_constant_for_init (nn, nn);
10769           if (value != NULL_TREE)
10770             {
10771               tree type = TREE_TYPE (value);
10772               if (JPRIMITIVE_TYPE_P (type) || type == string_ptr_type_node)
10773                 return empty_stmt_node;
10774             }
10775           DECL_INITIAL (nn) = NULL_TREE;
10776         }
10777       wfl_op2 = TREE_OPERAND (node, 1);
10778
10779       if (TREE_OPERAND (node, 0) == error_mark_node)
10780         return error_mark_node;
10781
10782       if (COMPOUND_ASSIGN_P (wfl_op2))
10783         {
10784           tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0)); 
10785
10786           /* Hand stablize the lhs on both places */
10787           TREE_OPERAND (node, 0) = lvalue;
10788           TREE_OPERAND (TREE_OPERAND (node, 1), 0) = lvalue;
10789
10790           /* Now complete the RHS. We write it back later on. */
10791           nn = java_complete_tree (TREE_OPERAND (node, 1));
10792
10793           if ((cn = patch_string (nn)))
10794             nn = cn;
10795
10796           /* The last part of the rewrite for E1 op= E2 is to have 
10797              E1 = (T)(E1 op E2), with T being the type of E1. */
10798           nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2), 
10799                                                TREE_TYPE (lvalue), nn));
10800         }
10801
10802       /* If we're about to patch a NEW_ARRAY_INIT, we call a special
10803          function to complete this RHS */
10804       else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT)
10805         nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
10806                                    TREE_OPERAND (node, 1));
10807       /* Otherwise we simply complete the RHS */
10808       else
10809         nn = java_complete_tree (TREE_OPERAND (node, 1));
10810
10811       if (nn == error_mark_node)
10812         return error_mark_node;
10813
10814       /* Write back the RHS as we evaluated it. */
10815       TREE_OPERAND (node, 1) = nn;
10816
10817       /* In case we're handling = with a String as a RHS, we need to
10818          produce a String out of the RHS (it might still be a
10819          STRING_CST or a StringBuffer at this stage */
10820       if ((nn = patch_string (TREE_OPERAND (node, 1))))
10821         TREE_OPERAND (node, 1) = nn;
10822       node = patch_assignment (node, wfl_op1, wfl_op2);
10823       CAN_COMPLETE_NORMALLY (node) = 1;
10824       return node;
10825
10826     case MULT_EXPR:
10827     case PLUS_EXPR:
10828     case MINUS_EXPR:
10829     case LSHIFT_EXPR:
10830     case RSHIFT_EXPR:
10831     case URSHIFT_EXPR:
10832     case BIT_AND_EXPR:
10833     case BIT_XOR_EXPR:
10834     case BIT_IOR_EXPR:
10835     case TRUNC_MOD_EXPR:
10836     case RDIV_EXPR:
10837     case TRUTH_ANDIF_EXPR:
10838     case TRUTH_ORIF_EXPR:
10839     case EQ_EXPR: 
10840     case NE_EXPR:
10841     case GT_EXPR:
10842     case GE_EXPR:
10843     case LT_EXPR:
10844     case LE_EXPR:
10845       /* Operands 0 and 1 are WFL in certain cases only. patch_binop
10846          knows how to handle those cases. */
10847       wfl_op1 = TREE_OPERAND (node, 0);
10848       wfl_op2 = TREE_OPERAND (node, 1);
10849
10850       CAN_COMPLETE_NORMALLY (node) = 1;
10851       /* Don't complete string nodes if dealing with the PLUS operand. */
10852       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
10853         {
10854           nn = java_complete_tree (wfl_op1);
10855           if (nn == error_mark_node)
10856             return error_mark_node;
10857           if ((cn = patch_string (nn)))
10858             nn = cn;
10859           TREE_OPERAND (node, 0) = nn;
10860         }
10861       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
10862         {
10863           nn = java_complete_tree (wfl_op2);
10864           if (nn == error_mark_node)
10865             return error_mark_node;
10866           if ((cn = patch_string (nn)))
10867             nn = cn;
10868           TREE_OPERAND (node, 1) = nn;
10869         }
10870       return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
10871
10872     case INSTANCEOF_EXPR:
10873       wfl_op1 = TREE_OPERAND (node, 0);
10874       COMPLETE_CHECK_OP_0 (node);
10875       if (flag_emit_xref)
10876         {
10877           TREE_TYPE (node) = boolean_type_node;
10878           return node;
10879         }
10880       return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
10881
10882     case UNARY_PLUS_EXPR:
10883     case NEGATE_EXPR:
10884     case TRUTH_NOT_EXPR:
10885     case BIT_NOT_EXPR:
10886     case PREDECREMENT_EXPR:
10887     case PREINCREMENT_EXPR:
10888     case POSTDECREMENT_EXPR:
10889     case POSTINCREMENT_EXPR:
10890     case CONVERT_EXPR:
10891       /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
10892          how to handle those cases. */
10893       wfl_op1 = TREE_OPERAND (node, 0);
10894       CAN_COMPLETE_NORMALLY (node) = 1;
10895       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
10896       if (TREE_OPERAND (node, 0) == error_mark_node)
10897         return error_mark_node;
10898       node = patch_unaryop (node, wfl_op1);
10899       CAN_COMPLETE_NORMALLY (node) = 1;
10900       break;
10901
10902     case ARRAY_REF:
10903       /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
10904          how to handle those cases. */
10905       wfl_op1 = TREE_OPERAND (node, 0);
10906       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
10907       if (TREE_OPERAND (node, 0) == error_mark_node)
10908         return error_mark_node;
10909       if (!flag_emit_class_files && !flag_emit_xref)
10910         TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
10911       /* The same applies to wfl_op2 */
10912       wfl_op2 = TREE_OPERAND (node, 1);
10913       TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
10914       if (TREE_OPERAND (node, 1) == error_mark_node)
10915         return error_mark_node;
10916       if (!flag_emit_class_files && !flag_emit_xref)
10917         TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
10918       return patch_array_ref (node);
10919
10920     case RECORD_TYPE:
10921       return node;;
10922
10923     case COMPONENT_REF:
10924       /* The first step in the re-write of qualified name handling.  FIXME.
10925          So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
10926       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10927       if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
10928         {
10929           tree name = TREE_OPERAND (node, 1);
10930           tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
10931           if (field == NULL_TREE)
10932             {
10933               error ("missing static field `%s'", IDENTIFIER_POINTER (name));
10934               return error_mark_node;
10935             }
10936           if (! FIELD_STATIC (field))
10937             {
10938               error ("not a static field `%s'", IDENTIFIER_POINTER (name));
10939               return error_mark_node;
10940             }
10941           return field;
10942         }
10943       else
10944         fatal ("unimplemented java_complete_tree for COMPONENT_REF");
10945       break;
10946
10947     case THIS_EXPR:
10948       /* Can't use THIS in a static environment */
10949       if (!current_this)
10950         {
10951           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10952           parse_error_context (wfl_operator, "Keyword `this' used outside "
10953                                "allowed context");
10954           TREE_TYPE (node) = error_mark_node;
10955           return error_mark_node;
10956         }
10957       if (ctxp->explicit_constructor_p)
10958         {
10959           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10960           parse_error_context 
10961             (wfl_operator, "Can't reference `this' or `super' before the "
10962              "superclass constructor has been called");
10963           TREE_TYPE (node) = error_mark_node;
10964           return error_mark_node;
10965         }
10966       return current_this;
10967
10968     default:
10969       CAN_COMPLETE_NORMALLY (node) = 1;
10970       /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
10971          and it's time to turn it into the appropriate String object
10972          */
10973       if ((node = patch_string (node)))
10974         return node;
10975       fatal ("No case for tree code `%s' - java_complete_tree\n",
10976              tree_code_name [TREE_CODE (node)]);
10977     }
10978   return node;
10979 }
10980
10981 /* Complete function call's argument. Return a non zero value is an
10982    error was found.  */
10983
10984 static int
10985 complete_function_arguments (node)
10986      tree node;
10987 {
10988   int flag = 0;
10989   tree cn;
10990
10991   ctxp->explicit_constructor_p += (CALL_THIS_CONSTRUCTOR_P (node) ? 1 : 0);
10992   for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
10993     {
10994       tree wfl = TREE_VALUE (cn), parm, temp;
10995       parm = java_complete_tree (wfl);
10996       if (parm == error_mark_node)
10997         {
10998           flag = 1;
10999           continue;
11000         }
11001       /* If have a string literal that we haven't transformed yet or a
11002          crafted string buffer, as a result of use of the the String
11003          `+' operator. Build `parm.toString()' and expand it. */
11004       if ((temp = patch_string (parm)))
11005         parm = temp;
11006       /* Inline PRIMTYPE.TYPE read access */
11007       parm = maybe_build_primttype_type_ref (parm, wfl);
11008
11009       TREE_VALUE (cn) = parm;
11010     }
11011   ctxp->explicit_constructor_p -= (CALL_THIS_CONSTRUCTOR_P (node) ? 1 : 0);
11012   return flag;
11013 }
11014
11015 /* Sometimes (for loops and variable initialized during their
11016    declaration), we want to wrap a statement around a WFL and turn it
11017    debugable.  */
11018
11019 static tree
11020 build_debugable_stmt (location, stmt)
11021     int location;
11022     tree stmt;
11023 {
11024   if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
11025     {
11026       stmt = build_expr_wfl (stmt, input_filename, 0, 0);
11027       EXPR_WFL_LINECOL (stmt) = location;
11028     }
11029   JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
11030   return stmt;
11031 }
11032
11033 static tree
11034 build_expr_block (body, decls)
11035      tree body, decls;
11036 {
11037   tree node = make_node (BLOCK);
11038   BLOCK_EXPR_DECLS (node) = decls;
11039   BLOCK_EXPR_BODY (node) = body;
11040   if (body)
11041     TREE_TYPE (node) = TREE_TYPE (body);
11042   TREE_SIDE_EFFECTS (node) = 1;
11043   return node;
11044 }
11045
11046 /* Create a new function block and link it approriately to current
11047    function block chain */
11048
11049 static tree
11050 enter_block ()
11051 {
11052   return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
11053 }
11054
11055 /* Link block B supercontext to the previous block. The current
11056    function DECL is used as supercontext when enter_a_block is called
11057    for the first time for a given function. The current function body
11058    (DECL_FUNCTION_BODY) is set to be block B.  */
11059
11060 static tree
11061 enter_a_block (b)
11062      tree b;
11063 {
11064   tree fndecl = current_function_decl; 
11065
11066   if (!fndecl) {
11067     BLOCK_SUPERCONTEXT (b) = current_static_block;
11068     current_static_block = b;
11069   }
11070
11071   else if (!DECL_FUNCTION_BODY (fndecl))
11072     {
11073       BLOCK_SUPERCONTEXT (b) = fndecl;
11074       DECL_FUNCTION_BODY (fndecl) = b;
11075     }
11076   else
11077     {
11078       BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
11079       DECL_FUNCTION_BODY (fndecl) = b;
11080     }
11081   return b;
11082 }
11083
11084 /* Exit a block by changing the current function body
11085    (DECL_FUNCTION_BODY) to the current block super context, only if
11086    the block being exited isn't the method's top level one.  */
11087
11088 static tree
11089 exit_block ()
11090 {
11091   tree b;
11092   if (current_function_decl)
11093     {
11094       b = DECL_FUNCTION_BODY (current_function_decl);
11095       if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
11096         DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
11097     }
11098   else
11099     {
11100       b = current_static_block;
11101
11102       if (BLOCK_SUPERCONTEXT (b))
11103         current_static_block = BLOCK_SUPERCONTEXT (b);
11104     }
11105   return b;
11106 }
11107
11108 /* Lookup for NAME in the nested function's blocks, all the way up to
11109    the current toplevel one. It complies with Java's local variable
11110    scoping rules.  */
11111
11112 static tree
11113 lookup_name_in_blocks (name)
11114      tree name;
11115 {
11116   tree b = GET_CURRENT_BLOCK (current_function_decl);
11117
11118   while (b != current_function_decl)
11119     {
11120       tree current;
11121
11122       /* Paranoid sanity check. To be removed */
11123       if (TREE_CODE (b) != BLOCK)
11124         fatal ("non block expr function body - lookup_name_in_blocks");
11125
11126       for (current = BLOCK_EXPR_DECLS (b); current; 
11127            current = TREE_CHAIN (current))
11128         if (DECL_NAME (current) == name)
11129           return current;
11130       b = BLOCK_SUPERCONTEXT (b);
11131     }
11132   return NULL_TREE;
11133 }
11134
11135 static void
11136 maybe_absorb_scoping_blocks ()
11137 {
11138   while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
11139     {
11140       tree b = exit_block ();
11141       java_method_add_stmt (current_function_decl, b);
11142       SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
11143     }
11144 }
11145
11146 \f
11147 /* This section of the source is reserved to build_* functions that
11148    are building incomplete tree nodes and the patch_* functions that
11149    are completing them.  */
11150
11151 /* Build a super() constructor invocation. Returns empty_stmt_node if
11152    we're currently dealing with the class java.lang.Object. */
11153
11154 static tree
11155 build_super_invocation ()
11156 {
11157   if (current_class == object_type_node)
11158     return empty_stmt_node;
11159   else
11160     {
11161       tree super_wfl = build_wfl_node (super_identifier_node);
11162       return build_method_invocation (super_wfl, NULL_TREE);
11163     }
11164 }
11165
11166 /* Build a SUPER/THIS qualified method invocation.  */
11167
11168 static tree
11169 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
11170      int use_this;
11171      tree name, args;
11172      int lloc, rloc;
11173
11174 {
11175   tree invok;
11176   tree wfl = 
11177     build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
11178   EXPR_WFL_LINECOL (wfl) = lloc;
11179   invok = build_method_invocation (name, args);
11180   return make_qualified_primary (wfl, invok, rloc);
11181 }
11182
11183 /* Build an incomplete CALL_EXPR node. */
11184
11185 static tree
11186 build_method_invocation (name, args)
11187     tree name;
11188     tree args;
11189 {
11190   tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
11191   TREE_SIDE_EFFECTS (call) = 1;
11192   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
11193   return call;
11194 }
11195
11196 /* Build an incomplete new xxx(...) node. */
11197
11198 static tree
11199 build_new_invocation (name, args)
11200     tree name, args;
11201 {
11202   tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
11203   TREE_SIDE_EFFECTS (call) = 1;
11204   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
11205   return call;
11206 }
11207
11208 /* Build an incomplete assignment expression. */
11209
11210 static tree
11211 build_assignment (op, op_location, lhs, rhs)
11212      int op, op_location;
11213      tree lhs, rhs;
11214 {
11215   tree assignment;
11216   /* Build the corresponding binop if we deal with a Compound
11217      Assignment operator. Mark the binop sub-tree as part of a
11218      Compound Assignment expression */
11219   if (op != ASSIGN_TK)
11220     {
11221       rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
11222       COMPOUND_ASSIGN_P (rhs) = 1;
11223     }
11224   assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
11225   TREE_SIDE_EFFECTS (assignment) = 1;
11226   EXPR_WFL_LINECOL (assignment) = op_location;
11227   return assignment;
11228 }
11229
11230 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
11231
11232 char *
11233 print_int_node (node)
11234     tree node;
11235 {
11236   static char buffer [80];
11237   if (TREE_CONSTANT_OVERFLOW (node))
11238     sprintf (buffer, "<overflow>");
11239     
11240   if (TREE_INT_CST_HIGH (node) == 0)
11241     sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
11242              TREE_INT_CST_LOW (node));
11243   else if (TREE_INT_CST_HIGH (node) == -1
11244            && TREE_INT_CST_LOW (node) != 0)
11245     {
11246       buffer [0] = '-';
11247       sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
11248                -TREE_INT_CST_LOW (node));
11249     }
11250   else
11251     sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
11252              TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
11253
11254   return buffer;
11255 }
11256
11257 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
11258    context.  */
11259
11260 static int
11261 check_final_assignment (lvalue, wfl)
11262      tree lvalue, wfl;
11263 {
11264   if (JDECL_P (lvalue) 
11265       && FIELD_FINAL (lvalue) && !IS_CLINIT (current_function_decl))
11266     {
11267       parse_error_context 
11268         (wfl, "Can't assign a value to the final variable `%s'",
11269          IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11270       return 1;
11271     }
11272   return 0;
11273 }
11274
11275 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
11276    read. This is needed to avoid circularities in the implementation
11277    of these fields in libjava. */
11278
11279 static tree
11280 maybe_build_primttype_type_ref (rhs, wfl)
11281     tree rhs, wfl;
11282 {
11283   tree to_return = NULL_TREE;
11284   tree rhs_type = TREE_TYPE (rhs);
11285   if (TREE_CODE (rhs) == COMPOUND_EXPR)
11286     {
11287       tree n = TREE_OPERAND (rhs, 1);
11288       if (TREE_CODE (n) == VAR_DECL 
11289           && DECL_NAME (n) == TYPE_identifier_node
11290           && rhs_type == class_ptr_type)
11291         {
11292           char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
11293           if (!strncmp (self_name, "java.lang.", 10))
11294             to_return = build_primtype_type_ref (self_name);
11295         }
11296     }
11297   return (to_return ? to_return : rhs );
11298 }
11299
11300 /* 15.25 Assignment operators. */
11301
11302 static tree
11303 patch_assignment (node, wfl_op1, wfl_op2)
11304      tree node;
11305      tree wfl_op1;
11306      tree wfl_op2;
11307 {
11308   tree rhs = TREE_OPERAND (node, 1);
11309   tree lvalue = TREE_OPERAND (node, 0), llvalue;
11310   tree lhs_type, rhs_type, new_rhs = NULL_TREE;
11311   int error_found = 0;
11312   int lvalue_from_array = 0;
11313
11314   /* Can't assign to a final. */
11315   if (check_final_assignment (lvalue, wfl_op1))
11316     error_found = 1;
11317
11318   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
11319
11320   /* Lhs can be a named variable */
11321   if (JDECL_P (lvalue))
11322     {
11323       lhs_type = TREE_TYPE (lvalue);
11324     }
11325   /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
11326      comment on reason why */
11327   else if (TREE_CODE (wfl_op1) == ARRAY_REF)
11328     {
11329       lhs_type = TREE_TYPE (lvalue);
11330       lvalue_from_array = 1;
11331     }
11332   /* Or a field access */
11333   else if (TREE_CODE (lvalue) == COMPONENT_REF)
11334     lhs_type = TREE_TYPE (lvalue);
11335   /* Or a function return slot */
11336   else if (TREE_CODE (lvalue) == RESULT_DECL)
11337     lhs_type = TREE_TYPE (lvalue);
11338   /* Otherwise, we might want to try to write into an optimized static
11339      final, this is an of a different nature, reported further on. */
11340   else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
11341            && resolve_expression_name (wfl_op1, &llvalue))
11342     {
11343       if (check_final_assignment (llvalue, wfl_op1))
11344         {
11345           /* What we should do instead is resetting the all the flags
11346              previously set, exchange lvalue for llvalue and continue. */
11347           error_found = 1;
11348           return error_mark_node;
11349         }
11350       else 
11351         lhs_type = TREE_TYPE (lvalue);
11352     }
11353   else 
11354     {
11355       parse_error_context (wfl_op1, "Invalid left hand side of assignment");
11356       error_found = 1;
11357     }
11358
11359   rhs_type = TREE_TYPE (rhs);
11360   /* 5.1 Try the assignment conversion for builtin type. */
11361   new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
11362
11363   /* 5.2 If it failed, try a reference conversion */
11364   if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
11365     lhs_type = promote_type (rhs_type);
11366
11367   /* 15.25.2 If we have a compound assignment, convert RHS into the
11368      type of the LHS */
11369   else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
11370     new_rhs = convert (lhs_type, rhs);
11371
11372   /* Explicit cast required. This is an error */
11373   if (!new_rhs)
11374     {
11375       char *t1 = strdup (lang_printable_name (TREE_TYPE (rhs), 0));
11376       char *t2 = strdup (lang_printable_name (lhs_type, 0));
11377       tree wfl;
11378       char operation [32];      /* Max size known */
11379
11380       /* If the assignment is part of a declaration, we use the WFL of
11381          the declared variable to point out the error and call it a
11382          declaration problem. If the assignment is a genuine =
11383          operator, we call is a operator `=' problem, otherwise we
11384          call it an assignment problem. In both of these last cases,
11385          we use the WFL of the operator to indicate the error. */
11386
11387       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
11388         {
11389           wfl = wfl_op1;
11390           strcpy (operation, "declaration");
11391         }
11392       else
11393         {
11394           wfl = wfl_operator;
11395           if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
11396             strcpy (operation, "assignment");
11397           else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
11398             strcpy (operation, "`return'");
11399           else
11400             strcpy (operation, "`='");
11401         }
11402
11403       parse_error_context 
11404         (wfl, (!valid_cast_to_p (rhs_type, lhs_type) ?
11405                "Incompatible type for %s. Can't convert `%s' to `%s'" :
11406                "Incompatible type for %s. Explicit cast "
11407                "needed to convert `%s' to `%s'"), operation, t1, t2);
11408       free (t1); free (t2);
11409       error_found = 1;
11410     }
11411
11412   /* Inline read access to java.lang.PRIMTYPE.TYPE */
11413   if (new_rhs)
11414     new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
11415
11416   if (error_found)
11417     return error_mark_node;
11418
11419   /* 10.10: Array Store Exception runtime check */
11420   if (!flag_emit_class_files
11421       && !flag_emit_xref
11422       && lvalue_from_array 
11423       && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type))
11424       && !CLASS_FINAL (TYPE_NAME (GET_SKIP_TYPE (rhs_type))))
11425     {
11426       tree check;
11427       tree base = lvalue;
11428
11429       /* We need to retrieve the right argument for _Jv_CheckArrayStore */
11430       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
11431         base = TREE_OPERAND (lvalue, 0);
11432       else
11433         {
11434           if (flag_bounds_check)
11435             base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
11436           else
11437             base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
11438         }
11439
11440       /* Build the invocation of _Jv_CheckArrayStore */
11441       new_rhs = save_expr (new_rhs);
11442       check = build (CALL_EXPR, void_type_node,
11443                      build_address_of (soft_checkarraystore_node),
11444                      tree_cons (NULL_TREE, base,
11445                                 build_tree_list (NULL_TREE, new_rhs)),
11446                      NULL_TREE);
11447       TREE_SIDE_EFFECTS (check) = 1;
11448
11449       /* We have to decide on an insertion point */
11450       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
11451         {
11452           tree t;
11453           if (flag_bounds_check)
11454             {
11455               t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
11456               TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
11457                 build (COMPOUND_EXPR, void_type_node, t, check);
11458             }
11459           else
11460             TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
11461                                               check, TREE_OPERAND (lvalue, 1));
11462         }
11463       else 
11464         {
11465           /* Make sure the bound check will happen before the store check */
11466           if (flag_bounds_check)
11467             TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
11468               build (COMPOUND_EXPR, void_type_node,
11469                      TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
11470           else
11471             lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
11472         }
11473     }
11474
11475   TREE_OPERAND (node, 0) = lvalue;
11476   TREE_OPERAND (node, 1) = new_rhs;
11477   TREE_TYPE (node) = lhs_type;
11478   return node;
11479 }
11480
11481 /* Check that type SOURCE can be cast into type DEST. If the cast
11482    can't occur at all, return 0 otherwise 1. This function is used to
11483    produce accurate error messages on the reasons why an assignment
11484    failed. */
11485
11486 static tree
11487 try_reference_assignconv (lhs_type, rhs)
11488      tree lhs_type, rhs;
11489 {
11490   tree new_rhs = NULL_TREE;
11491   tree rhs_type = TREE_TYPE (rhs);
11492
11493   if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
11494     {
11495       /* `null' may be assigned to any reference type */
11496       if (rhs == null_pointer_node)
11497         new_rhs = null_pointer_node;
11498       /* Try the reference assignment conversion */
11499       else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
11500         new_rhs = rhs;
11501       /* This is a magic assignment that we process differently */
11502       else if (rhs == soft_exceptioninfo_call_node)
11503         new_rhs = rhs;
11504     }
11505   return new_rhs;
11506 }
11507
11508 /* Check that RHS can be converted into LHS_TYPE by the assignment
11509    conversion (5.2), for the cases of RHS being a builtin type. Return
11510    NULL_TREE if the conversion fails or if because RHS isn't of a
11511    builtin type. Return a converted RHS if the conversion is possible.  */
11512
11513 static tree
11514 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
11515      tree wfl_op1, lhs_type, rhs;
11516 {
11517   tree new_rhs = NULL_TREE;
11518   tree rhs_type = TREE_TYPE (rhs);
11519
11520   /* Zero accepted everywhere */
11521   if (TREE_CODE (rhs) == INTEGER_CST 
11522       && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
11523       && JPRIMITIVE_TYPE_P (rhs_type))
11524     new_rhs = convert (lhs_type, rhs);
11525
11526   /* 5.1.1 Try Identity Conversion,
11527      5.1.2 Try Widening Primitive Conversion */
11528   else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
11529     new_rhs = convert (lhs_type, rhs);
11530
11531   /* Try a narrowing primitive conversion (5.1.3): 
11532        - expression is a constant expression of type int AND
11533        - variable is byte, short or char AND
11534        - The value of the expression is representable in the type of the 
11535          variable */
11536   else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
11537            && (lhs_type == byte_type_node || lhs_type == char_type_node
11538                || lhs_type == short_type_node))
11539     {
11540       if (int_fits_type_p (rhs, lhs_type))
11541         new_rhs = convert (lhs_type, rhs);
11542       else if (wfl_op1)         /* Might be called with a NULL */
11543         parse_warning_context 
11544           (wfl_op1, "Constant expression `%s' to wide for narrowing "
11545            "primitive conversion to `%s'", 
11546            print_int_node (rhs), lang_printable_name (lhs_type, 0));
11547       /* Reported a warning that will turn into an error further
11548          down, so we don't return */
11549     }
11550
11551   return new_rhs;
11552 }
11553
11554 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
11555    conversion (5.1.1) or widening primitve conversion (5.1.2).  Return
11556    0 is the conversion test fails.  This implements parts the method
11557    invocation convertion (5.3).  */
11558
11559 static int
11560 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
11561      tree lhs_type, rhs_type;
11562 {
11563   /* 5.1.1: This is the identity conversion part. */
11564   if (lhs_type == rhs_type)
11565     return 1;
11566
11567   /* Reject non primitive types */
11568   if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
11569     return 0;
11570
11571   /* 5.1.2: widening primitive conversion. byte, even if it's smaller
11572      than a char can't be converted into a char. Short can't too, but
11573      the < test below takes care of that */
11574   if (lhs_type == char_type_node && rhs_type == byte_type_node)
11575     return 0;
11576
11577   /* Accept all promoted type here. Note, we can't use <= in the test
11578      below, because we still need to bounce out assignments of short
11579      to char and the likes */
11580   if (lhs_type == int_type_node
11581       && (rhs_type == promoted_byte_type_node
11582           || rhs_type == promoted_short_type_node
11583           || rhs_type == promoted_char_type_node
11584           || rhs_type == promoted_boolean_type_node))
11585     return 1;
11586
11587   /* From here, an integral is widened if its precision is smaller
11588      than the precision of the LHS or if the LHS is a floating point
11589      type, or the RHS is a float and the RHS a double. */
11590   if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type) 
11591        && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
11592       || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
11593       || (rhs_type == float_type_node && lhs_type == double_type_node))
11594     return 1;
11595
11596   return 0;
11597 }
11598
11599 /* Check that something of SOURCE type can be assigned or cast to
11600    something of DEST type at runtime. Return 1 if the operation is
11601    valid, 0 otherwise. If CAST is set to 1, we're treating the case
11602    were SOURCE is cast into DEST, which borrows a lot of the
11603    assignment check. */
11604
11605 static int
11606 valid_ref_assignconv_cast_p (source, dest, cast)
11607      tree source;
11608      tree dest;
11609      int cast;
11610 {
11611   /* SOURCE or DEST might be null if not from a declared entity. */
11612   if (!source || !dest)
11613     return 0;
11614   if (JNULLP_TYPE_P (source))
11615     return 1;
11616   if (TREE_CODE (source) == POINTER_TYPE)
11617     source = TREE_TYPE (source);
11618   if (TREE_CODE (dest) == POINTER_TYPE)
11619     dest = TREE_TYPE (dest);
11620   /* Case where SOURCE is a class type */
11621   if (TYPE_CLASS_P (source))
11622     {
11623       if (TYPE_CLASS_P (dest))
11624         return  source == dest || inherits_from_p (source, dest)
11625           || (cast && inherits_from_p (dest, source));
11626       if (TYPE_INTERFACE_P (dest))
11627         {
11628           /* If doing a cast and SOURCE is final, the operation is
11629              always correct a compile time (because even if SOURCE
11630              does not implement DEST, a subclass of SOURCE might). */
11631           if (cast && !CLASS_FINAL (TYPE_NAME (source)))
11632             return 1;
11633           /* Otherwise, SOURCE must implement DEST */
11634           return interface_of_p (dest, source);
11635         }
11636       /* DEST is an array, cast permited if SOURCE is of Object type */
11637       return (cast && source == object_type_node ? 1 : 0);
11638     }
11639   if (TYPE_INTERFACE_P (source))
11640     {
11641       if (TYPE_CLASS_P (dest))
11642         {
11643           /* If not casting, DEST must be the Object type */
11644           if (!cast)
11645             return dest == object_type_node;
11646           /* We're doing a cast. The cast is always valid is class
11647              DEST is not final, otherwise, DEST must implement SOURCE */
11648           else if (!CLASS_FINAL (TYPE_NAME (dest)))
11649             return 1;
11650           else
11651             return interface_of_p (source, dest);
11652         }
11653       if (TYPE_INTERFACE_P (dest))
11654         {
11655           /* If doing a cast, then if SOURCE and DEST contain method
11656              with the same signature but different return type, then
11657              this is a (compile time) error */
11658           if (cast)
11659             {
11660               tree method_source, method_dest;
11661               tree source_type;
11662               tree source_sig;
11663               tree source_name;
11664               for (method_source = TYPE_METHODS (source); method_source; 
11665                    method_source = TREE_CHAIN (method_source))
11666                 {
11667                   source_sig = 
11668                     build_java_argument_signature (TREE_TYPE (method_source));
11669                   source_type = TREE_TYPE (TREE_TYPE (method_source));
11670                   source_name = DECL_NAME (method_source);
11671                   for (method_dest = TYPE_METHODS (dest);
11672                        method_dest; method_dest = TREE_CHAIN (method_dest))
11673                     if (source_sig == 
11674                         build_java_argument_signature (TREE_TYPE (method_dest))
11675                         && source_name == DECL_NAME (method_dest)
11676                         && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
11677                       return 0;
11678                 }
11679               return 1;
11680             }
11681           else
11682             return source == dest || interface_of_p (dest, source);
11683         }
11684       else                      /* Array */
11685         return (cast ? 
11686                 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
11687     }
11688   if (TYPE_ARRAY_P (source))
11689     {
11690       if (TYPE_CLASS_P (dest))
11691         return dest == object_type_node;
11692       /* Can't cast an array to an interface unless the interface is
11693          java.lang.Cloneable */
11694       if (TYPE_INTERFACE_P (dest))
11695         return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
11696       else                      /* Arrays */
11697         {
11698           tree source_element_type = TYPE_ARRAY_ELEMENT (source);
11699           tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
11700           
11701           /* In case of severe errors, they turn out null */
11702           if (!dest_element_type || !source_element_type)
11703             return 0;
11704           if (source_element_type == dest_element_type)
11705             return 1;
11706           return valid_ref_assignconv_cast_p (source_element_type,
11707                                               dest_element_type, cast);
11708         }
11709       return 0;
11710     }
11711   return 0;
11712 }
11713
11714 static int
11715 valid_cast_to_p (source, dest)
11716      tree source;
11717      tree dest;
11718 {
11719   if (TREE_CODE (source) == POINTER_TYPE)
11720     source = TREE_TYPE (source);
11721   if (TREE_CODE (dest) == POINTER_TYPE)
11722     dest = TREE_TYPE (dest);
11723
11724   if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
11725     return valid_ref_assignconv_cast_p (source, dest, 1);
11726
11727   else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
11728     return 1;
11729
11730   return 0;
11731 }
11732
11733 /* Method invocation conversion test. Return 1 if type SOURCE can be
11734    converted to type DEST through the methond invocation conversion
11735    process (5.3) */
11736
11737 static tree
11738 do_unary_numeric_promotion (arg)
11739      tree arg;
11740 {
11741   tree type = TREE_TYPE (arg);
11742   if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
11743       : TREE_CODE (type) == CHAR_TYPE)
11744     arg = convert (int_type_node, arg);
11745   return arg;
11746 }
11747
11748 /* Return a non zero value if SOURCE can be converted into DEST using
11749    the method invocation conversion rule (5.3).  */
11750 static int
11751 valid_method_invocation_conversion_p (dest, source)
11752      tree dest, source;
11753 {
11754   return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
11755            && valid_builtin_assignconv_identity_widening_p (dest, source))
11756           || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
11757               && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
11758               && valid_ref_assignconv_cast_p (source, dest, 0)));
11759 }
11760
11761 /* Build an incomplete binop expression. */
11762
11763 static tree
11764 build_binop (op, op_location, op1, op2)
11765      enum tree_code op;
11766      int op_location;
11767      tree op1, op2;
11768 {
11769   tree binop = build (op, NULL_TREE, op1, op2);
11770   TREE_SIDE_EFFECTS (binop) = 1;
11771   /* Store the location of the operator, for better error report. The
11772      string of the operator will be rebuild based on the OP value. */
11773   EXPR_WFL_LINECOL (binop) = op_location;
11774   return binop;
11775 }
11776
11777 /* Build the string of the operator retained by NODE. If NODE is part
11778    of a compound expression, add an '=' at the end of the string. This
11779    function is called when an error needs to be reported on an
11780    operator. The string is returned as a pointer to a static character
11781    buffer. */
11782
11783 static char *
11784 operator_string (node)
11785      tree node;
11786 {
11787 #define BUILD_OPERATOR_STRING(S)                                        \
11788   {                                                                     \
11789     sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
11790     return buffer;                                                      \
11791   }
11792   
11793   static char buffer [10];
11794   switch (TREE_CODE (node))
11795     {
11796     case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
11797     case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
11798     case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
11799     case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
11800     case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
11801     case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
11802     case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
11803     case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
11804     case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
11805     case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
11806     case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
11807     case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
11808     case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
11809     case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
11810     case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
11811     case GT_EXPR: BUILD_OPERATOR_STRING (">");
11812     case GE_EXPR: BUILD_OPERATOR_STRING (">=");
11813     case LT_EXPR: BUILD_OPERATOR_STRING ("<");
11814     case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
11815     case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
11816     case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
11817     case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
11818     case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
11819     case PREINCREMENT_EXPR:     /* Fall through */
11820     case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
11821     case PREDECREMENT_EXPR:     /* Fall through */
11822     case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
11823     default:
11824       fatal ("unregistered operator %s - operator_string",
11825              tree_code_name [TREE_CODE (node)]);
11826     }
11827   return NULL;
11828 #undef BUILD_OPERATOR_STRING
11829 }
11830
11831 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
11832    errors but we modify NODE so that it contains the type computed
11833    according to the expression, when it's fixed. Otherwise, we write
11834    error_mark_node as the type. It allows us to further the analysis
11835    of remaining nodes and detects more errors in certain cases.  */
11836
11837 static tree
11838 patch_binop (node, wfl_op1, wfl_op2)
11839      tree node;
11840      tree wfl_op1;
11841      tree wfl_op2;
11842 {
11843   tree op1 = TREE_OPERAND (node, 0);
11844   tree op2 = TREE_OPERAND (node, 1);
11845   tree op1_type = TREE_TYPE (op1);
11846   tree op2_type = TREE_TYPE (op2);
11847   tree prom_type = NULL_TREE;
11848   int code = TREE_CODE (node);
11849
11850   /* If 1, tell the routine that we have to return error_mark_node
11851      after checking for the initialization of the RHS */
11852   int error_found = 0;
11853
11854   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
11855
11856   switch (code)
11857     {
11858     /* 15.16 Multiplicative operators */
11859     case MULT_EXPR:             /* 15.16.1 Multiplication Operator * */
11860     case RDIV_EXPR:             /* 15.16.2 Division Operator / */
11861     case TRUNC_MOD_EXPR:        /* 15.16.3 Remainder operator % */
11862       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
11863         {
11864           if (!JPRIMITIVE_TYPE_P (op1_type))
11865             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
11866           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
11867             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
11868           TREE_TYPE (node) = error_mark_node;
11869           error_found = 1;
11870           break;
11871         }
11872       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
11873       /* Change the division operator if necessary */
11874       if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
11875         TREE_SET_CODE (node, TRUNC_DIV_EXPR);
11876
11877       /* This one is more complicated. FLOATs are processed by a
11878          function call to soft_fmod. Duplicate the value of the
11879          COMPOUND_ASSIGN_P flag. */
11880       if (code == TRUNC_MOD_EXPR)
11881         {
11882           tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
11883           COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
11884           TREE_SIDE_EFFECTS (mod)
11885             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
11886           return mod;
11887         }
11888       break;
11889
11890     /* 15.17 Additive Operators */
11891     case PLUS_EXPR:             /* 15.17.1 String Concatenation Operator + */
11892
11893       /* Operation is valid if either one argument is a string
11894          constant, a String object or a StringBuffer crafted for the
11895          purpose of the a previous usage of the String concatenation
11896          operator */
11897
11898       if (TREE_CODE (op1) == STRING_CST 
11899           || TREE_CODE (op2) == STRING_CST
11900           || JSTRING_TYPE_P (op1_type)
11901           || JSTRING_TYPE_P (op2_type)
11902           || IS_CRAFTED_STRING_BUFFER_P (op1)
11903           || IS_CRAFTED_STRING_BUFFER_P (op2))
11904         return build_string_concatenation (op1, op2);
11905
11906     case MINUS_EXPR:            /* 15.17.2 Additive Operators (+ and -) for
11907                                    Numeric Types */
11908       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
11909         {
11910           if (!JPRIMITIVE_TYPE_P (op1_type))
11911             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
11912           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
11913             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
11914           TREE_TYPE (node) = error_mark_node;
11915           error_found = 1;
11916           break;
11917         }
11918       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
11919       break;
11920
11921     /* 15.18 Shift Operators */
11922     case LSHIFT_EXPR:
11923     case RSHIFT_EXPR:
11924     case URSHIFT_EXPR:
11925       if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
11926         {
11927           if (!JINTEGRAL_TYPE_P (op1_type))
11928             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
11929           else
11930             parse_error_context 
11931               (wfl_operator, (JPRIMITIVE_TYPE_P (op2_type) ? 
11932                "Incompatible type for `%s'. Explicit cast needed to convert "
11933                "shift distance from `%s' to integral" : 
11934                "Incompatible type for `%s'. Can't convert shift distance from "
11935                "`%s' to integral"), 
11936                operator_string (node), lang_printable_name (op2_type, 0));
11937           TREE_TYPE (node) = error_mark_node;
11938           error_found = 1;
11939           break;
11940         }
11941
11942       /* Unary numeric promotion (5.6.1) is performed on each operand
11943          separatly */
11944       op1 = do_unary_numeric_promotion (op1);
11945       op2 = do_unary_numeric_promotion (op2);
11946
11947       /* The type of the shift expression is the type of the promoted
11948          type of the left-hand operand */
11949       prom_type = TREE_TYPE (op1);
11950
11951       /* Shift int only up to 0x1f and long up to 0x3f */
11952       if (prom_type == int_type_node)
11953         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
11954                            build_int_2 (0x1f, 0)));
11955       else
11956         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
11957                            build_int_2 (0x3f, 0)));
11958
11959       /* The >>> operator is a >> operating on unsigned quantities */
11960       if (code == URSHIFT_EXPR && ! flag_emit_class_files)
11961         {
11962           tree to_return;
11963           tree utype = unsigned_type (prom_type);
11964           op1 = convert (utype, op1);
11965           TREE_SET_CODE (node, RSHIFT_EXPR);
11966           TREE_OPERAND (node, 0) = op1;
11967           TREE_OPERAND (node, 1) = op2;
11968           TREE_TYPE (node) = utype;
11969           to_return = convert (prom_type, node);
11970           /* Copy the original value of the COMPOUND_ASSIGN_P flag */
11971           COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
11972           TREE_SIDE_EFFECTS (to_return)
11973             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
11974           return to_return;
11975         }
11976       break;
11977
11978       /* 15.19.1 Type Comparison Operator instaceof */
11979     case INSTANCEOF_EXPR:
11980
11981       TREE_TYPE (node) = boolean_type_node;
11982
11983       if (!(op2_type = resolve_type_during_patch (op2)))
11984         return error_mark_node;
11985
11986       /* The first operand must be a reference type or the null type */
11987       if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
11988         error_found = 1;        /* Error reported further below */
11989
11990       /* The second operand must be a reference type */
11991       if (!JREFERENCE_TYPE_P (op2_type))
11992         {
11993           SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
11994           parse_error_context
11995             (wfl_operator, "Invalid argument `%s' for `instanceof'",
11996              lang_printable_name (op2_type, 0));
11997           error_found = 1;
11998         }
11999
12000       if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
12001         {
12002           /* If the first operand is null, the result is always false */
12003           if (op1 == null_pointer_node)
12004             return boolean_false_node;
12005           else if (flag_emit_class_files)
12006             {
12007               TREE_OPERAND (node, 1) = op2_type;
12008               TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
12009               return node;
12010             }
12011           /* Otherwise we have to invoke instance of to figure it out */
12012           else
12013             {
12014               tree call =
12015                 build (CALL_EXPR, boolean_type_node,
12016                        build_address_of (soft_instanceof_node),
12017                        tree_cons 
12018                        (NULL_TREE, op1,
12019                         build_tree_list (NULL_TREE,
12020                                          build_class_ref (op2_type))),
12021                        NULL_TREE);
12022               TREE_SIDE_EFFECTS (call) = TREE_SIDE_EFFECTS (op1);
12023               return call;
12024             }
12025         }
12026       /* There is no way the expression operand can be an instance of
12027          the type operand. This is a compile time error. */
12028       else
12029         {
12030           char *t1 = strdup (lang_printable_name (op1_type, 0));
12031           SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
12032           parse_error_context 
12033             (wfl_operator, "Impossible for `%s' to be instance of `%s'",
12034              t1, lang_printable_name (op2_type, 0));
12035           free (t1);
12036           error_found = 1;
12037         }
12038       
12039       break;
12040
12041       /* 15.21 Bitwise and Logical Operators */
12042     case BIT_AND_EXPR:
12043     case BIT_XOR_EXPR:
12044     case BIT_IOR_EXPR:
12045       if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
12046         /* Binary numeric promotion is performed on both operand and the
12047            expression retain that type */
12048         prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12049
12050       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE 
12051                && TREE_CODE (op1_type) == BOOLEAN_TYPE)
12052         /* The type of the bitwise operator expression is BOOLEAN */
12053         prom_type = boolean_type_node;
12054       else
12055         {
12056           if (!JINTEGRAL_TYPE_P (op1_type))
12057             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
12058           if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
12059             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
12060           TREE_TYPE (node) = error_mark_node;
12061           error_found = 1;
12062           /* Insert a break here if adding thing before the switch's
12063              break for this case */
12064         }
12065       break;
12066
12067       /* 15.22 Conditional-And Operator */
12068     case TRUTH_ANDIF_EXPR:
12069       /* 15.23 Conditional-Or Operator */
12070     case TRUTH_ORIF_EXPR:
12071       /* Operands must be of BOOLEAN type */
12072       if (TREE_CODE (op1_type) != BOOLEAN_TYPE || 
12073           TREE_CODE (op2_type) != BOOLEAN_TYPE)
12074         {
12075           if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
12076             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
12077           if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
12078             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
12079           TREE_TYPE (node) = boolean_type_node;
12080           error_found = 1;
12081           break;
12082         }
12083       /* The type of the conditional operators is BOOLEAN */
12084       prom_type = boolean_type_node;
12085       break;
12086
12087       /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
12088     case LT_EXPR:
12089     case GT_EXPR:
12090     case LE_EXPR:
12091     case GE_EXPR:
12092       /* The type of each of the operands must be a primitive numeric
12093          type */
12094       if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
12095         {
12096           if (!JNUMERIC_TYPE_P (op1_type))
12097             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
12098           if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
12099             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
12100           TREE_TYPE (node) = boolean_type_node;
12101           error_found = 1;
12102           break;
12103         }
12104       /* Binary numeric promotion is performed on the operands */
12105       binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12106       /* The type of the relation expression is always BOOLEAN */
12107       prom_type = boolean_type_node;
12108       break;
12109
12110       /* 15.20 Equality Operator */
12111     case EQ_EXPR:
12112     case NE_EXPR:
12113       /* 15.20.1 Numerical Equality Operators == and != */
12114       /* Binary numeric promotion is performed on the operands */
12115       if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
12116         binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12117       
12118       /* 15.20.2 Boolean Equality Operators == and != */
12119       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
12120           TREE_CODE (op2_type) == BOOLEAN_TYPE)
12121         ;                       /* Nothing to do here */
12122       
12123       /* 15.20.3 Reference Equality Operators == and != */
12124       /* Types have to be either references or the null type. If
12125          they're references, it must be possible to convert either
12126          type to the other by casting conversion. */
12127       else if (op1 == null_pointer_node || op2 == null_pointer_node 
12128                || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
12129                    && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
12130                        || valid_ref_assignconv_cast_p (op2_type, 
12131                                                        op1_type, 1))))
12132         ;                       /* Nothing to do here */
12133           
12134       /* Else we have an error figure what can't be converted into
12135          what and report the error */
12136       else
12137         {
12138           char *t1;
12139           t1 = strdup (lang_printable_name (op1_type, 0));
12140           parse_error_context 
12141             (wfl_operator, "Incompatible type for `%s'. Can't convert `%s' "
12142              "to `%s'", operator_string (node), t1, 
12143              lang_printable_name (op2_type, 0));
12144           free (t1);
12145           TREE_TYPE (node) = boolean_type_node;
12146           error_found = 1;
12147           break;
12148         }
12149       prom_type = boolean_type_node;
12150       break;
12151     }
12152
12153   if (error_found)
12154     return error_mark_node;
12155
12156   TREE_OPERAND (node, 0) = op1;
12157   TREE_OPERAND (node, 1) = op2;
12158   TREE_TYPE (node) = prom_type;
12159   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
12160   
12161   if (flag_emit_xref)
12162     return node;
12163
12164   /* fold does not respect side-effect order as required for Java but not C.
12165    * Also, it sometimes create SAVE_EXPRs which are bad when emitting
12166    * bytecode.
12167    */
12168   if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
12169       : ! TREE_SIDE_EFFECTS (node))
12170     node = fold (node);
12171   return node;
12172 }
12173
12174 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
12175    zero value, the value of CSTE comes after the valude of STRING */
12176
12177 static tree
12178 do_merge_string_cste (cste, string, string_len, after)
12179      tree cste;
12180      char *string;
12181      int string_len, after;
12182 {
12183   int len = TREE_STRING_LENGTH (cste) + string_len;
12184   char *old = TREE_STRING_POINTER (cste);
12185   TREE_STRING_LENGTH (cste) = len;
12186   TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
12187   if (after)
12188     {
12189       strcpy (TREE_STRING_POINTER (cste), string);
12190       strcat (TREE_STRING_POINTER (cste), old);
12191     }
12192   else
12193     {
12194       strcpy (TREE_STRING_POINTER (cste), old);
12195       strcat (TREE_STRING_POINTER (cste), string);
12196     }
12197   return cste;
12198 }
12199
12200 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
12201    new STRING_CST on success, NULL_TREE on failure */
12202
12203 static tree
12204 merge_string_cste (op1, op2, after)
12205      tree op1, op2;
12206      int after;
12207 {
12208   /* Handle two string constants right away */
12209   if (TREE_CODE (op2) == STRING_CST)
12210     return do_merge_string_cste (op1, TREE_STRING_POINTER (op2), 
12211                                  TREE_STRING_LENGTH (op2), after);
12212   
12213   /* Reasonable integer constant can be treated right away */
12214   if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
12215     {
12216       static char *boolean_true = "true";
12217       static char *boolean_false = "false";
12218       static char *null_pointer = "null";
12219       char ch[3];
12220       char *string;
12221       
12222       if (op2 == boolean_true_node)
12223         string = boolean_true;
12224       else if (op2 == boolean_false_node)
12225         string = boolean_false;
12226       else if (op2 == null_pointer_node)
12227         string = null_pointer;
12228       else if (TREE_TYPE (op2) == char_type_node)
12229         {
12230           ch[0] = (char )TREE_INT_CST_LOW (op2);
12231           ch[1] = '\0';
12232           string = ch;
12233         }
12234       else
12235           string = print_int_node (op2);
12236       
12237       return do_merge_string_cste (op1, string, strlen (string), after);
12238     }
12239   return NULL_TREE;
12240 }
12241
12242 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
12243    has to be a STRING_CST and the other part must be a STRING_CST or a
12244    INTEGRAL constant. Return a new STRING_CST if the operation
12245    succeed, NULL_TREE otherwise.
12246
12247    If the case we want to optimize for space, we might want to return
12248    NULL_TREE for each invocation of this routine. FIXME */
12249
12250 static tree
12251 string_constant_concatenation (op1, op2)
12252      tree op1, op2;
12253 {
12254   if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
12255     {
12256       tree string, rest;
12257       int invert;
12258       
12259       string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
12260       rest   = (string == op1 ? op2 : op1);
12261       invert = (string == op1 ? 0 : 1 );
12262       
12263       /* Walk REST, only if it looks reasonable */
12264       if (TREE_CODE (rest) != STRING_CST
12265           && !IS_CRAFTED_STRING_BUFFER_P (rest)
12266           && !JSTRING_TYPE_P (TREE_TYPE (rest))
12267           && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
12268         {
12269           rest = java_complete_tree (rest);
12270           if (rest == error_mark_node)
12271             return error_mark_node;
12272           rest = fold (rest);
12273         }
12274       return merge_string_cste (string, rest, invert);
12275     }
12276   return NULL_TREE;
12277 }
12278
12279 /* Implement the `+' operator. Does static optimization if possible,
12280    otherwise create (if necessary) and append elements to a
12281    StringBuffer. The StringBuffer will be carried around until it is
12282    used for a function call or an assignment. Then toString() will be
12283    called on it to turn it into a String object. */
12284
12285 static tree
12286 build_string_concatenation (op1, op2)
12287      tree op1, op2;
12288 {
12289   tree result;
12290   int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
12291
12292   if (flag_emit_xref)
12293     return build (PLUS_EXPR, string_type_node, op1, op2);
12294   
12295   /* Try to do some static optimization */
12296   if ((result = string_constant_concatenation (op1, op2)))
12297     return result;
12298
12299   /* Discard empty strings on either side of the expression */
12300   if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
12301     {
12302       op1 = op2;
12303       op2 = NULL_TREE;
12304     }
12305   else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
12306     op2 = NULL_TREE;
12307
12308   /* If operands are string constant, turn then into object references */
12309   if (TREE_CODE (op1) == STRING_CST)
12310     op1 = patch_string_cst (op1);
12311   if (op2 && TREE_CODE (op2) == STRING_CST)
12312     op2 = patch_string_cst (op2);
12313
12314   /* If either one of the constant is null and the other non null
12315      operand is a String object, return it. */
12316   if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
12317     return op1;
12318
12319   /* If OP1 isn't already a StringBuffer, create and
12320      initialize a new one */
12321   if (!IS_CRAFTED_STRING_BUFFER_P (op1))
12322     {
12323       /* Two solutions here: 
12324          1) OP1 is a string reference, we call new StringBuffer(OP1)
12325          2) OP1 is something else, we call new StringBuffer().append(OP1). */
12326       if (JSTRING_TYPE_P (TREE_TYPE (op1)))
12327         op1 = BUILD_STRING_BUFFER (op1);
12328       else
12329         {
12330           tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
12331           op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
12332         }
12333     }
12334
12335   if (op2)
12336     {
12337       /* OP1 is no longer the last node holding a crafted StringBuffer */
12338       IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
12339       /* Create a node for `{new...,xxx}.append (op2)' */
12340       if (op2)
12341         op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
12342     }
12343
12344   /* Mark the last node holding a crafted StringBuffer */
12345   IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
12346
12347   TREE_SIDE_EFFECTS (op1) = side_effects;
12348   return op1;
12349 }
12350
12351 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
12352    StringBuffer. If no string were found to be patched, return
12353    NULL. */
12354
12355 static tree
12356 patch_string (node)
12357     tree node;
12358 {
12359   if (node == error_mark_node)
12360     return error_mark_node;
12361   if (TREE_CODE (node) == STRING_CST)
12362     return patch_string_cst (node);
12363   else if (IS_CRAFTED_STRING_BUFFER_P (node))
12364     {
12365       int saved = ctxp->explicit_constructor_p;
12366       tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
12367       tree ret;
12368       /* Temporary disable forbid the use of `this'. */
12369       ctxp->explicit_constructor_p = 0;
12370       ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
12371       /* Restore it at its previous value */
12372       ctxp->explicit_constructor_p = saved;
12373       return ret;
12374     }
12375   return NULL_TREE;
12376 }
12377
12378 /* Build the internal representation of a string constant.  */
12379
12380 static tree
12381 patch_string_cst (node)
12382      tree node;
12383 {
12384   int location;
12385   if (! flag_emit_class_files)
12386     {
12387       push_obstacks (&permanent_obstack, &permanent_obstack);
12388       node = get_identifier (TREE_STRING_POINTER (node));
12389       location = alloc_name_constant (CONSTANT_String, node);
12390       node = build_ref_from_constant_pool (location);
12391     }
12392   TREE_TYPE (node) = string_ptr_type_node;
12393   TREE_CONSTANT (node) = 1;
12394   return node;
12395 }
12396
12397 /* Build an incomplete unary operator expression. */
12398
12399 static tree
12400 build_unaryop (op_token, op_location, op1)
12401      int op_token, op_location;
12402      tree op1;
12403 {
12404   enum tree_code op;
12405   tree unaryop;
12406   switch (op_token)
12407     {
12408     case PLUS_TK: op = UNARY_PLUS_EXPR; break;
12409     case MINUS_TK: op = NEGATE_EXPR; break;
12410     case NEG_TK: op = TRUTH_NOT_EXPR; break;
12411     case NOT_TK: op = BIT_NOT_EXPR; break;
12412     default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
12413                     op_token);
12414     }
12415
12416   unaryop = build1 (op, NULL_TREE, op1);
12417   TREE_SIDE_EFFECTS (unaryop) = 1;
12418   /* Store the location of the operator, for better error report. The
12419      string of the operator will be rebuild based on the OP value. */
12420   EXPR_WFL_LINECOL (unaryop) = op_location;
12421   return unaryop;
12422 }
12423
12424 /* Special case for the ++/-- operators, since they require an extra
12425    argument to build, which is set to NULL and patched
12426    later. IS_POST_P is 1 if the operator, 0 otherwise.  */
12427
12428 static tree
12429 build_incdec (op_token, op_location, op1, is_post_p)
12430      int op_token, op_location;
12431      tree op1;
12432      int is_post_p;
12433 {
12434   static enum tree_code lookup [2][2] = 
12435     {
12436       { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
12437       { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
12438     };
12439   tree node = build (lookup [is_post_p][(op_token - DECR_TK)], 
12440                      NULL_TREE, op1, NULL_TREE);
12441   TREE_SIDE_EFFECTS (node) = 1;
12442   /* Store the location of the operator, for better error report. The
12443      string of the operator will be rebuild based on the OP value. */
12444   EXPR_WFL_LINECOL (node) = op_location;
12445   return node;
12446 }     
12447
12448 /* Build an incomplete cast operator, based on the use of the
12449    CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
12450    set. java_complete_tree is trained to walk a CONVERT_EXPR even
12451    though its type is already set.  */
12452
12453 static tree
12454 build_cast (location, type, exp)
12455      int location;
12456      tree type, exp;
12457 {
12458   tree node = build1 (CONVERT_EXPR, type, exp);
12459   EXPR_WFL_LINECOL (node) = location;
12460   return node;
12461 }
12462
12463 /* 15.14 Unary operators. We return error_mark_node in case of error,
12464    but preserve the type of NODE if the type is fixed.  */
12465
12466 static tree
12467 patch_unaryop (node, wfl_op)
12468      tree node;
12469      tree wfl_op;
12470 {
12471   tree op = TREE_OPERAND (node, 0);
12472   tree op_type = TREE_TYPE (op);
12473   tree prom_type = NULL_TREE, value, decl;
12474   int code = TREE_CODE (node);
12475   int error_found = 0;
12476
12477   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
12478
12479   switch (code)
12480     {
12481       /* 15.13.2 Postfix Increment Operator ++ */
12482     case POSTINCREMENT_EXPR:
12483       /* 15.13.3 Postfix Increment Operator -- */
12484     case POSTDECREMENT_EXPR:
12485       /* 15.14.1 Prefix Increment Operator ++ */
12486     case PREINCREMENT_EXPR:
12487       /* 15.14.2 Prefix Decrement Operator -- */
12488     case PREDECREMENT_EXPR:
12489       decl = strip_out_static_field_access_decl (op);
12490       /* We really should have a JAVA_ARRAY_EXPR to avoid this */
12491       if (!JDECL_P (decl) 
12492           && TREE_CODE (decl) != COMPONENT_REF
12493           && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
12494           && TREE_CODE (decl) != INDIRECT_REF
12495           && !(TREE_CODE (decl) == COMPOUND_EXPR
12496                && TREE_OPERAND (decl, 1)
12497                && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
12498         {
12499           tree lvalue;
12500           /* Before screaming, check that we're not in fact trying to
12501              increment a optimized static final access, in which case
12502              we issue an different error message. */
12503           if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
12504                 && resolve_expression_name (wfl_op, &lvalue)
12505                 && check_final_assignment (lvalue, wfl_op)))
12506             parse_error_context (wfl_operator, "Invalid argument to `%s'",
12507                                  operator_string (node));
12508           TREE_TYPE (node) = error_mark_node;
12509           error_found = 1;
12510         }
12511       else if (check_final_assignment (op, wfl_op))
12512         error_found = 1;
12513
12514       /* From now on, we know that op if a variable and that it has a
12515          valid wfl. We use wfl_op to locate errors related to the
12516          ++/-- operand. */
12517       else if (!JNUMERIC_TYPE_P (op_type))
12518         {
12519           parse_error_context
12520             (wfl_op, "Invalid argument type `%s' to `%s'",
12521              lang_printable_name (op_type, 0), operator_string (node));
12522           TREE_TYPE (node) = error_mark_node;
12523           error_found = 1;
12524         }
12525       else
12526         {
12527           /* Before the addition, binary numeric promotion is performed on
12528              both operands */
12529           value = build_int_2 (1, 0);
12530           TREE_TYPE (node) = 
12531             binary_numeric_promotion (op_type, TREE_TYPE (value), &op, &value);
12532           /* And write the promoted incremented and increment */
12533           TREE_OPERAND (node, 0) = op;
12534           TREE_OPERAND (node, 1) = value;
12535           /* Convert the overall back into its original type. */
12536           return fold (convert (op_type, node));
12537         }
12538       break;
12539
12540       /* 15.14.3 Unary Plus Operator + */
12541     case UNARY_PLUS_EXPR:
12542       /* 15.14.4 Unary Minus Operator - */
12543     case NEGATE_EXPR:
12544       if (!JNUMERIC_TYPE_P (op_type))
12545         {
12546           ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
12547           TREE_TYPE (node) = error_mark_node;
12548           error_found = 1;
12549         }
12550       /* Unary numeric promotion is performed on operand */
12551       else
12552         {
12553           op = do_unary_numeric_promotion (op);
12554           prom_type = TREE_TYPE (op);
12555           if (code == UNARY_PLUS_EXPR)
12556             return fold (op);
12557         }
12558       break;
12559
12560       /* 15.14.5 Bitwise Complement Operator ~ */
12561     case BIT_NOT_EXPR:
12562       if (!JINTEGRAL_TYPE_P (op_type))
12563         {
12564           ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
12565           TREE_TYPE (node) = error_mark_node;
12566           error_found = 1;
12567         }
12568       else
12569         {
12570           op = do_unary_numeric_promotion (op);
12571           prom_type = TREE_TYPE (op);
12572         }
12573       break;
12574
12575       /* 15.14.6 Logical Complement Operator ! */
12576     case TRUTH_NOT_EXPR:
12577       if (TREE_CODE (op_type) != BOOLEAN_TYPE)
12578         {
12579           ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
12580           /* But the type is known. We will report an error if further
12581              attempt of a assignment is made with this rhs */
12582           TREE_TYPE (node) = boolean_type_node;
12583           error_found = 1;
12584         }
12585       else
12586         prom_type = boolean_type_node;
12587       break;
12588
12589       /* 15.15 Cast Expression */
12590     case CONVERT_EXPR:
12591       value = patch_cast (node, wfl_operator);
12592       if (value == error_mark_node)
12593         {
12594           /* If this cast is part of an assignment, we tell the code
12595              that deals with it not to complain about a mismatch,
12596              because things have been cast, anyways */
12597           TREE_TYPE (node) = error_mark_node;
12598           error_found = 1;
12599         }
12600       else
12601         {
12602           value = fold (value);
12603           TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
12604           return value;
12605         }
12606       break;
12607     }
12608   
12609   if (error_found)
12610     return error_mark_node;
12611
12612   /* There are cases where node has been replaced by something else
12613      and we don't end up returning here: UNARY_PLUS_EXPR,
12614      CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
12615   TREE_OPERAND (node, 0) = fold (op);
12616   TREE_TYPE (node) = prom_type;
12617   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
12618   return fold (node);
12619 }
12620
12621 /* Generic type resolution that sometimes takes place during node
12622    patching. Returned the resolved type or generate an error
12623    message. Return the resolved type or NULL_TREE.  */
12624
12625 static tree
12626 resolve_type_during_patch (type)
12627      tree type;
12628 {
12629   if (unresolved_type_p (type, NULL))
12630     {
12631       tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
12632       if (!type_decl)
12633         {
12634           parse_error_context (type, 
12635                                "Class `%s' not found in type declaration",
12636                                IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
12637           return NULL_TREE;
12638         }
12639       else
12640         {
12641           CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
12642           return TREE_TYPE (type_decl);
12643         }
12644     }
12645   return type;
12646 }
12647 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
12648    found. Otherwise NODE or something meant to replace it is returned.  */
12649
12650 static tree
12651 patch_cast (node, wfl_operator)
12652      tree node;
12653      tree wfl_operator;
12654 {
12655   tree op = TREE_OPERAND (node, 0);
12656   tree op_type = TREE_TYPE (op);
12657   tree cast_type = TREE_TYPE (node);
12658   char *t1;
12659
12660   /* First resolve OP_TYPE if unresolved */
12661   if (!(cast_type = resolve_type_during_patch (cast_type)))
12662     return error_mark_node;
12663
12664   /* Check on cast that are proven correct at compile time */
12665   if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
12666     {
12667       static tree convert_narrow ();
12668       /* Same type */
12669       if (cast_type == op_type)
12670         return node;
12671
12672       /* float and double type are converted to the original type main
12673          variant and then to the target type. */
12674       if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
12675         op = convert (integer_type_node, op);
12676
12677       /* Try widening/narowwing convertion. Potentially, things need
12678          to be worked out in gcc so we implement the extreme cases
12679          correctly. fold_convert() needs to be fixed. */
12680       return convert (cast_type, op);
12681     }
12682
12683   /* It's also valid to cast a boolean into a boolean */
12684   if (op_type == boolean_type_node && cast_type == boolean_type_node)
12685     return node;
12686
12687   /* null can be casted to references */
12688   if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
12689     return build_null_of_type (cast_type);
12690
12691   /* The remaining legal casts involve conversion between reference
12692      types. Check for their compile time correctness. */
12693   if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type) 
12694       && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
12695     {
12696       TREE_TYPE (node) = promote_type (cast_type);
12697       /* Now, the case can be determined correct at compile time if
12698          OP_TYPE can be converted into CAST_TYPE by assignment
12699          conversion (5.2) */
12700
12701       if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
12702         {
12703           TREE_SET_CODE (node, NOP_EXPR);
12704           return node;
12705         }
12706
12707       if (flag_emit_class_files)
12708         {
12709           TREE_SET_CODE (node, CONVERT_EXPR);
12710           return node;
12711         }
12712
12713       /* The cast requires a run-time check */
12714       return build (CALL_EXPR, promote_type (cast_type),
12715                     build_address_of (soft_checkcast_node),
12716                     tree_cons (NULL_TREE, build_class_ref (cast_type),
12717                                build_tree_list (NULL_TREE, op)),
12718                     NULL_TREE);
12719     }
12720
12721   /* Any other casts are proven incorrect at compile time */
12722   t1 = strdup (lang_printable_name (op_type, 0));
12723   parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
12724                        t1, lang_printable_name (cast_type, 0));
12725   free (t1);
12726   return error_mark_node;
12727 }
12728
12729 /* Build a null constant and give it the type TYPE.  */
12730
12731 static tree
12732 build_null_of_type (type)
12733      tree type;
12734 {
12735   tree node = build_int_2 (0, 0);
12736   TREE_TYPE (node) = promote_type (type);
12737   return node;
12738 }
12739
12740 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
12741    a list of indices. */
12742 static tree
12743 build_array_ref (location, array, index)
12744      int location;
12745      tree array, index;
12746 {
12747   tree node = build (ARRAY_REF, NULL_TREE, array, index);
12748   EXPR_WFL_LINECOL (node) = location;
12749   return node;
12750 }
12751
12752 /* 15.12 Array Access Expression */
12753
12754 static tree
12755 patch_array_ref (node)
12756      tree node;
12757 {
12758   tree array = TREE_OPERAND (node, 0);
12759   tree array_type  = TREE_TYPE (array);
12760   tree index = TREE_OPERAND (node, 1);
12761   tree index_type = TREE_TYPE (index);
12762   int error_found = 0;
12763
12764   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
12765
12766   if (TREE_CODE (array_type) == POINTER_TYPE)
12767     array_type = TREE_TYPE (array_type);
12768
12769   /* The array reference must be an array */
12770   if (!TYPE_ARRAY_P (array_type))
12771     {
12772       parse_error_context 
12773         (wfl_operator, "`[]' can only be applied to arrays. It can't be "
12774          "applied to `%s'", lang_printable_name (array_type, 0));
12775       TREE_TYPE (node) = error_mark_node;
12776       error_found = 1;
12777     }
12778
12779   /* The array index underdoes unary numeric promotion. The promoted
12780      type must be int */
12781   index = do_unary_numeric_promotion (index);
12782   if (TREE_TYPE (index) != int_type_node)
12783     {
12784       int could_cast = valid_cast_to_p (index_type, int_type_node);
12785       parse_error_context 
12786         (wfl_operator, 
12787          (could_cast ? "Incompatible type for `[]'. Explicit cast needed to "
12788           "convert `%s' to `int'" : "Incompatible type for `[]'. "
12789           "Can't convert `%s' to `int'"),
12790          lang_printable_name (index_type, 0));
12791       TREE_TYPE (node) = error_mark_node;
12792       error_found = 1;
12793     }
12794
12795   if (error_found)
12796     return error_mark_node;
12797
12798   array_type = TYPE_ARRAY_ELEMENT (array_type);
12799
12800   if (flag_emit_class_files || flag_emit_xref)
12801     {
12802       TREE_OPERAND (node, 0) = array;
12803       TREE_OPERAND (node, 1) = index;
12804     }
12805   else
12806     {
12807       /* The save_expr is for correct evaluation order.  It would be cleaner
12808          to use force_evaluation_order (see comment there), but that is
12809          difficult when we also have to deal with bounds checking. */
12810       if (TREE_SIDE_EFFECTS (index))
12811         array = save_expr (array);
12812       node = build_java_arrayaccess (array, array_type, index);
12813       if (TREE_SIDE_EFFECTS (index))
12814         node = build (COMPOUND_EXPR, array_type, array, node);
12815     }
12816   TREE_TYPE (node) = array_type;
12817   return node;
12818 }
12819
12820 /* 15.9 Array Creation Expressions */
12821
12822 static tree
12823 build_newarray_node (type, dims, extra_dims)
12824      tree type;
12825      tree dims;
12826      int extra_dims;
12827 {
12828   tree node =
12829     build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims), 
12830            build_int_2 (extra_dims, 0));
12831   return node;
12832 }
12833
12834 static tree
12835 patch_newarray (node)
12836      tree node;
12837 {
12838   tree type = TREE_OPERAND (node, 0);
12839   tree dims = TREE_OPERAND (node, 1);
12840   tree cdim, array_type;
12841   int error_found = 0;
12842   int ndims = 0;
12843   int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
12844
12845   /* Dimension types are verified. It's better for the types to be
12846      verified in order. */
12847   for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
12848     {
12849       int dim_error = 0;
12850       tree dim = TREE_VALUE (cdim);
12851
12852       /* Dim might have been saved during its evaluation */
12853       dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
12854
12855       /* The type of each specified dimension must be an integral type. */
12856       if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
12857         dim_error = 1;
12858
12859       /* Each expression undergoes an unary numeric promotion (5.6.1) and the
12860          promoted type must be int. */
12861       else
12862         {
12863           dim = do_unary_numeric_promotion (dim);
12864           if (TREE_TYPE (dim) != int_type_node)
12865             dim_error = 1;
12866         }
12867
12868       /* Report errors on types here */
12869       if (dim_error)
12870         {
12871           parse_error_context 
12872             (TREE_PURPOSE (cdim), 
12873              "Incompatible type for dimension in array creation expression. "
12874              "%s convert `%s' to `int'", 
12875              (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
12876               "Explicit cast needed to" : "Can't"),
12877              lang_printable_name (TREE_TYPE (dim), 0));
12878           error_found = 1;
12879         }
12880
12881       TREE_PURPOSE (cdim) = NULL_TREE;
12882     }
12883
12884   /* Resolve array base type if unresolved */
12885   if (!(type = resolve_type_during_patch (type)))
12886     error_found = 1;
12887
12888   if (error_found)
12889     {
12890       /* We don't want further evaluation of this bogus array creation
12891          operation */
12892       TREE_TYPE (node) = error_mark_node;
12893       return error_mark_node;
12894     }
12895
12896   /* Set array_type to the actual (promoted) array type of the result. */
12897   if (TREE_CODE (type) == RECORD_TYPE)
12898     type = build_pointer_type (type);
12899   while (--xdims >= 0)
12900     {
12901       type = promote_type (build_java_array_type (type, -1));
12902     }
12903   dims = nreverse (dims);
12904   array_type = type;
12905   for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
12906     {
12907       type = array_type;
12908       array_type = build_java_array_type (type,
12909                                           TREE_CODE (cdim) == INTEGER_CST ?
12910                                           TREE_INT_CST_LOW (cdim) : -1);
12911       array_type = promote_type (array_type);
12912     }
12913   dims = nreverse (dims);
12914
12915   /* The node is transformed into a function call. Things are done
12916      differently according to the number of dimensions. If the number
12917      of dimension is equal to 1, then the nature of the base type
12918      (primitive or not) matters. */
12919   if (ndims == 1)
12920     return build_new_array (type, TREE_VALUE (dims));
12921   
12922   /* Can't reuse what's already written in expr.c because it uses the
12923      JVM stack representation. Provide a build_multianewarray. FIXME */
12924   return build (CALL_EXPR, array_type,
12925                 build_address_of (soft_multianewarray_node),
12926                 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
12927                            tree_cons (NULL_TREE, 
12928                                       build_int_2 (ndims, 0), dims )),
12929                 NULL_TREE);
12930 }
12931
12932 /* 10.6 Array initializer.  */
12933
12934 /* Build a wfl for array element that don't have one, so we can
12935    pin-point errors.  */
12936
12937 static tree
12938 maybe_build_array_element_wfl (node)
12939      tree node;
12940 {
12941   if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
12942     return build_expr_wfl (NULL_TREE, ctxp->filename,
12943                            ctxp->elc.line, ctxp->elc.prev_col);
12944   else
12945     return NULL_TREE;
12946 }
12947
12948 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
12949    identification of initialized arrays easier to detect during walk
12950    and expansion.  */
12951
12952 static tree
12953 build_new_array_init (location, values)
12954      int location;
12955      tree values;
12956 {
12957   tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
12958   tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
12959   EXPR_WFL_LINECOL (to_return) = location;
12960   return to_return;
12961 }
12962
12963 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
12964    occurred.  Otherwise return NODE after having set its type
12965    appropriately.  */
12966
12967 static tree
12968 patch_new_array_init (type, node)
12969      tree type, node;
12970 {
12971   int error_seen = 0;
12972   tree current, element_type;
12973   HOST_WIDE_INT length;
12974   int all_constant = 1;
12975   tree init = TREE_OPERAND (node, 0);
12976
12977   if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
12978     {
12979       parse_error_context (node,
12980                            "Invalid array initializer for non-array type `%s'",
12981                            lang_printable_name (type, 1));
12982       return error_mark_node;
12983     }
12984   type = TREE_TYPE (type);
12985   element_type = TYPE_ARRAY_ELEMENT (type);
12986
12987   CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
12988
12989   for (length = 0, current = CONSTRUCTOR_ELTS (init);
12990        current;  length++, current = TREE_CHAIN (current))
12991     {
12992       tree elt = TREE_VALUE (current);
12993       if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
12994         {
12995           error_seen |= array_constructor_check_entry (element_type, current);
12996           elt = TREE_VALUE (current);
12997           /* When compiling to native code, STRING_CST is converted to
12998              INDIRECT_REF, but still with a TREE_CONSTANT flag. */
12999           if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
13000             all_constant = 0;
13001         }
13002       else
13003         {
13004           TREE_VALUE (current) = patch_new_array_init (element_type, elt);
13005           TREE_PURPOSE (current) = NULL_TREE;
13006           all_constant = 0;
13007         }
13008       if (elt && TREE_VALUE (elt) == error_mark_node)
13009         error_seen = 1;
13010     }
13011
13012   if (error_seen)
13013     return error_mark_node;
13014
13015   /* Create a new type. We can't reuse the one we have here by
13016      patching its dimension because it originally is of dimension -1
13017      hence reused by gcc. This would prevent triangular arrays. */
13018   type = build_java_array_type (element_type, length);
13019   TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
13020   TREE_TYPE (node) = promote_type (type);
13021   TREE_CONSTANT (init) = all_constant;
13022   TREE_CONSTANT (node) = all_constant;
13023   return node;
13024 }
13025
13026 /* Verify that one entry of the initializer element list can be
13027    assigned to the array base type. Report 1 if an error occurred, 0
13028    otherwise.  */
13029
13030 static int
13031 array_constructor_check_entry (type, entry)
13032      tree type, entry;
13033 {
13034   char *array_type_string = NULL;       /* For error reports */
13035   tree value, type_value, new_value, wfl_value, patched;
13036   int error_seen = 0;
13037
13038   new_value = NULL_TREE;
13039   wfl_value = TREE_VALUE (entry);
13040
13041   value = java_complete_tree (TREE_VALUE (entry));
13042   /* patch_string return error_mark_node if arg is error_mark_node */
13043   if ((patched = patch_string (value)))
13044     value = patched;
13045   if (value == error_mark_node)
13046     return 1;
13047   
13048   type_value = TREE_TYPE (value);
13049   
13050   /* At anytime, try_builtin_assignconv can report a warning on
13051      constant overflow during narrowing. */
13052   SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
13053   new_value = try_builtin_assignconv (wfl_operator, type, value);
13054   if (!new_value && (new_value = try_reference_assignconv (type, value)))
13055     type_value = promote_type (type);
13056   
13057   /* Check and report errors */
13058   if (!new_value)
13059     {
13060       char *msg = (!valid_cast_to_p (type_value, type) ?
13061                    "Can't" : "Explicit cast needed to");
13062       if (!array_type_string)
13063         array_type_string = strdup (lang_printable_name (type, 1));
13064       parse_error_context 
13065         (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
13066          msg, lang_printable_name (type_value, 1), array_type_string);
13067       error_seen = 1;
13068     }
13069   
13070   if (new_value)
13071     {
13072       new_value = maybe_build_primttype_type_ref (new_value, wfl_operator);
13073       TREE_VALUE (entry) = new_value;
13074     }
13075
13076   if (array_type_string)
13077     free (array_type_string);
13078
13079   TREE_PURPOSE (entry) = NULL_TREE;
13080   return error_seen;
13081 }
13082
13083 static tree
13084 build_this (location)
13085      int location;
13086 {
13087   tree node = build_wfl_node (this_identifier_node);
13088   TREE_SET_CODE (node, THIS_EXPR);
13089   EXPR_WFL_LINECOL (node) = location;
13090   return node;
13091 }
13092
13093 /* 14.15 The return statement. It builds a modify expression that
13094    assigns the returned value to the RESULT_DECL that hold the value
13095    to be returned. */
13096
13097 static tree
13098 build_return (location, op)
13099      int location;
13100      tree op;
13101 {
13102   tree node = build1 (RETURN_EXPR, NULL_TREE, op);
13103   EXPR_WFL_LINECOL (node) = location;
13104   node = build_debugable_stmt (location, node);
13105   return node;
13106 }
13107
13108 static tree
13109 patch_return (node)
13110      tree node;
13111 {
13112   tree return_exp = TREE_OPERAND (node, 0);
13113   tree meth = current_function_decl;
13114   tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
13115   int error_found = 0;
13116
13117   TREE_TYPE (node) = error_mark_node;
13118   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13119
13120   /* It's invalid to have a return value within a function that is
13121      declared with the keyword void or that is a constructor */
13122   if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
13123     error_found = 1;
13124
13125   /* It's invalid to use a return statement in a static block */
13126   if (IS_CLINIT (current_function_decl))
13127     error_found = 1;
13128
13129   /* It's invalid to have a no return value within a function that
13130      isn't declared with the keyword `void' */
13131   if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
13132     error_found = 2;
13133
13134   if (error_found)
13135     {
13136       if (IS_CLINIT (current_function_decl))
13137         parse_error_context (wfl_operator,
13138                              "`return' inside static initializer.");
13139
13140       else if (!DECL_CONSTRUCTOR_P (meth))
13141         {
13142           char *t = strdup (lang_printable_name (mtype, 0));
13143           parse_error_context (wfl_operator, 
13144                                "`return' with%s value from `%s %s'",
13145                                (error_found == 1 ? "" : "out"), 
13146                                t, lang_printable_name (meth, 0));
13147           free (t);
13148         }
13149       else
13150         parse_error_context (wfl_operator, 
13151                              "`return' with value from constructor `%s'",
13152                              lang_printable_name (meth, 0));
13153       return error_mark_node;
13154     }
13155
13156   /* If we have a return_exp, build a modify expression and expand
13157      it. Note: at that point, the assignment is declared valid, but we
13158      may want to carry some more hacks */
13159   if (return_exp)
13160     {
13161       tree exp = java_complete_tree (return_exp);
13162       tree modify, patched;
13163
13164       /* If the function returned value and EXP are booleans, EXP has
13165       to be converted into the type of DECL_RESULT, which is integer
13166       (see complete_start_java_method) */
13167       if (TREE_TYPE (exp) == boolean_type_node &&
13168           TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
13169         exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
13170
13171       /* `null' can be assigned to a function returning a reference */
13172       if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
13173           exp == null_pointer_node)
13174         exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
13175
13176       if ((patched = patch_string (exp)))
13177         exp = patched;
13178       
13179       modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
13180       EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
13181       modify = java_complete_tree (modify);
13182
13183       if (modify != error_mark_node)
13184         {
13185           TREE_SIDE_EFFECTS (modify) = 1;
13186           TREE_OPERAND (node, 0) = modify;
13187         }
13188       else
13189         return error_mark_node;
13190     }
13191   TREE_TYPE (node) = void_type_node;
13192   TREE_SIDE_EFFECTS (node) = 1;
13193   return node;
13194 }
13195
13196 /* 14.8 The if Statement */
13197
13198 static tree
13199 build_if_else_statement (location, expression, if_body, else_body)
13200      int location;
13201      tree expression, if_body, else_body;
13202 {
13203   tree node;
13204   if (!else_body)
13205     else_body = empty_stmt_node;
13206   node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
13207   EXPR_WFL_LINECOL (node) = location;
13208   node = build_debugable_stmt (location, node);
13209   return node;
13210 }
13211
13212 static tree
13213 patch_if_else_statement (node)
13214      tree node;
13215 {
13216   tree expression = TREE_OPERAND (node, 0);
13217
13218   TREE_TYPE (node) = error_mark_node;
13219   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13220
13221   /* The type of expression must be boolean */
13222   if (TREE_TYPE (expression) != boolean_type_node
13223       && TREE_TYPE (expression) != promoted_boolean_type_node)
13224     {
13225       parse_error_context 
13226         (wfl_operator, 
13227          "Incompatible type for `if'. Can't convert `%s' to `boolean'", 
13228          lang_printable_name (TREE_TYPE (expression), 0));
13229       return error_mark_node;
13230     }
13231   
13232   TREE_TYPE (node) = void_type_node;
13233   TREE_SIDE_EFFECTS (node) = 1;
13234   CAN_COMPLETE_NORMALLY (node)
13235     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
13236     | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
13237   return node;
13238 }
13239
13240 /* 14.6 Labeled Statements */
13241
13242 /* Action taken when a lableled statement is parsed. a new
13243    LABELED_BLOCK_EXPR is created. No statement is attached to the
13244    label, yet.  LABEL can be NULL_TREE for artificially-generated blocks. */
13245
13246 static tree
13247 build_labeled_block (location, label)
13248      int location;
13249      tree label;
13250 {
13251   tree label_name ;
13252   tree label_decl, node;
13253   if (label == NULL_TREE || label == continue_identifier_node)
13254     label_name = label;
13255   else
13256     {
13257       label_name = merge_qualified_name (label_id, label);
13258       /* Issue an error if we try to reuse a label that was previously
13259          declared */
13260       if (IDENTIFIER_LOCAL_VALUE (label_name))
13261         {
13262           EXPR_WFL_LINECOL (wfl_operator) = location;
13263           parse_error_context (wfl_operator, "Declaration of `%s' shadows "
13264                                "a previous label declaration",
13265                                IDENTIFIER_POINTER (label));
13266           EXPR_WFL_LINECOL (wfl_operator) = 
13267             EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
13268           parse_error_context (wfl_operator, "This is the location of the "
13269                                "previous declaration of label `%s'",
13270                                IDENTIFIER_POINTER (label));
13271           java_error_count--;
13272         }
13273     }
13274
13275   label_decl = create_label_decl (label_name);
13276   node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
13277   EXPR_WFL_LINECOL (node) = location;
13278   TREE_SIDE_EFFECTS (node) = 1;
13279   return node;
13280 }
13281
13282 /* A labeled statement LBE is attached a statement.  */
13283
13284 static tree
13285 finish_labeled_statement (lbe, statement)
13286      tree lbe;                  /* Labeled block expr */
13287      tree statement;
13288 {
13289   /* In anyways, tie the loop to its statement */
13290   LABELED_BLOCK_BODY (lbe) = statement;
13291   pop_labeled_block ();
13292   POP_LABELED_BLOCK ();
13293   return lbe;
13294 }
13295
13296 /* 14.10, 14.11, 14.12 Loop Statements */
13297
13298 /* Create an empty LOOP_EXPR and make it the last in the nested loop
13299    list. */
13300
13301 static tree
13302 build_new_loop (loop_body)
13303      tree loop_body;
13304 {
13305   tree loop =  build (LOOP_EXPR, NULL_TREE, loop_body);
13306   TREE_SIDE_EFFECTS (loop) = 1;
13307   PUSH_LOOP (loop);
13308   return loop;
13309 }
13310
13311 /* Create a loop body according to the following structure:
13312      COMPOUND_EXPR
13313        COMPOUND_EXPR            (loop main body)
13314          EXIT_EXPR              (this order is for while/for loops.
13315          LABELED_BLOCK_EXPR      the order is reversed for do loops)
13316            LABEL_DECL           (a continue occuring here branches at the 
13317            BODY                  end of this labeled block)
13318        INCREMENT                (if any)
13319
13320   REVERSED, if non zero, tells that the loop condition expr comes
13321   after the body, like in the do-while loop.
13322
13323   To obtain a loop, the loop body structure described above is
13324   encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
13325
13326    LABELED_BLOCK_EXPR
13327      LABEL_DECL                   (use this label to exit the loop)
13328      LOOP_EXPR
13329        <structure described above> */
13330
13331 static tree
13332 build_loop_body (location, condition, reversed)
13333      int location;
13334      tree condition;
13335      int reversed;
13336 {
13337   tree first, second, body;
13338
13339   condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
13340   EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
13341   condition = build_debugable_stmt (location, condition);
13342   TREE_SIDE_EFFECTS (condition) = 1;
13343
13344   body = build_labeled_block (0, continue_identifier_node);
13345   first = (reversed ? body : condition);
13346   second = (reversed ? condition : body);
13347   return 
13348     build (COMPOUND_EXPR, NULL_TREE, 
13349            build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
13350 }
13351
13352 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
13353    their order) on the current loop. Unlink the current loop from the
13354    loop list.  */
13355
13356 static tree
13357 finish_loop_body (location, condition, body, reversed)
13358      int location;
13359      tree condition, body;
13360      int reversed;
13361 {
13362   tree to_return = ctxp->current_loop;
13363   tree loop_body = LOOP_EXPR_BODY (to_return);
13364   if (condition)
13365     {
13366       tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
13367       /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
13368          The real EXIT_EXPR is one operand further. */
13369       EXPR_WFL_LINECOL (cnode) = location;
13370       /* This one is for accurate error reports */
13371       EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
13372       TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
13373     }
13374   LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
13375   POP_LOOP ();
13376   return to_return;
13377 }
13378
13379 /* Tailored version of finish_loop_body for FOR loops, when FOR
13380    loops feature the condition part */
13381
13382 static tree
13383 finish_for_loop (location, condition, update, body)
13384     int location;
13385     tree condition, update, body;
13386 {
13387   /* Put the condition and the loop body in place */
13388   tree loop = finish_loop_body (location, condition, body, 0);
13389   /* LOOP is the current loop which has been now popped of the loop
13390      stack. Install the update block */
13391   LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
13392   return loop;
13393 }
13394
13395 /* If the loop isn't surrounded by a labeled statement, create one and
13396    insert LOOP as its body.  */
13397
13398 static tree
13399 patch_loop_statement (loop)
13400      tree loop;
13401 {
13402   tree loop_label;
13403   tree block = ctxp->current_labeled_block;
13404   TREE_TYPE (loop) = void_type_node;
13405   if (block != NULL_TREE)
13406     {
13407       tree block_body = LABELED_BLOCK_BODY (block);
13408       if (IS_FOR_LOOP_P (loop))
13409         {
13410           if (TREE_CODE (block_body) == BLOCK)
13411             {
13412               block_body = BLOCK_EXPR_BODY (block_body);
13413               if (block_body == loop
13414                   || (TREE_CODE (block_body) == COMPOUND_EXPR
13415                       && TREE_OPERAND (block_body, 1) == loop))
13416                 return loop;
13417             }
13418         }
13419       else
13420         {
13421           if (block_body == loop)
13422             return loop;
13423         }
13424     }
13425   loop_label = build_labeled_block (0, NULL_TREE);
13426   LABELED_BLOCK_BODY (loop_label) = loop;
13427   PUSH_LABELED_BLOCK (loop_label);
13428   loop = loop_label;
13429   return loop;
13430 }
13431
13432 /* 14.13, 14.14: break and continue Statements */
13433
13434 /* Build a break or a continue statement. a null NAME indicates an
13435    unlabeled break/continue statement.  */
13436
13437 static tree
13438 build_bc_statement (location, is_break, name)
13439      int location, is_break;
13440      tree name;
13441 {
13442   tree break_continue, label_block_expr = NULL_TREE;
13443
13444   if (name)
13445     {
13446       if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE 
13447             (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
13448         /* Null means that we don't have a target for this named
13449            break/continue. In this case, we make the target to be the
13450            label name, so that the error can be reported accuratly in
13451            patch_bc_statement. */
13452         label_block_expr = EXPR_WFL_NODE (name);
13453     }
13454   /* Unlabeled break/continue will be handled during the
13455      break/continue patch operation */
13456   break_continue 
13457     = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
13458
13459   IS_BREAK_STMT_P (break_continue) = is_break;
13460   TREE_SIDE_EFFECTS (break_continue) = 1;
13461   EXPR_WFL_LINECOL (break_continue) = location;
13462   break_continue = build_debugable_stmt (location, break_continue);
13463   return break_continue;
13464 }
13465
13466 /* Verification of a break/continue statement. */
13467
13468 static tree
13469 patch_bc_statement (node)
13470      tree node;
13471 {
13472   tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
13473   tree labeled_block = ctxp->current_labeled_block;
13474   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13475  
13476   /* Having an identifier here means that the target is unknown. */
13477   if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
13478     {
13479       parse_error_context (wfl_operator, "No label definition found for `%s'",
13480                            IDENTIFIER_POINTER (bc_label));
13481       return error_mark_node;
13482     }
13483   if (! IS_BREAK_STMT_P (node))
13484     {
13485       /* It's a continue statement. */
13486       for (;; labeled_block = TREE_CHAIN (labeled_block))
13487         {
13488           if (labeled_block == NULL_TREE)
13489             {
13490               if (bc_label == NULL_TREE)
13491                 parse_error_context (wfl_operator,
13492                                      "`continue' must be in loop");
13493               else
13494                 parse_error_context 
13495                   (wfl_operator, "continue label `%s' does not name a loop",
13496                    IDENTIFIER_POINTER (bc_label));
13497               return error_mark_node;
13498             }
13499           if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
13500                == continue_identifier_node)
13501               && (bc_label == NULL_TREE
13502                   || TREE_CHAIN (labeled_block) == bc_label))
13503             {
13504               bc_label = labeled_block;
13505               break;
13506             }
13507         }
13508     }
13509   else if (!bc_label)
13510     { 
13511       for (;; labeled_block = TREE_CHAIN (labeled_block))
13512         {
13513           if (labeled_block == NULL_TREE)
13514             {
13515               parse_error_context (wfl_operator,
13516                                      "`break' must be in loop or switch");
13517               return error_mark_node;
13518             }
13519           target_stmt = LABELED_BLOCK_BODY (labeled_block);
13520           if (TREE_CODE (target_stmt) == SWITCH_EXPR
13521               || TREE_CODE (target_stmt) == LOOP_EXPR)
13522             {
13523               bc_label = labeled_block;
13524               break;
13525             }
13526         }
13527     }
13528
13529   EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
13530   CAN_COMPLETE_NORMALLY (bc_label) = 1;
13531
13532   /* Our break/continue don't return values. */
13533   TREE_TYPE (node) = void_type_node;
13534   /* Encapsulate the break within a compound statement so that it's
13535      expanded all the times by expand_expr (and not clobered
13536      sometimes, like after a if statement) */
13537   node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
13538   TREE_SIDE_EFFECTS (node) = 1;
13539   return node;
13540 }
13541
13542 /* Process the exit expression belonging to a loop. Its type must be
13543    boolean.  */
13544
13545 static tree
13546 patch_exit_expr (node)
13547      tree node;
13548 {
13549   tree expression = TREE_OPERAND (node, 0);
13550   TREE_TYPE (node) = error_mark_node;
13551   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13552
13553   /* The type of expression must be boolean */
13554   if (TREE_TYPE (expression) != boolean_type_node)
13555     {
13556       parse_error_context 
13557         (wfl_operator, 
13558          "Incompatible type for loop conditional. Can't convert `%s' to "
13559          "`boolean'", 
13560          lang_printable_name (TREE_TYPE (expression), 0));
13561       return error_mark_node;
13562     }
13563   /* Now we know things are allright, invert the condition, fold and
13564      return */
13565   TREE_OPERAND (node, 0) = 
13566     fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
13567
13568   if (! integer_zerop (TREE_OPERAND (node, 0))
13569       && ctxp->current_loop != NULL_TREE
13570       && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
13571     CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
13572   if (! integer_onep (TREE_OPERAND (node, 0)))
13573     CAN_COMPLETE_NORMALLY (node) = 1;
13574
13575
13576   TREE_TYPE (node) = void_type_node;
13577   return node;
13578 }
13579
13580 /* 14.9 Switch statement */
13581
13582 static tree
13583 patch_switch_statement (node)
13584      tree node;
13585 {
13586   tree se = TREE_OPERAND (node, 0), se_type;
13587
13588   /* Complete the switch expression */
13589   se = TREE_OPERAND (node, 0) = java_complete_tree (se);
13590   se_type = TREE_TYPE (se);
13591   /* The type of the switch expression must be char, byte, short or
13592      int */
13593   if (!JINTEGRAL_TYPE_P (se_type))
13594     {
13595       EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13596       parse_error_context (wfl_operator, "Incompatible type for `switch'. "
13597                            "Can't convert `%s' to `int'",
13598                            lang_printable_name (se_type, 0));
13599       /* This is what java_complete_tree will check */
13600       TREE_OPERAND (node, 0) = error_mark_node;
13601       return error_mark_node;
13602     }
13603
13604   TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13605
13606   /* Ready to return */
13607   if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
13608     {
13609       TREE_TYPE (node) = error_mark_node;
13610       return error_mark_node;
13611     }
13612   TREE_TYPE (node) = void_type_node;
13613   TREE_SIDE_EFFECTS (node) = 1;
13614   CAN_COMPLETE_NORMALLY (node)
13615     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)) 
13616       || ! SWITCH_HAS_DEFAULT (node);
13617   return node;
13618 }
13619
13620 /* 14.18 The try statement */
13621
13622 static tree
13623 build_try_statement (location, try_block, catches)
13624      int location;
13625      tree try_block, catches;
13626 {
13627   tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
13628   EXPR_WFL_LINECOL (node) = location;
13629   return node;
13630 }
13631
13632 static tree
13633 build_try_finally_statement (location, try_block, finally)
13634      int location;
13635      tree try_block, finally;
13636 {
13637   tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
13638   EXPR_WFL_LINECOL (node) = location;
13639   return node;
13640 }
13641
13642 static tree
13643 patch_try_statement (node)
13644      tree node;
13645 {
13646   int error_found = 0;
13647   tree try = TREE_OPERAND (node, 0);
13648   /* Exception handlers are considered in left to right order */
13649   tree catch = nreverse (TREE_OPERAND (node, 1));
13650   tree current, caught_type_list = NULL_TREE;
13651
13652   /* Check catch clauses, if any. Every time we find an error, we try
13653      to process the next catch clause. We process the catch clause before
13654      the try block so that when processing the try block we can check thrown
13655      exceptions againts the caught type list. */
13656   for (current = catch; current; current = TREE_CHAIN (current))
13657     {
13658       tree carg_decl, carg_type;
13659       tree sub_current, catch_block, catch_clause;
13660       int unreachable;
13661
13662       /* At this point, the structure of the catch clause is
13663            CATCH_EXPR           (catch node)
13664              BLOCK              (with the decl of the parameter)
13665                COMPOUND_EXPR
13666                  MODIFY_EXPR   (assignment of the catch parameter)
13667                  BLOCK          (catch clause block)
13668        */
13669       catch_clause = TREE_OPERAND (current, 0);
13670       carg_decl = BLOCK_EXPR_DECLS (catch_clause);
13671       carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
13672
13673       /* Catch clauses can't have more than one parameter declared,
13674          but it's already enforced by the grammar. Make sure that the
13675          only parameter of the clause statement in of class Throwable
13676          or a subclass of Throwable, but that was done earlier. The
13677          catch clause parameter type has also been resolved. */
13678       
13679       /* Just make sure that the catch clause parameter type inherits
13680          from java.lang.Throwable */
13681       if (!inherits_from_p (carg_type, throwable_type_node))
13682         {
13683           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
13684           parse_error_context (wfl_operator,
13685                                "Can't catch class `%s'. Catch clause "
13686                                "parameter type must be a subclass of "
13687                                "class `java.lang.Throwable'",
13688                                lang_printable_name (carg_type, 0));
13689           error_found = 1;
13690           continue;
13691         }
13692       
13693       /* Partial check for unreachable catch statement: The catch
13694          clause is reachable iff is no earlier catch block A in
13695          the try statement such that the type of the catch
13696          clause's parameter is the same as or a subclass of the
13697          type of A's parameter */
13698       unreachable = 0;
13699       for (sub_current = catch;
13700            sub_current != current; sub_current = TREE_CHAIN (sub_current))
13701         {
13702           tree sub_catch_clause, decl;
13703           sub_catch_clause = TREE_OPERAND (sub_current, 0);
13704           decl = BLOCK_EXPR_DECLS (sub_catch_clause);
13705
13706           if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
13707             {
13708               EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
13709               parse_error_context 
13710                 (wfl_operator, "`catch' not reached because of the catch "
13711                  "clause at line %d", EXPR_WFL_LINENO (sub_current));
13712               unreachable = error_found = 1;
13713               break;
13714             }
13715         }
13716       /* Complete the catch clause block */
13717       catch_block = java_complete_tree (TREE_OPERAND (current, 0));
13718       if (catch_block == error_mark_node)
13719         {
13720           error_found = 1;
13721           continue;
13722         }
13723       if (CAN_COMPLETE_NORMALLY (catch_block))
13724         CAN_COMPLETE_NORMALLY (node) = 1;
13725       TREE_OPERAND (current, 0) = catch_block;
13726
13727       if (unreachable)
13728         continue;
13729
13730       /* Things to do here: the exception must be thrown */
13731
13732       /* Link this type to the caught type list */
13733       caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
13734     }
13735
13736   PUSH_EXCEPTIONS (caught_type_list);
13737   if ((try = java_complete_tree (try)) == error_mark_node)
13738     error_found = 1;
13739   if (CAN_COMPLETE_NORMALLY (try))
13740     CAN_COMPLETE_NORMALLY (node) = 1;
13741   POP_EXCEPTIONS ();
13742
13743   /* Verification ends here */
13744   if (error_found) 
13745     return error_mark_node;
13746
13747   TREE_OPERAND (node, 0) = try;
13748   TREE_OPERAND (node, 1) = catch;
13749   TREE_TYPE (node) = void_type_node;
13750   return node;
13751 }
13752
13753 /* 14.17 The synchronized Statement */
13754
13755 static tree
13756 patch_synchronized_statement (node, wfl_op1)
13757     tree node, wfl_op1;
13758 {
13759   tree expr = java_complete_tree (TREE_OPERAND (node, 0));
13760   tree block = TREE_OPERAND (node, 1);
13761
13762   tree enter, exit, expr_decl, assignment;
13763
13764   if (expr == error_mark_node)
13765     {
13766       block = java_complete_tree (block);
13767       return expr;
13768     }
13769
13770   /* The TYPE of expr must be a reference type */
13771   if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
13772     {
13773       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
13774       parse_error_context (wfl_operator, "Incompatible type for `synchronized'"
13775                            ". Can't convert `%s' to `java.lang.Object'",
13776                            lang_printable_name (TREE_TYPE (expr), 0));
13777       return error_mark_node;
13778     }
13779
13780   if (flag_emit_xref)
13781     {
13782       TREE_OPERAND (node, 0) = expr;
13783       TREE_OPERAND (node, 1) = java_complete_tree (block);
13784       CAN_COMPLETE_NORMALLY (node) = 1;
13785       return node;
13786     }
13787
13788   /* Generate a try-finally for the synchronized statement, except
13789      that the handler that catches all throw exception calls
13790      _Jv_MonitorExit and then rethrow the exception.
13791      The synchronized statement is then implemented as:
13792      TRY 
13793        {
13794          _Jv_MonitorEnter (expression)
13795          synchronized_block
13796          _Jv_MonitorExit (expression)
13797        }
13798      CATCH_ALL
13799        {
13800          e = _Jv_exception_info ();
13801          _Jv_MonitorExit (expression)
13802          Throw (e);
13803        } */
13804
13805   expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
13806   BUILD_MONITOR_ENTER (enter, expr_decl);
13807   BUILD_MONITOR_EXIT (exit, expr_decl);
13808   CAN_COMPLETE_NORMALLY (enter) = 1;
13809   CAN_COMPLETE_NORMALLY (exit) = 1;
13810   assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
13811   TREE_SIDE_EFFECTS (assignment) = 1;
13812   node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
13813                  build (COMPOUND_EXPR, NULL_TREE,
13814                         build (WITH_CLEANUP_EXPR, NULL_TREE,
13815                                build (COMPOUND_EXPR, NULL_TREE,
13816                                       assignment, enter),
13817                                NULL_TREE, exit),
13818                         block));
13819   node = build_expr_block (node, expr_decl);
13820
13821   return java_complete_tree (node);
13822 }
13823
13824 /* 14.16 The throw Statement */
13825
13826 static tree
13827 patch_throw_statement (node, wfl_op1)
13828     tree node, wfl_op1;
13829 {
13830   tree expr = TREE_OPERAND (node, 0);
13831   tree type = TREE_TYPE (expr);
13832   int unchecked_ok = 0, tryblock_throws_ok = 0;
13833
13834   /* Thrown expression must be assignable to java.lang.Throwable */
13835   if (!try_reference_assignconv (throwable_type_node, expr))
13836     {
13837       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
13838       parse_error_context (wfl_operator, "Can't throw `%s'; it must be a "
13839                            "subclass of class `java.lang.Throwable'",
13840                            lang_printable_name (type, 0));
13841       /* If the thrown expression was a reference, we further the
13842          compile-time check. */
13843       if (!JREFERENCE_TYPE_P (type))
13844         return error_mark_node;
13845     }
13846
13847   /* At least one of the following must be true */
13848
13849   /* The type of the throw expression is a not checked exception,
13850      i.e. is a unchecked expression. */
13851   unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
13852
13853   /* Throw is contained in a try statement and at least one catch
13854      clause can receive the thrown expression or the current method is
13855      declared to throw such an exception. Or, the throw statement is
13856      contained in a method or constructor declaration and the type of
13857      the Expression is assignable to at least one type listed in the
13858      throws clause the declaration. */
13859   SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
13860   if (!unchecked_ok)
13861     tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
13862   if (!(unchecked_ok || tryblock_throws_ok))
13863     {
13864       /* If there is a surrounding try block that has no matching
13865          clatch clause, report it first. A surrounding try block exits
13866          only if there is something after the list of checked
13867          exception thrown by the current function (if any). */
13868       if (IN_TRY_BLOCK_P ())
13869         parse_error_context (wfl_operator, "Checked exception `%s' can't be "
13870                              "caught by any of the catch clause(s) "
13871                              "of the surrounding `try' block",
13872                              lang_printable_name (type, 0));
13873       /* If we have no surrounding try statement and the method doesn't have
13874          any throws, report it now. FIXME */
13875
13876       /* We report that the exception can't be throw from a try block
13877          in all circumstances but when the `throw' is inside a static
13878          block. */
13879       else if (!EXCEPTIONS_P (currently_caught_type_list) 
13880                && !tryblock_throws_ok)
13881         {
13882           if (IS_CLINIT (current_function_decl))
13883             parse_error_context (wfl_operator, "Checked exception `%s' can't "
13884                                  "be thrown in initializer",
13885                                  lang_printable_name (type, 0));
13886           else
13887             parse_error_context (wfl_operator, "Checked exception `%s' isn't "
13888                                  "thrown from a `try' block", 
13889                                  lang_printable_name (type, 0));
13890         }
13891       /* Otherwise, the current method doesn't have the appropriate
13892          throws declaration */
13893       else
13894         parse_error_context (wfl_operator, "Checked exception `%s' doesn't "
13895                              "match any of current method's `throws' "
13896                              "declaration(s)", 
13897                              lang_printable_name (type, 0));
13898       return error_mark_node;
13899     }
13900
13901   if (! flag_emit_class_files && ! flag_emit_xref)
13902     BUILD_THROW (node, expr);
13903
13904   /* If doing xrefs, keep the location where the `throw' was seen. */
13905   if (flag_emit_xref)
13906     EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
13907   return node;
13908 }
13909
13910 /* Check that exception said to be thrown by method DECL can be
13911    effectively caught from where DECL is invoked.  */
13912
13913 static void
13914 check_thrown_exceptions (location, decl)
13915      int location;
13916      tree decl;
13917 {
13918   tree throws;
13919   /* For all the unchecked exceptions thrown by DECL */
13920   for (throws = DECL_FUNCTION_THROWS (decl); throws; 
13921        throws = TREE_CHAIN (throws)) 
13922     if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
13923       {
13924 #if 1
13925         /* Temporary hack to suppresses errors about cloning arrays. FIXME */
13926         if (DECL_NAME (decl) == get_identifier ("clone"))
13927           continue;
13928 #endif
13929         EXPR_WFL_LINECOL (wfl_operator) = location;
13930         parse_error_context 
13931           (wfl_operator, "Exception `%s' must be caught, or it must be "
13932            "declared in the `throws' clause of `%s'", 
13933            lang_printable_name (TREE_VALUE (throws), 0),
13934            IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
13935       }
13936 }
13937
13938 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
13939    try-catch blocks, OR is listed in the `throws' clause of the
13940    current method.  */
13941
13942 static int
13943 check_thrown_exceptions_do (exception)
13944      tree exception;
13945 {
13946   tree list = currently_caught_type_list;
13947   resolve_and_layout (exception, NULL_TREE);
13948   /* First, all the nested try-catch-finally at that stage. The
13949      last element contains `throws' clause exceptions, if any. */
13950   if (IS_UNCHECKED_EXCEPTION_P (exception))
13951     return 1;
13952   while (list)
13953     {
13954       tree caught;
13955       for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
13956         if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
13957           return 1;
13958       list = TREE_CHAIN (list);
13959     }
13960   return 0;
13961 }
13962
13963 static void
13964 purge_unchecked_exceptions (mdecl)
13965      tree mdecl;
13966 {
13967   tree throws = DECL_FUNCTION_THROWS (mdecl);
13968   tree new = NULL_TREE;
13969
13970   while (throws)
13971     {
13972       tree next = TREE_CHAIN (throws);
13973       if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
13974         {
13975           TREE_CHAIN (throws) = new;
13976           new = throws;
13977         }
13978       throws = next;
13979     }
13980   /* List is inverted here, but it doesn't matter */
13981   DECL_FUNCTION_THROWS (mdecl) = new;
13982 }
13983
13984 /* 15.24 Conditional Operator ?: */
13985
13986 static tree
13987 patch_conditional_expr (node, wfl_cond, wfl_op1)
13988      tree node, wfl_cond, wfl_op1;
13989 {
13990   tree cond = TREE_OPERAND (node, 0);
13991   tree op1 = TREE_OPERAND (node, 1);
13992   tree op2 = TREE_OPERAND (node, 2);
13993   tree resulting_type = NULL_TREE;
13994   tree t1, t2, patched;
13995   int error_found = 0;
13996
13997   /* Operands of ?: might be StringBuffers crafted as a result of a
13998      string concatenation. Obtain a descent operand here.  */
13999   if ((patched = patch_string (op1)))
14000     TREE_OPERAND (node, 1) = op1 = patched;
14001   if ((patched = patch_string (op2)))
14002     TREE_OPERAND (node, 2) = op2 = patched;
14003
14004   t1 = TREE_TYPE (op1);
14005   t2 = TREE_TYPE (op2);
14006
14007   /* The first expression must be a boolean */
14008   if (TREE_TYPE (cond) != boolean_type_node)
14009     {
14010       SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
14011       parse_error_context (wfl_operator, "Incompatible type for `?:'. Can't "
14012                            "convert `%s' to `boolean'",
14013                            lang_printable_name (TREE_TYPE (cond), 0));
14014       error_found = 1;
14015     }
14016
14017   /* Second and third can be numeric, boolean (i.e. primitive),
14018      references or null. Anything else results in an error */
14019   if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
14020         || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node) 
14021             && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
14022         || (t1 == boolean_type_node && t2 == boolean_type_node)))
14023     error_found = 1;
14024
14025   /* Determine the type of the conditional expression. Same types are
14026      easy to deal with */
14027   else if (t1 == t2)
14028     resulting_type = t1;
14029
14030   /* There are different rules for numeric types */
14031   else if (JNUMERIC_TYPE_P (t1))
14032     {
14033       /* if byte/short found, the resulting type is short */
14034       if ((t1 == byte_type_node && t2 == short_type_node)
14035           || (t1 == short_type_node && t2 == byte_type_node))
14036         resulting_type = short_type_node;
14037
14038       /* If t1 is a constant int and t2 is of type byte, short or char
14039          and t1's value fits in t2, then the resulting type is t2 */
14040       else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
14041           && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
14042         resulting_type = t2;
14043
14044       /* If t2 is a constant int and t1 is of type byte, short or char
14045          and t2's value fits in t1, then the resulting type is t1 */
14046       else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
14047           && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
14048         resulting_type = t1;
14049
14050       /* Otherwise, binary numeric promotion is applied and the
14051          resulting type is the promoted type of operand 1 and 2 */
14052       else 
14053         resulting_type = binary_numeric_promotion (t1, t2, 
14054                                                    &TREE_OPERAND (node, 1), 
14055                                                    &TREE_OPERAND (node, 2));
14056     }
14057
14058   /* Cases of a reference and a null type */
14059   else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
14060     resulting_type = t1;
14061
14062   else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
14063     resulting_type = t2;
14064
14065   /* Last case: different reference types. If a type can be converted
14066      into the other one by assignment conversion, the latter
14067      determines the type of the expression */
14068   else if ((resulting_type = try_reference_assignconv (t1, op2)))
14069     resulting_type = promote_type (t1);
14070
14071   else if ((resulting_type = try_reference_assignconv (t2, op1)))
14072     resulting_type = promote_type (t2);
14073
14074   /* If we don't have any resulting type, we're in trouble */
14075   if (!resulting_type)
14076     {
14077       char *t = strdup (lang_printable_name (t1, 0));
14078       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
14079       parse_error_context (wfl_operator, "Incompatible type for `?:'. Can't "
14080                            "convert `%s' to `%s'", t,
14081                            lang_printable_name (t2, 0));
14082       free (t);
14083       error_found = 1;
14084     }
14085
14086   if (error_found)
14087     {
14088       TREE_TYPE (node) = error_mark_node;
14089       return error_mark_node;
14090     }
14091
14092   TREE_TYPE (node) = resulting_type;
14093   TREE_SET_CODE (node, COND_EXPR);
14094   CAN_COMPLETE_NORMALLY (node) = 1;
14095   return node;
14096 }
14097
14098 /* Try to constant fold NODE.
14099    If NODE is not a constant expression, return NULL_EXPR.
14100    CONTEXT is a static final VAR_DECL whose initializer we are folding. */
14101
14102 static tree
14103 fold_constant_for_init (node, context)
14104      tree node;
14105      tree context;
14106 {
14107   tree op0, op1, val;
14108   enum tree_code code = TREE_CODE (node);
14109
14110   if (code == STRING_CST)
14111     return node;
14112
14113   if (code == INTEGER_CST || code == REAL_CST)
14114     return convert (TREE_TYPE (context), node);
14115   if (TREE_TYPE (node) != NULL_TREE && code != VAR_DECL)
14116     return NULL_TREE;
14117
14118   switch (code)
14119     {
14120     case PLUS_EXPR:
14121     case MINUS_EXPR:
14122     case MULT_EXPR:
14123     case TRUNC_MOD_EXPR:
14124     case RDIV_EXPR:
14125     case LSHIFT_EXPR:
14126     case RSHIFT_EXPR:
14127     case URSHIFT_EXPR:
14128     case BIT_AND_EXPR:
14129     case BIT_XOR_EXPR:
14130     case BIT_IOR_EXPR:
14131     case TRUTH_ANDIF_EXPR:
14132     case TRUTH_ORIF_EXPR:
14133     case EQ_EXPR: 
14134     case NE_EXPR:
14135     case GT_EXPR:
14136     case GE_EXPR:
14137     case LT_EXPR:
14138     case LE_EXPR:
14139       op0 = TREE_OPERAND (node, 0);
14140       op1 = TREE_OPERAND (node, 1);
14141       val = fold_constant_for_init (op0, context);
14142       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14143         return NULL_TREE;
14144       TREE_OPERAND (node, 0) = val;
14145       val = fold_constant_for_init (op1, context);
14146       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14147         return NULL_TREE;
14148       TREE_OPERAND (node, 1) = val;
14149       return patch_binop (node, op0, op1);
14150
14151     case UNARY_PLUS_EXPR:
14152     case NEGATE_EXPR:
14153     case TRUTH_NOT_EXPR:
14154     case BIT_NOT_EXPR:
14155     case CONVERT_EXPR:
14156       op0 = TREE_OPERAND (node, 0);
14157       val = fold_constant_for_init (op0, context);
14158       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14159         return NULL_TREE;
14160       TREE_OPERAND (node, 0) = val;
14161       return patch_unaryop (node, op0);
14162       break;
14163
14164     case COND_EXPR:
14165       val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
14166       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14167         return NULL_TREE;
14168       TREE_OPERAND (node, 0) = val;
14169       val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
14170       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14171         return NULL_TREE;
14172       TREE_OPERAND (node, 1) = val;
14173       val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
14174       if (val == NULL_TREE || ! TREE_CONSTANT (val))
14175         return NULL_TREE;
14176       TREE_OPERAND (node, 2) = val;
14177       return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
14178         : TREE_OPERAND (node, 2);
14179
14180     case VAR_DECL:
14181       if (! FIELD_STATIC (node) || ! FIELD_FINAL (node)
14182           || DECL_INITIAL (node) == NULL_TREE)
14183         return NULL_TREE;
14184       val = DECL_INITIAL (node);
14185       /* Guard against infinite recursion. */
14186       DECL_INITIAL (node) = NULL_TREE;
14187       val = fold_constant_for_init (val, node);
14188       DECL_INITIAL (node) = val;
14189       return val;
14190
14191     case EXPR_WITH_FILE_LOCATION:
14192       /* Compare java_complete_tree and resolve_expression_name. */
14193       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
14194           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
14195         {
14196           tree name = EXPR_WFL_NODE (node);
14197           tree decl;
14198           if (PRIMARY_P (node))
14199             return NULL_TREE;
14200           else if (! QUALIFIED_P (name))
14201             {
14202               decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
14203               if (decl == NULL_TREE || ! FIELD_STATIC (decl))
14204                 return NULL_TREE;
14205               return fold_constant_for_init (decl, decl);
14206             }
14207           else
14208             {
14209               /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
14210               qualify_ambiguous_name (node);
14211               if (resolve_field_access (node, &decl, NULL)
14212                   && decl != NULL_TREE)
14213                 return fold_constant_for_init (decl, decl);
14214               return NULL_TREE;
14215             }
14216         }
14217       else
14218         {
14219           op0 = TREE_OPERAND (node, 0);
14220           val = fold_constant_for_init (op0, context);
14221           if (val == NULL_TREE || ! TREE_CONSTANT (val))
14222             return NULL_TREE;
14223           TREE_OPERAND (node, 0) = val;
14224           return val;
14225         }
14226
14227 #ifdef USE_COMPONENT_REF
14228     case IDENTIFIER:
14229     case COMPONENT_REF:
14230       ?;
14231 #endif
14232
14233     default:
14234       return NULL_TREE;
14235     }
14236 }
14237
14238 #ifdef USE_COMPONENT_REF
14239 /* Context is 'T' for TypeName, 'P' for PackageName,
14240    'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
14241
14242 tree
14243 resolve_simple_name (name, context)
14244      tree name;
14245      int context;
14246 {
14247 }
14248
14249 tree
14250 resolve_qualified_name (name, context)
14251      tree name;
14252      int context;
14253 {
14254 }
14255 #endif