]>
Commit | Line | Data |
---|---|---|
8b27f225 | 1 | |
89004479 | 2 | /* A Bison parser, made from ./parse.y |
eb69a686 JH |
3 | by GNU Bison version 1.25 |
4 | */ | |
8b27f225 PB |
5 | |
6 | #define YYBISON 1 /* Identify Bison output. */ | |
7 | ||
2aa11e97 APB |
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 | |
eb69a686 JH |
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 | |
8b27f225 | 122 | |
89004479 | 123 | #line 48 "./parse.y" |
8b27f225 | 124 | |
8b27f225 | 125 | #include "config.h" |
bc3ca41b PB |
126 | #include "system.h" |
127 | #include <dirent.h> | |
8b27f225 PB |
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" | |
5e942c50 | 138 | #include "convert.h" |
63a212ed | 139 | #include "buffer.h" |
f099f336 | 140 | #include "xref.h" |
b384405b | 141 | #include "function.h" |
138657ec | 142 | #include "except.h" |
0ae70c6a | 143 | #include "defaults.h" |
8b27f225 | 144 | |
82371d41 | 145 | /* Local function prototypes */ |
df32d2ce KG |
146 | static char *java_accstring_lookup PARAMS ((int)); |
147 | static void classitf_redefinition_error PARAMS ((const char *,tree, tree, tree)); | |
148 | static void variable_redefinition_error PARAMS ((tree, tree, tree, int)); | |
149 | static void check_modifiers PARAMS ((const char *, int, int)); | |
150 | static tree create_class PARAMS ((int, tree, tree, tree)); | |
151 | static tree create_interface PARAMS ((int, tree, tree)); | |
152 | static tree find_field PARAMS ((tree, tree)); | |
153 | static tree lookup_field_wrapper PARAMS ((tree, tree)); | |
154 | static int duplicate_declaration_error_p PARAMS ((tree, tree, tree)); | |
155 | static void register_fields PARAMS ((int, tree, tree)); | |
156 | static tree parser_qualified_classname PARAMS ((tree)); | |
157 | static int parser_check_super PARAMS ((tree, tree, tree)); | |
158 | static int parser_check_super_interface PARAMS ((tree, tree, tree)); | |
159 | static void check_modifiers_consistency PARAMS ((int)); | |
160 | static tree lookup_cl PARAMS ((tree)); | |
161 | static tree lookup_java_method2 PARAMS ((tree, tree, int)); | |
162 | static tree method_header PARAMS ((int, tree, tree, tree)); | |
163 | static void fix_method_argument_names PARAMS ((tree ,tree)); | |
164 | static tree method_declarator PARAMS ((tree, tree)); | |
165 | static void parse_warning_context PARAMS ((tree cl, const char *msg, ...)) | |
d4476be2 | 166 | ATTRIBUTE_PRINTF_2; |
df32d2ce KG |
167 | static void issue_warning_error_from_context PARAMS ((tree, const char *msg, va_list)); |
168 | static void parse_ctor_invocation_error PARAMS ((void)); | |
169 | static tree parse_jdk1_1_error PARAMS ((const char *)); | |
170 | static void complete_class_report_errors PARAMS ((jdep *)); | |
171 | static int process_imports PARAMS ((void)); | |
172 | static void read_import_dir PARAMS ((tree)); | |
173 | static int find_in_imports_on_demand PARAMS ((tree)); | |
174 | static int find_in_imports PARAMS ((tree)); | |
175 | static int check_pkg_class_access PARAMS ((tree, tree)); | |
176 | static tree resolve_package PARAMS ((tree, tree *)); | |
177 | static tree lookup_package_type PARAMS ((const char *, int)); | |
178 | static tree lookup_package_type_and_set_next PARAMS ((const char *, int, tree *)); | |
179 | static tree resolve_class PARAMS ((tree, tree, tree)); | |
180 | static void declare_local_variables PARAMS ((int, tree, tree)); | |
181 | static void source_start_java_method PARAMS ((tree)); | |
182 | static void source_end_java_method PARAMS ((void)); | |
183 | static void expand_start_java_method PARAMS ((tree)); | |
184 | static tree find_name_in_single_imports PARAMS ((tree)); | |
185 | static void check_abstract_method_header PARAMS ((tree)); | |
186 | static tree lookup_java_interface_method2 PARAMS ((tree, tree)); | |
187 | static tree resolve_expression_name PARAMS ((tree, tree *)); | |
188 | static tree maybe_create_class_interface_decl PARAMS ((tree, tree, tree)); | |
189 | static int check_class_interface_creation PARAMS ((int, int, tree, | |
82371d41 | 190 | tree, tree, tree)); |
df32d2ce | 191 | static tree patch_method_invocation PARAMS ((tree, tree, tree, |
ac825856 | 192 | int *, tree *)); |
df32d2ce KG |
193 | static int breakdown_qualified PARAMS ((tree *, tree *, tree)); |
194 | static tree resolve_and_layout PARAMS ((tree, tree)); | |
195 | static tree resolve_no_layout PARAMS ((tree, tree)); | |
196 | static int invocation_mode PARAMS ((tree, int)); | |
197 | static tree find_applicable_accessible_methods_list PARAMS ((int, tree, | |
82371d41 | 198 | tree, tree)); |
df32d2ce | 199 | static void search_applicable_methods_list PARAMS ((int, tree, tree, tree, |
cc596f8c | 200 | tree *, tree *)); |
df32d2ce KG |
201 | static tree find_most_specific_methods_list PARAMS ((tree)); |
202 | static int argument_types_convertible PARAMS ((tree, tree)); | |
203 | static tree patch_invoke PARAMS ((tree, tree, tree)); | |
204 | static tree lookup_method_invoke PARAMS ((int, tree, tree, tree, tree)); | |
205 | static tree register_incomplete_type PARAMS ((int, tree, tree, tree)); | |
206 | static tree obtain_incomplete_type PARAMS ((tree)); | |
207 | static tree java_complete_lhs PARAMS ((tree)); | |
208 | static tree java_complete_tree PARAMS ((tree)); | |
209 | static int java_pre_expand_clinit PARAMS ((tree)); | |
210 | static void java_complete_expand_method PARAMS ((tree)); | |
211 | static int unresolved_type_p PARAMS ((tree, tree *)); | |
212 | static void create_jdep_list PARAMS ((struct parser_ctxt *)); | |
213 | static tree build_expr_block PARAMS ((tree, tree)); | |
214 | static tree enter_block PARAMS ((void)); | |
215 | static tree enter_a_block PARAMS ((tree)); | |
216 | static tree exit_block PARAMS ((void)); | |
217 | static tree lookup_name_in_blocks PARAMS ((tree)); | |
218 | static void maybe_absorb_scoping_blocks PARAMS ((void)); | |
219 | static tree build_method_invocation PARAMS ((tree, tree)); | |
220 | static tree build_new_invocation PARAMS ((tree, tree)); | |
221 | static tree build_assignment PARAMS ((int, int, tree, tree)); | |
222 | static tree build_binop PARAMS ((enum tree_code, int, tree, tree)); | |
223 | static int check_final_assignment PARAMS ((tree ,tree)); | |
224 | static tree patch_assignment PARAMS ((tree, tree, tree )); | |
225 | static tree patch_binop PARAMS ((tree, tree, tree)); | |
226 | static tree build_unaryop PARAMS ((int, int, tree)); | |
227 | static tree build_incdec PARAMS ((int, int, tree, int)); | |
228 | static tree patch_unaryop PARAMS ((tree, tree)); | |
229 | static tree build_cast PARAMS ((int, tree, tree)); | |
230 | static tree build_null_of_type PARAMS ((tree)); | |
231 | static tree patch_cast PARAMS ((tree, tree)); | |
232 | static int valid_ref_assignconv_cast_p PARAMS ((tree, tree, int)); | |
233 | static int valid_builtin_assignconv_identity_widening_p PARAMS ((tree, tree)); | |
234 | static int valid_cast_to_p PARAMS ((tree, tree)); | |
235 | static int valid_method_invocation_conversion_p PARAMS ((tree, tree)); | |
236 | static tree try_builtin_assignconv PARAMS ((tree, tree, tree)); | |
237 | static tree try_reference_assignconv PARAMS ((tree, tree)); | |
238 | static tree build_unresolved_array_type PARAMS ((tree)); | |
239 | static tree build_array_from_name PARAMS ((tree, tree, tree, tree *)); | |
240 | static tree build_array_ref PARAMS ((int, tree, tree)); | |
241 | static tree patch_array_ref PARAMS ((tree)); | |
242 | static tree make_qualified_name PARAMS ((tree, tree, int)); | |
243 | static tree merge_qualified_name PARAMS ((tree, tree)); | |
244 | static tree make_qualified_primary PARAMS ((tree, tree, int)); | |
245 | static int resolve_qualified_expression_name PARAMS ((tree, tree *, | |
82371d41 | 246 | tree *, tree *)); |
df32d2ce KG |
247 | static void qualify_ambiguous_name PARAMS ((tree)); |
248 | static void maybe_generate_clinit PARAMS ((void)); | |
249 | static tree resolve_field_access PARAMS ((tree, tree *, tree *)); | |
250 | static tree build_newarray_node PARAMS ((tree, tree, int)); | |
251 | static tree patch_newarray PARAMS ((tree)); | |
252 | static tree resolve_type_during_patch PARAMS ((tree)); | |
253 | static tree build_this PARAMS ((int)); | |
254 | static tree build_return PARAMS ((int, tree)); | |
255 | static tree patch_return PARAMS ((tree)); | |
256 | static tree maybe_access_field PARAMS ((tree, tree, tree)); | |
257 | static int complete_function_arguments PARAMS ((tree)); | |
258 | static int check_for_static_method_reference PARAMS ((tree, tree, tree, tree, tree)); | |
259 | static int not_accessible_p PARAMS ((tree, tree, int)); | |
260 | static void check_deprecation PARAMS ((tree, tree)); | |
261 | static int class_in_current_package PARAMS ((tree)); | |
262 | static tree build_if_else_statement PARAMS ((int, tree, tree, tree)); | |
263 | static tree patch_if_else_statement PARAMS ((tree)); | |
264 | static tree add_stmt_to_compound PARAMS ((tree, tree, tree)); | |
265 | static tree add_stmt_to_block PARAMS ((tree, tree, tree)); | |
266 | static tree patch_exit_expr PARAMS ((tree)); | |
267 | static tree build_labeled_block PARAMS ((int, tree)); | |
268 | static tree finish_labeled_statement PARAMS ((tree, tree)); | |
269 | static tree build_bc_statement PARAMS ((int, int, tree)); | |
270 | static tree patch_bc_statement PARAMS ((tree)); | |
271 | static tree patch_loop_statement PARAMS ((tree)); | |
272 | static tree build_new_loop PARAMS ((tree)); | |
273 | static tree build_loop_body PARAMS ((int, tree, int)); | |
274 | static tree finish_loop_body PARAMS ((int, tree, tree, int)); | |
275 | static tree build_debugable_stmt PARAMS ((int, tree)); | |
276 | static tree finish_for_loop PARAMS ((int, tree, tree, tree)); | |
277 | static tree patch_switch_statement PARAMS ((tree)); | |
278 | static tree string_constant_concatenation PARAMS ((tree, tree)); | |
279 | static tree build_string_concatenation PARAMS ((tree, tree)); | |
280 | static tree patch_string_cst PARAMS ((tree)); | |
281 | static tree patch_string PARAMS ((tree)); | |
282 | static tree build_try_statement PARAMS ((int, tree, tree)); | |
283 | static tree build_try_finally_statement PARAMS ((int, tree, tree)); | |
284 | static tree patch_try_statement PARAMS ((tree)); | |
285 | static tree patch_synchronized_statement PARAMS ((tree, tree)); | |
286 | static tree patch_throw_statement PARAMS ((tree, tree)); | |
287 | static void check_thrown_exceptions PARAMS ((int, tree)); | |
288 | static int check_thrown_exceptions_do PARAMS ((tree)); | |
289 | static void purge_unchecked_exceptions PARAMS ((tree)); | |
290 | static void check_throws_clauses PARAMS ((tree, tree, tree)); | |
291 | static void finish_method_declaration PARAMS ((tree)); | |
292 | static tree build_super_invocation PARAMS ((tree)); | |
293 | static int verify_constructor_circularity PARAMS ((tree, tree)); | |
294 | static char *constructor_circularity_msg PARAMS ((tree, tree)); | |
295 | static tree build_this_super_qualified_invocation PARAMS ((int, tree, tree, | |
82371d41 | 296 | int, int)); |
df32d2ce KG |
297 | static const char *get_printable_method_name PARAMS ((tree)); |
298 | static tree patch_conditional_expr PARAMS ((tree, tree, tree)); | |
299 | static void maybe_generate_finit PARAMS ((void)); | |
300 | static void fix_constructors PARAMS ((tree)); | |
301 | static int verify_constructor_super PARAMS ((void)); | |
302 | static tree create_artificial_method PARAMS ((tree, int, tree, tree, tree)); | |
303 | static void start_artificial_method_body PARAMS ((tree)); | |
304 | static void end_artificial_method_body PARAMS ((tree)); | |
305 | static int check_method_redefinition PARAMS ((tree, tree)); | |
306 | static int reset_method_name PARAMS ((tree)); | |
307 | static void java_check_regular_methods PARAMS ((tree)); | |
308 | static void java_check_abstract_methods PARAMS ((tree)); | |
309 | static tree maybe_build_primttype_type_ref PARAMS ((tree, tree)); | |
310 | static void unreachable_stmt_error PARAMS ((tree)); | |
311 | static tree find_expr_with_wfl PARAMS ((tree)); | |
312 | static void missing_return_error PARAMS ((tree)); | |
313 | static tree build_new_array_init PARAMS ((int, tree)); | |
314 | static tree patch_new_array_init PARAMS ((tree, tree)); | |
315 | static tree maybe_build_array_element_wfl PARAMS ((tree)); | |
316 | static int array_constructor_check_entry PARAMS ((tree, tree)); | |
317 | static const char *purify_type_name PARAMS ((const char *)); | |
318 | static tree fold_constant_for_init PARAMS ((tree, tree)); | |
319 | static tree strip_out_static_field_access_decl PARAMS ((tree)); | |
320 | static jdeplist *reverse_jdep_list PARAMS ((struct parser_ctxt *)); | |
321 | static void static_ref_err PARAMS ((tree, tree, tree)); | |
322 | static void parser_add_interface PARAMS ((tree, tree, tree)); | |
323 | static void add_superinterfaces PARAMS ((tree, tree)); | |
324 | static tree jdep_resolve_class PARAMS ((jdep *)); | |
325 | static int note_possible_classname PARAMS ((const char *, int)); | |
326 | static void java_complete_expand_methods PARAMS ((void)); | |
327 | static void java_expand_finals PARAMS ((void)); | |
328 | static tree cut_identifier_in_qualified PARAMS ((tree)); | |
329 | static tree java_stabilize_reference PARAMS ((tree)); | |
330 | static tree do_unary_numeric_promotion PARAMS ((tree)); | |
331 | static char * operator_string PARAMS ((tree)); | |
332 | static tree do_merge_string_cste PARAMS ((tree, const char *, int, int)); | |
333 | static tree merge_string_cste PARAMS ((tree, tree, int)); | |
334 | static tree java_refold PARAMS ((tree)); | |
335 | static int java_decl_equiv PARAMS ((tree, tree)); | |
336 | static int binop_compound_p PARAMS ((enum tree_code)); | |
337 | static tree search_loop PARAMS ((tree)); | |
338 | static int labeled_block_contains_loop_p PARAMS ((tree, tree)); | |
339 | static void check_abstract_method_definitions PARAMS ((int, tree, tree)); | |
340 | static void java_check_abstract_method_definitions PARAMS ((tree)); | |
341 | static void java_debug_context_do PARAMS ((int)); | |
82371d41 | 342 | |
8b27f225 PB |
343 | /* Number of error found so far. */ |
344 | int java_error_count; | |
345 | /* Number of warning found so far. */ | |
346 | int java_warning_count; | |
ce6e9147 APB |
347 | /* Tell when not to fold, when doing xrefs */ |
348 | int do_not_fold; | |
8b27f225 PB |
349 | |
350 | /* The current parser context */ | |
d4370213 | 351 | struct parser_ctxt *ctxp; |
8b27f225 | 352 | |
d4370213 | 353 | /* List of things that were analyzed for which code will be generated */ |
b351b287 APB |
354 | static struct parser_ctxt *ctxp_for_generation = NULL; |
355 | ||
8b27f225 PB |
356 | /* binop_lookup maps token to tree_code. It is used where binary |
357 | operations are involved and required by the parser. RDIV_EXPR | |
358 | covers both integral/floating point division. The code is changed | |
359 | once the type of both operator is worked out. */ | |
360 | ||
361 | static enum tree_code binop_lookup[19] = | |
362 | { | |
363 | PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR, | |
364 | LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR, | |
365 | BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR, | |
366 | TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR, | |
367 | EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR, | |
368 | }; | |
369 | #define BINOP_LOOKUP(VALUE) \ | |
370 | binop_lookup [((VALUE) - PLUS_TK)% \ | |
371 | (sizeof (binop_lookup) / sizeof (binop_lookup[0]))] | |
372 | ||
5cbdba64 APB |
373 | /* This is the end index for binary operators that can also be used |
374 | in compound assignements. */ | |
375 | #define BINOP_COMPOUND_CANDIDATES 11 | |
376 | ||
8b27f225 PB |
377 | /* Fake WFL used to report error message. It is initialized once if |
378 | needed and reused with it's location information is overriden. */ | |
12472854 | 379 | tree wfl_operator = NULL_TREE; |
8b27f225 PB |
380 | |
381 | /* The "$L" identifier we use to create labels. */ | |
382 | static tree label_id = NULL_TREE; | |
383 | ||
384 | /* The "StringBuffer" identifier used for the String `+' operator. */ | |
385 | static tree wfl_string_buffer = NULL_TREE; | |
386 | ||
387 | /* The "append" identifier used for String `+' operator. */ | |
388 | static tree wfl_append = NULL_TREE; | |
389 | ||
390 | /* The "toString" identifier used for String `+' operator. */ | |
391 | static tree wfl_to_string = NULL_TREE; | |
392 | ||
ba179f9f APB |
393 | /* The "java.lang" import qualified name. */ |
394 | static tree java_lang_id = NULL_TREE; | |
395 | ||
09ed0f70 APB |
396 | /* The "java.lang.Cloneable" qualified name. */ |
397 | static tree java_lang_cloneable = NULL_TREE; | |
398 | ||
f099f336 APB |
399 | /* Context and flag for static blocks */ |
400 | static tree current_static_block = NULL_TREE; | |
401 | ||
ee07f4f4 APB |
402 | /* The list of all packages we've seen so far */ |
403 | static tree package_list = NULL_TREE; | |
f099f336 | 404 | |
ee07f4f4 | 405 | |
51149cc8 | 406 | #line 331 "./parse.y" |
8b27f225 PB |
407 | typedef union { |
408 | tree node; | |
409 | int sub_token; | |
410 | struct { | |
411 | int token; | |
412 | int location; | |
413 | } operator; | |
414 | int value; | |
415 | } YYSTYPE; | |
51149cc8 | 416 | #line 341 "./parse.y" |
9ee9b555 KG |
417 | |
418 | #include "lex.c" | |
8b27f225 PB |
419 | #ifndef YYDEBUG |
420 | #define YYDEBUG 1 | |
421 | #endif | |
422 | ||
423 | #include <stdio.h> | |
424 | ||
425 | #ifndef __cplusplus | |
426 | #ifndef __STDC__ | |
427 | #define const | |
428 | #endif | |
429 | #endif | |
430 | ||
431 | ||
432 | ||
efa0a23f | 433 | #define YYFINAL 776 |
8b27f225 PB |
434 | #define YYFLAG -32768 |
435 | #define YYNTBASE 110 | |
436 | ||
eb69a686 | 437 | #define YYTRANSLATE(x) ((unsigned)(x) <= 364 ? yytranslate[x] : 266) |
8b27f225 PB |
438 | |
439 | static const char yytranslate[] = { 0, | |
440 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
441 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
442 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
443 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
444 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
445 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
446 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
447 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
448 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
449 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
450 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
451 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
452 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
453 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
454 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
455 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
456 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
457 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
458 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
459 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
460 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
461 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
462 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
463 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
464 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
eb69a686 JH |
465 | 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, |
466 | 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, | |
467 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, | |
468 | 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, | |
469 | 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, | |
470 | 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, | |
471 | 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, | |
472 | 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, | |
473 | 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, | |
474 | 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, | |
475 | 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, | |
476 | 106, 107, 108, 109 | |
8b27f225 PB |
477 | }; |
478 | ||
479 | #if YYDEBUG != 0 | |
480 | static const short yyprhs[] = { 0, | |
481 | 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, | |
482 | 20, 22, 24, 26, 28, 30, 32, 34, 38, 42, | |
483 | 46, 50, 54, 56, 58, 60, 64, 66, 67, 69, | |
484 | 71, 73, 76, 79, 82, 86, 88, 91, 93, 96, | |
485 | 100, 103, 107, 109, 111, 115, 118, 122, 128, 133, | |
486 | 139, 141, 143, 145, 147, 149, 152, 153, 161, 162, | |
487 | 169, 173, 176, 180, 185, 186, 189, 193, 196, 197, | |
488 | 200, 203, 205, 209, 213, 216, 220, 222, 225, 227, | |
0b4d333e APB |
489 | 229, 231, 233, 235, 238, 240, 242, 244, 248, 253, |
490 | 255, 259, 263, 265, 269, 273, 278, 280, 284, 287, | |
491 | 291, 295, 297, 299, 300, 304, 307, 311, 315, 320, | |
492 | 325, 328, 332, 335, 339, 342, 346, 351, 355, 359, | |
493 | 363, 365, 369, 373, 376, 380, 383, 387, 388, 391, | |
494 | 394, 396, 400, 404, 406, 409, 411, 414, 418, 420, | |
495 | 421, 425, 428, 432, 436, 441, 444, 448, 452, 457, | |
2e5eb5c5 APB |
496 | 459, 462, 467, 473, 481, 488, 490, 492, 493, 498, |
497 | 499, 505, 506, 512, 513, 520, 524, 529, 532, 536, | |
498 | 539, 543, 546, 550, 552, 555, 557, 559, 561, 563, | |
499 | 565, 568, 571, 574, 578, 583, 585, 589, 593, 596, | |
500 | 600, 602, 604, 606, 609, 611, 613, 615, 618, 621, | |
501 | 625, 627, 629, 631, 633, 635, 637, 639, 641, 643, | |
502 | 645, 647, 649, 651, 653, 655, 657, 659, 661, 663, | |
503 | 665, 667, 669, 671, 674, 677, 680, 683, 686, 689, | |
504 | 692, 695, 699, 704, 709, 715, 720, 726, 733, 741, | |
505 | 748, 750, 752, 754, 756, 758, 760, 762, 768, 771, | |
506 | 775, 780, 788, 796, 797, 801, 806, 809, 813, 819, | |
507 | 822, 826, 830, 835, 837, 840, 843, 845, 848, 852, | |
508 | 855, 858, 862, 865, 870, 873, 876, 880, 885, 888, | |
509 | 890, 898, 906, 913, 917, 923, 928, 936, 943, 946, | |
510 | 949, 953, 956, 957, 959, 961, 964, 965, 967, 969, | |
511 | 973, 977, 980, 984, 987, 991, 994, 998, 1001, 1005, | |
512 | 1008, 1012, 1015, 1019, 1023, 1026, 1030, 1036, 1042, 1045, | |
513 | 1050, 1054, 1056, 1060, 1064, 1069, 1072, 1074, 1077, 1080, | |
514 | 1085, 1088, 1092, 1097, 1100, 1103, 1105, 1107, 1109, 1111, | |
515 | 1115, 1117, 1119, 1121, 1123, 1127, 1131, 1135, 1139, 1143, | |
516 | 1147, 1151, 1155, 1161, 1166, 1173, 1179, 1184, 1190, 1196, | |
517 | 1203, 1207, 1211, 1216, 1222, 1225, 1229, 1233, 1237, 1239, | |
518 | 1243, 1247, 1251, 1255, 1260, 1265, 1270, 1275, 1279, 1283, | |
519 | 1285, 1288, 1292, 1296, 1299, 1302, 1306, 1310, 1314, 1318, | |
520 | 1321, 1325, 1330, 1336, 1343, 1349, 1356, 1361, 1366, 1371, | |
521 | 1376, 1380, 1385, 1389, 1394, 1396, 1398, 1400, 1402, 1405, | |
522 | 1408, 1410, 1412, 1415, 1418, 1420, 1423, 1426, 1429, 1432, | |
523 | 1435, 1438, 1440, 1443, 1446, 1448, 1451, 1454, 1460, 1465, | |
524 | 1470, 1476, 1481, 1484, 1490, 1495, 1501, 1503, 1507, 1511, | |
525 | 1515, 1519, 1523, 1527, 1529, 1533, 1537, 1541, 1545, 1547, | |
526 | 1551, 1555, 1559, 1563, 1567, 1571, 1573, 1577, 1581, 1585, | |
527 | 1589, 1593, 1597, 1601, 1605, 1609, 1613, 1615, 1619, 1623, | |
528 | 1627, 1631, 1633, 1637, 1641, 1643, 1647, 1651, 1653, 1657, | |
529 | 1661, 1663, 1667, 1671, 1673, 1677, 1681, 1683, 1689, 1694, | |
530 | 1698, 1704, 1706, 1708, 1712, 1716, 1718, 1720, 1722, 1724, | |
531 | 1726, 1728 | |
8b27f225 PB |
532 | }; |
533 | ||
534 | static const short yyrhs[] = { 123, | |
535 | 0, 104, 0, 105, 0, 108, 0, 103, 0, 102, | |
536 | 0, 109, 0, 113, 0, 114, 0, 82, 0, 85, | |
537 | 0, 50, 0, 115, 0, 118, 0, 119, 0, 115, | |
538 | 0, 115, 0, 113, 97, 98, 0, 119, 97, 98, | |
539 | 0, 118, 97, 98, 0, 113, 97, 1, 0, 118, | |
540 | 97, 1, 0, 120, 0, 121, 0, 122, 0, 119, | |
541 | 101, 122, 0, 86, 0, 0, 126, 0, 124, 0, | |
542 | 125, 0, 126, 124, 0, 126, 125, 0, 124, 125, | |
543 | 0, 126, 124, 125, 0, 127, 0, 124, 127, 0, | |
544 | 130, 0, 125, 130, 0, 75, 119, 99, 0, 75, | |
545 | 1, 0, 75, 119, 1, 0, 128, 0, 129, 0, | |
546 | 55, 119, 99, 0, 55, 1, 0, 55, 119, 1, | |
547 | 0, 55, 119, 101, 5, 99, 0, 55, 119, 101, | |
548 | 1, 0, 55, 119, 101, 5, 1, 0, 132, 0, | |
2e5eb5c5 | 549 | 166, 0, 99, 0, 1, 0, 44, 0, 131, 44, |
8b27f225 PB |
550 | 0, 0, 131, 67, 122, 135, 136, 133, 138, 0, |
551 | 0, 67, 122, 135, 136, 134, 138, 0, 131, 67, | |
552 | 1, 0, 67, 1, 0, 67, 122, 1, 0, 131, | |
553 | 67, 122, 1, 0, 0, 63, 116, 0, 63, 116, | |
554 | 1, 0, 63, 1, 0, 0, 52, 137, 0, 52, | |
555 | 1, 0, 117, 0, 137, 100, 117, 0, 137, 100, | |
556 | 1, 0, 95, 96, 0, 95, 139, 96, 0, 140, | |
557 | 0, 139, 140, 0, 141, 0, 156, 0, 158, 0, | |
2e5eb5c5 APB |
558 | 179, 0, 142, 0, 142, 99, 0, 147, 0, 132, |
559 | 0, 166, 0, 112, 143, 99, 0, 131, 112, 143, | |
0b4d333e APB |
560 | 99, 0, 144, 0, 143, 100, 144, 0, 143, 100, |
561 | 1, 0, 145, 0, 145, 92, 146, 0, 145, 92, | |
562 | 1, 0, 145, 92, 146, 1, 0, 122, 0, 145, | |
563 | 97, 98, 0, 122, 1, 0, 145, 97, 1, 0, | |
2e5eb5c5 | 564 | 145, 98, 1, 0, 264, 0, 177, 0, 0, 149, |
0b4d333e APB |
565 | 148, 155, 0, 149, 1, 0, 112, 150, 153, 0, |
566 | 59, 150, 153, 0, 131, 112, 150, 153, 0, 131, | |
567 | 59, 150, 153, 0, 112, 1, 0, 131, 112, 1, | |
568 | 0, 59, 1, 0, 131, 59, 1, 0, 131, 1, | |
569 | 0, 122, 93, 94, 0, 122, 93, 151, 94, 0, | |
570 | 150, 97, 98, 0, 122, 93, 1, 0, 150, 97, | |
571 | 1, 0, 152, 0, 151, 100, 152, 0, 151, 100, | |
572 | 1, 0, 112, 145, 0, 131, 112, 145, 0, 112, | |
573 | 1, 0, 131, 112, 1, 0, 0, 53, 154, 0, | |
574 | 53, 1, 0, 116, 0, 154, 100, 116, 0, 154, | |
2e5eb5c5 APB |
575 | 100, 1, 0, 179, 0, 179, 99, 0, 99, 0, |
576 | 157, 179, 0, 157, 179, 99, 0, 44, 0, 0, | |
0b4d333e APB |
577 | 160, 159, 162, 0, 161, 153, 0, 131, 161, 153, |
578 | 0, 120, 93, 94, 0, 120, 93, 151, 94, 0, | |
2e5eb5c5 APB |
579 | 180, 163, 0, 180, 164, 163, 0, 180, 182, 163, |
580 | 0, 180, 164, 182, 163, 0, 181, 0, 181, 99, | |
581 | 0, 165, 93, 94, 99, 0, 165, 93, 233, 94, | |
582 | 99, 0, 119, 101, 65, 93, 233, 94, 99, 0, | |
583 | 119, 101, 65, 93, 94, 99, 0, 76, 0, 65, | |
584 | 0, 0, 61, 122, 167, 172, 0, 0, 131, 61, | |
585 | 122, 168, 172, 0, 0, 61, 122, 171, 169, 172, | |
586 | 0, 0, 131, 61, 122, 171, 170, 172, 0, 61, | |
587 | 122, 1, 0, 131, 61, 122, 1, 0, 63, 117, | |
588 | 0, 171, 100, 117, 0, 63, 1, 0, 171, 100, | |
589 | 1, 0, 95, 96, 0, 95, 173, 96, 0, 174, | |
590 | 0, 173, 174, 0, 175, 0, 176, 0, 132, 0, | |
591 | 166, 0, 142, 0, 149, 99, 0, 149, 1, 0, | |
592 | 95, 96, 0, 95, 178, 96, 0, 95, 178, 100, | |
593 | 96, 0, 146, 0, 178, 100, 146, 0, 178, 100, | |
594 | 1, 0, 95, 96, 0, 180, 182, 181, 0, 95, | |
595 | 0, 96, 0, 183, 0, 182, 183, 0, 184, 0, | |
596 | 186, 0, 132, 0, 185, 99, 0, 112, 143, 0, | |
597 | 131, 112, 143, 0, 188, 0, 191, 0, 195, 0, | |
598 | 196, 0, 207, 0, 211, 0, 188, 0, 192, 0, | |
599 | 197, 0, 208, 0, 212, 0, 179, 0, 189, 0, | |
600 | 193, 0, 198, 0, 210, 0, 218, 0, 219, 0, | |
601 | 220, 0, 222, 0, 221, 0, 224, 0, 99, 0, | |
602 | 122, 88, 0, 190, 186, 0, 122, 1, 0, 190, | |
603 | 187, 0, 194, 99, 0, 1, 99, 0, 1, 95, | |
604 | 0, 1, 96, 0, 165, 93, 1, 0, 165, 93, | |
605 | 94, 1, 0, 165, 93, 233, 1, 0, 165, 93, | |
606 | 233, 94, 1, 0, 119, 101, 65, 1, 0, 119, | |
607 | 101, 65, 93, 1, 0, 119, 101, 65, 93, 233, | |
608 | 1, 0, 119, 101, 65, 93, 233, 94, 1, 0, | |
609 | 119, 101, 65, 93, 94, 1, 0, 261, 0, 245, | |
610 | 0, 246, 0, 242, 0, 243, 0, 239, 0, 231, | |
611 | 0, 48, 93, 264, 94, 186, 0, 48, 1, 0, | |
612 | 48, 93, 1, 0, 48, 93, 264, 1, 0, 48, | |
613 | 93, 264, 94, 187, 56, 186, 0, 48, 93, 264, | |
614 | 94, 187, 56, 187, 0, 0, 200, 199, 201, 0, | |
615 | 68, 93, 264, 94, 0, 68, 1, 0, 68, 93, | |
616 | 1, 0, 68, 93, 264, 94, 1, 0, 95, 96, | |
617 | 0, 95, 204, 96, 0, 95, 202, 96, 0, 95, | |
618 | 202, 204, 96, 0, 203, 0, 202, 203, 0, 204, | |
619 | 182, 0, 205, 0, 204, 205, 0, 62, 265, 88, | |
620 | 0, 47, 88, 0, 62, 1, 0, 62, 265, 1, | |
621 | 0, 47, 1, 0, 66, 93, 264, 94, 0, 206, | |
622 | 186, 0, 66, 1, 0, 66, 93, 1, 0, 66, | |
623 | 93, 264, 1, 0, 206, 187, 0, 51, 0, 209, | |
624 | 186, 66, 93, 264, 94, 99, 0, 214, 99, 264, | |
625 | 99, 216, 94, 186, 0, 214, 99, 99, 216, 94, | |
626 | 186, 0, 214, 99, 1, 0, 214, 99, 264, 99, | |
627 | 1, 0, 214, 99, 99, 1, 0, 214, 99, 264, | |
628 | 99, 216, 94, 187, 0, 214, 99, 99, 216, 94, | |
629 | 187, 0, 71, 93, 0, 71, 1, 0, 71, 93, | |
630 | 1, 0, 213, 215, 0, 0, 217, 0, 185, 0, | |
631 | 217, 1, 0, 0, 217, 0, 194, 0, 217, 100, | |
632 | 194, 0, 217, 100, 1, 0, 54, 99, 0, 54, | |
633 | 122, 99, 0, 54, 1, 0, 54, 122, 1, 0, | |
634 | 73, 99, 0, 73, 122, 99, 0, 73, 1, 0, | |
635 | 73, 122, 1, 0, 58, 99, 0, 58, 264, 99, | |
636 | 0, 58, 1, 0, 58, 264, 1, 0, 49, 264, | |
637 | 99, 0, 49, 1, 0, 49, 264, 1, 0, 223, | |
638 | 93, 264, 94, 179, 0, 223, 93, 264, 94, 1, | |
639 | 0, 223, 1, 0, 223, 93, 1, 94, 0, 223, | |
efa0a23f | 640 | 93, 1, 0, 131, 0, 70, 179, 225, 0, 70, |
2e5eb5c5 APB |
641 | 179, 228, 0, 70, 179, 225, 228, 0, 70, 1, |
642 | 0, 226, 0, 225, 226, 0, 227, 179, 0, 60, | |
643 | 93, 152, 94, 0, 60, 1, 0, 60, 93, 1, | |
644 | 0, 60, 93, 1, 94, 0, 64, 179, 0, 64, | |
645 | 1, 0, 230, 0, 234, 0, 111, 0, 76, 0, | |
646 | 93, 264, 94, 0, 231, 0, 238, 0, 239, 0, | |
647 | 240, 0, 119, 101, 67, 0, 113, 101, 67, 0, | |
648 | 59, 101, 67, 0, 119, 101, 76, 0, 93, 264, | |
649 | 1, 0, 119, 101, 1, 0, 113, 101, 1, 0, | |
650 | 59, 101, 1, 0, 72, 116, 93, 233, 94, 0, | |
651 | 72, 116, 93, 94, 0, 72, 116, 93, 233, 94, | |
652 | 138, 0, 72, 116, 93, 94, 138, 0, 232, 122, | |
653 | 93, 94, 0, 232, 122, 93, 94, 138, 0, 232, | |
654 | 122, 93, 233, 94, 0, 232, 122, 93, 233, 94, | |
655 | 138, 0, 72, 1, 99, 0, 72, 116, 1, 0, | |
656 | 72, 116, 93, 1, 0, 72, 116, 93, 233, 1, | |
657 | 0, 232, 1, 0, 232, 122, 1, 0, 119, 101, | |
658 | 72, 0, 229, 101, 72, 0, 264, 0, 233, 100, | |
659 | 264, 0, 233, 100, 1, 0, 72, 113, 235, 0, | |
660 | 72, 115, 235, 0, 72, 113, 235, 237, 0, 72, | |
661 | 115, 235, 237, 0, 72, 115, 237, 177, 0, 72, | |
662 | 113, 237, 177, 0, 72, 1, 98, 0, 72, 1, | |
663 | 97, 0, 236, 0, 235, 236, 0, 97, 264, 98, | |
664 | 0, 97, 264, 1, 0, 97, 1, 0, 97, 98, | |
665 | 0, 237, 97, 98, 0, 237, 97, 1, 0, 229, | |
666 | 101, 122, 0, 65, 101, 122, 0, 65, 1, 0, | |
667 | 119, 93, 94, 0, 119, 93, 233, 94, 0, 229, | |
668 | 101, 122, 93, 94, 0, 229, 101, 122, 93, 233, | |
669 | 94, 0, 65, 101, 122, 93, 94, 0, 65, 101, | |
670 | 122, 93, 233, 94, 0, 65, 101, 1, 94, 0, | |
671 | 65, 101, 1, 101, 0, 119, 97, 264, 98, 0, | |
672 | 230, 97, 264, 98, 0, 119, 97, 1, 0, 119, | |
673 | 97, 264, 1, 0, 230, 97, 1, 0, 230, 97, | |
674 | 264, 1, 0, 229, 0, 119, 0, 242, 0, 243, | |
675 | 0, 241, 46, 0, 241, 45, 0, 245, 0, 246, | |
676 | 0, 3, 244, 0, 4, 244, 0, 247, 0, 3, | |
677 | 1, 0, 4, 1, 0, 46, 244, 0, 46, 1, | |
678 | 0, 45, 244, 0, 45, 1, 0, 241, 0, 89, | |
679 | 244, 0, 90, 244, 0, 248, 0, 89, 1, 0, | |
680 | 90, 1, 0, 93, 113, 237, 94, 244, 0, 93, | |
681 | 113, 94, 244, 0, 93, 264, 94, 247, 0, 93, | |
682 | 119, 237, 94, 247, 0, 93, 113, 97, 1, 0, | |
683 | 93, 1, 0, 93, 113, 237, 94, 1, 0, 93, | |
684 | 113, 94, 1, 0, 93, 119, 237, 94, 1, 0, | |
685 | 244, 0, 249, 5, 244, 0, 249, 6, 244, 0, | |
686 | 249, 7, 244, 0, 249, 5, 1, 0, 249, 6, | |
687 | 1, 0, 249, 7, 1, 0, 249, 0, 250, 3, | |
688 | 249, 0, 250, 4, 249, 0, 250, 3, 1, 0, | |
689 | 250, 4, 1, 0, 250, 0, 251, 8, 250, 0, | |
690 | 251, 9, 250, 0, 251, 10, 250, 0, 251, 8, | |
691 | 1, 0, 251, 9, 1, 0, 251, 10, 1, 0, | |
692 | 251, 0, 252, 20, 251, 0, 252, 18, 251, 0, | |
693 | 252, 21, 251, 0, 252, 19, 251, 0, 252, 57, | |
694 | 114, 0, 252, 20, 1, 0, 252, 18, 1, 0, | |
695 | 252, 21, 1, 0, 252, 19, 1, 0, 252, 57, | |
696 | 1, 0, 252, 0, 253, 16, 252, 0, 253, 17, | |
697 | 252, 0, 253, 16, 1, 0, 253, 17, 1, 0, | |
698 | 253, 0, 254, 11, 253, 0, 254, 11, 1, 0, | |
699 | 254, 0, 255, 12, 254, 0, 255, 12, 1, 0, | |
700 | 255, 0, 256, 13, 255, 0, 256, 13, 1, 0, | |
701 | 256, 0, 257, 14, 256, 0, 257, 14, 1, 0, | |
702 | 257, 0, 258, 15, 257, 0, 258, 15, 1, 0, | |
703 | 258, 0, 258, 87, 264, 88, 259, 0, 258, 87, | |
704 | 88, 1, 0, 258, 87, 1, 0, 258, 87, 264, | |
705 | 88, 1, 0, 259, 0, 261, 0, 262, 263, 260, | |
706 | 0, 262, 263, 1, 0, 119, 0, 238, 0, 240, | |
707 | 0, 91, 0, 92, 0, 260, 0, 264, 0 | |
8b27f225 PB |
708 | }; |
709 | ||
710 | #endif | |
711 | ||
712 | #if YYDEBUG != 0 | |
713 | static const short yyrline[] = { 0, | |
51149cc8 MK |
714 | 485, 491, 493, 494, 495, 496, 497, 501, 503, 506, |
715 | 508, 509, 512, 514, 517, 521, 525, 529, 535, 537, | |
716 | 539, 541, 546, 548, 551, 555, 560, 565, 567, 568, | |
717 | 569, 570, 571, 572, 573, 576, 581, 587, 589, 592, | |
718 | 598, 600, 604, 606, 609, 636, 638, 642, 655, 657, | |
719 | 661, 668, 673, 675, 685, 690, 705, 709, 712, 715, | |
720 | 718, 720, 722, 727, 731, 733, 735, 737, 741, 743, | |
721 | 745, 752, 758, 763, 767, 776, 786, 788, 791, 793, | |
722 | 794, 795, 799, 801, 803, 804, 806, 811, 814, 824, | |
723 | 827, 829, 833, 836, 843, 849, 857, 859, 861, 863, | |
724 | 865, 869, 871, 875, 882, 883, 887, 890, 892, 894, | |
725 | 896, 901, 903, 905, 907, 914, 917, 919, 928, 930, | |
726 | 934, 939, 944, 948, 953, 958, 960, 967, 969, 971, | |
727 | 975, 978, 980, 984, 986, 987, 992, 998, 1005, 1013, | |
728 | 1020, 1023, 1026, 1030, 1033, 1037, 1046, 1048, 1050, 1054, | |
729 | 1056, 1059, 1066, 1074, 1076, 1080, 1087, 1097, 1101, 1104, | |
730 | 1107, 1110, 1113, 1116, 1119, 1122, 1124, 1128, 1134, 1139, | |
731 | 1141, 1145, 1148, 1152, 1154, 1157, 1159, 1160, 1162, 1166, | |
732 | 1170, 1176, 1181, 1184, 1186, 1190, 1196, 1200, 1205, 1214, | |
733 | 1218, 1223, 1235, 1237, 1240, 1242, 1244, 1248, 1252, 1255, | |
734 | 1259, 1261, 1262, 1263, 1264, 1265, 1269, 1271, 1272, 1273, | |
735 | 1274, 1278, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, | |
736 | 1288, 1289, 1292, 1297, 1308, 1311, 1315, 1322, 1332, 1338, | |
737 | 1344, 1350, 1352, 1357, 1359, 1364, 1366, 1368, 1370, 1372, | |
738 | 1376, 1378, 1379, 1380, 1381, 1382, 1383, 1386, 1392, 1394, | |
739 | 1396, 1400, 1405, 1410, 1416, 1426, 1432, 1434, 1436, 1443, | |
740 | 1446, 1448, 1450, 1454, 1456, 1459, 1463, 1465, 1468, 1475, | |
741 | 1481, 1483, 1485, 1489, 1497, 1500, 1502, 1504, 1508, 1513, | |
742 | 1522, 1527, 1530, 1537, 1539, 1541, 1545, 1548, 1557, 1564, | |
743 | 1566, 1570, 1583, 1585, 1591, 1597, 1601, 1603, 1607, 1610, | |
744 | 1612, 1616, 1619, 1621, 1623, 1627, 1630, 1632, 1634, 1638, | |
745 | 1641, 1643, 1645, 1649, 1655, 1657, 1661, 1668, 1670, 1672, | |
746 | 1674, 1678, 1690, 1693, 1695, 1700, 1704, 1706, 1713, 1721, | |
747 | 1738, 1740, 1745, 1749, 1752, 1757, 1759, 1762, 1764, 1766, | |
748 | 1768, 1769, 1770, 1771, 1775, 1777, 1779, 1784, 1786, 1788, | |
749 | 1790, 1792, 1796, 1799, 1804, 1806, 1811, 1812, 1813, 1814, | |
750 | 1815, 1817, 1819, 1821, 1823, 1825, 1829, 1831, 1834, 1840, | |
751 | 1845, 1849, 1852, 1854, 1856, 1860, 1862, 1864, 1866, 1870, | |
752 | 1873, 1877, 1883, 1885, 1893, 1920, 1922, 1926, 1931, 1938, | |
753 | 1942, 1945, 1947, 1958, 1969, 1974, 1983, 1985, 1989, 1992, | |
754 | 1994, 1999, 2004, 2009, 2016, 2018, 2019, 2020, 2023, 2028, | |
755 | 2033, 2035, 2036, 2038, 2040, 2041, 2043, 2047, 2050, 2054, | |
756 | 2057, 2061, 2063, 2065, 2067, 2068, 2070, 2074, 2083, 2085, | |
757 | 2087, 2100, 2102, 2108, 2110, 2112, 2116, 2118, 2123, 2128, | |
758 | 2133, 2135, 2137, 2141, 2143, 2148, 2153, 2155, 2159, 2161, | |
759 | 2166, 2171, 2176, 2178, 2180, 2184, 2186, 2191, 2196, 2201, | |
760 | 2206, 2208, 2210, 2212, 2214, 2216, 2220, 2222, 2227, 2232, | |
761 | 2234, 2238, 2240, 2245, 2249, 2251, 2256, 2260, 2262, 2267, | |
762 | 2271, 2273, 2278, 2282, 2284, 2289, 2293, 2295, 2300, 2306, | |
763 | 2308, 2312, 2314, 2317, 2320, 2328, 2330, 2331, 2334, 2336, | |
764 | 2339, 2343 | |
8b27f225 PB |
765 | }; |
766 | #endif | |
767 | ||
768 | ||
769 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) | |
770 | ||
771 | static const char * const yytname[] = { "$","error","$undefined.","PLUS_TK", | |
772 | "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK", | |
773 | "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK", | |
774 | "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK", | |
775 | "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK", | |
776 | "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK", | |
777 | "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK", | |
778 | "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK", | |
779 | "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK", | |
780 | "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK", | |
781 | "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK", | |
782 | "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK", | |
783 | "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK", | |
784 | "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK", | |
785 | "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK", | |
786 | "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK", | |
787 | "goal","literal","type","primitive_type","reference_type","class_or_interface_type", | |
788 | "class_type","interface_type","array_type","name","simple_name","qualified_name", | |
789 | "identifier","compilation_unit","import_declarations","type_declarations","package_declaration", | |
790 | "import_declaration","single_type_import_declaration","type_import_on_demand_declaration", | |
791 | "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces", | |
792 | "interface_type_list","class_body","class_body_declarations","class_body_declaration", | |
793 | "class_member_declaration","field_declaration","variable_declarators","variable_declarator", | |
794 | "variable_declarator_id","variable_initializer","method_declaration","@3","method_header", | |
795 | "method_declarator","formal_parameter_list","formal_parameter","throws","class_type_list", | |
22eed1e6 | 796 | "method_body","static_initializer","static","constructor_declaration","@4","constructor_header", |
2e5eb5c5 | 797 | "constructor_declarator","constructor_body","constructor_block_end","explicit_constructor_invocation", |
22eed1e6 APB |
798 | "this_or_super","interface_declaration","@5","@6","@7","@8","extends_interfaces", |
799 | "interface_body","interface_member_declarations","interface_member_declaration", | |
800 | "constant_declaration","abstract_method_declaration","array_initializer","variable_initializers", | |
801 | "block","block_begin","block_end","block_statements","block_statement","local_variable_declaration_statement", | |
802 | "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement", | |
803 | "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement", | |
8b27f225 | 804 | "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi", |
12472854 PB |
805 | "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups", |
806 | "switch_block_statement_group","switch_labels","switch_label","while_expression", | |
807 | "while_statement","while_statement_nsi","do_statement_begin","do_statement", | |
808 | "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update", | |
809 | "statement_expression_list","break_statement","continue_statement","return_statement", | |
810 | "throw_statement","synchronized_statement","synchronized","try_statement","catches", | |
811 | "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array", | |
812 | "class_instance_creation_expression","something_dot_new","argument_list","array_creation_expression", | |
813 | "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access", | |
814 | "postfix_expression","post_increment_expression","post_decrement_expression", | |
815 | "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus", | |
816 | "cast_expression","multiplicative_expression","additive_expression","shift_expression", | |
817 | "relational_expression","equality_expression","and_expression","exclusive_or_expression", | |
818 | "inclusive_or_expression","conditional_and_expression","conditional_or_expression", | |
819 | "conditional_expression","assignment_expression","assignment","left_hand_side", | |
820 | "assignment_operator","expression","constant_expression", NULL | |
8b27f225 PB |
821 | }; |
822 | #endif | |
823 | ||
824 | static const short yyr1[] = { 0, | |
825 | 110, 111, 111, 111, 111, 111, 111, 112, 112, 113, | |
826 | 113, 113, 114, 114, 115, 116, 117, 118, 118, 118, | |
827 | 118, 118, 119, 119, 120, 121, 122, 123, 123, 123, | |
828 | 123, 123, 123, 123, 123, 124, 124, 125, 125, 126, | |
829 | 126, 126, 127, 127, 128, 128, 128, 129, 129, 129, | |
830 | 130, 130, 130, 130, 131, 131, 133, 132, 134, 132, | |
831 | 132, 132, 132, 132, 135, 135, 135, 135, 136, 136, | |
832 | 136, 137, 137, 137, 138, 138, 139, 139, 140, 140, | |
0b4d333e APB |
833 | 140, 140, 141, 141, 141, 141, 141, 142, 142, 143, |
834 | 143, 143, 144, 144, 144, 144, 145, 145, 145, 145, | |
835 | 145, 146, 146, 148, 147, 147, 149, 149, 149, 149, | |
836 | 149, 149, 149, 149, 149, 150, 150, 150, 150, 150, | |
837 | 151, 151, 151, 152, 152, 152, 152, 153, 153, 153, | |
838 | 154, 154, 154, 155, 155, 155, 156, 156, 157, 159, | |
839 | 158, 160, 160, 161, 161, 162, 162, 162, 162, 163, | |
2e5eb5c5 APB |
840 | 163, 164, 164, 164, 164, 165, 165, 167, 166, 168, |
841 | 166, 169, 166, 170, 166, 166, 166, 171, 171, 171, | |
842 | 171, 172, 172, 173, 173, 174, 174, 174, 174, 175, | |
843 | 176, 176, 177, 177, 177, 178, 178, 178, 179, 179, | |
844 | 180, 181, 182, 182, 183, 183, 183, 184, 185, 185, | |
845 | 186, 186, 186, 186, 186, 186, 187, 187, 187, 187, | |
846 | 187, 188, 188, 188, 188, 188, 188, 188, 188, 188, | |
847 | 188, 188, 189, 190, 191, 191, 192, 193, 193, 193, | |
848 | 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, | |
849 | 194, 194, 194, 194, 194, 194, 194, 195, 195, 195, | |
850 | 195, 196, 197, 199, 198, 200, 200, 200, 200, 201, | |
851 | 201, 201, 201, 202, 202, 203, 204, 204, 205, 205, | |
852 | 205, 205, 205, 206, 207, 207, 207, 207, 208, 209, | |
853 | 210, 211, 211, 211, 211, 211, 212, 212, 213, 213, | |
854 | 213, 214, 215, 215, 215, 215, 216, 216, 217, 217, | |
855 | 217, 218, 218, 218, 218, 219, 219, 219, 219, 220, | |
856 | 220, 220, 220, 221, 221, 221, 222, 222, 222, 222, | |
857 | 222, 223, 224, 224, 224, 224, 225, 225, 226, 227, | |
858 | 227, 227, 227, 228, 228, 229, 229, 230, 230, 230, | |
22eed1e6 | 859 | 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, |
2e5eb5c5 APB |
860 | 230, 230, 231, 231, 231, 231, 231, 231, 231, 231, |
861 | 231, 231, 231, 231, 231, 231, 232, 232, 233, 233, | |
862 | 233, 234, 234, 234, 234, 234, 234, 234, 234, 235, | |
863 | 235, 236, 236, 236, 237, 237, 237, 238, 238, 238, | |
864 | 239, 239, 239, 239, 239, 239, 239, 239, 240, 240, | |
865 | 240, 240, 240, 240, 241, 241, 241, 241, 242, 243, | |
866 | 244, 244, 244, 244, 244, 244, 244, 245, 245, 246, | |
867 | 246, 247, 247, 247, 247, 247, 247, 248, 248, 248, | |
868 | 248, 248, 248, 248, 248, 248, 249, 249, 249, 249, | |
869 | 249, 249, 249, 250, 250, 250, 250, 250, 251, 251, | |
870 | 251, 251, 251, 251, 251, 252, 252, 252, 252, 252, | |
871 | 252, 252, 252, 252, 252, 252, 253, 253, 253, 253, | |
872 | 253, 254, 254, 254, 255, 255, 255, 256, 256, 256, | |
873 | 257, 257, 257, 258, 258, 258, 259, 259, 259, 259, | |
874 | 259, 260, 260, 261, 261, 262, 262, 262, 263, 263, | |
875 | 264, 265 | |
8b27f225 PB |
876 | }; |
877 | ||
878 | static const short yyr2[] = { 0, | |
879 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
880 | 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, | |
881 | 3, 3, 1, 1, 1, 3, 1, 0, 1, 1, | |
882 | 1, 2, 2, 2, 3, 1, 2, 1, 2, 3, | |
883 | 2, 3, 1, 1, 3, 2, 3, 5, 4, 5, | |
884 | 1, 1, 1, 1, 1, 2, 0, 7, 0, 6, | |
885 | 3, 2, 3, 4, 0, 2, 3, 2, 0, 2, | |
886 | 2, 1, 3, 3, 2, 3, 1, 2, 1, 1, | |
0b4d333e APB |
887 | 1, 1, 1, 2, 1, 1, 1, 3, 4, 1, |
888 | 3, 3, 1, 3, 3, 4, 1, 3, 2, 3, | |
889 | 3, 1, 1, 0, 3, 2, 3, 3, 4, 4, | |
890 | 2, 3, 2, 3, 2, 3, 4, 3, 3, 3, | |
891 | 1, 3, 3, 2, 3, 2, 3, 0, 2, 2, | |
892 | 1, 3, 3, 1, 2, 1, 2, 3, 1, 0, | |
2e5eb5c5 APB |
893 | 3, 2, 3, 3, 4, 2, 3, 3, 4, 1, |
894 | 2, 4, 5, 7, 6, 1, 1, 0, 4, 0, | |
895 | 5, 0, 5, 0, 6, 3, 4, 2, 3, 2, | |
896 | 3, 2, 3, 1, 2, 1, 1, 1, 1, 1, | |
897 | 2, 2, 2, 3, 4, 1, 3, 3, 2, 3, | |
898 | 1, 1, 1, 2, 1, 1, 1, 2, 2, 3, | |
8b27f225 PB |
899 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
900 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
2e5eb5c5 APB |
901 | 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, |
902 | 2, 3, 4, 4, 5, 4, 5, 6, 7, 6, | |
903 | 1, 1, 1, 1, 1, 1, 1, 5, 2, 3, | |
904 | 4, 7, 7, 0, 3, 4, 2, 3, 5, 2, | |
905 | 3, 3, 4, 1, 2, 2, 1, 2, 3, 2, | |
906 | 2, 3, 2, 4, 2, 2, 3, 4, 2, 1, | |
907 | 7, 7, 6, 3, 5, 4, 7, 6, 2, 2, | |
908 | 3, 2, 0, 1, 1, 2, 0, 1, 1, 3, | |
0b4d333e | 909 | 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, |
2e5eb5c5 APB |
910 | 3, 2, 3, 3, 2, 3, 5, 5, 2, 4, |
911 | 3, 1, 3, 3, 4, 2, 1, 2, 2, 4, | |
912 | 2, 3, 4, 2, 2, 1, 1, 1, 1, 3, | |
913 | 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, | |
914 | 3, 3, 5, 4, 6, 5, 4, 5, 5, 6, | |
915 | 3, 3, 4, 5, 2, 3, 3, 3, 1, 3, | |
916 | 3, 3, 3, 4, 4, 4, 4, 3, 3, 1, | |
917 | 2, 3, 3, 2, 2, 3, 3, 3, 3, 2, | |
918 | 3, 4, 5, 6, 5, 6, 4, 4, 4, 4, | |
919 | 3, 4, 3, 4, 1, 1, 1, 1, 2, 2, | |
920 | 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, | |
921 | 2, 1, 2, 2, 1, 2, 2, 5, 4, 4, | |
922 | 5, 4, 2, 5, 4, 5, 1, 3, 3, 3, | |
923 | 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, | |
924 | 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, | |
925 | 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, | |
926 | 3, 1, 3, 3, 1, 3, 3, 1, 3, 3, | |
927 | 1, 3, 3, 1, 3, 3, 1, 5, 4, 3, | |
928 | 5, 1, 1, 3, 3, 1, 1, 1, 1, 1, | |
929 | 1, 1 | |
8b27f225 PB |
930 | }; |
931 | ||
932 | static const short yydefact[] = { 0, | |
933 | 54, 55, 0, 0, 0, 0, 53, 1, 0, 0, | |
934 | 0, 36, 43, 44, 38, 0, 51, 52, 46, 27, | |
935 | 0, 23, 24, 25, 0, 62, 0, 41, 0, 0, | |
936 | 37, 39, 0, 0, 56, 0, 0, 47, 45, 0, | |
2e5eb5c5 APB |
937 | 166, 0, 0, 162, 63, 0, 69, 42, 40, 0, |
938 | 0, 0, 61, 0, 49, 0, 26, 170, 17, 168, | |
939 | 15, 0, 159, 0, 0, 68, 16, 0, 0, 59, | |
940 | 167, 0, 164, 64, 69, 50, 48, 12, 0, 10, | |
941 | 11, 172, 0, 8, 9, 13, 14, 15, 0, 178, | |
942 | 180, 0, 179, 0, 174, 176, 177, 171, 169, 163, | |
943 | 67, 71, 72, 70, 0, 161, 0, 57, 113, 0, | |
0b4d333e | 944 | 128, 111, 0, 0, 90, 93, 128, 0, 0, 0, |
2e5eb5c5 APB |
945 | 115, 0, 0, 182, 181, 173, 175, 0, 0, 60, |
946 | 165, 0, 0, 0, 0, 108, 99, 88, 0, 0, | |
0b4d333e | 947 | 0, 0, 107, 21, 18, 22, 20, 19, 114, 128, |
2e5eb5c5 | 948 | 112, 0, 128, 74, 73, 55, 191, 75, 23, 0, |
0b4d333e APB |
949 | 86, 0, 77, 79, 83, 85, 0, 80, 0, 81, |
950 | 140, 128, 87, 82, 0, 58, 119, 116, 0, 0, | |
951 | 0, 121, 130, 131, 129, 120, 118, 92, 0, 91, | |
2e5eb5c5 APB |
952 | 95, 0, 0, 0, 0, 0, 0, 0, 339, 0, |
953 | 0, 0, 0, 6, 5, 2, 3, 4, 7, 338, | |
954 | 0, 406, 0, 103, 405, 336, 341, 0, 337, 342, | |
955 | 343, 344, 422, 407, 408, 437, 411, 412, 415, 425, | |
956 | 444, 449, 456, 467, 472, 475, 478, 481, 484, 487, | |
957 | 492, 501, 493, 0, 102, 100, 98, 101, 110, 89, | |
958 | 109, 189, 0, 128, 76, 78, 84, 106, 0, 137, | |
efa0a23f APB |
959 | 0, 142, 0, 0, 0, 280, 0, 0, 0, 0, |
960 | 0, 0, 0, 0, 339, 0, 223, 0, 8, 406, | |
961 | 0, 322, 197, 0, 212, 0, 193, 195, 0, 196, | |
962 | 201, 213, 0, 202, 214, 0, 203, 204, 215, 254, | |
963 | 0, 205, 0, 216, 206, 293, 0, 217, 218, 219, | |
964 | 221, 220, 0, 222, 247, 246, 0, 244, 245, 242, | |
965 | 243, 241, 126, 124, 0, 117, 0, 0, 416, 406, | |
966 | 342, 344, 413, 417, 414, 421, 420, 419, 418, 0, | |
967 | 390, 0, 0, 0, 16, 0, 426, 423, 427, 424, | |
968 | 433, 0, 406, 0, 183, 186, 0, 0, 0, 0, | |
969 | 0, 96, 0, 0, 365, 0, 410, 409, 0, 0, | |
8b27f225 | 970 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
efa0a23f APB |
971 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 499, |
972 | 500, 0, 144, 0, 143, 136, 105, 134, 138, 191, | |
973 | 141, 0, 230, 231, 229, 249, 0, 315, 0, 304, | |
974 | 302, 0, 312, 310, 0, 276, 0, 257, 0, 326, | |
975 | 0, 290, 0, 308, 306, 0, 0, 199, 0, 0, | |
976 | 226, 224, 0, 0, 192, 190, 194, 198, 406, 322, | |
977 | 225, 228, 0, 275, 0, 406, 0, 295, 299, 292, | |
978 | 0, 0, 319, 0, 127, 125, 123, 122, 133, 132, | |
979 | 352, 347, 0, 389, 379, 378, 361, 0, 372, 380, | |
980 | 0, 373, 0, 362, 0, 0, 0, 0, 0, 0, | |
981 | 349, 340, 184, 0, 351, 346, 391, 0, 369, 401, | |
982 | 0, 350, 345, 367, 348, 368, 388, 403, 0, 366, | |
983 | 0, 441, 438, 442, 439, 443, 440, 447, 445, 448, | |
984 | 446, 453, 450, 454, 451, 455, 452, 463, 458, 465, | |
985 | 460, 462, 457, 464, 459, 466, 0, 461, 470, 468, | |
986 | 471, 469, 474, 473, 477, 476, 480, 479, 483, 482, | |
987 | 486, 485, 490, 0, 0, 495, 494, 145, 135, 406, | |
988 | 146, 0, 0, 150, 0, 250, 0, 316, 314, 305, | |
989 | 303, 313, 311, 277, 0, 258, 0, 0, 0, 323, | |
990 | 327, 0, 324, 291, 309, 307, 340, 0, 200, 232, | |
991 | 0, 0, 0, 255, 0, 296, 0, 284, 0, 0, | |
992 | 321, 0, 397, 398, 0, 384, 385, 0, 381, 374, | |
993 | 0, 377, 375, 376, 363, 354, 0, 435, 429, 432, | |
994 | 0, 0, 430, 188, 185, 187, 392, 0, 402, 399, | |
995 | 0, 404, 400, 357, 0, 489, 0, 0, 147, 0, | |
996 | 0, 151, 148, 251, 0, 278, 274, 0, 331, 0, | |
997 | 335, 334, 328, 325, 329, 236, 0, 233, 234, 0, | |
998 | 0, 0, 260, 0, 264, 0, 267, 0, 301, 300, | |
999 | 286, 0, 298, 0, 320, 0, 395, 0, 383, 382, | |
1000 | 387, 386, 356, 364, 353, 434, 428, 436, 431, 371, | |
1001 | 370, 393, 0, 358, 359, 491, 488, 0, 149, 0, | |
1002 | 0, 0, 248, 0, 201, 0, 208, 209, 0, 210, | |
1003 | 211, 0, 259, 332, 0, 237, 0, 0, 235, 273, | |
1004 | 270, 271, 502, 0, 262, 265, 0, 261, 0, 268, | |
1005 | 0, 0, 285, 0, 318, 317, 396, 355, 394, 360, | |
1006 | 0, 152, 0, 0, 0, 227, 279, 0, 333, 330, | |
1007 | 240, 238, 0, 272, 269, 263, 0, 283, 0, 0, | |
1008 | 0, 153, 0, 252, 0, 0, 239, 281, 282, 155, | |
1009 | 0, 0, 0, 0, 154, 0, 0, 0, 0, 288, | |
1010 | 0, 253, 287, 0, 0, 0 | |
8b27f225 PB |
1011 | }; |
1012 | ||
efa0a23f APB |
1013 | static const short yydefgoto[] = { 774, |
1014 | 210, 278, 211, 85, 86, 68, 60, 87, 212, 22, | |
8b27f225 | 1015 | 23, 24, 8, 9, 10, 11, 12, 13, 14, 15, |
efa0a23f | 1016 | 440, 283, 132, 105, 47, 70, 104, 130, 162, 163, |
0b4d333e | 1017 | 164, 91, 114, 115, 116, 213, 166, 259, 92, 111, |
efa0a23f APB |
1018 | 181, 182, 136, 185, 397, 168, 169, 170, 261, 171, |
1019 | 172, 401, 551, 552, 284, 18, 43, 72, 65, 107, | |
1020 | 44, 63, 94, 95, 96, 97, 214, 357, 285, 175, | |
1021 | 554, 719, 287, 288, 289, 290, 694, 291, 292, 293, | |
1022 | 294, 697, 295, 296, 297, 298, 698, 299, 443, 300, | |
1023 | 584, 654, 655, 656, 657, 301, 302, 700, 303, 304, | |
1024 | 305, 701, 306, 307, 450, 662, 663, 308, 309, 310, | |
1025 | 311, 312, 313, 314, 570, 571, 572, 573, 215, 216, | |
1026 | 217, 218, 488, 219, 469, 470, 471, 220, 221, 222, | |
2e5eb5c5 APB |
1027 | 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, |
1028 | 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, | |
efa0a23f | 1029 | 243, 244, 392, 489, 714 |
8b27f225 PB |
1030 | }; |
1031 | ||
efa0a23f APB |
1032 | static const short yypact[] = { 409, |
1033 | -32768,-32768, 168, -48, 226, 450,-32768,-32768, 240, 262, | |
1034 | 446,-32768,-32768,-32768,-32768, 723,-32768,-32768,-32768,-32768, | |
1035 | 13,-32768,-32768,-32768, 348,-32768, 250,-32768, 74, 474, | |
1036 | -32768,-32768, 487, 587,-32768, -48, 465,-32768,-32768, 476, | |
1037 | -32768, 467, -49, -42,-32768, 470, 41,-32768,-32768, -48, | |
1038 | 589, 359,-32768, 337,-32768, 66,-32768,-32768,-32768,-32768, | |
1039 | 0, 1441,-32768, 488, -49,-32768,-32768, 307, 496,-32768, | |
1040 | -32768, -49, -42,-32768, 41,-32768,-32768,-32768, 511,-32768, | |
1041 | -32768,-32768, 539, 12,-32768,-32768, 133, 442, 645,-32768, | |
1042 | -32768, 77,-32768, 1574,-32768,-32768,-32768,-32768,-32768,-32768, | |
1043 | -32768,-32768,-32768, 21, 169,-32768, -49,-32768,-32768, 196, | |
1044 | 1,-32768, 501, 181,-32768, 746, 1, 105, 107, 336, | |
1045 | -32768, 557, 558,-32768,-32768,-32768,-32768, 565, 1027,-32768, | |
1046 | -32768, 169, 590, 574, 170,-32768,-32768,-32768, 576, 2045, | |
1047 | 180, 390,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1, | |
1048 | -32768, 504, 1,-32768,-32768, 347, 237,-32768, 376, 645, | |
1049 | -32768, 1354,-32768,-32768, 404,-32768, 52,-32768, 403,-32768, | |
1050 | -32768, 516,-32768,-32768, 1837,-32768,-32768,-32768, 583, 876, | |
1051 | 321,-32768,-32768,-32768, 479,-32768,-32768,-32768, 513,-32768, | |
1052 | -32768, 2741, 2792, 2857, 2908, 491, 47, 670,-32768, 2973, | |
1053 | 3024, 3089, 5088,-32768,-32768,-32768,-32768,-32768,-32768,-32768, | |
1054 | 541, 958, 29,-32768, 562, 571,-32768, 584,-32768, 370, | |
1055 | -32768, 424, 696,-32768,-32768,-32768,-32768,-32768,-32768,-32768, | |
1056 | 1057, 872, 1116, 888, 878, 676, 698, 668, 712, 209, | |
1057 | -32768,-32768,-32768, 797,-32768,-32768,-32768,-32768,-32768,-32768, | |
1058 | -32768,-32768, 931, 516,-32768,-32768,-32768,-32768, 472, 635, | |
1059 | 662,-32768, 178, 271, 3140,-32768, 115, 732, 118, 293, | |
1060 | 325, 148, 343, 149, 678, 5387,-32768, -48, 628, 709, | |
1061 | 437, 833,-32768, 687,-32768, 1769,-32768,-32768, 699,-32768, | |
1062 | -32768,-32768, 1905,-32768,-32768, 714,-32768,-32768,-32768,-32768, | |
1063 | 1905,-32768, 1905,-32768,-32768, 5438, 721,-32768,-32768,-32768, | |
1064 | -32768,-32768, 412,-32768, 577, 766, 696, 887, 905,-32768, | |
1065 | -32768,-32768,-32768, 879, 594,-32768, 663, 616,-32768, 731, | |
1066 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 30, | |
1067 | -32768, 657, 1030, 736, 736, 413,-32768,-32768,-32768,-32768, | |
1068 | -32768, 772, 1044, 19,-32768,-32768, 719, 32, 5155, 3205, | |
1069 | 563,-32768, 8, 3256,-32768, 416,-32768,-32768, 3321, 3372, | |
1070 | 3437, 3488, 3553, 3604, 3669, 3720, 3785, 3836, 3901, 3952, | |
1071 | 690, 4017, 4068, 4133, 4184, 4249, 4300, 4365, 2096,-32768, | |
1072 | -32768, 4416,-32768, 561,-32768,-32768,-32768, 751,-32768,-32768, | |
1073 | -32768, 1769,-32768,-32768,-32768,-32768, 4481,-32768, 86,-32768, | |
1074 | -32768, 121,-32768,-32768, 167,-32768, 4532,-32768, 4597,-32768, | |
1075 | 791,-32768, 4996,-32768,-32768, 211, 43, 757, 2161, 892, | |
1076 | -32768,-32768, -48, 2212,-32768,-32768,-32768,-32768, 1056, 834, | |
1077 | -32768,-32768, 785,-32768, 818, 910, 876,-32768,-32768,-32768, | |
1078 | 55, 2277,-32768, 4648,-32768, 879,-32768,-32768,-32768,-32768, | |
1079 | -32768,-32768, -37, 793,-32768,-32768,-32768, 2328, 736,-32768, | |
1080 | -32, 736, -32,-32768, 2393, 4713, 201, 521, 2444, 748, | |
1081 | -32768, 5463,-32768, 1130,-32768,-32768,-32768, 573,-32768,-32768, | |
1082 | 243,-32768,-32768,-32768,-32768,-32768, 798,-32768, 248,-32768, | |
1083 | 5206,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1057,-32768, | |
1084 | 1057,-32768, 872,-32768, 872,-32768, 872,-32768, 1116,-32768, | |
1085 | 1116,-32768, 1116,-32768, 1116,-32768, 12,-32768,-32768, 888, | |
1086 | -32768, 888,-32768, 878,-32768, 676,-32768, 698,-32768, 668, | |
1087 | -32768, 712,-32768, 897, 816,-32768,-32768,-32768,-32768, 982, | |
1088 | -32768, 1769, 819, 822, 1769,-32768, 236,-32768,-32768,-32768, | |
1089 | -32768,-32768,-32768,-32768, 354,-32768, 829, 429, 216, 791, | |
1090 | -32768, 403,-32768,-32768,-32768,-32768,-32768, 434, 757,-32768, | |
1091 | 924, 24, 692,-32768, 835,-32768, 5130,-32768, 5021, 831, | |
1092 | 842, 844,-32768,-32768, 5271,-32768,-32768, 260,-32768, 846, | |
1093 | 264,-32768, 846,-32768,-32768, 169, 84,-32768,-32768,-32768, | |
1094 | 4764, 1427,-32768,-32768,-32768,-32768,-32768, 4829,-32768,-32768, | |
1095 | 5322,-32768,-32768, 169, 623,-32768, 4880, 928,-32768, 1769, | |
1096 | 2509,-32768,-32768,-32768, 1971,-32768,-32768, 255,-32768, 665, | |
1097 | -32768,-32768,-32768,-32768,-32768,-32768, 2560,-32768,-32768, 940, | |
1098 | 411, 4945,-32768, 727,-32768, 1544,-32768, 5387,-32768,-32768, | |
1099 | -32768, 852, 848, 5063,-32768, 342,-32768, 644,-32768,-32768, | |
1100 | -32768,-32768,-32768,-32768, 169,-32768,-32768,-32768,-32768,-32768, | |
1101 | -32768,-32768, 669,-32768, 169,-32768,-32768, 440,-32768, 228, | |
1102 | 94, 444,-32768, 900, 904, 1971,-32768,-32768, 1971,-32768, | |
1103 | -32768, 864,-32768, 875, 885,-32768, 965, 106,-32768,-32768, | |
1104 | -32768,-32768,-32768, 456,-32768,-32768, 1618,-32768, 1686,-32768, | |
1105 | 889, 1905,-32768, 894,-32768,-32768,-32768,-32768,-32768,-32768, | |
1106 | 2625,-32768, 235, 4481, 1905,-32768,-32768, 2676,-32768,-32768, | |
1107 | -32768,-32768, 971,-32768,-32768,-32768, 891,-32768, 1905, 238, | |
1108 | 116,-32768, 362,-32768, 5021, 899,-32768,-32768,-32768,-32768, | |
1109 | 241, 1971, 921, 5063,-32768, 962, 1971, 929, 1971,-32768, | |
1110 | 1971,-32768,-32768, 1026, 1028,-32768 | |
8b27f225 PB |
1111 | }; |
1112 | ||
1113 | static const short yypgoto[] = {-32768, | |
efa0a23f APB |
1114 | -32768, -57, -60, 648, -24, -121, 332,-32768, -3, 485, |
1115 | -32768, 130,-32768, 1022, 770,-32768, 212,-32768,-32768, 851, | |
1116 | 153, 17,-32768,-32768, 981, 961,-32768, -128,-32768, 883, | |
1117 | -32768, 126, -117, 901, -167, -193,-32768,-32768, 388, 639, | |
1118 | 788, -326, -98,-32768,-32768,-32768,-32768,-32768,-32768,-32768, | |
1119 | 896,-32768, 64,-32768, 636, -2,-32768,-32768,-32768,-32768, | |
1120 | 995, 646,-32768, 954,-32768,-32768, 387,-32768, -120, 799, | |
1121 | 781, -164, -279,-32768, 752, -70, 25, -364,-32768, -343, | |
1122 | -32768,-32768,-32768, -270,-32768,-32768,-32768,-32768,-32768,-32768, | |
1123 | -32768,-32768, 415, 422, -621, -342,-32768,-32768,-32768,-32768, | |
1124 | -32768,-32768,-32768, -304,-32768, -623, 760,-32768,-32768,-32768, | |
1125 | -32768,-32768,-32768,-32768,-32768, 508,-32768, 517,-32768,-32768, | |
1126 | 218,-32768, -413,-32768, 744, 399, -329, 1085, 275, 1199, | |
1127 | 335, 397, 553, -111, 610, 641, -467,-32768, 633, 780, | |
1128 | 642, 626, 697, 706, 715, 705, 707,-32768, 471, 708, | |
1129 | 779,-32768,-32768, -132,-32768 | |
8b27f225 PB |
1130 | }; |
1131 | ||
1132 | ||
efa0a23f | 1133 | #define YYLAST 5572 |
8b27f225 PB |
1134 | |
1135 | ||
1136 | static const short yytable[] = { 21, | |
efa0a23f APB |
1137 | 458, 84, 29, 176, 83, 152, 437, 245, 174, 356, |
1138 | 286, 324, 184, 38, 613, 473, 17, 59, 143, 481, | |
1139 | 582, 67, 478, 480, 649, 17, 17, 17, 84, 362, | |
1140 | 461, 123, 485, 84, 720, 449, 83, 20, 61, 59, | |
1141 | 724, 174, 61, 481, 59, 62, 17, 341, 260, 17, | |
1142 | 17, 249, 258, 134, 251, 586, 593, 64, 88, 93, | |
1143 | 61, 607, 203, 594, 601, 61, 76, 17, 84, 354, | |
1144 | 245, 83, 84, 262, 48, 179, 346, 124, 90, 496, | |
1145 | 333, 335, 337, 339, 674, 88, 558, 625, 348, 350, | |
1146 | 88, 93, 69, 20, 649, 720, 462, 135, 486, 84, | |
1147 | 50, 84, 123, 59, 83, 144, 742, 146, 118, 67, | |
1148 | 90, 39, 482, 40, 279, 410, 742, 650, 341, 84, | |
1149 | 128, 560, 325, 618, 61, 88, 173, -94, -94, 88, | |
1150 | 61, 763, 409, 25, 27, 415, 577, 344, 398, 600, | |
1151 | 768, 352, 603, 427, 679, 161, -104, 342, 420, 424, | |
1152 | -104, 421, 16, -294, 587, 395, 88, 456, 88, 173, | |
1153 | 428, 16, 16, 16, 77, 52, 54, 562, 19, 57, | |
1154 | 186, 280, 49, 345, 50, 125, 88, 675, 161, 57, | |
1155 | 246, 668, 16, 618, 559, 16, 16, 733, 330, 330, | |
1156 | 330, 330, 84, 618, 61, 179, 330, 330, 353, 743, | |
1157 | 20, 610, 145, 16, 147, 618, 460, 683, 110, 761, | |
1158 | -157, 575, 113, 411, 89, 618, 641, 691, 342, 561, | |
1159 | 31, 84, 441, 388, 433, 279, 26, 491, 648, 119, | |
1160 | 444, 499, 445, 708, 20, 709, 634, 555, 741, -30, | |
1161 | 1, 757, 157, 619, 31, 279, 89, 425, 622, 88, | |
1162 | 45, 110, 113, 20, 165, 703, 545, 503, 505, 507, | |
1163 | 669, -31, 1, 129, 671, 563, 84, 187, 189, 179, | |
1164 | 695, 406, 403, 404, 557, 437, 405, 247, 88, 138, | |
1165 | 139, 160, 280, 2, 565, 180, 567, 165, 133, 439, | |
1166 | 616, 696, 699, 416, 3, 389, 491, 439, 597, 439, | |
1167 | 4, -65, 446, 67, 281, 2, 5, 101, 189, 576, | |
1168 | 157, 20, 46, 705, 160, 579, 660, 751, 449, 590, | |
1169 | 527, 592, 4, 88, 61, 418, 732, 282, 5, 635, | |
1170 | 702, 695, 252, 752, 695, 598, 760, 74, 7, 765, | |
1171 | 620, 279, 725, 422, -65, 623, 491, 366, 41, -256, | |
1172 | 437, 245, 696, 699, 636, 696, 699, 670, -66, 71, | |
1173 | 7, 672, 634, 407, 609, 330, 330, 330, 330, 330, | |
1174 | 330, 330, 330, 330, 330, 330, 330, 88, 330, 330, | |
1175 | 330, 330, 330, 330, 330, 417, 84, 630, -65, 433, | |
1176 | 248, 702, 315, 449, 702, 99, 412, 695, 550, 46, | |
1177 | 103, -66, 695, 426, 695, 180, 695, 189, -28, 1, | |
1178 | 42, 710, 453, 474, 326, 281, 500, 419, 696, 699, | |
1179 | 327, 42, 281, 696, 699, 696, 699, 696, 699, 639, | |
1180 | 281, -65, 281, 148, 646, 423, 157, 431, 282, 437, | |
1181 | 646, -139, -158, 88, 406, -29, 1, 637, 642, 316, | |
1182 | 28, 645, 2, -160, 189, 762, 744, 702, 447, 155, | |
1183 | -497, -497, 702, 3, 702, 53, 702, 58, 253, 4, | |
1184 | 66, 464, 330, -34, 1, 5, 55, 673, 330, 180, | |
1185 | 56, -25, -25, 6, 449, 681, -32, 1, 98, 2, | |
1186 | 57, 279, 497, 449, 279, 684, 102, 157, 711, 677, | |
1187 | 3, 137, 257, 315, 454, 475, 4, 7, 501, 317, | |
1188 | 315, 109, 5, 137, -498, -498, 167, 2, 315, 713, | |
1189 | 315, 640, -25, 315, 432, 721, 647, -25, -25, -25, | |
1190 | 2, 281, 731, -25, 4, 20, 734, -25, 120, 112, | |
1191 | 5, 3, 50, 745, 7, 726, 728, 4, 280, 167, | |
1192 | 20, 280, 20, 5, 282, 20, 730, 149, 151, 57, | |
1193 | 316, 20, 189, 492, 693, 154, 157, 316, 134, 279, | |
1194 | 396, 318, 7, 20, 183, 316, 188, 316, 328, 84, | |
1195 | 316, 20, 179, 323, 365, 7, -33, 1, -35, 1, | |
1196 | 177, 340, -97, 133, 455, 279, 20, -97, -97, -97, | |
1197 | -97, 753, 250, 139, -97, 756, -97, 330, 330, -97, | |
1198 | -97, -97, -97, 159, 611, 629, 459, 601, 633, 315, | |
1199 | 317, -341, -341, 330, 20, 441, 280, 317, 444, 493, | |
1200 | 2, 439, 2, 2, 494, 317, 88, 317, 495, 78, | |
1201 | 317, 358, 20, 20, 159, 121, 159, 4, 20, 4, | |
1202 | 20, 748, 280, 5, 548, 5, 279, 463, 279, 20, | |
1203 | 327, 20, 363, 457, 754, 704, 617, 364, 20, 20, | |
1204 | 343, 80, 618, -341, 81, 20, 316, -341, 759, 20, | |
1205 | 386, 281, 318, 178, 281, 7, 384, 7, 35, 318, | |
1206 | 526, 693, 439, 689, 78, 439, 748, 318, 754, 318, | |
1207 | 759, 20, 318, 122, 282, 36, 2, 282, 2, 385, | |
1208 | 100, 37, 78, 280, 78, 280, 685, 106, 439, 78, | |
1209 | 736, 117, 618, 737, 118, 387, 80, 319, 358, 81, | |
1210 | 20, 439, 413, 399, 192, 193, 317, 727, 651, 78, | |
1211 | 367, 368, 20, 618, 80, 439, 80, 81, 20, 81, | |
1212 | 20, 80, 131, 652, 81, 20, 400, 57, 439, 281, | |
1213 | 150, 153, 729, 439, 281, 439, 35, 439, 618, 315, | |
1214 | -156, 80, 315, 651, 81, 20, 194, 195, 30, 434, | |
1215 | 34, 78, 282, 36, 320, 281, 766, 653, 652, 37, | |
1216 | 196, 770, 180, 772, -15, 773, 197, 438, 318, -496, | |
1217 | -496, 359, 51, 198, 315, 429, 315, 199, 282, 430, | |
1218 | -343, -343, 442, 80, 483, 321, 81, 20, 484, 452, | |
1219 | 200, 201, 715, 359, 202, 281, 316, 360, 281, 316, | |
1220 | 414, 361, 468, 204, 205, 206, 207, 140, 319, 208, | |
1221 | 209, 612, 141, 142, 601, 319, 281, 315, 281, 549, | |
1222 | 568, 281, 315, 319, 569, 319, 139, 602, 319, 604, | |
1223 | 32, 316, -343, 316, 281, 476, -343, 599, 477, 282, | |
1224 | 599, 282, 358, 315, 372, 373, 35, 35, 281, 583, | |
1225 | 32, 315, 78, 585, 32, 595, 317, 390, 391, 317, | |
1226 | 621, 281, 492, 382, 383, 320, 281, 626, 281, 37, | |
1227 | 281, 32, 320, 627, 316, 377, 378, 379, 380, 316, | |
1228 | 320, 631, 320, 315, 80, 320, 315, 81, 20, 35, | |
1229 | 632, 317, 638, 317, 648, 78, 321, 658, 492, 664, | |
1230 | 316, -407, -407, 321, 315, 665, 315, 666, 316, 315, | |
1231 | 709, 321, 601, 321, 381, 722, 321, 587, 318, -408, | |
1232 | -408, 318, 315, 322, 319, 735, 578, 80, 493, -207, | |
1233 | 81, 20, 738, 494, 317, 741, 315, 495, 739, 317, | |
1234 | 316, 757, 315, 316, 2, 141, 142, 20, 740, 315, | |
1235 | 78, 315, 747, 318, 315, 318, 315, 749, 315, 758, | |
1236 | 317, 316, 688, 316, 493, -15, 316, 764, 317, 494, | |
1237 | -496, -496, 359, 495, 509, 511, 429, 530, 532, 316, | |
1238 | 361, 320, 80, 20, 767, 81, 20, 769, 519, 521, | |
1239 | 523, 525, 771, 316, 393, 775, 318, 776, 528, 316, | |
1240 | 317, 318, 33, 317, 75, 108, 316, 553, 316, 190, | |
1241 | 394, 316, 321, 316, 256, 316, 73, 127, -496, -496, | |
1242 | 359, 317, 318, 317, 360, 254, 317, 448, 361, 402, | |
1243 | 318, 369, 370, 371, 322, 451, 436, -15, 716, 317, | |
1244 | 156, 322, -496, -496, 359, 717, 78, 643, 429, 322, | |
1245 | 534, 322, 628, 317, 322, 79, 644, 4, 472, 317, | |
1246 | 536, 540, 318, 5, 542, 318, 317, 687, 317, 547, | |
1247 | 538, 317, 0, 317, 319, 317, 0, 319, 80, 0, | |
1248 | 0, 81, 20, 318, 0, 318, 0, 0, 318, 0, | |
1249 | 0, 157, 158, 374, 375, 376, 465, 466, 467, 0, | |
1250 | 614, 318, 192, 193, -496, -496, 359, 0, 0, 319, | |
1251 | 479, 319, 0, 0, 361, 318, -496, -496, 359, 0, | |
1252 | 0, 318, 360, 513, 515, 517, 430, 0, 318, 0, | |
1253 | 318, 320, 0, 318, 320, 318, 0, 318, 0, 0, | |
1254 | 0, 0, 0, 0, 194, 195, 0, 0, 0, 78, | |
1255 | 322, 0, 319, 0, 0, 0, 0, 319, 196, 0, | |
1256 | 0, 0, 321, 0, 197, 321, 320, 0, 320, 0, | |
1257 | 0, 198, 0, 0, 0, 199, 0, 0, 319, 0, | |
1258 | 0, 80, 0, 0, 81, 20, 319, 0, 200, 201, | |
1259 | 0, 0, 202, 0, 203, 615, 0, 321, 0, 321, | |
1260 | 0, 204, 205, 206, 207, 0, 0, 208, 209, 320, | |
1261 | 0, 0, 0, 0, 320, 0, 0, 0, 319, 0, | |
1262 | 0, 319, 0, 0, 0, 0, 0, 0, 0, 0, | |
1263 | 0, 0, 0, 0, 0, 320, 0, 0, 0, 319, | |
1264 | 321, 319, 0, 320, 319, 321, 331, 331, 331, 331, | |
1265 | 0, 0, 0, 0, 331, 331, 0, 319, 0, 0, | |
1266 | 0, 0, 0, 0, 0, 0, 321, 0, 0, 0, | |
1267 | 0, 319, 0, 0, 321, 320, 0, 319, 320, 0, | |
1268 | 0, 0, 0, 0, 319, 0, 319, 0, 0, 319, | |
1269 | 0, 319, 0, 319, 0, 0, 320, 0, 320, 0, | |
1270 | 322, 320, 0, 322, 0, 0, 321, 0, 0, 321, | |
1271 | 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, | |
1272 | 0, 0, 0, 0, 0, 0, 0, 321, 320, 321, | |
1273 | 0, 0, 321, 0, 320, 322, 0, 322, 0, 0, | |
1274 | 0, 320, 0, 320, 0, 321, 320, 0, 320, 0, | |
1275 | 320, 0, 0, 0, 0, 0, 0, 0, 0, 321, | |
1276 | 332, 332, 332, 332, 0, 321, 0, 156, 332, 332, | |
1277 | 0, 0, 321, 78, 321, 0, 0, 321, 322, 321, | |
1278 | 0, 321, 79, 322, 4, 0, 0, 0, 0, 0, | |
1279 | 5, 0, 0, 0, 0, 0, 0, 678, 0, 0, | |
1280 | 0, 0, 0, 0, 322, 80, 0, 0, 81, 20, | |
1281 | 0, 0, 322, 0, 0, 0, 0, 0, 157, 255, | |
1282 | 0, 0, 0, 331, 331, 331, 331, 331, 331, 331, | |
1283 | 331, 331, 331, 331, 331, 0, 331, 331, 331, 331, | |
1284 | 331, 331, 331, 0, 322, 0, 78, 322, 0, 0, | |
1285 | 0, 0, 0, 0, 2, 196, 0, 0, 0, 0, | |
1286 | 78, 197, 0, 0, 0, 322, 0, 322, 198, 79, | |
1287 | 322, 4, 199, 0, 0, 0, 0, 5, 80, 0, | |
1288 | 0, 81, 20, 322, 0, 200, 201, 0, 0, 202, | |
1289 | 0, 0, 80, 0, 0, 81, 20, 322, 204, 205, | |
1290 | 206, 207, 0, 322, 208, 209, 82, 0, 0, 0, | |
1291 | 322, 0, 322, 0, 263, 322, 0, 322, 0, 322, | |
1292 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
1293 | 331, 0, 0, 0, 0, 0, 331, 332, 332, 332, | |
2e5eb5c5 | 1294 | 332, 332, 332, 332, 332, 332, 332, 332, 332, 0, |
efa0a23f APB |
1295 | 332, 332, 332, 332, 332, 332, 332, 2, 194, 195, |
1296 | 651, 264, 265, 78, 266, 0, 0, 267, 0, 0, | |
1297 | 0, 268, 196, 0, 0, 652, 0, 0, 269, 270, | |
1298 | 5, 271, 0, 272, 273, 198, 274, 2, 263, 275, | |
1299 | 0, 0, 0, 78, 0, 80, 0, 0, 81, 20, | |
1300 | 0, 0, 79, 0, 4, 0, 276, 0, 157, 718, | |
1301 | 5, 0, 277, 0, 0, 204, 205, 206, 207, 0, | |
1302 | 0, 208, 209, 0, 0, 80, 0, 0, 81, 20, | |
1303 | 0, 2, 194, 195, 651, 264, 265, 78, 266, 126, | |
1304 | 0, 267, 0, 0, 332, 268, 196, 0, 0, 652, | |
1305 | 332, 0, 269, 270, 5, 271, 263, 272, 273, 198, | |
1306 | 274, 0, 0, 275, 0, 331, 331, 0, 0, 80, | |
1179ebc2 | 1307 | 0, 0, 81, 20, 0, 0, 0, 0, 0, 0, |
efa0a23f APB |
1308 | 276, 331, 157, 746, 0, 0, 277, 0, 0, 204, |
1309 | 205, 206, 207, 0, 0, 208, 209, 0, 0, 2, | |
1310 | 194, 195, -266, 264, 265, 78, 266, 0, 0, 267, | |
1311 | 0, 0, 0, 268, 196, 0, 0, -266, 0, 0, | |
1312 | 269, 270, 5, 271, 0, 272, 273, 198, 274, 0, | |
1313 | 0, 275, 0, 0, 0, 0, 0, 80, 0, 263, | |
1314 | 81, 20, 0, 0, 0, 0, 0, 0, 276, 0, | |
1315 | 157, -266, 0, 0, 277, 0, 0, 204, 205, 206, | |
1316 | 207, 0, 0, 208, 209, 0, 0, 0, 0, 0, | |
1317 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 332, | |
1318 | 332, 0, 2, 194, 195, 0, 264, 265, 78, 266, | |
1319 | 0, 0, 267, 0, 0, 332, 268, 196, 0, 0, | |
1320 | 0, 0, 0, 269, 270, 5, 271, 263, 272, 273, | |
1321 | 198, 274, 0, 0, 275, 0, 0, 0, 0, 0, | |
2e5eb5c5 | 1322 | 80, 0, 0, 81, 20, 0, 0, 0, 0, 0, |
efa0a23f | 1323 | 0, 276, 0, 157, 435, 0, 0, 277, 0, 0, |
2e5eb5c5 | 1324 | 204, 205, 206, 207, 0, 0, 208, 209, 0, 0, |
efa0a23f APB |
1325 | 2, 194, 195, 0, 264, 265, 78, 266, 0, 0, |
1326 | 267, 0, 0, 0, 268, 196, 0, 0, 0, 0, | |
1327 | 0, 269, 270, 5, 271, 263, 272, 273, 198, 274, | |
1328 | 0, 0, 275, 0, 0, 0, 0, 0, 80, 0, | |
1329 | 0, 81, 20, 0, 0, 0, 0, 0, 0, 276, | |
1330 | 0, 157, 0, 0, 0, 277, 0, 0, 204, 205, | |
1331 | 206, 207, 0, 0, 208, 209, 0, 0, 2, 194, | |
1332 | 195, 0, 264, 265, 78, 266, 0, 0, 267, 0, | |
1333 | 0, 0, 268, 196, 0, 0, 0, 0, 0, 269, | |
1334 | 270, 263, 271, 0, 272, 273, 198, 274, 0, 0, | |
1335 | 275, 0, 0, 0, 0, 0, 80, 0, 0, 81, | |
1336 | 20, 0, 0, 0, 0, 0, 0, 276, 0, 157, | |
1337 | 0, 0, 0, 277, 0, 0, 204, 205, 206, 207, | |
1338 | 0, 0, 208, 209, 2, 194, 195, 0, 692, 265, | |
1339 | 78, 266, 0, 0, 267, 0, 0, 0, 268, 196, | |
1340 | 0, 0, 0, 0, 0, 269, 270, 0, 271, 0, | |
1341 | 272, 273, 198, 274, 0, 191, 275, 192, 193, 0, | |
1342 | 0, 0, 80, 0, 0, 81, 20, 0, 0, 0, | |
1343 | 0, 0, 0, 276, 0, 157, 0, 0, 0, 277, | |
1344 | 0, 0, 204, 205, 206, 207, 0, 0, 208, 209, | |
1345 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 194, | |
1346 | 195, 0, 0, 0, 78, 0, 543, 0, 192, 193, | |
1347 | 0, 0, 0, 196, 0, 0, 0, 0, 0, 197, | |
1348 | 0, 0, 0, 0, 0, 0, 198, 0, 0, 0, | |
1349 | 199, 0, 0, 0, 0, 0, 80, 0, 0, 81, | |
1350 | 20, 0, 0, 200, 201, 0, 0, 202, 0, 203, | |
1351 | 194, 195, 0, 0, 0, 78, 204, 205, 206, 207, | |
1352 | 0, 0, 208, 209, 196, 0, 0, 0, 0, 0, | |
1353 | 197, 490, 0, 192, 193, 0, 0, 198, 0, 0, | |
1354 | 0, 199, 0, 0, 0, 0, 0, 80, 0, 0, | |
1355 | 81, 20, 0, 544, 200, 201, 0, 0, 202, 0, | |
1356 | 0, 0, 0, 0, 0, 0, 0, 204, 205, 206, | |
1357 | 207, 0, 0, 208, 209, 194, 195, 0, 0, 0, | |
1358 | 78, 0, 580, 0, 192, 193, 0, 0, 0, 196, | |
1359 | 0, 0, 0, 0, 0, 197, 0, 0, 0, 0, | |
1360 | 0, 0, 198, 0, 0, 0, 199, 0, 0, 0, | |
1361 | 0, 0, 80, 0, 0, 81, 20, 0, 0, 200, | |
1362 | 201, 0, 0, 202, 0, 0, 194, 195, 148, 0, | |
1363 | 0, 78, 204, 205, 206, 207, 0, 0, 208, 209, | |
1364 | 196, 0, 0, 0, 0, 0, 197, 588, 0, 192, | |
1365 | 193, 0, 0, 198, 0, 0, 0, 199, 0, 0, | |
1366 | 0, 0, 0, 80, 0, 0, 81, 20, 0, 0, | |
1367 | 200, 201, 0, 0, 202, 581, 0, 0, 0, 0, | |
1368 | 0, 0, 0, 204, 205, 206, 207, 0, 0, 208, | |
1369 | 209, 194, 195, 0, 0, 0, 78, 0, 596, 0, | |
1370 | 192, 193, 0, 0, 0, 196, 0, 0, 0, 0, | |
1371 | 0, 197, 0, 0, 0, 0, 0, 0, 198, 0, | |
12472854 | 1372 | 0, 0, 199, 0, 0, 0, 0, 0, 80, 0, |
0b4d333e | 1373 | 0, 81, 20, 0, 0, 200, 201, 0, 0, 202, |
efa0a23f APB |
1374 | 0, 0, 194, 195, 0, 589, 0, 78, 204, 205, |
1375 | 206, 207, 0, 0, 208, 209, 196, 0, 0, 0, | |
1376 | 0, 0, 197, 605, 0, 192, 193, 0, 0, 198, | |
22eed1e6 APB |
1377 | 0, 0, 0, 199, 0, 0, 0, 0, 0, 80, |
1378 | 0, 0, 81, 20, 0, 0, 200, 201, 0, 0, | |
efa0a23f APB |
1379 | 202, 0, 0, 0, 0, 597, 0, 0, 0, 204, |
1380 | 205, 206, 207, 0, 0, 208, 209, 194, 195, 0, | |
1381 | 0, 0, 78, 0, 490, 0, 192, 193, 0, 0, | |
1382 | 0, 196, 0, 0, 0, 0, 0, 197, 0, 0, | |
1383 | 0, 0, 0, 0, 198, 0, 0, 0, 199, 0, | |
1384 | 0, 0, 0, 0, 80, 0, 0, 81, 20, 0, | |
1385 | 0, 200, 201, 0, 0, 202, 606, 0, 194, 195, | |
1386 | 0, 0, 0, 78, 204, 205, 206, 207, 0, 0, | |
1387 | 208, 209, 196, 0, 0, 0, 0, 0, 197, 580, | |
1388 | 0, 192, 193, 0, 0, 198, 0, 0, 0, 199, | |
1389 | 0, 0, 0, 0, 0, 80, 0, 0, 81, 20, | |
1390 | 0, 0, 200, 201, 0, 0, 202, 0, 0, 0, | |
1391 | 0, 597, 0, 0, 0, 204, 205, 206, 207, 0, | |
1392 | 0, 208, 209, 194, 195, 0, 0, 0, 78, 0, | |
1393 | 706, 0, 192, 193, 0, 0, 0, 196, 0, 0, | |
1394 | 0, 0, 0, 197, 0, 0, 0, 0, 0, 0, | |
22eed1e6 APB |
1395 | 198, 0, 0, 0, 199, 0, 0, 0, 0, 0, |
1396 | 80, 0, 0, 81, 20, 0, 0, 200, 201, 0, | |
efa0a23f APB |
1397 | 0, 202, 690, 0, 194, 195, 0, 0, 0, 78, |
1398 | 204, 205, 206, 207, 0, 0, 208, 209, 196, 0, | |
1399 | 0, 0, 0, 0, 197, 706, 0, 192, 193, 0, | |
22eed1e6 APB |
1400 | 0, 198, 0, 0, 0, 199, 0, 0, 0, 0, |
1401 | 0, 80, 0, 0, 81, 20, 0, 0, 200, 201, | |
efa0a23f APB |
1402 | 0, 0, 202, 707, 0, 0, 0, 0, 0, 0, |
1403 | 0, 204, 205, 206, 207, 0, 0, 208, 209, 194, | |
1404 | 195, 0, 0, 0, 78, 0, 588, 0, 192, 193, | |
1405 | 0, 0, 0, 196, 0, 0, 0, 0, 0, 197, | |
1406 | 0, 0, 0, 0, 0, 0, 198, 0, 0, 0, | |
1407 | 199, 0, 0, 0, 0, 0, 80, 0, 0, 81, | |
1408 | 20, 0, 0, 200, 201, 0, 0, 202, 750, 0, | |
1409 | 194, 195, 0, 0, 0, 78, 204, 205, 206, 207, | |
1410 | 0, 0, 208, 209, 196, 0, 0, 0, 0, 0, | |
1411 | 197, 329, 0, 192, 193, 0, 0, 198, 0, 0, | |
1412 | 0, 199, 0, 0, 0, 0, 0, 80, 0, 0, | |
1413 | 81, 20, 0, 0, 200, 201, 0, 0, 202, 0, | |
1414 | 0, 0, 0, 0, 755, 0, 0, 204, 205, 206, | |
1415 | 207, 0, 0, 208, 209, 194, 195, 0, 0, 0, | |
1416 | 78, 0, 334, 0, 192, 193, 0, 0, 0, 196, | |
1417 | 0, 0, 0, 0, 0, 197, 0, 0, 0, 0, | |
22eed1e6 APB |
1418 | 0, 0, 198, 0, 0, 0, 199, 0, 0, 0, |
1419 | 0, 0, 80, 0, 0, 81, 20, 0, 0, 200, | |
efa0a23f APB |
1420 | 201, 0, 0, 202, 0, 0, 194, 195, 0, 0, |
1421 | 0, 78, 204, 205, 206, 207, 0, 0, 208, 209, | |
1422 | 196, 0, 0, 0, 0, 0, 197, 336, 0, 192, | |
1423 | 193, 0, 0, 198, 0, 0, 0, 199, 0, 0, | |
1424 | 0, 0, 0, 80, 0, 0, 81, 20, 0, 0, | |
1425 | 200, 201, 0, 0, 202, 0, 0, 0, 0, 0, | |
1426 | 0, 0, 0, 204, 205, 206, 207, 0, 0, 208, | |
1427 | 209, 194, 195, 0, 0, 0, 78, 0, 338, 0, | |
1428 | 192, 193, 0, 0, 0, 196, 0, 0, 0, 0, | |
1429 | 0, 197, 0, 0, 0, 0, 0, 0, 198, 0, | |
22eed1e6 APB |
1430 | 0, 0, 199, 0, 0, 0, 0, 0, 80, 0, |
1431 | 0, 81, 20, 0, 0, 200, 201, 0, 0, 202, | |
efa0a23f APB |
1432 | 0, 0, 194, 195, 0, 0, 0, 78, 204, 205, |
1433 | 206, 207, 0, 0, 208, 209, 196, 0, 0, 0, | |
1434 | 0, 0, 197, 347, 0, 192, 193, 0, 0, 198, | |
22eed1e6 APB |
1435 | 0, 0, 0, 199, 0, 0, 0, 0, 0, 80, |
1436 | 0, 0, 81, 20, 0, 0, 200, 201, 0, 0, | |
efa0a23f APB |
1437 | 202, 0, 0, 0, 0, 0, 0, 0, 0, 204, |
1438 | 205, 206, 207, 0, 0, 208, 209, 194, 195, 0, | |
1439 | 0, 0, 78, 0, 349, 0, 192, 193, 0, 0, | |
1440 | 0, 196, 0, 0, 0, 0, 0, 197, 0, 0, | |
1441 | 0, 0, 0, 0, 198, 0, 0, 0, 199, 0, | |
1442 | 0, 0, 0, 0, 80, 0, 0, 81, 20, 0, | |
1443 | 0, 200, 201, 0, 0, 202, 0, 0, 194, 195, | |
1444 | 0, 0, 0, 78, 204, 205, 206, 207, 0, 0, | |
1445 | 208, 209, 196, 0, 0, 0, 0, 0, 197, 351, | |
1446 | 0, 192, 193, 0, 0, 198, 0, 0, 0, 199, | |
1447 | 0, 0, 0, 0, 0, 80, 0, 0, 81, 20, | |
1448 | 0, 0, 200, 201, 0, 0, 202, 0, 0, 0, | |
1449 | 0, 0, 0, 0, 0, 204, 205, 206, 207, 0, | |
1450 | 0, 208, 209, 194, 195, 0, 0, 0, 78, 0, | |
1451 | 408, 0, 192, 193, 0, 0, 0, 196, 0, 0, | |
1452 | 0, 0, 0, 197, 0, 0, 0, 0, 0, 0, | |
22eed1e6 APB |
1453 | 198, 0, 0, 0, 199, 0, 0, 0, 0, 0, |
1454 | 80, 0, 0, 81, 20, 0, 0, 200, 201, 0, | |
efa0a23f APB |
1455 | 0, 202, 0, 0, 194, 195, 0, 0, 0, 78, |
1456 | 204, 205, 206, 207, 0, 0, 208, 209, 196, 0, | |
1457 | 0, 0, 0, 0, 197, 490, 0, 192, 193, 0, | |
2e5eb5c5 APB |
1458 | 0, 198, 0, 0, 0, 199, 0, 0, 0, 0, |
1459 | 0, 80, 0, 0, 81, 20, 0, 0, 200, 201, | |
efa0a23f APB |
1460 | 0, 0, 202, 0, 0, 0, 0, 0, 0, 0, |
1461 | 0, 204, 205, 206, 207, 0, 0, 208, 209, 194, | |
1462 | 195, 0, 0, 0, 78, 0, 498, 0, 192, 193, | |
1463 | 0, 0, 0, 196, 0, 0, 0, 0, 0, 197, | |
1464 | 0, 0, 0, 0, 0, 0, 198, 0, 0, 0, | |
1465 | 199, 0, 0, 0, 0, 0, 80, 0, 0, 81, | |
1466 | 20, 0, 0, 200, 201, 0, 0, 202, 0, 0, | |
1467 | 194, 195, 0, 0, 0, 78, 204, 205, 206, 207, | |
1468 | 0, 0, 208, 209, 196, 0, 0, 0, 0, 0, | |
1469 | 197, 502, 0, 192, 193, 0, 0, 198, 0, 0, | |
2e5eb5c5 APB |
1470 | 0, 199, 0, 0, 0, 0, 0, 80, 0, 0, |
1471 | 81, 20, 0, 0, 200, 201, 0, 0, 202, 0, | |
efa0a23f APB |
1472 | 0, 0, 0, 0, 0, 0, 0, 204, 205, 206, |
1473 | 207, 0, 0, 208, 209, 194, 195, 0, 0, 0, | |
1474 | 78, 0, 504, 0, 192, 193, 0, 0, 0, 196, | |
1475 | 0, 0, 0, 0, 0, 197, 0, 0, 0, 0, | |
1476 | 0, 0, 198, 0, 0, 0, 199, 0, 0, 0, | |
1477 | 0, 0, 80, 0, 0, 81, 20, 0, 0, 200, | |
1478 | 201, 0, 0, 202, 0, 0, 194, 195, 0, 0, | |
1479 | 0, 78, 204, 205, 206, 207, 0, 0, 208, 209, | |
1480 | 196, 0, 0, 0, 0, 0, 197, 506, 0, 192, | |
1481 | 193, 0, 0, 198, 0, 0, 0, 199, 0, 0, | |
1482 | 0, 0, 0, 80, 0, 0, 81, 20, 0, 0, | |
1483 | 200, 201, 0, 0, 202, 0, 0, 0, 0, 0, | |
1484 | 0, 0, 0, 204, 205, 206, 207, 0, 0, 208, | |
1485 | 209, 194, 195, 0, 0, 0, 78, 0, 508, 0, | |
1486 | 192, 193, 0, 0, 0, 196, 0, 0, 0, 0, | |
1487 | 0, 197, 0, 0, 0, 0, 0, 0, 198, 0, | |
22eed1e6 APB |
1488 | 0, 0, 199, 0, 0, 0, 0, 0, 80, 0, |
1489 | 0, 81, 20, 0, 0, 200, 201, 0, 0, 202, | |
efa0a23f APB |
1490 | 0, 0, 194, 195, 0, 0, 0, 78, 204, 205, |
1491 | 206, 207, 0, 0, 208, 209, 196, 0, 0, 0, | |
1492 | 0, 0, 197, 510, 0, 192, 193, 0, 0, 198, | |
22eed1e6 APB |
1493 | 0, 0, 0, 199, 0, 0, 0, 0, 0, 80, |
1494 | 0, 0, 81, 20, 0, 0, 200, 201, 0, 0, | |
efa0a23f APB |
1495 | 202, 0, 0, 0, 0, 0, 0, 0, 0, 204, |
1496 | 205, 206, 207, 0, 0, 208, 209, 194, 195, 0, | |
1497 | 0, 0, 78, 0, 512, 0, 192, 193, 0, 0, | |
1498 | 0, 196, 0, 0, 0, 0, 0, 197, 0, 0, | |
1499 | 0, 0, 0, 0, 198, 0, 0, 0, 199, 0, | |
1500 | 0, 0, 0, 0, 80, 0, 0, 81, 20, 0, | |
1501 | 0, 200, 201, 0, 0, 202, 0, 0, 194, 195, | |
1502 | 0, 0, 0, 78, 204, 205, 206, 207, 0, 0, | |
1503 | 208, 209, 196, 0, 0, 0, 0, 0, 197, 514, | |
1504 | 0, 192, 193, 0, 0, 198, 0, 0, 0, 199, | |
1505 | 0, 0, 0, 0, 0, 80, 0, 0, 81, 20, | |
1506 | 0, 0, 200, 201, 0, 0, 202, 0, 0, 0, | |
1507 | 0, 0, 0, 0, 0, 204, 205, 206, 207, 0, | |
1508 | 0, 208, 209, 194, 195, 0, 0, 0, 78, 0, | |
1509 | 516, 0, 192, 193, 0, 0, 0, 196, 0, 0, | |
1510 | 0, 0, 0, 197, 0, 0, 0, 0, 0, 0, | |
22eed1e6 APB |
1511 | 198, 0, 0, 0, 199, 0, 0, 0, 0, 0, |
1512 | 80, 0, 0, 81, 20, 0, 0, 200, 201, 0, | |
efa0a23f APB |
1513 | 0, 202, 0, 0, 194, 195, 0, 0, 0, 78, |
1514 | 204, 205, 206, 207, 0, 0, 208, 209, 196, 0, | |
1515 | 0, 0, 0, 0, 197, 518, 0, 192, 193, 0, | |
2e5eb5c5 APB |
1516 | 0, 198, 0, 0, 0, 199, 0, 0, 0, 0, |
1517 | 0, 80, 0, 0, 81, 20, 0, 0, 200, 201, | |
efa0a23f APB |
1518 | 0, 0, 202, 0, 0, 0, 0, 0, 0, 0, |
1519 | 0, 204, 205, 206, 207, 0, 0, 208, 209, 194, | |
1520 | 195, 0, 0, 0, 78, 0, 520, 0, 192, 193, | |
1521 | 0, 0, 0, 196, 0, 0, 0, 0, 0, 197, | |
1522 | 0, 0, 0, 0, 0, 0, 198, 0, 0, 0, | |
1523 | 199, 0, 0, 0, 0, 0, 80, 0, 0, 81, | |
1524 | 20, 0, 0, 200, 201, 0, 0, 202, 0, 0, | |
1525 | 194, 195, 0, 0, 0, 78, 204, 205, 206, 207, | |
1526 | 0, 0, 208, 209, 196, 0, 0, 0, 0, 0, | |
1527 | 197, 522, 0, 192, 193, 0, 0, 198, 0, 0, | |
2e5eb5c5 APB |
1528 | 0, 199, 0, 0, 0, 0, 0, 80, 0, 0, |
1529 | 81, 20, 0, 0, 200, 201, 0, 0, 202, 0, | |
efa0a23f APB |
1530 | 0, 0, 0, 0, 0, 0, 0, 204, 205, 206, |
1531 | 207, 0, 0, 208, 209, 194, 195, 0, 0, 0, | |
1532 | 78, 0, 524, 0, 192, 193, 0, 0, 0, 196, | |
1533 | 0, 0, 0, 0, 0, 197, 0, 0, 0, 0, | |
1534 | 0, 0, 198, 0, 0, 0, 199, 0, 0, 0, | |
1535 | 0, 0, 80, 0, 0, 81, 20, 0, 0, 200, | |
1536 | 201, 0, 0, 202, 0, 0, 194, 195, 0, 0, | |
1537 | 0, 78, 204, 205, 206, 207, 0, 0, 208, 209, | |
1538 | 196, 0, 0, 0, 0, 0, 197, 529, 0, 192, | |
1539 | 193, 0, 0, 198, 0, 0, 0, 199, 0, 0, | |
1540 | 0, 0, 0, 80, 0, 0, 81, 20, 0, 0, | |
1541 | 200, 201, 0, 0, 202, 0, 0, 0, 0, 0, | |
1542 | 0, 0, 0, 204, 205, 206, 207, 0, 0, 208, | |
1543 | 209, 194, 195, 0, 0, 0, 78, 0, 531, 0, | |
1544 | 192, 193, 0, 0, 0, 196, 0, 0, 0, 0, | |
1545 | 0, 197, 0, 0, 0, 0, 0, 0, 198, 0, | |
22eed1e6 APB |
1546 | 0, 0, 199, 0, 0, 0, 0, 0, 80, 0, |
1547 | 0, 81, 20, 0, 0, 200, 201, 0, 0, 202, | |
efa0a23f APB |
1548 | 0, 0, 194, 195, 0, 0, 0, 78, 204, 205, |
1549 | 206, 207, 0, 0, 208, 209, 196, 0, 0, 0, | |
1550 | 0, 0, 197, 533, 0, 192, 193, 0, 0, 198, | |
22eed1e6 APB |
1551 | 0, 0, 0, 199, 0, 0, 0, 0, 0, 80, |
1552 | 0, 0, 81, 20, 0, 0, 200, 201, 0, 0, | |
efa0a23f APB |
1553 | 202, 0, 0, 0, 0, 0, 0, 0, 0, 204, |
1554 | 205, 206, 207, 0, 0, 208, 209, 194, 195, 0, | |
1555 | 0, 0, 78, 0, 535, 0, 192, 193, 0, 0, | |
1556 | 0, 196, 0, 0, 0, 0, 0, 197, 0, 0, | |
1557 | 0, 0, 0, 0, 198, 0, 0, 0, 199, 0, | |
1558 | 0, 0, 0, 0, 80, 0, 0, 81, 20, 0, | |
1559 | 0, 200, 201, 0, 0, 202, 0, 0, 194, 195, | |
1560 | 0, 0, 0, 78, 204, 205, 206, 207, 0, 0, | |
1561 | 208, 209, 196, 0, 0, 0, 0, 0, 197, 537, | |
1562 | 0, 192, 193, 0, 0, 198, 0, 0, 0, 199, | |
1563 | 0, 0, 0, 0, 0, 80, 0, 0, 81, 20, | |
1564 | 0, 0, 200, 201, 0, 0, 202, 0, 0, 0, | |
1565 | 0, 0, 0, 0, 0, 204, 205, 206, 207, 0, | |
1566 | 0, 208, 209, 194, 195, 0, 0, 0, 78, 0, | |
1567 | 539, 0, 192, 193, 0, 0, 0, 196, 0, 0, | |
1568 | 0, 0, 0, 197, 0, 0, 0, 0, 0, 0, | |
22eed1e6 APB |
1569 | 198, 0, 0, 0, 199, 0, 0, 0, 0, 0, |
1570 | 80, 0, 0, 81, 20, 0, 0, 200, 201, 0, | |
efa0a23f APB |
1571 | 0, 202, 0, 0, 194, 195, 0, 0, 0, 78, |
1572 | 204, 205, 206, 207, 0, 0, 208, 209, 196, 0, | |
1573 | 0, 0, 0, 0, 197, 541, 0, 192, 193, 0, | |
2e5eb5c5 APB |
1574 | 0, 198, 0, 0, 0, 199, 0, 0, 0, 0, |
1575 | 0, 80, 0, 0, 81, 20, 0, 0, 200, 201, | |
efa0a23f APB |
1576 | 0, 0, 202, 0, 0, 0, 0, 0, 0, 0, |
1577 | 0, 204, 205, 206, 207, 0, 0, 208, 209, 194, | |
1578 | 195, 0, 0, 0, 78, 0, 546, 0, 192, 193, | |
1579 | 0, 0, 0, 196, 0, 0, 0, 0, 0, 197, | |
1580 | 0, 0, 0, 0, 0, 0, 198, 0, 0, 0, | |
1581 | 199, 0, 0, 0, 0, 0, 80, 0, 0, 81, | |
1582 | 20, 0, 0, 200, 201, 0, 0, 202, 0, 0, | |
1583 | 194, 195, 0, 0, 0, 78, 204, 205, 206, 207, | |
1584 | 0, 0, 208, 209, 196, 0, 0, 0, 0, 0, | |
1585 | 197, 556, 0, 192, 193, 0, 0, 198, 0, 0, | |
2e5eb5c5 APB |
1586 | 0, 199, 0, 0, 0, 0, 0, 80, 0, 0, |
1587 | 81, 20, 0, 0, 200, 201, 0, 0, 202, 0, | |
efa0a23f APB |
1588 | 0, 0, 0, 0, 0, 0, 0, 204, 205, 206, |
1589 | 207, 0, 0, 208, 209, 194, 195, 0, 0, 0, | |
1590 | 78, 0, 564, 0, 192, 193, 0, 0, 0, 196, | |
1591 | 0, 0, 0, 0, 0, 197, 0, 0, 0, 0, | |
1592 | 0, 0, 198, 0, 0, 0, 199, 0, 0, 0, | |
1593 | 0, 0, 80, 0, 0, 81, 20, 0, 0, 200, | |
1594 | 201, 0, 0, 202, 0, 0, 194, 195, 0, 0, | |
1595 | 0, 78, 204, 205, 206, 207, 0, 0, 208, 209, | |
1596 | 196, 0, 0, 0, 0, 0, 197, 566, 0, 192, | |
1597 | 193, 0, 0, 198, 0, 0, 0, 199, 0, 0, | |
1598 | 0, 0, 0, 80, 0, 0, 81, 20, 0, 0, | |
1599 | 200, 201, 0, 0, 202, 0, 0, 0, 0, 0, | |
1600 | 0, 0, 0, 204, 205, 206, 207, 0, 0, 208, | |
1601 | 209, 194, 195, 0, 0, 0, 78, 0, 591, 0, | |
1602 | 192, 193, 0, 0, 0, 196, 0, 0, 0, 0, | |
1603 | 0, 197, 0, 0, 0, 0, 0, 0, 198, 0, | |
22eed1e6 APB |
1604 | 0, 0, 199, 0, 0, 0, 0, 0, 80, 0, |
1605 | 0, 81, 20, 0, 0, 200, 201, 0, 0, 202, | |
efa0a23f APB |
1606 | 0, 0, 194, 195, 0, 0, 0, 78, 204, 205, |
1607 | 206, 207, 0, 0, 208, 209, 196, 0, 0, 0, | |
1608 | 0, 0, 197, 608, 0, 192, 193, 0, 0, 198, | |
22eed1e6 APB |
1609 | 0, 0, 0, 199, 0, 0, 0, 0, 0, 80, |
1610 | 0, 0, 81, 20, 0, 0, 200, 201, 0, 0, | |
efa0a23f APB |
1611 | 202, 0, 0, 0, 0, 0, 0, 0, 0, 204, |
1612 | 205, 206, 207, 0, 0, 208, 209, 194, 195, 0, | |
1613 | 0, 0, 78, 0, 676, 0, 192, 193, 0, 0, | |
1614 | 0, 196, 0, 0, 0, 0, 0, 197, 0, 0, | |
1615 | 0, 0, 0, 0, 198, 0, 0, 0, 199, 0, | |
1616 | 0, 0, 0, 0, 80, 0, 0, 81, 20, 0, | |
1617 | 0, 200, 201, 0, 0, 202, 0, 0, 194, 195, | |
1618 | 0, 0, 0, 78, 204, 205, 206, 207, 0, 0, | |
1619 | 208, 209, 196, 0, 0, 0, 0, 0, 197, 680, | |
1620 | 0, 192, 193, 0, 0, 198, 0, 0, 0, 199, | |
1621 | 0, 0, 0, 0, 0, 80, 0, 0, 81, 20, | |
1622 | 0, 0, 200, 201, 0, 0, 202, 0, 0, 0, | |
1623 | 0, 0, 0, 0, 0, 204, 205, 206, 207, 0, | |
1624 | 0, 208, 209, 194, 195, 0, 0, 0, 78, 0, | |
1625 | 686, 0, 192, 193, 0, 0, 0, 196, 0, 0, | |
1626 | 0, 0, 0, 197, 0, 0, 0, 0, 0, 0, | |
22eed1e6 APB |
1627 | 198, 0, 0, 0, 199, 0, 0, 0, 0, 0, |
1628 | 80, 0, 0, 81, 20, 0, 0, 200, 201, 0, | |
efa0a23f APB |
1629 | 0, 202, 0, 0, 194, 195, 0, 0, 0, 78, |
1630 | 204, 205, 206, 207, 0, 0, 208, 209, 196, 0, | |
1631 | 0, 0, 0, 0, 197, 712, 0, 192, 193, 0, | |
2e5eb5c5 APB |
1632 | 0, 198, 0, 0, 0, 199, 0, 0, 0, 0, |
1633 | 0, 80, 0, 0, 81, 20, 0, 0, 200, 201, | |
efa0a23f APB |
1634 | 0, 0, 202, 0, 0, 0, 0, 0, 0, 0, |
1635 | 0, 204, 205, 206, 207, 0, 0, 208, 209, 194, | |
1636 | 195, 0, 0, 0, 78, 0, 574, 0, 0, 0, | |
1637 | 0, 0, 0, 196, 0, 0, 0, 0, 0, 197, | |
1638 | 0, 0, 0, 0, 0, 0, 198, 0, 0, 0, | |
1639 | 199, 661, 0, 0, 0, 0, 80, 0, 0, 81, | |
1640 | 20, 0, 0, 200, 201, 0, 0, 202, 0, -289, | |
1641 | -289, -289, 0, 0, 0, -289, 204, 205, 206, 207, | |
1642 | 0, 0, 208, 209, -289, 0, 0, 0, 0, 0, | |
1643 | -289, 0, 0, 723, 0, 194, 195, -289, 0, 0, | |
1644 | 78, -289, 0, 0, 0, 0, 0, -289, 0, 196, | |
1645 | -289, -289, 0, 0, 0, 197, 0, 0, -289, 0, | |
1646 | 192, 193, 198, 0, -289, 0, 199, -289, -289, -289, | |
1647 | -289, 0, 80, -289, -289, 81, 20, 194, 195, 0, | |
1648 | 0, 0, 78, 276, -297, 0, 0, 0, 0, 0, | |
1649 | 0, 196, 204, 205, 206, 207, 0, 197, 208, 209, | |
1650 | 659, 0, 194, 195, 198, 0, 0, 78, 199, 0, | |
1651 | 0, 0, 0, 0, 80, 0, 196, 81, 20, 0, | |
1652 | 0, 0, 197, 0, 0, 276, -297, 192, 193, 198, | |
1653 | 0, 0, 0, 199, 204, 205, 206, 207, 0, 80, | |
1654 | 208, 209, 81, 20, 194, 195, 200, 201, 0, 78, | |
1655 | 202, 0, 203, 355, 0, 0, 0, 0, 196, 204, | |
1656 | 205, 206, 207, 0, 197, 208, 209, 0, 0, 194, | |
1657 | 195, 198, 0, 0, 78, 199, 0, 0, 192, 193, | |
1658 | 0, 80, 0, 196, 81, 20, 0, 0, 0, 197, | |
1659 | 0, 0, 276, 0, 0, 0, 198, 0, 0, 0, | |
1660 | 199, 204, 205, 206, 207, 0, 80, 208, 209, 81, | |
1661 | 20, 0, 0, 200, 201, 0, 0, 202, 487, 0, | |
1662 | 194, 195, 0, 0, 0, 78, 204, 205, 206, 207, | |
1663 | 0, 0, 208, 209, 196, 0, 0, 0, 0, 0, | |
1664 | 197, 0, 0, 192, 193, 0, 0, 198, 0, 0, | |
1665 | 0, 199, 0, 0, 0, 0, 0, 80, 0, 0, | |
1666 | 81, 20, 0, 0, 200, 201, 0, 0, 202, 624, | |
1667 | 0, 0, 0, 0, 0, 0, 0, 204, 205, 206, | |
1668 | 207, 0, 0, 208, 209, 194, 195, 0, 0, 0, | |
1669 | 78, 0, 0, 0, 192, 193, 0, 0, 0, 196, | |
1670 | 0, 0, 0, 0, 0, 197, 0, 0, 0, 0, | |
2e5eb5c5 APB |
1671 | 0, 0, 198, 0, 0, 0, 199, 0, 0, 0, |
1672 | 0, 0, 80, 0, 0, 81, 20, 0, 0, 200, | |
efa0a23f APB |
1673 | 201, 0, 0, 202, 667, 0, 194, 195, 0, 0, |
1674 | 0, 78, 204, 205, 206, 207, 0, 0, 208, 209, | |
1675 | 196, 0, 0, 0, 0, 0, 197, 0, 0, 192, | |
1676 | 193, 0, 0, 198, 0, 0, 0, 199, 0, 0, | |
1677 | 0, 0, 0, 80, 0, 0, 81, 20, 0, 0, | |
1678 | 200, 201, 0, 0, 202, 682, 0, 0, 0, 0, | |
1679 | 0, 0, 0, 204, 205, 206, 207, 0, 0, 208, | |
1680 | 209, 194, 195, 0, 0, 0, 78, 0, 0, 0, | |
1681 | 0, 0, 0, 0, 0, 196, 0, 0, 0, 0, | |
1682 | 0, 197, 0, 0, 0, 0, 0, 0, 198, 0, | |
22eed1e6 | 1683 | 0, 0, 199, 0, 0, 0, 0, 0, 80, 0, |
efa0a23f APB |
1684 | 0, 81, 20, 0, 0, 200, 201, 0, 0, 202, |
1685 | 0, 2, 194, 195, 0, 0, 0, 78, 204, 205, | |
1686 | 206, 207, 0, 0, 208, 209, 196, 0, 0, 0, | |
2e5eb5c5 | 1687 | 0, 0, 197, 0, 0, 0, 0, 0, 0, 198, |
efa0a23f APB |
1688 | 0, 0, 78, 199, 0, 0, 0, 0, 0, 80, |
1689 | 0, 196, 81, 20, 0, 0, 0, 197, 0, 0, | |
1690 | 276, 0, 0, 0, 198, 0, 0, 0, 199, 204, | |
1691 | 205, 206, 207, 0, 80, 208, 209, 81, 20, 0, | |
1692 | 0, 200, 201, 0, 0, 202, 0, 0, 0, 0, | |
1693 | 0, 0, 0, 0, 204, 205, 206, 207, 0, 0, | |
1694 | 208, 209 | |
8b27f225 PB |
1695 | }; |
1696 | ||
1697 | static const short yycheck[] = { 3, | |
efa0a23f APB |
1698 | 327, 62, 6, 132, 62, 123, 286, 140, 129, 203, |
1699 | 175, 179, 134, 1, 482, 345, 0, 42, 117, 1, | |
1700 | 434, 46, 352, 353, 1, 9, 10, 11, 89, 1, | |
1701 | 1, 89, 1, 94, 656, 306, 94, 86, 42, 64, | |
1702 | 664, 162, 46, 1, 69, 95, 30, 1, 169, 33, | |
1703 | 34, 150, 1, 53, 153, 1, 94, 100, 62, 62, | |
1704 | 64, 475, 95, 101, 97, 69, 1, 51, 129, 202, | |
1705 | 203, 129, 133, 172, 1, 133, 198, 1, 62, 72, | |
1706 | 192, 193, 194, 195, 1, 89, 1, 501, 200, 201, | |
1707 | 94, 94, 52, 86, 1, 717, 67, 97, 67, 160, | |
1708 | 101, 162, 160, 128, 162, 1, 1, 1, 97, 134, | |
1709 | 94, 99, 94, 101, 175, 1, 1, 94, 1, 180, | |
1710 | 100, 1, 180, 100, 128, 129, 129, 99, 100, 133, | |
1711 | 134, 755, 265, 4, 5, 268, 94, 198, 259, 469, | |
1712 | 764, 202, 472, 276, 612, 129, 95, 101, 1, 1, | |
1713 | 99, 272, 0, 99, 100, 254, 160, 325, 162, 162, | |
1714 | 278, 9, 10, 11, 99, 36, 37, 1, 1, 40, | |
1715 | 1, 175, 99, 198, 101, 99, 180, 94, 162, 50, | |
1716 | 1, 595, 30, 100, 99, 33, 34, 94, 192, 193, | |
1717 | 194, 195, 253, 100, 198, 253, 200, 201, 202, 94, | |
1718 | 86, 1, 98, 51, 98, 100, 328, 621, 79, 94, | |
1719 | 93, 1, 83, 99, 62, 100, 1, 631, 101, 99, | |
1720 | 9, 282, 293, 15, 282, 286, 1, 360, 1, 97, | |
1721 | 301, 364, 303, 647, 86, 1, 1, 402, 1, 0, | |
1722 | 1, 1, 95, 1, 33, 306, 94, 99, 1, 253, | |
1723 | 1, 122, 123, 86, 129, 1, 389, 369, 370, 371, | |
1724 | 1, 0, 1, 95, 1, 99, 327, 98, 139, 327, | |
1725 | 635, 1, 95, 96, 407, 555, 99, 98, 282, 99, | |
1726 | 100, 129, 286, 44, 417, 133, 419, 162, 93, 293, | |
1727 | 484, 635, 635, 1, 55, 87, 429, 301, 98, 303, | |
1728 | 61, 52, 306, 328, 175, 44, 67, 1, 179, 99, | |
1729 | 95, 86, 63, 640, 162, 433, 587, 731, 589, 452, | |
1730 | 381, 454, 61, 327, 328, 1, 99, 175, 67, 94, | |
1731 | 635, 696, 96, 99, 699, 468, 99, 1, 99, 99, | |
1732 | 98, 402, 1, 1, 95, 98, 479, 218, 1, 95, | |
1733 | 630, 484, 696, 696, 1, 699, 699, 98, 52, 1, | |
1734 | 99, 98, 1, 93, 476, 369, 370, 371, 372, 373, | |
22eed1e6 | 1735 | 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, |
efa0a23f APB |
1736 | 384, 385, 386, 387, 388, 93, 447, 552, 52, 447, |
1737 | 1, 696, 175, 664, 699, 64, 267, 762, 402, 63, | |
1738 | 69, 95, 767, 274, 769, 253, 771, 278, 0, 1, | |
1739 | 63, 1, 1, 1, 94, 286, 1, 93, 762, 762, | |
1740 | 100, 63, 293, 767, 767, 769, 769, 771, 771, 1, | |
1741 | 301, 95, 303, 98, 1, 93, 95, 1, 286, 719, | |
1742 | 1, 95, 95, 447, 1, 0, 1, 94, 569, 175, | |
1743 | 1, 572, 44, 95, 325, 94, 1, 762, 306, 128, | |
1744 | 91, 92, 767, 55, 769, 1, 771, 1, 93, 61, | |
1745 | 1, 342, 476, 0, 1, 67, 1, 606, 482, 327, | |
1746 | 5, 45, 46, 75, 755, 618, 0, 1, 1, 44, | |
1747 | 361, 552, 363, 764, 555, 624, 1, 95, 88, 611, | |
1748 | 55, 1, 99, 286, 93, 93, 61, 99, 93, 175, | |
1749 | 293, 1, 67, 1, 91, 92, 129, 44, 301, 652, | |
1750 | 303, 93, 86, 306, 88, 658, 93, 91, 92, 93, | |
1751 | 44, 402, 93, 97, 61, 86, 93, 101, 97, 1, | |
1752 | 67, 55, 101, 88, 99, 666, 675, 61, 552, 162, | |
1753 | 86, 555, 86, 67, 402, 86, 685, 1, 1, 430, | |
1754 | 286, 86, 433, 1, 635, 1, 95, 293, 53, 630, | |
1755 | 99, 175, 99, 86, 1, 301, 1, 303, 100, 640, | |
1756 | 306, 86, 640, 1, 1, 99, 0, 1, 0, 1, | |
1757 | 1, 101, 92, 93, 1, 656, 86, 97, 98, 99, | |
1758 | 100, 734, 99, 100, 92, 738, 94, 611, 612, 97, | |
1759 | 98, 99, 100, 129, 94, 552, 1, 97, 555, 402, | |
1760 | 286, 45, 46, 627, 86, 696, 630, 293, 699, 67, | |
1761 | 44, 635, 44, 44, 72, 301, 640, 303, 76, 50, | |
1762 | 306, 101, 86, 86, 160, 1, 162, 61, 86, 61, | |
1763 | 86, 722, 656, 67, 94, 67, 717, 1, 719, 86, | |
1764 | 100, 86, 101, 1, 735, 1, 94, 97, 86, 86, | |
1765 | 1, 82, 100, 97, 85, 86, 402, 101, 749, 86, | |
1766 | 13, 552, 286, 94, 555, 99, 11, 99, 44, 293, | |
1767 | 1, 762, 696, 630, 50, 699, 767, 301, 769, 303, | |
1768 | 771, 86, 306, 59, 552, 61, 44, 555, 44, 12, | |
1769 | 65, 67, 50, 717, 50, 719, 94, 72, 722, 50, | |
1770 | 696, 83, 100, 699, 97, 14, 82, 175, 101, 85, | |
1771 | 86, 735, 1, 99, 3, 4, 402, 94, 47, 50, | |
1772 | 45, 46, 86, 100, 82, 749, 82, 85, 86, 85, | |
1773 | 86, 82, 107, 62, 85, 86, 95, 628, 762, 630, | |
1774 | 122, 123, 94, 767, 635, 769, 44, 771, 100, 552, | |
1775 | 93, 82, 555, 47, 85, 86, 45, 46, 9, 93, | |
1776 | 11, 50, 630, 61, 175, 656, 762, 96, 62, 67, | |
1777 | 59, 767, 640, 769, 86, 771, 65, 99, 402, 91, | |
1778 | 92, 93, 33, 72, 587, 97, 589, 76, 656, 101, | |
1779 | 45, 46, 99, 82, 96, 175, 85, 86, 100, 99, | |
1780 | 89, 90, 96, 93, 93, 696, 552, 97, 699, 555, | |
1781 | 99, 101, 97, 102, 103, 104, 105, 92, 286, 108, | |
1782 | 109, 94, 97, 98, 97, 293, 717, 630, 719, 99, | |
1783 | 60, 722, 635, 301, 64, 303, 100, 471, 306, 473, | |
1784 | 10, 587, 97, 589, 735, 94, 101, 469, 97, 717, | |
1785 | 472, 719, 101, 656, 3, 4, 44, 44, 749, 95, | |
1786 | 30, 664, 50, 66, 34, 93, 552, 91, 92, 555, | |
1787 | 93, 762, 1, 16, 17, 286, 767, 1, 769, 67, | |
1788 | 771, 51, 293, 88, 630, 18, 19, 20, 21, 635, | |
1789 | 301, 93, 303, 696, 82, 306, 699, 85, 86, 44, | |
1790 | 99, 587, 94, 589, 1, 50, 286, 93, 1, 99, | |
1791 | 656, 45, 46, 293, 717, 94, 719, 94, 664, 722, | |
1792 | 1, 301, 97, 303, 57, 94, 306, 100, 552, 45, | |
1793 | 46, 555, 735, 175, 402, 56, 65, 82, 67, 56, | |
1794 | 85, 86, 99, 72, 630, 1, 749, 76, 94, 635, | |
1795 | 696, 1, 755, 699, 44, 97, 98, 86, 94, 762, | |
1796 | 50, 764, 94, 587, 767, 589, 769, 94, 771, 99, | |
1797 | 656, 717, 65, 719, 67, 86, 722, 99, 664, 72, | |
1798 | 91, 92, 93, 76, 372, 373, 97, 382, 383, 735, | |
1799 | 101, 402, 82, 86, 94, 85, 86, 56, 377, 378, | |
1800 | 379, 380, 94, 749, 94, 0, 630, 0, 381, 755, | |
1801 | 696, 635, 11, 699, 54, 75, 762, 402, 764, 139, | |
1802 | 253, 767, 402, 769, 162, 771, 52, 94, 91, 92, | |
1803 | 93, 717, 656, 719, 97, 160, 722, 306, 101, 261, | |
1804 | 664, 5, 6, 7, 286, 306, 286, 86, 654, 735, | |
1805 | 44, 293, 91, 92, 93, 654, 50, 570, 97, 301, | |
1806 | 384, 303, 101, 749, 306, 59, 570, 61, 345, 755, | |
1807 | 385, 387, 696, 67, 388, 699, 762, 627, 764, 392, | |
1808 | 386, 767, -1, 769, 552, 771, -1, 555, 82, -1, | |
1809 | -1, 85, 86, 717, -1, 719, -1, -1, 722, -1, | |
1810 | -1, 95, 96, 8, 9, 10, 97, 98, 99, -1, | |
1811 | 1, 735, 3, 4, 91, 92, 93, -1, -1, 587, | |
1812 | 97, 589, -1, -1, 101, 749, 91, 92, 93, -1, | |
1813 | -1, 755, 97, 374, 375, 376, 101, -1, 762, -1, | |
1814 | 764, 552, -1, 767, 555, 769, -1, 771, -1, -1, | |
1815 | -1, -1, -1, -1, 45, 46, -1, -1, -1, 50, | |
1816 | 402, -1, 630, -1, -1, -1, -1, 635, 59, -1, | |
1817 | -1, -1, 552, -1, 65, 555, 587, -1, 589, -1, | |
1818 | -1, 72, -1, -1, -1, 76, -1, -1, 656, -1, | |
1819 | -1, 82, -1, -1, 85, 86, 664, -1, 89, 90, | |
1820 | -1, -1, 93, -1, 95, 96, -1, 587, -1, 589, | |
1821 | -1, 102, 103, 104, 105, -1, -1, 108, 109, 630, | |
1822 | -1, -1, -1, -1, 635, -1, -1, -1, 696, -1, | |
1823 | -1, 699, -1, -1, -1, -1, -1, -1, -1, -1, | |
1824 | -1, -1, -1, -1, -1, 656, -1, -1, -1, 717, | |
1825 | 630, 719, -1, 664, 722, 635, 192, 193, 194, 195, | |
1826 | -1, -1, -1, -1, 200, 201, -1, 735, -1, -1, | |
1827 | -1, -1, -1, -1, -1, -1, 656, -1, -1, -1, | |
1828 | -1, 749, -1, -1, 664, 696, -1, 755, 699, -1, | |
1829 | -1, -1, -1, -1, 762, -1, 764, -1, -1, 767, | |
1830 | -1, 769, -1, 771, -1, -1, 717, -1, 719, -1, | |
1831 | 552, 722, -1, 555, -1, -1, 696, -1, -1, 699, | |
1832 | -1, -1, -1, -1, 735, -1, -1, -1, -1, -1, | |
1833 | -1, -1, -1, -1, -1, -1, -1, 717, 749, 719, | |
1834 | -1, -1, 722, -1, 755, 587, -1, 589, -1, -1, | |
1835 | -1, 762, -1, 764, -1, 735, 767, -1, 769, -1, | |
1836 | 771, -1, -1, -1, -1, -1, -1, -1, -1, 749, | |
1837 | 192, 193, 194, 195, -1, 755, -1, 44, 200, 201, | |
1838 | -1, -1, 762, 50, 764, -1, -1, 767, 630, 769, | |
1839 | -1, 771, 59, 635, 61, -1, -1, -1, -1, -1, | |
1840 | 67, -1, -1, -1, -1, -1, -1, 1, -1, -1, | |
1841 | -1, -1, -1, -1, 656, 82, -1, -1, 85, 86, | |
1842 | -1, -1, 664, -1, -1, -1, -1, -1, 95, 96, | |
1843 | -1, -1, -1, 369, 370, 371, 372, 373, 374, 375, | |
1844 | 376, 377, 378, 379, 380, -1, 382, 383, 384, 385, | |
1845 | 386, 387, 388, -1, 696, -1, 50, 699, -1, -1, | |
1846 | -1, -1, -1, -1, 44, 59, -1, -1, -1, -1, | |
1847 | 50, 65, -1, -1, -1, 717, -1, 719, 72, 59, | |
1848 | 722, 61, 76, -1, -1, -1, -1, 67, 82, -1, | |
1849 | -1, 85, 86, 735, -1, 89, 90, -1, -1, 93, | |
1850 | -1, -1, 82, -1, -1, 85, 86, 749, 102, 103, | |
1851 | 104, 105, -1, 755, 108, 109, 96, -1, -1, -1, | |
1852 | 762, -1, 764, -1, 1, 767, -1, 769, -1, 771, | |
1853 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |
1854 | 476, -1, -1, -1, -1, -1, 482, 369, 370, 371, | |
1855 | 372, 373, 374, 375, 376, 377, 378, 379, 380, -1, | |
1856 | 382, 383, 384, 385, 386, 387, 388, 44, 45, 46, | |
1857 | 47, 48, 49, 50, 51, -1, -1, 54, -1, -1, | |
1858 | -1, 58, 59, -1, -1, 62, -1, -1, 65, 66, | |
1859 | 67, 68, -1, 70, 71, 72, 73, 44, 1, 76, | |
1860 | -1, -1, -1, 50, -1, 82, -1, -1, 85, 86, | |
1861 | -1, -1, 59, -1, 61, -1, 93, -1, 95, 96, | |
1862 | 67, -1, 99, -1, -1, 102, 103, 104, 105, -1, | |
1863 | -1, 108, 109, -1, -1, 82, -1, -1, 85, 86, | |
1864 | -1, 44, 45, 46, 47, 48, 49, 50, 51, 96, | |
1865 | -1, 54, -1, -1, 476, 58, 59, -1, -1, 62, | |
1866 | 482, -1, 65, 66, 67, 68, 1, 70, 71, 72, | |
1867 | 73, -1, -1, 76, -1, 611, 612, -1, -1, 82, | |
1179ebc2 | 1868 | -1, -1, 85, 86, -1, -1, -1, -1, -1, -1, |
efa0a23f APB |
1869 | 93, 627, 95, 96, -1, -1, 99, -1, -1, 102, |
1870 | 103, 104, 105, -1, -1, 108, 109, -1, -1, 44, | |
1871 | 45, 46, 47, 48, 49, 50, 51, -1, -1, 54, | |
1872 | -1, -1, -1, 58, 59, -1, -1, 62, -1, -1, | |
1873 | 65, 66, 67, 68, -1, 70, 71, 72, 73, -1, | |
1874 | -1, 76, -1, -1, -1, -1, -1, 82, -1, 1, | |
1875 | 85, 86, -1, -1, -1, -1, -1, -1, 93, -1, | |
1876 | 95, 96, -1, -1, 99, -1, -1, 102, 103, 104, | |
1877 | 105, -1, -1, 108, 109, -1, -1, -1, -1, -1, | |
1878 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 611, | |
1879 | 612, -1, 44, 45, 46, -1, 48, 49, 50, 51, | |
1880 | -1, -1, 54, -1, -1, 627, 58, 59, -1, -1, | |
2e5eb5c5 APB |
1881 | -1, -1, -1, 65, 66, 67, 68, 1, 70, 71, |
1882 | 72, 73, -1, -1, 76, -1, -1, -1, -1, -1, | |
1883 | 82, -1, -1, 85, 86, -1, -1, -1, -1, -1, | |
efa0a23f | 1884 | -1, 93, -1, 95, 96, -1, -1, 99, -1, -1, |
2e5eb5c5 APB |
1885 | 102, 103, 104, 105, -1, -1, 108, 109, -1, -1, |
1886 | 44, 45, 46, -1, 48, 49, 50, 51, -1, -1, | |
1887 | 54, -1, -1, -1, 58, 59, -1, -1, -1, -1, | |
efa0a23f | 1888 | -1, 65, 66, 67, 68, 1, 70, 71, 72, 73, |
2e5eb5c5 APB |
1889 | -1, -1, 76, -1, -1, -1, -1, -1, 82, -1, |
1890 | -1, 85, 86, -1, -1, -1, -1, -1, -1, 93, | |
1891 | -1, 95, -1, -1, -1, 99, -1, -1, 102, 103, | |
efa0a23f APB |
1892 | 104, 105, -1, -1, 108, 109, -1, -1, 44, 45, |
1893 | 46, -1, 48, 49, 50, 51, -1, -1, 54, -1, | |
1894 | -1, -1, 58, 59, -1, -1, -1, -1, -1, 65, | |
1895 | 66, 1, 68, -1, 70, 71, 72, 73, -1, -1, | |
1896 | 76, -1, -1, -1, -1, -1, 82, -1, -1, 85, | |
1897 | 86, -1, -1, -1, -1, -1, -1, 93, -1, 95, | |
1898 | -1, -1, -1, 99, -1, -1, 102, 103, 104, 105, | |
1899 | -1, -1, 108, 109, 44, 45, 46, -1, 48, 49, | |
1900 | 50, 51, -1, -1, 54, -1, -1, -1, 58, 59, | |
1901 | -1, -1, -1, -1, -1, 65, 66, -1, 68, -1, | |
1902 | 70, 71, 72, 73, -1, 1, 76, 3, 4, -1, | |
1903 | -1, -1, 82, -1, -1, 85, 86, -1, -1, -1, | |
1904 | -1, -1, -1, 93, -1, 95, -1, -1, -1, 99, | |
1905 | -1, -1, 102, 103, 104, 105, -1, -1, 108, 109, | |
1906 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, | |
1907 | 46, -1, -1, -1, 50, -1, 1, -1, 3, 4, | |
1908 | -1, -1, -1, 59, -1, -1, -1, -1, -1, 65, | |
1909 | -1, -1, -1, -1, -1, -1, 72, -1, -1, -1, | |
1910 | 76, -1, -1, -1, -1, -1, 82, -1, -1, 85, | |
1911 | 86, -1, -1, 89, 90, -1, -1, 93, -1, 95, | |
1912 | 45, 46, -1, -1, -1, 50, 102, 103, 104, 105, | |
1913 | -1, -1, 108, 109, 59, -1, -1, -1, -1, -1, | |
1914 | 65, 1, -1, 3, 4, -1, -1, 72, -1, -1, | |
1915 | -1, 76, -1, -1, -1, -1, -1, 82, -1, -1, | |
1916 | 85, 86, -1, 88, 89, 90, -1, -1, 93, -1, | |
1917 | -1, -1, -1, -1, -1, -1, -1, 102, 103, 104, | |
1918 | 105, -1, -1, 108, 109, 45, 46, -1, -1, -1, | |
1919 | 50, -1, 1, -1, 3, 4, -1, -1, -1, 59, | |
1920 | -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, | |
1921 | -1, -1, 72, -1, -1, -1, 76, -1, -1, -1, | |
1922 | -1, -1, 82, -1, -1, 85, 86, -1, -1, 89, | |
1923 | 90, -1, -1, 93, -1, -1, 45, 46, 98, -1, | |
1924 | -1, 50, 102, 103, 104, 105, -1, -1, 108, 109, | |
1925 | 59, -1, -1, -1, -1, -1, 65, 1, -1, 3, | |
1926 | 4, -1, -1, 72, -1, -1, -1, 76, -1, -1, | |
1927 | -1, -1, -1, 82, -1, -1, 85, 86, -1, -1, | |
1928 | 89, 90, -1, -1, 93, 94, -1, -1, -1, -1, | |
1929 | -1, -1, -1, 102, 103, 104, 105, -1, -1, 108, | |
1930 | 109, 45, 46, -1, -1, -1, 50, -1, 1, -1, | |
1931 | 3, 4, -1, -1, -1, 59, -1, -1, -1, -1, | |
1932 | -1, 65, -1, -1, -1, -1, -1, -1, 72, -1, | |
12472854 | 1933 | -1, -1, 76, -1, -1, -1, -1, -1, 82, -1, |
0b4d333e | 1934 | -1, 85, 86, -1, -1, 89, 90, -1, -1, 93, |
efa0a23f APB |
1935 | -1, -1, 45, 46, -1, 99, -1, 50, 102, 103, |
1936 | 104, 105, -1, -1, 108, 109, 59, -1, -1, -1, | |
1937 | -1, -1, 65, 1, -1, 3, 4, -1, -1, 72, | |
22eed1e6 APB |
1938 | -1, -1, -1, 76, -1, -1, -1, -1, -1, 82, |
1939 | -1, -1, 85, 86, -1, -1, 89, 90, -1, -1, | |
efa0a23f APB |
1940 | 93, -1, -1, -1, -1, 98, -1, -1, -1, 102, |
1941 | 103, 104, 105, -1, -1, 108, 109, 45, 46, -1, | |
1942 | -1, -1, 50, -1, 1, -1, 3, 4, -1, -1, | |
1943 | -1, 59, -1, -1, -1, -1, -1, 65, -1, -1, | |
1944 | -1, -1, -1, -1, 72, -1, -1, -1, 76, -1, | |
1945 | -1, -1, -1, -1, 82, -1, -1, 85, 86, -1, | |
1946 | -1, 89, 90, -1, -1, 93, 94, -1, 45, 46, | |
1947 | -1, -1, -1, 50, 102, 103, 104, 105, -1, -1, | |
1948 | 108, 109, 59, -1, -1, -1, -1, -1, 65, 1, | |
1949 | -1, 3, 4, -1, -1, 72, -1, -1, -1, 76, | |
1950 | -1, -1, -1, -1, -1, 82, -1, -1, 85, 86, | |
1951 | -1, -1, 89, 90, -1, -1, 93, -1, -1, -1, | |
1952 | -1, 98, -1, -1, -1, 102, 103, 104, 105, -1, | |
1953 | -1, 108, 109, 45, 46, -1, -1, -1, 50, -1, | |
1954 | 1, -1, 3, 4, -1, -1, -1, 59, -1, -1, | |
1955 | -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, | |
8b27f225 PB |
1956 | 72, -1, -1, -1, 76, -1, -1, -1, -1, -1, |
1957 | 82, -1, -1, 85, 86, -1, -1, 89, 90, -1, | |
efa0a23f APB |
1958 | -1, 93, 94, -1, 45, 46, -1, -1, -1, 50, |
1959 | 102, 103, 104, 105, -1, -1, 108, 109, 59, -1, | |
1960 | -1, -1, -1, -1, 65, 1, -1, 3, 4, -1, | |
2e5eb5c5 APB |
1961 | -1, 72, -1, -1, -1, 76, -1, -1, -1, -1, |
1962 | -1, 82, -1, -1, 85, 86, -1, -1, 89, 90, | |
efa0a23f APB |
1963 | -1, -1, 93, 94, -1, -1, -1, -1, -1, -1, |
1964 | -1, 102, 103, 104, 105, -1, -1, 108, 109, 45, | |
1965 | 46, -1, -1, -1, 50, -1, 1, -1, 3, 4, | |
1966 | -1, -1, -1, 59, -1, -1, -1, -1, -1, 65, | |
1967 | -1, -1, -1, -1, -1, -1, 72, -1, -1, -1, | |
1968 | 76, -1, -1, -1, -1, -1, 82, -1, -1, 85, | |
1969 | 86, -1, -1, 89, 90, -1, -1, 93, 94, -1, | |
1970 | 45, 46, -1, -1, -1, 50, 102, 103, 104, 105, | |
1971 | -1, -1, 108, 109, 59, -1, -1, -1, -1, -1, | |
1972 | 65, 1, -1, 3, 4, -1, -1, 72, -1, -1, | |
1973 | -1, 76, -1, -1, -1, -1, -1, 82, -1, -1, | |
1974 | 85, 86, -1, -1, 89, 90, -1, -1, 93, -1, | |
1975 | -1, -1, -1, -1, 99, -1, -1, 102, 103, 104, | |
1976 | 105, -1, -1, 108, 109, 45, 46, -1, -1, -1, | |
1977 | 50, -1, 1, -1, 3, 4, -1, -1, -1, 59, | |
1978 | -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, | |
8b27f225 PB |
1979 | -1, -1, 72, -1, -1, -1, 76, -1, -1, -1, |
1980 | -1, -1, 82, -1, -1, 85, 86, -1, -1, 89, | |
efa0a23f APB |
1981 | 90, -1, -1, 93, -1, -1, 45, 46, -1, -1, |
1982 | -1, 50, 102, 103, 104, 105, -1, -1, 108, 109, | |
1983 | 59, -1, -1, -1, -1, -1, 65, 1, -1, 3, | |
1984 | 4, -1, -1, 72, -1, -1, -1, 76, -1, -1, | |
1985 | -1, -1, -1, 82, -1, -1, 85, 86, -1, -1, | |
1986 | 89, 90, -1, -1, 93, -1, -1, -1, -1, -1, | |
1987 | -1, -1, -1, 102, 103, 104, 105, -1, -1, 108, | |
1988 | 109, 45, 46, -1, -1, -1, 50, -1, 1, -1, | |
1989 | 3, 4, -1, -1, -1, 59, -1, -1, -1, -1, | |
1990 | -1, 65, -1, -1, -1, -1, -1, -1, 72, -1, | |
8b27f225 PB |
1991 | -1, -1, 76, -1, -1, -1, -1, -1, 82, -1, |
1992 | -1, 85, 86, -1, -1, 89, 90, -1, -1, 93, | |
efa0a23f APB |
1993 | -1, -1, 45, 46, -1, -1, -1, 50, 102, 103, |
1994 | 104, 105, -1, -1, 108, 109, 59, -1, -1, -1, | |
1995 | -1, -1, 65, 1, -1, 3, 4, -1, -1, 72, | |
8b27f225 PB |
1996 | -1, -1, -1, 76, -1, -1, -1, -1, -1, 82, |
1997 | -1, -1, 85, 86, -1, -1, 89, 90, -1, -1, | |
efa0a23f APB |
1998 | 93, -1, -1, -1, -1, -1, -1, -1, -1, 102, |
1999 | 103, 104, 105, -1, -1, 108, 109, 45, 46, -1, | |
2000 | -1, -1, 50, -1, 1, -1, 3, 4, -1, -1, | |
2001 | -1, 59, -1, -1, -1, -1, -1, 65, -1, -1, | |
2002 | -1, -1, -1, -1, 72, -1, -1, -1, 76, -1, | |
2003 | -1, -1, -1, -1, 82, -1, -1, 85, 86, -1, | |
2004 | -1, 89, 90, -1, -1, 93, -1, -1, 45, 46, | |
2005 | -1, -1, -1, 50, 102, 103, 104, 105, -1, -1, | |
2006 | 108, 109, 59, -1, -1, -1, -1, -1, 65, 1, | |
2007 | -1, 3, 4, -1, -1, 72, -1, -1, -1, 76, | |
2008 | -1, -1, -1, -1, -1, 82, -1, -1, 85, 86, | |
2009 | -1, -1, 89, 90, -1, -1, 93, -1, -1, -1, | |
2010 | -1, -1, -1, -1, -1, 102, 103, 104, 105, -1, | |
2011 | -1, 108, 109, 45, 46, -1, -1, -1, 50, -1, | |
2012 | 1, -1, 3, 4, -1, -1, -1, 59, -1, -1, | |
2013 | -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, | |
8b27f225 PB |
2014 | 72, -1, -1, -1, 76, -1, -1, -1, -1, -1, |
2015 | 82, -1, -1, 85, 86, -1, -1, 89, 90, -1, | |
efa0a23f APB |
2016 | -1, 93, -1, -1, 45, 46, -1, -1, -1, 50, |
2017 | 102, 103, 104, 105, -1, -1, 108, 109, 59, -1, | |
2018 | -1, -1, -1, -1, 65, 1, -1, 3, 4, -1, | |
2e5eb5c5 APB |
2019 | -1, 72, -1, -1, -1, 76, -1, -1, -1, -1, |
2020 | -1, 82, -1, -1, 85, 86, -1, -1, 89, 90, | |
efa0a23f APB |
2021 | -1, -1, 93, -1, -1, -1, -1, -1, -1, -1, |
2022 | -1, 102, 103, 104, 105, -1, -1, 108, 109, 45, | |
2023 | 46, -1, -1, -1, 50, -1, 1, -1, 3, 4, | |
2024 | -1, -1, -1, 59, -1, -1, -1, -1, -1, 65, | |
2025 | -1, -1, -1, -1, -1, -1, 72, -1, -1, -1, | |
2026 | 76, -1, -1, -1, -1, -1, 82, -1, -1, 85, | |
2027 | 86, -1, -1, 89, 90, -1, -1, 93, -1, -1, | |
2028 | 45, 46, -1, -1, -1, 50, 102, 103, 104, 105, | |
2029 | -1, -1, 108, 109, 59, -1, -1, -1, -1, -1, | |
2030 | 65, 1, -1, 3, 4, -1, -1, 72, -1, -1, | |
2e5eb5c5 APB |
2031 | -1, 76, -1, -1, -1, -1, -1, 82, -1, -1, |
2032 | 85, 86, -1, -1, 89, 90, -1, -1, 93, -1, | |
efa0a23f APB |
2033 | -1, -1, -1, -1, -1, -1, -1, 102, 103, 104, |
2034 | 105, -1, -1, 108, 109, 45, 46, -1, -1, -1, | |
2035 | 50, -1, 1, -1, 3, 4, -1, -1, -1, 59, | |
2036 | -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, | |
2037 | -1, -1, 72, -1, -1, -1, 76, -1, -1, -1, | |
2038 | -1, -1, 82, -1, -1, 85, 86, -1, -1, 89, | |
2039 | 90, -1, -1, 93, -1, -1, 45, 46, -1, -1, | |
2040 | -1, 50, 102, 103, 104, 105, -1, -1, 108, 109, | |
2041 | 59, -1, -1, -1, -1, -1, 65, 1, -1, 3, | |
2042 | 4, -1, -1, 72, -1, -1, -1, 76, -1, -1, | |
2043 | -1, -1, -1, 82, -1, -1, 85, 86, -1, -1, | |
2044 | 89, 90, -1, -1, 93, -1, -1, -1, -1, -1, | |
2045 | -1, -1, -1, 102, 103, 104, 105, -1, -1, 108, | |
2046 | 109, 45, 46, -1, -1, -1, 50, -1, 1, -1, | |
2047 | 3, 4, -1, -1, -1, 59, -1, -1, -1, -1, | |
2048 | -1, 65, -1, -1, -1, -1, -1, -1, 72, -1, | |
8b27f225 PB |
2049 | -1, -1, 76, -1, -1, -1, -1, -1, 82, -1, |
2050 | -1, 85, 86, -1, -1, 89, 90, -1, -1, 93, | |
efa0a23f APB |
2051 | -1, -1, 45, 46, -1, -1, -1, 50, 102, 103, |
2052 | 104, 105, -1, -1, 108, 109, 59, -1, -1, -1, | |
2053 | -1, -1, 65, 1, -1, 3, 4, -1, -1, 72, | |
8b27f225 PB |
2054 | -1, -1, -1, 76, -1, -1, -1, -1, -1, 82, |
2055 | -1, -1, 85, 86, -1, -1, 89, 90, -1, -1, | |
efa0a23f APB |
2056 | 93, -1, -1, -1, -1, -1, -1, -1, -1, 102, |
2057 | 103, 104, 105, -1, -1, 108, 109, 45, 46, -1, | |
2058 | -1, -1, 50, -1, 1, -1, 3, 4, -1, -1, | |
2059 | -1, 59, -1, -1, -1, -1, -1, 65, -1, -1, | |
2060 | -1, -1, -1, -1, 72, -1, -1, -1, 76, -1, | |
2061 | -1, -1, -1, -1, 82, -1, -1, 85, 86, -1, | |
2062 | -1, 89, 90, -1, -1, 93, -1, -1, 45, 46, | |
2063 | -1, -1, -1, 50, 102, 103, 104, 105, -1, -1, | |
2064 | 108, 109, 59, -1, -1, -1, -1, -1, 65, 1, | |
2065 | -1, 3, 4, -1, -1, 72, -1, -1, -1, 76, | |
2066 | -1, -1, -1, -1, -1, 82, -1, -1, 85, 86, | |
2067 | -1, -1, 89, 90, -1, -1, 93, -1, -1, -1, | |
2068 | -1, -1, -1, -1, -1, 102, 103, 104, 105, -1, | |
2069 | -1, 108, 109, 45, 46, -1, -1, -1, 50, -1, | |
2070 | 1, -1, 3, 4, -1, -1, -1, 59, -1, -1, | |
2071 | -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, | |
8b27f225 PB |
2072 | 72, -1, -1, -1, 76, -1, -1, -1, -1, -1, |
2073 | 82, -1, -1, 85, 86, -1, -1, 89, 90, -1, | |
efa0a23f APB |
2074 | -1, 93, -1, -1, 45, 46, -1, -1, -1, 50, |
2075 | 102, 103, 104, 105, -1, -1, 108, 109, 59, -1, | |
2076 | -1, -1, -1, -1, 65, 1, -1, 3, 4, -1, | |
2e5eb5c5 APB |
2077 | -1, 72, -1, -1, -1, 76, -1, -1, -1, -1, |
2078 | -1, 82, -1, -1, 85, 86, -1, -1, 89, 90, | |
efa0a23f APB |
2079 | -1, -1, 93, -1, -1, -1, -1, -1, -1, -1, |
2080 | -1, 102, 103, 104, 105, -1, -1, 108, 109, 45, | |
2081 | 46, -1, -1, -1, 50, -1, 1, -1, 3, 4, | |
2082 | -1, -1, -1, 59, -1, -1, -1, -1, -1, 65, | |
2083 | -1, -1, -1, -1, -1, -1, 72, -1, -1, -1, | |
2084 | 76, -1, -1, -1, -1, -1, 82, -1, -1, 85, | |
2085 | 86, -1, -1, 89, 90, -1, -1, 93, -1, -1, | |
2086 | 45, 46, -1, -1, -1, 50, 102, 103, 104, 105, | |
2087 | -1, -1, 108, 109, 59, -1, -1, -1, -1, -1, | |
2088 | 65, 1, -1, 3, 4, -1, -1, 72, -1, -1, | |
2e5eb5c5 APB |
2089 | -1, 76, -1, -1, -1, -1, -1, 82, -1, -1, |
2090 | 85, 86, -1, -1, 89, 90, -1, -1, 93, -1, | |
efa0a23f APB |
2091 | -1, -1, -1, -1, -1, -1, -1, 102, 103, 104, |
2092 | 105, -1, -1, 108, 109, 45, 46, -1, -1, -1, | |
2093 | 50, -1, 1, -1, 3, 4, -1, -1, -1, 59, | |
2094 | -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, | |
2095 | -1, -1, 72, -1, -1, -1, 76, -1, -1, -1, | |
2096 | -1, -1, 82, -1, -1, 85, 86, -1, -1, 89, | |
2097 | 90, -1, -1, 93, -1, -1, 45, 46, -1, -1, | |
2098 | -1, 50, 102, 103, 104, 105, -1, -1, 108, 109, | |
2099 | 59, -1, -1, -1, -1, -1, 65, 1, -1, 3, | |
2100 | 4, -1, -1, 72, -1, -1, -1, 76, -1, -1, | |
2101 | -1, -1, -1, 82, -1, -1, 85, 86, -1, -1, | |
2102 | 89, 90, -1, -1, 93, -1, -1, -1, -1, -1, | |
2103 | -1, -1, -1, 102, 103, 104, 105, -1, -1, 108, | |
2104 | 109, 45, 46, -1, -1, -1, 50, -1, 1, -1, | |
2105 | 3, 4, -1, -1, -1, 59, -1, -1, -1, -1, | |
2106 | -1, 65, -1, -1, -1, -1, -1, -1, 72, -1, | |
8b27f225 PB |
2107 | -1, -1, 76, -1, -1, -1, -1, -1, 82, -1, |
2108 | -1, 85, 86, -1, -1, 89, 90, -1, -1, 93, | |
efa0a23f APB |
2109 | -1, -1, 45, 46, -1, -1, -1, 50, 102, 103, |
2110 | 104, 105, -1, -1, 108, 109, 59, -1, -1, -1, | |
2111 | -1, -1, 65, 1, -1, 3, 4, -1, -1, 72, | |
8b27f225 PB |
2112 | -1, -1, -1, 76, -1, -1, -1, -1, -1, 82, |
2113 | -1, -1, 85, 86, -1, -1, 89, 90, -1, -1, | |
efa0a23f APB |
2114 | 93, -1, -1, -1, -1, -1, -1, -1, -1, 102, |
2115 | 103, 104, 105, -1, -1, 108, 109, 45, 46, -1, | |
2116 | -1, -1, 50, -1, 1, -1, 3, 4, -1, -1, | |
2117 | -1, 59, -1, -1, -1, -1, -1, 65, -1, -1, | |
2118 | -1, -1, -1, -1, 72, -1, -1, -1, 76, -1, | |
2119 | -1, -1, -1, -1, 82, -1, -1, 85, 86, -1, | |
2120 | -1, 89, 90, -1, -1, 93, -1, -1, 45, 46, | |
2121 | -1, -1, -1, 50, 102, 103, 104, 105, -1, -1, | |
2122 | 108, 109, 59, -1, -1, -1, -1, -1, 65, 1, | |
2123 | -1, 3, 4, -1, -1, 72, -1, -1, -1, 76, | |
2124 | -1, -1, -1, -1, -1, 82, -1, -1, 85, 86, | |
2125 | -1, -1, 89, 90, -1, -1, 93, -1, -1, -1, | |
2126 | -1, -1, -1, -1, -1, 102, 103, 104, 105, -1, | |
2127 | -1, 108, 109, 45, 46, -1, -1, -1, 50, -1, | |
2128 | 1, -1, 3, 4, -1, -1, -1, 59, -1, -1, | |
2129 | -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, | |
8b27f225 PB |
2130 | 72, -1, -1, -1, 76, -1, -1, -1, -1, -1, |
2131 | 82, -1, -1, 85, 86, -1, -1, 89, 90, -1, | |
efa0a23f APB |
2132 | -1, 93, -1, -1, 45, 46, -1, -1, -1, 50, |
2133 | 102, 103, 104, 105, -1, -1, 108, 109, 59, -1, | |
2134 | -1, -1, -1, -1, 65, 1, -1, 3, 4, -1, | |
2e5eb5c5 APB |
2135 | -1, 72, -1, -1, -1, 76, -1, -1, -1, -1, |
2136 | -1, 82, -1, -1, 85, 86, -1, -1, 89, 90, | |
efa0a23f APB |
2137 | -1, -1, 93, -1, -1, -1, -1, -1, -1, -1, |
2138 | -1, 102, 103, 104, 105, -1, -1, 108, 109, 45, | |
2139 | 46, -1, -1, -1, 50, -1, 1, -1, 3, 4, | |
2140 | -1, -1, -1, 59, -1, -1, -1, -1, -1, 65, | |
2141 | -1, -1, -1, -1, -1, -1, 72, -1, -1, -1, | |
2142 | 76, -1, -1, -1, -1, -1, 82, -1, -1, 85, | |
2143 | 86, -1, -1, 89, 90, -1, -1, 93, -1, -1, | |
2144 | 45, 46, -1, -1, -1, 50, 102, 103, 104, 105, | |
2145 | -1, -1, 108, 109, 59, -1, -1, -1, -1, -1, | |
2146 | 65, 1, -1, 3, 4, -1, -1, 72, -1, -1, | |
2e5eb5c5 APB |
2147 | -1, 76, -1, -1, -1, -1, -1, 82, -1, -1, |
2148 | 85, 86, -1, -1, 89, 90, -1, -1, 93, -1, | |
efa0a23f APB |
2149 | -1, -1, -1, -1, -1, -1, -1, 102, 103, 104, |
2150 | 105, -1, -1, 108, 109, 45, 46, -1, -1, -1, | |
2151 | 50, -1, 1, -1, 3, 4, -1, -1, -1, 59, | |
2152 | -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, | |
2153 | -1, -1, 72, -1, -1, -1, 76, -1, -1, -1, | |
2154 | -1, -1, 82, -1, -1, 85, 86, -1, -1, 89, | |
2155 | 90, -1, -1, 93, -1, -1, 45, 46, -1, -1, | |
2156 | -1, 50, 102, 103, 104, 105, -1, -1, 108, 109, | |
2157 | 59, -1, -1, -1, -1, -1, 65, 1, -1, 3, | |
2158 | 4, -1, -1, 72, -1, -1, -1, 76, -1, -1, | |
2159 | -1, -1, -1, 82, -1, -1, 85, 86, -1, -1, | |
2160 | 89, 90, -1, -1, 93, -1, -1, -1, -1, -1, | |
2161 | -1, -1, -1, 102, 103, 104, 105, -1, -1, 108, | |
2162 | 109, 45, 46, -1, -1, -1, 50, -1, 1, -1, | |
2163 | 3, 4, -1, -1, -1, 59, -1, -1, -1, -1, | |
2164 | -1, 65, -1, -1, -1, -1, -1, -1, 72, -1, | |
8b27f225 PB |
2165 | -1, -1, 76, -1, -1, -1, -1, -1, 82, -1, |
2166 | -1, 85, 86, -1, -1, 89, 90, -1, -1, 93, | |
efa0a23f APB |
2167 | -1, -1, 45, 46, -1, -1, -1, 50, 102, 103, |
2168 | 104, 105, -1, -1, 108, 109, 59, -1, -1, -1, | |
2169 | -1, -1, 65, 1, -1, 3, 4, -1, -1, 72, | |
8b27f225 PB |
2170 | -1, -1, -1, 76, -1, -1, -1, -1, -1, 82, |
2171 | -1, -1, 85, 86, -1, -1, 89, 90, -1, -1, | |
efa0a23f APB |
2172 | 93, -1, -1, -1, -1, -1, -1, -1, -1, 102, |
2173 | 103, 104, 105, -1, -1, 108, 109, 45, 46, -1, | |
2174 | -1, -1, 50, -1, 1, -1, 3, 4, -1, -1, | |
2175 | -1, 59, -1, -1, -1, -1, -1, 65, -1, -1, | |
2176 | -1, -1, -1, -1, 72, -1, -1, -1, 76, -1, | |
2177 | -1, -1, -1, -1, 82, -1, -1, 85, 86, -1, | |
2178 | -1, 89, 90, -1, -1, 93, -1, -1, 45, 46, | |
2179 | -1, -1, -1, 50, 102, 103, 104, 105, -1, -1, | |
2180 | 108, 109, 59, -1, -1, -1, -1, -1, 65, 1, | |
2181 | -1, 3, 4, -1, -1, 72, -1, -1, -1, 76, | |
2182 | -1, -1, -1, -1, -1, 82, -1, -1, 85, 86, | |
2183 | -1, -1, 89, 90, -1, -1, 93, -1, -1, -1, | |
2184 | -1, -1, -1, -1, -1, 102, 103, 104, 105, -1, | |
2185 | -1, 108, 109, 45, 46, -1, -1, -1, 50, -1, | |
2186 | 1, -1, 3, 4, -1, -1, -1, 59, -1, -1, | |
2187 | -1, -1, -1, 65, -1, -1, -1, -1, -1, -1, | |
8b27f225 PB |
2188 | 72, -1, -1, -1, 76, -1, -1, -1, -1, -1, |
2189 | 82, -1, -1, 85, 86, -1, -1, 89, 90, -1, | |
efa0a23f APB |
2190 | -1, 93, -1, -1, 45, 46, -1, -1, -1, 50, |
2191 | 102, 103, 104, 105, -1, -1, 108, 109, 59, -1, | |
2192 | -1, -1, -1, -1, 65, 1, -1, 3, 4, -1, | |
2e5eb5c5 APB |
2193 | -1, 72, -1, -1, -1, 76, -1, -1, -1, -1, |
2194 | -1, 82, -1, -1, 85, 86, -1, -1, 89, 90, | |
efa0a23f APB |
2195 | -1, -1, 93, -1, -1, -1, -1, -1, -1, -1, |
2196 | -1, 102, 103, 104, 105, -1, -1, 108, 109, 45, | |
2197 | 46, -1, -1, -1, 50, -1, 1, -1, -1, -1, | |
2198 | -1, -1, -1, 59, -1, -1, -1, -1, -1, 65, | |
2199 | -1, -1, -1, -1, -1, -1, 72, -1, -1, -1, | |
2200 | 76, 1, -1, -1, -1, -1, 82, -1, -1, 85, | |
2201 | 86, -1, -1, 89, 90, -1, -1, 93, -1, 44, | |
2202 | 45, 46, -1, -1, -1, 50, 102, 103, 104, 105, | |
2203 | -1, -1, 108, 109, 59, -1, -1, -1, -1, -1, | |
2204 | 65, -1, -1, 1, -1, 45, 46, 72, -1, -1, | |
2205 | 50, 76, -1, -1, -1, -1, -1, 82, -1, 59, | |
2206 | 85, 86, -1, -1, -1, 65, -1, -1, 93, -1, | |
2207 | 3, 4, 72, -1, 99, -1, 76, 102, 103, 104, | |
2208 | 105, -1, 82, 108, 109, 85, 86, 45, 46, -1, | |
2209 | -1, -1, 50, 93, 94, -1, -1, -1, -1, -1, | |
2210 | -1, 59, 102, 103, 104, 105, -1, 65, 108, 109, | |
2e5eb5c5 APB |
2211 | 1, -1, 45, 46, 72, -1, -1, 50, 76, -1, |
2212 | -1, -1, -1, -1, 82, -1, 59, 85, 86, -1, | |
efa0a23f APB |
2213 | -1, -1, 65, -1, -1, 93, 94, 3, 4, 72, |
2214 | -1, -1, -1, 76, 102, 103, 104, 105, -1, 82, | |
2215 | 108, 109, 85, 86, 45, 46, 89, 90, -1, 50, | |
2216 | 93, -1, 95, 96, -1, -1, -1, -1, 59, 102, | |
2217 | 103, 104, 105, -1, 65, 108, 109, -1, -1, 45, | |
2218 | 46, 72, -1, -1, 50, 76, -1, -1, 3, 4, | |
2e5eb5c5 | 2219 | -1, 82, -1, 59, 85, 86, -1, -1, -1, 65, |
efa0a23f | 2220 | -1, -1, 93, -1, -1, -1, 72, -1, -1, -1, |
2e5eb5c5 | 2221 | 76, 102, 103, 104, 105, -1, 82, 108, 109, 85, |
efa0a23f APB |
2222 | 86, -1, -1, 89, 90, -1, -1, 93, 94, -1, |
2223 | 45, 46, -1, -1, -1, 50, 102, 103, 104, 105, | |
2224 | -1, -1, 108, 109, 59, -1, -1, -1, -1, -1, | |
2225 | 65, -1, -1, 3, 4, -1, -1, 72, -1, -1, | |
2226 | -1, 76, -1, -1, -1, -1, -1, 82, -1, -1, | |
2227 | 85, 86, -1, -1, 89, 90, -1, -1, 93, 94, | |
2228 | -1, -1, -1, -1, -1, -1, -1, 102, 103, 104, | |
2229 | 105, -1, -1, 108, 109, 45, 46, -1, -1, -1, | |
2230 | 50, -1, -1, -1, 3, 4, -1, -1, -1, 59, | |
2231 | -1, -1, -1, -1, -1, 65, -1, -1, -1, -1, | |
2232 | -1, -1, 72, -1, -1, -1, 76, -1, -1, -1, | |
2233 | -1, -1, 82, -1, -1, 85, 86, -1, -1, 89, | |
2234 | 90, -1, -1, 93, 94, -1, 45, 46, -1, -1, | |
2235 | -1, 50, 102, 103, 104, 105, -1, -1, 108, 109, | |
2236 | 59, -1, -1, -1, -1, -1, 65, -1, -1, 3, | |
2237 | 4, -1, -1, 72, -1, -1, -1, 76, -1, -1, | |
2238 | -1, -1, -1, 82, -1, -1, 85, 86, -1, -1, | |
2239 | 89, 90, -1, -1, 93, 94, -1, -1, -1, -1, | |
2240 | -1, -1, -1, 102, 103, 104, 105, -1, -1, 108, | |
2241 | 109, 45, 46, -1, -1, -1, 50, -1, -1, -1, | |
2242 | -1, -1, -1, -1, -1, 59, -1, -1, -1, -1, | |
2243 | -1, 65, -1, -1, -1, -1, -1, -1, 72, -1, | |
2244 | -1, -1, 76, -1, -1, -1, -1, -1, 82, -1, | |
2245 | -1, 85, 86, -1, -1, 89, 90, -1, -1, 93, | |
2246 | -1, 44, 45, 46, -1, -1, -1, 50, 102, 103, | |
2247 | 104, 105, -1, -1, 108, 109, 59, -1, -1, -1, | |
2e5eb5c5 | 2248 | -1, -1, 65, -1, -1, -1, -1, -1, -1, 72, |
efa0a23f APB |
2249 | -1, -1, 50, 76, -1, -1, -1, -1, -1, 82, |
2250 | -1, 59, 85, 86, -1, -1, -1, 65, -1, -1, | |
2251 | 93, -1, -1, -1, 72, -1, -1, -1, 76, 102, | |
2252 | 103, 104, 105, -1, 82, 108, 109, 85, 86, -1, | |
2253 | -1, 89, 90, -1, -1, 93, -1, -1, -1, -1, | |
2254 | -1, -1, -1, -1, 102, 103, 104, 105, -1, -1, | |
2255 | 108, 109 | |
8b27f225 PB |
2256 | }; |
2257 | #define YYPURE 1 | |
2258 | ||
2259 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ | |
c52b5771 | 2260 | #line 3 "/home/green/cygnus/njava/i0/share/bison.simple" |
8b27f225 PB |
2261 | |
2262 | /* Skeleton output parser for bison, | |
2263 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. | |
2264 | ||
2265 | This program is free software; you can redistribute it and/or modify | |
2266 | it under the terms of the GNU General Public License as published by | |
2267 | the Free Software Foundation; either version 2, or (at your option) | |
2268 | any later version. | |
2269 | ||
2270 | This program is distributed in the hope that it will be useful, | |
2271 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
2272 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
2273 | GNU General Public License for more details. | |
2274 | ||
2275 | You should have received a copy of the GNU General Public License | |
2276 | along with this program; if not, write to the Free Software | |
51149cc8 | 2277 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
8b27f225 PB |
2278 | |
2279 | /* As a special exception, when this file is copied by Bison into a | |
2280 | Bison output file, you may use that output file without restriction. | |
2281 | This special exception was added by the Free Software Foundation | |
2282 | in version 1.24 of Bison. */ | |
2283 | ||
eb69a686 | 2284 | #ifndef alloca |
8b27f225 PB |
2285 | #ifdef __GNUC__ |
2286 | #define alloca __builtin_alloca | |
2287 | #else /* not GNU C. */ | |
eb69a686 | 2288 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) |
8b27f225 PB |
2289 | #include <alloca.h> |
2290 | #else /* not sparc */ | |
eb69a686 | 2291 | #if defined (MSDOS) && !defined (__TURBOC__) |
8b27f225 PB |
2292 | #include <malloc.h> |
2293 | #else /* not MSDOS, or __TURBOC__ */ | |
2294 | #if defined(_AIX) | |
eb69a686 | 2295 | #include <malloc.h> |
8b27f225 | 2296 | #pragma alloca |
eb69a686 JH |
2297 | #else /* not MSDOS, __TURBOC__, or _AIX */ |
2298 | #ifdef __hpux | |
2299 | #ifdef __cplusplus | |
2300 | extern "C" { | |
2301 | void *alloca (unsigned int); | |
2302 | }; | |
2303 | #else /* not __cplusplus */ | |
2304 | void *alloca (); | |
2305 | #endif /* not __cplusplus */ | |
8b27f225 PB |
2306 | #endif /* __hpux */ |
2307 | #endif /* not _AIX */ | |
2308 | #endif /* not MSDOS, or __TURBOC__ */ | |
eb69a686 JH |
2309 | #endif /* not sparc. */ |
2310 | #endif /* not GNU C. */ | |
2311 | #endif /* alloca not defined. */ | |
8b27f225 | 2312 | |
eb69a686 JH |
2313 | /* This is the parser code that is written into each bison parser |
2314 | when the %semantic_parser declaration is not specified in the grammar. | |
2315 | It was written by Richard Stallman by simplifying the hairy parser | |
2316 | used when %semantic_parser is specified. */ | |
8b27f225 PB |
2317 | |
2318 | /* Note: there must be only one dollar sign in this file. | |
2319 | It is replaced by the list of actions, each action | |
2320 | as one case of the switch. */ | |
2321 | ||
2322 | #define yyerrok (yyerrstatus = 0) | |
2323 | #define yyclearin (yychar = YYEMPTY) | |
2324 | #define YYEMPTY -2 | |
2325 | #define YYEOF 0 | |
eb69a686 JH |
2326 | #define YYACCEPT return(0) |
2327 | #define YYABORT return(1) | |
8b27f225 PB |
2328 | #define YYERROR goto yyerrlab1 |
2329 | /* Like YYERROR except do call yyerror. | |
2330 | This remains here temporarily to ease the | |
2331 | transition to the new meaning of YYERROR, for GCC. | |
2332 | Once GCC version 2 has supplanted version 1, this can go. */ | |
2333 | #define YYFAIL goto yyerrlab | |
2334 | #define YYRECOVERING() (!!yyerrstatus) | |
2335 | #define YYBACKUP(token, value) \ | |
2336 | do \ | |
2337 | if (yychar == YYEMPTY && yylen == 1) \ | |
2338 | { yychar = (token), yylval = (value); \ | |
2339 | yychar1 = YYTRANSLATE (yychar); \ | |
2340 | YYPOPSTACK; \ | |
2341 | goto yybackup; \ | |
2342 | } \ | |
2343 | else \ | |
2344 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ | |
2345 | while (0) | |
2346 | ||
2347 | #define YYTERROR 1 | |
2348 | #define YYERRCODE 256 | |
2349 | ||
2350 | #ifndef YYPURE | |
2351 | #define YYLEX yylex() | |
2352 | #endif | |
2353 | ||
2354 | #ifdef YYPURE | |
2355 | #ifdef YYLSP_NEEDED | |
2356 | #ifdef YYLEX_PARAM | |
2357 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) | |
2358 | #else | |
2359 | #define YYLEX yylex(&yylval, &yylloc) | |
2360 | #endif | |
2361 | #else /* not YYLSP_NEEDED */ | |
2362 | #ifdef YYLEX_PARAM | |
2363 | #define YYLEX yylex(&yylval, YYLEX_PARAM) | |
2364 | #else | |
2365 | #define YYLEX yylex(&yylval) | |
2366 | #endif | |
2367 | #endif /* not YYLSP_NEEDED */ | |
2368 | #endif | |
2369 | ||
2370 | /* If nonreentrant, generate the variables here */ | |
2371 | ||
2372 | #ifndef YYPURE | |
2373 | ||
2374 | int yychar; /* the lookahead symbol */ | |
2375 | YYSTYPE yylval; /* the semantic value of the */ | |
2376 | /* lookahead symbol */ | |
2377 | ||
2378 | #ifdef YYLSP_NEEDED | |
2379 | YYLTYPE yylloc; /* location data for the lookahead */ | |
2380 | /* symbol */ | |
2381 | #endif | |
2382 | ||
2383 | int yynerrs; /* number of parse errors so far */ | |
2384 | #endif /* not YYPURE */ | |
2385 | ||
2386 | #if YYDEBUG != 0 | |
2387 | int yydebug; /* nonzero means print parse trace */ | |
2388 | /* Since this is uninitialized, it does not stop multiple parsers | |
2389 | from coexisting. */ | |
2390 | #endif | |
2391 | ||
2392 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ | |
2393 | ||
2394 | #ifndef YYINITDEPTH | |
2395 | #define YYINITDEPTH 200 | |
2396 | #endif | |
2397 | ||
2398 | /* YYMAXDEPTH is the maximum size the stacks can grow to | |
2399 | (effective only if the built-in stack extension method is used). */ | |
2400 | ||
2401 | #if YYMAXDEPTH == 0 | |
2402 | #undef YYMAXDEPTH | |
2403 | #endif | |
2404 | ||
2405 | #ifndef YYMAXDEPTH | |
2406 | #define YYMAXDEPTH 10000 | |
2407 | #endif | |
591702de | 2408 | |
eb69a686 JH |
2409 | /* Prevent warning if -Wstrict-prototypes. */ |
2410 | #ifdef __GNUC__ | |
2411 | int yyparse (void); | |
2412 | #endif | |
2413 | \f | |
8b27f225 PB |
2414 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
2415 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) | |
2416 | #else /* not GNU C or C++ */ | |
2417 | #ifndef __cplusplus | |
2418 | ||
2419 | /* This is the most reliable way to avoid incompatibilities | |
2420 | in available built-in functions on various systems. */ | |
2421 | static void | |
2422 | __yy_memcpy (to, from, count) | |
2423 | char *to; | |
2424 | char *from; | |
eb69a686 | 2425 | int count; |
8b27f225 PB |
2426 | { |
2427 | register char *f = from; | |
2428 | register char *t = to; | |
2429 | register int i = count; | |
2430 | ||
2431 | while (i-- > 0) | |
2432 | *t++ = *f++; | |
2433 | } | |
2434 | ||
2435 | #else /* __cplusplus */ | |
2436 | ||
2437 | /* This is the most reliable way to avoid incompatibilities | |
2438 | in available built-in functions on various systems. */ | |
2439 | static void | |
eb69a686 | 2440 | __yy_memcpy (char *to, char *from, int count) |
8b27f225 | 2441 | { |
591702de | 2442 | register char *f = from; |
eb69a686 | 2443 | register char *t = to; |
8b27f225 PB |
2444 | register int i = count; |
2445 | ||
2446 | while (i-- > 0) | |
2447 | *t++ = *f++; | |
2448 | } | |
2449 | ||
2450 | #endif | |
2451 | #endif | |
2452 | \f | |
c52b5771 | 2453 | #line 196 "/home/green/cygnus/njava/i0/share/bison.simple" |
8b27f225 PB |
2454 | |
2455 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed | |
2456 | into yyparse. The argument should have type void *. | |
2457 | It should actually point to an object. | |
2458 | Grammar actions can access the variable by casting it | |
2459 | to the proper pointer type. */ | |
2460 | ||
2461 | #ifdef YYPARSE_PARAM | |
2462 | #ifdef __cplusplus | |
2463 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM | |
2464 | #define YYPARSE_PARAM_DECL | |
2465 | #else /* not __cplusplus */ | |
2466 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM | |
2467 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; | |
2468 | #endif /* not __cplusplus */ | |
2469 | #else /* not YYPARSE_PARAM */ | |
2470 | #define YYPARSE_PARAM_ARG | |
2471 | #define YYPARSE_PARAM_DECL | |
2472 | #endif /* not YYPARSE_PARAM */ | |
2473 | ||
2474 | int | |
2475 | yyparse(YYPARSE_PARAM_ARG) | |
2476 | YYPARSE_PARAM_DECL | |
2477 | { | |
2478 | register int yystate; | |
2479 | register int yyn; | |
2480 | register short *yyssp; | |
2481 | register YYSTYPE *yyvsp; | |
2482 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ | |
2483 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ | |
2484 | ||
2485 | short yyssa[YYINITDEPTH]; /* the state stack */ | |
2486 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ | |
2487 | ||
2488 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ | |
2489 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ | |
2490 | ||
2491 | #ifdef YYLSP_NEEDED | |
2492 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ | |
2493 | YYLTYPE *yyls = yylsa; | |
2494 | YYLTYPE *yylsp; | |
2495 | ||
2496 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) | |
2497 | #else | |
2498 | #define YYPOPSTACK (yyvsp--, yyssp--) | |
2499 | #endif | |
2500 | ||
2501 | int yystacksize = YYINITDEPTH; | |
2502 | ||
2503 | #ifdef YYPURE | |
2504 | int yychar; | |
2505 | YYSTYPE yylval; | |
2506 | int yynerrs; | |
2507 | #ifdef YYLSP_NEEDED | |
2508 | YYLTYPE yylloc; | |
2509 | #endif | |
2510 | #endif | |
2511 | ||
2512 | YYSTYPE yyval; /* the variable used to return */ | |
2513 | /* semantic values from the action */ | |
2514 | /* routines */ | |
2515 | ||
2516 | int yylen; | |
2517 | ||
2518 | #if YYDEBUG != 0 | |
2519 | if (yydebug) | |
2520 | fprintf(stderr, "Starting parse\n"); | |
2521 | #endif | |
2522 | ||
2523 | yystate = 0; | |
2524 | yyerrstatus = 0; | |
2525 | yynerrs = 0; | |
2526 | yychar = YYEMPTY; /* Cause a token to be read. */ | |
2527 | ||
2528 | /* Initialize stack pointers. | |
2529 | Waste one element of value and location stack | |
2530 | so that they stay on the same level as the state stack. | |
2531 | The wasted elements are never initialized. */ | |
2532 | ||
2533 | yyssp = yyss - 1; | |
2534 | yyvsp = yyvs; | |
2535 | #ifdef YYLSP_NEEDED | |
2536 | yylsp = yyls; | |
2537 | #endif | |
2538 | ||
2539 | /* Push a new state, which is found in yystate . */ | |
2540 | /* In all cases, when you get here, the value and location stacks | |
2541 | have just been pushed. so pushing a state here evens the stacks. */ | |
2542 | yynewstate: | |
2543 | ||
2544 | *++yyssp = yystate; | |
2545 | ||
2546 | if (yyssp >= yyss + yystacksize - 1) | |
2547 | { | |
2548 | /* Give user a chance to reallocate the stack */ | |
2549 | /* Use copies of these so that the &'s don't force the real ones into memory. */ | |
2550 | YYSTYPE *yyvs1 = yyvs; | |
2551 | short *yyss1 = yyss; | |
2552 | #ifdef YYLSP_NEEDED | |
2553 | YYLTYPE *yyls1 = yyls; | |
2554 | #endif | |
2555 | ||
2556 | /* Get the current used size of the three stacks, in elements. */ | |
2557 | int size = yyssp - yyss + 1; | |
2558 | ||
2559 | #ifdef yyoverflow | |
2560 | /* Each stack pointer address is followed by the size of | |
2561 | the data in use in that stack, in bytes. */ | |
2562 | #ifdef YYLSP_NEEDED | |
2563 | /* This used to be a conditional around just the two extra args, | |
2564 | but that might be undefined if yyoverflow is a macro. */ | |
2565 | yyoverflow("parser stack overflow", | |
2566 | &yyss1, size * sizeof (*yyssp), | |
2567 | &yyvs1, size * sizeof (*yyvsp), | |
2568 | &yyls1, size * sizeof (*yylsp), | |
2569 | &yystacksize); | |
2570 | #else | |
2571 | yyoverflow("parser stack overflow", | |
2572 | &yyss1, size * sizeof (*yyssp), | |
2573 | &yyvs1, size * sizeof (*yyvsp), | |
2574 | &yystacksize); | |
2575 | #endif | |
2576 | ||
2577 | yyss = yyss1; yyvs = yyvs1; | |
2578 | #ifdef YYLSP_NEEDED | |
2579 | yyls = yyls1; | |
2580 | #endif | |
2581 | #else /* no yyoverflow */ | |
2582 | /* Extend the stack our own way. */ | |
2583 | if (yystacksize >= YYMAXDEPTH) | |
2584 | { | |
2585 | yyerror("parser stack overflow"); | |
2586 | return 2; | |
2587 | } | |
2588 | yystacksize *= 2; | |
2589 | if (yystacksize > YYMAXDEPTH) | |
2590 | yystacksize = YYMAXDEPTH; | |
eb69a686 JH |
2591 | yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); |
2592 | __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); | |
2593 | yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); | |
2594 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); | |
8b27f225 | 2595 | #ifdef YYLSP_NEEDED |
eb69a686 JH |
2596 | yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); |
2597 | __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); | |
8b27f225 PB |
2598 | #endif |
2599 | #endif /* no yyoverflow */ | |
2600 | ||
2601 | yyssp = yyss + size - 1; | |
2602 | yyvsp = yyvs + size - 1; | |
2603 | #ifdef YYLSP_NEEDED | |
2604 | yylsp = yyls + size - 1; | |
2605 | #endif | |
2606 | ||
2607 | #if YYDEBUG != 0 | |
2608 | if (yydebug) | |
2609 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); | |
2610 | #endif | |
2611 | ||
2612 | if (yyssp >= yyss + yystacksize - 1) | |
2613 | YYABORT; | |
2614 | } | |
2615 | ||
2616 | #if YYDEBUG != 0 | |
2617 | if (yydebug) | |
2618 | fprintf(stderr, "Entering state %d\n", yystate); | |
2619 | #endif | |
2620 | ||
2621 | goto yybackup; | |
2622 | yybackup: | |
2623 | ||
2624 | /* Do appropriate processing given the current state. */ | |
2625 | /* Read a lookahead token if we need one and don't already have one. */ | |
2626 | /* yyresume: */ | |
2627 | ||
2628 | /* First try to decide what to do without reference to lookahead token. */ | |
2629 | ||
2630 | yyn = yypact[yystate]; | |
2631 | if (yyn == YYFLAG) | |
2632 | goto yydefault; | |
2633 | ||
2634 | /* Not known => get a lookahead token if don't already have one. */ | |
2635 | ||
2636 | /* yychar is either YYEMPTY or YYEOF | |
2637 | or a valid token in external form. */ | |
2638 | ||
2639 | if (yychar == YYEMPTY) | |
2640 | { | |
2641 | #if YYDEBUG != 0 | |
2642 | if (yydebug) | |
2643 | fprintf(stderr, "Reading a token: "); | |
2644 | #endif | |
2645 | yychar = YYLEX; | |
2646 | } | |
2647 | ||
2648 | /* Convert token to internal form (in yychar1) for indexing tables with */ | |
2649 | ||
2650 | if (yychar <= 0) /* This means end of input. */ | |
2651 | { | |
2652 | yychar1 = 0; | |
2653 | yychar = YYEOF; /* Don't call YYLEX any more */ | |
2654 | ||
2655 | #if YYDEBUG != 0 | |
2656 | if (yydebug) | |
2657 | fprintf(stderr, "Now at end of input.\n"); | |
2658 | #endif | |
2659 | } | |
2660 | else | |
2661 | { | |
2662 | yychar1 = YYTRANSLATE(yychar); | |
2663 | ||
2664 | #if YYDEBUG != 0 | |
2665 | if (yydebug) | |
2666 | { | |
2667 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); | |
2668 | /* Give the individual parser a way to print the precise meaning | |
2669 | of a token, for further debugging info. */ | |
2670 | #ifdef YYPRINT | |
2671 | YYPRINT (stderr, yychar, yylval); | |
2672 | #endif | |
2673 | fprintf (stderr, ")\n"); | |
2674 | } | |
2675 | #endif | |
2676 | } | |
2677 | ||
2678 | yyn += yychar1; | |
2679 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) | |
2680 | goto yydefault; | |
2681 | ||
2682 | yyn = yytable[yyn]; | |
2683 | ||
2684 | /* yyn is what to do for this token type in this state. | |
2685 | Negative => reduce, -yyn is rule number. | |
2686 | Positive => shift, yyn is new state. | |
2687 | New state is final state => don't bother to shift, | |
2688 | just return success. | |
2689 | 0, or most negative number => error. */ | |
2690 | ||
2691 | if (yyn < 0) | |
2692 | { | |
2693 | if (yyn == YYFLAG) | |
2694 | goto yyerrlab; | |
2695 | yyn = -yyn; | |
2696 | goto yyreduce; | |
2697 | } | |
2698 | else if (yyn == 0) | |
2699 | goto yyerrlab; | |
2700 | ||
2701 | if (yyn == YYFINAL) | |
2702 | YYACCEPT; | |
2703 | ||
2704 | /* Shift the lookahead token. */ | |
2705 | ||
2706 | #if YYDEBUG != 0 | |
2707 | if (yydebug) | |
2708 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); | |
2709 | #endif | |
2710 | ||
2711 | /* Discard the token being shifted unless it is eof. */ | |
2712 | if (yychar != YYEOF) | |
2713 | yychar = YYEMPTY; | |
2714 | ||
2715 | *++yyvsp = yylval; | |
2716 | #ifdef YYLSP_NEEDED | |
2717 | *++yylsp = yylloc; | |
2718 | #endif | |
2719 | ||
2720 | /* count tokens shifted since error; after three, turn off error status. */ | |
2721 | if (yyerrstatus) yyerrstatus--; | |
2722 | ||
2723 | yystate = yyn; | |
2724 | goto yynewstate; | |
2725 | ||
2726 | /* Do the default action for the current state. */ | |
2727 | yydefault: | |
2728 | ||
2729 | yyn = yydefact[yystate]; | |
2730 | if (yyn == 0) | |
2731 | goto yyerrlab; | |
2732 | ||
2733 | /* Do a reduction. yyn is the number of a rule to reduce with. */ | |
2734 | yyreduce: | |
2735 | yylen = yyr2[yyn]; | |
2736 | if (yylen > 0) | |
2737 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ | |
2738 | ||
2739 | #if YYDEBUG != 0 | |
2740 | if (yydebug) | |
2741 | { | |
2742 | int i; | |
2743 | ||
2744 | fprintf (stderr, "Reducing via rule %d (line %d), ", | |
2745 | yyn, yyrline[yyn]); | |
2746 | ||
2747 | /* Print the symbols being reduced, and their result. */ | |
2748 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) | |
2749 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); | |
2750 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); | |
2751 | } | |
2752 | #endif | |
2753 | ||
2754 | ||
2755 | switch (yyn) { | |
2756 | ||
2757 | case 1: | |
51149cc8 | 2758 | #line 487 "./parse.y" |
8b27f225 PB |
2759 | {; |
2760 | break;} | |
2761 | case 18: | |
51149cc8 | 2762 | #line 531 "./parse.y" |
8b27f225 PB |
2763 | { |
2764 | yyval.node = build_java_array_type (yyvsp[-2].node, -1); | |
2765 | CLASS_LOADED_P (yyval.node) = 1; | |
2766 | ; | |
2767 | break;} | |
2768 | case 19: | |
51149cc8 | 2769 | #line 536 "./parse.y" |
8b27f225 PB |
2770 | { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ; |
2771 | break;} | |
2772 | case 20: | |
51149cc8 | 2773 | #line 538 "./parse.y" |
8b27f225 PB |
2774 | { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ; |
2775 | break;} | |
2776 | case 21: | |
51149cc8 | 2777 | #line 540 "./parse.y" |
8b27f225 PB |
2778 | {RULE ("']' expected"); RECOVER;; |
2779 | break;} | |
2780 | case 22: | |
51149cc8 | 2781 | #line 542 "./parse.y" |
8b27f225 PB |
2782 | {RULE ("']' expected"); RECOVER;; |
2783 | break;} | |
2784 | case 26: | |
51149cc8 | 2785 | #line 557 "./parse.y" |
8b27f225 PB |
2786 | { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ; |
2787 | break;} | |
2788 | case 28: | |
51149cc8 | 2789 | #line 566 "./parse.y" |
8b27f225 PB |
2790 | {yyval.node = NULL;; |
2791 | break;} | |
2792 | case 36: | |
51149cc8 | 2793 | #line 578 "./parse.y" |
8b27f225 PB |
2794 | { |
2795 | yyval.node = NULL; | |
2796 | ; | |
2797 | break;} | |
2798 | case 37: | |
51149cc8 | 2799 | #line 582 "./parse.y" |
8b27f225 PB |
2800 | { |
2801 | yyval.node = NULL; | |
2802 | ; | |
2803 | break;} | |
2804 | case 40: | |
51149cc8 | 2805 | #line 594 "./parse.y" |
ee07f4f4 APB |
2806 | { |
2807 | ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node); | |
2808 | package_list = tree_cons (ctxp->package, NULL, package_list); | |
2809 | ; | |
8b27f225 PB |
2810 | break;} |
2811 | case 41: | |
51149cc8 | 2812 | #line 599 "./parse.y" |
8b27f225 PB |
2813 | {yyerror ("Missing name"); RECOVER;; |
2814 | break;} | |
2815 | case 42: | |
51149cc8 | 2816 | #line 601 "./parse.y" |
8b27f225 PB |
2817 | {yyerror ("';' expected"); RECOVER;; |
2818 | break;} | |
2819 | case 45: | |
51149cc8 | 2820 | #line 611 "./parse.y" |
8b27f225 PB |
2821 | { |
2822 | tree name = EXPR_WFL_NODE (yyvsp[-1].node), node, last_name; | |
2823 | int i = IDENTIFIER_LENGTH (name)-1; | |
49f48c71 | 2824 | const char *last = &IDENTIFIER_POINTER (name)[i]; |
8b27f225 PB |
2825 | while (last != IDENTIFIER_POINTER (name)) |
2826 | { | |
2827 | if (last [0] == '.') | |
2828 | break; | |
2829 | last--; | |
2830 | } | |
2831 | last_name = get_identifier (++last); | |
2832 | if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name)) | |
2833 | { | |
2834 | tree err = find_name_in_single_imports (last_name); | |
2835 | if (err && err != name) | |
2836 | parse_error_context | |
2837 | (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'", | |
2838 | IDENTIFIER_POINTER (name), | |
2839 | IDENTIFIER_POINTER (err)); | |
5e942c50 APB |
2840 | else |
2841 | REGISTER_IMPORT (yyvsp[-1].node, last_name) | |
8b27f225 PB |
2842 | } |
2843 | else | |
5e942c50 | 2844 | REGISTER_IMPORT (yyvsp[-1].node, last_name); |
8b27f225 PB |
2845 | ; |
2846 | break;} | |
2847 | case 46: | |
51149cc8 | 2848 | #line 637 "./parse.y" |
8b27f225 PB |
2849 | {yyerror ("Missing name"); RECOVER;; |
2850 | break;} | |
2851 | case 47: | |
51149cc8 | 2852 | #line 639 "./parse.y" |
8b27f225 PB |
2853 | {yyerror ("';' expected"); RECOVER;; |
2854 | break;} | |
2855 | case 48: | |
51149cc8 | 2856 | #line 644 "./parse.y" |
8b27f225 PB |
2857 | { |
2858 | tree name = EXPR_WFL_NODE (yyvsp[-3].node); | |
ba179f9f APB |
2859 | /* Don't import java.lang.* twice. */ |
2860 | if (name != java_lang_id) | |
2861 | { | |
2862 | tree node = build_tree_list (yyvsp[-3].node, NULL_TREE); | |
2863 | read_import_dir (yyvsp[-3].node); | |
2864 | TREE_CHAIN (node) = ctxp->import_demand_list; | |
2865 | ctxp->import_demand_list = node; | |
2866 | } | |
8b27f225 PB |
2867 | ; |
2868 | break;} | |
2869 | case 49: | |
51149cc8 | 2870 | #line 656 "./parse.y" |
8b27f225 PB |
2871 | {yyerror ("'*' expected"); RECOVER;; |
2872 | break;} | |
2873 | case 50: | |
51149cc8 | 2874 | #line 658 "./parse.y" |
8b27f225 PB |
2875 | {yyerror ("';' expected"); RECOVER;; |
2876 | break;} | |
2877 | case 51: | |
51149cc8 | 2878 | #line 663 "./parse.y" |
8b27f225 | 2879 | { |
22eed1e6 | 2880 | maybe_generate_finit (); |
63a212ed | 2881 | maybe_generate_clinit (); |
8b27f225 PB |
2882 | yyval.node = yyvsp[0].node; |
2883 | ; | |
2884 | break;} | |
7f1d4866 | 2885 | case 52: |
51149cc8 | 2886 | #line 669 "./parse.y" |
7f1d4866 APB |
2887 | { |
2888 | maybe_generate_clinit (); | |
2889 | yyval.node = yyvsp[0].node; | |
2890 | ; | |
2891 | break;} | |
8b27f225 | 2892 | case 53: |
51149cc8 | 2893 | #line 674 "./parse.y" |
8b27f225 PB |
2894 | { yyval.node = NULL; ; |
2895 | break;} | |
2896 | case 54: | |
51149cc8 | 2897 | #line 676 "./parse.y" |
8b27f225 PB |
2898 | { |
2899 | YYERROR_NOW; | |
2900 | yyerror ("Class or interface declaration expected"); | |
2901 | ; | |
2902 | break;} | |
2903 | case 55: | |
51149cc8 | 2904 | #line 687 "./parse.y" |
8b27f225 PB |
2905 | { |
2906 | yyval.value = (1 << yyvsp[0].value); | |
2907 | ; | |
2908 | break;} | |
2909 | case 56: | |
51149cc8 | 2910 | #line 691 "./parse.y" |
8b27f225 PB |
2911 | { |
2912 | int acc = (1 << yyvsp[0].value); | |
2913 | if (yyval.value & acc) | |
2914 | parse_error_context | |
2915 | (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice", | |
2916 | java_accstring_lookup (acc)); | |
2917 | else | |
2918 | { | |
2919 | yyval.value |= acc; | |
2920 | } | |
2921 | ; | |
2922 | break;} | |
2923 | case 57: | |
51149cc8 | 2924 | #line 707 "./parse.y" |
8b27f225 PB |
2925 | { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ; |
2926 | break;} | |
2927 | case 58: | |
51149cc8 | 2928 | #line 709 "./parse.y" |
8b27f225 PB |
2929 | { |
2930 | yyval.node = yyvsp[0].node; | |
2931 | ; | |
2932 | break;} | |
2933 | case 59: | |
51149cc8 | 2934 | #line 713 "./parse.y" |
8b27f225 PB |
2935 | { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ; |
2936 | break;} | |
2937 | case 60: | |
51149cc8 | 2938 | #line 715 "./parse.y" |
8b27f225 PB |
2939 | { |
2940 | yyval.node = yyvsp[0].node; | |
2941 | ; | |
2942 | break;} | |
2943 | case 61: | |
51149cc8 | 2944 | #line 719 "./parse.y" |
8b27f225 PB |
2945 | {yyerror ("Missing class name"); RECOVER;; |
2946 | break;} | |
2947 | case 62: | |
51149cc8 | 2948 | #line 721 "./parse.y" |
8b27f225 PB |
2949 | {yyerror ("Missing class name"); RECOVER;; |
2950 | break;} | |
2951 | case 63: | |
51149cc8 | 2952 | #line 723 "./parse.y" |
0b4d333e APB |
2953 | { |
2954 | if (!ctxp->class_err) yyerror ("'{' expected"); | |
2955 | DRECOVER(class1); | |
2956 | ; | |
8b27f225 PB |
2957 | break;} |
2958 | case 64: | |
51149cc8 | 2959 | #line 728 "./parse.y" |
8b27f225 PB |
2960 | {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;; |
2961 | break;} | |
2962 | case 65: | |
51149cc8 | 2963 | #line 732 "./parse.y" |
8b27f225 PB |
2964 | { yyval.node = NULL; ; |
2965 | break;} | |
2966 | case 66: | |
51149cc8 | 2967 | #line 734 "./parse.y" |
8b27f225 PB |
2968 | { yyval.node = yyvsp[0].node; ; |
2969 | break;} | |
2970 | case 67: | |
51149cc8 | 2971 | #line 736 "./parse.y" |
8b27f225 PB |
2972 | {yyerror ("'{' expected"); ctxp->class_err=1;; |
2973 | break;} | |
2974 | case 68: | |
51149cc8 | 2975 | #line 738 "./parse.y" |
8b27f225 PB |
2976 | {yyerror ("Missing super class name"); ctxp->class_err=1;; |
2977 | break;} | |
2978 | case 69: | |
51149cc8 | 2979 | #line 742 "./parse.y" |
8b27f225 PB |
2980 | { yyval.node = NULL_TREE; ; |
2981 | break;} | |
2982 | case 70: | |
51149cc8 | 2983 | #line 744 "./parse.y" |
8b27f225 PB |
2984 | { yyval.node = yyvsp[0].node; ; |
2985 | break;} | |
2986 | case 71: | |
51149cc8 | 2987 | #line 746 "./parse.y" |
8b27f225 PB |
2988 | { |
2989 | ctxp->class_err=1; | |
2990 | yyerror ("Missing interface name"); | |
2991 | ; | |
2992 | break;} | |
2993 | case 72: | |
51149cc8 | 2994 | #line 754 "./parse.y" |
8b27f225 PB |
2995 | { |
2996 | ctxp->interface_number = 1; | |
2997 | yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); | |
2998 | ; | |
2999 | break;} | |
3000 | case 73: | |
51149cc8 | 3001 | #line 759 "./parse.y" |
8b27f225 PB |
3002 | { |
3003 | ctxp->interface_number++; | |
3004 | yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE)); | |
3005 | ; | |
3006 | break;} | |
3007 | case 74: | |
51149cc8 | 3008 | #line 764 "./parse.y" |
8b27f225 PB |
3009 | {yyerror ("Missing interface name"); RECOVER;; |
3010 | break;} | |
3011 | case 75: | |
51149cc8 | 3012 | #line 769 "./parse.y" |
7f10c2e2 APB |
3013 | { |
3014 | /* Store the location of the `}' when doing xrefs */ | |
3015 | if (flag_emit_xref) | |
3016 | DECL_END_SOURCE_LINE (ctxp->current_parsed_class) = | |
3017 | EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1); | |
3018 | yyval.node = ctxp->current_parsed_class; | |
3019 | ; | |
8b27f225 PB |
3020 | break;} |
3021 | case 76: | |
51149cc8 | 3022 | #line 777 "./parse.y" |
7f10c2e2 APB |
3023 | { |
3024 | /* Store the location of the `}' when doing xrefs */ | |
3025 | if (flag_emit_xref) | |
3026 | DECL_END_SOURCE_LINE (ctxp->current_parsed_class) = | |
3027 | EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1); | |
3028 | yyval.node = ctxp->current_parsed_class; | |
3029 | ; | |
8b27f225 PB |
3030 | break;} |
3031 | case 82: | |
51149cc8 | 3032 | #line 796 "./parse.y" |
8b27f225 PB |
3033 | { yyval.node = parse_jdk1_1_error ("instance initializer"); ; |
3034 | break;} | |
0b4d333e | 3035 | case 84: |
51149cc8 | 3036 | #line 802 "./parse.y" |
0b4d333e | 3037 | { yyval.node = yyvsp[-1].node; ; |
8b27f225 PB |
3038 | break;} |
3039 | case 86: | |
51149cc8 | 3040 | #line 805 "./parse.y" |
0b4d333e | 3041 | { yyval.node = parse_jdk1_1_error ("inner classe declaration"); ; |
8b27f225 PB |
3042 | break;} |
3043 | case 87: | |
51149cc8 | 3044 | #line 807 "./parse.y" |
0b4d333e | 3045 | { yyval.node = parse_jdk1_1_error ("inner interface declaration"); ; |
8b27f225 PB |
3046 | break;} |
3047 | case 88: | |
51149cc8 | 3048 | #line 813 "./parse.y" |
0b4d333e APB |
3049 | { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ; |
3050 | break;} | |
3051 | case 89: | |
51149cc8 | 3052 | #line 815 "./parse.y" |
8b27f225 PB |
3053 | { |
3054 | check_modifiers | |
3055 | ("Illegal modifier `%s' for field declaration", | |
3056 | yyvsp[-3].value, FIELD_MODIFIERS); | |
3057 | check_modifiers_consistency (yyvsp[-3].value); | |
3058 | register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node); | |
3059 | ; | |
3060 | break;} | |
8b27f225 | 3061 | case 91: |
51149cc8 | 3062 | #line 828 "./parse.y" |
0b4d333e | 3063 | { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ; |
8b27f225 PB |
3064 | break;} |
3065 | case 92: | |
51149cc8 | 3066 | #line 830 "./parse.y" |
0b4d333e | 3067 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 PB |
3068 | break;} |
3069 | case 93: | |
51149cc8 | 3070 | #line 835 "./parse.y" |
0b4d333e APB |
3071 | { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ; |
3072 | break;} | |
3073 | case 94: | |
51149cc8 | 3074 | #line 837 "./parse.y" |
8b27f225 PB |
3075 | { |
3076 | if (java_error_count) | |
3077 | yyvsp[0].node = NULL_TREE; | |
3078 | yyval.node = build_tree_list | |
3079 | (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node)); | |
3080 | ; | |
3081 | break;} | |
0b4d333e | 3082 | case 95: |
51149cc8 | 3083 | #line 844 "./parse.y" |
8b27f225 PB |
3084 | { |
3085 | yyerror ("Missing variable initializer"); | |
3086 | yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE); | |
3087 | RECOVER; | |
3088 | ; | |
3089 | break;} | |
0b4d333e | 3090 | case 96: |
51149cc8 | 3091 | #line 850 "./parse.y" |
8b27f225 PB |
3092 | { |
3093 | yyerror ("';' expected"); | |
3094 | yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE); | |
3095 | RECOVER; | |
3096 | ; | |
3097 | break;} | |
0b4d333e | 3098 | case 98: |
51149cc8 | 3099 | #line 860 "./parse.y" |
8b27f225 PB |
3100 | { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ; |
3101 | break;} | |
0b4d333e | 3102 | case 99: |
51149cc8 | 3103 | #line 862 "./parse.y" |
8b27f225 PB |
3104 | {yyerror ("Invalid declaration"); DRECOVER(vdi);; |
3105 | break;} | |
0b4d333e | 3106 | case 100: |
51149cc8 | 3107 | #line 864 "./parse.y" |
8b27f225 PB |
3108 | {yyerror ("']' expected"); DRECOVER(vdi);; |
3109 | break;} | |
0b4d333e | 3110 | case 101: |
51149cc8 | 3111 | #line 866 "./parse.y" |
8b27f225 PB |
3112 | {yyerror ("Unbalanced ']'"); DRECOVER(vdi);; |
3113 | break;} | |
0b4d333e | 3114 | case 104: |
51149cc8 | 3115 | #line 877 "./parse.y" |
8b27f225 PB |
3116 | { |
3117 | current_function_decl = yyvsp[0].node; | |
3118 | source_start_java_method (current_function_decl); | |
3119 | ; | |
3120 | break;} | |
8b27f225 | 3121 | case 105: |
51149cc8 | 3122 | #line 882 "./parse.y" |
e85ac860 | 3123 | { finish_method_declaration (yyvsp[0].node); ; |
8b27f225 PB |
3124 | break;} |
3125 | case 106: | |
51149cc8 | 3126 | #line 884 "./parse.y" |
0b4d333e | 3127 | {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;; |
8b27f225 PB |
3128 | break;} |
3129 | case 107: | |
51149cc8 | 3130 | #line 889 "./parse.y" |
0b4d333e | 3131 | { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ; |
8b27f225 PB |
3132 | break;} |
3133 | case 108: | |
51149cc8 | 3134 | #line 891 "./parse.y" |
0b4d333e | 3135 | { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ; |
8b27f225 PB |
3136 | break;} |
3137 | case 109: | |
51149cc8 | 3138 | #line 893 "./parse.y" |
0b4d333e | 3139 | { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ; |
8b27f225 PB |
3140 | break;} |
3141 | case 110: | |
51149cc8 | 3142 | #line 895 "./parse.y" |
0b4d333e | 3143 | { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ; |
8b27f225 PB |
3144 | break;} |
3145 | case 111: | |
51149cc8 | 3146 | #line 897 "./parse.y" |
efa0a23f APB |
3147 | { |
3148 | yyerror ("Invalid method declaration, method name required"); | |
3149 | RECOVER; | |
3150 | ; | |
8b27f225 PB |
3151 | break;} |
3152 | case 112: | |
51149cc8 | 3153 | #line 902 "./parse.y" |
0b4d333e | 3154 | {RECOVER;; |
8b27f225 PB |
3155 | break;} |
3156 | case 113: | |
51149cc8 | 3157 | #line 904 "./parse.y" |
8b27f225 PB |
3158 | {yyerror ("Identifier expected"); RECOVER;; |
3159 | break;} | |
3160 | case 114: | |
51149cc8 | 3161 | #line 906 "./parse.y" |
0b4d333e APB |
3162 | {yyerror ("Identifier expected"); RECOVER;; |
3163 | break;} | |
3164 | case 115: | |
51149cc8 | 3165 | #line 908 "./parse.y" |
8b27f225 PB |
3166 | { |
3167 | yyerror ("Invalid method declaration, return type required"); | |
3168 | RECOVER; | |
3169 | ; | |
3170 | break;} | |
0b4d333e | 3171 | case 116: |
51149cc8 | 3172 | #line 916 "./parse.y" |
8b27f225 PB |
3173 | { yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE); ; |
3174 | break;} | |
0b4d333e | 3175 | case 117: |
51149cc8 | 3176 | #line 918 "./parse.y" |
8b27f225 PB |
3177 | { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ; |
3178 | break;} | |
0b4d333e | 3179 | case 118: |
51149cc8 | 3180 | #line 920 "./parse.y" |
8b27f225 | 3181 | { |
1886c9d8 APB |
3182 | EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location; |
3183 | TREE_PURPOSE (yyvsp[-2].node) = | |
3184 | build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node)); | |
3185 | parse_warning_context | |
3186 | (wfl_operator, | |
3187 | "Discouraged form of returned type specification"); | |
8b27f225 PB |
3188 | ; |
3189 | break;} | |
8b27f225 | 3190 | case 119: |
51149cc8 | 3191 | #line 929 "./parse.y" |
0b4d333e | 3192 | {yyerror ("')' expected"); DRECOVER(method_declarator);; |
8b27f225 PB |
3193 | break;} |
3194 | case 120: | |
51149cc8 | 3195 | #line 931 "./parse.y" |
0b4d333e APB |
3196 | {yyerror ("']' expected"); RECOVER;; |
3197 | break;} | |
3198 | case 121: | |
51149cc8 | 3199 | #line 936 "./parse.y" |
8b27f225 PB |
3200 | { |
3201 | ctxp->formal_parameter_number = 1; | |
3202 | ; | |
3203 | break;} | |
0b4d333e | 3204 | case 122: |
51149cc8 | 3205 | #line 940 "./parse.y" |
8b27f225 PB |
3206 | { |
3207 | ctxp->formal_parameter_number += 1; | |
3208 | yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); | |
3209 | ; | |
3210 | break;} | |
8b27f225 | 3211 | case 123: |
51149cc8 | 3212 | #line 945 "./parse.y" |
0b4d333e APB |
3213 | {yyerror ("Missing formal parameter term"); RECOVER;; |
3214 | break;} | |
3215 | case 124: | |
51149cc8 | 3216 | #line 950 "./parse.y" |
8b27f225 PB |
3217 | { |
3218 | yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node); | |
3219 | ; | |
3220 | break;} | |
0b4d333e | 3221 | case 125: |
51149cc8 | 3222 | #line 954 "./parse.y" |
5256aa37 APB |
3223 | { |
3224 | parse_jdk1_1_error ("final parameters"); | |
3225 | yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node); | |
3226 | ; | |
8b27f225 | 3227 | break;} |
0b4d333e | 3228 | case 126: |
51149cc8 | 3229 | #line 959 "./parse.y" |
8b27f225 PB |
3230 | {yyerror ("Missing identifier"); RECOVER;; |
3231 | break;} | |
0b4d333e | 3232 | case 127: |
51149cc8 | 3233 | #line 961 "./parse.y" |
8b27f225 PB |
3234 | { |
3235 | SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[-2].value)); | |
3236 | yyerror ("Missing identifier"); RECOVER; | |
3237 | ; | |
3238 | break;} | |
8b27f225 | 3239 | case 128: |
51149cc8 | 3240 | #line 968 "./parse.y" |
0b4d333e | 3241 | { yyval.node = NULL_TREE; ; |
8b27f225 PB |
3242 | break;} |
3243 | case 129: | |
51149cc8 | 3244 | #line 970 "./parse.y" |
0b4d333e | 3245 | { yyval.node = yyvsp[0].node; ; |
8b27f225 PB |
3246 | break;} |
3247 | case 130: | |
51149cc8 | 3248 | #line 972 "./parse.y" |
0b4d333e | 3249 | {yyerror ("Missing class type term"); RECOVER;; |
8b27f225 PB |
3250 | break;} |
3251 | case 131: | |
51149cc8 | 3252 | #line 977 "./parse.y" |
0b4d333e | 3253 | { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ; |
8b27f225 PB |
3254 | break;} |
3255 | case 132: | |
51149cc8 | 3256 | #line 979 "./parse.y" |
0b4d333e APB |
3257 | { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ; |
3258 | break;} | |
3259 | case 133: | |
51149cc8 | 3260 | #line 981 "./parse.y" |
8b27f225 PB |
3261 | {yyerror ("Missing class type term"); RECOVER;; |
3262 | break;} | |
0b4d333e | 3263 | case 136: |
51149cc8 | 3264 | #line 988 "./parse.y" |
8b27f225 PB |
3265 | { yyval.node = NULL_TREE; ; |
3266 | break;} | |
0b4d333e | 3267 | case 137: |
51149cc8 | 3268 | #line 994 "./parse.y" |
8b27f225 | 3269 | { |
f099f336 APB |
3270 | TREE_CHAIN (yyvsp[0].node) = ctxp->static_initialized; |
3271 | ctxp->static_initialized = yyvsp[0].node; | |
8b27f225 PB |
3272 | ; |
3273 | break;} | |
0b4d333e | 3274 | case 138: |
51149cc8 | 3275 | #line 999 "./parse.y" |
8b27f225 | 3276 | { |
f099f336 APB |
3277 | TREE_CHAIN (yyvsp[-1].node) = ctxp->static_initialized; |
3278 | ctxp->static_initialized = yyvsp[-1].node; | |
8b27f225 PB |
3279 | ; |
3280 | break;} | |
0b4d333e | 3281 | case 139: |
51149cc8 | 3282 | #line 1007 "./parse.y" |
8b27f225 PB |
3283 | { |
3284 | SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value)); | |
3285 | ; | |
3286 | break;} | |
0b4d333e | 3287 | case 140: |
51149cc8 | 3288 | #line 1015 "./parse.y" |
8b27f225 | 3289 | { |
22eed1e6 APB |
3290 | current_function_decl = yyvsp[0].node; |
3291 | source_start_java_method (current_function_decl); | |
8b27f225 PB |
3292 | ; |
3293 | break;} | |
22eed1e6 | 3294 | case 141: |
51149cc8 | 3295 | #line 1020 "./parse.y" |
e85ac860 | 3296 | { finish_method_declaration (yyvsp[0].node); ; |
22eed1e6 APB |
3297 | break;} |
3298 | case 142: | |
51149cc8 | 3299 | #line 1025 "./parse.y" |
0b4d333e | 3300 | { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ; |
22eed1e6 APB |
3301 | break;} |
3302 | case 143: | |
51149cc8 | 3303 | #line 1027 "./parse.y" |
0b4d333e | 3304 | { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ; |
22eed1e6 APB |
3305 | break;} |
3306 | case 144: | |
51149cc8 | 3307 | #line 1032 "./parse.y" |
0b4d333e | 3308 | { yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE); ; |
22eed1e6 APB |
3309 | break;} |
3310 | case 145: | |
51149cc8 | 3311 | #line 1034 "./parse.y" |
0b4d333e APB |
3312 | { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ; |
3313 | break;} | |
3314 | case 146: | |
51149cc8 | 3315 | #line 1042 "./parse.y" |
22eed1e6 | 3316 | { |
c877974e | 3317 | BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node; |
22eed1e6 | 3318 | yyval.node = yyvsp[0].node; |
8b27f225 PB |
3319 | ; |
3320 | break;} | |
22eed1e6 | 3321 | case 147: |
51149cc8 | 3322 | #line 1047 "./parse.y" |
22eed1e6 APB |
3323 | { yyval.node = yyvsp[0].node; ; |
3324 | break;} | |
3325 | case 148: | |
51149cc8 | 3326 | #line 1049 "./parse.y" |
22eed1e6 APB |
3327 | { yyval.node = yyvsp[0].node; ; |
3328 | break;} | |
3329 | case 149: | |
51149cc8 | 3330 | #line 1051 "./parse.y" |
0b4d333e APB |
3331 | { yyval.node = yyvsp[0].node; ; |
3332 | break;} | |
2e5eb5c5 | 3333 | case 152: |
51149cc8 | 3334 | #line 1061 "./parse.y" |
22eed1e6 APB |
3335 | { |
3336 | yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE); | |
3337 | yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node); | |
3338 | yyval.node = java_method_add_stmt (current_function_decl, yyval.node); | |
8b27f225 PB |
3339 | ; |
3340 | break;} | |
2e5eb5c5 | 3341 | case 153: |
51149cc8 | 3342 | #line 1067 "./parse.y" |
22eed1e6 APB |
3343 | { |
3344 | yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node); | |
3345 | yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node); | |
3346 | yyval.node = java_method_add_stmt (current_function_decl, yyval.node); | |
8b27f225 PB |
3347 | ; |
3348 | break;} | |
2e5eb5c5 | 3349 | case 154: |
51149cc8 | 3350 | #line 1075 "./parse.y" |
8b27f225 PB |
3351 | {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ; |
3352 | break;} | |
2e5eb5c5 | 3353 | case 155: |
51149cc8 | 3354 | #line 1077 "./parse.y" |
0b4d333e APB |
3355 | {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ; |
3356 | break;} | |
2e5eb5c5 | 3357 | case 156: |
51149cc8 | 3358 | #line 1082 "./parse.y" |
8b27f225 | 3359 | { |
9ee9b555 | 3360 | tree wfl = build_wfl_node (this_identifier_node); |
8b27f225 PB |
3361 | EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location; |
3362 | yyval.node = wfl; | |
3363 | ; | |
3364 | break;} | |
2e5eb5c5 | 3365 | case 157: |
51149cc8 | 3366 | #line 1088 "./parse.y" |
8b27f225 | 3367 | { |
9ee9b555 | 3368 | tree wfl = build_wfl_node (super_identifier_node); |
8b27f225 PB |
3369 | EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location; |
3370 | yyval.node = wfl; | |
3371 | ; | |
3372 | break;} | |
2e5eb5c5 | 3373 | case 158: |
51149cc8 | 3374 | #line 1099 "./parse.y" |
8b27f225 PB |
3375 | { create_interface (0, yyvsp[0].node, NULL_TREE); ; |
3376 | break;} | |
2e5eb5c5 | 3377 | case 159: |
51149cc8 | 3378 | #line 1101 "./parse.y" |
8b27f225 PB |
3379 | { |
3380 | yyval.node = yyvsp[0].node; | |
3381 | ; | |
3382 | break;} | |
2e5eb5c5 | 3383 | case 160: |
51149cc8 | 3384 | #line 1105 "./parse.y" |
8b27f225 PB |
3385 | { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ; |
3386 | break;} | |
2e5eb5c5 | 3387 | case 161: |
51149cc8 | 3388 | #line 1107 "./parse.y" |
2e5eb5c5 | 3389 | { |
8b27f225 PB |
3390 | yyval.node = yyvsp[0].node; |
3391 | ; | |
3392 | break;} | |
2e5eb5c5 | 3393 | case 162: |
51149cc8 | 3394 | #line 1111 "./parse.y" |
8b27f225 PB |
3395 | { create_interface (0, yyvsp[-1].node, yyvsp[0].node); ; |
3396 | break;} | |
2e5eb5c5 | 3397 | case 163: |
51149cc8 | 3398 | #line 1113 "./parse.y" |
8b27f225 PB |
3399 | { |
3400 | yyval.node = yyvsp[0].node; | |
3401 | ; | |
3402 | break;} | |
2e5eb5c5 | 3403 | case 164: |
51149cc8 | 3404 | #line 1117 "./parse.y" |
8b27f225 PB |
3405 | { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ; |
3406 | break;} | |
2e5eb5c5 | 3407 | case 165: |
51149cc8 | 3408 | #line 1119 "./parse.y" |
8b27f225 PB |
3409 | { |
3410 | yyval.node = yyvsp[0].node; | |
3411 | ; | |
3412 | break;} | |
2e5eb5c5 | 3413 | case 166: |
51149cc8 | 3414 | #line 1123 "./parse.y" |
0b4d333e | 3415 | {yyerror ("'{' expected"); RECOVER;; |
8b27f225 | 3416 | break;} |
2e5eb5c5 | 3417 | case 167: |
51149cc8 | 3418 | #line 1125 "./parse.y" |
0b4d333e APB |
3419 | {yyerror ("'{' expected"); RECOVER;; |
3420 | break;} | |
2e5eb5c5 | 3421 | case 168: |
51149cc8 | 3422 | #line 1130 "./parse.y" |
8b27f225 PB |
3423 | { |
3424 | ctxp->interface_number = 1; | |
3425 | yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); | |
3426 | ; | |
3427 | break;} | |
2e5eb5c5 | 3428 | case 169: |
51149cc8 | 3429 | #line 1135 "./parse.y" |
8b27f225 PB |
3430 | { |
3431 | ctxp->interface_number++; | |
3432 | yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE)); | |
3433 | ; | |
3434 | break;} | |
2e5eb5c5 | 3435 | case 170: |
51149cc8 | 3436 | #line 1140 "./parse.y" |
0b4d333e | 3437 | {yyerror ("Invalid interface type"); RECOVER;; |
8b27f225 | 3438 | break;} |
2e5eb5c5 | 3439 | case 171: |
51149cc8 | 3440 | #line 1142 "./parse.y" |
0b4d333e | 3441 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 3442 | break;} |
2e5eb5c5 | 3443 | case 172: |
51149cc8 | 3444 | #line 1147 "./parse.y" |
8b27f225 PB |
3445 | { yyval.node = NULL_TREE; ; |
3446 | break;} | |
2e5eb5c5 | 3447 | case 173: |
51149cc8 | 3448 | #line 1149 "./parse.y" |
0b4d333e | 3449 | { yyval.node = NULL_TREE; ; |
8b27f225 | 3450 | break;} |
2e5eb5c5 | 3451 | case 178: |
51149cc8 | 3452 | #line 1161 "./parse.y" |
0b4d333e APB |
3453 | { yyval.node = parse_jdk1_1_error ("inner class declaration"); ; |
3454 | break;} | |
2e5eb5c5 | 3455 | case 179: |
51149cc8 | 3456 | #line 1163 "./parse.y" |
8b27f225 PB |
3457 | { yyval.node = parse_jdk1_1_error ("inner interface declaration"); ; |
3458 | break;} | |
2e5eb5c5 | 3459 | case 181: |
51149cc8 | 3460 | #line 1172 "./parse.y" |
8b27f225 PB |
3461 | { |
3462 | check_abstract_method_header (yyvsp[-1].node); | |
3463 | current_function_decl = NULL_TREE; /* FIXME ? */ | |
3464 | ; | |
3465 | break;} | |
2e5eb5c5 | 3466 | case 182: |
51149cc8 | 3467 | #line 1177 "./parse.y" |
0b4d333e | 3468 | {yyerror ("';' expected"); RECOVER;; |
8b27f225 | 3469 | break;} |
2e5eb5c5 | 3470 | case 183: |
51149cc8 | 3471 | #line 1183 "./parse.y" |
0b4d333e | 3472 | { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ; |
8b27f225 | 3473 | break;} |
2e5eb5c5 | 3474 | case 184: |
51149cc8 | 3475 | #line 1185 "./parse.y" |
0b4d333e | 3476 | { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ; |
ac825856 | 3477 | break;} |
2e5eb5c5 | 3478 | case 185: |
51149cc8 | 3479 | #line 1187 "./parse.y" |
0b4d333e APB |
3480 | { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ; |
3481 | break;} | |
2e5eb5c5 | 3482 | case 186: |
51149cc8 | 3483 | #line 1192 "./parse.y" |
f8976021 APB |
3484 | { |
3485 | yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), | |
3486 | yyvsp[0].node, NULL_TREE); | |
3487 | ; | |
ac825856 | 3488 | break;} |
2e5eb5c5 | 3489 | case 187: |
51149cc8 | 3490 | #line 1197 "./parse.y" |
1179ebc2 APB |
3491 | { |
3492 | yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node); | |
3493 | ; | |
8b27f225 | 3494 | break;} |
2e5eb5c5 | 3495 | case 188: |
51149cc8 | 3496 | #line 1201 "./parse.y" |
0b4d333e | 3497 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 3498 | break;} |
2e5eb5c5 | 3499 | case 189: |
51149cc8 | 3500 | #line 1207 "./parse.y" |
7f10c2e2 APB |
3501 | { |
3502 | /* Store the location of the `}' when doing xrefs */ | |
3503 | if (current_function_decl && flag_emit_xref) | |
3504 | DECL_END_SOURCE_LINE (current_function_decl) = | |
3505 | EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1); | |
3506 | yyval.node = empty_stmt_node; | |
3507 | ; | |
8b27f225 | 3508 | break;} |
2e5eb5c5 | 3509 | case 190: |
51149cc8 | 3510 | #line 1215 "./parse.y" |
0b4d333e | 3511 | { yyval.node = yyvsp[0].node; ; |
22eed1e6 | 3512 | break;} |
2e5eb5c5 | 3513 | case 191: |
51149cc8 | 3514 | #line 1220 "./parse.y" |
0b4d333e APB |
3515 | { enter_block (); ; |
3516 | break;} | |
2e5eb5c5 | 3517 | case 192: |
51149cc8 | 3518 | #line 1225 "./parse.y" |
8b27f225 PB |
3519 | { |
3520 | maybe_absorb_scoping_blocks (); | |
7f10c2e2 APB |
3521 | /* Store the location of the `}' when doing xrefs */ |
3522 | if (current_function_decl && flag_emit_xref) | |
3523 | DECL_END_SOURCE_LINE (current_function_decl) = | |
3524 | EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1); | |
8b27f225 PB |
3525 | yyval.node = exit_block (); |
3526 | ; | |
3527 | break;} | |
2e5eb5c5 | 3528 | case 196: |
51149cc8 | 3529 | #line 1243 "./parse.y" |
12472854 | 3530 | { java_method_add_stmt (current_function_decl, yyvsp[0].node); ; |
8b27f225 | 3531 | break;} |
2e5eb5c5 | 3532 | case 197: |
51149cc8 | 3533 | #line 1245 "./parse.y" |
12472854 | 3534 | { parse_jdk1_1_error ("inner class declaration"); ; |
8b27f225 | 3535 | break;} |
2e5eb5c5 | 3536 | case 199: |
51149cc8 | 3537 | #line 1254 "./parse.y" |
8b27f225 PB |
3538 | { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ; |
3539 | break;} | |
2e5eb5c5 | 3540 | case 200: |
51149cc8 | 3541 | #line 1256 "./parse.y" |
8b27f225 PB |
3542 | { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ; |
3543 | break;} | |
2e5eb5c5 | 3544 | case 206: |
51149cc8 | 3545 | #line 1266 "./parse.y" |
6efa1cc2 APB |
3546 | { yyval.node = exit_block (); ; |
3547 | break;} | |
2e5eb5c5 | 3548 | case 211: |
51149cc8 | 3549 | #line 1275 "./parse.y" |
cd9643f7 | 3550 | { yyval.node = exit_block (); ; |
8b27f225 | 3551 | break;} |
2e5eb5c5 | 3552 | case 223: |
51149cc8 | 3553 | #line 1294 "./parse.y" |
0b4d333e APB |
3554 | { yyval.node = empty_stmt_node; ; |
3555 | break;} | |
2e5eb5c5 | 3556 | case 224: |
51149cc8 | 3557 | #line 1299 "./parse.y" |
8b27f225 PB |
3558 | { |
3559 | yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node), | |
3560 | EXPR_WFL_NODE (yyvsp[-1].node)); | |
3561 | pushlevel (2); | |
3562 | push_labeled_block (yyval.node); | |
3563 | PUSH_LABELED_BLOCK (yyval.node); | |
3564 | ; | |
3565 | break;} | |
2e5eb5c5 | 3566 | case 225: |
51149cc8 | 3567 | #line 1310 "./parse.y" |
e85ac860 | 3568 | { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ; |
8b27f225 | 3569 | break;} |
2e5eb5c5 | 3570 | case 226: |
51149cc8 | 3571 | #line 1312 "./parse.y" |
0b4d333e APB |
3572 | {yyerror ("':' expected"); RECOVER;; |
3573 | break;} | |
2e5eb5c5 | 3574 | case 227: |
51149cc8 | 3575 | #line 1317 "./parse.y" |
e85ac860 | 3576 | { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ; |
8b27f225 | 3577 | break;} |
2e5eb5c5 | 3578 | case 228: |
51149cc8 | 3579 | #line 1324 "./parse.y" |
8b27f225 PB |
3580 | { |
3581 | /* We have a statement. Generate a WFL around it so | |
3582 | we can debug it */ | |
3583 | yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0); | |
3584 | /* We know we have a statement, so set the debug | |
3585 | info to be eventually generate here. */ | |
3586 | yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node); | |
3587 | ; | |
3588 | break;} | |
2e5eb5c5 | 3589 | case 229: |
51149cc8 | 3590 | #line 1333 "./parse.y" |
8b27f225 PB |
3591 | { |
3592 | if (ctxp->prevent_ese != lineno) | |
3593 | yyerror ("Invalid expression statement"); | |
3594 | DRECOVER (expr_stmt); | |
3595 | ; | |
3596 | break;} | |
2e5eb5c5 | 3597 | case 230: |
51149cc8 | 3598 | #line 1339 "./parse.y" |
8b27f225 PB |
3599 | { |
3600 | if (ctxp->prevent_ese != lineno) | |
3601 | yyerror ("Invalid expression statement"); | |
3602 | DRECOVER (expr_stmt); | |
3603 | ; | |
3604 | break;} | |
2e5eb5c5 | 3605 | case 231: |
51149cc8 | 3606 | #line 1345 "./parse.y" |
22eed1e6 APB |
3607 | { |
3608 | if (ctxp->prevent_ese != lineno) | |
3609 | yyerror ("Invalid expression statement"); | |
3610 | DRECOVER (expr_stmt); | |
3611 | ; | |
8b27f225 | 3612 | break;} |
2e5eb5c5 | 3613 | case 232: |
51149cc8 | 3614 | #line 1351 "./parse.y" |
22eed1e6 | 3615 | {yyerror ("')' expected"); RECOVER;; |
8b27f225 | 3616 | break;} |
2e5eb5c5 | 3617 | case 233: |
51149cc8 | 3618 | #line 1353 "./parse.y" |
22eed1e6 | 3619 | { |
8119c720 | 3620 | parse_ctor_invocation_error (); |
22eed1e6 APB |
3621 | RECOVER; |
3622 | ; | |
8b27f225 | 3623 | break;} |
2e5eb5c5 | 3624 | case 234: |
51149cc8 | 3625 | #line 1358 "./parse.y" |
22eed1e6 | 3626 | {yyerror ("')' expected"); RECOVER;; |
8b27f225 | 3627 | break;} |
2e5eb5c5 | 3628 | case 235: |
51149cc8 | 3629 | #line 1360 "./parse.y" |
22eed1e6 | 3630 | { |
8119c720 | 3631 | parse_ctor_invocation_error (); |
22eed1e6 APB |
3632 | RECOVER; |
3633 | ; | |
8b27f225 | 3634 | break;} |
8b27f225 | 3635 | case 236: |
51149cc8 | 3636 | #line 1365 "./parse.y" |
2e5eb5c5 | 3637 | {yyerror ("'(' expected"); RECOVER;; |
8b27f225 PB |
3638 | break;} |
3639 | case 237: | |
51149cc8 | 3640 | #line 1367 "./parse.y" |
2e5eb5c5 | 3641 | {yyerror ("')' expected"); RECOVER;; |
8b27f225 | 3642 | break;} |
0b4d333e | 3643 | case 238: |
51149cc8 | 3644 | #line 1369 "./parse.y" |
2e5eb5c5 APB |
3645 | {yyerror ("')' expected"); RECOVER;; |
3646 | break;} | |
3647 | case 239: | |
51149cc8 | 3648 | #line 1371 "./parse.y" |
2e5eb5c5 APB |
3649 | {yyerror ("';' expected"); RECOVER;; |
3650 | break;} | |
3651 | case 240: | |
51149cc8 | 3652 | #line 1373 "./parse.y" |
0b4d333e | 3653 | {yyerror ("';' expected"); RECOVER;; |
8b27f225 | 3654 | break;} |
2e5eb5c5 | 3655 | case 248: |
51149cc8 | 3656 | #line 1388 "./parse.y" |
2aa11e97 APB |
3657 | { |
3658 | yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node, | |
3659 | yyvsp[0].node, NULL_TREE); | |
3660 | ; | |
8b27f225 | 3661 | break;} |
2e5eb5c5 | 3662 | case 249: |
51149cc8 | 3663 | #line 1393 "./parse.y" |
0b4d333e | 3664 | {yyerror ("'(' expected"); RECOVER;; |
8b27f225 | 3665 | break;} |
2e5eb5c5 | 3666 | case 250: |
51149cc8 | 3667 | #line 1395 "./parse.y" |
0b4d333e | 3668 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 3669 | break;} |
2e5eb5c5 | 3670 | case 251: |
51149cc8 | 3671 | #line 1397 "./parse.y" |
0b4d333e | 3672 | {yyerror ("')' expected"); RECOVER;; |
8b27f225 | 3673 | break;} |
2e5eb5c5 | 3674 | case 252: |
51149cc8 | 3675 | #line 1402 "./parse.y" |
8b27f225 PB |
3676 | { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ; |
3677 | break;} | |
2e5eb5c5 | 3678 | case 253: |
51149cc8 | 3679 | #line 1407 "./parse.y" |
0b4d333e APB |
3680 | { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ; |
3681 | break;} | |
2e5eb5c5 | 3682 | case 254: |
51149cc8 | 3683 | #line 1412 "./parse.y" |
12472854 PB |
3684 | { |
3685 | enter_block (); | |
8b27f225 PB |
3686 | ; |
3687 | break;} | |
2e5eb5c5 | 3688 | case 255: |
51149cc8 | 3689 | #line 1416 "./parse.y" |
8b27f225 | 3690 | { |
12472854 | 3691 | /* Make into "proper list" of COMPOUND_EXPRs. |
f8976021 APB |
3692 | I.e. make the last statment also have its own |
3693 | COMPOUND_EXPR. */ | |
12472854 PB |
3694 | maybe_absorb_scoping_blocks (); |
3695 | TREE_OPERAND (yyvsp[-2].node, 1) = exit_block (); | |
3696 | yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node); | |
8b27f225 PB |
3697 | ; |
3698 | break;} | |
2e5eb5c5 | 3699 | case 256: |
51149cc8 | 3700 | #line 1428 "./parse.y" |
12472854 PB |
3701 | { |
3702 | yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE); | |
3703 | EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location; | |
3704 | ; | |
8b27f225 | 3705 | break;} |
22eed1e6 | 3706 | case 257: |
51149cc8 | 3707 | #line 1433 "./parse.y" |
2e5eb5c5 | 3708 | {yyerror ("'(' expected"); RECOVER;; |
8b27f225 | 3709 | break;} |
f8976021 | 3710 | case 258: |
51149cc8 | 3711 | #line 1435 "./parse.y" |
2e5eb5c5 | 3712 | {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);; |
f8976021 APB |
3713 | break;} |
3714 | case 259: | |
51149cc8 | 3715 | #line 1437 "./parse.y" |
2e5eb5c5 | 3716 | {yyerror ("'{' expected"); RECOVER;; |
f8976021 APB |
3717 | break;} |
3718 | case 260: | |
51149cc8 | 3719 | #line 1445 "./parse.y" |
0b4d333e APB |
3720 | { yyval.node = NULL_TREE; ; |
3721 | break;} | |
3722 | case 261: | |
51149cc8 | 3723 | #line 1447 "./parse.y" |
f8976021 APB |
3724 | { yyval.node = NULL_TREE; ; |
3725 | break;} | |
2e5eb5c5 | 3726 | case 262: |
51149cc8 | 3727 | #line 1449 "./parse.y" |
2e5eb5c5 APB |
3728 | { yyval.node = NULL_TREE; ; |
3729 | break;} | |
3730 | case 263: | |
51149cc8 | 3731 | #line 1451 "./parse.y" |
2e5eb5c5 APB |
3732 | { yyval.node = NULL_TREE; ; |
3733 | break;} | |
3734 | case 269: | |
51149cc8 | 3735 | #line 1470 "./parse.y" |
8b27f225 | 3736 | { |
12472854 PB |
3737 | tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node); |
3738 | EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location; | |
3739 | java_method_add_stmt (current_function_decl, lab); | |
8b27f225 PB |
3740 | ; |
3741 | break;} | |
2e5eb5c5 | 3742 | case 270: |
51149cc8 | 3743 | #line 1476 "./parse.y" |
8b27f225 | 3744 | { |
12472854 PB |
3745 | tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE); |
3746 | EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location; | |
3747 | java_method_add_stmt (current_function_decl, lab); | |
8b27f225 PB |
3748 | ; |
3749 | break;} | |
2e5eb5c5 | 3750 | case 271: |
51149cc8 | 3751 | #line 1482 "./parse.y" |
0b4d333e | 3752 | {yyerror ("Missing or invalid constant expression"); RECOVER;; |
8b27f225 | 3753 | break;} |
2e5eb5c5 | 3754 | case 272: |
51149cc8 | 3755 | #line 1484 "./parse.y" |
22eed1e6 APB |
3756 | {yyerror ("':' expected"); RECOVER;; |
3757 | break;} | |
2e5eb5c5 | 3758 | case 273: |
51149cc8 | 3759 | #line 1486 "./parse.y" |
0b4d333e APB |
3760 | {yyerror ("':' expected"); RECOVER;; |
3761 | break;} | |
2e5eb5c5 | 3762 | case 274: |
51149cc8 | 3763 | #line 1491 "./parse.y" |
8b27f225 PB |
3764 | { |
3765 | tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0); | |
3766 | yyval.node = build_new_loop (body); | |
3767 | ; | |
3768 | break;} | |
2e5eb5c5 | 3769 | case 275: |
51149cc8 | 3770 | #line 1499 "./parse.y" |
e85ac860 | 3771 | { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ; |
8b27f225 | 3772 | break;} |
2e5eb5c5 | 3773 | case 276: |
51149cc8 | 3774 | #line 1501 "./parse.y" |
0b4d333e | 3775 | {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;; |
8b27f225 | 3776 | break;} |
2e5eb5c5 | 3777 | case 277: |
51149cc8 | 3778 | #line 1503 "./parse.y" |
0b4d333e | 3779 | {yyerror ("Missing term and ')' expected"); RECOVER;; |
8b27f225 | 3780 | break;} |
2e5eb5c5 | 3781 | case 278: |
51149cc8 | 3782 | #line 1505 "./parse.y" |
0b4d333e | 3783 | {yyerror ("')' expected"); RECOVER;; |
8b27f225 | 3784 | break;} |
2e5eb5c5 | 3785 | case 279: |
51149cc8 | 3786 | #line 1510 "./parse.y" |
e85ac860 | 3787 | { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ; |
0b4d333e | 3788 | break;} |
2e5eb5c5 | 3789 | case 280: |
51149cc8 | 3790 | #line 1515 "./parse.y" |
8b27f225 PB |
3791 | { |
3792 | tree body = build_loop_body (0, NULL_TREE, 1); | |
3793 | yyval.node = build_new_loop (body); | |
3794 | ; | |
3795 | break;} | |
2e5eb5c5 | 3796 | case 281: |
51149cc8 | 3797 | #line 1524 "./parse.y" |
e85ac860 | 3798 | { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ; |
8b27f225 | 3799 | break;} |
2e5eb5c5 | 3800 | case 282: |
51149cc8 | 3801 | #line 1529 "./parse.y" |
e85ac860 | 3802 | { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ; |
0b4d333e | 3803 | break;} |
2e5eb5c5 | 3804 | case 283: |
51149cc8 | 3805 | #line 1531 "./parse.y" |
8b27f225 | 3806 | { |
e85ac860 | 3807 | yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node); |
8b27f225 PB |
3808 | /* We have not condition, so we get rid of the EXIT_EXPR */ |
3809 | LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = | |
c877974e | 3810 | empty_stmt_node; |
8b27f225 PB |
3811 | ; |
3812 | break;} | |
2e5eb5c5 | 3813 | case 284: |
51149cc8 | 3814 | #line 1538 "./parse.y" |
0b4d333e | 3815 | {yyerror ("Invalid control expression"); RECOVER;; |
8b27f225 | 3816 | break;} |
2e5eb5c5 | 3817 | case 285: |
51149cc8 | 3818 | #line 1540 "./parse.y" |
22eed1e6 | 3819 | {yyerror ("Invalid update expression"); RECOVER;; |
8b27f225 | 3820 | break;} |
2e5eb5c5 | 3821 | case 286: |
51149cc8 | 3822 | #line 1542 "./parse.y" |
0b4d333e | 3823 | {yyerror ("Invalid update expression"); RECOVER;; |
22eed1e6 | 3824 | break;} |
2e5eb5c5 | 3825 | case 287: |
51149cc8 | 3826 | #line 1547 "./parse.y" |
e85ac860 | 3827 | { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);; |
0b4d333e | 3828 | break;} |
2e5eb5c5 | 3829 | case 288: |
51149cc8 | 3830 | #line 1549 "./parse.y" |
8b27f225 | 3831 | { |
e85ac860 | 3832 | yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node); |
8b27f225 PB |
3833 | /* We have not condition, so we get rid of the EXIT_EXPR */ |
3834 | LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = | |
c877974e | 3835 | empty_stmt_node; |
8b27f225 PB |
3836 | ; |
3837 | break;} | |
2e5eb5c5 | 3838 | case 289: |
51149cc8 | 3839 | #line 1559 "./parse.y" |
8b27f225 PB |
3840 | { |
3841 | /* This scope defined for local variable that may be | |
3842 | defined within the scope of the for loop */ | |
3843 | enter_block (); | |
3844 | ; | |
3845 | break;} | |
2e5eb5c5 | 3846 | case 290: |
51149cc8 | 3847 | #line 1565 "./parse.y" |
0b4d333e | 3848 | {yyerror ("'(' expected"); DRECOVER(for_1);; |
8b27f225 | 3849 | break;} |
2e5eb5c5 | 3850 | case 291: |
51149cc8 | 3851 | #line 1567 "./parse.y" |
0b4d333e APB |
3852 | {yyerror ("Invalid init statement"); RECOVER;; |
3853 | break;} | |
2e5eb5c5 | 3854 | case 292: |
51149cc8 | 3855 | #line 1572 "./parse.y" |
8b27f225 PB |
3856 | { |
3857 | /* We now declare the loop body. The loop is | |
3858 | declared as a for loop. */ | |
3859 | tree body = build_loop_body (0, NULL_TREE, 0); | |
3860 | yyval.node = build_new_loop (body); | |
3861 | IS_FOR_LOOP_P (yyval.node) = 1; | |
3862 | /* The loop is added to the current block the for | |
3863 | statement is defined within */ | |
3864 | java_method_add_stmt (current_function_decl, yyval.node); | |
3865 | ; | |
3866 | break;} | |
2e5eb5c5 | 3867 | case 293: |
51149cc8 | 3868 | #line 1584 "./parse.y" |
c877974e | 3869 | { yyval.node = empty_stmt_node; ; |
8b27f225 | 3870 | break;} |
2e5eb5c5 | 3871 | case 294: |
51149cc8 | 3872 | #line 1586 "./parse.y" |
8b27f225 PB |
3873 | { |
3874 | /* Init statement recorded within the previously | |
3875 | defined block scope */ | |
3876 | yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node); | |
3877 | ; | |
3878 | break;} | |
2e5eb5c5 | 3879 | case 295: |
51149cc8 | 3880 | #line 1592 "./parse.y" |
8b27f225 PB |
3881 | { |
3882 | /* Local variable are recorded within the previously | |
3883 | defined block scope */ | |
3884 | yyval.node = NULL_TREE; | |
3885 | ; | |
3886 | break;} | |
1179ebc2 | 3887 | case 296: |
51149cc8 | 3888 | #line 1598 "./parse.y" |
2e5eb5c5 | 3889 | {yyerror ("';' expected"); DRECOVER(for_init_1);; |
8b27f225 | 3890 | break;} |
1179ebc2 | 3891 | case 297: |
51149cc8 | 3892 | #line 1602 "./parse.y" |
2e5eb5c5 | 3893 | {yyval.node = empty_stmt_node;; |
8b27f225 | 3894 | break;} |
1179ebc2 | 3895 | case 298: |
51149cc8 | 3896 | #line 1604 "./parse.y" |
2e5eb5c5 | 3897 | { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ; |
8b27f225 | 3898 | break;} |
1179ebc2 | 3899 | case 299: |
51149cc8 | 3900 | #line 1609 "./parse.y" |
2e5eb5c5 | 3901 | { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ; |
8b27f225 | 3902 | break;} |
1179ebc2 | 3903 | case 300: |
51149cc8 | 3904 | #line 1611 "./parse.y" |
2e5eb5c5 | 3905 | { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ; |
8b27f225 | 3906 | break;} |
1179ebc2 | 3907 | case 301: |
51149cc8 | 3908 | #line 1613 "./parse.y" |
2e5eb5c5 | 3909 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 3910 | break;} |
1179ebc2 | 3911 | case 302: |
51149cc8 | 3912 | #line 1618 "./parse.y" |
2e5eb5c5 | 3913 | { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ; |
8b27f225 | 3914 | break;} |
1179ebc2 | 3915 | case 303: |
51149cc8 | 3916 | #line 1620 "./parse.y" |
2e5eb5c5 | 3917 | { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ; |
8b27f225 | 3918 | break;} |
1179ebc2 | 3919 | case 304: |
51149cc8 | 3920 | #line 1622 "./parse.y" |
2e5eb5c5 | 3921 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 3922 | break;} |
1179ebc2 | 3923 | case 305: |
51149cc8 | 3924 | #line 1624 "./parse.y" |
2e5eb5c5 | 3925 | {yyerror ("';' expected"); RECOVER;; |
8b27f225 | 3926 | break;} |
1179ebc2 | 3927 | case 306: |
51149cc8 | 3928 | #line 1629 "./parse.y" |
2e5eb5c5 | 3929 | { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ; |
8b27f225 | 3930 | break;} |
1179ebc2 | 3931 | case 307: |
51149cc8 | 3932 | #line 1631 "./parse.y" |
2e5eb5c5 | 3933 | { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ; |
8b27f225 | 3934 | break;} |
1179ebc2 | 3935 | case 308: |
51149cc8 | 3936 | #line 1633 "./parse.y" |
2e5eb5c5 | 3937 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 3938 | break;} |
1179ebc2 | 3939 | case 309: |
51149cc8 | 3940 | #line 1635 "./parse.y" |
2e5eb5c5 | 3941 | {yyerror ("';' expected"); RECOVER;; |
8b27f225 | 3942 | break;} |
1179ebc2 | 3943 | case 310: |
51149cc8 | 3944 | #line 1640 "./parse.y" |
2e5eb5c5 | 3945 | { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ; |
8b27f225 | 3946 | break;} |
1179ebc2 | 3947 | case 311: |
51149cc8 | 3948 | #line 1642 "./parse.y" |
2e5eb5c5 | 3949 | { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ; |
0b4d333e APB |
3950 | break;} |
3951 | case 312: | |
51149cc8 | 3952 | #line 1644 "./parse.y" |
2e5eb5c5 APB |
3953 | {yyerror ("Missing term"); RECOVER;; |
3954 | break;} | |
3955 | case 313: | |
51149cc8 | 3956 | #line 1646 "./parse.y" |
2e5eb5c5 APB |
3957 | {yyerror ("';' expected"); RECOVER;; |
3958 | break;} | |
3959 | case 314: | |
51149cc8 | 3960 | #line 1651 "./parse.y" |
8b27f225 PB |
3961 | { |
3962 | yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node); | |
3963 | EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location; | |
3964 | ; | |
3965 | break;} | |
2e5eb5c5 | 3966 | case 315: |
51149cc8 | 3967 | #line 1656 "./parse.y" |
0b4d333e | 3968 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 3969 | break;} |
2e5eb5c5 | 3970 | case 316: |
51149cc8 | 3971 | #line 1658 "./parse.y" |
0b4d333e APB |
3972 | {yyerror ("';' expected"); RECOVER;; |
3973 | break;} | |
2e5eb5c5 | 3974 | case 317: |
51149cc8 | 3975 | #line 1663 "./parse.y" |
8b27f225 PB |
3976 | { |
3977 | yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node); | |
3978 | EXPR_WFL_LINECOL (yyval.node) = | |
3979 | EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK)); | |
3980 | ; | |
3981 | break;} | |
2e5eb5c5 | 3982 | case 318: |
51149cc8 | 3983 | #line 1669 "./parse.y" |
0b4d333e | 3984 | {yyerror ("'{' expected"); RECOVER;; |
8b27f225 | 3985 | break;} |
2e5eb5c5 | 3986 | case 319: |
51149cc8 | 3987 | #line 1671 "./parse.y" |
0b4d333e | 3988 | {yyerror ("'(' expected"); RECOVER;; |
8b27f225 | 3989 | break;} |
2e5eb5c5 | 3990 | case 320: |
51149cc8 | 3991 | #line 1673 "./parse.y" |
22eed1e6 APB |
3992 | {yyerror ("Missing term"); RECOVER;; |
3993 | break;} | |
2e5eb5c5 | 3994 | case 321: |
51149cc8 | 3995 | #line 1675 "./parse.y" |
0b4d333e APB |
3996 | {yyerror ("Missing term"); RECOVER;; |
3997 | break;} | |
2e5eb5c5 | 3998 | case 322: |
51149cc8 | 3999 | #line 1680 "./parse.y" |
8b27f225 | 4000 | { |
781b0558 KG |
4001 | check_modifiers ( |
4002 | "Illegal modifier `%s'. Only `synchronized' was expected here", | |
efa0a23f APB |
4003 | yyvsp[0].value, ACC_SYNCHRONIZED); |
4004 | if (yyvsp[0].value != ACC_SYNCHRONIZED) | |
4005 | MODIFIER_WFL (SYNCHRONIZED_TK) = | |
4006 | build_wfl_node (NULL_TREE); | |
8b27f225 PB |
4007 | ; |
4008 | break;} | |
2e5eb5c5 | 4009 | case 323: |
51149cc8 | 4010 | #line 1692 "./parse.y" |
a7d8d81f | 4011 | { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ; |
8b27f225 | 4012 | break;} |
2e5eb5c5 | 4013 | case 324: |
51149cc8 | 4014 | #line 1694 "./parse.y" |
a7d8d81f | 4015 | { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ; |
8b27f225 | 4016 | break;} |
2e5eb5c5 | 4017 | case 325: |
51149cc8 | 4018 | #line 1696 "./parse.y" |
2aa11e97 APB |
4019 | { yyval.node = build_try_finally_statement |
4020 | (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location, | |
4021 | yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node); | |
4022 | ; | |
8b27f225 | 4023 | break;} |
2e5eb5c5 | 4024 | case 326: |
51149cc8 | 4025 | #line 1701 "./parse.y" |
8b27f225 PB |
4026 | {yyerror ("'{' expected"); DRECOVER (try_statement);; |
4027 | break;} | |
2e5eb5c5 | 4028 | case 328: |
51149cc8 | 4029 | #line 1707 "./parse.y" |
8b27f225 PB |
4030 | { |
4031 | TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node; | |
4032 | yyval.node = yyvsp[0].node; | |
4033 | ; | |
4034 | break;} | |
2e5eb5c5 | 4035 | case 329: |
51149cc8 | 4036 | #line 1715 "./parse.y" |
8b27f225 PB |
4037 | { |
4038 | java_method_add_stmt (current_function_decl, yyvsp[0].node); | |
4039 | exit_block (); | |
4040 | yyval.node = yyvsp[-1].node; | |
4041 | ; | |
4042 | break;} | |
2e5eb5c5 | 4043 | case 330: |
51149cc8 | 4044 | #line 1723 "./parse.y" |
8b27f225 PB |
4045 | { |
4046 | /* We add a block to define a scope for | |
4047 | formal_parameter (CCBP). The formal parameter is | |
4048 | declared initialized by the appropriate function | |
4049 | call */ | |
4050 | tree ccpb = enter_block (); | |
c877974e APB |
4051 | tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location, |
4052 | TREE_PURPOSE (yyvsp[-1].node), | |
4053 | soft_exceptioninfo_call_node); | |
8b27f225 PB |
4054 | declare_local_variables (0, TREE_VALUE (yyvsp[-1].node), |
4055 | build_tree_list (TREE_PURPOSE (yyvsp[-1].node), | |
4056 | init)); | |
4057 | yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb); | |
4058 | EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location; | |
4059 | ; | |
4060 | break;} | |
2e5eb5c5 | 4061 | case 331: |
51149cc8 | 4062 | #line 1739 "./parse.y" |
b5b8a0e7 | 4063 | {yyerror ("'(' expected"); RECOVER; yyval.node = NULL_TREE;; |
8b27f225 | 4064 | break;} |
2e5eb5c5 | 4065 | case 332: |
51149cc8 | 4066 | #line 1741 "./parse.y" |
b5b8a0e7 APB |
4067 | { |
4068 | yyerror ("Missing term or ')' expected"); | |
4069 | RECOVER; yyval.node = NULL_TREE; | |
4070 | ; | |
8b27f225 | 4071 | break;} |
2e5eb5c5 | 4072 | case 333: |
51149cc8 | 4073 | #line 1746 "./parse.y" |
b5b8a0e7 | 4074 | {yyerror ("Missing term"); RECOVER; yyval.node = NULL_TREE;; |
0b4d333e | 4075 | break;} |
2e5eb5c5 | 4076 | case 334: |
51149cc8 | 4077 | #line 1751 "./parse.y" |
a7d8d81f | 4078 | { yyval.node = yyvsp[0].node; ; |
8b27f225 | 4079 | break;} |
2e5eb5c5 | 4080 | case 335: |
51149cc8 | 4081 | #line 1753 "./parse.y" |
8b27f225 PB |
4082 | {yyerror ("'{' expected"); RECOVER; ; |
4083 | break;} | |
2e5eb5c5 | 4084 | case 339: |
51149cc8 | 4085 | #line 1765 "./parse.y" |
8b27f225 PB |
4086 | { yyval.node = build_this (yyvsp[0].operator.location); ; |
4087 | break;} | |
2e5eb5c5 | 4088 | case 340: |
51149cc8 | 4089 | #line 1767 "./parse.y" |
8b27f225 PB |
4090 | {yyval.node = yyvsp[-1].node;; |
4091 | break;} | |
1179ebc2 | 4092 | case 345: |
51149cc8 | 4093 | #line 1776 "./parse.y" |
2e5eb5c5 | 4094 | { yyval.node = parse_jdk1_1_error ("named class literals"); ; |
8b27f225 | 4095 | break;} |
1179ebc2 | 4096 | case 346: |
51149cc8 | 4097 | #line 1778 "./parse.y" |
2e5eb5c5 | 4098 | { yyval.node = build_class_ref (yyvsp[-2].node); ; |
8b27f225 | 4099 | break;} |
1179ebc2 | 4100 | case 347: |
51149cc8 | 4101 | #line 1780 "./parse.y" |
2e5eb5c5 | 4102 | { yyval.node = build_class_ref (void_type_node); ; |
8b27f225 | 4103 | break;} |
1179ebc2 | 4104 | case 348: |
51149cc8 | 4105 | #line 1785 "./parse.y" |
2e5eb5c5 | 4106 | { yyval.node = parse_jdk1_1_error ("class literals"); ; |
8b27f225 | 4107 | break;} |
1179ebc2 | 4108 | case 349: |
51149cc8 | 4109 | #line 1787 "./parse.y" |
2e5eb5c5 | 4110 | {yyerror ("')' expected"); RECOVER;; |
8b27f225 | 4111 | break;} |
1179ebc2 | 4112 | case 350: |
51149cc8 | 4113 | #line 1789 "./parse.y" |
2e5eb5c5 | 4114 | {yyerror ("'class' or 'this' expected" ); RECOVER;; |
8b27f225 | 4115 | break;} |
1179ebc2 | 4116 | case 351: |
51149cc8 | 4117 | #line 1791 "./parse.y" |
2e5eb5c5 | 4118 | {yyerror ("'class' expected" ); RECOVER;; |
8b27f225 | 4119 | break;} |
1179ebc2 | 4120 | case 352: |
51149cc8 | 4121 | #line 1793 "./parse.y" |
2e5eb5c5 | 4122 | {yyerror ("'class' expected" ); RECOVER;; |
8b27f225 | 4123 | break;} |
1179ebc2 | 4124 | case 353: |
51149cc8 | 4125 | #line 1798 "./parse.y" |
2e5eb5c5 | 4126 | { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ; |
8b27f225 | 4127 | break;} |
0b4d333e | 4128 | case 354: |
51149cc8 | 4129 | #line 1800 "./parse.y" |
2e5eb5c5 | 4130 | { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ; |
8b27f225 | 4131 | break;} |
2e5eb5c5 | 4132 | case 355: |
51149cc8 | 4133 | #line 1805 "./parse.y" |
2e5eb5c5 | 4134 | { yyval.node = parse_jdk1_1_error ("inner class instance creation"); ; |
8b27f225 | 4135 | break;} |
2e5eb5c5 | 4136 | case 356: |
51149cc8 | 4137 | #line 1807 "./parse.y" |
2e5eb5c5 | 4138 | { yyval.node = parse_jdk1_1_error ("inner class instance creation"); ; |
8b27f225 | 4139 | break;} |
1179ebc2 | 4140 | case 361: |
51149cc8 | 4141 | #line 1816 "./parse.y" |
2e5eb5c5 | 4142 | {yyerror ("'(' expected"); DRECOVER(new_1);; |
8b27f225 | 4143 | break;} |
1179ebc2 | 4144 | case 362: |
51149cc8 | 4145 | #line 1818 "./parse.y" |
2e5eb5c5 | 4146 | {yyerror ("'(' expected"); RECOVER;; |
22eed1e6 | 4147 | break;} |
1179ebc2 | 4148 | case 363: |
51149cc8 | 4149 | #line 1820 "./parse.y" |
2e5eb5c5 | 4150 | {yyerror ("')' or term expected"); RECOVER;; |
0b4d333e APB |
4151 | break;} |
4152 | case 364: | |
51149cc8 | 4153 | #line 1822 "./parse.y" |
2e5eb5c5 APB |
4154 | {yyerror ("')' expected"); RECOVER;; |
4155 | break;} | |
4156 | case 365: | |
51149cc8 | 4157 | #line 1824 "./parse.y" |
2e5eb5c5 APB |
4158 | {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;; |
4159 | break;} | |
4160 | case 366: | |
51149cc8 | 4161 | #line 1826 "./parse.y" |
8b27f225 PB |
4162 | {yyerror ("'(' expected"); RECOVER;; |
4163 | break;} | |
2e5eb5c5 | 4164 | case 369: |
51149cc8 | 4165 | #line 1836 "./parse.y" |
8b27f225 PB |
4166 | { |
4167 | yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE); | |
4168 | ctxp->formal_parameter_number = 1; | |
4169 | ; | |
4170 | break;} | |
2e5eb5c5 | 4171 | case 370: |
51149cc8 | 4172 | #line 1841 "./parse.y" |
8b27f225 PB |
4173 | { |
4174 | ctxp->formal_parameter_number += 1; | |
4175 | yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node); | |
4176 | ; | |
4177 | break;} | |
8b27f225 | 4178 | case 371: |
51149cc8 | 4179 | #line 1846 "./parse.y" |
2e5eb5c5 | 4180 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 PB |
4181 | break;} |
4182 | case 372: | |
51149cc8 | 4183 | #line 1851 "./parse.y" |
2e5eb5c5 | 4184 | { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ; |
8b27f225 PB |
4185 | break;} |
4186 | case 373: | |
51149cc8 | 4187 | #line 1853 "./parse.y" |
2e5eb5c5 | 4188 | { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ; |
8b27f225 PB |
4189 | break;} |
4190 | case 374: | |
51149cc8 | 4191 | #line 1855 "./parse.y" |
2e5eb5c5 | 4192 | { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));; |
8b27f225 PB |
4193 | break;} |
4194 | case 375: | |
51149cc8 | 4195 | #line 1857 "./parse.y" |
2e5eb5c5 | 4196 | { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));; |
8b27f225 | 4197 | break;} |
1179ebc2 | 4198 | case 376: |
51149cc8 | 4199 | #line 1861 "./parse.y" |
2e5eb5c5 | 4200 | { yyval.node = parse_jdk1_1_error ("anonymous array"); ; |
8b27f225 | 4201 | break;} |
1179ebc2 | 4202 | case 377: |
51149cc8 | 4203 | #line 1863 "./parse.y" |
2e5eb5c5 | 4204 | { yyval.node = parse_jdk1_1_error ("anonymous array"); ; |
8b27f225 | 4205 | break;} |
1179ebc2 | 4206 | case 378: |
51149cc8 | 4207 | #line 1865 "./parse.y" |
2e5eb5c5 | 4208 | {yyerror ("'[' expected"); DRECOVER ("]");; |
22eed1e6 | 4209 | break;} |
1179ebc2 | 4210 | case 379: |
51149cc8 | 4211 | #line 1867 "./parse.y" |
2e5eb5c5 | 4212 | {yyerror ("']' expected"); RECOVER;; |
0b4d333e APB |
4213 | break;} |
4214 | case 380: | |
51149cc8 | 4215 | #line 1872 "./parse.y" |
2e5eb5c5 APB |
4216 | { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ; |
4217 | break;} | |
4218 | case 381: | |
51149cc8 | 4219 | #line 1874 "./parse.y" |
2e5eb5c5 APB |
4220 | { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ; |
4221 | break;} | |
4222 | case 382: | |
51149cc8 | 4223 | #line 1879 "./parse.y" |
8b27f225 PB |
4224 | { |
4225 | EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location; | |
4226 | yyval.node = yyvsp[-1].node; | |
4227 | ; | |
4228 | break;} | |
2e5eb5c5 | 4229 | case 383: |
51149cc8 | 4230 | #line 1884 "./parse.y" |
8b27f225 PB |
4231 | {yyerror ("']' expected"); RECOVER;; |
4232 | break;} | |
2e5eb5c5 | 4233 | case 384: |
51149cc8 | 4234 | #line 1886 "./parse.y" |
8b27f225 PB |
4235 | { |
4236 | yyerror ("Missing term"); | |
4237 | yyerror ("']' expected"); | |
4238 | RECOVER; | |
4239 | ; | |
4240 | break;} | |
2e5eb5c5 | 4241 | case 385: |
51149cc8 | 4242 | #line 1895 "./parse.y" |
ba179f9f APB |
4243 | { |
4244 | int allocate = 0; | |
4245 | /* If not initialized, allocate memory for the osb | |
4246 | numbers stack */ | |
4247 | if (!ctxp->osb_limit) | |
4248 | { | |
4249 | allocate = ctxp->osb_limit = 32; | |
4250 | ctxp->osb_depth = -1; | |
4251 | } | |
4252 | /* If capacity overflown, reallocate a bigger chuck */ | |
4253 | else if (ctxp->osb_depth+1 == ctxp->osb_limit) | |
4254 | allocate = ctxp->osb_limit << 1; | |
4255 | ||
4256 | if (allocate) | |
4257 | { | |
4258 | allocate *= sizeof (int); | |
4259 | if (ctxp->osb_number) | |
4260 | ctxp->osb_number = (int *)xrealloc (ctxp->osb_number, | |
4261 | allocate); | |
4262 | else | |
4263 | ctxp->osb_number = (int *)xmalloc (allocate); | |
4264 | } | |
4265 | ctxp->osb_depth++; | |
4266 | CURRENT_OSB (ctxp) = 1; | |
4267 | ; | |
8b27f225 | 4268 | break;} |
2e5eb5c5 | 4269 | case 386: |
51149cc8 | 4270 | #line 1921 "./parse.y" |
0b4d333e | 4271 | { CURRENT_OSB (ctxp)++; ; |
8b27f225 | 4272 | break;} |
2e5eb5c5 | 4273 | case 387: |
51149cc8 | 4274 | #line 1923 "./parse.y" |
0b4d333e | 4275 | { yyerror ("']' expected"); RECOVER;; |
8b27f225 | 4276 | break;} |
2e5eb5c5 | 4277 | case 388: |
51149cc8 | 4278 | #line 1928 "./parse.y" |
0b4d333e APB |
4279 | { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ; |
4280 | break;} | |
2e5eb5c5 | 4281 | case 389: |
51149cc8 | 4282 | #line 1932 "./parse.y" |
8b27f225 PB |
4283 | { |
4284 | tree super_wfl = | |
9ee9b555 | 4285 | build_wfl_node (super_identifier_node); |
8b27f225 | 4286 | EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location; |
22eed1e6 APB |
4287 | yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location); |
4288 | ; | |
8b27f225 | 4289 | break;} |
2e5eb5c5 | 4290 | case 390: |
51149cc8 | 4291 | #line 1939 "./parse.y" |
0b4d333e | 4292 | {yyerror ("Field expected"); DRECOVER (super_field_acces);; |
8b27f225 | 4293 | break;} |
2e5eb5c5 | 4294 | case 391: |
51149cc8 | 4295 | #line 1944 "./parse.y" |
0b4d333e | 4296 | { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ; |
8b27f225 | 4297 | break;} |
2e5eb5c5 | 4298 | case 392: |
51149cc8 | 4299 | #line 1946 "./parse.y" |
0b4d333e APB |
4300 | { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ; |
4301 | break;} | |
2e5eb5c5 | 4302 | case 393: |
51149cc8 | 4303 | #line 1948 "./parse.y" |
8b27f225 | 4304 | { |
22eed1e6 APB |
4305 | if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR) |
4306 | yyval.node = build_this_super_qualified_invocation | |
4307 | (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location); | |
4308 | else | |
4309 | { | |
4310 | tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE); | |
4311 | yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location); | |
4312 | } | |
8b27f225 PB |
4313 | ; |
4314 | break;} | |
2e5eb5c5 | 4315 | case 394: |
51149cc8 | 4316 | #line 1959 "./parse.y" |
22eed1e6 APB |
4317 | { |
4318 | if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR) | |
4319 | yyval.node = build_this_super_qualified_invocation | |
4320 | (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location); | |
4321 | else | |
4322 | { | |
4323 | tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); | |
4324 | yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location); | |
4325 | } | |
8b27f225 PB |
4326 | ; |
4327 | break;} | |
2e5eb5c5 | 4328 | case 395: |
51149cc8 | 4329 | #line 1970 "./parse.y" |
22eed1e6 APB |
4330 | { |
4331 | yyval.node = build_this_super_qualified_invocation | |
4332 | (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location); | |
8b27f225 PB |
4333 | ; |
4334 | break;} | |
2e5eb5c5 | 4335 | case 396: |
51149cc8 | 4336 | #line 1975 "./parse.y" |
22eed1e6 APB |
4337 | { |
4338 | yyval.node = build_this_super_qualified_invocation | |
4339 | (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location); | |
4340 | ; | |
8b27f225 | 4341 | break;} |
2e5eb5c5 | 4342 | case 397: |
51149cc8 | 4343 | #line 1984 "./parse.y" |
8b27f225 PB |
4344 | { yyerror ("'(' expected"); DRECOVER (method_invocation); ; |
4345 | break;} | |
2e5eb5c5 | 4346 | case 398: |
51149cc8 | 4347 | #line 1986 "./parse.y" |
0b4d333e | 4348 | { yyerror ("'(' expected"); DRECOVER (method_invocation); ; |
8b27f225 | 4349 | break;} |
2e5eb5c5 | 4350 | case 399: |
51149cc8 | 4351 | #line 1991 "./parse.y" |
8b27f225 PB |
4352 | { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ; |
4353 | break;} | |
2e5eb5c5 | 4354 | case 400: |
51149cc8 | 4355 | #line 1993 "./parse.y" |
0b4d333e | 4356 | { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ; |
8b27f225 | 4357 | break;} |
2e5eb5c5 | 4358 | case 401: |
51149cc8 | 4359 | #line 1995 "./parse.y" |
8b27f225 | 4360 | { |
0b4d333e | 4361 | yyerror ("Missing term and ']' expected"); |
8b27f225 PB |
4362 | DRECOVER(array_access); |
4363 | ; | |
4364 | break;} | |
2e5eb5c5 | 4365 | case 402: |
51149cc8 | 4366 | #line 2000 "./parse.y" |
8b27f225 | 4367 | { |
0b4d333e | 4368 | yyerror ("']' expected"); |
8b27f225 PB |
4369 | DRECOVER(array_access); |
4370 | ; | |
4371 | break;} | |
2e5eb5c5 | 4372 | case 403: |
51149cc8 | 4373 | #line 2005 "./parse.y" |
8b27f225 | 4374 | { |
0b4d333e | 4375 | yyerror ("Missing term and ']' expected"); |
8b27f225 PB |
4376 | DRECOVER(array_access); |
4377 | ; | |
4378 | break;} | |
2e5eb5c5 | 4379 | case 404: |
51149cc8 | 4380 | #line 2010 "./parse.y" |
0b4d333e APB |
4381 | { |
4382 | yyerror ("']' expected"); | |
4383 | DRECOVER(array_access); | |
4384 | ; | |
8b27f225 | 4385 | break;} |
2e5eb5c5 | 4386 | case 409: |
51149cc8 | 4387 | #line 2025 "./parse.y" |
22eed1e6 | 4388 | { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ; |
8b27f225 | 4389 | break;} |
2e5eb5c5 | 4390 | case 410: |
51149cc8 | 4391 | #line 2030 "./parse.y" |
0b4d333e | 4392 | { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ; |
8b27f225 | 4393 | break;} |
2e5eb5c5 | 4394 | case 413: |
51149cc8 | 4395 | #line 2037 "./parse.y" |
0b4d333e | 4396 | {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ; |
8b27f225 | 4397 | break;} |
1179ebc2 | 4398 | case 414: |
51149cc8 | 4399 | #line 2039 "./parse.y" |
2e5eb5c5 | 4400 | {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ; |
8b27f225 | 4401 | break;} |
1179ebc2 | 4402 | case 416: |
51149cc8 | 4403 | #line 2042 "./parse.y" |
2e5eb5c5 | 4404 | {yyerror ("Missing term"); RECOVER; |
8b27f225 | 4405 | break;} |
1179ebc2 | 4406 | case 417: |
51149cc8 | 4407 | #line 2044 "./parse.y" |
0b4d333e | 4408 | {yyerror ("Missing term"); RECOVER; |
8b27f225 | 4409 | break;} |
1179ebc2 | 4410 | case 418: |
51149cc8 | 4411 | #line 2049 "./parse.y" |
0b4d333e | 4412 | {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ; |
8b27f225 | 4413 | break;} |
0b4d333e | 4414 | case 419: |
51149cc8 | 4415 | #line 2051 "./parse.y" |
0b4d333e | 4416 | {yyerror ("Missing term"); RECOVER; |
8b27f225 | 4417 | break;} |
2e5eb5c5 | 4418 | case 420: |
51149cc8 | 4419 | #line 2056 "./parse.y" |
2e5eb5c5 APB |
4420 | {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ; |
4421 | break;} | |
1179ebc2 | 4422 | case 421: |
51149cc8 | 4423 | #line 2058 "./parse.y" |
2e5eb5c5 | 4424 | {yyerror ("Missing term"); RECOVER; |
8b27f225 | 4425 | break;} |
2e5eb5c5 | 4426 | case 423: |
51149cc8 | 4427 | #line 2064 "./parse.y" |
0b4d333e | 4428 | {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ; |
8b27f225 | 4429 | break;} |
1179ebc2 | 4430 | case 424: |
51149cc8 | 4431 | #line 2066 "./parse.y" |
2e5eb5c5 APB |
4432 | {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ; |
4433 | break;} | |
4434 | case 426: | |
51149cc8 | 4435 | #line 2069 "./parse.y" |
22eed1e6 APB |
4436 | {yyerror ("Missing term"); RECOVER; |
4437 | break;} | |
2e5eb5c5 | 4438 | case 427: |
51149cc8 | 4439 | #line 2071 "./parse.y" |
0b4d333e APB |
4440 | {yyerror ("Missing term"); RECOVER; |
4441 | break;} | |
2e5eb5c5 | 4442 | case 428: |
51149cc8 | 4443 | #line 2076 "./parse.y" |
8b27f225 PB |
4444 | { |
4445 | tree type = yyvsp[-3].node; | |
ba179f9f | 4446 | while (CURRENT_OSB (ctxp)--) |
8b27f225 | 4447 | type = build_java_array_type (type, -1); |
ba179f9f | 4448 | ctxp->osb_depth--; |
8b27f225 PB |
4449 | yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node); |
4450 | ; | |
4451 | break;} | |
2e5eb5c5 | 4452 | case 429: |
51149cc8 | 4453 | #line 2084 "./parse.y" |
22eed1e6 APB |
4454 | { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ; |
4455 | break;} | |
2e5eb5c5 | 4456 | case 430: |
51149cc8 | 4457 | #line 2086 "./parse.y" |
0b4d333e APB |
4458 | { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ; |
4459 | break;} | |
2e5eb5c5 | 4460 | case 431: |
51149cc8 | 4461 | #line 2088 "./parse.y" |
8b27f225 | 4462 | { |
49f48c71 | 4463 | const char *ptr; |
ba179f9f | 4464 | while (CURRENT_OSB (ctxp)--) |
8b27f225 | 4465 | obstack_1grow (&temporary_obstack, '['); |
ba179f9f | 4466 | ctxp->osb_depth--; |
8b27f225 PB |
4467 | obstack_grow0 (&temporary_obstack, |
4468 | IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)), | |
4469 | IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node))); | |
4470 | ptr = obstack_finish (&temporary_obstack); | |
4471 | EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr); | |
4472 | yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node); | |
4473 | ; | |
4474 | break;} | |
2e5eb5c5 | 4475 | case 432: |
51149cc8 | 4476 | #line 2101 "./parse.y" |
8b27f225 PB |
4477 | {yyerror ("']' expected, invalid type expression");; |
4478 | break;} | |
2e5eb5c5 | 4479 | case 433: |
51149cc8 | 4480 | #line 2103 "./parse.y" |
8b27f225 PB |
4481 | { |
4482 | if (ctxp->prevent_ese != lineno) | |
4483 | yyerror ("Invalid type expression"); RECOVER; | |
4484 | RECOVER; | |
4485 | ; | |
4486 | break;} | |
2e5eb5c5 | 4487 | case 434: |
51149cc8 | 4488 | #line 2109 "./parse.y" |
8b27f225 PB |
4489 | {yyerror ("Missing term"); RECOVER;; |
4490 | break;} | |
2e5eb5c5 | 4491 | case 435: |
51149cc8 | 4492 | #line 2111 "./parse.y" |
22eed1e6 APB |
4493 | {yyerror ("Missing term"); RECOVER;; |
4494 | break;} | |
2e5eb5c5 | 4495 | case 436: |
51149cc8 | 4496 | #line 2113 "./parse.y" |
0b4d333e | 4497 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 4498 | break;} |
2e5eb5c5 | 4499 | case 438: |
51149cc8 | 4500 | #line 2119 "./parse.y" |
0b4d333e APB |
4501 | { |
4502 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), | |
4503 | yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); | |
8b27f225 PB |
4504 | ; |
4505 | break;} | |
2e5eb5c5 | 4506 | case 439: |
51149cc8 | 4507 | #line 2124 "./parse.y" |
8b27f225 PB |
4508 | { |
4509 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4510 | yyvsp[-2].node, yyvsp[0].node); | |
4511 | ; | |
4512 | break;} | |
2e5eb5c5 | 4513 | case 440: |
51149cc8 | 4514 | #line 2129 "./parse.y" |
0b4d333e APB |
4515 | { |
4516 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4517 | yyvsp[-2].node, yyvsp[0].node); | |
4518 | ; | |
8b27f225 | 4519 | break;} |
2e5eb5c5 | 4520 | case 441: |
51149cc8 | 4521 | #line 2134 "./parse.y" |
22eed1e6 APB |
4522 | {yyerror ("Missing term"); RECOVER;; |
4523 | break;} | |
2e5eb5c5 | 4524 | case 442: |
51149cc8 | 4525 | #line 2136 "./parse.y" |
8b27f225 PB |
4526 | {yyerror ("Missing term"); RECOVER;; |
4527 | break;} | |
2e5eb5c5 | 4528 | case 443: |
51149cc8 | 4529 | #line 2138 "./parse.y" |
0b4d333e | 4530 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 4531 | break;} |
2e5eb5c5 | 4532 | case 445: |
51149cc8 | 4533 | #line 2144 "./parse.y" |
8b27f225 PB |
4534 | { |
4535 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4536 | yyvsp[-2].node, yyvsp[0].node); | |
4537 | ; | |
4538 | break;} | |
2e5eb5c5 | 4539 | case 446: |
51149cc8 | 4540 | #line 2149 "./parse.y" |
8b27f225 PB |
4541 | { |
4542 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4543 | yyvsp[-2].node, yyvsp[0].node); | |
4544 | ; | |
4545 | break;} | |
2e5eb5c5 | 4546 | case 447: |
51149cc8 | 4547 | #line 2154 "./parse.y" |
0b4d333e APB |
4548 | {yyerror ("Missing term"); RECOVER;; |
4549 | break;} | |
2e5eb5c5 | 4550 | case 448: |
51149cc8 | 4551 | #line 2156 "./parse.y" |
0b4d333e APB |
4552 | {yyerror ("Missing term"); RECOVER;; |
4553 | break;} | |
2e5eb5c5 | 4554 | case 450: |
51149cc8 | 4555 | #line 2162 "./parse.y" |
8b27f225 PB |
4556 | { |
4557 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4558 | yyvsp[-2].node, yyvsp[0].node); | |
4559 | ; | |
4560 | break;} | |
2e5eb5c5 | 4561 | case 451: |
51149cc8 | 4562 | #line 2167 "./parse.y" |
8b27f225 PB |
4563 | { |
4564 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4565 | yyvsp[-2].node, yyvsp[0].node); | |
4566 | ; | |
4567 | break;} | |
2e5eb5c5 | 4568 | case 452: |
51149cc8 | 4569 | #line 2172 "./parse.y" |
0b4d333e APB |
4570 | { |
4571 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4572 | yyvsp[-2].node, yyvsp[0].node); | |
4573 | ; | |
1179ebc2 | 4574 | break;} |
2e5eb5c5 | 4575 | case 453: |
51149cc8 | 4576 | #line 2177 "./parse.y" |
8b27f225 PB |
4577 | {yyerror ("Missing term"); RECOVER;; |
4578 | break;} | |
2e5eb5c5 | 4579 | case 454: |
51149cc8 | 4580 | #line 2179 "./parse.y" |
8b27f225 PB |
4581 | {yyerror ("Missing term"); RECOVER;; |
4582 | break;} | |
2e5eb5c5 | 4583 | case 455: |
51149cc8 | 4584 | #line 2181 "./parse.y" |
0b4d333e | 4585 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 4586 | break;} |
2e5eb5c5 | 4587 | case 457: |
51149cc8 | 4588 | #line 2187 "./parse.y" |
8b27f225 PB |
4589 | { |
4590 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4591 | yyvsp[-2].node, yyvsp[0].node); | |
4592 | ; | |
4593 | break;} | |
2e5eb5c5 | 4594 | case 458: |
51149cc8 | 4595 | #line 2192 "./parse.y" |
8b27f225 PB |
4596 | { |
4597 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4598 | yyvsp[-2].node, yyvsp[0].node); | |
4599 | ; | |
4600 | break;} | |
2e5eb5c5 | 4601 | case 459: |
51149cc8 | 4602 | #line 2197 "./parse.y" |
8b27f225 PB |
4603 | { |
4604 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4605 | yyvsp[-2].node, yyvsp[0].node); | |
4606 | ; | |
4607 | break;} | |
2e5eb5c5 | 4608 | case 460: |
51149cc8 | 4609 | #line 2202 "./parse.y" |
0b4d333e APB |
4610 | { |
4611 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4612 | yyvsp[-2].node, yyvsp[0].node); | |
4613 | ; | |
8b27f225 | 4614 | break;} |
8b27f225 | 4615 | case 461: |
51149cc8 | 4616 | #line 2207 "./parse.y" |
2e5eb5c5 | 4617 | { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ; |
8b27f225 PB |
4618 | break;} |
4619 | case 462: | |
51149cc8 | 4620 | #line 2209 "./parse.y" |
8b27f225 PB |
4621 | {yyerror ("Missing term"); RECOVER;; |
4622 | break;} | |
4623 | case 463: | |
51149cc8 | 4624 | #line 2211 "./parse.y" |
0b4d333e APB |
4625 | {yyerror ("Missing term"); RECOVER;; |
4626 | break;} | |
4627 | case 464: | |
51149cc8 | 4628 | #line 2213 "./parse.y" |
2e5eb5c5 APB |
4629 | {yyerror ("Missing term"); RECOVER;; |
4630 | break;} | |
4631 | case 465: | |
51149cc8 | 4632 | #line 2215 "./parse.y" |
2e5eb5c5 | 4633 | {yyerror ("Missing term"); RECOVER;; |
8b27f225 | 4634 | break;} |
0b4d333e | 4635 | case 466: |
51149cc8 | 4636 | #line 2217 "./parse.y" |
2e5eb5c5 APB |
4637 | {yyerror ("Invalid reference type"); RECOVER;; |
4638 | break;} | |
4639 | case 468: | |
51149cc8 | 4640 | #line 2223 "./parse.y" |
8b27f225 PB |
4641 | { |
4642 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4643 | yyvsp[-2].node, yyvsp[0].node); | |
4644 | ; | |
4645 | break;} | |
2e5eb5c5 | 4646 | case 469: |
51149cc8 | 4647 | #line 2228 "./parse.y" |
8b27f225 PB |
4648 | { |
4649 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4650 | yyvsp[-2].node, yyvsp[0].node); | |
4651 | ; | |
4652 | break;} | |
2e5eb5c5 | 4653 | case 470: |
51149cc8 | 4654 | #line 2233 "./parse.y" |
8b27f225 PB |
4655 | {yyerror ("Missing term"); RECOVER;; |
4656 | break;} | |
2e5eb5c5 | 4657 | case 471: |
51149cc8 | 4658 | #line 2235 "./parse.y" |
8b27f225 PB |
4659 | {yyerror ("Missing term"); RECOVER;; |
4660 | break;} | |
2e5eb5c5 | 4661 | case 473: |
51149cc8 | 4662 | #line 2241 "./parse.y" |
8b27f225 PB |
4663 | { |
4664 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4665 | yyvsp[-2].node, yyvsp[0].node); | |
4666 | ; | |
4667 | break;} | |
2e5eb5c5 | 4668 | case 474: |
51149cc8 | 4669 | #line 2246 "./parse.y" |
8b27f225 PB |
4670 | {yyerror ("Missing term"); RECOVER;; |
4671 | break;} | |
2e5eb5c5 | 4672 | case 476: |
51149cc8 | 4673 | #line 2252 "./parse.y" |
8b27f225 PB |
4674 | { |
4675 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4676 | yyvsp[-2].node, yyvsp[0].node); | |
4677 | ; | |
4678 | break;} | |
2e5eb5c5 | 4679 | case 477: |
51149cc8 | 4680 | #line 2257 "./parse.y" |
8b27f225 PB |
4681 | {yyerror ("Missing term"); RECOVER;; |
4682 | break;} | |
2e5eb5c5 | 4683 | case 479: |
51149cc8 | 4684 | #line 2263 "./parse.y" |
8b27f225 PB |
4685 | { |
4686 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4687 | yyvsp[-2].node, yyvsp[0].node); | |
4688 | ; | |
4689 | break;} | |
2e5eb5c5 | 4690 | case 480: |
51149cc8 | 4691 | #line 2268 "./parse.y" |
8b27f225 PB |
4692 | {yyerror ("Missing term"); RECOVER;; |
4693 | break;} | |
2e5eb5c5 | 4694 | case 482: |
51149cc8 | 4695 | #line 2274 "./parse.y" |
8b27f225 PB |
4696 | { |
4697 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4698 | yyvsp[-2].node, yyvsp[0].node); | |
4699 | ; | |
4700 | break;} | |
2e5eb5c5 | 4701 | case 483: |
51149cc8 | 4702 | #line 2279 "./parse.y" |
8b27f225 PB |
4703 | {yyerror ("Missing term"); RECOVER;; |
4704 | break;} | |
2e5eb5c5 | 4705 | case 485: |
51149cc8 | 4706 | #line 2285 "./parse.y" |
8b27f225 PB |
4707 | { |
4708 | yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location, | |
4709 | yyvsp[-2].node, yyvsp[0].node); | |
4710 | ; | |
4711 | break;} | |
2e5eb5c5 | 4712 | case 486: |
51149cc8 | 4713 | #line 2290 "./parse.y" |
8b27f225 PB |
4714 | {yyerror ("Missing term"); RECOVER;; |
4715 | break;} | |
2e5eb5c5 | 4716 | case 488: |
51149cc8 | 4717 | #line 2296 "./parse.y" |
22eed1e6 APB |
4718 | { |
4719 | yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); | |
4720 | EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location; | |
4721 | ; | |
4722 | break;} | |
2e5eb5c5 | 4723 | case 489: |
51149cc8 | 4724 | #line 2301 "./parse.y" |
8b27f225 PB |
4725 | { |
4726 | YYERROR_NOW; | |
4727 | yyerror ("Missing term"); | |
4728 | DRECOVER (1); | |
4729 | ; | |
4730 | break;} | |
2e5eb5c5 | 4731 | case 490: |
51149cc8 | 4732 | #line 2307 "./parse.y" |
8b27f225 PB |
4733 | {yyerror ("Missing term"); DRECOVER (2);; |
4734 | break;} | |
2e5eb5c5 | 4735 | case 491: |
51149cc8 | 4736 | #line 2309 "./parse.y" |
8b27f225 PB |
4737 | {yyerror ("Missing term"); DRECOVER (3);; |
4738 | break;} | |
2e5eb5c5 | 4739 | case 494: |
51149cc8 | 4740 | #line 2319 "./parse.y" |
8b27f225 PB |
4741 | { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ; |
4742 | break;} | |
2e5eb5c5 | 4743 | case 495: |
51149cc8 | 4744 | #line 2321 "./parse.y" |
8b27f225 PB |
4745 | { |
4746 | if (ctxp->prevent_ese != lineno) | |
4747 | yyerror ("Missing term"); | |
4748 | DRECOVER (assign); | |
4749 | ; | |
4750 | break;} | |
4751 | } | |
4752 | /* the action file gets copied in in place of this dollarsign */ | |
c52b5771 | 4753 | #line 498 "/home/green/cygnus/njava/i0/share/bison.simple" |
8b27f225 PB |
4754 | \f |
4755 | yyvsp -= yylen; | |
4756 | yyssp -= yylen; | |
4757 | #ifdef YYLSP_NEEDED | |
4758 | yylsp -= yylen; | |
4759 | #endif | |
4760 | ||
4761 | #if YYDEBUG != 0 | |
4762 | if (yydebug) | |
4763 | { | |
4764 | short *ssp1 = yyss - 1; | |
4765 | fprintf (stderr, "state stack now"); | |
4766 | while (ssp1 != yyssp) | |
4767 | fprintf (stderr, " %d", *++ssp1); | |
4768 | fprintf (stderr, "\n"); | |
4769 | } | |
4770 | #endif | |
4771 | ||
4772 | *++yyvsp = yyval; | |
4773 | ||
4774 | #ifdef YYLSP_NEEDED | |
4775 | yylsp++; | |
4776 | if (yylen == 0) | |
4777 | { | |
4778 | yylsp->first_line = yylloc.first_line; | |
4779 | yylsp->first_column = yylloc.first_column; | |
4780 | yylsp->last_line = (yylsp-1)->last_line; | |
4781 | yylsp->last_column = (yylsp-1)->last_column; | |
4782 | yylsp->text = 0; | |
4783 | } | |
4784 | else | |
4785 | { | |
4786 | yylsp->last_line = (yylsp+yylen-1)->last_line; | |
4787 | yylsp->last_column = (yylsp+yylen-1)->last_column; | |
4788 | } | |
4789 | #endif | |
4790 | ||
4791 | /* Now "shift" the result of the reduction. | |
4792 | Determine what state that goes to, | |
4793 | based on the state we popped back to | |
4794 | and the rule number reduced by. */ | |
4795 | ||
4796 | yyn = yyr1[yyn]; | |
4797 | ||
4798 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; | |
4799 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) | |
4800 | yystate = yytable[yystate]; | |
4801 | else | |
4802 | yystate = yydefgoto[yyn - YYNTBASE]; | |
4803 | ||
4804 | goto yynewstate; | |
4805 | ||
4806 | yyerrlab: /* here on detecting error */ | |
4807 | ||
4808 | if (! yyerrstatus) | |
4809 | /* If not already recovering from an error, report this error. */ | |
4810 | { | |
4811 | ++yynerrs; | |
4812 | ||
4813 | #ifdef YYERROR_VERBOSE | |
4814 | yyn = yypact[yystate]; | |
4815 | ||
4816 | if (yyn > YYFLAG && yyn < YYLAST) | |
4817 | { | |
4818 | int size = 0; | |
4819 | char *msg; | |
4820 | int x, count; | |
4821 | ||
4822 | count = 0; | |
4823 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ | |
4824 | for (x = (yyn < 0 ? -yyn : 0); | |
4825 | x < (sizeof(yytname) / sizeof(char *)); x++) | |
4826 | if (yycheck[x + yyn] == x) | |
4827 | size += strlen(yytname[x]) + 15, count++; | |
4828 | msg = (char *) malloc(size + 15); | |
4829 | if (msg != 0) | |
4830 | { | |
4831 | strcpy(msg, "parse error"); | |
4832 | ||
4833 | if (count < 5) | |
4834 | { | |
4835 | count = 0; | |
4836 | for (x = (yyn < 0 ? -yyn : 0); | |
4837 | x < (sizeof(yytname) / sizeof(char *)); x++) | |
4838 | if (yycheck[x + yyn] == x) | |
4839 | { | |
4840 | strcat(msg, count == 0 ? ", expecting `" : " or `"); | |
4841 | strcat(msg, yytname[x]); | |
4842 | strcat(msg, "'"); | |
4843 | count++; | |
4844 | } | |
4845 | } | |
4846 | yyerror(msg); | |
4847 | free(msg); | |
4848 | } | |
4849 | else | |
4850 | yyerror ("parse error; also virtual memory exceeded"); | |
4851 | } | |
4852 | else | |
4853 | #endif /* YYERROR_VERBOSE */ | |
4854 | yyerror("parse error"); | |
4855 | } | |
4856 | ||
4857 | goto yyerrlab1; | |
4858 | yyerrlab1: /* here on error raised explicitly by an action */ | |
4859 | ||
4860 | if (yyerrstatus == 3) | |
4861 | { | |
4862 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ | |
4863 | ||
4864 | /* return failure if at end of input */ | |
4865 | if (yychar == YYEOF) | |
4866 | YYABORT; | |
4867 | ||
4868 | #if YYDEBUG != 0 | |
4869 | if (yydebug) | |
4870 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); | |
4871 | #endif | |
4872 | ||
4873 | yychar = YYEMPTY; | |
4874 | } | |
4875 | ||
4876 | /* Else will try to reuse lookahead token | |
4877 | after shifting the error token. */ | |
4878 | ||
4879 | yyerrstatus = 3; /* Each real token shifted decrements this */ | |
4880 | ||
4881 | goto yyerrhandle; | |
4882 | ||
4883 | yyerrdefault: /* current state does not do anything special for the error token. */ | |
4884 | ||
4885 | #if 0 | |
4886 | /* This is wrong; only states that explicitly want error tokens | |
4887 | should shift them. */ | |
4888 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ | |
4889 | if (yyn) goto yydefault; | |
4890 | #endif | |
4891 | ||
4892 | yyerrpop: /* pop the current state because it cannot handle the error token */ | |
4893 | ||
4894 | if (yyssp == yyss) YYABORT; | |
4895 | yyvsp--; | |
4896 | yystate = *--yyssp; | |
4897 | #ifdef YYLSP_NEEDED | |
4898 | yylsp--; | |
4899 | #endif | |
4900 | ||
4901 | #if YYDEBUG != 0 | |
4902 | if (yydebug) | |
4903 | { | |
4904 | short *ssp1 = yyss - 1; | |
4905 | fprintf (stderr, "Error: state stack now"); | |
4906 | while (ssp1 != yyssp) | |
4907 | fprintf (stderr, " %d", *++ssp1); | |
4908 | fprintf (stderr, "\n"); | |
4909 | } | |
4910 | #endif | |
4911 | ||
4912 | yyerrhandle: | |
4913 | ||
4914 | yyn = yypact[yystate]; | |
4915 | if (yyn == YYFLAG) | |
4916 | goto yyerrdefault; | |
4917 | ||
4918 | yyn += YYTERROR; | |
4919 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) | |
4920 | goto yyerrdefault; | |
4921 | ||
4922 | yyn = yytable[yyn]; | |
4923 | if (yyn < 0) | |
4924 | { | |
4925 | if (yyn == YYFLAG) | |
4926 | goto yyerrpop; | |
4927 | yyn = -yyn; | |
4928 | goto yyreduce; | |
4929 | } | |
4930 | else if (yyn == 0) | |
4931 | goto yyerrpop; | |
4932 | ||
4933 | if (yyn == YYFINAL) | |
4934 | YYACCEPT; | |
4935 | ||
4936 | #if YYDEBUG != 0 | |
4937 | if (yydebug) | |
4938 | fprintf(stderr, "Shifting error token, "); | |
4939 | #endif | |
4940 | ||
4941 | *++yyvsp = yylval; | |
4942 | #ifdef YYLSP_NEEDED | |
4943 | *++yylsp = yylloc; | |
4944 | #endif | |
4945 | ||
4946 | yystate = yyn; | |
4947 | goto yynewstate; | |
4948 | } | |
51149cc8 | 4949 | #line 2347 "./parse.y" |
8b27f225 PB |
4950 | |
4951 | \f | |
4952 | ||
8b27f225 PB |
4953 | /* Flag for the error report routine to issue the error the first time |
4954 | it's called (overriding the default behavior which is to drop the | |
4955 | first invocation and honor the second one, taking advantage of a | |
4956 | richer context. */ | |
4957 | static int force_error = 0; | |
4958 | ||
4959 | /* Create a new parser context and make it the current one. */ | |
4960 | ||
4961 | void | |
4962 | java_push_parser_context () | |
4963 | { | |
4964 | struct parser_ctxt *new = | |
23a79c61 | 4965 | (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt)); |
8b27f225 | 4966 | |
4504ead1 | 4967 | bzero ((PTR) new, sizeof (struct parser_ctxt)); |
8b27f225 PB |
4968 | new->next = ctxp; |
4969 | ctxp = new; | |
4970 | if (ctxp->next) | |
5e942c50 APB |
4971 | { |
4972 | ctxp->incomplete_class = ctxp->next->incomplete_class; | |
4973 | ctxp->gclass_list = ctxp->next->gclass_list; | |
4974 | } | |
8b27f225 PB |
4975 | } |
4976 | ||
4977 | void | |
4978 | java_parser_context_save_global () | |
4979 | { | |
22eed1e6 APB |
4980 | if (!ctxp) |
4981 | { | |
4982 | java_push_parser_context (); | |
ee07f4f4 APB |
4983 | ctxp->saved_data_ctx = 1; |
4984 | } | |
4985 | else if (ctxp->saved_data) | |
4986 | { | |
4987 | struct parser_ctxt *new = | |
4988 | (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt)); | |
4989 | bzero ((PTR)new, sizeof (struct parser_ctxt)); | |
4990 | memcpy ((PTR)new, (PTR)ctxp, sizeof (struct parser_ctxt)); | |
4991 | new->next = ctxp; | |
4992 | ctxp = new; | |
4993 | ctxp->saved_data_ctx = 1; | |
22eed1e6 | 4994 | } |
8b27f225 PB |
4995 | ctxp->finput = finput; |
4996 | ctxp->lineno = lineno; | |
4997 | ctxp->current_class = current_class; | |
4998 | ctxp->filename = input_filename; | |
4999 | ctxp->current_function_decl = current_function_decl; | |
ee07f4f4 | 5000 | ctxp->saved_data = 1; |
8b27f225 PB |
5001 | } |
5002 | ||
5003 | void | |
5004 | java_parser_context_restore_global () | |
5005 | { | |
5006 | finput = ctxp->finput; | |
5007 | lineno = ctxp->lineno; | |
5008 | current_class = ctxp->current_class; | |
5009 | input_filename = ctxp->filename; | |
ee07f4f4 | 5010 | ctxp->saved_data = 0; |
8b27f225 | 5011 | current_function_decl = ctxp->current_function_decl; |
ee07f4f4 APB |
5012 | if (ctxp->saved_data_ctx) |
5013 | java_pop_parser_context (0); | |
8b27f225 PB |
5014 | } |
5015 | ||
5016 | void | |
b351b287 APB |
5017 | java_pop_parser_context (generate) |
5018 | int generate; | |
8b27f225 PB |
5019 | { |
5020 | tree current; | |
5e942c50 | 5021 | struct parser_ctxt *toFree, *next; |
8b27f225 | 5022 | |
5e942c50 APB |
5023 | if (!ctxp) |
5024 | return; | |
5025 | ||
5026 | toFree = ctxp; | |
5027 | next = ctxp->next; | |
8b27f225 PB |
5028 | if (next) |
5029 | { | |
5030 | next->incomplete_class = ctxp->incomplete_class; | |
5e942c50 | 5031 | next->gclass_list = ctxp->gclass_list; |
8b27f225 PB |
5032 | lineno = ctxp->lineno; |
5033 | finput = ctxp->finput; | |
5034 | current_class = ctxp->current_class; | |
5035 | } | |
5036 | ||
5037 | /* Set the single import class file flag to 0 for the current list | |
5038 | of imported things */ | |
5039 | for (current = ctxp->import_list; current; current = TREE_CHAIN (current)) | |
5040 | IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0; | |
5041 | ||
5042 | /* And restore those of the previous context */ | |
5043 | if ((ctxp = next)) /* Assignment is really meant here */ | |
5044 | for (current = ctxp->import_list; current; current = TREE_CHAIN (current)) | |
5045 | IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1; | |
5046 | ||
b351b287 APB |
5047 | if (generate) |
5048 | { | |
5049 | toFree->next = ctxp_for_generation; | |
5050 | ctxp_for_generation = toFree; | |
5051 | } | |
5052 | else | |
5053 | free (toFree); | |
8b27f225 PB |
5054 | } |
5055 | ||
ee07f4f4 APB |
5056 | /* Dump the stacked up parser contexts. Intended to be called from a |
5057 | debugger. */ | |
5058 | ||
5059 | static void | |
5060 | java_debug_context_do (tab) | |
5061 | int tab; | |
5062 | { | |
5063 | #define JAVA_TAB_CONTEXT(C) \ | |
5064 | {int i; for (i = 0; i < (C); i++) fputc (' ', stderr);} | |
5065 | ||
5066 | struct parser_ctxt *copy = ctxp; | |
5067 | while (copy) | |
5068 | { | |
5069 | JAVA_TAB_CONTEXT (tab); | |
5070 | fprintf (stderr, "ctxt: 0x%0lX\n", (unsigned long)copy); | |
5071 | JAVA_TAB_CONTEXT (tab); | |
5072 | fprintf (stderr, "filename: %s\n", copy->filename); | |
5073 | JAVA_TAB_CONTEXT (tab); | |
5074 | fprintf (stderr, "package: %s\n", | |
5075 | (copy->package ? | |
5076 | IDENTIFIER_POINTER (copy->package) : "<none>")); | |
5077 | JAVA_TAB_CONTEXT (tab); | |
5078 | fprintf (stderr, "context for saving: %d\n", copy->saved_data_ctx); | |
5079 | JAVA_TAB_CONTEXT (tab); | |
5080 | fprintf (stderr, "saved data: %d\n", copy->saved_data); | |
5081 | copy = copy->next; | |
5082 | tab += 2; | |
5083 | } | |
5084 | #undef JAVA_TAB_CONTEXT | |
5085 | } | |
5086 | ||
5087 | void | |
5088 | java_debug_context () | |
5089 | { | |
5090 | java_debug_context_do (0); | |
5091 | } | |
5092 | ||
5093 | ||
8119c720 APB |
5094 | /* Reporting an constructor invocation error. */ |
5095 | static void | |
5096 | parse_ctor_invocation_error () | |
5097 | { | |
5098 | if (DECL_CONSTRUCTOR_P (current_function_decl)) | |
5099 | yyerror ("Constructor invocation must be first thing in a constructor"); | |
5100 | else | |
5101 | yyerror ("Only constructors can invoke constructors"); | |
5102 | } | |
5103 | ||
5104 | /* Reporting JDK1.1 features not implemented. */ | |
8b27f225 PB |
5105 | |
5106 | static tree | |
5107 | parse_jdk1_1_error (msg) | |
49f48c71 | 5108 | const char *msg; |
8b27f225 PB |
5109 | { |
5110 | sorry (": `%s' JDK1.1(TM) feature", msg); | |
5111 | java_error_count++; | |
c877974e | 5112 | return empty_stmt_node; |
8b27f225 PB |
5113 | } |
5114 | ||
5115 | static int do_warning = 0; | |
5116 | ||
5117 | void | |
5118 | yyerror (msg) | |
49f48c71 | 5119 | const char *msg; |
8b27f225 PB |
5120 | { |
5121 | static java_lc elc; | |
5122 | static int prev_lineno; | |
49f48c71 | 5123 | static const char *prev_msg; |
8b27f225 PB |
5124 | |
5125 | int save_lineno; | |
5126 | char *remainder, *code_from_source; | |
5127 | extern struct obstack temporary_obstack; | |
5128 | ||
5129 | if (!force_error && prev_lineno == lineno) | |
5130 | return; | |
5131 | ||
5132 | /* Save current error location but report latter, when the context is | |
5133 | richer. */ | |
5134 | if (ctxp->java_error_flag == 0) | |
5135 | { | |
5136 | ctxp->java_error_flag = 1; | |
5137 | elc = ctxp->elc; | |
5138 | /* Do something to use the previous line if we're reaching the | |
5139 | end of the file... */ | |
5140 | #ifdef VERBOSE_SKELETON | |
5141 | printf ("* Error detected (%s)\n", (msg ? msg : "(null)")); | |
5142 | #endif | |
5143 | return; | |
5144 | } | |
5145 | ||
5146 | /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */ | |
5147 | if (!force_error && msg == prev_msg && prev_lineno == elc.line) | |
5148 | return; | |
5149 | ||
5150 | ctxp->java_error_flag = 0; | |
5151 | if (do_warning) | |
5152 | java_warning_count++; | |
5153 | else | |
5154 | java_error_count++; | |
5155 | ||
5156 | if (elc.col == 0 && msg[1] == ';') | |
5157 | { | |
5158 | elc.col = ctxp->p_line->char_col-1; | |
5159 | elc.line = ctxp->p_line->lineno; | |
5160 | } | |
5161 | ||
5162 | save_lineno = lineno; | |
5163 | prev_lineno = lineno = elc.line; | |
5164 | prev_msg = msg; | |
5165 | ||
5166 | code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col); | |
5167 | obstack_grow0 (&temporary_obstack, | |
5168 | code_from_source, strlen (code_from_source)); | |
5169 | remainder = obstack_finish (&temporary_obstack); | |
5170 | if (do_warning) | |
5171 | warning ("%s.\n%s", msg, remainder); | |
5172 | else | |
5173 | error ("%s.\n%s", msg, remainder); | |
5174 | ||
5175 | /* This allow us to cheaply avoid an extra 'Invalid expression | |
5176 | statement' error report when errors have been already reported on | |
5177 | the same line. This occurs when we report an error but don't have | |
5178 | a synchronization point other than ';', which | |
5179 | expression_statement is the only one to take care of. */ | |
5180 | ctxp->prevent_ese = lineno = save_lineno; | |
5181 | } | |
5182 | ||
5183 | static void | |
12472854 | 5184 | issue_warning_error_from_context (cl, msg, ap) |
5e942c50 | 5185 | tree cl; |
d4476be2 | 5186 | const char *msg; |
12472854 | 5187 | va_list ap; |
5e942c50 | 5188 | { |
1886c9d8 | 5189 | char *saved, *saved_input_filename; |
12472854 PB |
5190 | char buffer [4096]; |
5191 | vsprintf (buffer, msg, ap); | |
5192 | force_error = 1; | |
5e942c50 APB |
5193 | |
5194 | ctxp->elc.line = EXPR_WFL_LINENO (cl); | |
82371d41 APB |
5195 | ctxp->elc.col = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 : |
5196 | (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl))); | |
5e942c50 APB |
5197 | |
5198 | /* We have a CL, that's a good reason for using it if it contains data */ | |
5199 | saved = ctxp->filename; | |
5200 | if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl)) | |
5201 | ctxp->filename = EXPR_WFL_FILENAME (cl); | |
1886c9d8 APB |
5202 | saved_input_filename = input_filename; |
5203 | input_filename = ctxp->filename; | |
12472854 PB |
5204 | java_error (NULL); |
5205 | java_error (buffer); | |
5e942c50 | 5206 | ctxp->filename = saved; |
1886c9d8 | 5207 | input_filename = saved_input_filename; |
12472854 | 5208 | force_error = 0; |
5e942c50 APB |
5209 | } |
5210 | ||
8b27f225 PB |
5211 | /* Issue an error message at a current source line CL */ |
5212 | ||
12472854 | 5213 | void |
df32d2ce | 5214 | parse_error_context VPARAMS ((tree cl, const char *msg, ...)) |
8b27f225 | 5215 | { |
d4476be2 | 5216 | #ifndef ANSI_PROTOTYPES |
8b27f225 | 5217 | tree cl; |
d4476be2 | 5218 | const char *msg; |
8b27f225 | 5219 | #endif |
8b27f225 PB |
5220 | va_list ap; |
5221 | ||
5222 | VA_START (ap, msg); | |
d4476be2 | 5223 | #ifndef ANSI_PROTOTYPES |
8b27f225 | 5224 | cl = va_arg (ap, tree); |
d4476be2 | 5225 | msg = va_arg (ap, const char *); |
8b27f225 | 5226 | #endif |
12472854 PB |
5227 | issue_warning_error_from_context (cl, msg, ap); |
5228 | va_end (ap); | |
8b27f225 PB |
5229 | } |
5230 | ||
5231 | /* Issue a warning at a current source line CL */ | |
5232 | ||
5233 | static void | |
df32d2ce | 5234 | parse_warning_context VPARAMS ((tree cl, const char *msg, ...)) |
8b27f225 | 5235 | { |
d4476be2 | 5236 | #ifndef ANSI_PROTOTYPES |
8b27f225 | 5237 | tree cl; |
d4476be2 | 5238 | const char *msg; |
8b27f225 | 5239 | #endif |
8b27f225 PB |
5240 | va_list ap; |
5241 | ||
5242 | VA_START (ap, msg); | |
d4476be2 | 5243 | #ifndef ANSI_PROTOTYPES |
8b27f225 | 5244 | cl = va_arg (ap, tree); |
d4476be2 | 5245 | msg = va_arg (ap, const char *); |
8b27f225 | 5246 | #endif |
8b27f225 | 5247 | |
c877974e | 5248 | force_error = do_warning = 1; |
12472854 | 5249 | issue_warning_error_from_context (cl, msg, ap); |
c877974e | 5250 | do_warning = force_error = 0; |
12472854 | 5251 | va_end (ap); |
8b27f225 PB |
5252 | } |
5253 | ||
82371d41 APB |
5254 | static tree |
5255 | find_expr_with_wfl (node) | |
5256 | tree node; | |
5257 | { | |
5258 | while (node) | |
5259 | { | |
5260 | char code; | |
5261 | tree to_return; | |
5262 | ||
5263 | switch (TREE_CODE (node)) | |
5264 | { | |
5265 | case BLOCK: | |
c0d87ff6 PB |
5266 | node = BLOCK_EXPR_BODY (node); |
5267 | continue; | |
82371d41 APB |
5268 | |
5269 | case COMPOUND_EXPR: | |
5270 | to_return = find_expr_with_wfl (TREE_OPERAND (node, 0)); | |
5271 | if (to_return) | |
5272 | return to_return; | |
c0d87ff6 PB |
5273 | node = TREE_OPERAND (node, 1); |
5274 | continue; | |
82371d41 APB |
5275 | |
5276 | case LOOP_EXPR: | |
c0d87ff6 PB |
5277 | node = TREE_OPERAND (node, 0); |
5278 | continue; | |
82371d41 APB |
5279 | |
5280 | case LABELED_BLOCK_EXPR: | |
c0d87ff6 PB |
5281 | node = TREE_OPERAND (node, 1); |
5282 | continue; | |
5283 | ||
82371d41 APB |
5284 | default: |
5285 | code = TREE_CODE_CLASS (TREE_CODE (node)); | |
5286 | if (((code == '1') || (code == '2') || (code == 'e')) | |
5287 | && EXPR_WFL_LINECOL (node)) | |
5288 | return node; | |
ba179f9f | 5289 | return NULL_TREE; |
82371d41 APB |
5290 | } |
5291 | } | |
5292 | return NULL_TREE; | |
5293 | } | |
5294 | ||
5295 | /* Issue a missing return statement error. Uses METHOD to figure the | |
5296 | last line of the method the error occurs in. */ | |
5297 | ||
5298 | static void | |
5299 | missing_return_error (method) | |
5300 | tree method; | |
5301 | { | |
5302 | EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2); | |
5303 | parse_error_context (wfl_operator, "Missing return statement"); | |
5304 | } | |
5305 | ||
5306 | /* Issue an unreachable statement error. From NODE, find the next | |
5307 | statement to report appropriately. */ | |
5308 | static void | |
5309 | unreachable_stmt_error (node) | |
5310 | tree node; | |
5311 | { | |
5312 | /* Browse node to find the next expression node that has a WFL. Use | |
5313 | the location to report the error */ | |
5314 | if (TREE_CODE (node) == COMPOUND_EXPR) | |
5315 | node = find_expr_with_wfl (TREE_OPERAND (node, 1)); | |
5316 | else | |
5317 | node = find_expr_with_wfl (node); | |
5318 | ||
5319 | if (node) | |
5320 | { | |
5321 | EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2); | |
5322 | parse_error_context (wfl_operator, "Unreachable statement"); | |
5323 | } | |
5324 | else | |
5325 | fatal ("Can't get valid statement - unreachable_stmt_error"); | |
5326 | } | |
5327 | ||
c877974e | 5328 | int |
8b27f225 PB |
5329 | java_report_errors () |
5330 | { | |
5331 | if (java_error_count) | |
5332 | fprintf (stderr, "%d error%s", | |
5333 | java_error_count, (java_error_count == 1 ? "" : "s")); | |
5334 | if (java_warning_count) | |
5335 | fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""), | |
5336 | java_warning_count, (java_warning_count == 1 ? "" : "s")); | |
5337 | if (java_error_count || java_warning_count) | |
5338 | putc ('\n', stderr); | |
c877974e | 5339 | return java_error_count; |
8b27f225 PB |
5340 | } |
5341 | ||
5342 | static char * | |
5343 | java_accstring_lookup (flags) | |
5344 | int flags; | |
5345 | { | |
5346 | static char buffer [80]; | |
5347 | #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;} | |
5348 | ||
5349 | /* Access modifier looked-up first for easier report on forbidden | |
5350 | access. */ | |
5351 | if (flags & ACC_PUBLIC) COPY_RETURN ("public"); | |
5352 | if (flags & ACC_PRIVATE) COPY_RETURN ("private"); | |
5353 | if (flags & ACC_PROTECTED) COPY_RETURN ("protected"); | |
5354 | if (flags & ACC_STATIC) COPY_RETURN ("static"); | |
5355 | if (flags & ACC_FINAL) COPY_RETURN ("final"); | |
5356 | if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized"); | |
5357 | if (flags & ACC_VOLATILE) COPY_RETURN ("volatile"); | |
5358 | if (flags & ACC_TRANSIENT) COPY_RETURN ("transient"); | |
5359 | if (flags & ACC_NATIVE) COPY_RETURN ("native"); | |
5360 | if (flags & ACC_INTERFACE) COPY_RETURN ("interface"); | |
5361 | if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract"); | |
5362 | ||
5363 | buffer [0] = '\0'; | |
5364 | return buffer; | |
5365 | #undef COPY_RETURN | |
5366 | } | |
5367 | ||
5368 | /* Issuing error messages upon redefinition of classes, interfaces or | |
5369 | variables. */ | |
5370 | ||
5371 | static void | |
5372 | classitf_redefinition_error (context, id, decl, cl) | |
49f48c71 | 5373 | const char *context; |
8b27f225 PB |
5374 | tree id, decl, cl; |
5375 | { | |
5376 | parse_error_context (cl, "%s `%s' already defined in %s:%d", | |
5377 | context, IDENTIFIER_POINTER (id), | |
5378 | DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); | |
5379 | /* Here we should point out where its redefined. It's a unicode. FIXME */ | |
5380 | } | |
5381 | ||
5382 | static void | |
5383 | variable_redefinition_error (context, name, type, line) | |
5384 | tree context, name, type; | |
5385 | int line; | |
5386 | { | |
49f48c71 | 5387 | const char *type_name; |
8b27f225 PB |
5388 | |
5389 | /* Figure a proper name for type. We might haven't resolved it */ | |
c877974e APB |
5390 | if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type)) |
5391 | type_name = IDENTIFIER_POINTER (TYPE_NAME (type)); | |
8b27f225 PB |
5392 | else |
5393 | type_name = lang_printable_name (type, 0); | |
5394 | ||
5395 | parse_error_context (context, | |
781b0558 | 5396 | "Variable `%s' is already defined in this method and was declared `%s %s' at line %d", |
8b27f225 PB |
5397 | IDENTIFIER_POINTER (name), |
5398 | type_name, IDENTIFIER_POINTER (name), line); | |
5399 | } | |
5400 | ||
5401 | static tree | |
5402 | build_array_from_name (type, type_wfl, name, ret_name) | |
5403 | tree type, type_wfl, name, *ret_name; | |
5404 | { | |
5405 | int more_dims = 0; | |
49f48c71 | 5406 | const char *string; |
8b27f225 PB |
5407 | |
5408 | /* Eventually get more dims */ | |
5409 | string = IDENTIFIER_POINTER (name); | |
5410 | while (string [more_dims] == '[') | |
5411 | more_dims++; | |
5412 | ||
5413 | /* If we have, then craft a new type for this variable */ | |
5414 | if (more_dims) | |
5415 | { | |
c0d87ff6 | 5416 | name = get_identifier (&string [more_dims]); |
8b27f225 | 5417 | |
34f4db93 APB |
5418 | /* If we have a pointer, use its type */ |
5419 | if (TREE_CODE (type) == POINTER_TYPE) | |
5420 | type = TREE_TYPE (type); | |
8b27f225 PB |
5421 | |
5422 | /* Building the first dimension of a primitive type uses this | |
5423 | function */ | |
5424 | if (JPRIMITIVE_TYPE_P (type)) | |
5425 | { | |
5426 | type = build_java_array_type (type, -1); | |
22eed1e6 | 5427 | CLASS_LOADED_P (type) = 1; |
8b27f225 PB |
5428 | more_dims--; |
5429 | } | |
5430 | /* Otherwise, if we have a WFL for this type, use it (the type | |
5431 | is already an array on an unresolved type, and we just keep | |
5432 | on adding dimensions) */ | |
5433 | else if (type_wfl) | |
5434 | type = type_wfl; | |
5435 | ||
5436 | /* Add all the dimensions */ | |
5437 | while (more_dims--) | |
5438 | type = build_unresolved_array_type (type); | |
5439 | ||
5440 | /* The type may have been incomplete in the first place */ | |
5441 | if (type_wfl) | |
5442 | type = obtain_incomplete_type (type); | |
5443 | } | |
5444 | ||
5445 | *ret_name = name; | |
5446 | return type; | |
5447 | } | |
5448 | ||
5449 | /* Build something that the type identifier resolver will identify as | |
5450 | being an array to an unresolved type. TYPE_WFL is a WFL on a | |
5451 | identifier. */ | |
5452 | ||
5453 | static tree | |
5454 | build_unresolved_array_type (type_or_wfl) | |
5455 | tree type_or_wfl; | |
5456 | { | |
49f48c71 | 5457 | const char *ptr; |
8b27f225 | 5458 | |
1886c9d8 | 5459 | /* TYPE_OR_WFL might be an array on a resolved type. In this case, |
8b27f225 PB |
5460 | just create a array type */ |
5461 | if (TREE_CODE (type_or_wfl) == RECORD_TYPE) | |
5462 | { | |
5463 | tree type = build_java_array_type (type_or_wfl, -1); | |
5464 | CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl); | |
5465 | return type; | |
5466 | } | |
5467 | ||
5468 | obstack_1grow (&temporary_obstack, '['); | |
5469 | obstack_grow0 (&temporary_obstack, | |
5470 | IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)), | |
5471 | IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl))); | |
5472 | ptr = obstack_finish (&temporary_obstack); | |
5473 | return build_expr_wfl (get_identifier (ptr), | |
5474 | EXPR_WFL_FILENAME (type_or_wfl), | |
5475 | EXPR_WFL_LINENO (type_or_wfl), | |
5476 | EXPR_WFL_COLNO (type_or_wfl)); | |
5477 | } | |
5478 | ||
5479 | /* Check modifiers. If one doesn't fit, retrieve it in its declaration line | |
5480 | and point it out. */ | |
5481 | ||
5482 | static void | |
5483 | check_modifiers (message, value, mask) | |
49f48c71 | 5484 | const char *message; |
8b27f225 PB |
5485 | int value; |
5486 | int mask; | |
5487 | { | |
5488 | /* Should point out the one that don't fit. ASCII/unicode, | |
5489 | going backward. FIXME */ | |
5490 | if (value & ~mask) | |
5491 | { | |
5492 | int i, remainder = value & ~mask; | |
5493 | for (i = 0; i <= 10; i++) | |
5494 | if ((1 << i) & remainder) | |
5495 | parse_error_context (ctxp->modifier_ctx [i], message, | |
5496 | java_accstring_lookup (1 << i)); | |
5497 | } | |
5498 | } | |
5499 | ||
5500 | static void | |
5501 | parser_add_interface (class_decl, interface_decl, wfl) | |
5502 | tree class_decl, interface_decl, wfl; | |
5503 | { | |
5504 | if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl))) | |
5505 | parse_error_context (wfl, "Interface `%s' repeated", | |
5506 | IDENTIFIER_POINTER (DECL_NAME (interface_decl))); | |
5507 | } | |
5508 | ||
5509 | /* Bulk of common class/interface checks. Return 1 if an error was | |
5510 | encountered. TAG is 0 for a class, 1 for an interface. */ | |
5511 | ||
5512 | static int | |
5513 | check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl) | |
5514 | int is_interface, flags; | |
5515 | tree raw_name, qualified_name, decl, cl; | |
5516 | { | |
5517 | tree node; | |
5518 | ||
5519 | if (!quiet_flag) | |
5520 | fprintf (stderr, " %s %s", (is_interface ? "interface" : "class"), | |
5521 | IDENTIFIER_POINTER (qualified_name)); | |
5522 | ||
5523 | /* Scope of an interface/class type name: | |
5524 | - Can't be imported by a single type import | |
5525 | - Can't already exists in the package */ | |
5526 | if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name) | |
5527 | && (node = find_name_in_single_imports (raw_name))) | |
5528 | { | |
5529 | parse_error_context | |
5530 | (cl, "%s name `%s' clashes with imported type `%s'", | |
5531 | (is_interface ? "Interface" : "Class"), | |
5532 | IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node)); | |
5533 | return 1; | |
5534 | } | |
5535 | if (decl && CLASS_COMPLETE_P (decl)) | |
5536 | { | |
5537 | classitf_redefinition_error ((is_interface ? "Interface" : "Class"), | |
5538 | qualified_name, decl, cl); | |
5539 | return 1; | |
5540 | } | |
5541 | ||
5542 | /* If public, file name should match class/interface name */ | |
5543 | if (flags & ACC_PUBLIC) | |
5544 | { | |
49f48c71 | 5545 | const char *f; |
8b27f225 PB |
5546 | |
5547 | /* Contains OS dependent assumption on path separator. FIXME */ | |
5548 | for (f = &input_filename [strlen (input_filename)]; | |
fa322ab5 TT |
5549 | f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR; |
5550 | f--) | |
5551 | ; | |
847fe791 | 5552 | if (f[0] == '/' || f[0] == DIR_SEPARATOR) |
8b27f225 PB |
5553 | f++; |
5554 | if (strncmp (IDENTIFIER_POINTER (raw_name), | |
5555 | f , IDENTIFIER_LENGTH (raw_name)) || | |
5556 | f [IDENTIFIER_LENGTH (raw_name)] != '.') | |
781b0558 KG |
5557 | parse_error_context |
5558 | (cl, "Public %s `%s' must be defined in a file called `%s.java'", | |
8b27f225 PB |
5559 | (is_interface ? "interface" : "class"), |
5560 | IDENTIFIER_POINTER (qualified_name), | |
5561 | IDENTIFIER_POINTER (raw_name)); | |
5562 | } | |
5563 | ||
5564 | check_modifiers ((is_interface ? | |
5565 | "Illegal modifier `%s' for interface declaration" : | |
5566 | "Illegal modifier `%s' for class declaration"), flags, | |
5567 | (is_interface ? INTERFACE_MODIFIERS : CLASS_MODIFIERS)); | |
5568 | return 0; | |
5569 | } | |
5570 | ||
5571 | /* If DECL is NULL, create and push a new DECL, record the current | |
5572 | line CL and do other maintenance things. */ | |
5573 | ||
5574 | static tree | |
5575 | maybe_create_class_interface_decl (decl, qualified_name, cl) | |
5576 | tree decl, qualified_name, cl; | |
5577 | { | |
5e942c50 | 5578 | if (!decl) |
8b27f225 PB |
5579 | decl = push_class (make_class (), qualified_name); |
5580 | ||
5581 | /* Take care of the file and line business */ | |
5582 | DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl); | |
f099f336 APB |
5583 | /* If we're emiting xrefs, store the line/col number information */ |
5584 | if (flag_emit_xref) | |
5585 | DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl); | |
5586 | else | |
5587 | DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl); | |
8b27f225 | 5588 | CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1; |
b351b287 APB |
5589 | CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) = |
5590 | IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl)); | |
8b27f225 PB |
5591 | |
5592 | ctxp->current_parsed_class = decl; | |
5593 | ||
5594 | /* Link the declaration to the already seen ones */ | |
5595 | TREE_CHAIN (decl) = ctxp->class_list; | |
5596 | ctxp->class_list = decl; | |
5e942c50 | 5597 | |
23a79c61 | 5598 | /* Create a new nodes in the global lists */ |
5e942c50 | 5599 | ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list); |
23a79c61 | 5600 | all_class_list = tree_cons (NULL_TREE, decl, all_class_list); |
5e942c50 | 5601 | |
8b27f225 PB |
5602 | /* Install a new dependency list element */ |
5603 | create_jdep_list (ctxp); | |
5604 | ||
5605 | SOURCE_FRONTEND_DEBUG (("Defining class/interface %s", | |
5606 | IDENTIFIER_POINTER (qualified_name))); | |
5607 | return decl; | |
5608 | } | |
5609 | ||
5610 | static void | |
5611 | add_superinterfaces (decl, interface_list) | |
5612 | tree decl, interface_list; | |
5613 | { | |
5614 | tree node; | |
5615 | /* Superinterface(s): if present and defined, parser_check_super_interface () | |
5616 | takes care of ensuring that: | |
5617 | - This is an accessible interface type, | |
5618 | - Circularity detection. | |
5619 | parser_add_interface is then called. If present but not defined, | |
5620 | the check operation is delayed until the super interface gets | |
5621 | defined. */ | |
5622 | for (node = interface_list; node; node = TREE_CHAIN (node)) | |
5623 | { | |
5e942c50 APB |
5624 | tree current = TREE_PURPOSE (node); |
5625 | tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current)); | |
5626 | if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl))) | |
8b27f225 | 5627 | { |
5e942c50 APB |
5628 | if (!parser_check_super_interface (idecl, decl, current)) |
5629 | parser_add_interface (decl, idecl, current); | |
8b27f225 PB |
5630 | } |
5631 | else | |
5632 | register_incomplete_type (JDEP_INTERFACE, | |
5633 | current, decl, NULL_TREE); | |
5634 | } | |
5635 | } | |
5636 | ||
5637 | /* Create an interface in pass1 and return its decl. Return the | |
5638 | interface's decl in pass 2. */ | |
5639 | ||
5640 | static tree | |
5641 | create_interface (flags, id, super) | |
5642 | int flags; | |
5643 | tree id, super; | |
5644 | { | |
5645 | tree raw_name = EXPR_WFL_NODE (id); | |
5646 | tree q_name = parser_qualified_classname (id); | |
5647 | tree decl = IDENTIFIER_CLASS_VALUE (q_name); | |
5648 | ||
5649 | EXPR_WFL_NODE (id) = q_name; /* Keep source location, even if refined. */ | |
5650 | ||
5651 | /* Basic checks: scope, redefinition, modifiers */ | |
5652 | if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id)) | |
5653 | return NULL_TREE; | |
5654 | ||
5655 | /* Interface modifiers check | |
5656 | - public/abstract allowed (already done at that point) | |
5657 | - abstract is obsolete (comes first, it's a warning, or should be) | |
5658 | - Can't use twice the same (checked in the modifier rule) */ | |
c877974e | 5659 | if ((flags & ACC_ABSTRACT) && flag_redundant) |
8b27f225 PB |
5660 | parse_warning_context |
5661 | (MODIFIER_WFL (ABSTRACT_TK), | |
781b0558 | 5662 | "Redundant use of `abstract' modifier. Interface `%s' is implicitely abstract", IDENTIFIER_POINTER (raw_name)); |
8b27f225 PB |
5663 | |
5664 | /* Create a new decl if DECL is NULL, otherwise fix it */ | |
5665 | decl = maybe_create_class_interface_decl (decl, q_name, id); | |
5666 | ||
5667 | /* Set super info and mark the class a complete */ | |
2aa11e97 | 5668 | set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl), |
8b27f225 PB |
5669 | object_type_node, ctxp->interface_number); |
5670 | ctxp->interface_number = 0; | |
5671 | CLASS_COMPLETE_P (decl) = 1; | |
5672 | add_superinterfaces (decl, super); | |
5673 | ||
5674 | return decl; | |
5675 | } | |
5676 | ||
5677 | /* Create an class in pass1 and return its decl. Return class | |
5678 | interface's decl in pass 2. */ | |
5679 | ||
5680 | static tree | |
5681 | create_class (flags, id, super, interfaces) | |
5682 | int flags; | |
5683 | tree id, super, interfaces; | |
5684 | { | |
5685 | tree raw_name = EXPR_WFL_NODE (id); | |
5686 | tree class_id, decl; | |
9ee9b555 | 5687 | tree super_decl_type; |
8b27f225 PB |
5688 | |
5689 | class_id = parser_qualified_classname (id); | |
5690 | decl = IDENTIFIER_CLASS_VALUE (class_id); | |
5e942c50 | 5691 | ctxp->current_parsed_class_un = EXPR_WFL_NODE (id); |
8b27f225 PB |
5692 | EXPR_WFL_NODE (id) = class_id; |
5693 | ||
5694 | /* Basic check: scope, redefinition, modifiers */ | |
5695 | if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id)) | |
5696 | return NULL_TREE; | |
5697 | ||
5698 | /* Class modifier check: | |
5699 | - Allowed modifier (already done at that point) | |
5700 | - abstract AND final forbidden | |
5701 | - Public classes defined in the correct file */ | |
5702 | if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL)) | |
781b0558 KG |
5703 | parse_error_context |
5704 | (id, "Class `%s' can't be declared both abstract and final", | |
5705 | IDENTIFIER_POINTER (raw_name)); | |
8b27f225 PB |
5706 | |
5707 | /* Create a new decl if DECL is NULL, otherwise fix it */ | |
5708 | decl = maybe_create_class_interface_decl (decl, class_id, id); | |
5709 | ||
5710 | /* If SUPER exists, use it, otherwise use Object */ | |
5711 | if (super) | |
5712 | { | |
5713 | /* Can't extend java.lang.Object */ | |
5714 | if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node) | |
5715 | { | |
5716 | parse_error_context (id, "Can't extend `java.lang.Object'"); | |
5717 | return NULL_TREE; | |
5718 | } | |
5719 | ||
2c3199bc PB |
5720 | super_decl_type = |
5721 | register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE); | |
8b27f225 PB |
5722 | } |
5723 | else if (TREE_TYPE (decl) != object_type_node) | |
5724 | super_decl_type = object_type_node; | |
5725 | /* We're defining java.lang.Object */ | |
5726 | else | |
5727 | super_decl_type = NULL_TREE; | |
5728 | ||
5729 | /* Set super info and mark the class a complete */ | |
5730 | set_super_info (flags, TREE_TYPE (decl), super_decl_type, | |
5731 | ctxp->interface_number); | |
5732 | ctxp->interface_number = 0; | |
5733 | CLASS_COMPLETE_P (decl) = 1; | |
5734 | add_superinterfaces (decl, interfaces); | |
5735 | ||
7f10c2e2 APB |
5736 | /* If doing xref, store the location at which the inherited class |
5737 | (if any) was seen. */ | |
5738 | if (flag_emit_xref && super) | |
5739 | DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super); | |
5740 | ||
5e942c50 APB |
5741 | /* Eventually sets the @deprecated tag flag */ |
5742 | CHECK_DEPRECATED (decl); | |
5743 | ||
8b27f225 PB |
5744 | return decl; |
5745 | } | |
5746 | ||
5747 | /* Can't use lookup_field () since we don't want to load the class and | |
5748 | can't set the CLASS_LOADED_P flag */ | |
5749 | ||
5750 | static tree | |
5751 | find_field (class, name) | |
5752 | tree class; | |
5753 | tree name; | |
5754 | { | |
5755 | tree decl; | |
5756 | for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl)) | |
5757 | { | |
5758 | if (DECL_NAME (decl) == name) | |
5759 | return decl; | |
5760 | } | |
5761 | return NULL_TREE; | |
5762 | } | |
5763 | ||
5764 | /* Wrap around lookup_field that doesn't potentially upset the value | |
5765 | of CLASS */ | |
5766 | ||
5767 | static tree | |
5768 | lookup_field_wrapper (class, name) | |
5769 | tree class, name; | |
5770 | { | |
5771 | tree type = class; | |
5b09b33e | 5772 | tree decl; |
c877974e | 5773 | java_parser_context_save_global (); |
5b09b33e | 5774 | decl = lookup_field (&type, name); |
c877974e | 5775 | java_parser_context_restore_global (); |
93024893 | 5776 | return decl == error_mark_node ? NULL : decl; |
8b27f225 PB |
5777 | } |
5778 | ||
5779 | /* Find duplicate field within the same class declarations and report | |
5780 | the error. Returns 1 if a duplicated field was found, 0 | |
5781 | otherwise. */ | |
5782 | ||
5783 | static int | |
5784 | duplicate_declaration_error_p (new_field_name, new_type, cl) | |
5785 | tree new_field_name, new_type, cl; | |
5786 | { | |
5787 | /* This might be modified to work with method decl as well */ | |
5788 | tree decl = find_field (TREE_TYPE (ctxp->current_parsed_class), | |
5789 | new_field_name); | |
5790 | if (decl) | |
5791 | { | |
c2e3db92 | 5792 | char *t1 = xstrdup (purify_type_name |
4a5f66c3 APB |
5793 | ((TREE_CODE (new_type) == POINTER_TYPE |
5794 | && TREE_TYPE (new_type) == NULL_TREE) ? | |
5795 | IDENTIFIER_POINTER (TYPE_NAME (new_type)) : | |
5796 | lang_printable_name (new_type, 1))); | |
c877974e APB |
5797 | /* The type may not have been completed by the time we report |
5798 | the error */ | |
c2e3db92 | 5799 | char *t2 = xstrdup (purify_type_name |
4a5f66c3 | 5800 | ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE |
c877974e APB |
5801 | && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ? |
5802 | IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) : | |
5803 | lang_printable_name (TREE_TYPE (decl), 1))); | |
8b27f225 PB |
5804 | parse_error_context |
5805 | (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)", | |
5806 | t1, IDENTIFIER_POINTER (new_field_name), | |
5807 | t2, IDENTIFIER_POINTER (DECL_NAME (decl)), | |
5808 | DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); | |
5809 | free (t1); | |
5810 | free (t2); | |
5811 | return 1; | |
5812 | } | |
5813 | return 0; | |
5814 | } | |
5815 | ||
5816 | /* Field registration routine. If TYPE doesn't exist, field | |
5817 | declarations are linked to the undefined TYPE dependency list, to | |
5818 | be later resolved in java_complete_class () */ | |
5819 | ||
5820 | static void | |
5821 | register_fields (flags, type, variable_list) | |
5822 | int flags; | |
5823 | tree type, variable_list; | |
5824 | { | |
5825 | tree current, saved_type; | |
5826 | tree class_type = TREE_TYPE (ctxp->current_parsed_class); | |
5827 | int saved_lineno = lineno; | |
5828 | int must_chain = 0; | |
5829 | tree wfl = NULL_TREE; | |
5830 | ||
5831 | /* If we're adding fields to interfaces, those fields are public, | |
5832 | static, final */ | |
5833 | if (CLASS_INTERFACE (TYPE_NAME (class_type))) | |
5834 | { | |
5835 | OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK), | |
5836 | flags, ACC_PUBLIC, | |
5837 | "%s", "interface field(s)"); | |
5838 | OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK), | |
5839 | flags, ACC_STATIC, | |
5840 | "%s", "interface field(s)"); | |
5841 | OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK), | |
5842 | flags, ACC_FINAL, "%s", "interface field(s)"); | |
5843 | check_modifiers ("Illegal interface member modifier `%s'", flags, | |
5844 | INTERFACE_FIELD_MODIFIERS); | |
5845 | flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL); | |
5846 | } | |
5847 | ||
5848 | /* Obtain a suitable type for resolution, if necessary */ | |
5849 | SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain); | |
5850 | ||
5851 | /* If TYPE is fully resolved and we don't have a reference, make one */ | |
1886c9d8 | 5852 | PROMOTE_RECORD_IF_COMPLETE (type, must_chain); |
8b27f225 PB |
5853 | |
5854 | for (current = variable_list, saved_type = type; current; | |
5855 | current = TREE_CHAIN (current), type = saved_type) | |
5856 | { | |
c877974e | 5857 | tree real_type; |
8b27f225 PB |
5858 | tree field_decl; |
5859 | tree cl = TREE_PURPOSE (current); | |
5860 | tree init = TREE_VALUE (current); | |
5861 | tree current_name = EXPR_WFL_NODE (cl); | |
5862 | ||
5863 | /* Process NAME, as it may specify extra dimension(s) for it */ | |
5864 | type = build_array_from_name (type, wfl, current_name, ¤t_name); | |
5865 | ||
8b27f225 PB |
5866 | /* Type adjustment. We may have just readjusted TYPE because |
5867 | the variable specified more dimensions. Make sure we have | |
22eed1e6 APB |
5868 | a reference if we can and don't have one already. Also |
5869 | change the name if we have an init. */ | |
5870 | if (type != saved_type) | |
5871 | { | |
1886c9d8 | 5872 | PROMOTE_RECORD_IF_COMPLETE (type, must_chain); |
22eed1e6 APB |
5873 | if (init) |
5874 | EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name; | |
5875 | } | |
8b27f225 | 5876 | |
c877974e APB |
5877 | real_type = GET_REAL_TYPE (type); |
5878 | /* Check for redeclarations */ | |
5879 | if (duplicate_declaration_error_p (current_name, real_type, cl)) | |
5880 | continue; | |
5881 | ||
8b27f225 | 5882 | /* Set lineno to the line the field was found and create a |
5e942c50 | 5883 | declaration for it. Eventually sets the @deprecated tag flag. */ |
f099f336 APB |
5884 | if (flag_emit_xref) |
5885 | lineno = EXPR_WFL_LINECOL (cl); | |
5886 | else | |
5887 | lineno = EXPR_WFL_LINENO (cl); | |
c877974e | 5888 | field_decl = add_field (class_type, current_name, real_type, flags); |
5e942c50 | 5889 | CHECK_DEPRECATED (field_decl); |
8b27f225 PB |
5890 | |
5891 | /* Check if we must chain. */ | |
5892 | if (must_chain) | |
5893 | register_incomplete_type (JDEP_FIELD, wfl, field_decl, type); | |
5894 | ||
8b27f225 PB |
5895 | /* If we have an initialization value tied to the field */ |
5896 | if (init) | |
5897 | { | |
5898 | /* The field is declared static */ | |
5899 | if (flags & ACC_STATIC) | |
5900 | { | |
63a212ed PB |
5901 | /* We include the field and its initialization part into |
5902 | a list used to generate <clinit>. After <clinit> is | |
ba179f9f APB |
5903 | walked, field initializations will be processed and |
5904 | fields initialized with known constants will be taken | |
5905 | out of <clinit> and have their DECL_INITIAL set | |
63a212ed PB |
5906 | appropriately. */ |
5907 | TREE_CHAIN (init) = ctxp->static_initialized; | |
5908 | ctxp->static_initialized = init; | |
7f10c2e2 APB |
5909 | if (TREE_OPERAND (init, 1) |
5910 | && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT) | |
5bba4807 | 5911 | TREE_STATIC (TREE_OPERAND (init, 1)) = 1; |
8b27f225 | 5912 | } |
5e942c50 APB |
5913 | /* A non-static field declared with an immediate initialization is |
5914 | to be initialized in <init>, if any. This field is remembered | |
5915 | to be processed at the time of the generation of <init>. */ | |
8b27f225 PB |
5916 | else |
5917 | { | |
5918 | TREE_CHAIN (init) = ctxp->non_static_initialized; | |
5919 | ctxp->non_static_initialized = init; | |
5920 | } | |
5b09b33e | 5921 | MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1; |
8576f094 | 5922 | DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1); |
8b27f225 PB |
5923 | } |
5924 | } | |
5925 | lineno = saved_lineno; | |
5926 | } | |
5927 | ||
ac825856 | 5928 | /* Generate the method $finit$ that initializes fields initialized |
22eed1e6 APB |
5929 | upon declaration. */ |
5930 | ||
5931 | static void | |
5932 | maybe_generate_finit () | |
5933 | { | |
5934 | tree mdecl, current; | |
5935 | ||
5936 | if (!ctxp->non_static_initialized || java_error_count) | |
5937 | return; | |
5938 | ||
5939 | mdecl = create_artificial_method (TREE_TYPE (ctxp->current_parsed_class), | |
ac825856 | 5940 | ACC_PRIVATE, void_type_node, |
82371d41 | 5941 | finit_identifier_node, end_params_node); |
22eed1e6 APB |
5942 | start_artificial_method_body (mdecl); |
5943 | ||
5944 | ctxp->non_static_initialized = nreverse (ctxp->non_static_initialized); | |
5945 | for (current = ctxp->non_static_initialized; current; | |
5946 | current = TREE_CHAIN (current)) | |
5947 | java_method_add_stmt (mdecl, | |
5948 | build_debugable_stmt (EXPR_WFL_LINECOL (current), | |
5949 | current)); | |
5950 | ||
5951 | end_artificial_method_body (mdecl); | |
5952 | CLASS_HAS_FINIT_P (TREE_TYPE (ctxp->current_parsed_class)) = 1; | |
5953 | ctxp->non_static_initialized = NULL_TREE; | |
5954 | } | |
5955 | ||
8b27f225 PB |
5956 | /* Check whether it is necessary to generate a <clinit> for the class |
5957 | we just parsed. */ | |
5958 | ||
5959 | static void | |
5960 | maybe_generate_clinit () | |
5961 | { | |
22eed1e6 | 5962 | tree mdecl, c; |
8b27f225 PB |
5963 | |
5964 | if (!ctxp->static_initialized || java_error_count) | |
5965 | return; | |
5966 | ||
22eed1e6 APB |
5967 | mdecl = create_artificial_method (TREE_TYPE (ctxp->current_parsed_class), |
5968 | ACC_STATIC, void_type_node, | |
82371d41 | 5969 | clinit_identifier_node, end_params_node); |
22eed1e6 | 5970 | start_artificial_method_body (mdecl); |
8b27f225 PB |
5971 | |
5972 | /* Keep initialization in order to enforce 8.5 */ | |
5973 | ctxp->static_initialized = nreverse (ctxp->static_initialized); | |
5974 | ||
5975 | /* We process the list of assignment we produced as the result of | |
5976 | the declaration of initialized static field and add them as | |
5977 | statement to the <clinit> method. */ | |
5978 | for (c = ctxp->static_initialized; c; c = TREE_CHAIN (c)) | |
5979 | { | |
5980 | /* We build the assignment expression that will initialize the | |
5981 | field to its value. There are strict rules on static | |
5982 | initializers (8.5). FIXME */ | |
22eed1e6 APB |
5983 | java_method_add_stmt (mdecl, |
5984 | build_debugable_stmt (EXPR_WFL_LINECOL (c), c)); | |
8b27f225 PB |
5985 | } |
5986 | ||
22eed1e6 | 5987 | end_artificial_method_body (mdecl); |
8b27f225 PB |
5988 | ctxp->static_initialized = NULL_TREE; |
5989 | } | |
5990 | ||
5991 | /* Shared accros method_declarator and method_header to remember the | |
5992 | patch stage that was reached during the declaration of the method. | |
5993 | A method DECL is built differently is there is no patch | |
5994 | (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN) | |
5995 | pending on the currently defined method. */ | |
5996 | ||
5997 | static int patch_stage; | |
5998 | ||
5999 | /* Check the method declaration and add the method to its current | |
6000 | class. If the argument list is known to contain incomplete types, | |
6001 | the method is partially added and the registration will be resume | |
22eed1e6 APB |
6002 | once the method arguments resolved. If TYPE is NULL, we're dealing |
6003 | with a constructor. */ | |
8b27f225 PB |
6004 | |
6005 | static tree | |
6006 | method_header (flags, type, mdecl, throws) | |
6007 | int flags; | |
6008 | tree type, mdecl, throws; | |
6009 | { | |
6010 | tree meth = TREE_VALUE (mdecl); | |
6011 | tree id = TREE_PURPOSE (mdecl); | |
1886c9d8 | 6012 | tree type_wfl = NULL_TREE; |
79d13333 APB |
6013 | tree meth_name = NULL_TREE; |
6014 | tree current, orig_arg, this_class; | |
8b27f225 | 6015 | int saved_lineno; |
1886c9d8 | 6016 | int constructor_ok = 0, must_chain; |
8b27f225 PB |
6017 | |
6018 | check_modifiers_consistency (flags); | |
79d13333 APB |
6019 | |
6020 | if (ctxp->current_parsed_class) | |
6021 | this_class = TREE_TYPE (ctxp->current_parsed_class); | |
6022 | else | |
6023 | return NULL_TREE; | |
8b27f225 PB |
6024 | |
6025 | /* There are some forbidden modifiers for an abstract method and its | |
6026 | class must be abstract as well. */ | |
22eed1e6 | 6027 | if (type && (flags & ACC_ABSTRACT)) |
8b27f225 PB |
6028 | { |
6029 | ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private"); | |
6030 | ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static"); | |
6031 | ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final"); | |
6032 | ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native"); | |
6033 | ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized"); | |
2aa11e97 APB |
6034 | if (!CLASS_ABSTRACT (TYPE_NAME (this_class)) |
6035 | && !CLASS_INTERFACE (TYPE_NAME (this_class))) | |
8b27f225 | 6036 | parse_error_context |
781b0558 | 6037 | (id, "Class `%s' must be declared abstract to define abstract method `%s'", |
8b27f225 PB |
6038 | IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)), |
6039 | IDENTIFIER_POINTER (EXPR_WFL_NODE (id))); | |
6040 | } | |
22eed1e6 APB |
6041 | /* Things to be checked when declaring a constructor */ |
6042 | if (!type) | |
6043 | { | |
6044 | int ec = java_error_count; | |
6045 | /* 8.6: Constructor declarations: we might be trying to define a | |
6046 | method without specifying a return type. */ | |
5e942c50 | 6047 | if (EXPR_WFL_NODE (id) != ctxp->current_parsed_class_un) |
22eed1e6 APB |
6048 | parse_error_context |
6049 | (id, "Invalid method declaration, return type required"); | |
6050 | /* 8.6.3: Constructor modifiers */ | |
6051 | else | |
6052 | { | |
6053 | JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract"); | |
6054 | JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static"); | |
6055 | JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final"); | |
6056 | JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native"); | |
6057 | JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized"); | |
6058 | } | |
6059 | /* If we found error here, we don't consider it's OK to tread | |
6060 | the method definition as a constructor, for the rest of this | |
6061 | function */ | |
6062 | if (ec == java_error_count) | |
6063 | constructor_ok = 1; | |
6064 | } | |
8b27f225 PB |
6065 | |
6066 | /* Method declared within the scope of an interface are implicitly | |
6067 | abstract and public. Conflicts with other erroneously provided | |
c0d87ff6 | 6068 | modifiers are checked right after. */ |
8b27f225 PB |
6069 | |
6070 | if (CLASS_INTERFACE (TYPE_NAME (this_class))) | |
6071 | { | |
6072 | /* If FLAGS isn't set because of a modifier, turn the | |
6073 | corresponding modifier WFL to NULL so we issue a warning on | |
6074 | the obsolete use of the modifier */ | |
6075 | if (!(flags & ACC_PUBLIC)) | |
6076 | MODIFIER_WFL (PUBLIC_TK) = NULL; | |
6077 | if (!(flags & ACC_ABSTRACT)) | |
6078 | MODIFIER_WFL (ABSTRACT_TK) = NULL; | |
6079 | flags |= ACC_PUBLIC; | |
9ee9b555 | 6080 | flags |= ACC_ABSTRACT; |
8b27f225 PB |
6081 | } |
6082 | ||
6083 | /* Modifiers context reset moved up, so abstract method declaration | |
6084 | modifiers can be later checked. */ | |
6085 | ||
22eed1e6 APB |
6086 | /* Set constructor returned type to void and method name to <init>, |
6087 | unless we found an error identifier the constructor (in which | |
6088 | case we retain the original name) */ | |
6089 | if (!type) | |
6090 | { | |
6091 | type = void_type_node; | |
6092 | if (constructor_ok) | |
6093 | meth_name = init_identifier_node; | |
6094 | } | |
6095 | else | |
6096 | meth_name = EXPR_WFL_NODE (id); | |
8b27f225 | 6097 | |
1886c9d8 APB |
6098 | /* Do the returned type resolution and registration if necessary */ |
6099 | SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain); | |
6100 | ||
4a5f66c3 APB |
6101 | if (meth_name) |
6102 | type = build_array_from_name (type, type_wfl, meth_name, &meth_name); | |
1886c9d8 APB |
6103 | EXPR_WFL_NODE (id) = meth_name; |
6104 | PROMOTE_RECORD_IF_COMPLETE (type, must_chain); | |
6105 | ||
6106 | if (must_chain) | |
8b27f225 | 6107 | { |
1886c9d8 APB |
6108 | patch_stage = JDEP_METHOD_RETURN; |
6109 | register_incomplete_type (patch_stage, type_wfl, id, type); | |
6110 | TREE_TYPE (meth) = GET_REAL_TYPE (type); | |
8b27f225 | 6111 | } |
5e942c50 | 6112 | else |
1886c9d8 | 6113 | TREE_TYPE (meth) = type; |
8b27f225 PB |
6114 | |
6115 | saved_lineno = lineno; | |
6116 | /* When defining an abstract or interface method, the curly | |
6117 | bracket at level 1 doesn't exist because there is no function | |
6118 | body */ | |
6119 | lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 : | |
6120 | EXPR_WFL_LINENO (id)); | |
6121 | ||
5e942c50 APB |
6122 | /* Remember the original argument list */ |
6123 | orig_arg = TYPE_ARG_TYPES (meth); | |
6124 | ||
8b27f225 PB |
6125 | if (patch_stage) /* includes ret type and/or all args */ |
6126 | { | |
6127 | jdep *jdep; | |
6128 | meth = add_method_1 (this_class, flags, meth_name, meth); | |
6129 | /* Patch for the return type */ | |
6130 | if (patch_stage == JDEP_METHOD_RETURN) | |
6131 | { | |
6132 | jdep = CLASSD_LAST (ctxp->classd_list); | |
6133 | JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth)); | |
6134 | } | |
6135 | /* This is the stop JDEP. METH allows the function's signature | |
6136 | to be computed. */ | |
6137 | register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE); | |
6138 | } | |
6139 | else | |
5e942c50 APB |
6140 | meth = add_method (this_class, flags, meth_name, |
6141 | build_java_signature (meth)); | |
6142 | ||
6143 | /* Fix the method argument list so we have the argument name | |
6144 | information */ | |
6145 | fix_method_argument_names (orig_arg, meth); | |
6146 | ||
6147 | /* Register the parameter number and re-install the current line | |
6148 | number */ | |
8b27f225 PB |
6149 | DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1; |
6150 | lineno = saved_lineno; | |
6151 | ||
6152 | /* Register exception specified by the `throws' keyword for | |
6153 | resolution and set the method decl appropriate field to the list. | |
6154 | Note: the grammar ensures that what we get here are class | |
6155 | types. */ | |
6156 | if (throws) | |
6157 | { | |
6158 | throws = nreverse (throws); | |
6159 | for (current = throws; current; current = TREE_CHAIN (current)) | |
6160 | { | |
6161 | register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current), | |
6162 | NULL_TREE, NULL_TREE); | |
6163 | JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) = | |
6164 | &TREE_VALUE (current); | |
6165 | } | |
22eed1e6 APB |
6166 | DECL_FUNCTION_THROWS (meth) = throws; |
6167 | } | |
6168 | ||
6169 | /* We set the DECL_NAME to ID so we can track the location where | |
6170 | the function was declared. This allow us to report | |
6171 | redefinition error accurately. When method are verified, | |
6172 | DECL_NAME is reinstalled properly (using the content of the | |
6173 | WFL node ID) (see check_method_redefinition). We don't do that | |
6174 | when Object is being defined. Constructor <init> names will be | |
6175 | reinstalled the same way. */ | |
6176 | if (TREE_TYPE (ctxp->current_parsed_class) != object_type_node) | |
6177 | DECL_NAME (meth) = id; | |
6178 | ||
6179 | /* Set the flag if we correctly processed a constructor */ | |
6180 | if (constructor_ok) | |
6181 | DECL_CONSTRUCTOR_P (meth) = 1; | |
6182 | ||
5e942c50 APB |
6183 | /* Eventually set the @deprecated tag flag */ |
6184 | CHECK_DEPRECATED (meth); | |
6185 | ||
7f10c2e2 APB |
6186 | /* If doing xref, store column and line number information instead |
6187 | of the line number only. */ | |
6188 | if (flag_emit_xref) | |
6189 | DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id); | |
6190 | ||
22eed1e6 APB |
6191 | return meth; |
6192 | } | |
6193 | ||
5e942c50 APB |
6194 | static void |
6195 | fix_method_argument_names (orig_arg, meth) | |
6196 | tree orig_arg, meth; | |
6197 | { | |
6198 | tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth)); | |
6199 | if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE) | |
6200 | { | |
6201 | TREE_PURPOSE (arg) = this_identifier_node; | |
6202 | arg = TREE_CHAIN (arg); | |
6203 | } | |
82371d41 | 6204 | while (orig_arg != end_params_node) |
5e942c50 APB |
6205 | { |
6206 | TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg); | |
6207 | orig_arg = TREE_CHAIN (orig_arg); | |
6208 | arg = TREE_CHAIN (arg); | |
6209 | } | |
6210 | } | |
6211 | ||
22eed1e6 APB |
6212 | /* Complete the method declaration with METHOD_BODY. */ |
6213 | ||
6214 | static void | |
e85ac860 | 6215 | finish_method_declaration (method_body) |
22eed1e6 APB |
6216 | tree method_body; |
6217 | { | |
79d13333 APB |
6218 | int flags; |
6219 | ||
6220 | if (!current_function_decl) | |
6221 | return; | |
6222 | ||
6223 | flags = get_access_flags_from_decl (current_function_decl); | |
5256aa37 APB |
6224 | |
6225 | /* 8.4.5 Method Body */ | |
6226 | if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body) | |
6227 | { | |
6228 | tree wfl = DECL_NAME (current_function_decl); | |
6229 | parse_error_context (wfl, | |
6230 | "%s method `%s' can't have a body defined", | |
6231 | (METHOD_NATIVE (current_function_decl) ? | |
6232 | "Native" : "Abstract"), | |
6233 | IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl))); | |
6234 | method_body = NULL_TREE; | |
6235 | } | |
6236 | else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body) | |
6237 | { | |
6238 | tree wfl = DECL_NAME (current_function_decl); | |
781b0558 KG |
6239 | parse_error_context |
6240 | (wfl, | |
6241 | "Non native and non abstract method `%s' must have a body defined", | |
6242 | IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl))); | |
5256aa37 APB |
6243 | method_body = NULL_TREE; |
6244 | } | |
6245 | ||
2c56429a APB |
6246 | if (flag_emit_class_files && method_body |
6247 | && TREE_CODE (method_body) == NOP_EXPR | |
6248 | && TREE_TYPE (current_function_decl) | |
6249 | && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node) | |
6250 | method_body = build1 (RETURN_EXPR, void_type_node, NULL); | |
6251 | ||
22eed1e6 APB |
6252 | BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body; |
6253 | maybe_absorb_scoping_blocks (); | |
6254 | /* Exit function's body */ | |
6255 | exit_block (); | |
6256 | /* Merge last line of the function with first line, directly in the | |
6257 | function decl. It will be used to emit correct debug info. */ | |
7f10c2e2 APB |
6258 | if (!flag_emit_xref) |
6259 | DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1); | |
f099f336 APB |
6260 | /* So we don't have an irrelevant function declaration context for |
6261 | the next static block we'll see. */ | |
6262 | current_function_decl = NULL_TREE; | |
22eed1e6 APB |
6263 | } |
6264 | ||
6265 | /* Build a an error message for constructor circularity errors. */ | |
6266 | ||
6267 | static char * | |
6268 | constructor_circularity_msg (from, to) | |
6269 | tree from, to; | |
6270 | { | |
6271 | static char string [4096]; | |
c2e3db92 | 6272 | char *t = xstrdup (lang_printable_name (from, 0)); |
22eed1e6 APB |
6273 | sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0)); |
6274 | free (t); | |
6275 | return string; | |
6276 | } | |
6277 | ||
6278 | /* Verify a circular call to METH. Return 1 if an error is found, 0 | |
6279 | otherwise. */ | |
6280 | ||
6281 | static int | |
6282 | verify_constructor_circularity (meth, current) | |
6283 | tree meth, current; | |
6284 | { | |
6285 | static tree list = NULL_TREE; | |
6286 | tree c; | |
6287 | for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c)) | |
6288 | { | |
6289 | if (TREE_VALUE (c) == meth) | |
6290 | { | |
6291 | char *t; | |
6292 | if (list) | |
6293 | { | |
6294 | tree liste; | |
6295 | list = nreverse (list); | |
6296 | for (liste = list; liste; liste = TREE_CHAIN (liste)) | |
6297 | { | |
6298 | parse_error_context | |
c63b98cd | 6299 | (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s", |
22eed1e6 APB |
6300 | constructor_circularity_msg |
6301 | (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste)))); | |
6302 | java_error_count--; | |
6303 | } | |
6304 | } | |
c2e3db92 | 6305 | t = xstrdup (lang_printable_name (meth, 0)); |
22eed1e6 APB |
6306 | parse_error_context (TREE_PURPOSE (c), |
6307 | "%s: recursive invocation of constructor `%s'", | |
6308 | constructor_circularity_msg (current, meth), t); | |
6309 | free (t); | |
6310 | list = NULL_TREE; | |
6311 | return 1; | |
6312 | } | |
8b27f225 | 6313 | } |
22eed1e6 APB |
6314 | for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c)) |
6315 | { | |
6316 | list = tree_cons (c, current, list); | |
6317 | if (verify_constructor_circularity (meth, TREE_VALUE (c))) | |
6318 | return 1; | |
6319 | list = TREE_CHAIN (list); | |
6320 | } | |
6321 | return 0; | |
8b27f225 PB |
6322 | } |
6323 | ||
6324 | /* Check modifiers that can be declared but exclusively */ | |
6325 | ||
6326 | static void | |
6327 | check_modifiers_consistency (flags) | |
6328 | int flags; | |
6329 | { | |
6330 | int acc_count = 0; | |
6331 | tree cl = NULL_TREE; | |
6332 | ||
6333 | THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, 0, acc_count, cl); | |
6334 | THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, 1, acc_count, cl); | |
6335 | THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, 2, acc_count, cl); | |
6336 | if (acc_count > 1) | |
6337 | parse_error_context | |
781b0558 | 6338 | (cl, "Inconsistent member declaration. At most one of `public', `private', or `protected' may be specified"); |
8b27f225 PB |
6339 | } |
6340 | ||
6341 | /* Check the methode header METH for abstract specifics features */ | |
6342 | ||
6343 | static void | |
6344 | check_abstract_method_header (meth) | |
6345 | tree meth; | |
6346 | { | |
6347 | int flags = get_access_flags_from_decl (meth); | |
6348 | /* DECL_NAME might still be a WFL node */ | |
c877974e | 6349 | tree name = GET_METHOD_NAME (meth); |
8b27f225 PB |
6350 | |
6351 | OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (ABSTRACT_TK), flags, | |
6352 | ACC_ABSTRACT, "abstract method `%s'", | |
6353 | IDENTIFIER_POINTER (name)); | |
6354 | OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK), flags, | |
6355 | ACC_PUBLIC, "abstract method `%s'", | |
6356 | IDENTIFIER_POINTER (name)); | |
6357 | ||
6358 | check_modifiers ("Illegal modifier `%s' for interface method", | |
6359 | flags, INTERFACE_METHOD_MODIFIERS); | |
6360 | } | |
6361 | ||
6362 | /* Create a FUNCTION_TYPE node and start augmenting it with the | |
6363 | declared function arguments. Arguments type that can't be resolved | |
6364 | are left as they are, but the returned node is marked as containing | |
6365 | incomplete types. */ | |
6366 | ||
6367 | static tree | |
6368 | method_declarator (id, list) | |
6369 | tree id, list; | |
6370 | { | |
6371 | tree arg_types = NULL_TREE, current, node; | |
6372 | tree meth = make_node (FUNCTION_TYPE); | |
6373 | jdep *jdep; | |
6374 | ||
6375 | patch_stage = JDEP_NO_PATCH; | |
6376 | ||
6377 | for (current = list; current; current = TREE_CHAIN (current)) | |
6378 | { | |
6379 | int must_chain = 0; | |
6380 | tree wfl_name = TREE_PURPOSE (current); | |
6381 | tree type = TREE_VALUE (current); | |
6382 | tree name = EXPR_WFL_NODE (wfl_name); | |
6383 | tree already, arg_node; | |
6384 | tree type_wfl = NULL_TREE; | |
23a79c61 | 6385 | tree real_type; |
8b27f225 PB |
6386 | |
6387 | /* Obtain a suitable type for resolution, if necessary */ | |
6388 | SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain); | |
6389 | ||
6390 | /* Process NAME, as it may specify extra dimension(s) for it */ | |
6391 | type = build_array_from_name (type, type_wfl, name, &name); | |
6392 | EXPR_WFL_NODE (wfl_name) = name; | |
6393 | ||
23a79c61 APB |
6394 | real_type = GET_REAL_TYPE (type); |
6395 | if (TREE_CODE (real_type) == RECORD_TYPE) | |
6396 | { | |
6397 | real_type = promote_type (real_type); | |
6398 | if (TREE_CODE (type) == TREE_LIST) | |
6399 | TREE_PURPOSE (type) = real_type; | |
6400 | } | |
5e942c50 | 6401 | |
8b27f225 PB |
6402 | /* Check redefinition */ |
6403 | for (already = arg_types; already; already = TREE_CHAIN (already)) | |
6404 | if (TREE_PURPOSE (already) == name) | |
6405 | { | |
781b0558 KG |
6406 | parse_error_context |
6407 | (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'", | |
6408 | IDENTIFIER_POINTER (name), | |
8b27f225 PB |
6409 | IDENTIFIER_POINTER (EXPR_WFL_NODE (id))); |
6410 | break; | |
6411 | } | |
6412 | ||
6413 | /* If we've an incomplete argument type, we know there is a location | |
6414 | to patch when the type get resolved, later. */ | |
6415 | jdep = NULL; | |
6416 | if (must_chain) | |
6417 | { | |
6418 | patch_stage = JDEP_METHOD; | |
6419 | type = register_incomplete_type (patch_stage, | |
6420 | type_wfl, wfl_name, type); | |
6421 | jdep = CLASSD_LAST (ctxp->classd_list); | |
6422 | JDEP_MISC (jdep) = id; | |
6423 | } | |
6424 | ||
6425 | /* The argument node: a name and a (possibly) incomplete type */ | |
23a79c61 | 6426 | arg_node = build_tree_list (name, real_type); |
8b27f225 PB |
6427 | if (jdep) |
6428 | JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node); | |
6429 | TREE_CHAIN (arg_node) = arg_types; | |
6430 | arg_types = arg_node; | |
6431 | } | |
82371d41 | 6432 | TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node); |
8b27f225 PB |
6433 | node = build_tree_list (id, meth); |
6434 | return node; | |
6435 | } | |
6436 | ||
6437 | static int | |
6438 | unresolved_type_p (wfl, returned) | |
6439 | tree wfl; | |
6440 | tree *returned; | |
6441 | ||
6442 | { | |
6443 | if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION) | |
6444 | { | |
6445 | tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl)); | |
6446 | if (returned) | |
6447 | *returned = (decl ? TREE_TYPE (decl) : NULL_TREE); | |
6448 | return 1; | |
6449 | } | |
6450 | if (returned) | |
6451 | *returned = wfl; | |
6452 | return 0; | |
6453 | } | |
6454 | ||
6455 | /* From NAME, build a qualified identifier node using the | |
6456 | qualification from the current package definition. */ | |
6457 | ||
6458 | static tree | |
6459 | parser_qualified_classname (name) | |
6460 | tree name; | |
6461 | { | |
6462 | if (ctxp->package) | |
6463 | return merge_qualified_name (ctxp->package, EXPR_WFL_NODE (name)); | |
6464 | else | |
6465 | return EXPR_WFL_NODE (name); | |
6466 | } | |
6467 | ||
6468 | /* Called once the type a interface extends is resolved. Returns 0 if | |
6469 | everything is OK. */ | |
6470 | ||
6471 | static int | |
6472 | parser_check_super_interface (super_decl, this_decl, this_wfl) | |
6473 | tree super_decl, this_decl, this_wfl; | |
6474 | { | |
6475 | tree super_type = TREE_TYPE (super_decl); | |
6476 | ||
6477 | /* Has to be an interface */ | |
6478 | if (!CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (super_decl)))) | |
6479 | { | |
6480 | parse_error_context | |
6481 | (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'", | |
6482 | (TYPE_ARRAY_P (super_type) ? "array" : "class"), | |
6483 | IDENTIFIER_POINTER (DECL_NAME (super_decl)), | |
6484 | (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ? | |
6485 | "interface" : "class"), | |
6486 | IDENTIFIER_POINTER (DECL_NAME (this_decl))); | |
6487 | return 1; | |
6488 | } | |
6489 | ||
6490 | /* Check scope: same package OK, other package: OK if public */ | |
6491 | if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl))) | |
6492 | return 1; | |
6493 | ||
6494 | SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s", | |
6495 | IDENTIFIER_POINTER (DECL_NAME (this_decl)), | |
6496 | IDENTIFIER_POINTER (DECL_NAME (super_decl)))); | |
6497 | return 0; | |
6498 | } | |
6499 | ||
6500 | /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns | |
6501 | 0 if everthing is OK. */ | |
6502 | ||
6503 | static int | |
6504 | parser_check_super (super_decl, this_decl, wfl) | |
6505 | tree super_decl, this_decl, wfl; | |
6506 | { | |
6507 | tree super_type = TREE_TYPE (super_decl); | |
6508 | ||
6509 | /* SUPER should be a CLASS (neither an array nor an interface) */ | |
6510 | if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type))) | |
6511 | { | |
6512 | parse_error_context | |
6513 | (wfl, "Class `%s' can't subclass %s `%s'", | |
6514 | IDENTIFIER_POINTER (DECL_NAME (this_decl)), | |
6515 | (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"), | |
6516 | IDENTIFIER_POINTER (DECL_NAME (super_decl))); | |
6517 | return 1; | |
6518 | } | |
6519 | ||
6520 | if (CLASS_FINAL (TYPE_NAME (super_type))) | |
6521 | { | |
6522 | parse_error_context (wfl, "Can't subclass final classes: %s", | |
6523 | IDENTIFIER_POINTER (DECL_NAME (super_decl))); | |
6524 | return 1; | |
6525 | } | |
6526 | ||
6527 | /* Check scope: same package OK, other package: OK if public */ | |
6528 | if (check_pkg_class_access (DECL_NAME (super_decl), wfl)) | |
6529 | return 1; | |
6530 | ||
6531 | SOURCE_FRONTEND_DEBUG (("Completing class %s with %s", | |
6532 | IDENTIFIER_POINTER (DECL_NAME (this_decl)), | |
6533 | IDENTIFIER_POINTER (DECL_NAME (super_decl)))); | |
6534 | return 0; | |
6535 | } | |
6536 | ||
6537 | /* Create a new dependency list and link it (in a LIFO manner) to the | |
6538 | CTXP list of type dependency list. */ | |
6539 | ||
6540 | static void | |
6541 | create_jdep_list (ctxp) | |
6542 | struct parser_ctxt *ctxp; | |
6543 | { | |
23a79c61 | 6544 | jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist)); |
8b27f225 PB |
6545 | new->first = new->last = NULL; |
6546 | new->next = ctxp->classd_list; | |
6547 | ctxp->classd_list = new; | |
6548 | } | |
6549 | ||
6550 | static jdeplist * | |
6551 | reverse_jdep_list (ctxp) | |
6552 | struct parser_ctxt *ctxp; | |
6553 | { | |
6554 | register jdeplist *prev = NULL, *current, *next; | |
6555 | for (current = ctxp->classd_list; current; current = next) | |
6556 | { | |
6557 | next = current->next; | |
6558 | current->next = prev; | |
6559 | prev = current; | |
6560 | } | |
6561 | return prev; | |
6562 | } | |
6563 | ||
23a79c61 APB |
6564 | /* Create a fake pointer based on the ID stored in |
6565 | TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be | |
6566 | registered again. */ | |
8b27f225 PB |
6567 | |
6568 | static tree | |
23a79c61 APB |
6569 | obtain_incomplete_type (type_name) |
6570 | tree type_name; | |
8b27f225 | 6571 | { |
23a79c61 APB |
6572 | tree ptr, name; |
6573 | ||
6574 | if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION) | |
6575 | name = EXPR_WFL_NODE (type_name); | |
6576 | else if (INCOMPLETE_TYPE_P (type_name)) | |
6577 | name = TYPE_NAME (type_name); | |
6578 | else | |
6579 | fatal ("invalid type name - obtain_incomplete_type"); | |
8b27f225 PB |
6580 | |
6581 | for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr)) | |
78d21f92 | 6582 | if (TYPE_NAME (ptr) == name) |
8b27f225 PB |
6583 | break; |
6584 | ||
6585 | if (!ptr) | |
6586 | { | |
8b27f225 | 6587 | push_obstacks (&permanent_obstack, &permanent_obstack); |
78d21f92 PB |
6588 | BUILD_PTR_FROM_NAME (ptr, name); |
6589 | layout_type (ptr); | |
8b27f225 PB |
6590 | pop_obstacks (); |
6591 | TREE_CHAIN (ptr) = ctxp->incomplete_class; | |
6592 | ctxp->incomplete_class = ptr; | |
6593 | } | |
6594 | ||
6595 | return ptr; | |
6596 | } | |
6597 | ||
6598 | /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is | |
6599 | non NULL instead of computing a new fake type based on WFL. The new | |
6600 | dependency is inserted in the current type dependency list, in FIFO | |
6601 | manner. */ | |
6602 | ||
6603 | static tree | |
6604 | register_incomplete_type (kind, wfl, decl, ptr) | |
6605 | int kind; | |
6606 | tree wfl, decl, ptr; | |
6607 | { | |
23a79c61 | 6608 | jdep *new = (jdep *)xmalloc (sizeof (jdep)); |
8b27f225 | 6609 | |
8b27f225 PB |
6610 | if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */ |
6611 | ptr = obtain_incomplete_type (wfl); | |
6612 | ||
6613 | JDEP_KIND (new) = kind; | |
6614 | JDEP_DECL (new) = decl; | |
6615 | JDEP_SOLV (new) = ptr; | |
6616 | JDEP_WFL (new) = wfl; | |
6617 | JDEP_CHAIN (new) = NULL; | |
6618 | JDEP_MISC (new) = NULL_TREE; | |
6619 | JDEP_GET_PATCH (new) = (tree *)NULL; | |
6620 | ||
6621 | JDEP_INSERT (ctxp->classd_list, new); | |
6622 | ||
6623 | return ptr; | |
6624 | } | |
6625 | ||
6626 | void | |
6627 | java_check_circular_reference () | |
6628 | { | |
6629 | tree current; | |
6630 | for (current = ctxp->class_list; current; current = TREE_CHAIN (current)) | |
6631 | { | |
6632 | tree type = TREE_TYPE (current); | |
781b0558 | 6633 | if (CLASS_INTERFACE (current)) |
8b27f225 PB |
6634 | { |
6635 | /* Check all interfaces this class extends */ | |
6636 | tree basetype_vec = TYPE_BINFO_BASETYPES (type); | |
6637 | int n, i; | |
6638 | ||
6639 | if (!basetype_vec) | |
6640 | return; | |
6641 | n = TREE_VEC_LENGTH (basetype_vec); | |
6642 | for (i = 0; i < n; i++) | |
6643 | { | |
6644 | tree vec_elt = TREE_VEC_ELT (basetype_vec, i); | |
6645 | if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node | |
6646 | && interface_of_p (type, BINFO_TYPE (vec_elt))) | |
6647 | parse_error_context (lookup_cl (current), | |
6648 | "Cyclic interface inheritance"); | |
6649 | } | |
6650 | } | |
6651 | else | |
6652 | if (inherits_from_p (CLASSTYPE_SUPER (type), type)) | |
6653 | parse_error_context (lookup_cl (current), | |
6654 | "Cyclic class inheritance"); | |
6655 | } | |
6656 | } | |
6657 | ||
781b0558 KG |
6658 | /* Fix the constructors. This will be called right after circular |
6659 | references have been checked. It is necessary to fix constructors | |
6660 | early even if no code generation will take place for that class: | |
6661 | some generated constructor might be required by the class whose | |
6662 | compilation triggered this one to be simply loaded. */ | |
6663 | ||
6664 | void | |
6665 | java_fix_constructors () | |
6666 | { | |
6667 | tree current; | |
6668 | ||
6669 | for (current = ctxp->class_list; current; current = TREE_CHAIN (current)) | |
6670 | { | |
6671 | tree decl; | |
6672 | tree class_type = TREE_TYPE (current); | |
6673 | int saw_ctor = 0; | |
6674 | ||
6675 | for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl)) | |
6676 | { | |
6677 | if (DECL_CONSTRUCTOR_P (decl)) | |
6678 | { | |
6679 | fix_constructors (decl); | |
6680 | saw_ctor = 1; | |
6681 | } | |
6682 | } | |
6683 | ||
6684 | if (!saw_ctor) | |
6685 | { | |
6686 | int flags = (get_access_flags_from_decl (current) & ACC_PUBLIC ? | |
6687 | ACC_PUBLIC : 0); | |
6688 | decl = create_artificial_method (class_type, flags, void_type_node, | |
6689 | init_identifier_node, | |
6690 | end_params_node); | |
6691 | DECL_CONSTRUCTOR_P (decl) = 1; | |
6692 | } | |
6693 | } | |
6694 | } | |
6695 | ||
23a79c61 APB |
6696 | /* safe_layout_class just makes sure that we can load a class without |
6697 | disrupting the current_class, input_file, lineno, etc, information | |
6698 | about the class processed currently. */ | |
6699 | ||
8b27f225 PB |
6700 | void |
6701 | safe_layout_class (class) | |
6702 | tree class; | |
6703 | { | |
6704 | tree save_current_class = current_class; | |
6705 | char *save_input_filename = input_filename; | |
6706 | int save_lineno = lineno; | |
5e942c50 | 6707 | |
8b27f225 | 6708 | push_obstacks (&permanent_obstack, &permanent_obstack); |
5e942c50 | 6709 | |
8b27f225 PB |
6710 | layout_class (class); |
6711 | pop_obstacks (); | |
5e942c50 | 6712 | |
8b27f225 PB |
6713 | current_class = save_current_class; |
6714 | input_filename = save_input_filename; | |
6715 | lineno = save_lineno; | |
6716 | CLASS_LOADED_P (class) = 1; | |
6717 | } | |
6718 | ||
6719 | static tree | |
6720 | jdep_resolve_class (dep) | |
6721 | jdep *dep; | |
6722 | { | |
6723 | tree decl; | |
6724 | ||
23a79c61 APB |
6725 | if (JDEP_RESOLVED_P (dep)) |
6726 | decl = JDEP_RESOLVED_DECL (dep); | |
6727 | else | |
8b27f225 | 6728 | { |
23a79c61 APB |
6729 | decl = resolve_class (JDEP_TO_RESOLVE (dep), |
6730 | JDEP_DECL (dep), JDEP_WFL (dep)); | |
8b27f225 PB |
6731 | JDEP_RESOLVED (dep, decl); |
6732 | } | |
23a79c61 | 6733 | |
8b27f225 | 6734 | if (!decl) |
23a79c61 APB |
6735 | complete_class_report_errors (dep); |
6736 | ||
8b27f225 PB |
6737 | return decl; |
6738 | } | |
6739 | ||
6740 | /* Complete unsatisfied class declaration and their dependencies */ | |
6741 | ||
6742 | void | |
6743 | java_complete_class () | |
6744 | { | |
6745 | tree cclass; | |
6746 | jdeplist *cclassd; | |
6747 | int error_found; | |
6748 | tree type; | |
6749 | ||
6750 | push_obstacks (&permanent_obstack, &permanent_obstack); | |
6751 | ||
6752 | /* Process imports and reverse the import on demand list */ | |
6753 | process_imports (); | |
6754 | if (ctxp->import_demand_list) | |
6755 | ctxp->import_demand_list = nreverse (ctxp->import_demand_list); | |
6756 | ||
6757 | /* Rever things so we have the right order */ | |
6758 | ctxp->class_list = nreverse (ctxp->class_list); | |
6759 | ctxp->classd_list = reverse_jdep_list (ctxp); | |
c877974e | 6760 | |
8b27f225 PB |
6761 | for (cclassd = ctxp->classd_list, cclass = ctxp->class_list; |
6762 | cclass && cclassd; | |
6763 | cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd)) | |
6764 | { | |
6765 | jdep *dep; | |
6766 | for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep)) | |
6767 | { | |
6768 | tree decl; | |
8b27f225 PB |
6769 | if (!(decl = jdep_resolve_class (dep))) |
6770 | continue; | |
6771 | ||
6772 | /* Now it's time to patch */ | |
6773 | switch (JDEP_KIND (dep)) | |
6774 | { | |
6775 | case JDEP_SUPER: | |
6776 | /* Simply patch super */ | |
6777 | if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep))) | |
6778 | continue; | |
6779 | BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO | |
6780 | (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl); | |
6781 | break; | |
6782 | ||
6783 | case JDEP_FIELD: | |
6784 | { | |
6785 | /* We do part of the job done in add_field */ | |
6786 | tree field_decl = JDEP_DECL (dep); | |
6787 | tree field_type = TREE_TYPE (decl); | |
6788 | push_obstacks (&permanent_obstack, &permanent_obstack); | |
6789 | if (TREE_CODE (field_type) == RECORD_TYPE) | |
6790 | field_type = promote_type (field_type); | |
6791 | pop_obstacks (); | |
6792 | TREE_TYPE (field_decl) = field_type; | |
5e942c50 APB |
6793 | DECL_ALIGN (field_decl) = 0; |
6794 | layout_decl (field_decl, 0); | |
8b27f225 PB |
6795 | SOURCE_FRONTEND_DEBUG |
6796 | (("Completed field/var decl `%s' with `%s'", | |
6797 | IDENTIFIER_POINTER (DECL_NAME (field_decl)), | |
6798 | IDENTIFIER_POINTER (DECL_NAME (decl)))); | |
6799 | break; | |
6800 | } | |
6801 | case JDEP_METHOD: /* We start patching a method */ | |
6802 | case JDEP_METHOD_RETURN: | |
6803 | error_found = 0; | |
6804 | while (1) | |
6805 | { | |
6806 | if (decl) | |
6807 | { | |
6808 | type = TREE_TYPE(decl); | |
6809 | if (TREE_CODE (type) == RECORD_TYPE) | |
6810 | type = promote_type (type); | |
6811 | JDEP_APPLY_PATCH (dep, type); | |
6812 | SOURCE_FRONTEND_DEBUG | |
6813 | (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ? | |
6814 | "Completing fct `%s' with ret type `%s'": | |
6815 | "Completing arg `%s' with type `%s'"), | |
6816 | IDENTIFIER_POINTER (EXPR_WFL_NODE | |
6817 | (JDEP_DECL_WFL (dep))), | |
6818 | IDENTIFIER_POINTER (DECL_NAME (decl)))); | |
6819 | } | |
6820 | else | |
6821 | error_found = 1; | |
6822 | dep = JDEP_CHAIN (dep); | |
6823 | if (JDEP_KIND (dep) == JDEP_METHOD_END) | |
6824 | break; | |
6825 | else | |
6826 | decl = jdep_resolve_class (dep); | |
6827 | } | |
6828 | if (!error_found) | |
6829 | { | |
6830 | tree mdecl = JDEP_DECL (dep), signature; | |
6831 | push_obstacks (&permanent_obstack, &permanent_obstack); | |
6832 | /* Recompute and reset the signature */ | |
6833 | signature = build_java_signature (TREE_TYPE (mdecl)); | |
6834 | set_java_signature (TREE_TYPE (mdecl), signature); | |
6835 | pop_obstacks (); | |
6836 | } | |
6837 | else | |
6838 | continue; | |
6839 | break; | |
6840 | ||
6841 | case JDEP_INTERFACE: | |
6842 | if (parser_check_super_interface (decl, JDEP_DECL (dep), | |
6843 | JDEP_WFL (dep))) | |
6844 | continue; | |
6845 | parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep)); | |
6846 | break; | |
6847 | ||
6848 | case JDEP_PARM: | |
6849 | case JDEP_VARIABLE: | |
6850 | type = TREE_TYPE(decl); | |
6851 | if (TREE_CODE (type) == RECORD_TYPE) | |
6852 | type = promote_type (type); | |
6853 | JDEP_APPLY_PATCH (dep, type); | |
6854 | break; | |
6855 | ||
6856 | case JDEP_TYPE: | |
6857 | JDEP_APPLY_PATCH (dep, TREE_TYPE (decl)); | |
6858 | SOURCE_FRONTEND_DEBUG | |
6859 | (("Completing a random type dependency on a '%s' node", | |
6860 | tree_code_name [TREE_CODE (JDEP_DECL (dep))])); | |
6861 | break; | |
6862 | ||
6863 | case JDEP_EXCEPTION: | |
c877974e APB |
6864 | JDEP_APPLY_PATCH (dep, TREE_TYPE (decl)); |
6865 | SOURCE_FRONTEND_DEBUG | |
6866 | (("Completing `%s' `throws' argument node", | |
6867 | IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))))); | |
8b27f225 PB |
6868 | break; |
6869 | ||
6870 | default: | |
6871 | fatal ("Can't handle patch code %d - java_complete_class", | |
6872 | JDEP_KIND (dep)); | |
6873 | } | |
6874 | } | |
6875 | } | |
6876 | pop_obstacks (); | |
6877 | return; | |
6878 | } | |
6879 | ||
6880 | /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an | |
6881 | array. */ | |
6882 | ||
6883 | static tree | |
6884 | resolve_class (class_type, decl, cl) | |
6885 | tree class_type, decl, cl; | |
6886 | { | |
49f48c71 KG |
6887 | const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type)); |
6888 | const char *base = name; | |
78d21f92 PB |
6889 | tree resolved_type = TREE_TYPE (class_type); |
6890 | tree resolved_type_decl; | |
8b27f225 | 6891 | |
78d21f92 PB |
6892 | if (resolved_type != NULL_TREE) |
6893 | { | |
6894 | tree resolved_type_decl = TYPE_NAME (resolved_type); | |
6895 | if (resolved_type_decl == NULL_TREE | |
6896 | || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE) | |
6897 | { | |
6898 | resolved_type_decl = build_decl (TYPE_DECL, | |
6899 | TYPE_NAME (class_type), | |
6900 | resolved_type); | |
6901 | } | |
6902 | return resolved_type_decl; | |
6903 | } | |
6904 | ||
8b27f225 PB |
6905 | /* 1- Check to see if we have an array. If true, find what we really |
6906 | want to resolve */ | |
6907 | while (name[0] == '[') | |
6908 | name++; | |
6909 | if (base != name) | |
6910 | TYPE_NAME (class_type) = get_identifier (name); | |
6911 | ||
6912 | /* 2- Resolve the bare type */ | |
6913 | if (!(resolved_type_decl = do_resolve_class (class_type, decl, cl))) | |
6914 | return NULL_TREE; | |
6915 | resolved_type = TREE_TYPE (resolved_type_decl); | |
6916 | ||
6917 | /* 3- If we have and array, reconstruct the array down to its nesting */ | |
6918 | if (base != name) | |
6919 | { | |
6920 | while (base != name) | |
6921 | { | |
6922 | if (TREE_CODE (resolved_type) == RECORD_TYPE) | |
6923 | resolved_type = promote_type (resolved_type); | |
6924 | resolved_type = build_java_array_type (resolved_type, -1); | |
6925 | CLASS_LOADED_P (resolved_type) = 1; | |
6926 | name--; | |
6927 | } | |
6928 | /* Build a fake decl for this, since this is what is expected to | |
6929 | be returned. */ | |
6930 | resolved_type_decl = | |
6931 | build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type); | |
6932 | /* Figure how those two things are important for error report. FIXME */ | |
6933 | DECL_SOURCE_LINE (resolved_type_decl) = 0; | |
6934 | DECL_SOURCE_FILE (resolved_type_decl) = input_filename; | |
78d21f92 | 6935 | TYPE_NAME (class_type) = TYPE_NAME (resolved_type); |
8b27f225 | 6936 | } |
78d21f92 | 6937 | TREE_TYPE (class_type) = resolved_type; |
8b27f225 PB |
6938 | return resolved_type_decl; |
6939 | } | |
6940 | ||
6941 | /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL | |
6942 | are used to report error messages. */ | |
6943 | ||
78d21f92 | 6944 | tree |
8b27f225 PB |
6945 | do_resolve_class (class_type, decl, cl) |
6946 | tree class_type; | |
6947 | tree decl; | |
6948 | tree cl; | |
6949 | { | |
6950 | tree new_class_decl; | |
6951 | tree original_name = NULL_TREE; | |
6952 | ||
6953 | /* Do not try to replace TYPE_NAME (class_type) by a variable, since | |
6954 | its is changed by find_in_imports{_on_demand} */ | |
6955 | ||
6956 | /* 1- Check for the type in single imports */ | |
6957 | if (find_in_imports (class_type)) | |
6958 | return NULL_TREE; | |
6959 | ||
6960 | /* 2- And check for the type in the current compilation unit. If it fails, | |
ee07f4f4 | 6961 | try with a name qualified with the package name we've seen so far */ |
8b27f225 PB |
6962 | if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type)))) |
6963 | { | |
6964 | if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) && | |
6965 | !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl))) | |
6966 | load_class (TYPE_NAME (class_type), 0); | |
6967 | return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type)); | |
6968 | } | |
6969 | ||
6970 | original_name = TYPE_NAME (class_type); | |
ee07f4f4 | 6971 | if (!QUALIFIED_P (TYPE_NAME (class_type))) |
bc3ca41b | 6972 | { |
ee07f4f4 APB |
6973 | tree package; |
6974 | for (package = package_list; package; package = TREE_CHAIN (package)) | |
bc3ca41b | 6975 | { |
ee07f4f4 APB |
6976 | tree new_qualified; |
6977 | ||
6978 | new_qualified = merge_qualified_name (TREE_PURPOSE (package), | |
6979 | original_name); | |
6980 | TYPE_NAME (class_type) = new_qualified; | |
6981 | new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type)); | |
6982 | if (!new_class_decl) | |
6983 | load_class (TYPE_NAME (class_type), 0); | |
6984 | new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type)); | |
6985 | if (new_class_decl) | |
6986 | { | |
6987 | if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) && | |
6988 | !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl))) | |
6989 | load_class (TYPE_NAME (class_type), 0); | |
6990 | return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type)); | |
6991 | } | |
bc3ca41b PB |
6992 | } |
6993 | } | |
8b27f225 PB |
6994 | TYPE_NAME (class_type) = original_name; |
6995 | ||
6996 | /* 3- Check an other compilation unit that bears the name of type */ | |
6997 | load_class (TYPE_NAME (class_type), 0); | |
6998 | if (check_pkg_class_access (TYPE_NAME (class_type), | |
6999 | (cl ? cl : lookup_cl (decl)))) | |
7000 | return NULL_TREE; | |
7001 | ||
7002 | if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type)))) | |
7003 | return new_class_decl; | |
7004 | ||
7005 | /* 4- Check the import on demands. Don't allow bar.baz to be | |
7006 | imported from foo.* */ | |
7007 | if (!QUALIFIED_P (TYPE_NAME (class_type))) | |
7008 | if (find_in_imports_on_demand (class_type)) | |
7009 | return NULL_TREE; | |
7010 | ||
7011 | /* 5- Last call for a resolution */ | |
7012 | return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type)); | |
7013 | } | |
7014 | ||
7015 | /* Resolve NAME and lay it out (if not done and if not the current | |
23a79c61 APB |
7016 | parsed class). Return a decl node. This function is meant to be |
7017 | called when type resolution is necessary during the walk pass. */ | |
8b27f225 PB |
7018 | |
7019 | static tree | |
c877974e APB |
7020 | resolve_and_layout (something, cl) |
7021 | tree something; | |
8b27f225 PB |
7022 | tree cl; |
7023 | { | |
c877974e APB |
7024 | tree decl; |
7025 | ||
23a79c61 APB |
7026 | /* Don't do that on the current class */ |
7027 | if (something == current_class) | |
7028 | return TYPE_NAME (current_class); | |
c877974e | 7029 | |
23a79c61 | 7030 | /* Don't do anything for void and other primitive types */ |
c877974e APB |
7031 | if (JPRIMITIVE_TYPE_P (something) || something == void_type_node) |
7032 | return NULL_TREE; | |
7033 | ||
23a79c61 APB |
7034 | /* Pointer types can be reall pointer types or fake pointers. When |
7035 | finding a real pointer, recheck for primitive types */ | |
7036 | if (TREE_CODE (something) == POINTER_TYPE) | |
7037 | { | |
7038 | if (TREE_TYPE (something)) | |
7039 | { | |
7040 | something = TREE_TYPE (something); | |
7041 | if (JPRIMITIVE_TYPE_P (something) || something == void_type_node) | |
7042 | return NULL_TREE; | |
7043 | } | |
7044 | else | |
7045 | something = TYPE_NAME (something); | |
7046 | } | |
7047 | ||
7048 | /* Don't do anything for arrays of primitive types */ | |
7049 | if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something) | |
7050 | && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something))) | |
7051 | return NULL_TREE; | |
7052 | ||
7053 | /* If something is not and IDENTIFIER_NODE, it can be a a TYPE_DECL | |
7054 | or a real TYPE */ | |
c877974e APB |
7055 | if (TREE_CODE (something) != IDENTIFIER_NODE) |
7056 | something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ? | |
7057 | DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something)); | |
7058 | ||
23a79c61 APB |
7059 | if (!(decl = resolve_no_layout (something, cl))) |
7060 | return NULL_TREE; | |
7061 | ||
7062 | /* Resolve and layout if necessary */ | |
7063 | layout_class_methods (TREE_TYPE (decl)); | |
7705e9db APB |
7064 | /* Check methods, but only once */ |
7065 | if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) | |
7066 | && !CLASS_LOADED_P (TREE_TYPE (decl))) | |
23a79c61 APB |
7067 | CHECK_METHODS (decl); |
7068 | if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl))) | |
8b27f225 | 7069 | safe_layout_class (TREE_TYPE (decl)); |
23a79c61 | 7070 | |
8b27f225 PB |
7071 | return decl; |
7072 | } | |
7073 | ||
7074 | /* Resolve a class, returns its decl but doesn't perform any | |
7075 | layout. The current parsing context is saved and restored */ | |
7076 | ||
7077 | static tree | |
7078 | resolve_no_layout (name, cl) | |
7079 | tree name, cl; | |
7080 | { | |
7081 | tree ptr, decl; | |
7082 | BUILD_PTR_FROM_NAME (ptr, name); | |
7083 | java_parser_context_save_global (); | |
7084 | decl = resolve_class (ptr, NULL_TREE, cl); | |
7085 | java_parser_context_restore_global (); | |
7086 | ||
7087 | return decl; | |
7088 | } | |
7089 | ||
23a79c61 | 7090 | /* Called when reporting errors. Skip leader '[' in a complex array |
82371d41 | 7091 | type description that failed to be resolved. */ |
8b27f225 | 7092 | |
49f48c71 | 7093 | static const char * |
8b27f225 | 7094 | purify_type_name (name) |
49f48c71 | 7095 | const char *name; |
8b27f225 PB |
7096 | { |
7097 | while (*name && *name == '[') | |
7098 | name++; | |
7099 | return name; | |
7100 | } | |
7101 | ||
7102 | /* The type CURRENT refers to can't be found. We print error messages. */ | |
7103 | ||
7104 | static void | |
7105 | complete_class_report_errors (dep) | |
7106 | jdep *dep; | |
7107 | { | |
49f48c71 | 7108 | const char *name; |
23a79c61 APB |
7109 | |
7110 | if (!JDEP_WFL (dep)) | |
7111 | return; | |
7112 | ||
7113 | name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))); | |
8b27f225 PB |
7114 | switch (JDEP_KIND (dep)) |
7115 | { | |
7116 | case JDEP_SUPER: | |
7117 | parse_error_context | |
7118 | (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found", | |
23a79c61 | 7119 | purify_type_name (name), |
8b27f225 PB |
7120 | IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep)))); |
7121 | break; | |
7122 | case JDEP_FIELD: | |
7123 | parse_error_context | |
7124 | (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'", | |
23a79c61 | 7125 | purify_type_name (name), |
8b27f225 PB |
7126 | IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep)))); |
7127 | break; | |
7128 | case JDEP_METHOD: /* Covers arguments */ | |
7129 | parse_error_context | |
781b0558 | 7130 | (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'", |
23a79c61 | 7131 | purify_type_name (name), |
8b27f225 PB |
7132 | IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))), |
7133 | IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep)))); | |
7134 | break; | |
7135 | case JDEP_METHOD_RETURN: /* Covers return type */ | |
7136 | parse_error_context | |
781b0558 | 7137 | (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'", |
23a79c61 | 7138 | purify_type_name (name), |
8b27f225 PB |
7139 | IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep)))); |
7140 | break; | |
7141 | case JDEP_INTERFACE: | |
7142 | parse_error_context | |
7143 | (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found", | |
7144 | IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))), | |
7145 | (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")), | |
7146 | IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep)))); | |
7147 | break; | |
7148 | case JDEP_VARIABLE: | |
7149 | parse_error_context | |
781b0558 | 7150 | (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'", |
8b27f225 PB |
7151 | purify_type_name (IDENTIFIER_POINTER |
7152 | (EXPR_WFL_NODE (JDEP_WFL (dep)))), | |
7153 | IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep)))); | |
7154 | break; | |
7155 | case JDEP_EXCEPTION: /* As specified by `throws' */ | |
7156 | parse_error_context | |
7157 | (JDEP_WFL (dep), "Class `%s' not found in `throws'", | |
7158 | IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))); | |
7159 | break; | |
7160 | default: | |
7161 | /* Fix for -Wall. Just break doing nothing. The error will be | |
7162 | caught later */ | |
7163 | break; | |
7164 | } | |
7165 | } | |
7166 | ||
7167 | /* Check uninitialized final. */ | |
7168 | ||
7169 | void | |
7170 | java_check_final () | |
7171 | { | |
7172 | } | |
7173 | ||
22eed1e6 APB |
7174 | /* Return a static string containing the DECL prototype string. If |
7175 | DECL is a constructor, use the class name instead of the form | |
7176 | <init> */ | |
7177 | ||
49f48c71 | 7178 | static const char * |
22eed1e6 APB |
7179 | get_printable_method_name (decl) |
7180 | tree decl; | |
7181 | { | |
49f48c71 | 7182 | const char *to_return; |
9ee9b555 | 7183 | tree name = NULL_TREE; |
22eed1e6 APB |
7184 | |
7185 | if (DECL_CONSTRUCTOR_P (decl)) | |
7186 | { | |
7187 | name = DECL_NAME (decl); | |
5e942c50 | 7188 | DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl))); |
22eed1e6 APB |
7189 | } |
7190 | ||
7191 | to_return = lang_printable_name (decl, 0); | |
7192 | if (DECL_CONSTRUCTOR_P (decl)) | |
7193 | DECL_NAME (decl) = name; | |
7194 | ||
7195 | return to_return; | |
7196 | } | |
7197 | ||
5e942c50 APB |
7198 | /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method |
7199 | nevertheless needs to be verfied, 1 otherwise. */ | |
7200 | ||
7201 | static int | |
7202 | reset_method_name (method) | |
7203 | tree method; | |
7204 | { | |
7f1d4866 | 7205 | if (!IS_CLINIT (method) && DECL_NAME (method) != finit_identifier_node) |
5e942c50 APB |
7206 | { |
7207 | /* NAME is just the plain name when Object is being defined */ | |
7208 | if (DECL_CONTEXT (method) != object_type_node) | |
c877974e APB |
7209 | DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ? |
7210 | init_identifier_node : GET_METHOD_NAME (method)); | |
5e942c50 APB |
7211 | return 0; |
7212 | } | |
7213 | else | |
7214 | return 1; | |
7215 | } | |
7216 | ||
c877974e APB |
7217 | /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */ |
7218 | ||
7219 | tree | |
7220 | java_get_real_method_name (method_decl) | |
7221 | tree method_decl; | |
7222 | { | |
7223 | tree method_name = DECL_NAME (method_decl); | |
7224 | if (DECL_CONSTRUCTOR_P (method_decl)) | |
7225 | return init_identifier_node; | |
82371d41 APB |
7226 | |
7227 | /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P | |
7228 | and still can be a constructor. FIXME */ | |
7229 | ||
23a79c61 APB |
7230 | /* Don't confuse method only bearing the name of their class as |
7231 | constructors */ | |
82371d41 APB |
7232 | else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl)) |
7233 | && ctxp | |
7234 | && ctxp->current_parsed_class_un == EXPR_WFL_NODE (method_name) | |
23a79c61 APB |
7235 | && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED |
7236 | && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node) | |
c877974e APB |
7237 | return init_identifier_node; |
7238 | else | |
7239 | return EXPR_WFL_NODE (method_name); | |
7240 | } | |
7241 | ||
22eed1e6 APB |
7242 | /* Track method being redefined inside the same class. As a side |
7243 | effect, set DECL_NAME to an IDENTIFIER (prior entering this | |
d77613be | 7244 | function it's a FWL, so we can track errors more accurately.) */ |
22eed1e6 | 7245 | |
8b27f225 PB |
7246 | static int |
7247 | check_method_redefinition (class, method) | |
7248 | tree class, method; | |
7249 | { | |
7250 | tree redef, name; | |
7251 | tree cl = DECL_NAME (method); | |
c3f2a476 | 7252 | tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method)); |
ba179f9f APB |
7253 | /* decl name of artificial <clinit> and $finit$ doesn't need to be |
7254 | fixed and checked */ | |
5e942c50 APB |
7255 | |
7256 | /* Reset the method name before running the check. If it returns 1, | |
7257 | the method doesn't need to be verified with respect to method | |
7258 | redeclaration and we return 0 */ | |
7259 | if (reset_method_name (method)) | |
8b27f225 | 7260 | return 0; |
5e942c50 APB |
7261 | |
7262 | name = DECL_NAME (method); | |
8b27f225 PB |
7263 | for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef)) |
7264 | { | |
c3f2a476 | 7265 | if (redef == method) |
8b27f225 | 7266 | break; |
c3f2a476 APB |
7267 | if (DECL_NAME (redef) == name |
7268 | && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef))) | |
8b27f225 | 7269 | { |
22eed1e6 APB |
7270 | parse_error_context |
7271 | (cl, "Duplicate %s declaration `%s'", | |
7272 | (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"), | |
7273 | get_printable_method_name (redef)); | |
8b27f225 PB |
7274 | return 1; |
7275 | } | |
7276 | } | |
7277 | return 0; | |
7278 | } | |
7279 | ||
d77613be APB |
7280 | static void |
7281 | check_abstract_method_definitions (do_interface, class_decl, type) | |
7282 | int do_interface; | |
7283 | tree class_decl, type; | |
7284 | { | |
7285 | tree class = TREE_TYPE (class_decl); | |
7286 | tree method, end_type; | |
7287 | ||
7288 | end_type = (do_interface ? object_type_node : type); | |
7289 | for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method)) | |
7290 | { | |
7291 | tree other_super, other_method, method_sig, method_name; | |
7292 | int found = 0; | |
7293 | ||
7294 | if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method)) | |
7295 | continue; | |
7296 | ||
7297 | /* Now verify that somewhere in between TYPE and CLASS, | |
7298 | abstract method METHOD gets a non abstract definition | |
7299 | that is inherited by CLASS. */ | |
7300 | ||
7301 | method_sig = build_java_signature (TREE_TYPE (method)); | |
7302 | method_name = DECL_NAME (method); | |
7303 | if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION) | |
7304 | method_name = EXPR_WFL_NODE (method_name); | |
7305 | ||
7306 | for (other_super = class; other_super != end_type; | |
7307 | other_super = CLASSTYPE_SUPER (other_super)) | |
7308 | { | |
7309 | for (other_method = TYPE_METHODS (other_super); other_method; | |
7310 | other_method = TREE_CHAIN (other_method)) | |
7311 | { | |
7312 | tree s = build_java_signature (TREE_TYPE (other_method)); | |
7313 | tree other_name = DECL_NAME (other_method); | |
7314 | ||
7315 | if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION) | |
7316 | other_name = EXPR_WFL_NODE (other_name); | |
7317 | if (!IS_CLINIT (other_method) | |
7318 | && !DECL_CONSTRUCTOR_P (other_method) | |
7319 | && method_name == other_name && method_sig == s) | |
7320 | { | |
7321 | found = 1; | |
7322 | break; | |
7323 | } | |
7324 | } | |
7325 | } | |
7326 | ||
7327 | /* Report that abstract METHOD didn't find an implementation | |
7328 | that CLASS can use. */ | |
7329 | if (!found) | |
7330 | { | |
c2e3db92 | 7331 | char *t = xstrdup (lang_printable_name |
d77613be APB |
7332 | (TREE_TYPE (TREE_TYPE (method)), 0)); |
7333 | tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method))); | |
7334 | tree saved_wfl = NULL_TREE; | |
7335 | ||
7336 | if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION) | |
7337 | { | |
7338 | saved_wfl = DECL_NAME (method); | |
7339 | DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method)); | |
7340 | } | |
7341 | ||
7342 | parse_error_context | |
7343 | (lookup_cl (class_decl), | |
781b0558 | 7344 | "Class `%s' doesn't define the abstract method `%s %s' from %s `%s'. This method must be defined or %s `%s' must be declared abstract", |
d77613be APB |
7345 | IDENTIFIER_POINTER (DECL_NAME (class_decl)), |
7346 | t, lang_printable_name (method, 0), | |
7347 | (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ? | |
7348 | "interface" : "class"), | |
7349 | IDENTIFIER_POINTER (ccn), | |
7350 | (CLASS_INTERFACE (class_decl) ? "interface" : "class"), | |
7351 | IDENTIFIER_POINTER (DECL_NAME (class_decl))); | |
7352 | ||
7353 | free (t); | |
7354 | ||
7355 | if (saved_wfl) | |
7356 | DECL_NAME (method) = saved_wfl; | |
7357 | } | |
7358 | } | |
7359 | } | |
7360 | ||
7361 | /* Check that CLASS_DECL somehoow implements all inherited abstract | |
7362 | methods. */ | |
7363 | ||
7364 | static void | |
7365 | java_check_abstract_method_definitions (class_decl) | |
7366 | tree class_decl; | |
7367 | { | |
7368 | tree class = TREE_TYPE (class_decl); | |
7369 | tree super, vector; | |
7370 | int i; | |
7371 | ||
7372 | if (CLASS_ABSTRACT (class_decl)) | |
7373 | return; | |
7374 | ||
7375 | /* Check for inherited types */ | |
7376 | for (super = CLASSTYPE_SUPER (class); super != object_type_node; | |
7377 | super = CLASSTYPE_SUPER (super)) | |
7378 | { | |
7379 | if (!CLASS_ABSTRACT (TYPE_NAME (super))) | |
7380 | continue; | |
7381 | ||
7382 | check_abstract_method_definitions (0, class_decl, super); | |
7383 | } | |
7384 | ||
7385 | /* Check for implemented interfaces. */ | |
7386 | vector = TYPE_BINFO_BASETYPES (class); | |
7387 | for (i = 1; i < TREE_VEC_LENGTH (vector); i++) | |
7388 | { | |
7389 | super = BINFO_TYPE (TREE_VEC_ELT (vector, i)); | |
7390 | check_abstract_method_definitions (1, class_decl, super); | |
7391 | } | |
7392 | } | |
7393 | ||
7394 | /* Check all the methods of CLASS_DECL. Methods are first completed | |
7395 | then checked according to regular method existance rules. If no | |
7396 | constructor for CLASS_DECL were encountered, then build its | |
7397 | declaration. */ | |
8b27f225 PB |
7398 | |
7399 | static void | |
7400 | java_check_regular_methods (class_decl) | |
7401 | tree class_decl; | |
7402 | { | |
5e942c50 | 7403 | int saw_constructor = 0; |
8b27f225 PB |
7404 | tree method; |
7405 | tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl)); | |
7406 | tree super_class = CLASSTYPE_SUPER (class); | |
5e942c50 | 7407 | tree saved_found_wfl = NULL_TREE, found = NULL_TREE; |
c877974e APB |
7408 | tree mthrows; |
7409 | ||
7410 | /* It is not necessary to check methods defined in java.lang.Object */ | |
7411 | if (class == object_type_node) | |
7412 | return; | |
8b27f225 | 7413 | |
23a79c61 APB |
7414 | if (!TYPE_NVIRTUALS (class)) |
7415 | TYPE_METHODS (class) = nreverse (TYPE_METHODS (class)); | |
8b27f225 PB |
7416 | |
7417 | /* Should take interfaces into account. FIXME */ | |
7418 | for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method)) | |
7419 | { | |
5e942c50 | 7420 | tree sig; |
8b27f225 PB |
7421 | tree method_wfl = DECL_NAME (method); |
7422 | int aflags; | |
7423 | ||
5e942c50 APB |
7424 | /* If we previously found something and its name was saved, |
7425 | reinstall it now */ | |
7426 | if (found && saved_found_wfl) | |
ba179f9f APB |
7427 | { |
7428 | DECL_NAME (found) = saved_found_wfl; | |
7429 | saved_found_wfl = NULL_TREE; | |
7430 | } | |
5e942c50 | 7431 | |
8b27f225 PB |
7432 | /* Check for redefinitions */ |
7433 | if (check_method_redefinition (class, method)) | |
7434 | continue; | |
7435 | ||
22eed1e6 APB |
7436 | /* If we see one constructor a mark so we don't generate the |
7437 | default one. Also skip other verifications: constructors | |
7438 | can't be inherited hence hiden or overriden */ | |
7439 | if (DECL_CONSTRUCTOR_P (method)) | |
7440 | { | |
7441 | saw_constructor = 1; | |
7442 | continue; | |
7443 | } | |
7444 | ||
c877974e APB |
7445 | /* We verify things thrown by the method. They must inherits from |
7446 | java.lang.Throwable */ | |
7447 | for (mthrows = DECL_FUNCTION_THROWS (method); | |
7448 | mthrows; mthrows = TREE_CHAIN (mthrows)) | |
7449 | { | |
7450 | if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node)) | |
7451 | parse_error_context | |
781b0558 | 7452 | (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'", |
c877974e APB |
7453 | IDENTIFIER_POINTER |
7454 | (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows))))); | |
7455 | } | |
7456 | ||
8b27f225 | 7457 | sig = build_java_argument_signature (TREE_TYPE (method)); |
8b27f225 PB |
7458 | found = lookup_argument_method (super_class, DECL_NAME (method), sig); |
7459 | ||
5e942c50 | 7460 | /* Nothing overrides or it's a private method. */ |
aabd7048 | 7461 | if (!found) |
5e942c50 | 7462 | continue; |
aabd7048 PB |
7463 | if (METHOD_PRIVATE (found)) |
7464 | { | |
7465 | found = NULL_TREE; | |
7466 | continue; | |
7467 | } | |
5e942c50 APB |
7468 | |
7469 | /* If found wasn't verified, it's DECL_NAME won't be set properly. | |
7470 | We set it temporarily for the sake of the error report. */ | |
7471 | saved_found_wfl = DECL_NAME (found); | |
7472 | reset_method_name (found); | |
7473 | ||
8b27f225 PB |
7474 | /* Can't override a method with the same name and different return |
7475 | types. */ | |
7476 | if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method))) | |
7477 | { | |
c2e3db92 | 7478 | char *t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), |
8b27f225 PB |
7479 | 0)); |
7480 | parse_error_context | |
7f10c2e2 | 7481 | (method_wfl, |
8b27f225 PB |
7482 | "Method `%s' was defined with return type `%s' in class `%s'", |
7483 | lang_printable_name (found, 0), t, | |
7484 | IDENTIFIER_POINTER | |
7485 | (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found))))); | |
7486 | free (t); | |
7487 | } | |
7488 | ||
7f10c2e2 APB |
7489 | aflags = get_access_flags_from_decl (found); |
7490 | /* If the method has default, access in an other package, then | |
7491 | issue a warning that the current method doesn't override the | |
7492 | one that was found elsewhere. Do not issue this warning when | |
7493 | the match was found in java.lang.Object. */ | |
7494 | if (DECL_CONTEXT (found) != object_type_node | |
7495 | && ((aflags & 0x7) == 0) | |
7496 | && !class_in_current_package (DECL_CONTEXT (found)) | |
1fb89a4d | 7497 | && DECL_NAME (found) != clinit_identifier_node |
7f10c2e2 APB |
7498 | && flag_not_overriding) |
7499 | { | |
7500 | parse_warning_context | |
781b0558 | 7501 | (method_wfl, "Method `%s' in class `%s' does not override the corresponding method in class `%s', which is private to a different package", |
7f10c2e2 APB |
7502 | lang_printable_name (found, 0), |
7503 | IDENTIFIER_POINTER (DECL_NAME (class_decl)), | |
7504 | IDENTIFIER_POINTER (DECL_NAME | |
7505 | (TYPE_NAME (DECL_CONTEXT (found))))); | |
7506 | continue; | |
7507 | } | |
7508 | ||
8b27f225 PB |
7509 | /* Can't override final. Can't override static. */ |
7510 | if (METHOD_FINAL (found) || METHOD_STATIC (found)) | |
7511 | { | |
7512 | /* Static *can* override static */ | |
7513 | if (METHOD_STATIC (found) && METHOD_STATIC (method)) | |
7514 | continue; | |
7515 | parse_error_context | |
7516 | (method_wfl, | |
7517 | "%s methods can't be overriden. Method `%s' is %s in class `%s'", | |
7518 | (METHOD_FINAL (found) ? "Final" : "Static"), | |
7519 | lang_printable_name (found, 0), | |
7520 | (METHOD_FINAL (found) ? "final" : "static"), | |
7521 | IDENTIFIER_POINTER | |
7522 | (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found))))); | |
7523 | continue; | |
7524 | } | |
7f10c2e2 | 7525 | |
8b27f225 PB |
7526 | /* Static method can't override instance method. */ |
7527 | if (METHOD_STATIC (method)) | |
7528 | { | |
7529 | parse_error_context | |
7530 | (method_wfl, | |
781b0558 | 7531 | "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'", |
8b27f225 PB |
7532 | lang_printable_name (found, 0), |
7533 | IDENTIFIER_POINTER | |
7534 | (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found))))); | |
7535 | continue; | |
7536 | } | |
5e942c50 | 7537 | |
5e942c50 APB |
7538 | /* - Overriding/hiding public must be public |
7539 | - Overriding/hiding protected must be protected or public | |
7540 | - If the overriden or hidden method has default (package) | |
7541 | access, then the overriding or hiding method must not be | |
7542 | private; otherwise, a compile-time error occurs */ | |
7543 | if ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method)) | |
7544 | || (METHOD_PROTECTED (found) | |
7545 | && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method))) | |
7546 | || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC)) | |
7547 | && METHOD_PRIVATE (method))) | |
8b27f225 PB |
7548 | { |
7549 | parse_error_context | |
7550 | (method_wfl, | |
781b0558 | 7551 | "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0), |
5e942c50 APB |
7552 | (METHOD_PUBLIC (method) ? "public" : |
7553 | (METHOD_PRIVATE (method) ? "private" : "protected")), | |
7554 | IDENTIFIER_POINTER (DECL_NAME | |
7555 | (TYPE_NAME (DECL_CONTEXT (found))))); | |
8b27f225 PB |
7556 | continue; |
7557 | } | |
7558 | ||
7559 | /* Overriding methods must have compatible `throws' clauses on checked | |
7560 | exceptions, if any */ | |
7561 | check_throws_clauses (method, method_wfl, found); | |
7562 | ||
8b27f225 PB |
7563 | /* Inheriting multiple methods with the same signature. FIXME */ |
7564 | } | |
7565 | ||
5e942c50 APB |
7566 | /* Don't forget eventual pending found and saved_found_wfl. Take |
7567 | into account that we might have exited because we saw an | |
d77613be | 7568 | artificial method as the last entry. */ |
5e942c50 APB |
7569 | |
7570 | if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl) | |
7571 | DECL_NAME (found) = saved_found_wfl; | |
7572 | ||
23a79c61 APB |
7573 | if (!TYPE_NVIRTUALS (class)) |
7574 | TYPE_METHODS (class) = nreverse (TYPE_METHODS (class)); | |
8b27f225 | 7575 | |
d77613be APB |
7576 | /* Search for inherited abstract method not yet implemented in this |
7577 | class. */ | |
7578 | java_check_abstract_method_definitions (class_decl); | |
7579 | ||
22eed1e6 | 7580 | if (!saw_constructor) |
781b0558 | 7581 | fatal ("No constructor found"); |
8b27f225 PB |
7582 | } |
7583 | ||
7584 | /* Return a non zero value if the `throws' clause of METHOD (if any) | |
7585 | is incompatible with the `throws' clause of FOUND (if any). */ | |
7586 | ||
7587 | static void | |
7588 | check_throws_clauses (method, method_wfl, found) | |
7589 | tree method, method_wfl, found; | |
7590 | { | |
7591 | tree mthrows, fthrows; | |
7592 | ||
c877974e APB |
7593 | /* Can't check these things with class loaded from bytecode. FIXME */ |
7594 | if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found))) | |
7595 | return; | |
7596 | ||
8b27f225 PB |
7597 | for (mthrows = DECL_FUNCTION_THROWS (method); |
7598 | mthrows; mthrows = TREE_CHAIN (mthrows)) | |
7599 | { | |
7600 | /* We don't verify unchecked expressions */ | |
c877974e | 7601 | if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows))) |
8b27f225 PB |
7602 | continue; |
7603 | /* Checked expression must be compatible */ | |
7604 | for (fthrows = DECL_FUNCTION_THROWS (found); | |
7605 | fthrows; fthrows = TREE_CHAIN (fthrows)) | |
7606 | if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows))) | |
7607 | break; | |
7608 | if (!fthrows) | |
7609 | { | |
7610 | parse_error_context | |
781b0558 | 7611 | (method_wfl, "Invalid checked exception class `%s' in `throws' clause. The exception must be a subclass of an exception thrown by `%s' from class `%s'", |
8b27f225 PB |
7612 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))), |
7613 | lang_printable_name (found, 0), | |
7614 | IDENTIFIER_POINTER | |
7615 | (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found))))); | |
7616 | } | |
7617 | } | |
7618 | } | |
7619 | ||
7620 | /* Check abstract method of interface INTERFACE */ | |
7621 | ||
7622 | static void | |
5e942c50 APB |
7623 | java_check_abstract_methods (interface_decl) |
7624 | tree interface_decl; | |
8b27f225 PB |
7625 | { |
7626 | int i, n; | |
7627 | tree method, basetype_vec, found; | |
5e942c50 | 7628 | tree interface = TREE_TYPE (interface_decl); |
8b27f225 PB |
7629 | |
7630 | for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method)) | |
7631 | { | |
7632 | tree method_wfl = DECL_NAME (method); | |
7633 | ||
7634 | /* 2- Check for double definition inside the defining interface */ | |
7635 | if (check_method_redefinition (interface, method)) | |
7636 | continue; | |
7637 | ||
7638 | /* 3- Overriding is OK as far as we preserve the return type and | |
7639 | the thrown exceptions (FIXME) */ | |
7640 | found = lookup_java_interface_method2 (interface, method); | |
7641 | if (found) | |
7642 | { | |
5e942c50 APB |
7643 | char *t; |
7644 | tree saved_found_wfl = DECL_NAME (found); | |
7645 | reset_method_name (found); | |
c2e3db92 | 7646 | t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0)); |
8b27f225 PB |
7647 | parse_error_context |
7648 | (method_wfl, | |
5e942c50 | 7649 | "Method `%s' was defined with return type `%s' in class `%s'", |
8b27f225 PB |
7650 | lang_printable_name (found, 0), t, |
7651 | IDENTIFIER_POINTER | |
7652 | (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found))))); | |
7653 | free (t); | |
5e942c50 | 7654 | DECL_NAME (found) = saved_found_wfl; |
c63b98cd | 7655 | continue; |
8b27f225 PB |
7656 | } |
7657 | } | |
7658 | ||
7659 | /* 4- Inherited methods can't differ by their returned types */ | |
7660 | if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface))) | |
7661 | return; | |
7662 | n = TREE_VEC_LENGTH (basetype_vec); | |
7663 | for (i = 0; i < n; i++) | |
7664 | { | |
7665 | tree sub_interface_method, sub_interface; | |
7666 | tree vec_elt = TREE_VEC_ELT (basetype_vec, i); | |
7667 | if (!vec_elt) | |
7668 | continue; | |
7669 | sub_interface = BINFO_TYPE (vec_elt); | |
7670 | for (sub_interface_method = TYPE_METHODS (sub_interface); | |
7671 | sub_interface_method; | |
7672 | sub_interface_method = TREE_CHAIN (sub_interface_method)) | |
7673 | { | |
7674 | found = lookup_java_interface_method2 (interface, | |
7675 | sub_interface_method); | |
7676 | if (found && (found != sub_interface_method)) | |
5e942c50 APB |
7677 | { |
7678 | tree saved_found_wfl = DECL_NAME (found); | |
7679 | reset_method_name (found); | |
7680 | parse_error_context | |
7681 | (lookup_cl (sub_interface_method), | |
781b0558 | 7682 | "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'", |
5e942c50 APB |
7683 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))), |
7684 | lang_printable_name (found, 0), | |
7685 | IDENTIFIER_POINTER | |
7686 | (DECL_NAME (TYPE_NAME | |
7687 | (DECL_CONTEXT (sub_interface_method)))), | |
7688 | IDENTIFIER_POINTER | |
7689 | (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found))))); | |
7690 | DECL_NAME (found) = saved_found_wfl; | |
7691 | } | |
8b27f225 PB |
7692 | } |
7693 | } | |
7694 | } | |
7695 | ||
8b27f225 PB |
7696 | /* Lookup methods in interfaces using their name and partial |
7697 | signature. Return a matching method only if their types differ. */ | |
7698 | ||
7699 | static tree | |
7700 | lookup_java_interface_method2 (class, method_decl) | |
7701 | tree class, method_decl; | |
7702 | { | |
7703 | int i, n; | |
7704 | tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return; | |
7705 | ||
7706 | if (!basetype_vec) | |
7707 | return NULL_TREE; | |
7708 | ||
7709 | n = TREE_VEC_LENGTH (basetype_vec); | |
7710 | for (i = 0; i < n; i++) | |
7711 | { | |
7712 | tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return; | |
7713 | if ((BINFO_TYPE (vec_elt) != object_type_node) | |
7714 | && (to_return = | |
7715 | lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1))) | |
7716 | return to_return; | |
7717 | } | |
7718 | for (i = 0; i < n; i++) | |
7719 | { | |
7720 | to_return = lookup_java_interface_method2 | |
7721 | (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl); | |
7722 | if (to_return) | |
7723 | return to_return; | |
7724 | } | |
7725 | ||
7726 | return NULL_TREE; | |
7727 | } | |
7728 | ||
7729 | /* Lookup method using their name and partial signature. Return a | |
7730 | matching method only if their types differ. */ | |
7731 | ||
7732 | static tree | |
7733 | lookup_java_method2 (clas, method_decl, do_interface) | |
7734 | tree clas, method_decl; | |
7735 | int do_interface; | |
7736 | { | |
5e942c50 APB |
7737 | tree method, method_signature, method_name, method_type, name; |
7738 | ||
8b27f225 | 7739 | method_signature = build_java_argument_signature (TREE_TYPE (method_decl)); |
5e942c50 APB |
7740 | name = DECL_NAME (method_decl); |
7741 | method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ? | |
7742 | EXPR_WFL_NODE (name) : name); | |
8b27f225 PB |
7743 | method_type = TREE_TYPE (TREE_TYPE (method_decl)); |
7744 | ||
7745 | while (clas != NULL_TREE) | |
7746 | { | |
7747 | for (method = TYPE_METHODS (clas); | |
7748 | method != NULL_TREE; method = TREE_CHAIN (method)) | |
7749 | { | |
7750 | tree method_sig = build_java_argument_signature (TREE_TYPE (method)); | |
5e942c50 APB |
7751 | tree name = DECL_NAME (method); |
7752 | if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ? | |
7753 | EXPR_WFL_NODE (name) : name) == method_name | |
8b27f225 PB |
7754 | && method_sig == method_signature |
7755 | && TREE_TYPE (TREE_TYPE (method)) != method_type) | |
5e942c50 | 7756 | return method; |
8b27f225 PB |
7757 | } |
7758 | clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas)); | |
7759 | } | |
7760 | return NULL_TREE; | |
7761 | } | |
7762 | ||
f441f671 APB |
7763 | /* Return the line that matches DECL line number, and try its best to |
7764 | position the column number. Used during error reports. */ | |
8b27f225 PB |
7765 | |
7766 | static tree | |
7767 | lookup_cl (decl) | |
7768 | tree decl; | |
7769 | { | |
7770 | static tree cl = NULL_TREE; | |
f441f671 | 7771 | char *line, *found; |
8b27f225 PB |
7772 | |
7773 | if (!decl) | |
7774 | return NULL_TREE; | |
7775 | ||
7776 | if (cl == NULL_TREE) | |
7777 | cl = build_expr_wfl (NULL_TREE, NULL, 0, 0); | |
7778 | ||
7779 | EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl)); | |
7780 | EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1); | |
7781 | ||
f441f671 APB |
7782 | line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)), |
7783 | EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl)); | |
7784 | ||
7785 | found = strstr ((const char *)line, | |
7786 | (const char *)IDENTIFIER_POINTER (DECL_NAME (decl))); | |
7787 | if (found) | |
7788 | EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line); | |
7789 | ||
8b27f225 PB |
7790 | return cl; |
7791 | } | |
7792 | ||
7793 | /* Look for a simple name in the single-type import list */ | |
7794 | ||
7795 | static tree | |
7796 | find_name_in_single_imports (name) | |
7797 | tree name; | |
7798 | { | |
7799 | tree node; | |
7800 | ||
7801 | for (node = ctxp->import_list; node; node = TREE_CHAIN (node)) | |
7802 | if (TREE_VALUE (node) == name) | |
7803 | return (EXPR_WFL_NODE (TREE_PURPOSE (node))); | |
7804 | ||
7805 | return NULL_TREE; | |
7806 | } | |
7807 | ||
7808 | /* Process all single-type import. */ | |
7809 | ||
7810 | static int | |
7811 | process_imports () | |
7812 | { | |
7813 | tree import; | |
7814 | int error_found; | |
7815 | ||
7816 | for (import = ctxp->import_list; import; import = TREE_CHAIN (import)) | |
7817 | { | |
7818 | tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import)); | |
7819 | ||
7820 | /* Don't load twice something already defined. */ | |
7821 | if (IDENTIFIER_CLASS_VALUE (to_be_found)) | |
7822 | continue; | |
7823 | QUALIFIED_P (to_be_found) = 1; | |
7824 | load_class (to_be_found, 0); | |
7825 | error_found = | |
7826 | check_pkg_class_access (to_be_found, TREE_PURPOSE (import)); | |
7827 | if (!IDENTIFIER_CLASS_VALUE (to_be_found)) | |
7828 | { | |
7829 | parse_error_context (TREE_PURPOSE (import), | |
7830 | "Class or interface `%s' not found in import", | |
7831 | IDENTIFIER_POINTER (to_be_found)); | |
7832 | return 1; | |
7833 | } | |
7834 | if (error_found) | |
7835 | return 1; | |
7836 | } | |
7837 | return 0; | |
7838 | } | |
7839 | ||
7840 | /* Possibly find a class imported by a single-type import statement. Return | |
7841 | 1 if an error occured, 0 otherwise. */ | |
7842 | ||
7843 | static int | |
7844 | find_in_imports (class_type) | |
7845 | tree class_type; | |
7846 | { | |
7847 | tree import; | |
7848 | ||
7849 | for (import = ctxp->import_list; import; import = TREE_CHAIN (import)) | |
7850 | if (TREE_VALUE (import) == TYPE_NAME (class_type)) | |
7851 | { | |
7852 | TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import)); | |
7853 | QUALIFIED_P (TYPE_NAME (class_type)) = 1; | |
8b27f225 PB |
7854 | } |
7855 | return 0; | |
7856 | } | |
7857 | ||
8b27f225 | 7858 | static int |
63a212ed | 7859 | note_possible_classname (name, len) |
49f48c71 | 7860 | const char *name; |
63a212ed | 7861 | int len; |
8b27f225 | 7862 | { |
63a212ed PB |
7863 | tree node; |
7864 | if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0) | |
7865 | len = len - 5; | |
7866 | else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0) | |
7867 | len = len - 6; | |
8b27f225 | 7868 | else |
63a212ed PB |
7869 | return 0; |
7870 | node = ident_subst (name, len, "", '/', '.', ""); | |
7871 | IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */ | |
fe0e4d76 | 7872 | QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0; |
63a212ed | 7873 | return 1; |
8b27f225 PB |
7874 | } |
7875 | ||
7876 | /* Read a import directory, gathering potential match for further type | |
7877 | references. Indifferently reads a filesystem or a ZIP archive | |
7878 | directory. */ | |
7879 | ||
7880 | static void | |
7881 | read_import_dir (wfl) | |
7882 | tree wfl; | |
7883 | { | |
63a212ed | 7884 | tree package_id = EXPR_WFL_NODE (wfl); |
49f48c71 | 7885 | const char *package_name = IDENTIFIER_POINTER (package_id); |
63a212ed | 7886 | int package_length = IDENTIFIER_LENGTH (package_id); |
8b27f225 | 7887 | DIR *dirp = NULL; |
d8fccff5 | 7888 | JCF *saved_jcf = current_jcf; |
8b27f225 | 7889 | |
63a212ed PB |
7890 | int found = 0; |
7891 | int k; | |
7892 | void *entry; | |
7893 | struct buffer filename[1]; | |
7894 | ||
8b27f225 | 7895 | |
63a212ed PB |
7896 | if (IS_AN_IMPORT_ON_DEMAND_P (package_id)) |
7897 | return; | |
7898 | IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1; | |
7899 | ||
7900 | BUFFER_INIT (filename); | |
7901 | buffer_grow (filename, package_length + 100); | |
8b27f225 | 7902 | |
63a212ed PB |
7903 | for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry)) |
7904 | { | |
49f48c71 | 7905 | const char *entry_name = jcf_path_name (entry); |
63a212ed PB |
7906 | int entry_length = strlen (entry_name); |
7907 | if (jcf_path_is_zipfile (entry)) | |
7908 | { | |
7909 | ZipFile *zipf; | |
7910 | buffer_grow (filename, entry_length); | |
7911 | memcpy (filename->data, entry_name, entry_length - 1); | |
7912 | filename->data[entry_length-1] = '\0'; | |
7913 | zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry)); | |
7914 | if (zipf == NULL) | |
7915 | error ("malformed .zip archive in CLASSPATH: %s", entry_name); | |
7916 | else | |
7917 | { | |
7918 | ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory; | |
7919 | BUFFER_RESET (filename); | |
7920 | for (k = 0; k < package_length; k++) | |
7921 | { | |
7922 | char ch = package_name[k]; | |
7923 | *filename->ptr++ = ch == '.' ? '/' : ch; | |
7924 | } | |
7925 | *filename->ptr++ = '/'; | |
7926 | ||
345137c7 | 7927 | for (k = 0; k < zipf->count; k++, zipd = ZIPDIR_NEXT (zipd)) |
63a212ed | 7928 | { |
49f48c71 | 7929 | const char *current_entry = ZIPDIR_FILENAME (zipd); |
63a212ed PB |
7930 | int current_entry_len = zipd->filename_length; |
7931 | ||
345137c7 TT |
7932 | if (current_entry_len >= BUFFER_LENGTH (filename) |
7933 | && strncmp (filename->data, current_entry, | |
7934 | BUFFER_LENGTH (filename)) != 0) | |
63a212ed | 7935 | continue; |
345137c7 | 7936 | found |= note_possible_classname (current_entry, |
63a212ed PB |
7937 | current_entry_len); |
7938 | } | |
7939 | } | |
7940 | } | |
7941 | else | |
7942 | { | |
7943 | BUFFER_RESET (filename); | |
7944 | buffer_grow (filename, entry_length + package_length + 4); | |
7945 | strcpy (filename->data, entry_name); | |
7946 | filename->ptr = filename->data + entry_length; | |
7947 | for (k = 0; k < package_length; k++) | |
7948 | { | |
7949 | char ch = package_name[k]; | |
7950 | *filename->ptr++ = ch == '.' ? '/' : ch; | |
7951 | } | |
7952 | *filename->ptr = '\0'; | |
7953 | ||
7954 | dirp = opendir (filename->data); | |
7955 | if (dirp == NULL) | |
7956 | continue; | |
7957 | *filename->ptr++ = '/'; | |
7958 | for (;;) | |
7959 | { | |
63a212ed | 7960 | int len; |
49f48c71 | 7961 | const char *d_name; |
63a212ed PB |
7962 | struct dirent *direntp = readdir (dirp); |
7963 | if (!direntp) | |
7964 | break; | |
7965 | d_name = direntp->d_name; | |
7966 | len = strlen (direntp->d_name); | |
7967 | buffer_grow (filename, len+1); | |
7968 | strcpy (filename->ptr, d_name); | |
345137c7 | 7969 | found |= note_possible_classname (filename->data + entry_length, |
63a212ed PB |
7970 | package_length+len+1); |
7971 | } | |
7972 | if (dirp) | |
7973 | closedir (dirp); | |
7974 | } | |
7975 | } | |
7976 | ||
7977 | free (filename->data); | |
7978 | ||
7979 | /* Here we should have a unified way of retrieving an entry, to be | |
7980 | indexed. */ | |
7981 | if (!found) | |
8b27f225 PB |
7982 | { |
7983 | static int first = 1; | |
7984 | if (first) | |
7985 | { | |
781b0558 | 7986 | error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives.", package_name); |
8b27f225 PB |
7987 | java_error_count++; |
7988 | first = 0; | |
7989 | } | |
7990 | else | |
63a212ed PB |
7991 | parse_error_context (wfl, "Package `%s' not found in import", |
7992 | package_name); | |
8b27f225 PB |
7993 | current_jcf = saved_jcf; |
7994 | return; | |
7995 | } | |
8b27f225 PB |
7996 | current_jcf = saved_jcf; |
7997 | } | |
7998 | ||
7999 | /* Possibly find a type in the import on demands specified | |
8000 | types. Returns 1 if an error occured, 0 otherwise. Run throught the | |
8001 | entire list, to detected potential double definitions. */ | |
8002 | ||
8003 | static int | |
8004 | find_in_imports_on_demand (class_type) | |
8005 | tree class_type; | |
8006 | { | |
ab3a6dd6 | 8007 | tree node, import, node_to_use = NULL_TREE; |
8b27f225 | 8008 | int seen_once = -1; |
ab3a6dd6 | 8009 | tree cl = NULL_TREE; |
8b27f225 PB |
8010 | |
8011 | for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import)) | |
8012 | { | |
49f48c71 | 8013 | const char *id_name; |
8b27f225 PB |
8014 | obstack_grow (&temporary_obstack, |
8015 | IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))), | |
8016 | IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import)))); | |
63a212ed | 8017 | obstack_1grow (&temporary_obstack, '.'); |
8b27f225 PB |
8018 | obstack_grow0 (&temporary_obstack, |
8019 | IDENTIFIER_POINTER (TYPE_NAME (class_type)), | |
8020 | IDENTIFIER_LENGTH (TYPE_NAME (class_type))); | |
8021 | id_name = obstack_finish (&temporary_obstack); | |
8022 | ||
8023 | node = maybe_get_identifier (id_name); | |
8024 | if (node && IS_A_CLASSFILE_NAME (node)) | |
8025 | { | |
8026 | if (seen_once < 0) | |
8027 | { | |
8028 | cl = TREE_PURPOSE (import); | |
8029 | seen_once = 1; | |
8030 | node_to_use = node; | |
8031 | } | |
8032 | else | |
8033 | { | |
8034 | seen_once++; | |
8035 | parse_error_context | |
8036 | (import, "Type `%s' also potentially defined in package `%s'", | |
8037 | IDENTIFIER_POINTER (TYPE_NAME (class_type)), | |
8038 | IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import)))); | |
8039 | } | |
8040 | } | |
8041 | } | |
8042 | ||
8043 | if (seen_once == 1) | |
8044 | { | |
8045 | /* Setup lineno so that it refers to the line of the import (in | |
8046 | case we parse a class file and encounter errors */ | |
8047 | tree decl; | |
8048 | int saved_lineno = lineno; | |
8049 | lineno = EXPR_WFL_LINENO (cl); | |
63a212ed | 8050 | TYPE_NAME (class_type) = node_to_use; |
8b27f225 PB |
8051 | QUALIFIED_P (TYPE_NAME (class_type)) = 1; |
8052 | decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type)); | |
8053 | /* If there is no DECL set for the class or if the class isn't | |
8054 | loaded and not seen in source yet, the load */ | |
8055 | if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl)) | |
8056 | && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl)))) | |
8057 | load_class (node_to_use, 0); | |
8058 | lineno = saved_lineno; | |
8059 | return check_pkg_class_access (TYPE_NAME (class_type), cl); | |
8060 | } | |
8061 | else | |
8062 | return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */ | |
8063 | } | |
8064 | ||
5e942c50 APB |
8065 | static tree |
8066 | resolve_package (pkg, next) | |
8067 | tree pkg, *next; | |
8068 | { | |
2c56429a | 8069 | tree current; |
5e942c50 | 8070 | tree type_name = NULL_TREE; |
49f48c71 | 8071 | const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg)); |
5e942c50 APB |
8072 | |
8073 | /* The trick is to determine when the package name stops and were | |
8074 | the name of something contained in the package starts. Then we | |
8075 | return a fully qualified name of what we want to get. */ | |
8076 | ||
8077 | /* Do a quick search on well known package names */ | |
8078 | if (!strncmp (name, "java.lang.reflect", 17)) | |
8079 | { | |
8080 | *next = | |
8081 | TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)))); | |
8082 | type_name = lookup_package_type (name, 17); | |
8083 | } | |
8084 | else if (!strncmp (name, "java.lang", 9)) | |
8085 | { | |
8086 | *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))); | |
8087 | type_name = lookup_package_type (name, 9); | |
8088 | } | |
5e942c50 | 8089 | |
2c56429a APB |
8090 | /* If we found something here, return */ |
8091 | if (type_name) | |
8092 | return type_name; | |
8093 | ||
8094 | *next = EXPR_WFL_QUALIFICATION (pkg); | |
8095 | ||
8096 | /* Try the current package. */ | |
8097 | if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package), | |
8098 | IDENTIFIER_LENGTH (ctxp->package))) | |
8099 | { | |
8100 | type_name = | |
8101 | lookup_package_type_and_set_next (name, | |
8102 | IDENTIFIER_LENGTH (ctxp->package), | |
8103 | next ); | |
8104 | if (type_name) | |
8105 | return type_name; | |
8106 | } | |
8107 | ||
8108 | /* Search in imported package */ | |
8109 | for (current = ctxp->import_list; current; current = TREE_CHAIN (current)) | |
8110 | { | |
8111 | tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current)); | |
8112 | int len = IDENTIFIER_LENGTH (current_pkg_name); | |
8113 | if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len)) | |
8114 | { | |
8115 | tree left, dummy; | |
8116 | ||
8117 | breakdown_qualified (&left, &dummy, current_pkg_name); | |
8118 | len = IDENTIFIER_LENGTH (left); | |
8119 | type_name = lookup_package_type_and_set_next (name, len, next); | |
8120 | if (type_name) | |
8121 | break; | |
8122 | } | |
8123 | } | |
8124 | ||
8125 | return type_name; | |
8126 | } | |
8127 | ||
8128 | static tree | |
8129 | lookup_package_type_and_set_next (name, len, next) | |
49f48c71 | 8130 | const char *name; |
2c56429a APB |
8131 | int len; |
8132 | tree *next; | |
8133 | { | |
49f48c71 | 8134 | const char *ptr; |
2c56429a APB |
8135 | tree type_name = lookup_package_type (name, len); |
8136 | ||
8137 | if (!type_name) | |
8138 | return NULL; | |
8139 | ||
8140 | ptr = IDENTIFIER_POINTER (type_name); | |
8141 | while (ptr && (ptr = strchr (ptr, '.'))) | |
8142 | { | |
8143 | *next = TREE_CHAIN (*next); | |
8144 | ptr++; | |
8145 | } | |
5e942c50 APB |
8146 | return type_name; |
8147 | } | |
8148 | ||
8149 | static tree | |
8150 | lookup_package_type (name, from) | |
49f48c71 | 8151 | const char *name; |
5e942c50 APB |
8152 | int from; |
8153 | { | |
8154 | char subname [128]; | |
49f48c71 | 8155 | const char *sub = &name[from+1]; |
5e942c50 APB |
8156 | while (*sub != '.' && *sub) |
8157 | sub++; | |
8158 | strncpy (subname, name, sub-name); | |
8159 | subname [sub-name] = '\0'; | |
8160 | return get_identifier (subname); | |
8161 | } | |
8162 | ||
8b27f225 PB |
8163 | /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no |
8164 | access violations were found, 1 otherwise. */ | |
8165 | ||
8166 | static int | |
8167 | check_pkg_class_access (class_name, cl) | |
8168 | tree class_name; | |
8169 | tree cl; | |
8170 | { | |
8171 | tree type; | |
8172 | ||
8173 | if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name)) | |
8174 | return 0; | |
8175 | ||
8176 | if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name)))) | |
8177 | return 0; | |
8178 | ||
8179 | if (!CLASS_PUBLIC (TYPE_NAME (type))) | |
8180 | { | |
78d21f92 PB |
8181 | /* Access to a private class within the same package is |
8182 | allowed. */ | |
8183 | tree l, r; | |
8184 | breakdown_qualified (&l, &r, class_name); | |
8185 | if (l == ctxp->package) | |
8186 | return 0; | |
8187 | ||
8b27f225 | 8188 | parse_error_context |
781b0558 | 8189 | (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed", |
8b27f225 PB |
8190 | (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"), |
8191 | IDENTIFIER_POINTER (class_name)); | |
8192 | return 1; | |
8193 | } | |
8194 | return 0; | |
8195 | } | |
8196 | ||
8197 | /* Local variable declaration. */ | |
8198 | ||
8199 | static void | |
8200 | declare_local_variables (modifier, type, vlist) | |
8201 | int modifier; | |
8202 | tree type; | |
8203 | tree vlist; | |
8204 | { | |
8205 | tree decl, current, saved_type; | |
8206 | tree type_wfl = NULL_TREE; | |
8207 | int must_chain = 0; | |
8208 | ||
2aa11e97 | 8209 | /* Push a new block if statements were seen between the last time we |
8b27f225 | 8210 | pushed a block and now. Keep a cound of block to close */ |
f099f336 | 8211 | if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl))) |
8b27f225 | 8212 | { |
f099f336 | 8213 | tree body = GET_CURRENT_BLOCK (current_function_decl); |
8b27f225 | 8214 | tree b = enter_block (); |
f099f336 | 8215 | BLOCK_EXPR_ORIGIN (b) = body; |
8b27f225 PB |
8216 | } |
8217 | ||
8218 | if (modifier) | |
8219 | { | |
8220 | int i; | |
8221 | for (i = 0; i <= 10; i++) if (1 << i & modifier) break; | |
c877974e APB |
8222 | if (modifier == ACC_FINAL) |
8223 | { | |
8224 | if (flag_static_local_jdk1_1) | |
8225 | parse_warning_context (ctxp->modifier_ctx [i], | |
781b0558 | 8226 | "Unsupported JDK1.1 `final' local variable (treated as non final)"); |
c877974e APB |
8227 | } |
8228 | else | |
8229 | { | |
8230 | parse_error_context | |
8231 | (ctxp->modifier_ctx [i], | |
8232 | "Only `final' is allowed as a local variables modifier"); | |
8233 | return; | |
8234 | } | |
8b27f225 PB |
8235 | } |
8236 | ||
8237 | /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will | |
8238 | hold the TYPE value if a new incomplete has to be created (as | |
8239 | opposed to being found already existing and reused). */ | |
8240 | SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain); | |
8241 | ||
8242 | /* If TYPE is fully resolved and we don't have a reference, make one */ | |
1886c9d8 | 8243 | PROMOTE_RECORD_IF_COMPLETE (type, must_chain); |
8b27f225 PB |
8244 | |
8245 | /* Go through all the declared variables */ | |
8246 | for (current = vlist, saved_type = type; current; | |
8247 | current = TREE_CHAIN (current), type = saved_type) | |
8248 | { | |
c877974e | 8249 | tree other, real_type; |
8b27f225 PB |
8250 | tree wfl = TREE_PURPOSE (current); |
8251 | tree name = EXPR_WFL_NODE (wfl); | |
8252 | tree init = TREE_VALUE (current); | |
8253 | ||
8254 | /* Process NAME, as it may specify extra dimension(s) for it */ | |
8255 | type = build_array_from_name (type, type_wfl, name, &name); | |
8256 | ||
8257 | /* Variable redefinition check */ | |
8258 | if ((other = lookup_name_in_blocks (name))) | |
8259 | { | |
8260 | variable_redefinition_error (wfl, name, TREE_TYPE (other), | |
8261 | DECL_SOURCE_LINE (other)); | |
8262 | continue; | |
8263 | } | |
8264 | ||
8265 | /* Type adjustment. We may have just readjusted TYPE because | |
8266 | the variable specified more dimensions. Make sure we have | |
8267 | a reference if we can and don't have one already. */ | |
1886c9d8 | 8268 | PROMOTE_RECORD_IF_COMPLETE (type, must_chain); |
c877974e APB |
8269 | |
8270 | real_type = GET_REAL_TYPE (type); | |
8b27f225 PB |
8271 | /* Never layout this decl. This will be done when its scope |
8272 | will be entered */ | |
c877974e | 8273 | decl = build_decl (VAR_DECL, name, real_type); |
8b27f225 PB |
8274 | BLOCK_CHAIN_DECL (decl); |
8275 | ||
d4370213 APB |
8276 | /* If doing xreferencing, replace the line number with the WFL |
8277 | compound value */ | |
8278 | if (flag_emit_xref) | |
8279 | DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl); | |
8280 | ||
8b27f225 PB |
8281 | /* Don't try to use an INIT statement when an error was found */ |
8282 | if (init && java_error_count) | |
8283 | init = NULL_TREE; | |
8284 | ||
8285 | /* Add the initialization function to the current function's code */ | |
8286 | if (init) | |
8287 | { | |
8288 | /* Name might have been readjusted */ | |
8289 | EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name; | |
8290 | MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1; | |
8291 | java_method_add_stmt (current_function_decl, | |
8292 | build_debugable_stmt (EXPR_WFL_LINECOL (init), | |
8293 | init)); | |
8294 | } | |
8295 | ||
8296 | /* Setup dependency the type of the decl */ | |
8297 | if (must_chain) | |
8298 | { | |
8299 | jdep *dep; | |
8300 | register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type); | |
8301 | dep = CLASSD_LAST (ctxp->classd_list); | |
8302 | JDEP_GET_PATCH (dep) = &TREE_TYPE (decl); | |
8303 | } | |
8304 | } | |
8305 | SOURCE_FRONTEND_DEBUG (("Defined locals")); | |
8306 | } | |
8307 | ||
8308 | /* Called during parsing. Build decls from argument list. */ | |
8309 | ||
8310 | static void | |
8311 | source_start_java_method (fndecl) | |
8312 | tree fndecl; | |
8313 | { | |
8314 | tree tem; | |
8315 | tree parm_decl; | |
8316 | int i; | |
8317 | ||
79d13333 APB |
8318 | if (!fndecl) |
8319 | return; | |
8320 | ||
8b27f225 PB |
8321 | current_function_decl = fndecl; |
8322 | ||
8323 | /* New scope for the function */ | |
8324 | enter_block (); | |
8325 | for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0; | |
82371d41 | 8326 | tem != end_params_node; tem = TREE_CHAIN (tem), i++) |
8b27f225 PB |
8327 | { |
8328 | tree type = TREE_VALUE (tem); | |
8329 | tree name = TREE_PURPOSE (tem); | |
8330 | ||
23a79c61 APB |
8331 | /* If type is incomplete. Create an incomplete decl and ask for |
8332 | the decl to be patched later */ | |
8b27f225 PB |
8333 | if (INCOMPLETE_TYPE_P (type)) |
8334 | { | |
8335 | jdep *jdep; | |
c877974e APB |
8336 | tree real_type = GET_REAL_TYPE (type); |
8337 | parm_decl = build_decl (PARM_DECL, name, real_type); | |
23a79c61 | 8338 | type = obtain_incomplete_type (type); |
8b27f225 PB |
8339 | register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type); |
8340 | jdep = CLASSD_LAST (ctxp->classd_list); | |
8341 | JDEP_MISC (jdep) = name; | |
8342 | JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl); | |
8343 | } | |
8344 | else | |
8345 | parm_decl = build_decl (PARM_DECL, name, type); | |
8346 | ||
8347 | BLOCK_CHAIN_DECL (parm_decl); | |
8348 | } | |
8349 | tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)); | |
8350 | BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) = | |
8351 | nreverse (tem); | |
8352 | DECL_ARG_SLOT_COUNT (current_function_decl) = i; | |
8353 | } | |
8354 | ||
22eed1e6 APB |
8355 | /* Called during parsing. Creates an artificial method declaration. */ |
8356 | ||
8357 | static tree | |
8358 | create_artificial_method (class, flags, type, name, args) | |
8359 | tree class; | |
8360 | int flags; | |
8361 | tree type, name, args; | |
8362 | { | |
8363 | int saved_lineno = lineno; | |
8364 | tree mdecl; | |
8365 | ||
8366 | lineno = 0; | |
8367 | mdecl = make_node (FUNCTION_TYPE); | |
8368 | TREE_TYPE (mdecl) = type; | |
8369 | TYPE_ARG_TYPES (mdecl) = args; | |
8370 | mdecl = add_method (class, flags, name, build_java_signature (mdecl)); | |
8371 | lineno = saved_lineno; | |
8372 | DECL_ARTIFICIAL (mdecl) = 1; | |
8373 | return mdecl; | |
8374 | } | |
8375 | ||
8376 | /* Starts the body if an artifical method. */ | |
8377 | ||
8378 | static void | |
8379 | start_artificial_method_body (mdecl) | |
8380 | tree mdecl; | |
8381 | { | |
8382 | DECL_SOURCE_LINE (mdecl) = 1; | |
8383 | DECL_SOURCE_LINE_MERGE (mdecl, 1); | |
8384 | source_start_java_method (mdecl); | |
8385 | enter_block (); | |
8386 | } | |
8387 | ||
8388 | static void | |
8389 | end_artificial_method_body (mdecl) | |
8390 | tree mdecl; | |
8391 | { | |
8392 | BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block (); | |
8393 | exit_block (); | |
8394 | } | |
8395 | ||
8b27f225 PB |
8396 | /* Called during expansion. Push decls formerly built from argument |
8397 | list so they're usable during expansion. */ | |
8398 | ||
8399 | static void | |
8400 | expand_start_java_method (fndecl) | |
8401 | tree fndecl; | |
8402 | { | |
8403 | tree tem, *ptr; | |
8404 | ||
8405 | current_function_decl = fndecl; | |
8406 | ||
8407 | announce_function (fndecl); | |
8408 | pushlevel (1); /* Push parameters */ | |
8409 | ptr = &DECL_ARGUMENTS (fndecl); | |
8410 | tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)); | |
8411 | while (tem) | |
8412 | { | |
8413 | tree next = TREE_CHAIN (tem); | |
8414 | tree type = TREE_TYPE (tem); | |
e438e1b7 JJ |
8415 | if (PROMOTE_PROTOTYPES |
8416 | && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node) | |
8b27f225 PB |
8417 | && INTEGRAL_TYPE_P (type)) |
8418 | type = integer_type_node; | |
8b27f225 PB |
8419 | DECL_ARG_TYPE (tem) = type; |
8420 | layout_decl (tem, 0); | |
8421 | pushdecl (tem); | |
8b27f225 PB |
8422 | *ptr = tem; |
8423 | ptr = &TREE_CHAIN (tem); | |
8424 | tem = next; | |
8425 | } | |
8426 | *ptr = NULL_TREE; | |
8427 | pushdecl_force_head (DECL_ARGUMENTS (fndecl)); | |
8428 | lineno = DECL_SOURCE_LINE_FIRST (fndecl); | |
8b27f225 PB |
8429 | } |
8430 | ||
8431 | /* Terminate a function and expand its body. */ | |
8432 | ||
8433 | static void | |
8434 | source_end_java_method () | |
8435 | { | |
8436 | tree fndecl = current_function_decl; | |
138657ec | 8437 | int flag_asynchronous_exceptions = asynchronous_exceptions; |
8b27f225 | 8438 | |
79d13333 APB |
8439 | if (!fndecl) |
8440 | return; | |
8441 | ||
8b27f225 PB |
8442 | java_parser_context_save_global (); |
8443 | lineno = ctxp->last_ccb_indent1; | |
8444 | ||
8445 | /* Set EH language codes */ | |
8446 | java_set_exception_lang_code (); | |
8447 | ||
5423609c APB |
8448 | /* Turn function bodies with only a NOP expr null, so they don't get |
8449 | generated at all and we won't get warnings when using the -W | |
8450 | -Wall flags. */ | |
8451 | if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node) | |
8452 | BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE; | |
8453 | ||
8b27f225 PB |
8454 | /* Generate function's code */ |
8455 | if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) | |
5423609c APB |
8456 | && ! flag_emit_class_files |
8457 | && ! flag_emit_xref) | |
8b27f225 PB |
8458 | expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))); |
8459 | ||
8460 | /* pop out of its parameters */ | |
8461 | pushdecl_force_head (DECL_ARGUMENTS (fndecl)); | |
8462 | poplevel (1, 0, 1); | |
8463 | BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl; | |
8464 | ||
8465 | /* Generate rtl for function exit. */ | |
5423609c | 8466 | if (! flag_emit_class_files && ! flag_emit_xref) |
8b27f225 PB |
8467 | { |
8468 | lineno = DECL_SOURCE_LINE_LAST (fndecl); | |
8469 | /* Emit catch-finally clauses */ | |
8470 | emit_handlers (); | |
8471 | expand_function_end (input_filename, lineno, 0); | |
8472 | ||
138657ec AH |
8473 | /* FIXME: If the current method contains any exception handlers, |
8474 | force asynchronous_exceptions: this is necessary because signal | |
8475 | handlers in libjava may throw exceptions. This is far from being | |
8476 | a perfect solution, but it's better than doing nothing at all.*/ | |
8477 | if (catch_clauses) | |
8478 | asynchronous_exceptions = 1; | |
8479 | ||
8b27f225 PB |
8480 | /* Run the optimizers and output assembler code for this function. */ |
8481 | rest_of_compilation (fndecl); | |
8482 | } | |
8483 | ||
8484 | current_function_decl = NULL_TREE; | |
8226320b | 8485 | permanent_allocation (1); |
8b27f225 | 8486 | java_parser_context_restore_global (); |
138657ec | 8487 | asynchronous_exceptions = flag_asynchronous_exceptions; |
8b27f225 PB |
8488 | } |
8489 | ||
8490 | /* Record EXPR in the current function block. Complements compound | |
8491 | expression second operand if necessary. */ | |
8492 | ||
8493 | tree | |
8494 | java_method_add_stmt (fndecl, expr) | |
8495 | tree fndecl, expr; | |
8496 | { | |
b771925e APB |
8497 | if (!GET_CURRENT_BLOCK (fndecl)) |
8498 | return NULL_TREE; | |
f099f336 | 8499 | return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr); |
8b27f225 PB |
8500 | } |
8501 | ||
8502 | static tree | |
8503 | add_stmt_to_block (b, type, stmt) | |
8504 | tree b, type, stmt; | |
8505 | { | |
8506 | tree body = BLOCK_EXPR_BODY (b), c; | |
8507 | ||
8508 | if (java_error_count) | |
8509 | return body; | |
8510 | ||
8511 | if ((c = add_stmt_to_compound (body, type, stmt)) == body) | |
8512 | return body; | |
8513 | ||
8514 | BLOCK_EXPR_BODY (b) = c; | |
8515 | TREE_SIDE_EFFECTS (c) = 1; | |
8516 | return c; | |
8517 | } | |
8518 | ||
8519 | /* Add STMT to EXISTING if possible, otherwise create a new | |
8520 | COMPOUND_EXPR and add STMT to it. */ | |
8521 | ||
8522 | static tree | |
8523 | add_stmt_to_compound (existing, type, stmt) | |
8524 | tree existing, type, stmt; | |
8525 | { | |
12472854 PB |
8526 | if (existing) |
8527 | return build (COMPOUND_EXPR, type, existing, stmt); | |
8b27f225 | 8528 | else |
12472854 | 8529 | return stmt; |
8b27f225 PB |
8530 | } |
8531 | ||
8532 | /* Hold THIS for the scope of the current public method decl. */ | |
8533 | static tree current_this; | |
8534 | ||
1886c9d8 APB |
8535 | void java_layout_seen_class_methods () |
8536 | { | |
8537 | tree previous_list = all_class_list; | |
8538 | tree end = NULL_TREE; | |
8539 | tree current; | |
8540 | ||
8541 | while (1) | |
8542 | { | |
8543 | for (current = previous_list; | |
8544 | current != end; current = TREE_CHAIN (current)) | |
8545 | layout_class_methods (TREE_TYPE (TREE_VALUE (current))); | |
8546 | ||
8547 | if (previous_list != all_class_list) | |
8548 | { | |
8549 | end = previous_list; | |
8550 | previous_list = all_class_list; | |
8551 | } | |
8552 | else | |
8553 | break; | |
8554 | } | |
8555 | } | |
8556 | ||
23a79c61 APB |
8557 | /* Layout the methods of all classes loaded in one way on an |
8558 | other. Check methods of source parsed classes. Then reorder the | |
8559 | fields and layout the classes or the type of all source parsed | |
8560 | classes */ | |
8b27f225 PB |
8561 | |
8562 | void | |
8563 | java_layout_classes () | |
8564 | { | |
8565 | tree current; | |
bc3ca41b | 8566 | int save_error_count = java_error_count; |
5e942c50 | 8567 | |
23a79c61 | 8568 | /* Layout the methods of all classes seen so far */ |
1886c9d8 | 8569 | java_layout_seen_class_methods (); |
23a79c61 APB |
8570 | java_parse_abort_on_error (); |
8571 | all_class_list = NULL_TREE; | |
8572 | ||
8573 | /* Then check the methods of all parsed classes */ | |
8574 | for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current)) | |
8575 | if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current)))) | |
8576 | CHECK_METHODS (TREE_VALUE (current)); | |
8577 | java_parse_abort_on_error (); | |
8578 | ||
5e942c50 | 8579 | for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current)) |
8b27f225 | 8580 | { |
5e942c50 | 8581 | current_class = TREE_TYPE (TREE_VALUE (current)); |
22eed1e6 | 8582 | |
c877974e APB |
8583 | /* Reverse the fields, but leave the dummy field in front. |
8584 | Fields are already ordered for Object and Class */ | |
8585 | if (TYPE_FIELDS (current_class) && current_class != object_type_node | |
8586 | && current_class != class_type_node) | |
8587 | { | |
23a79c61 APB |
8588 | /* If the dummy field is there, reverse the right fields and |
8589 | just layout the type for proper fields offset */ | |
c877974e APB |
8590 | if (!DECL_NAME (TYPE_FIELDS (current_class))) |
8591 | { | |
8592 | tree fields = TYPE_FIELDS (current_class); | |
8593 | TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields)); | |
8594 | TYPE_SIZE (current_class) = NULL_TREE; | |
8595 | layout_type (current_class); | |
8596 | } | |
23a79c61 APB |
8597 | /* We don't have a dummy field, we need to layout the class, |
8598 | after having reversed the fields */ | |
c877974e APB |
8599 | else |
8600 | { | |
8601 | TYPE_FIELDS (current_class) = | |
8602 | nreverse (TYPE_FIELDS (current_class)); | |
8603 | TYPE_SIZE (current_class) = NULL_TREE; | |
8604 | layout_class (current_class); | |
8605 | } | |
8606 | } | |
23a79c61 APB |
8607 | else |
8608 | layout_class (current_class); | |
5e942c50 | 8609 | |
c877974e APB |
8610 | /* From now on, the class is considered completely loaded */ |
8611 | CLASS_LOADED_P (current_class) = 1; | |
8612 | ||
5e942c50 APB |
8613 | /* Error reported by the caller */ |
8614 | if (java_error_count) | |
8615 | return; | |
8b27f225 | 8616 | } |
23a79c61 APB |
8617 | |
8618 | /* We might have reloaded classes durign the process of laying out | |
8619 | classes for code generation. We must layout the methods of those | |
8620 | late additions, as constructor checks might use them */ | |
1886c9d8 | 8621 | java_layout_seen_class_methods (); |
23a79c61 | 8622 | java_parse_abort_on_error (); |
8b27f225 PB |
8623 | } |
8624 | ||
8625 | /* Expand all methods in all registered classes. */ | |
8626 | ||
49f48c71 | 8627 | static void |
8b27f225 PB |
8628 | java_complete_expand_methods () |
8629 | { | |
8630 | tree current; | |
ce6e9147 APB |
8631 | |
8632 | do_not_fold = flag_emit_xref; | |
8b27f225 PB |
8633 | |
8634 | for (current = ctxp->class_list; current; current = TREE_CHAIN (current)) | |
8635 | { | |
7f1d4866 | 8636 | int is_interface; |
8b27f225 | 8637 | tree class_type = CLASS_TO_HANDLE_TYPE (TREE_TYPE (current)); |
781b0558 | 8638 | tree decl, prev_decl; |
8b27f225 PB |
8639 | |
8640 | current_class = TREE_TYPE (current); | |
7f1d4866 | 8641 | is_interface = CLASS_INTERFACE (TYPE_NAME (current_class)); |
8b27f225 PB |
8642 | |
8643 | /* Initialize a new constant pool */ | |
8644 | init_outgoing_cpool (); | |
8645 | ||
63a212ed | 8646 | /* We want <clinit> (if any) to be processed first. */ |
781b0558 KG |
8647 | for (prev_decl = NULL_TREE, decl = TYPE_METHODS (class_type); |
8648 | decl; prev_decl= decl, decl = TREE_CHAIN (decl)) | |
8649 | if (IS_CLINIT (decl)) | |
8650 | { | |
8651 | if (!java_pre_expand_clinit (decl)) | |
8652 | { | |
8653 | if (prev_decl) | |
8654 | TREE_CHAIN (prev_decl) = TREE_CHAIN (decl); | |
8655 | else | |
8656 | TYPE_METHODS (class_type) = TREE_CHAIN (decl); | |
8657 | } | |
8658 | break; | |
8659 | } | |
cd9643f7 | 8660 | |
781b0558 | 8661 | /* Now go on for regular business. */ |
7f1d4866 APB |
8662 | for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl)) |
8663 | { | |
7f1d4866 APB |
8664 | current_function_decl = decl; |
8665 | /* Don't generate debug info on line zero when expanding a | |
8666 | generated constructor. */ | |
8667 | if (DECL_CONSTRUCTOR_P (decl) && !DECL_FUNCTION_BODY (decl)) | |
8668 | { | |
8669 | /* If we found errors, it's too dangerous to try to | |
8670 | generate and expand a constructor */ | |
8671 | if (!java_error_count) | |
8672 | { | |
8673 | restore_line_number_status (1); | |
8674 | java_complete_expand_method (decl); | |
8675 | restore_line_number_status (0); | |
8b27f225 | 8676 | } |
7f1d4866 APB |
8677 | } |
8678 | else if (METHOD_ABSTRACT (decl) || METHOD_NATIVE (decl)) | |
8679 | continue; | |
8680 | else | |
8681 | java_complete_expand_method (decl); | |
8682 | } | |
8b27f225 | 8683 | |
22eed1e6 APB |
8684 | /* Now verify constructor circularity (stop after the first one |
8685 | we find) */ | |
7f1d4866 | 8686 | if (!is_interface) |
22eed1e6 APB |
8687 | for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl)) |
8688 | if (DECL_CONSTRUCTOR_P (decl) && | |
8689 | verify_constructor_circularity (decl, decl)) | |
8690 | break; | |
8691 | ||
8b27f225 PB |
8692 | /* Make the class data, register it and run the rest of decl |
8693 | compilation on it */ | |
63a212ed PB |
8694 | if (!java_error_count) |
8695 | { | |
8696 | if (flag_emit_class_files) | |
8697 | write_classfile (current_class); | |
f099f336 APB |
8698 | if (flag_emit_xref) |
8699 | expand_xref (current_class); | |
aabd7048 | 8700 | else if (! flag_syntax_only) |
d593dd8c | 8701 | finish_class (); |
63a212ed | 8702 | } |
8b27f225 PB |
8703 | } |
8704 | } | |
8705 | ||
8706 | /* Hold a list of catch clauses list. The first element of this list is | |
8707 | the list of the catch clauses of the currently analysed try block. */ | |
8708 | static tree currently_caught_type_list; | |
8709 | ||
781b0558 KG |
8710 | /* Complete and expand <clinit>. Return a non zero value if <clinit> |
8711 | is worth keeping. */ | |
8712 | ||
8713 | static int | |
8714 | java_pre_expand_clinit (decl) | |
8715 | tree decl; | |
8716 | { | |
8717 | tree fbody = DECL_FUNCTION_BODY (decl); | |
781b0558 KG |
8718 | int to_return = 1; |
8719 | ||
8720 | if (fbody != NULL_TREE) | |
8721 | { | |
8722 | /* First check if we can ignore empty <clinit> */ | |
8723 | tree block_body = BLOCK_EXPR_BODY (fbody); | |
8724 | ||
8725 | current_this = NULL_TREE; | |
8726 | current_function_decl = decl; | |
8727 | if (block_body != NULL_TREE) | |
8728 | { | |
8729 | /* Prevent the use of `this' inside <clinit> */ | |
8730 | ctxp->explicit_constructor_p = 1; | |
8731 | block_body = java_complete_tree (block_body); | |
8732 | ctxp->explicit_constructor_p = 0; | |
8733 | ||
8734 | BLOCK_EXPR_BODY (fbody) = block_body; | |
8735 | if (block_body != NULL_TREE && TREE_CODE (block_body) == BLOCK | |
8736 | && BLOCK_EXPR_BODY (block_body) == empty_stmt_node) | |
8737 | to_return = 0; | |
8738 | } | |
8739 | } | |
8740 | return to_return; | |
8741 | } | |
8742 | ||
8b27f225 PB |
8743 | /* Complete and expand a method. */ |
8744 | ||
8745 | static void | |
8746 | java_complete_expand_method (mdecl) | |
8747 | tree mdecl; | |
8748 | { | |
22eed1e6 APB |
8749 | /* Fix constructors before expanding them */ |
8750 | if (DECL_CONSTRUCTOR_P (mdecl)) | |
8751 | fix_constructors (mdecl); | |
8b27f225 | 8752 | |
22eed1e6 | 8753 | /* Expand functions that have a body */ |
8b27f225 PB |
8754 | if (DECL_FUNCTION_BODY (mdecl)) |
8755 | { | |
c877974e APB |
8756 | tree fbody = DECL_FUNCTION_BODY (mdecl); |
8757 | tree block_body = BLOCK_EXPR_BODY (fbody); | |
cd531a2e | 8758 | tree exception_copy = NULL_TREE; |
8b27f225 | 8759 | expand_start_java_method (mdecl); |
939d7216 | 8760 | build_result_decl (mdecl); |
8b27f225 PB |
8761 | |
8762 | current_this | |
8763 | = (!METHOD_STATIC (mdecl) ? | |
8764 | BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE); | |
8765 | ||
ce6e9147 APB |
8766 | /* Purge the `throws' list of unchecked exceptions. If we're |
8767 | doing xref, save a copy of the list and re-install it | |
8768 | later. */ | |
8769 | if (flag_emit_xref) | |
8770 | exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl)); | |
8771 | ||
8b27f225 PB |
8772 | purge_unchecked_exceptions (mdecl); |
8773 | ||
8774 | /* Install exceptions thrown with `throws' */ | |
8775 | PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl)); | |
8776 | ||
c877974e | 8777 | if (block_body != NULL_TREE) |
bc3ca41b PB |
8778 | { |
8779 | block_body = java_complete_tree (block_body); | |
ce6e9147 APB |
8780 | if (!flag_emit_xref) |
8781 | check_for_initialization (block_body); | |
f099f336 | 8782 | ctxp->explicit_constructor_p = 0; |
bc3ca41b | 8783 | } |
c877974e | 8784 | BLOCK_EXPR_BODY (fbody) = block_body; |
5e942c50 | 8785 | |
c877974e | 8786 | if ((block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body)) |
ce6e9147 APB |
8787 | && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE |
8788 | && !flag_emit_xref) | |
82371d41 | 8789 | missing_return_error (current_function_decl); |
63a212ed | 8790 | |
939d7216 PB |
8791 | complete_start_java_method (mdecl); |
8792 | ||
8b27f225 PB |
8793 | /* Don't go any further if we've found error(s) during the |
8794 | expansion */ | |
8795 | if (!java_error_count) | |
8796 | source_end_java_method (); | |
22eed1e6 APB |
8797 | else |
8798 | { | |
8799 | pushdecl_force_head (DECL_ARGUMENTS (mdecl)); | |
8800 | poplevel (1, 0, 1); | |
8801 | } | |
8b27f225 PB |
8802 | |
8803 | /* Pop the exceptions and sanity check */ | |
8804 | POP_EXCEPTIONS(); | |
8805 | if (currently_caught_type_list) | |
8806 | fatal ("Exception list non empty - java_complete_expand_method"); | |
ce6e9147 APB |
8807 | |
8808 | if (flag_emit_xref) | |
8809 | DECL_FUNCTION_THROWS (mdecl) = exception_copy; | |
8b27f225 PB |
8810 | } |
8811 | } | |
8812 | ||
22eed1e6 APB |
8813 | /* Craft a body for default constructor. Patch existing constructor |
8814 | bodies with call to super() and field initialization statements if | |
8815 | necessary. */ | |
8816 | ||
8817 | static void | |
8818 | fix_constructors (mdecl) | |
8819 | tree mdecl; | |
8820 | { | |
8821 | tree body = DECL_FUNCTION_BODY (mdecl); | |
22eed1e6 | 8822 | |
22eed1e6 APB |
8823 | if (!body) |
8824 | { | |
ac825856 APB |
8825 | /* The constructor body must be crafted by hand. It's the |
8826 | constructor we defined when we realize we didn't have the | |
8827 | CLASSNAME() constructor */ | |
8828 | ||
22eed1e6 APB |
8829 | tree compound; |
8830 | ||
8831 | /* It is an error for the compiler to generate a default | |
8832 | constructor if the superclass doesn't have a constructor that | |
8833 | takes no argument */ | |
8834 | if (verify_constructor_super ()) | |
8835 | { | |
8836 | tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (current_class)); | |
49f48c71 | 8837 | const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl)); |
781b0558 KG |
8838 | parse_error_context |
8839 | (lookup_cl (TYPE_NAME (current_class)), | |
8840 | "No constructor matching `%s()' found in class `%s'", n, n); | |
22eed1e6 APB |
8841 | } |
8842 | ||
8843 | start_artificial_method_body (mdecl); | |
8844 | ||
8845 | /* We don't generate a super constructor invocation if we're | |
8846 | compiling java.lang.Object. build_super_invocation takes care | |
8847 | of that. */ | |
781b0558 | 8848 | compound = java_method_add_stmt (mdecl, build_super_invocation (mdecl)); |
22eed1e6 APB |
8849 | |
8850 | end_artificial_method_body (mdecl); | |
8851 | } | |
8852 | /* Search for an explicit constructor invocation */ | |
8853 | else | |
8854 | { | |
8855 | int found = 0; | |
8856 | tree main_block = BLOCK_EXPR_BODY (body); | |
8857 | tree compound = NULL_TREE; | |
8858 | ||
8859 | while (body) | |
8860 | switch (TREE_CODE (body)) | |
8861 | { | |
8862 | case CALL_EXPR: | |
8863 | found = CALL_EXPLICIT_CONSTRUCTOR_P (body); | |
8864 | body = NULL_TREE; | |
8865 | break; | |
8866 | case COMPOUND_EXPR: | |
8867 | case EXPR_WITH_FILE_LOCATION: | |
8868 | body = TREE_OPERAND (body, 0); | |
8869 | break; | |
8870 | case BLOCK: | |
8871 | body = BLOCK_EXPR_BODY (body); | |
8872 | break; | |
8873 | default: | |
8874 | found = 0; | |
8875 | body = NULL_TREE; | |
8876 | } | |
8877 | /* The constructor is missing an invocation of super() */ | |
8878 | if (!found) | |
8879 | compound = add_stmt_to_compound (compound, NULL_TREE, | |
781b0558 | 8880 | build_super_invocation (mdecl)); |
22eed1e6 | 8881 | |
22eed1e6 APB |
8882 | /* Fix the constructor main block if we're adding extra stmts */ |
8883 | if (compound) | |
8884 | { | |
8885 | compound = add_stmt_to_compound (compound, NULL_TREE, | |
8886 | BLOCK_EXPR_BODY (main_block)); | |
8887 | BLOCK_EXPR_BODY (main_block) = compound; | |
8888 | } | |
8889 | } | |
8890 | } | |
8891 | ||
8892 | /* Browse constructors in the super class, searching for a constructor | |
8893 | that doesn't take any argument. Return 0 if one is found, 1 | |
8894 | otherwise. */ | |
8895 | ||
8896 | static int | |
8897 | verify_constructor_super () | |
8898 | { | |
8899 | tree class = CLASSTYPE_SUPER (current_class); | |
8900 | if (!class) | |
8901 | return 0; | |
8902 | ||
8903 | if (class) | |
8904 | { | |
8905 | tree mdecl; | |
8906 | for (mdecl = TYPE_METHODS (class); mdecl; mdecl = TREE_CHAIN (mdecl)) | |
8907 | { | |
8908 | if (DECL_CONSTRUCTOR_P (mdecl) | |
d77613be APB |
8909 | && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (mdecl))) |
8910 | == end_params_node) | |
22eed1e6 APB |
8911 | return 0; |
8912 | } | |
8913 | } | |
8914 | return 1; | |
8915 | } | |
8916 | ||
8b27f225 PB |
8917 | /* Expand finals. */ |
8918 | ||
49f48c71 | 8919 | static void |
8b27f225 PB |
8920 | java_expand_finals () |
8921 | { | |
8922 | } | |
8923 | ||
22eed1e6 | 8924 | /* Generate code for all context remembered for code generation. */ |
b351b287 APB |
8925 | |
8926 | void | |
8927 | java_expand_classes () | |
8928 | { | |
5423609c | 8929 | int save_error_count = 0; |
23a79c61 APB |
8930 | java_parse_abort_on_error (); |
8931 | if (!(ctxp = ctxp_for_generation)) | |
5e942c50 APB |
8932 | return; |
8933 | java_layout_classes (); | |
8934 | java_parse_abort_on_error (); | |
8935 | ||
b351b287 APB |
8936 | for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next) |
8937 | { | |
8938 | ctxp = ctxp_for_generation; | |
8939 | lang_init_source (2); /* Error msgs have method prototypes */ | |
8940 | java_complete_expand_methods (); /* Complete and expand method bodies */ | |
8941 | java_parse_abort_on_error (); | |
8942 | java_expand_finals (); /* Expand and check the finals */ | |
8943 | java_parse_abort_on_error (); | |
8944 | java_check_final (); /* Check unitialized final */ | |
8945 | java_parse_abort_on_error (); | |
8946 | } | |
b351b287 APB |
8947 | } |
8948 | ||
8b27f225 PB |
8949 | /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to |
8950 | a tree list node containing RIGHT. Fore coming RIGHTs will be | |
8951 | chained to this hook. LOCATION contains the location of the | |
8952 | separating `.' operator. */ | |
8953 | ||
8954 | static tree | |
8955 | make_qualified_primary (primary, right, location) | |
8956 | tree primary, right; | |
8957 | int location; | |
8958 | { | |
8959 | tree wfl; | |
8960 | ||
8961 | /* We want to process THIS . xxx symbolicaly, to keep it consistent | |
8962 | with the way we're processing SUPER. A THIS from a primary as a | |
8963 | different form than a SUPER. Turn THIS into something symbolic */ | |
8964 | if (TREE_CODE (primary) == THIS_EXPR) | |
8965 | { | |
9ee9b555 | 8966 | wfl = build_wfl_node (this_identifier_node); |
8b27f225 PB |
8967 | EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (primary); |
8968 | wfl = make_qualified_name (wfl, right, location); | |
8969 | PRIMARY_P (wfl) = 1; | |
8970 | return wfl; | |
8971 | } | |
8972 | /* Other non WFL node are wrapped around a WFL */ | |
8973 | else if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION) | |
8974 | { | |
8975 | wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0); | |
8976 | EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (primary); | |
8977 | EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (primary, NULL_TREE); | |
8978 | } | |
8979 | else | |
8980 | { | |
8981 | wfl = primary; | |
8982 | if (!EXPR_WFL_QUALIFICATION (primary)) | |
8983 | EXPR_WFL_QUALIFICATION (primary) = | |
8984 | build_tree_list (primary, NULL_TREE); | |
8985 | } | |
8986 | ||
8987 | EXPR_WFL_LINECOL (right) = location; | |
8988 | chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE)); | |
8989 | PRIMARY_P (wfl) = 1; | |
8990 | return wfl; | |
8991 | } | |
8992 | ||
8993 | /* Simple merge of two name separated by a `.' */ | |
8994 | ||
8995 | static tree | |
8996 | merge_qualified_name (left, right) | |
8997 | tree left, right; | |
8998 | { | |
8999 | tree node; | |
9000 | obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left), | |
9001 | IDENTIFIER_LENGTH (left)); | |
9002 | obstack_1grow (&temporary_obstack, '.'); | |
9003 | obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right), | |
9004 | IDENTIFIER_LENGTH (right)); | |
9005 | node = get_identifier (obstack_base (&temporary_obstack)); | |
9006 | obstack_free (&temporary_obstack, obstack_base (&temporary_obstack)); | |
9007 | QUALIFIED_P (node) = 1; | |
9008 | return node; | |
9009 | } | |
9010 | ||
9011 | /* Merge the two parts of a qualified name into LEFT. Set the | |
9012 | location information of the resulting node to LOCATION, usually | |
9013 | inherited from the location information of the `.' operator. */ | |
9014 | ||
9015 | static tree | |
9016 | make_qualified_name (left, right, location) | |
9017 | tree left, right; | |
9018 | int location; | |
9019 | { | |
bc3ca41b PB |
9020 | #ifdef USE_COMPONENT_REF |
9021 | tree node = build (COMPONENT_REF, NULL_TREE, left, right); | |
9022 | EXPR_WFL_LINECOL (node) = location; | |
9023 | return node; | |
9024 | #else | |
8b27f225 PB |
9025 | tree left_id = EXPR_WFL_NODE (left); |
9026 | tree right_id = EXPR_WFL_NODE (right); | |
9027 | tree wfl, merge; | |
9028 | ||
9029 | merge = merge_qualified_name (left_id, right_id); | |
9030 | ||
9031 | /* Left wasn't qualified and is now qualified */ | |
9032 | if (!QUALIFIED_P (left_id)) | |
9033 | { | |
9034 | tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0); | |
9035 | EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left); | |
9036 | EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE); | |
9037 | } | |
9038 | ||
9039 | wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0); | |
9040 | EXPR_WFL_LINECOL (wfl) = location; | |
9041 | chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE)); | |
9042 | ||
9043 | EXPR_WFL_NODE (left) = merge; | |
9044 | return left; | |
bc3ca41b | 9045 | #endif |
8b27f225 PB |
9046 | } |
9047 | ||
9048 | /* Extract the last identifier component of the qualified in WFL. The | |
9049 | last identifier is removed from the linked list */ | |
9050 | ||
9051 | static tree | |
9052 | cut_identifier_in_qualified (wfl) | |
9053 | tree wfl; | |
9054 | { | |
9055 | tree q; | |
9056 | tree previous = NULL_TREE; | |
9057 | for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q)) | |
9058 | if (!TREE_CHAIN (q)) | |
9059 | { | |
9060 | if (!previous) | |
781b0558 | 9061 | fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified"); |
8b27f225 PB |
9062 | TREE_CHAIN (previous) = NULL_TREE; |
9063 | return TREE_PURPOSE (q); | |
9064 | } | |
9065 | } | |
9066 | ||
9067 | /* Resolve the expression name NAME. Return its decl. */ | |
9068 | ||
9069 | static tree | |
5e942c50 | 9070 | resolve_expression_name (id, orig) |
8b27f225 | 9071 | tree id; |
5e942c50 | 9072 | tree *orig; |
8b27f225 PB |
9073 | { |
9074 | tree name = EXPR_WFL_NODE (id); | |
9075 | tree decl; | |
9076 | ||
9077 | /* 6.5.5.1: Simple expression names */ | |
9078 | if (!PRIMARY_P (id) && !QUALIFIED_P (name)) | |
9079 | { | |
9080 | /* 15.13.1: NAME can appear within the scope of a local variable | |
9081 | declaration */ | |
9082 | if ((decl = IDENTIFIER_LOCAL_VALUE (name))) | |
9083 | return decl; | |
9084 | ||
9085 | /* 15.13.1: NAME can appear within a class declaration */ | |
9086 | else | |
9087 | { | |
9088 | decl = lookup_field_wrapper (current_class, name); | |
9089 | if (decl) | |
9090 | { | |
9091 | int fs = FIELD_STATIC (decl); | |
9092 | /* Instance variable (8.3.1.1) can't appear within | |
9093 | static method, static initializer or initializer for | |
9094 | a static variable. */ | |
9095 | if (!fs && METHOD_STATIC (current_function_decl)) | |
9096 | { | |
7f10c2e2 | 9097 | static_ref_err (id, name, current_class); |
8b27f225 PB |
9098 | return error_mark_node; |
9099 | } | |
22eed1e6 APB |
9100 | /* Instance variables can't appear as an argument of |
9101 | an explicit constructor invocation */ | |
9102 | if (!fs && ctxp->explicit_constructor_p) | |
9103 | { | |
9104 | parse_error_context | |
781b0558 | 9105 | (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name)); |
22eed1e6 APB |
9106 | return error_mark_node; |
9107 | } | |
5e942c50 APB |
9108 | |
9109 | /* Otherwise build what it takes to access the field */ | |
8b27f225 | 9110 | decl = build_field_ref ((fs ? NULL_TREE : current_this), |
7f1d4866 | 9111 | DECL_CONTEXT (decl), name); |
5423609c | 9112 | if (fs && !flag_emit_class_files && !flag_emit_xref) |
7f1d4866 | 9113 | decl = build_class_init (DECL_CONTEXT (decl), decl); |
5e942c50 APB |
9114 | /* We may be asked to save the real field access node */ |
9115 | if (orig) | |
9116 | *orig = decl; | |
9117 | /* And we return what we got */ | |
5b09b33e | 9118 | return decl; |
8b27f225 PB |
9119 | } |
9120 | /* Fall down to error report on undefined variable */ | |
9121 | } | |
9122 | } | |
9123 | /* 6.5.5.2 Qualified Expression Names */ | |
9124 | else | |
9125 | { | |
5e942c50 APB |
9126 | if (orig) |
9127 | *orig = NULL_TREE; | |
8b27f225 PB |
9128 | qualify_ambiguous_name (id); |
9129 | /* 15.10.1 Field Access Using a Primary and/or Expression Name */ | |
9130 | /* 15.10.2: Accessing Superclass Members using super */ | |
9131 | return resolve_field_access (id, NULL, NULL); | |
9132 | } | |
9133 | ||
9134 | /* We've got an error here */ | |
9135 | parse_error_context (id, "Undefined variable `%s'", | |
9136 | IDENTIFIER_POINTER (name)); | |
9137 | ||
9138 | return error_mark_node; | |
9139 | } | |
9140 | ||
7f10c2e2 APB |
9141 | static void |
9142 | static_ref_err (wfl, field_id, class_type) | |
9143 | tree wfl, field_id, class_type; | |
9144 | { | |
9145 | parse_error_context | |
9146 | (wfl, | |
9147 | "Can't make a static reference to nonstatic variable `%s' in class `%s'", | |
9148 | IDENTIFIER_POINTER (field_id), | |
9149 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type)))); | |
9150 | } | |
9151 | ||
8b27f225 PB |
9152 | /* 15.10.1 Field Acess Using a Primary and/or Expression Name. |
9153 | We return something suitable to generate the field access. We also | |
9154 | return the field decl in FIELD_DECL and its type in FIELD_TYPE. If | |
9155 | recipient's address can be null. */ | |
9156 | ||
9157 | static tree | |
9158 | resolve_field_access (qual_wfl, field_decl, field_type) | |
9159 | tree qual_wfl; | |
9160 | tree *field_decl, *field_type; | |
9161 | { | |
9162 | int is_static = 0; | |
9163 | tree field_ref; | |
9164 | tree decl, where_found, type_found; | |
9165 | ||
9166 | if (resolve_qualified_expression_name (qual_wfl, &decl, | |
9167 | &where_found, &type_found)) | |
9168 | return error_mark_node; | |
9169 | ||
9170 | /* Resolve the LENGTH field of an array here */ | |
9171 | if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found) | |
5423609c | 9172 | && ! flag_emit_class_files && ! flag_emit_xref) |
8b27f225 PB |
9173 | { |
9174 | tree length = build_java_array_length_access (where_found); | |
9175 | field_ref = | |
9176 | build_java_arraynull_check (type_found, length, int_type_node); | |
9177 | } | |
9178 | /* We might have been trying to resolve field.method(). In which | |
9179 | case, the resolution is over and decl is the answer */ | |
34f4db93 | 9180 | else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl) |
8b27f225 | 9181 | field_ref = decl; |
34f4db93 | 9182 | else if (JDECL_P (decl)) |
8b27f225 | 9183 | { |
5e942c50 APB |
9184 | int static_final_found = 0; |
9185 | if (!type_found) | |
9186 | type_found = DECL_CONTEXT (decl); | |
34f4db93 | 9187 | is_static = JDECL_P (decl) && FIELD_STATIC (decl); |
5e942c50 APB |
9188 | if (FIELD_FINAL (decl) |
9189 | && JPRIMITIVE_TYPE_P (TREE_TYPE (decl)) | |
9190 | && DECL_LANG_SPECIFIC (decl) | |
63a212ed | 9191 | && DECL_INITIAL (decl)) |
5e942c50 | 9192 | { |
63a212ed | 9193 | field_ref = DECL_INITIAL (decl); |
5e942c50 APB |
9194 | static_final_found = 1; |
9195 | } | |
9196 | else | |
7f10c2e2 APB |
9197 | field_ref = build_field_ref ((is_static && !flag_emit_xref? |
9198 | NULL_TREE : where_found), | |
5e942c50 | 9199 | type_found, DECL_NAME (decl)); |
8b27f225 PB |
9200 | if (field_ref == error_mark_node) |
9201 | return error_mark_node; | |
5423609c APB |
9202 | if (is_static && !static_final_found |
9203 | && !flag_emit_class_files && !flag_emit_xref) | |
8b27f225 PB |
9204 | { |
9205 | field_ref = build_class_init (type_found, field_ref); | |
9206 | /* If the static field was identified by an expression that | |
9207 | needs to be generated, make the field access a compound | |
7f10c2e2 | 9208 | expression whose first part is the evaluation of the |
8b27f225 | 9209 | field selector part. */ |
c877974e APB |
9210 | if (where_found && TREE_CODE (where_found) != TYPE_DECL |
9211 | && TREE_CODE (where_found) != RECORD_TYPE) | |
8b27f225 PB |
9212 | { |
9213 | tree type = QUAL_DECL_TYPE (field_ref); | |
8576f094 APB |
9214 | if (TREE_CODE (type) == RECORD_TYPE) |
9215 | type = build_pointer_type (type); | |
8b27f225 PB |
9216 | field_ref = build (COMPOUND_EXPR, type, where_found, field_ref); |
9217 | } | |
9218 | } | |
9219 | } | |
9220 | else | |
9221 | field_ref = decl; | |
9222 | ||
9223 | if (field_decl) | |
9224 | *field_decl = decl; | |
9225 | if (field_type) | |
c877974e APB |
9226 | *field_type = (QUAL_DECL_TYPE (decl) ? |
9227 | QUAL_DECL_TYPE (decl) : TREE_TYPE (decl)); | |
8b27f225 PB |
9228 | return field_ref; |
9229 | } | |
9230 | ||
78d21f92 PB |
9231 | /* If NODE is an access to f static field, strip out the class |
9232 | initialization part and return the field decl, otherwise, return | |
9233 | NODE. */ | |
9234 | ||
9235 | static tree | |
9236 | strip_out_static_field_access_decl (node) | |
9237 | tree node; | |
9238 | { | |
9239 | if (TREE_CODE (node) == COMPOUND_EXPR) | |
9240 | { | |
9241 | tree op1 = TREE_OPERAND (node, 1); | |
9242 | if (TREE_CODE (op1) == COMPOUND_EXPR) | |
9243 | { | |
9244 | tree call = TREE_OPERAND (op1, 0); | |
9245 | if (TREE_CODE (call) == CALL_EXPR | |
9246 | && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR | |
9247 | && TREE_OPERAND (TREE_OPERAND (call, 0), 0) | |
9248 | == soft_initclass_node) | |
9249 | return TREE_OPERAND (op1, 1); | |
9250 | } | |
2f11d407 TT |
9251 | else if (JDECL_P (op1)) |
9252 | return op1; | |
78d21f92 PB |
9253 | } |
9254 | return node; | |
9255 | } | |
9256 | ||
8b27f225 PB |
9257 | /* 6.5.5.2: Qualified Expression Names */ |
9258 | ||
9259 | static int | |
9260 | resolve_qualified_expression_name (wfl, found_decl, where_found, type_found) | |
9261 | tree wfl; | |
9262 | tree *found_decl, *type_found, *where_found; | |
9263 | { | |
9264 | int from_type = 0; /* Field search initiated from a type */ | |
9265 | int from_super = 0, from_cast = 0; | |
9266 | int previous_call_static = 0; | |
9267 | int is_static; | |
9268 | tree decl = NULL_TREE, type = NULL_TREE, q; | |
c877974e | 9269 | *type_found = *where_found = NULL_TREE; |
8b27f225 PB |
9270 | |
9271 | for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q)) | |
9272 | { | |
9273 | tree qual_wfl = QUAL_WFL (q); | |
7705e9db APB |
9274 | tree ret_decl; /* for EH checking */ |
9275 | int location; /* for EH checking */ | |
8b27f225 PB |
9276 | |
9277 | /* 15.10.1 Field Access Using a Primary */ | |
8b27f225 PB |
9278 | switch (TREE_CODE (qual_wfl)) |
9279 | { | |
9280 | case CALL_EXPR: | |
9281 | case NEW_CLASS_EXPR: | |
9282 | /* If the access to the function call is a non static field, | |
9283 | build the code to access it. */ | |
34f4db93 | 9284 | if (JDECL_P (decl) && !FIELD_STATIC (decl)) |
8b27f225 | 9285 | { |
ac825856 APB |
9286 | decl = maybe_access_field (decl, *where_found, |
9287 | DECL_CONTEXT (decl)); | |
8b27f225 PB |
9288 | if (decl == error_mark_node) |
9289 | return 1; | |
9290 | } | |
9291 | /* And code for the function call */ | |
9292 | if (complete_function_arguments (qual_wfl)) | |
9293 | return 1; | |
7705e9db | 9294 | |
ac825856 APB |
9295 | if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR) |
9296 | CALL_USING_SUPER (qual_wfl) = 1; | |
7705e9db APB |
9297 | location = (TREE_CODE (qual_wfl) == CALL_EXPR ? |
9298 | EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0); | |
9299 | *where_found = patch_method_invocation (qual_wfl, decl, type, | |
9300 | &is_static, &ret_decl); | |
8b27f225 PB |
9301 | if (*where_found == error_mark_node) |
9302 | return 1; | |
9303 | *type_found = type = QUAL_DECL_TYPE (*where_found); | |
9304 | ||
7705e9db APB |
9305 | /* EH check */ |
9306 | if (location) | |
9307 | check_thrown_exceptions (location, ret_decl); | |
9308 | ||
8b27f225 PB |
9309 | /* If the previous call was static and this one is too, |
9310 | build a compound expression to hold the two (because in | |
9311 | that case, previous function calls aren't transported as | |
9312 | forcoming function's argument. */ | |
9313 | if (previous_call_static && is_static) | |
9314 | { | |
9315 | decl = build (COMPOUND_EXPR, type, decl, *where_found); | |
9316 | TREE_SIDE_EFFECTS (decl) = 1; | |
9317 | } | |
9318 | else | |
9319 | { | |
9320 | previous_call_static = is_static; | |
9321 | decl = *where_found; | |
9322 | } | |
9323 | continue; | |
9324 | ||
d8fccff5 APB |
9325 | case NEW_ARRAY_EXPR: |
9326 | *where_found = decl = java_complete_tree (qual_wfl); | |
9327 | if (decl == error_mark_node) | |
9328 | return 1; | |
9329 | *type_found = type = QUAL_DECL_TYPE (decl); | |
9330 | CLASS_LOADED_P (type) = 1; | |
9331 | continue; | |
9332 | ||
8b27f225 PB |
9333 | case CONVERT_EXPR: |
9334 | *where_found = decl = java_complete_tree (qual_wfl); | |
9335 | if (decl == error_mark_node) | |
9336 | return 1; | |
9337 | *type_found = type = QUAL_DECL_TYPE (decl); | |
9338 | from_cast = 1; | |
9339 | continue; | |
9340 | ||
22eed1e6 | 9341 | case CONDITIONAL_EXPR: |
5e942c50 | 9342 | case STRING_CST: |
ac22f9cb | 9343 | case MODIFY_EXPR: |
22eed1e6 APB |
9344 | *where_found = decl = java_complete_tree (qual_wfl); |
9345 | if (decl == error_mark_node) | |
9346 | return 1; | |
9347 | *type_found = type = QUAL_DECL_TYPE (decl); | |
9348 | continue; | |
9349 | ||
8b27f225 PB |
9350 | case ARRAY_REF: |
9351 | /* If the access to the function call is a non static field, | |
9352 | build the code to access it. */ | |
34f4db93 | 9353 | if (JDECL_P (decl) && !FIELD_STATIC (decl)) |
8b27f225 PB |
9354 | { |
9355 | decl = maybe_access_field (decl, *where_found, type); | |
9356 | if (decl == error_mark_node) | |
9357 | return 1; | |
9358 | } | |
9359 | /* And code for the array reference expression */ | |
9360 | decl = java_complete_tree (qual_wfl); | |
9361 | if (decl == error_mark_node) | |
9362 | return 1; | |
9363 | type = QUAL_DECL_TYPE (decl); | |
9364 | continue; | |
9365 | ||
b5b8a0e7 APB |
9366 | case PLUS_EXPR: |
9367 | if ((decl = java_complete_tree (qual_wfl)) == error_mark_node) | |
9368 | return 1; | |
9369 | if ((type = patch_string (decl))) | |
9370 | decl = type; | |
9371 | *where_found = QUAL_RESOLUTION (q) = decl; | |
9372 | *type_found = type = TREE_TYPE (decl); | |
9373 | break; | |
9374 | ||
8b27f225 PB |
9375 | default: |
9376 | /* Fix for -Wall Just go to the next statement. Don't | |
9377 | continue */ | |
a3f406ce | 9378 | break; |
8b27f225 PB |
9379 | } |
9380 | ||
9381 | /* If we fall here, we weren't processing a (static) function call. */ | |
9382 | previous_call_static = 0; | |
9383 | ||
9384 | /* It can be the keyword THIS */ | |
9385 | if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node) | |
9386 | { | |
9387 | if (!current_this) | |
9388 | { | |
9389 | parse_error_context | |
9390 | (wfl, "Keyword `this' used outside allowed context"); | |
9391 | return 1; | |
9392 | } | |
f63991a8 APB |
9393 | if (ctxp->explicit_constructor_p) |
9394 | { | |
781b0558 | 9395 | parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called"); |
f63991a8 APB |
9396 | return 1; |
9397 | } | |
8b27f225 PB |
9398 | /* We have to generate code for intermediate acess */ |
9399 | *where_found = decl = current_this; | |
5e942c50 | 9400 | *type_found = type = QUAL_DECL_TYPE (decl); |
8b27f225 PB |
9401 | continue; |
9402 | } | |
9403 | ||
9404 | /* 15.10.2 Accessing Superclass Members using SUPER */ | |
9405 | if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node) | |
9406 | { | |
9407 | tree node; | |
9408 | /* Check on the restricted use of SUPER */ | |
9409 | if (METHOD_STATIC (current_function_decl) | |
9410 | || current_class == object_type_node) | |
9411 | { | |
9412 | parse_error_context | |
9413 | (wfl, "Keyword `super' used outside allowed context"); | |
9414 | return 1; | |
9415 | } | |
9416 | /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */ | |
9417 | node = build_cast (EXPR_WFL_LINECOL (qual_wfl), | |
9418 | CLASSTYPE_SUPER (current_class), | |
9419 | build_this (EXPR_WFL_LINECOL (qual_wfl))); | |
9420 | *where_found = decl = java_complete_tree (node); | |
22eed1e6 APB |
9421 | if (decl == error_mark_node) |
9422 | return 1; | |
8b27f225 PB |
9423 | *type_found = type = QUAL_DECL_TYPE (decl); |
9424 | from_super = from_type = 1; | |
9425 | continue; | |
9426 | } | |
9427 | ||
9428 | /* 15.13.1: Can't search for field name in packages, so we | |
9429 | assume a variable/class name was meant. */ | |
9430 | if (RESOLVE_PACKAGE_NAME_P (qual_wfl)) | |
9431 | { | |
5e942c50 APB |
9432 | tree name = resolve_package (wfl, &q); |
9433 | if (name) | |
9434 | { | |
9435 | *where_found = decl = resolve_no_layout (name, qual_wfl); | |
9436 | /* We wan't to be absolutely that the class is laid | |
9437 | out. We're going to search something inside it. */ | |
9438 | *type_found = type = TREE_TYPE (decl); | |
9439 | layout_class (type); | |
9440 | from_type = 1; | |
9441 | /* Should be a list, really. FIXME */ | |
9442 | RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (TREE_CHAIN (q))) = 1; | |
9443 | RESOLVE_PACKAGE_NAME_P (QUAL_WFL (TREE_CHAIN (q))) = 0; | |
9444 | } | |
8b27f225 | 9445 | else |
5e942c50 APB |
9446 | { |
9447 | if (from_super || from_cast) | |
9448 | parse_error_context | |
9449 | ((from_cast ? qual_wfl : wfl), | |
9450 | "No variable `%s' defined in class `%s'", | |
9451 | IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)), | |
9452 | lang_printable_name (type, 0)); | |
9453 | else | |
9454 | parse_error_context | |
9455 | (qual_wfl, "Undefined variable or class name: `%s'", | |
9456 | IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl))); | |
9457 | return 1; | |
9458 | } | |
8b27f225 PB |
9459 | } |
9460 | ||
9461 | /* We have a type name. It's been already resolved when the | |
9462 | expression was qualified. */ | |
9463 | else if (RESOLVE_TYPE_NAME_P (qual_wfl)) | |
9464 | { | |
9465 | if (!(decl = QUAL_RESOLUTION (q))) | |
9466 | return 1; /* Error reported already */ | |
9467 | ||
9468 | if (not_accessible_p (TREE_TYPE (decl), decl, 0)) | |
9469 | { | |
9470 | parse_error_context | |
9471 | (qual_wfl, "Can't access %s field `%s.%s' from `%s'", | |
9472 | java_accstring_lookup (get_access_flags_from_decl (decl)), | |
2aa11e97 | 9473 | GET_TYPE_NAME (type), |
8b27f225 PB |
9474 | IDENTIFIER_POINTER (DECL_NAME (decl)), |
9475 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class)))); | |
9476 | return 1; | |
9477 | } | |
5e942c50 | 9478 | check_deprecation (qual_wfl, decl); |
8b27f225 PB |
9479 | |
9480 | type = TREE_TYPE (decl); | |
9481 | from_type = 1; | |
9482 | } | |
9483 | /* We resolve and expression name */ | |
9484 | else | |
9485 | { | |
cd531a2e | 9486 | tree field_decl = NULL_TREE; |
8b27f225 PB |
9487 | |
9488 | /* If there exists an early resolution, use it. That occurs | |
9489 | only once and we know that there are more things to | |
9490 | come. Don't do that when processing something after SUPER | |
9491 | (we need more thing to be put in place below */ | |
9492 | if (!from_super && QUAL_RESOLUTION (q)) | |
9493 | { | |
9494 | decl = QUAL_RESOLUTION (q); | |
c877974e | 9495 | if (!type) |
5e942c50 | 9496 | { |
7f10c2e2 APB |
9497 | if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl)) |
9498 | { | |
9499 | if (current_this) | |
9500 | *where_found = current_this; | |
9501 | else | |
9502 | { | |
9503 | static_ref_err (qual_wfl, DECL_NAME (decl), | |
9504 | current_class); | |
9505 | return 1; | |
9506 | } | |
9507 | } | |
c877974e APB |
9508 | else |
9509 | { | |
9510 | *where_found = TREE_TYPE (decl); | |
9511 | if (TREE_CODE (*where_found) == POINTER_TYPE) | |
9512 | *where_found = TREE_TYPE (*where_found); | |
9513 | } | |
5e942c50 | 9514 | } |
8b27f225 PB |
9515 | } |
9516 | ||
9517 | /* We have to search for a field, knowing the type of its | |
9518 | container. The flag FROM_TYPE indicates that we resolved | |
9519 | the last member of the expression as a type name, which | |
5e942c50 APB |
9520 | means that for the resolution of this field, we'll look |
9521 | for other errors than if it was resolved as a member of | |
9522 | an other field. */ | |
8b27f225 PB |
9523 | else |
9524 | { | |
9525 | int is_static; | |
5e942c50 APB |
9526 | tree field_decl_type; /* For layout */ |
9527 | ||
8b27f225 PB |
9528 | if (!from_type && !JREFERENCE_TYPE_P (type)) |
9529 | { | |
9530 | parse_error_context | |
9531 | (qual_wfl, "Attempt to reference field `%s' in `%s %s'", | |
9532 | IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)), | |
9533 | lang_printable_name (type, 0), | |
9534 | IDENTIFIER_POINTER (DECL_NAME (field_decl))); | |
9535 | return 1; | |
9536 | } | |
9537 | ||
939d7216 PB |
9538 | field_decl = lookup_field_wrapper (type, |
9539 | EXPR_WFL_NODE (qual_wfl)); | |
9540 | if (field_decl == NULL_TREE) | |
8b27f225 PB |
9541 | { |
9542 | parse_error_context | |
2aa11e97 | 9543 | (qual_wfl, "No variable `%s' defined in type `%s'", |
8b27f225 | 9544 | IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)), |
2aa11e97 | 9545 | GET_TYPE_NAME (type)); |
8b27f225 PB |
9546 | return 1; |
9547 | } | |
939d7216 PB |
9548 | if (field_decl == error_mark_node) |
9549 | return 1; | |
5e942c50 APB |
9550 | |
9551 | /* Layout the type of field_decl, since we may need | |
c877974e APB |
9552 | it. Don't do primitive types or loaded classes. The |
9553 | situation of non primitive arrays may not handled | |
9554 | properly here. FIXME */ | |
5e942c50 APB |
9555 | if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE) |
9556 | field_decl_type = TREE_TYPE (TREE_TYPE (field_decl)); | |
9557 | else | |
9558 | field_decl_type = TREE_TYPE (field_decl); | |
9559 | if (!JPRIMITIVE_TYPE_P (field_decl_type) | |
c877974e APB |
9560 | && !CLASS_LOADED_P (field_decl_type) |
9561 | && !TYPE_ARRAY_P (field_decl_type)) | |
9562 | resolve_and_layout (field_decl_type, NULL_TREE); | |
9563 | if (TYPE_ARRAY_P (field_decl_type)) | |
9564 | CLASS_LOADED_P (field_decl_type) = 1; | |
8b27f225 PB |
9565 | |
9566 | /* Check on accessibility here */ | |
9567 | if (not_accessible_p (type, field_decl, from_super)) | |
9568 | { | |
9569 | parse_error_context | |
9570 | (qual_wfl, | |
9571 | "Can't access %s field `%s.%s' from `%s'", | |
9572 | java_accstring_lookup | |
9573 | (get_access_flags_from_decl (field_decl)), | |
2aa11e97 | 9574 | GET_TYPE_NAME (type), |
8b27f225 PB |
9575 | IDENTIFIER_POINTER (DECL_NAME (field_decl)), |
9576 | IDENTIFIER_POINTER | |
9577 | (DECL_NAME (TYPE_NAME (current_class)))); | |
9578 | return 1; | |
9579 | } | |
5e942c50 | 9580 | check_deprecation (qual_wfl, field_decl); |
8b27f225 PB |
9581 | |
9582 | /* There are things to check when fields are accessed | |
9583 | from type. There are no restrictions on a static | |
9584 | declaration of the field when it is accessed from an | |
9585 | interface */ | |
9586 | is_static = FIELD_STATIC (field_decl); | |
9587 | if (!from_super && from_type | |
9588 | && !TYPE_INTERFACE_P (type) && !is_static) | |
9589 | { | |
7f10c2e2 | 9590 | static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type); |
8b27f225 PB |
9591 | return 1; |
9592 | } | |
9593 | from_cast = from_super = 0; | |
9594 | ||
5e942c50 APB |
9595 | /* If we need to generate something to get a proper |
9596 | handle on what this field is accessed from, do it | |
9597 | now. */ | |
8b27f225 PB |
9598 | if (!is_static) |
9599 | { | |
9600 | decl = maybe_access_field (decl, *where_found, *type_found); | |
9601 | if (decl == error_mark_node) | |
9602 | return 1; | |
9603 | } | |
9604 | ||
9605 | /* We want to keep the location were found it, and the type | |
9606 | we found. */ | |
9607 | *where_found = decl; | |
9608 | *type_found = type; | |
9609 | ||
9610 | /* This is the decl found and eventually the next one to | |
9611 | search from */ | |
9612 | decl = field_decl; | |
9613 | } | |
9614 | from_type = 0; | |
9615 | type = QUAL_DECL_TYPE (decl); | |
9616 | } | |
9617 | } | |
9618 | *found_decl = decl; | |
9619 | return 0; | |
9620 | } | |
9621 | ||
9622 | /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl) | |
9623 | can't be accessed from REFERENCE (a record type). */ | |
9624 | ||
be245ac0 KG |
9625 | static int |
9626 | not_accessible_p (reference, member, from_super) | |
8b27f225 PB |
9627 | tree reference, member; |
9628 | int from_super; | |
9629 | { | |
9630 | int access_flag = get_access_flags_from_decl (member); | |
9631 | ||
9632 | /* Access always granted for members declared public */ | |
9633 | if (access_flag & ACC_PUBLIC) | |
9634 | return 0; | |
9635 | ||
9636 | /* Check access on protected members */ | |
9637 | if (access_flag & ACC_PROTECTED) | |
9638 | { | |
9639 | /* Access granted if it occurs from within the package | |
9640 | containing the class in which the protected member is | |
9641 | declared */ | |
9642 | if (class_in_current_package (DECL_CONTEXT (member))) | |
9643 | return 0; | |
9644 | ||
c877974e APB |
9645 | /* If accessed with the form `super.member', then access is granted */ |
9646 | if (from_super) | |
9647 | return 0; | |
8b27f225 | 9648 | |
c877974e APB |
9649 | /* Otherwise, access is granted if occuring from the class where |
9650 | member is declared or a subclass of it */ | |
9651 | if (inherits_from_p (reference, current_class)) | |
9652 | return 0; | |
8b27f225 PB |
9653 | return 1; |
9654 | } | |
9655 | ||
9656 | /* Check access on private members. Access is granted only if it | |
c877974e | 9657 | occurs from within the class in witch it is declared */ |
8b27f225 PB |
9658 | if (access_flag & ACC_PRIVATE) |
9659 | return (current_class == DECL_CONTEXT (member) ? 0 : 1); | |
9660 | ||
9661 | /* Default access are permitted only when occuring within the | |
9662 | package in which the type (REFERENCE) is declared. In other words, | |
9663 | REFERENCE is defined in the current package */ | |
9664 | if (ctxp->package) | |
9665 | return !class_in_current_package (reference); | |
9666 | ||
9667 | /* Otherwise, access is granted */ | |
9668 | return 0; | |
9669 | } | |
9670 | ||
5e942c50 APB |
9671 | /* Test deprecated decl access. */ |
9672 | static void | |
9673 | check_deprecation (wfl, decl) | |
9674 | tree wfl, decl; | |
9675 | { | |
49f48c71 | 9676 | const char *file = DECL_SOURCE_FILE (decl); |
5e942c50 APB |
9677 | /* Complain if the field is deprecated and the file it was defined |
9678 | in isn't compiled at the same time the file which contains its | |
9679 | use is */ | |
9680 | if (DECL_DEPRECATED (decl) | |
9681 | && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file))) | |
9682 | { | |
9683 | char the [20]; | |
9684 | switch (TREE_CODE (decl)) | |
9685 | { | |
9686 | case FUNCTION_DECL: | |
9687 | strcpy (the, "method"); | |
9688 | break; | |
9689 | case FIELD_DECL: | |
9690 | strcpy (the, "field"); | |
9691 | break; | |
9692 | case TYPE_DECL: | |
9693 | strcpy (the, "class"); | |
9694 | break; | |
9695 | default: | |
9696 | fatal ("unexpected DECL code - check_deprecation"); | |
9697 | } | |
9698 | parse_warning_context | |
9699 | (wfl, "The %s `%s' in class `%s' has been deprecated", | |
9700 | the, lang_printable_name (decl, 0), | |
9701 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl))))); | |
9702 | } | |
9703 | } | |
9704 | ||
8b27f225 PB |
9705 | /* Returns 1 if class was declared in the current package, 0 otherwise */ |
9706 | ||
9707 | static int | |
9708 | class_in_current_package (class) | |
9709 | tree class; | |
9710 | { | |
9711 | static tree cache = NULL_TREE; | |
9712 | int qualified_flag; | |
9713 | tree left; | |
9714 | ||
9715 | if (cache == class) | |
9716 | return 1; | |
9717 | ||
9718 | qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class))); | |
9719 | ||
9720 | /* If the current package is empty and the name of CLASS is | |
9721 | qualified, class isn't in the current package. If there is a | |
9722 | current package and the name of the CLASS is not qualified, class | |
9723 | isn't in the current package */ | |
9724 | if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag)) | |
9725 | return 0; | |
9726 | ||
9727 | /* If there is not package and the name of CLASS isn't qualified, | |
9728 | they belong to the same unnamed package */ | |
9729 | if (!ctxp->package && !qualified_flag) | |
9730 | return 1; | |
9731 | ||
9732 | /* Compare the left part of the name of CLASS with the package name */ | |
9733 | breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class))); | |
9734 | if (ctxp->package == left) | |
9735 | { | |
9736 | cache = class; | |
9737 | return 1; | |
9738 | } | |
9739 | return 0; | |
9740 | } | |
9741 | ||
9742 | /* This function may generate code to access DECL from WHERE. This is | |
9743 | done only if certain conditions meet. */ | |
9744 | ||
9745 | static tree | |
9746 | maybe_access_field (decl, where, type) | |
9747 | tree decl, where, type; | |
9748 | { | |
5e942c50 APB |
9749 | if (TREE_CODE (decl) == FIELD_DECL && decl != current_this |
9750 | && !FIELD_STATIC (decl)) | |
8b27f225 PB |
9751 | decl = build_field_ref (where ? where : current_this, |
9752 | (type ? type : DECL_CONTEXT (decl)), | |
9753 | DECL_NAME (decl)); | |
9754 | return decl; | |
9755 | } | |
9756 | ||
12472854 | 9757 | /* Build a method invocation, by patching PATCH. If non NULL |
8b27f225 PB |
9758 | and according to the situation, PRIMARY and WHERE may be |
9759 | used. IS_STATIC is set to 1 if the invoked function is static. */ | |
9760 | ||
9761 | static tree | |
ac825856 | 9762 | patch_method_invocation (patch, primary, where, is_static, ret_decl) |
8b27f225 PB |
9763 | tree patch, primary, where; |
9764 | int *is_static; | |
9765 | tree *ret_decl; | |
9766 | { | |
9767 | tree wfl = TREE_OPERAND (patch, 0); | |
9768 | tree args = TREE_OPERAND (patch, 1); | |
9769 | tree name = EXPR_WFL_NODE (wfl); | |
5e942c50 | 9770 | tree list; |
22eed1e6 | 9771 | int is_static_flag = 0; |
ac825856 | 9772 | int is_super_init = 0; |
bccaf73a | 9773 | tree this_arg = NULL_TREE; |
8b27f225 PB |
9774 | |
9775 | /* Should be overriden if everything goes well. Otherwise, if | |
9776 | something fails, it should keep this value. It stop the | |
9777 | evaluation of a bogus assignment. See java_complete_tree, | |
9778 | MODIFY_EXPR: for the reasons why we sometimes want to keep on | |
9779 | evaluating an assignment */ | |
9780 | TREE_TYPE (patch) = error_mark_node; | |
9781 | ||
9782 | /* Since lookup functions are messing with line numbers, save the | |
9783 | context now. */ | |
9784 | java_parser_context_save_global (); | |
9785 | ||
9786 | /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */ | |
9787 | ||
9788 | /* Resolution of qualified name, excluding constructors */ | |
9789 | if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch)) | |
9790 | { | |
9791 | tree class_decl, identifier, identifier_wfl; | |
9792 | /* Extract the last IDENTIFIER of the qualified | |
9793 | expression. This is a wfl and we will use it's location | |
9794 | data during error report. */ | |
9795 | identifier_wfl = cut_identifier_in_qualified (wfl); | |
9796 | identifier = EXPR_WFL_NODE (identifier_wfl); | |
9797 | ||
9798 | /* Given the context, IDENTIFIER is syntactically qualified | |
9799 | as a MethodName. We need to qualify what's before */ | |
9800 | qualify_ambiguous_name (wfl); | |
9801 | ||
2c56429a | 9802 | /* Package resolution */ |
8b27f225 PB |
9803 | if (RESOLVE_PACKAGE_NAME_P (wfl)) |
9804 | { | |
2c56429a APB |
9805 | tree next, decl, name = resolve_package (wfl, &next); |
9806 | ||
9807 | if (!name) | |
9808 | { | |
9809 | tree remainder; | |
9810 | breakdown_qualified (&remainder, NULL, EXPR_WFL_NODE (wfl)); | |
781b0558 KG |
9811 | parse_error_context |
9812 | (wfl, "Can't search method `%s' in package `%s'", | |
9813 | IDENTIFIER_POINTER (identifier), | |
9814 | IDENTIFIER_POINTER (remainder)); | |
2c56429a APB |
9815 | PATCH_METHOD_RETURN_ERROR (); |
9816 | } | |
9817 | RESOLVE_PACKAGE_NAME_P (wfl) = 0; | |
9818 | if ((decl = resolve_no_layout (name, QUAL_WFL (next)))) | |
9819 | { | |
9820 | QUAL_RESOLUTION (EXPR_WFL_QUALIFICATION (wfl)) = decl; | |
9821 | RESOLVE_EXPRESSION_NAME_P (wfl) = 0; | |
9822 | RESOLVE_TYPE_NAME_P (wfl) = 1; | |
9823 | } | |
9824 | else | |
9825 | { | |
9826 | RESOLVE_EXPRESSION_NAME_P (wfl) = 1; | |
9827 | RESOLVE_TYPE_NAME_P (wfl) = 0; | |
9828 | } | |
8b27f225 | 9829 | } |
2c56429a | 9830 | |
8b27f225 | 9831 | /* We're resolving a call from a type */ |
2c56429a | 9832 | if (RESOLVE_TYPE_NAME_P (wfl)) |
8b27f225 PB |
9833 | { |
9834 | tree decl = QUAL_RESOLUTION (EXPR_WFL_QUALIFICATION (wfl)); | |
9835 | tree name = DECL_NAME (decl); | |
9836 | tree type; | |
9837 | ||
9838 | class_decl = resolve_and_layout (name, wfl); | |
9839 | if (CLASS_INTERFACE (decl)) | |
9840 | { | |
9841 | parse_error_context | |
781b0558 KG |
9842 | (identifier_wfl, |
9843 | "Can't make static reference to method `%s' in interface `%s'", | |
9844 | IDENTIFIER_POINTER (identifier), | |
8b27f225 PB |
9845 | IDENTIFIER_POINTER (name)); |
9846 | PATCH_METHOD_RETURN_ERROR (); | |
9847 | } | |
9848 | /* Look the method up in the type selector. The method ought | |
9849 | to be static. */ | |
9850 | type = TREE_TYPE (class_decl); | |
9851 | list = lookup_method_invoke (0, wfl, type, identifier, args); | |
9852 | if (list && !METHOD_STATIC (list)) | |
9853 | { | |
c2e3db92 | 9854 | char *fct_name = xstrdup (lang_printable_name (list, 0)); |
8b27f225 PB |
9855 | parse_error_context |
9856 | (identifier_wfl, | |
9857 | "Can't make static reference to method `%s %s' in class `%s'", | |
9858 | lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), | |
9859 | fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)))); | |
9860 | free (fct_name); | |
9861 | PATCH_METHOD_RETURN_ERROR (); | |
9862 | } | |
5e942c50 | 9863 | args = nreverse (args); |
8b27f225 PB |
9864 | } |
9865 | /* We're resolving an expression name */ | |
9866 | else | |
9867 | { | |
9868 | tree field, type; | |
9869 | ||
9870 | /* 1- Find the field to which the call applies */ | |
9871 | field = resolve_field_access (wfl, NULL, &type); | |
9872 | if (field == error_mark_node) | |
9873 | PATCH_METHOD_RETURN_ERROR (); | |
c3f2a476 APB |
9874 | /* field is used in lieu of a primary. It alows us not to |
9875 | report errors on erroneous use of `this' in | |
9876 | constructors. */ | |
9877 | primary = field; | |
8b27f225 PB |
9878 | |
9879 | /* 2- Do the layout of the class where the last field | |
9880 | was found, so we can search it. */ | |
c877974e | 9881 | class_decl = resolve_and_layout (type, NULL_TREE); |
59e4a38e | 9882 | if (class_decl != NULL_TREE) |
c877974e APB |
9883 | type = TREE_TYPE (class_decl); |
9884 | ||
8b27f225 PB |
9885 | /* 3- Retrieve a filtered list of method matches, Refine |
9886 | if necessary. In any cases, point out errors. */ | |
9887 | list = lookup_method_invoke (0, identifier_wfl, type, | |
9888 | identifier, args); | |
9889 | ||
9890 | /* 4- Add the field as an argument */ | |
bccaf73a PB |
9891 | args = nreverse (args); |
9892 | this_arg = field; | |
8b27f225 PB |
9893 | } |
9894 | ||
5e942c50 | 9895 | /* IDENTIFIER_WFL will be used to report any problem further */ |
8b27f225 PB |
9896 | wfl = identifier_wfl; |
9897 | } | |
9898 | /* Resolution of simple names, names generated after a primary: or | |
9899 | constructors */ | |
9900 | else | |
9901 | { | |
cd531a2e | 9902 | tree class_to_search = NULL_TREE; |
8b27f225 PB |
9903 | int lc; /* Looking for Constructor */ |
9904 | ||
9905 | /* We search constructor in their target class */ | |
9906 | if (CALL_CONSTRUCTOR_P (patch)) | |
9907 | { | |
22eed1e6 APB |
9908 | if (TREE_CODE (patch) == NEW_CLASS_EXPR) |
9909 | class_to_search = EXPR_WFL_NODE (wfl); | |
9910 | else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) == | |
9911 | this_identifier_node) | |
9912 | class_to_search = NULL_TREE; | |
9913 | else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) == | |
9914 | super_identifier_node) | |
8b27f225 | 9915 | { |
ac825856 | 9916 | is_super_init = 1; |
22eed1e6 APB |
9917 | if (CLASSTYPE_SUPER (current_class)) |
9918 | class_to_search = | |
9919 | DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class))); | |
9920 | else | |
9921 | { | |
781b0558 | 9922 | parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object"); |
22eed1e6 APB |
9923 | PATCH_METHOD_RETURN_ERROR (); |
9924 | } | |
8b27f225 | 9925 | } |
22eed1e6 APB |
9926 | |
9927 | /* Class to search is NULL if we're searching the current one */ | |
9928 | if (class_to_search) | |
8b27f225 | 9929 | { |
23a79c61 APB |
9930 | class_to_search = resolve_and_layout (class_to_search, |
9931 | NULL_TREE); | |
22eed1e6 APB |
9932 | if (!class_to_search) |
9933 | { | |
9934 | parse_error_context | |
9935 | (wfl, "Class `%s' not found in type declaration", | |
9936 | IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl))); | |
9937 | PATCH_METHOD_RETURN_ERROR (); | |
9938 | } | |
9939 | ||
5e942c50 APB |
9940 | /* Can't instantiate an abstract class, but we can |
9941 | invoke it's constructor. It's use within the `new' | |
9942 | context is denied here. */ | |
9943 | if (CLASS_ABSTRACT (class_to_search) | |
9944 | && TREE_CODE (patch) == NEW_CLASS_EXPR) | |
22eed1e6 APB |
9945 | { |
9946 | parse_error_context | |
781b0558 KG |
9947 | (wfl, "Class `%s' is an abstract class. It can't be instantiated", |
9948 | IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl))); | |
22eed1e6 APB |
9949 | PATCH_METHOD_RETURN_ERROR (); |
9950 | } | |
9951 | class_to_search = TREE_TYPE (class_to_search); | |
8b27f225 | 9952 | } |
22eed1e6 APB |
9953 | else |
9954 | class_to_search = current_class; | |
8b27f225 PB |
9955 | lc = 1; |
9956 | } | |
9957 | /* This is a regular search in the local class, unless an | |
9958 | alternate class is specified. */ | |
9959 | else | |
9960 | { | |
9961 | class_to_search = (where ? where : current_class); | |
9962 | lc = 0; | |
9963 | } | |
9964 | ||
9965 | /* NAME is a simple identifier or comes from a primary. Search | |
9966 | in the class whose declaration contain the method being | |
9967 | invoked. */ | |
c877974e | 9968 | resolve_and_layout (class_to_search, NULL_TREE); |
8b27f225 PB |
9969 | list = lookup_method_invoke (lc, wfl, class_to_search, name, args); |
9970 | ||
9971 | /* Don't continue if no method were found, as the next statement | |
9972 | can't be executed then. */ | |
9973 | if (!list) | |
9974 | PATCH_METHOD_RETURN_ERROR (); | |
9975 | ||
9976 | /* Check for static reference if non static methods */ | |
9977 | if (check_for_static_method_reference (wfl, patch, list, | |
9978 | class_to_search, primary)) | |
9979 | PATCH_METHOD_RETURN_ERROR (); | |
9980 | ||
22eed1e6 APB |
9981 | /* Non static methods are called with the current object extra |
9982 | argument. If patch a `new TYPE()', the argument is the value | |
9983 | returned by the object allocator. If method is resolved as a | |
9984 | primary, use the primary otherwise use the current THIS. */ | |
8b27f225 | 9985 | args = nreverse (args); |
bccaf73a PB |
9986 | if (TREE_CODE (patch) != NEW_CLASS_EXPR) |
9987 | this_arg = primary ? primary : current_this; | |
8b27f225 PB |
9988 | } |
9989 | ||
9990 | /* Merge point of all resolution schemes. If we have nothing, this | |
9991 | is an error, already signaled */ | |
9992 | if (!list) | |
9993 | PATCH_METHOD_RETURN_ERROR (); | |
9994 | ||
9995 | /* Check accessibility, position the is_static flag, build and | |
9996 | return the call */ | |
c877974e | 9997 | if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0)) |
8b27f225 | 9998 | { |
c2e3db92 | 9999 | char *fct_name = xstrdup (lang_printable_name (list, 0)); |
8b27f225 PB |
10000 | parse_error_context |
10001 | (wfl, "Can't access %s method `%s %s.%s' from `%s'", | |
10002 | java_accstring_lookup (get_access_flags_from_decl (list)), | |
10003 | lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), | |
5e942c50 APB |
10004 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))), |
10005 | fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class)))); | |
8b27f225 PB |
10006 | free (fct_name); |
10007 | PATCH_METHOD_RETURN_ERROR (); | |
10008 | } | |
5e942c50 | 10009 | check_deprecation (wfl, list); |
22eed1e6 APB |
10010 | |
10011 | is_static_flag = METHOD_STATIC (list); | |
bccaf73a PB |
10012 | if (! METHOD_STATIC (list) && this_arg != NULL_TREE) |
10013 | args = tree_cons (NULL_TREE, this_arg, args); | |
22eed1e6 | 10014 | |
c3f2a476 APB |
10015 | /* In the context of an explicit constructor invocation, we can't |
10016 | invoke any method relying on `this'. Exceptions are: we're | |
10017 | invoking a static function, primary exists and is not the current | |
10018 | this, we're creating a new object. */ | |
22eed1e6 | 10019 | if (ctxp->explicit_constructor_p |
c3f2a476 APB |
10020 | && !is_static_flag |
10021 | && (!primary || primary == current_this) | |
10022 | && (TREE_CODE (patch) != NEW_CLASS_EXPR)) | |
22eed1e6 | 10023 | { |
781b0558 | 10024 | parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called"); |
22eed1e6 APB |
10025 | PATCH_METHOD_RETURN_ERROR (); |
10026 | } | |
8b27f225 | 10027 | java_parser_context_restore_global (); |
22eed1e6 APB |
10028 | if (is_static) |
10029 | *is_static = is_static_flag; | |
8b27f225 PB |
10030 | /* Sometimes, we want the decl of the selected method. Such as for |
10031 | EH checking */ | |
10032 | if (ret_decl) | |
10033 | *ret_decl = list; | |
ac825856 APB |
10034 | patch = patch_invoke (patch, list, args); |
10035 | if (is_super_init && CLASS_HAS_FINIT_P (current_class)) | |
10036 | { | |
10037 | /* Generate the code used to initialize fields declared with an | |
10038 | initialization statement. For now, it returns a call the the | |
10039 | artificial function $finit$, if required. */ | |
10040 | ||
10041 | tree finit_call = | |
10042 | build_method_invocation (build_expr_wfl (finit_identifier_node, | |
10043 | input_filename, 0, 0), | |
10044 | NULL_TREE); | |
10045 | patch = build (COMPOUND_EXPR, void_type_node, patch, | |
10046 | java_complete_tree (finit_call)); | |
10047 | CAN_COMPLETE_NORMALLY (patch) = 1; | |
10048 | } | |
10049 | return patch; | |
8b27f225 PB |
10050 | } |
10051 | ||
10052 | /* Check that we're not trying to do a static reference to a method in | |
10053 | non static method. Return 1 if it's the case, 0 otherwise. */ | |
10054 | ||
10055 | static int | |
10056 | check_for_static_method_reference (wfl, node, method, where, primary) | |
10057 | tree wfl, node, method, where, primary; | |
10058 | { | |
10059 | if (METHOD_STATIC (current_function_decl) | |
10060 | && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node)) | |
10061 | { | |
c2e3db92 | 10062 | char *fct_name = xstrdup (lang_printable_name (method, 0)); |
8b27f225 PB |
10063 | parse_error_context |
10064 | (wfl, "Can't make static reference to method `%s %s' in class `%s'", | |
10065 | lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name, | |
10066 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where)))); | |
10067 | free (fct_name); | |
10068 | return 1; | |
10069 | } | |
10070 | return 0; | |
10071 | } | |
10072 | ||
10073 | /* Patch an invoke expression METHOD and ARGS, based on its invocation | |
10074 | mode. */ | |
10075 | ||
10076 | static tree | |
ac825856 | 10077 | patch_invoke (patch, method, args) |
8b27f225 PB |
10078 | tree patch, method, args; |
10079 | { | |
8b27f225 | 10080 | tree dtable, func; |
8b27f225 PB |
10081 | tree original_call, t, ta; |
10082 | ||
5e942c50 APB |
10083 | /* Last step for args: convert build-in types. If we're dealing with |
10084 | a new TYPE() type call, the first argument to the constructor | |
10085 | isn't found in the incomming argument list, but delivered by | |
10086 | `new' */ | |
10087 | t = TYPE_ARG_TYPES (TREE_TYPE (method)); | |
10088 | if (TREE_CODE (patch) == NEW_CLASS_EXPR) | |
10089 | t = TREE_CHAIN (t); | |
ac825856 APB |
10090 | for (ta = args; t != end_params_node && ta; |
10091 | t = TREE_CHAIN (t), ta = TREE_CHAIN (ta)) | |
8b27f225 PB |
10092 | if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) && |
10093 | TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t)) | |
10094 | TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta)); | |
1a6d4fb7 APB |
10095 | |
10096 | /* Resolve unresolved returned type isses */ | |
10097 | t = TREE_TYPE (TREE_TYPE (method)); | |
10098 | if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t))) | |
10099 | resolve_and_layout (TREE_TYPE (t), NULL); | |
22eed1e6 | 10100 | |
5423609c | 10101 | if (flag_emit_class_files || flag_emit_xref) |
12472854 PB |
10102 | func = method; |
10103 | else | |
8b27f225 | 10104 | { |
12472854 | 10105 | tree signature = build_java_signature (TREE_TYPE (method)); |
ac825856 | 10106 | switch (invocation_mode (method, CALL_USING_SUPER (patch))) |
12472854 PB |
10107 | { |
10108 | case INVOKE_VIRTUAL: | |
10109 | dtable = invoke_build_dtable (0, args); | |
10110 | func = build_invokevirtual (dtable, method); | |
10111 | break; | |
8b27f225 | 10112 | |
12472854 PB |
10113 | case INVOKE_SUPER: |
10114 | case INVOKE_STATIC: | |
10115 | func = build_known_method_ref (method, TREE_TYPE (method), | |
10116 | DECL_CONTEXT (method), | |
10117 | signature, args); | |
10118 | break; | |
8b27f225 | 10119 | |
12472854 PB |
10120 | case INVOKE_INTERFACE: |
10121 | dtable = invoke_build_dtable (1, args); | |
10122 | func = build_invokeinterface (dtable, DECL_NAME (method), signature); | |
10123 | break; | |
5e942c50 | 10124 | |
12472854 | 10125 | default: |
ac825856 | 10126 | fatal ("internal error - unknown invocation_mode result"); |
12472854 PB |
10127 | } |
10128 | ||
10129 | /* Ensure self_type is initialized, (invokestatic). FIXME */ | |
10130 | func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func); | |
8b27f225 PB |
10131 | } |
10132 | ||
8b27f225 PB |
10133 | TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method)); |
10134 | TREE_OPERAND (patch, 0) = func; | |
10135 | TREE_OPERAND (patch, 1) = args; | |
10136 | original_call = patch; | |
10137 | ||
22eed1e6 APB |
10138 | /* We're processing a `new TYPE ()' form. New is called an its |
10139 | returned value is the first argument to the constructor. We build | |
10140 | a COMPOUND_EXPR and use saved expression so that the overall NEW | |
10141 | expression value is a pointer to a newly created and initialized | |
10142 | class. */ | |
10143 | if (TREE_CODE (original_call) == NEW_CLASS_EXPR) | |
8b27f225 PB |
10144 | { |
10145 | tree class = DECL_CONTEXT (method); | |
10146 | tree c1, saved_new, size, new; | |
5423609c | 10147 | if (flag_emit_class_files || flag_emit_xref) |
12472854 PB |
10148 | { |
10149 | TREE_TYPE (patch) = build_pointer_type (class); | |
10150 | return patch; | |
10151 | } | |
8b27f225 PB |
10152 | if (!TYPE_SIZE (class)) |
10153 | safe_layout_class (class); | |
10154 | size = size_in_bytes (class); | |
10155 | new = build (CALL_EXPR, promote_type (class), | |
10156 | build_address_of (alloc_object_node), | |
10157 | tree_cons (NULL_TREE, build_class_ref (class), | |
10158 | build_tree_list (NULL_TREE, | |
10159 | size_in_bytes (class))), | |
10160 | NULL_TREE); | |
10161 | saved_new = save_expr (new); | |
10162 | c1 = build_tree_list (NULL_TREE, saved_new); | |
10163 | TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1); | |
10164 | TREE_OPERAND (original_call, 1) = c1; | |
10165 | TREE_SET_CODE (original_call, CALL_EXPR); | |
10166 | patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new); | |
10167 | } | |
10168 | return patch; | |
10169 | } | |
10170 | ||
10171 | static int | |
10172 | invocation_mode (method, super) | |
10173 | tree method; | |
10174 | int super; | |
10175 | { | |
10176 | int access = get_access_flags_from_decl (method); | |
10177 | ||
22eed1e6 APB |
10178 | if (super) |
10179 | return INVOKE_SUPER; | |
10180 | ||
82371d41 | 10181 | if (access & ACC_STATIC || access & ACC_FINAL || access & ACC_PRIVATE) |
8b27f225 PB |
10182 | return INVOKE_STATIC; |
10183 | ||
10184 | if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method)))) | |
10185 | return INVOKE_STATIC; | |
10186 | ||
8b27f225 PB |
10187 | if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method)))) |
10188 | return INVOKE_INTERFACE; | |
10189 | ||
10190 | if (DECL_CONSTRUCTOR_P (method)) | |
10191 | return INVOKE_STATIC; | |
22eed1e6 | 10192 | |
8b27f225 PB |
10193 | return INVOKE_VIRTUAL; |
10194 | } | |
10195 | ||
10196 | /* Retrieve a refined list of matching methods. It covers the step | |
10197 | 15.11.2 (Compile-Time Step 2) */ | |
10198 | ||
10199 | static tree | |
10200 | lookup_method_invoke (lc, cl, class, name, arg_list) | |
10201 | int lc; | |
10202 | tree cl; | |
10203 | tree class, name, arg_list; | |
10204 | { | |
82371d41 | 10205 | tree atl = end_params_node; /* Arg Type List */ |
c877974e | 10206 | tree method, signature, list, node; |
49f48c71 | 10207 | const char *candidates; /* Used for error report */ |
b5b8a0e7 | 10208 | char *dup; |
8b27f225 | 10209 | |
5e942c50 | 10210 | /* Fix the arguments */ |
8b27f225 PB |
10211 | for (node = arg_list; node; node = TREE_CHAIN (node)) |
10212 | { | |
0b4d333e | 10213 | tree current_arg = TREE_TYPE (TREE_VALUE (node)); |
c877974e | 10214 | /* Non primitive type may have to be resolved */ |
0b4d333e | 10215 | if (!JPRIMITIVE_TYPE_P (current_arg)) |
c877974e APB |
10216 | resolve_and_layout (current_arg, NULL_TREE); |
10217 | /* And promoted */ | |
8b27f225 | 10218 | if (TREE_CODE (current_arg) == RECORD_TYPE) |
c877974e | 10219 | current_arg = promote_type (current_arg); |
5e942c50 | 10220 | atl = tree_cons (NULL_TREE, current_arg, atl); |
8b27f225 PB |
10221 | } |
10222 | ||
5e942c50 APB |
10223 | /* Find all candidates and then refine the list, searching for the |
10224 | most specific method. */ | |
10225 | list = find_applicable_accessible_methods_list (lc, class, name, atl); | |
10226 | list = find_most_specific_methods_list (list); | |
8b27f225 PB |
10227 | if (list && !TREE_CHAIN (list)) |
10228 | return TREE_VALUE (list); | |
10229 | ||
10230 | /* Issue an error. List candidates if any. Candidates are listed | |
10231 | only if accessible (non accessible methods may end-up here for | |
10232 | the sake of a better error report). */ | |
10233 | candidates = NULL; | |
10234 | if (list) | |
10235 | { | |
10236 | tree current; | |
10237 | obstack_grow (&temporary_obstack, ". Candidates are:\n", 18); | |
10238 | for (current = list; current; current = TREE_CHAIN (current)) | |
10239 | { | |
10240 | tree cm = TREE_VALUE (current); | |
10241 | char string [4096]; | |
10242 | if (!cm || not_accessible_p (class, cm, 0)) | |
10243 | continue; | |
8b27f225 | 10244 | sprintf |
22eed1e6 APB |
10245 | (string, " `%s' in `%s'%s", |
10246 | get_printable_method_name (cm), | |
8b27f225 PB |
10247 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))), |
10248 | (TREE_CHAIN (current) ? "\n" : "")); | |
10249 | obstack_grow (&temporary_obstack, string, strlen (string)); | |
10250 | } | |
10251 | obstack_1grow (&temporary_obstack, '\0'); | |
10252 | candidates = obstack_finish (&temporary_obstack); | |
10253 | } | |
10254 | /* Issue the error message */ | |
c877974e APB |
10255 | method = make_node (FUNCTION_TYPE); |
10256 | TYPE_ARG_TYPES (method) = atl; | |
8b27f225 | 10257 | signature = build_java_argument_signature (method); |
c63b98cd | 10258 | dup = xstrdup (lang_printable_name (class, 0)); |
b5b8a0e7 | 10259 | parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s", |
22eed1e6 | 10260 | (lc ? "constructor" : "method"), |
b5b8a0e7 APB |
10261 | (lc ? dup : IDENTIFIER_POINTER (name)), |
10262 | IDENTIFIER_POINTER (signature), dup, | |
8b27f225 | 10263 | (candidates ? candidates : "")); |
b5b8a0e7 | 10264 | free (dup); |
8b27f225 PB |
10265 | return NULL_TREE; |
10266 | } | |
10267 | ||
5e942c50 APB |
10268 | /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1 |
10269 | when we're looking for a constructor. */ | |
8b27f225 PB |
10270 | |
10271 | static tree | |
5e942c50 APB |
10272 | find_applicable_accessible_methods_list (lc, class, name, arglist) |
10273 | int lc; | |
8b27f225 PB |
10274 | tree class, name, arglist; |
10275 | { | |
8b27f225 PB |
10276 | tree list = NULL_TREE, all_list = NULL_TREE; |
10277 | ||
cc596f8c | 10278 | /* Search interfaces */ |
f4e16489 APB |
10279 | if (CLASS_INTERFACE (TYPE_NAME (class)) |
10280 | || CLASS_ABSTRACT (TYPE_NAME (class))) | |
8b27f225 | 10281 | { |
de0b553f APB |
10282 | static tree searched_interfaces = NULL_TREE; |
10283 | static int search_not_done = 0; | |
cc596f8c APB |
10284 | int i, n; |
10285 | tree basetype_vec = TYPE_BINFO_BASETYPES (class); | |
10286 | ||
de0b553f APB |
10287 | /* Have we searched this interface already? */ |
10288 | if (searched_interfaces) | |
10289 | { | |
10290 | tree current; | |
10291 | for (current = searched_interfaces; | |
10292 | current; current = TREE_CHAIN (current)) | |
10293 | if (TREE_VALUE (current) == class) | |
10294 | return NULL; | |
10295 | } | |
10296 | searched_interfaces = tree_cons (NULL_TREE, class, searched_interfaces); | |
10297 | ||
cc596f8c APB |
10298 | search_applicable_methods_list |
10299 | (lc, TYPE_METHODS (class), name, arglist, &list, &all_list); | |
10300 | ||
10301 | n = TREE_VEC_LENGTH (basetype_vec); | |
10302 | for (i = 0; i < n; i++) | |
8b27f225 | 10303 | { |
de0b553f APB |
10304 | tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)); |
10305 | tree rlist; | |
10306 | ||
10307 | /* Skip java.lang.Object (we'll search it once later.) */ | |
10308 | if (t == object_type_node) | |
10309 | continue; | |
10310 | ||
10311 | search_not_done++; | |
10312 | rlist = find_applicable_accessible_methods_list (lc, t, name, | |
10313 | arglist); | |
cc596f8c | 10314 | all_list = chainon (rlist, (list ? list : all_list)); |
de0b553f APB |
10315 | search_not_done--; |
10316 | } | |
10317 | ||
10318 | /* We're done. Reset the searched interfaces list and finally search | |
10319 | java.lang.Object */ | |
10320 | if (!search_not_done) | |
10321 | { | |
10322 | searched_interfaces = NULL_TREE; | |
10323 | search_applicable_methods_list (lc, TYPE_METHODS (object_type_node), | |
10324 | name, arglist, &list, &all_list); | |
8b27f225 | 10325 | } |
8b27f225 | 10326 | } |
cc596f8c APB |
10327 | /* Search classes */ |
10328 | else | |
10329 | while (class != NULL_TREE) | |
10330 | { | |
10331 | search_applicable_methods_list | |
10332 | (lc, TYPE_METHODS (class), name, arglist, &list, &all_list); | |
10333 | class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class)); | |
10334 | } | |
10335 | ||
8b27f225 PB |
10336 | /* Either return the list obtained or all selected (but |
10337 | inaccessible) methods for better error report. */ | |
10338 | return (!list ? all_list : list); | |
10339 | } | |
10340 | ||
cc596f8c APB |
10341 | /* Effectively search for the approriate method in method */ |
10342 | ||
10343 | static void | |
10344 | search_applicable_methods_list(lc, method, name, arglist, list, all_list) | |
10345 | int lc; | |
10346 | tree method, name, arglist; | |
10347 | tree *list, *all_list; | |
10348 | { | |
10349 | for (; method; method = TREE_CHAIN (method)) | |
10350 | { | |
10351 | /* When dealing with constructor, stop here, otherwise search | |
10352 | other classes */ | |
10353 | if (lc && !DECL_CONSTRUCTOR_P (method)) | |
10354 | continue; | |
10355 | else if (!lc && (DECL_CONSTRUCTOR_P (method) | |
10356 | || (GET_METHOD_NAME (method) != name))) | |
10357 | continue; | |
10358 | ||
10359 | if (argument_types_convertible (method, arglist)) | |
10360 | { | |
10361 | /* Retain accessible methods only */ | |
10362 | if (!not_accessible_p (DECL_CONTEXT (current_function_decl), | |
10363 | method, 0)) | |
10364 | *list = tree_cons (NULL_TREE, method, *list); | |
10365 | else | |
10366 | /* Also retain all selected method here */ | |
10367 | *all_list = tree_cons (NULL_TREE, method, *list); | |
10368 | } | |
10369 | } | |
10370 | } | |
10371 | ||
8b27f225 PB |
10372 | /* 15.11.2.2 Choose the Most Specific Method */ |
10373 | ||
10374 | static tree | |
10375 | find_most_specific_methods_list (list) | |
10376 | tree list; | |
10377 | { | |
10378 | int max = 0; | |
10379 | tree current, new_list = NULL_TREE; | |
10380 | for (current = list; current; current = TREE_CHAIN (current)) | |
10381 | { | |
10382 | tree method; | |
10383 | DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0; | |
10384 | ||
10385 | for (method = list; method; method = TREE_CHAIN (method)) | |
10386 | { | |
10387 | /* Don't test a method against itself */ | |
10388 | if (method == current) | |
10389 | continue; | |
10390 | ||
10391 | /* Compare arguments and location where method where declared */ | |
10392 | if (argument_types_convertible (TREE_VALUE (method), | |
10393 | TREE_VALUE (current)) | |
10394 | && valid_method_invocation_conversion_p | |
10395 | (DECL_CONTEXT (TREE_VALUE (method)), | |
10396 | DECL_CONTEXT (TREE_VALUE (current)))) | |
10397 | { | |
10398 | int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current)); | |
10399 | max = (v > max ? v : max); | |
10400 | } | |
10401 | } | |
10402 | } | |
10403 | ||
10404 | /* Review the list and select the maximally specific methods */ | |
10405 | for (current = list; current; current = TREE_CHAIN (current)) | |
10406 | if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max) | |
10407 | new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list); | |
10408 | ||
10409 | /* If we can't find one, lower expectations and try to gather multiple | |
10410 | maximally specific methods */ | |
10411 | while (!new_list) | |
10412 | { | |
10413 | while (--max > 0) | |
10414 | { | |
10415 | if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max) | |
10416 | new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list); | |
10417 | } | |
10418 | return new_list; | |
10419 | } | |
10420 | ||
10421 | return new_list; | |
10422 | } | |
10423 | ||
10424 | /* Make sure that the type of each M2_OR_ARGLIST arguments can be | |
10425 | converted by method invocation conversion (5.3) to the type of the | |
10426 | corresponding parameter of M1. Implementation expects M2_OR_ARGLIST | |
10427 | to change less often than M1. */ | |
10428 | ||
10429 | static int | |
10430 | argument_types_convertible (m1, m2_or_arglist) | |
10431 | tree m1, m2_or_arglist; | |
10432 | { | |
10433 | static tree m2_arg_value = NULL_TREE; | |
10434 | static tree m2_arg_cache = NULL_TREE; | |
10435 | ||
10436 | register tree m1_arg, m2_arg; | |
10437 | ||
10438 | m1_arg = TYPE_ARG_TYPES (TREE_TYPE (m1)); | |
10439 | if (!METHOD_STATIC (m1)) | |
10440 | m1_arg = TREE_CHAIN (m1_arg); | |
10441 | ||
10442 | if (m2_arg_value == m2_or_arglist) | |
10443 | m2_arg = m2_arg_cache; | |
10444 | else | |
10445 | { | |
10446 | /* M2_OR_ARGLIST can be a function DECL or a raw list of | |
10447 | argument types */ | |
10448 | if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL) | |
10449 | { | |
10450 | m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist)); | |
10451 | if (!METHOD_STATIC (m2_or_arglist)) | |
10452 | m2_arg = TREE_CHAIN (m2_arg); | |
10453 | } | |
10454 | else | |
10455 | m2_arg = m2_or_arglist; | |
10456 | ||
10457 | m2_arg_value = m2_or_arglist; | |
10458 | m2_arg_cache = m2_arg; | |
10459 | } | |
10460 | ||
82371d41 | 10461 | while (m1_arg != end_params_node && m2_arg != end_params_node) |
8b27f225 | 10462 | { |
c877974e | 10463 | resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE); |
8b27f225 PB |
10464 | if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg), |
10465 | TREE_VALUE (m2_arg))) | |
10466 | break; | |
10467 | m1_arg = TREE_CHAIN (m1_arg); | |
10468 | m2_arg = TREE_CHAIN (m2_arg); | |
10469 | } | |
82371d41 | 10470 | return m1_arg == end_params_node && m2_arg == end_params_node; |
8b27f225 PB |
10471 | } |
10472 | ||
10473 | /* Qualification routines */ | |
10474 | ||
10475 | static void | |
10476 | qualify_ambiguous_name (id) | |
10477 | tree id; | |
10478 | { | |
cd531a2e KG |
10479 | tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE, |
10480 | saved_current_class; | |
d8fccff5 | 10481 | int again, super_found = 0, this_found = 0, new_array_found = 0; |
8576f094 | 10482 | int code; |
8b27f225 PB |
10483 | |
10484 | /* We first qualify the first element, then derive qualification of | |
10485 | others based on the first one. If the first element is qualified | |
10486 | by a resolution (field or type), this resolution is stored in the | |
10487 | QUAL_RESOLUTION of the qual element being examined. We need to | |
10488 | save the current_class since the use of SUPER might change the | |
10489 | its value. */ | |
10490 | saved_current_class = current_class; | |
10491 | qual = EXPR_WFL_QUALIFICATION (id); | |
10492 | do { | |
10493 | ||
10494 | /* Simple qualified expression feature a qual_wfl that is a | |
10495 | WFL. Expression derived from a primary feature more complicated | |
10496 | things like a CALL_EXPR. Expression from primary need to be | |
10497 | worked out to extract the part on which the qualification will | |
10498 | take place. */ | |
10499 | qual_wfl = QUAL_WFL (qual); | |
10500 | switch (TREE_CODE (qual_wfl)) | |
10501 | { | |
10502 | case CALL_EXPR: | |
10503 | qual_wfl = TREE_OPERAND (qual_wfl, 0); | |
10504 | if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION) | |
10505 | { | |
10506 | qual = EXPR_WFL_QUALIFICATION (qual_wfl); | |
10507 | qual_wfl = QUAL_WFL (qual); | |
10508 | } | |
10509 | break; | |
d8fccff5 APB |
10510 | case NEW_ARRAY_EXPR: |
10511 | qual = TREE_CHAIN (qual); | |
1a6d4fb7 | 10512 | again = new_array_found = 1; |
d8fccff5 | 10513 | continue; |
8b27f225 PB |
10514 | case NEW_CLASS_EXPR: |
10515 | case CONVERT_EXPR: | |
10516 | qual_wfl = TREE_OPERAND (qual_wfl, 0); | |
10517 | break; | |
10518 | case ARRAY_REF: | |
10519 | while (TREE_CODE (qual_wfl) == ARRAY_REF) | |
10520 | qual_wfl = TREE_OPERAND (qual_wfl, 0); | |
10521 | break; | |
8576f094 APB |
10522 | case STRING_CST: |
10523 | qual = TREE_CHAIN (qual); | |
10524 | qual_wfl = QUAL_WFL (qual); | |
10525 | break; | |
8b27f225 PB |
10526 | default: |
10527 | /* Fix for -Wall. Just break doing nothing */ | |
10528 | break; | |
10529 | } | |
8576f094 | 10530 | |
8b27f225 PB |
10531 | ptr_type = current_class; |
10532 | again = 0; | |
8576f094 APB |
10533 | code = TREE_CODE (qual_wfl); |
10534 | ||
10535 | /* Pos evaluation: non WFL leading expression nodes */ | |
10536 | if (code == CONVERT_EXPR | |
10537 | && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION) | |
10538 | name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl)); | |
10539 | ||
ac22f9cb | 10540 | else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) && |
8576f094 APB |
10541 | TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION) |
10542 | name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0)); | |
10543 | ||
b5b8a0e7 APB |
10544 | else if (code == STRING_CST || code == CONDITIONAL_EXPR |
10545 | || code == PLUS_EXPR) | |
8576f094 APB |
10546 | { |
10547 | qual = TREE_CHAIN (qual); | |
10548 | qual_wfl = QUAL_WFL (qual); | |
10549 | again = 1; | |
10550 | } | |
10551 | else | |
f441f671 APB |
10552 | { |
10553 | name = EXPR_WFL_NODE (qual_wfl); | |
10554 | if (!name) | |
10555 | { | |
10556 | qual = EXPR_WFL_QUALIFICATION (qual_wfl); | |
10557 | again = 1; | |
10558 | } | |
10559 | } | |
10560 | ||
8b27f225 PB |
10561 | /* If we have a THIS (from a primary), we set the context accordingly */ |
10562 | if (name == this_identifier_node) | |
10563 | { | |
10564 | qual = TREE_CHAIN (qual); | |
10565 | qual_wfl = QUAL_WFL (qual); | |
22eed1e6 APB |
10566 | if (TREE_CODE (qual_wfl) == CALL_EXPR) |
10567 | again = 1; | |
10568 | else | |
10569 | name = EXPR_WFL_NODE (qual_wfl); | |
8b27f225 PB |
10570 | this_found = 1; |
10571 | } | |
10572 | /* If we have a SUPER, we set the context accordingly */ | |
10573 | if (name == super_identifier_node) | |
10574 | { | |
10575 | current_class = CLASSTYPE_SUPER (ptr_type); | |
10576 | /* Check that there is such a thing as a super class. If not, | |
10577 | return. The error will be caught later on, during the | |
10578 | resolution */ | |
10579 | if (!current_class) | |
10580 | { | |
10581 | current_class = saved_current_class; | |
10582 | return; | |
10583 | } | |
10584 | qual = TREE_CHAIN (qual); | |
10585 | /* Do one more interation to set things up */ | |
10586 | super_found = again = 1; | |
10587 | } | |
10588 | } while (again); | |
10589 | ||
10590 | /* If name appears within the scope of a location variable | |
10591 | declaration or parameter declaration, then it is an expression | |
10592 | name. We don't carry this test out if we're in the context of the | |
10593 | use of SUPER or THIS */ | |
1a6d4fb7 APB |
10594 | if (!this_found && !super_found && |
10595 | TREE_CODE (name) != STRING_CST && (decl = IDENTIFIER_LOCAL_VALUE (name))) | |
8b27f225 PB |
10596 | { |
10597 | RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1; | |
10598 | QUAL_RESOLUTION (qual) = decl; | |
10599 | } | |
10600 | ||
10601 | /* If within the class/interface NAME was found to be used there | |
10602 | exists a (possibly inherited) field named NAME, then this is an | |
d8fccff5 APB |
10603 | expression name. If we saw a NEW_ARRAY_EXPR before and want to |
10604 | address length, it is OK. */ | |
10605 | else if ((decl = lookup_field_wrapper (ptr_type, name)) | |
10606 | || (new_array_found && name == length_identifier_node)) | |
8b27f225 PB |
10607 | { |
10608 | RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1; | |
d8fccff5 | 10609 | QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl); |
8b27f225 PB |
10610 | } |
10611 | ||
1a6d4fb7 | 10612 | /* We reclassify NAME as yielding to a type name resolution if: |
8b27f225 PB |
10613 | - NAME is a class/interface declared within the compilation |
10614 | unit containing NAME, | |
10615 | - NAME is imported via a single-type-import declaration, | |
10616 | - NAME is declared in an another compilation unit of the package | |
10617 | of the compilation unit containing NAME, | |
10618 | - NAME is declared by exactly on type-import-on-demand declaration | |
1a6d4fb7 APB |
10619 | of the compilation unit containing NAME. |
10620 | - NAME is actually a STRING_CST. */ | |
10621 | else if (TREE_CODE (name) == STRING_CST || | |
10622 | (decl = resolve_and_layout (name, NULL_TREE))) | |
8b27f225 PB |
10623 | { |
10624 | RESOLVE_TYPE_NAME_P (qual_wfl) = 1; | |
10625 | QUAL_RESOLUTION (qual) = decl; | |
10626 | } | |
10627 | ||
10628 | /* Method call are expression name */ | |
c877974e | 10629 | else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR |
8576f094 APB |
10630 | || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF |
10631 | || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR) | |
8b27f225 PB |
10632 | RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1; |
10633 | ||
10634 | /* Check here that NAME isn't declared by more than one | |
10635 | type-import-on-demand declaration of the compilation unit | |
10636 | containing NAME. FIXME */ | |
10637 | ||
10638 | /* Otherwise, NAME is reclassified as a package name */ | |
10639 | else | |
10640 | RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1; | |
10641 | ||
10642 | /* Propagate the qualification accross other components of the | |
10643 | qualified name */ | |
10644 | for (qual = TREE_CHAIN (qual); qual; | |
10645 | qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual)) | |
10646 | { | |
10647 | if (RESOLVE_PACKAGE_NAME_P (qual_wfl)) | |
10648 | RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1; | |
10649 | else | |
10650 | RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1; | |
10651 | } | |
10652 | ||
10653 | /* Store the global qualification for the ambiguous part of ID back | |
10654 | into ID fields */ | |
10655 | if (RESOLVE_EXPRESSION_NAME_P (qual_wfl)) | |
10656 | RESOLVE_EXPRESSION_NAME_P (id) = 1; | |
10657 | else if (RESOLVE_TYPE_NAME_P (qual_wfl)) | |
10658 | RESOLVE_TYPE_NAME_P (id) = 1; | |
10659 | else if (RESOLVE_PACKAGE_NAME_P (qual_wfl)) | |
10660 | RESOLVE_PACKAGE_NAME_P (id) = 1; | |
10661 | ||
10662 | /* Restore the current class */ | |
10663 | current_class = saved_current_class; | |
10664 | } | |
10665 | ||
10666 | static int | |
10667 | breakdown_qualified (left, right, source) | |
10668 | tree *left, *right, source; | |
10669 | { | |
10670 | char *p = IDENTIFIER_POINTER (source), *base; | |
10671 | int l = IDENTIFIER_LENGTH (source); | |
10672 | ||
10673 | /* Breakdown NAME into REMAINDER . IDENTIFIER */ | |
10674 | base = p; | |
10675 | p += (l-1); | |
10676 | while (*p != '.' && p != base) | |
10677 | p--; | |
10678 | ||
10679 | /* We didn't find a '.'. Return an error */ | |
10680 | if (p == base) | |
10681 | return 1; | |
10682 | ||
10683 | *p = '\0'; | |
10684 | if (right) | |
10685 | *right = get_identifier (p+1); | |
10686 | *left = get_identifier (IDENTIFIER_POINTER (source)); | |
10687 | *p = '.'; | |
10688 | ||
10689 | return 0; | |
10690 | } | |
10691 | ||
8b27f225 | 10692 | /* Patch tree nodes in a function body. When a BLOCK is found, push |
5b09b33e PB |
10693 | local variable decls if present. |
10694 | Same as java_complete_lhs, but does resolve static finals to values. */ | |
8b27f225 PB |
10695 | |
10696 | static tree | |
10697 | java_complete_tree (node) | |
10698 | tree node; | |
5b09b33e PB |
10699 | { |
10700 | node = java_complete_lhs (node); | |
10701 | if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node) | |
7f10c2e2 APB |
10702 | && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE |
10703 | && !flag_emit_xref) | |
5b09b33e PB |
10704 | { |
10705 | tree value = DECL_INITIAL (node); | |
10706 | DECL_INITIAL (node) = NULL_TREE; | |
100f7cd8 | 10707 | push_obstacks (&permanent_obstack, &permanent_obstack); |
5b09b33e | 10708 | value = fold_constant_for_init (value, node); |
100f7cd8 | 10709 | pop_obstacks (); |
5b09b33e PB |
10710 | DECL_INITIAL (node) = value; |
10711 | if (value != NULL_TREE) | |
10712 | return value; | |
10713 | } | |
10714 | return node; | |
10715 | } | |
10716 | ||
2aa11e97 APB |
10717 | static tree |
10718 | java_stabilize_reference (node) | |
10719 | tree node; | |
10720 | { | |
10721 | if (TREE_CODE (node) == COMPOUND_EXPR) | |
10722 | { | |
10723 | tree op0 = TREE_OPERAND (node, 0); | |
10724 | tree op1 = TREE_OPERAND (node, 1); | |
642f15d1 | 10725 | TREE_OPERAND (node, 0) = save_expr (op0); |
2aa11e97 APB |
10726 | TREE_OPERAND (node, 1) = java_stabilize_reference (op1); |
10727 | return node; | |
10728 | } | |
5cbdba64 | 10729 | return stabilize_reference (node); |
2aa11e97 APB |
10730 | } |
10731 | ||
5b09b33e PB |
10732 | /* Patch tree nodes in a function body. When a BLOCK is found, push |
10733 | local variable decls if present. | |
10734 | Same as java_complete_tree, but does not resolve static finals to values. */ | |
10735 | ||
10736 | static tree | |
10737 | java_complete_lhs (node) | |
10738 | tree node; | |
8b27f225 | 10739 | { |
22eed1e6 | 10740 | tree nn, cn, wfl_op1, wfl_op2, wfl_op3; |
8b27f225 PB |
10741 | int flag; |
10742 | ||
10743 | /* CONVERT_EXPR always has its type set, even though it needs to be | |
10744 | worked out. */ | |
10745 | if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR) | |
10746 | return node; | |
10747 | ||
10748 | /* The switch block implements cases processing container nodes | |
10749 | first. Contained nodes are always written back. Leaves come | |
10750 | next and return a value. */ | |
10751 | switch (TREE_CODE (node)) | |
10752 | { | |
10753 | case BLOCK: | |
10754 | ||
10755 | /* 1- Block section. | |
10756 | Set the local values on decl names so we can identify them | |
10757 | faster when they're referenced. At that stage, identifiers | |
10758 | are legal so we don't check for declaration errors. */ | |
10759 | for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn)) | |
10760 | { | |
10761 | DECL_CONTEXT (cn) = current_function_decl; | |
10762 | IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn; | |
8b27f225 | 10763 | } |
12472854 PB |
10764 | if (BLOCK_EXPR_BODY (node) == NULL_TREE) |
10765 | CAN_COMPLETE_NORMALLY (node) = 1; | |
10766 | else | |
8b27f225 | 10767 | { |
12472854 PB |
10768 | tree stmt = BLOCK_EXPR_BODY (node); |
10769 | tree *ptr; | |
10770 | int error_seen = 0; | |
10771 | if (TREE_CODE (stmt) == COMPOUND_EXPR) | |
10772 | { | |
c877974e APB |
10773 | /* Re-order from (((A; B); C); ...; Z) to |
10774 | (A; (B; (C ; (...; Z)))). | |
12472854 PB |
10775 | This makes it easier to scan the statements left-to-right |
10776 | without using recursion (which might overflow the stack | |
10777 | if the block has many statements. */ | |
10778 | for (;;) | |
10779 | { | |
10780 | tree left = TREE_OPERAND (stmt, 0); | |
10781 | if (TREE_CODE (left) != COMPOUND_EXPR) | |
10782 | break; | |
10783 | TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1); | |
10784 | TREE_OPERAND (left, 1) = stmt; | |
10785 | stmt = left; | |
10786 | } | |
10787 | BLOCK_EXPR_BODY (node) = stmt; | |
10788 | } | |
10789 | ||
c877974e APB |
10790 | /* Now do the actual complete, without deep recursion for |
10791 | long blocks. */ | |
12472854 | 10792 | ptr = &BLOCK_EXPR_BODY (node); |
939d7216 PB |
10793 | while (TREE_CODE (*ptr) == COMPOUND_EXPR |
10794 | && TREE_OPERAND (*ptr, 1) != empty_stmt_node) | |
12472854 PB |
10795 | { |
10796 | tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0)); | |
10797 | tree *next = &TREE_OPERAND (*ptr, 1); | |
10798 | TREE_OPERAND (*ptr, 0) = cur; | |
cd9643f7 PB |
10799 | if (cur == empty_stmt_node) |
10800 | { | |
10801 | /* Optimization; makes it easier to detect empty bodies. | |
10802 | Most useful for <clinit> with all-constant initializer. */ | |
10803 | *ptr = *next; | |
10804 | continue; | |
10805 | } | |
12472854 PB |
10806 | if (TREE_CODE (cur) == ERROR_MARK) |
10807 | error_seen++; | |
10808 | else if (! CAN_COMPLETE_NORMALLY (cur)) | |
10809 | { | |
10810 | wfl_op2 = *next; | |
10811 | for (;;) | |
10812 | { | |
10813 | if (TREE_CODE (wfl_op2) == BLOCK) | |
10814 | wfl_op2 = BLOCK_EXPR_BODY (wfl_op2); | |
10815 | else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR) | |
10816 | wfl_op2 = TREE_OPERAND (wfl_op2, 0); | |
10817 | else | |
10818 | break; | |
10819 | } | |
10820 | if (TREE_CODE (wfl_op2) != CASE_EXPR | |
939d7216 | 10821 | && TREE_CODE (wfl_op2) != DEFAULT_EXPR) |
82371d41 | 10822 | unreachable_stmt_error (*ptr); |
12472854 PB |
10823 | } |
10824 | ptr = next; | |
10825 | } | |
10826 | *ptr = java_complete_tree (*ptr); | |
10827 | ||
10828 | if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0) | |
8b27f225 | 10829 | return error_mark_node; |
12472854 | 10830 | CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr); |
8b27f225 PB |
10831 | } |
10832 | /* Turn local bindings to null */ | |
10833 | for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn)) | |
10834 | IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE; | |
10835 | ||
10836 | TREE_TYPE (node) = void_type_node; | |
10837 | break; | |
10838 | ||
10839 | /* 2- They are expressions but ultimately deal with statements */ | |
10840 | ||
10841 | case THROW_EXPR: | |
10842 | wfl_op1 = TREE_OPERAND (node, 0); | |
10843 | COMPLETE_CHECK_OP_0 (node); | |
12472854 | 10844 | /* CAN_COMPLETE_NORMALLY (node) = 0; */ |
8b27f225 PB |
10845 | return patch_throw_statement (node, wfl_op1); |
10846 | ||
10847 | case SYNCHRONIZED_EXPR: | |
10848 | wfl_op1 = TREE_OPERAND (node, 0); | |
8b27f225 PB |
10849 | return patch_synchronized_statement (node, wfl_op1); |
10850 | ||
10851 | case TRY_EXPR: | |
10852 | return patch_try_statement (node); | |
10853 | ||
a7d8d81f PB |
10854 | case TRY_FINALLY_EXPR: |
10855 | COMPLETE_CHECK_OP_0 (node); | |
10856 | COMPLETE_CHECK_OP_1 (node); | |
10857 | CAN_COMPLETE_NORMALLY (node) | |
10858 | = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0)) | |
10859 | && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))); | |
10860 | TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0)); | |
10861 | return node; | |
10862 | ||
5a005d9e PB |
10863 | case CLEANUP_POINT_EXPR: |
10864 | COMPLETE_CHECK_OP_0 (node); | |
10865 | TREE_TYPE (node) = void_type_node; | |
2aa11e97 APB |
10866 | CAN_COMPLETE_NORMALLY (node) = |
10867 | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0)); | |
5a005d9e PB |
10868 | return node; |
10869 | ||
10870 | case WITH_CLEANUP_EXPR: | |
10871 | COMPLETE_CHECK_OP_0 (node); | |
10872 | COMPLETE_CHECK_OP_2 (node); | |
2aa11e97 APB |
10873 | CAN_COMPLETE_NORMALLY (node) = |
10874 | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0)); | |
5a005d9e PB |
10875 | TREE_TYPE (node) = void_type_node; |
10876 | return node; | |
10877 | ||
8b27f225 PB |
10878 | case LABELED_BLOCK_EXPR: |
10879 | PUSH_LABELED_BLOCK (node); | |
10880 | if (LABELED_BLOCK_BODY (node)) | |
10881 | COMPLETE_CHECK_OP_1 (node); | |
10882 | TREE_TYPE (node) = void_type_node; | |
10883 | POP_LABELED_BLOCK (); | |
1fb89a4d APB |
10884 | |
10885 | if (LABELED_BLOCK_BODY (node) == empty_stmt_node) | |
6efa1cc2 APB |
10886 | { |
10887 | LABELED_BLOCK_BODY (node) = NULL_TREE; | |
10888 | CAN_COMPLETE_NORMALLY (node) = 1; | |
10889 | } | |
1fb89a4d | 10890 | else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node))) |
12472854 | 10891 | CAN_COMPLETE_NORMALLY (node) = 1; |
8b27f225 PB |
10892 | return node; |
10893 | ||
10894 | case EXIT_BLOCK_EXPR: | |
10895 | /* We don't complete operand 1, because it's the return value of | |
10896 | the EXIT_BLOCK_EXPR which doesn't exist it Java */ | |
10897 | return patch_bc_statement (node); | |
10898 | ||
12472854 PB |
10899 | case CASE_EXPR: |
10900 | cn = java_complete_tree (TREE_OPERAND (node, 0)); | |
10901 | if (cn == error_mark_node) | |
10902 | return cn; | |
10903 | ||
8576f094 APB |
10904 | /* First, the case expression must be constant. Values of final |
10905 | fields are accepted. */ | |
12472854 | 10906 | cn = fold (cn); |
8576f094 APB |
10907 | if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF) |
10908 | && JDECL_P (TREE_OPERAND (cn, 1)) | |
10909 | && FIELD_FINAL (TREE_OPERAND (cn, 1)) | |
10910 | && DECL_INITIAL (TREE_OPERAND (cn, 1))) | |
100f7cd8 APB |
10911 | { |
10912 | push_obstacks (&permanent_obstack, &permanent_obstack); | |
10913 | cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)), | |
10914 | TREE_OPERAND (cn, 1)); | |
10915 | pop_obstacks (); | |
10916 | } | |
12472854 | 10917 | |
ce6e9147 | 10918 | if (!TREE_CONSTANT (cn) && !flag_emit_xref) |
12472854 PB |
10919 | { |
10920 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
10921 | parse_error_context (node, "Constant expression required"); | |
10922 | return error_mark_node; | |
10923 | } | |
10924 | ||
10925 | nn = ctxp->current_loop; | |
10926 | ||
10927 | /* It must be assignable to the type of the switch expression. */ | |
c877974e APB |
10928 | if (!try_builtin_assignconv (NULL_TREE, |
10929 | TREE_TYPE (TREE_OPERAND (nn, 0)), cn)) | |
12472854 PB |
10930 | { |
10931 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
10932 | parse_error_context | |
10933 | (wfl_operator, | |
10934 | "Incompatible type for case. Can't convert `%s' to `int'", | |
10935 | lang_printable_name (TREE_TYPE (cn), 0)); | |
10936 | return error_mark_node; | |
10937 | } | |
10938 | ||
10939 | cn = fold (convert (int_type_node, cn)); | |
10940 | ||
10941 | /* Multiple instance of a case label bearing the same | |
10942 | value is checked during code generation. The case | |
10943 | expression is allright so far. */ | |
10944 | TREE_OPERAND (node, 0) = cn; | |
c877974e | 10945 | TREE_TYPE (node) = void_type_node; |
12472854 | 10946 | CAN_COMPLETE_NORMALLY (node) = 1; |
23a79c61 | 10947 | TREE_SIDE_EFFECTS (node) = 1; |
12472854 PB |
10948 | break; |
10949 | ||
10950 | case DEFAULT_EXPR: | |
10951 | nn = ctxp->current_loop; | |
10952 | /* Only one default label is allowed per switch statement */ | |
10953 | if (SWITCH_HAS_DEFAULT (nn)) | |
10954 | { | |
10955 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
10956 | parse_error_context (wfl_operator, | |
10957 | "Duplicate case label: `default'"); | |
10958 | return error_mark_node; | |
10959 | } | |
10960 | else | |
10961 | SWITCH_HAS_DEFAULT (nn) = 1; | |
c877974e | 10962 | TREE_TYPE (node) = void_type_node; |
23a79c61 | 10963 | TREE_SIDE_EFFECTS (node) = 1; |
12472854 PB |
10964 | CAN_COMPLETE_NORMALLY (node) = 1; |
10965 | break; | |
10966 | ||
8b27f225 PB |
10967 | case SWITCH_EXPR: |
10968 | case LOOP_EXPR: | |
10969 | PUSH_LOOP (node); | |
10970 | /* Check whether the loop was enclosed in a labeled | |
10971 | statement. If not, create one, insert the loop in it and | |
10972 | return the node */ | |
10973 | nn = patch_loop_statement (node); | |
10974 | ||
10975 | /* Anyways, walk the body of the loop */ | |
10976 | if (TREE_CODE (node) == LOOP_EXPR) | |
10977 | TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0)); | |
10978 | /* Switch statement: walk the switch expression and the cases */ | |
10979 | else | |
10980 | node = patch_switch_statement (node); | |
10981 | ||
10982 | if (TREE_OPERAND (node, 0) == error_mark_node) | |
e85ac860 PB |
10983 | nn = error_mark_node; |
10984 | else | |
12472854 | 10985 | { |
e85ac860 PB |
10986 | TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node; |
10987 | /* If we returned something different, that's because we | |
10988 | inserted a label. Pop the label too. */ | |
10989 | if (nn != node) | |
10990 | { | |
10991 | if (CAN_COMPLETE_NORMALLY (node)) | |
10992 | CAN_COMPLETE_NORMALLY (nn) = 1; | |
10993 | POP_LABELED_BLOCK (); | |
10994 | } | |
12472854 | 10995 | } |
8b27f225 PB |
10996 | POP_LOOP (); |
10997 | return nn; | |
10998 | ||
10999 | case EXIT_EXPR: | |
11000 | TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0)); | |
11001 | return patch_exit_expr (node); | |
11002 | ||
11003 | case COND_EXPR: | |
11004 | /* Condition */ | |
11005 | TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0)); | |
11006 | if (TREE_OPERAND (node, 0) == error_mark_node) | |
11007 | return error_mark_node; | |
11008 | /* then-else branches */ | |
11009 | TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1)); | |
11010 | if (TREE_OPERAND (node, 1) == error_mark_node) | |
11011 | return error_mark_node; | |
11012 | TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2)); | |
11013 | if (TREE_OPERAND (node, 2) == error_mark_node) | |
11014 | return error_mark_node; | |
11015 | return patch_if_else_statement (node); | |
11016 | break; | |
11017 | ||
22eed1e6 APB |
11018 | case CONDITIONAL_EXPR: |
11019 | /* Condition */ | |
11020 | wfl_op1 = TREE_OPERAND (node, 0); | |
11021 | COMPLETE_CHECK_OP_0 (node); | |
11022 | wfl_op2 = TREE_OPERAND (node, 1); | |
11023 | COMPLETE_CHECK_OP_1 (node); | |
11024 | wfl_op3 = TREE_OPERAND (node, 2); | |
11025 | COMPLETE_CHECK_OP_2 (node); | |
11026 | return patch_conditional_expr (node, wfl_op1, wfl_op2); | |
11027 | ||
8b27f225 PB |
11028 | /* 3- Expression section */ |
11029 | case COMPOUND_EXPR: | |
12472854 | 11030 | wfl_op2 = TREE_OPERAND (node, 1); |
ac825856 APB |
11031 | TREE_OPERAND (node, 0) = nn = |
11032 | java_complete_tree (TREE_OPERAND (node, 0)); | |
939d7216 PB |
11033 | if (wfl_op2 == empty_stmt_node) |
11034 | CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn); | |
11035 | else | |
11036 | { | |
11037 | if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK) | |
bccaf73a | 11038 | { |
939d7216 PB |
11039 | /* An unreachable condition in a do-while statement |
11040 | is *not* (technically) an unreachable statement. */ | |
11041 | nn = wfl_op2; | |
11042 | if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION) | |
11043 | nn = EXPR_WFL_NODE (nn); | |
11044 | if (TREE_CODE (nn) != EXIT_EXPR) | |
11045 | { | |
11046 | SET_WFL_OPERATOR (wfl_operator, node, wfl_op2); | |
11047 | parse_error_context (wfl_operator, "Unreachable statement"); | |
11048 | } | |
bccaf73a | 11049 | } |
939d7216 PB |
11050 | TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1)); |
11051 | if (TREE_OPERAND (node, 1) == error_mark_node) | |
11052 | return error_mark_node; | |
11053 | CAN_COMPLETE_NORMALLY (node) | |
11054 | = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)); | |
12472854 | 11055 | } |
8b27f225 PB |
11056 | TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1)); |
11057 | break; | |
11058 | ||
11059 | case RETURN_EXPR: | |
12472854 | 11060 | /* CAN_COMPLETE_NORMALLY (node) = 0; */ |
8b27f225 PB |
11061 | return patch_return (node); |
11062 | ||
11063 | case EXPR_WITH_FILE_LOCATION: | |
11064 | if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */ | |
11065 | || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE) | |
12472854 | 11066 | { |
5423609c | 11067 | tree wfl = node; |
12472854 | 11068 | node = resolve_expression_name (node, NULL); |
939d7216 PB |
11069 | if (node == error_mark_node) |
11070 | return node; | |
5423609c APB |
11071 | /* Keep line number information somewhere were it doesn't |
11072 | disrupt the completion process. */ | |
2c56429a | 11073 | if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR) |
5423609c APB |
11074 | { |
11075 | EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1); | |
11076 | TREE_OPERAND (node, 1) = wfl; | |
11077 | } | |
12472854 PB |
11078 | CAN_COMPLETE_NORMALLY (node) = 1; |
11079 | } | |
8b27f225 PB |
11080 | else |
11081 | { | |
5b09b33e PB |
11082 | tree body; |
11083 | int save_lineno = lineno; | |
11084 | lineno = EXPR_WFL_LINENO (node); | |
11085 | body = java_complete_tree (EXPR_WFL_NODE (node)); | |
11086 | lineno = save_lineno; | |
12472854 | 11087 | EXPR_WFL_NODE (node) = body; |
939d7216 | 11088 | TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body); |
12472854 | 11089 | CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body); |
cd9643f7 PB |
11090 | if (body == empty_stmt_node) |
11091 | { | |
11092 | /* Optimization; makes it easier to detect empty bodies. */ | |
11093 | return body; | |
11094 | } | |
939d7216 | 11095 | if (body == error_mark_node) |
8b27f225 PB |
11096 | { |
11097 | /* Its important for the evaluation of assignment that | |
11098 | this mark on the TREE_TYPE is propagated. */ | |
11099 | TREE_TYPE (node) = error_mark_node; | |
11100 | return error_mark_node; | |
11101 | } | |
11102 | else | |
11103 | TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node)); | |
12472854 | 11104 | |
8b27f225 PB |
11105 | } |
11106 | break; | |
11107 | ||
11108 | case NEW_ARRAY_EXPR: | |
11109 | /* Patch all the dimensions */ | |
11110 | flag = 0; | |
11111 | for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn)) | |
11112 | { | |
11113 | int location = EXPR_WFL_LINECOL (TREE_VALUE (cn)); | |
781b0558 KG |
11114 | tree dim = convert (int_type_node, |
11115 | java_complete_tree (TREE_VALUE (cn))); | |
8b27f225 PB |
11116 | if (dim == error_mark_node) |
11117 | { | |
11118 | flag = 1; | |
11119 | continue; | |
11120 | } | |
11121 | else | |
11122 | { | |
11123 | TREE_VALUE (cn) = dim; | |
11124 | /* Setup the location of the current dimension, for | |
11125 | later error report. */ | |
11126 | TREE_PURPOSE (cn) = | |
11127 | build_expr_wfl (NULL_TREE, input_filename, 0, 0); | |
11128 | EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location; | |
11129 | } | |
11130 | } | |
11131 | /* They complete the array creation expression, if no errors | |
11132 | were found. */ | |
12472854 | 11133 | CAN_COMPLETE_NORMALLY (node) = 1; |
4fdea7b0 PB |
11134 | return (flag ? error_mark_node |
11135 | : force_evaluation_order (patch_newarray (node))); | |
8b27f225 PB |
11136 | |
11137 | case NEW_CLASS_EXPR: | |
11138 | case CALL_EXPR: | |
11139 | /* Complete function's argument(s) first */ | |
11140 | if (complete_function_arguments (node)) | |
11141 | return error_mark_node; | |
11142 | else | |
11143 | { | |
22eed1e6 APB |
11144 | tree decl, wfl = TREE_OPERAND (node, 0); |
11145 | int in_this = CALL_THIS_CONSTRUCTOR_P (node); | |
11146 | ||
c877974e | 11147 | node = patch_method_invocation (node, NULL_TREE, |
ac825856 | 11148 | NULL_TREE, 0, &decl); |
c877974e APB |
11149 | if (node == error_mark_node) |
11150 | return error_mark_node; | |
11151 | ||
11152 | check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl); | |
11153 | /* If we call this(...), register signature and positions */ | |
11154 | if (in_this) | |
11155 | DECL_CONSTRUCTOR_CALLS (current_function_decl) = | |
11156 | tree_cons (wfl, decl, | |
11157 | DECL_CONSTRUCTOR_CALLS (current_function_decl)); | |
82371d41 | 11158 | CAN_COMPLETE_NORMALLY (node) = 1; |
939d7216 | 11159 | return force_evaluation_order (node); |
8b27f225 PB |
11160 | } |
11161 | ||
11162 | case MODIFY_EXPR: | |
11163 | /* Save potential wfls */ | |
11164 | wfl_op1 = TREE_OPERAND (node, 0); | |
cd9643f7 PB |
11165 | TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1); |
11166 | if (MODIFY_EXPR_FROM_INITIALIZATION_P (node) | |
11167 | && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn) | |
11168 | && DECL_INITIAL (nn) != NULL_TREE) | |
11169 | { | |
100f7cd8 APB |
11170 | tree value; |
11171 | ||
11172 | push_obstacks (&permanent_obstack, &permanent_obstack); | |
11173 | value = fold_constant_for_init (nn, nn); | |
11174 | pop_obstacks (); | |
cd9643f7 PB |
11175 | if (value != NULL_TREE) |
11176 | { | |
11177 | tree type = TREE_TYPE (value); | |
11178 | if (JPRIMITIVE_TYPE_P (type) || type == string_ptr_type_node) | |
11179 | return empty_stmt_node; | |
11180 | } | |
11181 | DECL_INITIAL (nn) = NULL_TREE; | |
11182 | } | |
8b27f225 | 11183 | wfl_op2 = TREE_OPERAND (node, 1); |
cd9643f7 | 11184 | |
8b27f225 PB |
11185 | if (TREE_OPERAND (node, 0) == error_mark_node) |
11186 | return error_mark_node; | |
11187 | ||
5cbdba64 APB |
11188 | flag = COMPOUND_ASSIGN_P (wfl_op2); |
11189 | if (flag) | |
8b27f225 | 11190 | { |
2aa11e97 | 11191 | tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0)); |
8b27f225 PB |
11192 | |
11193 | /* Hand stablize the lhs on both places */ | |
8b27f225 | 11194 | TREE_OPERAND (node, 0) = lvalue; |
5cbdba64 APB |
11195 | TREE_OPERAND (TREE_OPERAND (node, 1), 0) = |
11196 | (flag_emit_class_files ? lvalue : save_expr (lvalue)); | |
2aa11e97 | 11197 | |
5cbdba64 | 11198 | /* 15.25.2.a: Left hand is not an array access. FIXME */ |
2aa11e97 APB |
11199 | /* Now complete the RHS. We write it back later on. */ |
11200 | nn = java_complete_tree (TREE_OPERAND (node, 1)); | |
11201 | ||
642f15d1 APB |
11202 | if ((cn = patch_string (nn))) |
11203 | nn = cn; | |
11204 | ||
2aa11e97 APB |
11205 | /* The last part of the rewrite for E1 op= E2 is to have |
11206 | E1 = (T)(E1 op E2), with T being the type of E1. */ | |
642f15d1 APB |
11207 | nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2), |
11208 | TREE_TYPE (lvalue), nn)); | |
5cbdba64 APB |
11209 | |
11210 | /* 15.25.2.b: Left hand is an array access. FIXME */ | |
8b27f225 PB |
11211 | } |
11212 | ||
f8976021 APB |
11213 | /* If we're about to patch a NEW_ARRAY_INIT, we call a special |
11214 | function to complete this RHS */ | |
2aa11e97 | 11215 | else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT) |
63a212ed | 11216 | nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)), |
f8976021 | 11217 | TREE_OPERAND (node, 1)); |
2aa11e97 | 11218 | /* Otherwise we simply complete the RHS */ |
f8976021 APB |
11219 | else |
11220 | nn = java_complete_tree (TREE_OPERAND (node, 1)); | |
11221 | ||
8b27f225 | 11222 | if (nn == error_mark_node) |
c0d87ff6 | 11223 | return error_mark_node; |
2aa11e97 APB |
11224 | |
11225 | /* Write back the RHS as we evaluated it. */ | |
8b27f225 PB |
11226 | TREE_OPERAND (node, 1) = nn; |
11227 | ||
11228 | /* In case we're handling = with a String as a RHS, we need to | |
11229 | produce a String out of the RHS (it might still be a | |
11230 | STRING_CST or a StringBuffer at this stage */ | |
11231 | if ((nn = patch_string (TREE_OPERAND (node, 1)))) | |
11232 | TREE_OPERAND (node, 1) = nn; | |
12472854 | 11233 | node = patch_assignment (node, wfl_op1, wfl_op2); |
5cbdba64 APB |
11234 | /* Reorganize the tree if necessary. */ |
11235 | if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node)) | |
11236 | || JSTRING_P (TREE_TYPE (node)))) | |
11237 | node = java_refold (node); | |
12472854 PB |
11238 | CAN_COMPLETE_NORMALLY (node) = 1; |
11239 | return node; | |
8b27f225 PB |
11240 | |
11241 | case MULT_EXPR: | |
11242 | case PLUS_EXPR: | |
11243 | case MINUS_EXPR: | |
11244 | case LSHIFT_EXPR: | |
11245 | case RSHIFT_EXPR: | |
11246 | case URSHIFT_EXPR: | |
11247 | case BIT_AND_EXPR: | |
11248 | case BIT_XOR_EXPR: | |
11249 | case BIT_IOR_EXPR: | |
11250 | case TRUNC_MOD_EXPR: | |
11251 | case RDIV_EXPR: | |
11252 | case TRUTH_ANDIF_EXPR: | |
11253 | case TRUTH_ORIF_EXPR: | |
11254 | case EQ_EXPR: | |
11255 | case NE_EXPR: | |
11256 | case GT_EXPR: | |
11257 | case GE_EXPR: | |
11258 | case LT_EXPR: | |
11259 | case LE_EXPR: | |
11260 | /* Operands 0 and 1 are WFL in certain cases only. patch_binop | |
11261 | knows how to handle those cases. */ | |
11262 | wfl_op1 = TREE_OPERAND (node, 0); | |
11263 | wfl_op2 = TREE_OPERAND (node, 1); | |
11264 | ||
12472854 | 11265 | CAN_COMPLETE_NORMALLY (node) = 1; |
8b27f225 PB |
11266 | /* Don't complete string nodes if dealing with the PLUS operand. */ |
11267 | if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1)) | |
2aa11e97 APB |
11268 | { |
11269 | nn = java_complete_tree (wfl_op1); | |
11270 | if (nn == error_mark_node) | |
11271 | return error_mark_node; | |
11272 | if ((cn = patch_string (nn))) | |
11273 | nn = cn; | |
11274 | TREE_OPERAND (node, 0) = nn; | |
11275 | } | |
8b27f225 | 11276 | if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2)) |
2aa11e97 APB |
11277 | { |
11278 | nn = java_complete_tree (wfl_op2); | |
11279 | if (nn == error_mark_node) | |
11280 | return error_mark_node; | |
11281 | if ((cn = patch_string (nn))) | |
11282 | nn = cn; | |
11283 | TREE_OPERAND (node, 1) = nn; | |
11284 | } | |
939d7216 | 11285 | return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2)); |
8b27f225 | 11286 | |
5e942c50 APB |
11287 | case INSTANCEOF_EXPR: |
11288 | wfl_op1 = TREE_OPERAND (node, 0); | |
11289 | COMPLETE_CHECK_OP_0 (node); | |
ce6e9147 APB |
11290 | if (flag_emit_xref) |
11291 | { | |
11292 | TREE_TYPE (node) = boolean_type_node; | |
11293 | return node; | |
11294 | } | |
5e942c50 APB |
11295 | return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1)); |
11296 | ||
8b27f225 PB |
11297 | case UNARY_PLUS_EXPR: |
11298 | case NEGATE_EXPR: | |
11299 | case TRUTH_NOT_EXPR: | |
11300 | case BIT_NOT_EXPR: | |
11301 | case PREDECREMENT_EXPR: | |
11302 | case PREINCREMENT_EXPR: | |
11303 | case POSTDECREMENT_EXPR: | |
11304 | case POSTINCREMENT_EXPR: | |
11305 | case CONVERT_EXPR: | |
11306 | /* There are cases were wfl_op1 is a WFL. patch_unaryop knows | |
11307 | how to handle those cases. */ | |
11308 | wfl_op1 = TREE_OPERAND (node, 0); | |
12472854 | 11309 | CAN_COMPLETE_NORMALLY (node) = 1; |
8b27f225 PB |
11310 | TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1); |
11311 | if (TREE_OPERAND (node, 0) == error_mark_node) | |
11312 | return error_mark_node; | |
4a5f66c3 APB |
11313 | node = patch_unaryop (node, wfl_op1); |
11314 | CAN_COMPLETE_NORMALLY (node) = 1; | |
11315 | break; | |
8b27f225 PB |
11316 | |
11317 | case ARRAY_REF: | |
11318 | /* There are cases were wfl_op1 is a WFL. patch_array_ref knows | |
11319 | how to handle those cases. */ | |
11320 | wfl_op1 = TREE_OPERAND (node, 0); | |
11321 | TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1); | |
11322 | if (TREE_OPERAND (node, 0) == error_mark_node) | |
11323 | return error_mark_node; | |
7f1d4866 | 11324 | if (!flag_emit_class_files && !flag_emit_xref) |
8b27f225 PB |
11325 | TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0)); |
11326 | /* The same applies to wfl_op2 */ | |
11327 | wfl_op2 = TREE_OPERAND (node, 1); | |
11328 | TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2); | |
11329 | if (TREE_OPERAND (node, 1) == error_mark_node) | |
11330 | return error_mark_node; | |
7f1d4866 | 11331 | if (!flag_emit_class_files && !flag_emit_xref) |
22eed1e6 | 11332 | TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1)); |
c877974e APB |
11333 | return patch_array_ref (node); |
11334 | ||
63a212ed PB |
11335 | case RECORD_TYPE: |
11336 | return node;; | |
11337 | ||
11338 | case COMPONENT_REF: | |
11339 | /* The first step in the re-write of qualified name handling. FIXME. | |
11340 | So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */ | |
c877974e | 11341 | TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0)); |
63a212ed PB |
11342 | if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE) |
11343 | { | |
11344 | tree name = TREE_OPERAND (node, 1); | |
11345 | tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name); | |
11346 | if (field == NULL_TREE) | |
11347 | { | |
11348 | error ("missing static field `%s'", IDENTIFIER_POINTER (name)); | |
11349 | return error_mark_node; | |
11350 | } | |
11351 | if (! FIELD_STATIC (field)) | |
11352 | { | |
11353 | error ("not a static field `%s'", IDENTIFIER_POINTER (name)); | |
11354 | return error_mark_node; | |
11355 | } | |
11356 | return field; | |
11357 | } | |
11358 | else | |
11359 | fatal ("unimplemented java_complete_tree for COMPONENT_REF"); | |
c877974e | 11360 | break; |
8b27f225 PB |
11361 | |
11362 | case THIS_EXPR: | |
11363 | /* Can't use THIS in a static environment */ | |
11364 | if (!current_this) | |
11365 | { | |
11366 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
781b0558 KG |
11367 | parse_error_context (wfl_operator, |
11368 | "Keyword `this' used outside allowed context"); | |
8b27f225 PB |
11369 | TREE_TYPE (node) = error_mark_node; |
11370 | return error_mark_node; | |
11371 | } | |
22eed1e6 APB |
11372 | if (ctxp->explicit_constructor_p) |
11373 | { | |
11374 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
11375 | parse_error_context | |
781b0558 | 11376 | (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called"); |
22eed1e6 APB |
11377 | TREE_TYPE (node) = error_mark_node; |
11378 | return error_mark_node; | |
11379 | } | |
8b27f225 PB |
11380 | return current_this; |
11381 | ||
11382 | default: | |
12472854 | 11383 | CAN_COMPLETE_NORMALLY (node) = 1; |
8b27f225 PB |
11384 | /* Ok: may be we have a STRING_CST or a crafted `StringBuffer' |
11385 | and it's time to turn it into the appropriate String object | |
11386 | */ | |
11387 | if ((node = patch_string (node))) | |
11388 | return node; | |
11389 | fatal ("No case for tree code `%s' - java_complete_tree\n", | |
11390 | tree_code_name [TREE_CODE (node)]); | |
11391 | } | |
11392 | return node; | |
11393 | } | |
11394 | ||
11395 | /* Complete function call's argument. Return a non zero value is an | |
11396 | error was found. */ | |
11397 | ||
11398 | static int | |
11399 | complete_function_arguments (node) | |
11400 | tree node; | |
11401 | { | |
11402 | int flag = 0; | |
11403 | tree cn; | |
11404 | ||
f63991a8 | 11405 | ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0); |
8b27f225 PB |
11406 | for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn)) |
11407 | { | |
11408 | tree wfl = TREE_VALUE (cn), parm, temp; | |
11409 | parm = java_complete_tree (wfl); | |
11410 | if (parm == error_mark_node) | |
11411 | { | |
11412 | flag = 1; | |
11413 | continue; | |
11414 | } | |
11415 | /* If have a string literal that we haven't transformed yet or a | |
11416 | crafted string buffer, as a result of use of the the String | |
11417 | `+' operator. Build `parm.toString()' and expand it. */ | |
11418 | if ((temp = patch_string (parm))) | |
11419 | parm = temp; | |
5e942c50 APB |
11420 | /* Inline PRIMTYPE.TYPE read access */ |
11421 | parm = maybe_build_primttype_type_ref (parm, wfl); | |
8b27f225 | 11422 | |
5e942c50 | 11423 | TREE_VALUE (cn) = parm; |
8b27f225 | 11424 | } |
f63991a8 | 11425 | ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0); |
8b27f225 PB |
11426 | return flag; |
11427 | } | |
11428 | ||
11429 | /* Sometimes (for loops and variable initialized during their | |
11430 | declaration), we want to wrap a statement around a WFL and turn it | |
11431 | debugable. */ | |
11432 | ||
11433 | static tree | |
11434 | build_debugable_stmt (location, stmt) | |
11435 | int location; | |
11436 | tree stmt; | |
11437 | { | |
11438 | if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION) | |
11439 | { | |
11440 | stmt = build_expr_wfl (stmt, input_filename, 0, 0); | |
11441 | EXPR_WFL_LINECOL (stmt) = location; | |
11442 | } | |
11443 | JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt); | |
11444 | return stmt; | |
11445 | } | |
11446 | ||
11447 | static tree | |
11448 | build_expr_block (body, decls) | |
11449 | tree body, decls; | |
11450 | { | |
11451 | tree node = make_node (BLOCK); | |
11452 | BLOCK_EXPR_DECLS (node) = decls; | |
11453 | BLOCK_EXPR_BODY (node) = body; | |
11454 | if (body) | |
11455 | TREE_TYPE (node) = TREE_TYPE (body); | |
11456 | TREE_SIDE_EFFECTS (node) = 1; | |
11457 | return node; | |
11458 | } | |
11459 | ||
11460 | /* Create a new function block and link it approriately to current | |
11461 | function block chain */ | |
11462 | ||
11463 | static tree | |
11464 | enter_block () | |
11465 | { | |
11466 | return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE))); | |
11467 | } | |
11468 | ||
11469 | /* Link block B supercontext to the previous block. The current | |
11470 | function DECL is used as supercontext when enter_a_block is called | |
11471 | for the first time for a given function. The current function body | |
11472 | (DECL_FUNCTION_BODY) is set to be block B. */ | |
11473 | ||
11474 | static tree | |
11475 | enter_a_block (b) | |
11476 | tree b; | |
11477 | { | |
11478 | tree fndecl = current_function_decl; | |
11479 | ||
f099f336 APB |
11480 | if (!fndecl) { |
11481 | BLOCK_SUPERCONTEXT (b) = current_static_block; | |
11482 | current_static_block = b; | |
11483 | } | |
11484 | ||
11485 | else if (!DECL_FUNCTION_BODY (fndecl)) | |
8b27f225 PB |
11486 | { |
11487 | BLOCK_SUPERCONTEXT (b) = fndecl; | |
11488 | DECL_FUNCTION_BODY (fndecl) = b; | |
11489 | } | |
11490 | else | |
11491 | { | |
11492 | BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl); | |
11493 | DECL_FUNCTION_BODY (fndecl) = b; | |
11494 | } | |
11495 | return b; | |
11496 | } | |
11497 | ||
11498 | /* Exit a block by changing the current function body | |
11499 | (DECL_FUNCTION_BODY) to the current block super context, only if | |
11500 | the block being exited isn't the method's top level one. */ | |
11501 | ||
11502 | static tree | |
11503 | exit_block () | |
11504 | { | |
f099f336 APB |
11505 | tree b; |
11506 | if (current_function_decl) | |
11507 | { | |
11508 | b = DECL_FUNCTION_BODY (current_function_decl); | |
11509 | if (BLOCK_SUPERCONTEXT (b) != current_function_decl) | |
11510 | DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b); | |
11511 | } | |
11512 | else | |
11513 | { | |
11514 | b = current_static_block; | |
8b27f225 | 11515 | |
f099f336 APB |
11516 | if (BLOCK_SUPERCONTEXT (b)) |
11517 | current_static_block = BLOCK_SUPERCONTEXT (b); | |
11518 | } | |
8b27f225 PB |
11519 | return b; |
11520 | } | |
11521 | ||
11522 | /* Lookup for NAME in the nested function's blocks, all the way up to | |
11523 | the current toplevel one. It complies with Java's local variable | |
11524 | scoping rules. */ | |
11525 | ||
11526 | static tree | |
11527 | lookup_name_in_blocks (name) | |
11528 | tree name; | |
11529 | { | |
f099f336 | 11530 | tree b = GET_CURRENT_BLOCK (current_function_decl); |
8b27f225 PB |
11531 | |
11532 | while (b != current_function_decl) | |
11533 | { | |
11534 | tree current; | |
11535 | ||
11536 | /* Paranoid sanity check. To be removed */ | |
11537 | if (TREE_CODE (b) != BLOCK) | |
11538 | fatal ("non block expr function body - lookup_name_in_blocks"); | |
11539 | ||
11540 | for (current = BLOCK_EXPR_DECLS (b); current; | |
11541 | current = TREE_CHAIN (current)) | |
11542 | if (DECL_NAME (current) == name) | |
11543 | return current; | |
11544 | b = BLOCK_SUPERCONTEXT (b); | |
11545 | } | |
11546 | return NULL_TREE; | |
11547 | } | |
11548 | ||
11549 | static void | |
11550 | maybe_absorb_scoping_blocks () | |
11551 | { | |
f099f336 | 11552 | while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl))) |
8b27f225 PB |
11553 | { |
11554 | tree b = exit_block (); | |
11555 | java_method_add_stmt (current_function_decl, b); | |
11556 | SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno)); | |
11557 | } | |
11558 | } | |
11559 | ||
11560 | \f | |
11561 | /* This section of the source is reserved to build_* functions that | |
11562 | are building incomplete tree nodes and the patch_* functions that | |
11563 | are completing them. */ | |
11564 | ||
c877974e | 11565 | /* Build a super() constructor invocation. Returns empty_stmt_node if |
22eed1e6 APB |
11566 | we're currently dealing with the class java.lang.Object. */ |
11567 | ||
11568 | static tree | |
781b0558 KG |
11569 | build_super_invocation (mdecl) |
11570 | tree mdecl; | |
22eed1e6 | 11571 | { |
781b0558 | 11572 | if (DECL_CONTEXT (mdecl) == object_type_node) |
c877974e | 11573 | return empty_stmt_node; |
22eed1e6 APB |
11574 | else |
11575 | { | |
9ee9b555 | 11576 | tree super_wfl = build_wfl_node (super_identifier_node); |
22eed1e6 APB |
11577 | return build_method_invocation (super_wfl, NULL_TREE); |
11578 | } | |
11579 | } | |
11580 | ||
11581 | /* Build a SUPER/THIS qualified method invocation. */ | |
11582 | ||
11583 | static tree | |
11584 | build_this_super_qualified_invocation (use_this, name, args, lloc, rloc) | |
11585 | int use_this; | |
11586 | tree name, args; | |
11587 | int lloc, rloc; | |
11588 | ||
11589 | { | |
11590 | tree invok; | |
11591 | tree wfl = | |
9ee9b555 | 11592 | build_wfl_node (use_this ? this_identifier_node : super_identifier_node); |
22eed1e6 APB |
11593 | EXPR_WFL_LINECOL (wfl) = lloc; |
11594 | invok = build_method_invocation (name, args); | |
11595 | return make_qualified_primary (wfl, invok, rloc); | |
11596 | } | |
11597 | ||
8b27f225 PB |
11598 | /* Build an incomplete CALL_EXPR node. */ |
11599 | ||
11600 | static tree | |
11601 | build_method_invocation (name, args) | |
11602 | tree name; | |
11603 | tree args; | |
11604 | { | |
11605 | tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE); | |
11606 | TREE_SIDE_EFFECTS (call) = 1; | |
11607 | EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name); | |
11608 | return call; | |
11609 | } | |
11610 | ||
11611 | /* Build an incomplete new xxx(...) node. */ | |
11612 | ||
11613 | static tree | |
11614 | build_new_invocation (name, args) | |
11615 | tree name, args; | |
11616 | { | |
11617 | tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE); | |
11618 | TREE_SIDE_EFFECTS (call) = 1; | |
11619 | EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name); | |
11620 | return call; | |
11621 | } | |
11622 | ||
11623 | /* Build an incomplete assignment expression. */ | |
11624 | ||
11625 | static tree | |
11626 | build_assignment (op, op_location, lhs, rhs) | |
11627 | int op, op_location; | |
11628 | tree lhs, rhs; | |
11629 | { | |
11630 | tree assignment; | |
11631 | /* Build the corresponding binop if we deal with a Compound | |
11632 | Assignment operator. Mark the binop sub-tree as part of a | |
11633 | Compound Assignment expression */ | |
11634 | if (op != ASSIGN_TK) | |
11635 | { | |
11636 | rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs); | |
11637 | COMPOUND_ASSIGN_P (rhs) = 1; | |
11638 | } | |
11639 | assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs); | |
11640 | TREE_SIDE_EFFECTS (assignment) = 1; | |
11641 | EXPR_WFL_LINECOL (assignment) = op_location; | |
11642 | return assignment; | |
11643 | } | |
11644 | ||
11645 | /* Print an INTEGER_CST node in a static buffer, and return the buffer. */ | |
11646 | ||
12472854 | 11647 | char * |
8b27f225 PB |
11648 | print_int_node (node) |
11649 | tree node; | |
11650 | { | |
11651 | static char buffer [80]; | |
11652 | if (TREE_CONSTANT_OVERFLOW (node)) | |
11653 | sprintf (buffer, "<overflow>"); | |
11654 | ||
11655 | if (TREE_INT_CST_HIGH (node) == 0) | |
11656 | sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED, | |
11657 | TREE_INT_CST_LOW (node)); | |
11658 | else if (TREE_INT_CST_HIGH (node) == -1 | |
11659 | && TREE_INT_CST_LOW (node) != 0) | |
11660 | { | |
11661 | buffer [0] = '-'; | |
11662 | sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED, | |
11663 | -TREE_INT_CST_LOW (node)); | |
11664 | } | |
11665 | else | |
11666 | sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX, | |
11667 | TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node)); | |
11668 | ||
11669 | return buffer; | |
11670 | } | |
11671 | ||
7f1d4866 APB |
11672 | /* Return 1 if an assignment to a FINAL is attempted in a non suitable |
11673 | context. */ | |
5e942c50 APB |
11674 | |
11675 | static int | |
11676 | check_final_assignment (lvalue, wfl) | |
11677 | tree lvalue, wfl; | |
11678 | { | |
7f1d4866 APB |
11679 | if (JDECL_P (lvalue) |
11680 | && FIELD_FINAL (lvalue) && !IS_CLINIT (current_function_decl)) | |
5e942c50 APB |
11681 | { |
11682 | parse_error_context | |
11683 | (wfl, "Can't assign a value to the final variable `%s'", | |
11684 | IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl))); | |
11685 | return 1; | |
11686 | } | |
11687 | return 0; | |
11688 | } | |
11689 | ||
11690 | /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in | |
11691 | read. This is needed to avoid circularities in the implementation | |
11692 | of these fields in libjava. */ | |
11693 | ||
11694 | static tree | |
11695 | maybe_build_primttype_type_ref (rhs, wfl) | |
11696 | tree rhs, wfl; | |
11697 | { | |
11698 | tree to_return = NULL_TREE; | |
11699 | tree rhs_type = TREE_TYPE (rhs); | |
11700 | if (TREE_CODE (rhs) == COMPOUND_EXPR) | |
11701 | { | |
11702 | tree n = TREE_OPERAND (rhs, 1); | |
11703 | if (TREE_CODE (n) == VAR_DECL | |
11704 | && DECL_NAME (n) == TYPE_identifier_node | |
11705 | && rhs_type == class_ptr_type) | |
11706 | { | |
49f48c71 | 11707 | const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)); |
5e942c50 APB |
11708 | if (!strncmp (self_name, "java.lang.", 10)) |
11709 | to_return = build_primtype_type_ref (self_name); | |
11710 | } | |
11711 | } | |
11712 | return (to_return ? to_return : rhs ); | |
11713 | } | |
11714 | ||
8b27f225 PB |
11715 | /* 15.25 Assignment operators. */ |
11716 | ||
11717 | static tree | |
11718 | patch_assignment (node, wfl_op1, wfl_op2) | |
11719 | tree node; | |
11720 | tree wfl_op1; | |
11721 | tree wfl_op2; | |
11722 | { | |
11723 | tree rhs = TREE_OPERAND (node, 1); | |
5e942c50 | 11724 | tree lvalue = TREE_OPERAND (node, 0), llvalue; |
cd531a2e | 11725 | tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE; |
8b27f225 PB |
11726 | int error_found = 0; |
11727 | int lvalue_from_array = 0; | |
11728 | ||
11729 | /* Can't assign to a final. */ | |
5e942c50 APB |
11730 | if (check_final_assignment (lvalue, wfl_op1)) |
11731 | error_found = 1; | |
8b27f225 PB |
11732 | |
11733 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
11734 | ||
11735 | /* Lhs can be a named variable */ | |
34f4db93 | 11736 | if (JDECL_P (lvalue)) |
8b27f225 | 11737 | { |
8b27f225 PB |
11738 | lhs_type = TREE_TYPE (lvalue); |
11739 | } | |
11740 | /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME + | |
11741 | comment on reason why */ | |
11742 | else if (TREE_CODE (wfl_op1) == ARRAY_REF) | |
11743 | { | |
11744 | lhs_type = TREE_TYPE (lvalue); | |
11745 | lvalue_from_array = 1; | |
11746 | } | |
11747 | /* Or a field access */ | |
11748 | else if (TREE_CODE (lvalue) == COMPONENT_REF) | |
11749 | lhs_type = TREE_TYPE (lvalue); | |
11750 | /* Or a function return slot */ | |
11751 | else if (TREE_CODE (lvalue) == RESULT_DECL) | |
11752 | lhs_type = TREE_TYPE (lvalue); | |
5e942c50 APB |
11753 | /* Otherwise, we might want to try to write into an optimized static |
11754 | final, this is an of a different nature, reported further on. */ | |
11755 | else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION | |
1504b2b4 | 11756 | && resolve_expression_name (wfl_op1, &llvalue)) |
5e942c50 | 11757 | { |
1504b2b4 APB |
11758 | if (check_final_assignment (llvalue, wfl_op1)) |
11759 | { | |
11760 | /* What we should do instead is resetting the all the flags | |
11761 | previously set, exchange lvalue for llvalue and continue. */ | |
11762 | error_found = 1; | |
11763 | return error_mark_node; | |
11764 | } | |
11765 | else | |
11766 | lhs_type = TREE_TYPE (lvalue); | |
5e942c50 APB |
11767 | } |
11768 | else | |
8b27f225 PB |
11769 | { |
11770 | parse_error_context (wfl_op1, "Invalid left hand side of assignment"); | |
11771 | error_found = 1; | |
11772 | } | |
11773 | ||
11774 | rhs_type = TREE_TYPE (rhs); | |
11775 | /* 5.1 Try the assignment conversion for builtin type. */ | |
11776 | new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs); | |
11777 | ||
11778 | /* 5.2 If it failed, try a reference conversion */ | |
11779 | if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs))) | |
11780 | lhs_type = promote_type (rhs_type); | |
11781 | ||
11782 | /* 15.25.2 If we have a compound assignment, convert RHS into the | |
11783 | type of the LHS */ | |
11784 | else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1))) | |
11785 | new_rhs = convert (lhs_type, rhs); | |
11786 | ||
11787 | /* Explicit cast required. This is an error */ | |
11788 | if (!new_rhs) | |
11789 | { | |
c2e3db92 KG |
11790 | char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0)); |
11791 | char *t2 = xstrdup (lang_printable_name (lhs_type, 0)); | |
8b27f225 PB |
11792 | tree wfl; |
11793 | char operation [32]; /* Max size known */ | |
11794 | ||
11795 | /* If the assignment is part of a declaration, we use the WFL of | |
11796 | the declared variable to point out the error and call it a | |
11797 | declaration problem. If the assignment is a genuine = | |
11798 | operator, we call is a operator `=' problem, otherwise we | |
11799 | call it an assignment problem. In both of these last cases, | |
11800 | we use the WFL of the operator to indicate the error. */ | |
11801 | ||
11802 | if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)) | |
11803 | { | |
11804 | wfl = wfl_op1; | |
11805 | strcpy (operation, "declaration"); | |
11806 | } | |
11807 | else | |
11808 | { | |
11809 | wfl = wfl_operator; | |
11810 | if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1))) | |
11811 | strcpy (operation, "assignment"); | |
11812 | else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL) | |
11813 | strcpy (operation, "`return'"); | |
11814 | else | |
11815 | strcpy (operation, "`='"); | |
11816 | } | |
11817 | ||
1ebadc60 | 11818 | if (!valid_cast_to_p (rhs_type, lhs_type)) |
781b0558 KG |
11819 | parse_error_context |
11820 | (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'", | |
11821 | operation, t1, t2); | |
1ebadc60 | 11822 | else |
781b0558 | 11823 | parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'", |
1ebadc60 | 11824 | operation, t1, t2); |
8b27f225 PB |
11825 | free (t1); free (t2); |
11826 | error_found = 1; | |
11827 | } | |
11828 | ||
c877974e APB |
11829 | /* Inline read access to java.lang.PRIMTYPE.TYPE */ |
11830 | if (new_rhs) | |
11831 | new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2); | |
5e942c50 | 11832 | |
8b27f225 PB |
11833 | if (error_found) |
11834 | return error_mark_node; | |
11835 | ||
2622b947 APB |
11836 | /* 10.10: Array Store Exception runtime check */ |
11837 | if (!flag_emit_class_files | |
5423609c | 11838 | && !flag_emit_xref |
2622b947 | 11839 | && lvalue_from_array |
781b0558 | 11840 | && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type))) |
2622b947 APB |
11841 | { |
11842 | tree check; | |
11843 | tree base = lvalue; | |
11844 | ||
11845 | /* We need to retrieve the right argument for _Jv_CheckArrayStore */ | |
11846 | if (TREE_CODE (lvalue) == COMPOUND_EXPR) | |
11847 | base = TREE_OPERAND (lvalue, 0); | |
11848 | else | |
11849 | { | |
11850 | if (flag_bounds_check) | |
11851 | base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0); | |
11852 | else | |
11853 | base = TREE_OPERAND (TREE_OPERAND (base, 0), 0); | |
11854 | } | |
11855 | ||
11856 | /* Build the invocation of _Jv_CheckArrayStore */ | |
dc4e6ccf | 11857 | new_rhs = save_expr (new_rhs); |
2622b947 APB |
11858 | check = build (CALL_EXPR, void_type_node, |
11859 | build_address_of (soft_checkarraystore_node), | |
11860 | tree_cons (NULL_TREE, base, | |
11861 | build_tree_list (NULL_TREE, new_rhs)), | |
11862 | NULL_TREE); | |
11863 | TREE_SIDE_EFFECTS (check) = 1; | |
11864 | ||
11865 | /* We have to decide on an insertion point */ | |
11866 | if (TREE_CODE (lvalue) == COMPOUND_EXPR) | |
11867 | { | |
11868 | tree t; | |
11869 | if (flag_bounds_check) | |
11870 | { | |
11871 | t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0); | |
11872 | TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) = | |
11873 | build (COMPOUND_EXPR, void_type_node, t, check); | |
11874 | } | |
11875 | else | |
11876 | TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type, | |
11877 | check, TREE_OPERAND (lvalue, 1)); | |
11878 | } | |
11879 | else | |
11880 | { | |
11881 | /* Make sure the bound check will happen before the store check */ | |
11882 | if (flag_bounds_check) | |
11883 | TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) = | |
11884 | build (COMPOUND_EXPR, void_type_node, | |
11885 | TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check); | |
11886 | else | |
11887 | lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue); | |
11888 | } | |
11889 | } | |
22eed1e6 | 11890 | |
8b27f225 PB |
11891 | TREE_OPERAND (node, 0) = lvalue; |
11892 | TREE_OPERAND (node, 1) = new_rhs; | |
11893 | TREE_TYPE (node) = lhs_type; | |
11894 | return node; | |
11895 | } | |
11896 | ||
11897 | /* Check that type SOURCE can be cast into type DEST. If the cast | |
11898 | can't occur at all, return 0 otherwise 1. This function is used to | |
11899 | produce accurate error messages on the reasons why an assignment | |
11900 | failed. */ | |
11901 | ||
11902 | static tree | |
11903 | try_reference_assignconv (lhs_type, rhs) | |
11904 | tree lhs_type, rhs; | |
11905 | { | |
11906 | tree new_rhs = NULL_TREE; | |
11907 | tree rhs_type = TREE_TYPE (rhs); | |
11908 | ||
11909 | if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type)) | |
11910 | { | |
11911 | /* `null' may be assigned to any reference type */ | |
11912 | if (rhs == null_pointer_node) | |
11913 | new_rhs = null_pointer_node; | |
11914 | /* Try the reference assignment conversion */ | |
11915 | else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0)) | |
11916 | new_rhs = rhs; | |
11917 | /* This is a magic assignment that we process differently */ | |
11918 | else if (rhs == soft_exceptioninfo_call_node) | |
11919 | new_rhs = rhs; | |
11920 | } | |
11921 | return new_rhs; | |
11922 | } | |
11923 | ||
11924 | /* Check that RHS can be converted into LHS_TYPE by the assignment | |
11925 | conversion (5.2), for the cases of RHS being a builtin type. Return | |
11926 | NULL_TREE if the conversion fails or if because RHS isn't of a | |
11927 | builtin type. Return a converted RHS if the conversion is possible. */ | |
11928 | ||
11929 | static tree | |
11930 | try_builtin_assignconv (wfl_op1, lhs_type, rhs) | |
11931 | tree wfl_op1, lhs_type, rhs; | |
11932 | { | |
11933 | tree new_rhs = NULL_TREE; | |
11934 | tree rhs_type = TREE_TYPE (rhs); | |
11935 | ||
5e942c50 APB |
11936 | /* Zero accepted everywhere */ |
11937 | if (TREE_CODE (rhs) == INTEGER_CST | |
11938 | && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0 | |
11939 | && JPRIMITIVE_TYPE_P (rhs_type)) | |
11940 | new_rhs = convert (lhs_type, rhs); | |
11941 | ||
8b27f225 PB |
11942 | /* 5.1.1 Try Identity Conversion, |
11943 | 5.1.2 Try Widening Primitive Conversion */ | |
5e942c50 | 11944 | else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)) |
8b27f225 PB |
11945 | new_rhs = convert (lhs_type, rhs); |
11946 | ||
11947 | /* Try a narrowing primitive conversion (5.1.3): | |
11948 | - expression is a constant expression of type int AND | |
11949 | - variable is byte, short or char AND | |
11950 | - The value of the expression is representable in the type of the | |
11951 | variable */ | |
11952 | else if (rhs_type == int_type_node && TREE_CONSTANT (rhs) | |
11953 | && (lhs_type == byte_type_node || lhs_type == char_type_node | |
11954 | || lhs_type == short_type_node)) | |
11955 | { | |
11956 | if (int_fits_type_p (rhs, lhs_type)) | |
11957 | new_rhs = convert (lhs_type, rhs); | |
11958 | else if (wfl_op1) /* Might be called with a NULL */ | |
11959 | parse_warning_context | |
781b0558 | 11960 | (wfl_op1, "Constant expression `%s' to wide for narrowing primitive conversion to `%s'", |
8b27f225 PB |
11961 | print_int_node (rhs), lang_printable_name (lhs_type, 0)); |
11962 | /* Reported a warning that will turn into an error further | |
11963 | down, so we don't return */ | |
11964 | } | |
11965 | ||
11966 | return new_rhs; | |
11967 | } | |
11968 | ||
11969 | /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity | |
11970 | conversion (5.1.1) or widening primitve conversion (5.1.2). Return | |
11971 | 0 is the conversion test fails. This implements parts the method | |
11972 | invocation convertion (5.3). */ | |
11973 | ||
11974 | static int | |
11975 | valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type) | |
11976 | tree lhs_type, rhs_type; | |
11977 | { | |
acd663ee | 11978 | /* 5.1.1: This is the identity conversion part. */ |
5e942c50 APB |
11979 | if (lhs_type == rhs_type) |
11980 | return 1; | |
11981 | ||
acd663ee APB |
11982 | /* Reject non primitive types */ |
11983 | if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type)) | |
8b27f225 PB |
11984 | return 0; |
11985 | ||
acd663ee APB |
11986 | /* 5.1.2: widening primitive conversion. byte, even if it's smaller |
11987 | than a char can't be converted into a char. Short can't too, but | |
11988 | the < test below takes care of that */ | |
8b27f225 PB |
11989 | if (lhs_type == char_type_node && rhs_type == byte_type_node) |
11990 | return 0; | |
11991 | ||
5e942c50 APB |
11992 | /* Accept all promoted type here. Note, we can't use <= in the test |
11993 | below, because we still need to bounce out assignments of short | |
11994 | to char and the likes */ | |
11995 | if (lhs_type == int_type_node | |
11996 | && (rhs_type == promoted_byte_type_node | |
11997 | || rhs_type == promoted_short_type_node | |
11998 | || rhs_type == promoted_char_type_node | |
11999 | || rhs_type == promoted_boolean_type_node)) | |
12000 | return 1; | |
12001 | ||
acd663ee APB |
12002 | /* From here, an integral is widened if its precision is smaller |
12003 | than the precision of the LHS or if the LHS is a floating point | |
12004 | type, or the RHS is a float and the RHS a double. */ | |
12005 | if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type) | |
12006 | && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type))) | |
12007 | || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type)) | |
12008 | || (rhs_type == float_type_node && lhs_type == double_type_node)) | |
8b27f225 PB |
12009 | return 1; |
12010 | ||
12011 | return 0; | |
12012 | } | |
12013 | ||
12014 | /* Check that something of SOURCE type can be assigned or cast to | |
12015 | something of DEST type at runtime. Return 1 if the operation is | |
12016 | valid, 0 otherwise. If CAST is set to 1, we're treating the case | |
12017 | were SOURCE is cast into DEST, which borrows a lot of the | |
12018 | assignment check. */ | |
12019 | ||
12020 | static int | |
12021 | valid_ref_assignconv_cast_p (source, dest, cast) | |
12022 | tree source; | |
12023 | tree dest; | |
12024 | int cast; | |
12025 | { | |
09ed0f70 APB |
12026 | /* SOURCE or DEST might be null if not from a declared entity. */ |
12027 | if (!source || !dest) | |
12028 | return 0; | |
5e942c50 APB |
12029 | if (JNULLP_TYPE_P (source)) |
12030 | return 1; | |
8b27f225 PB |
12031 | if (TREE_CODE (source) == POINTER_TYPE) |
12032 | source = TREE_TYPE (source); | |
12033 | if (TREE_CODE (dest) == POINTER_TYPE) | |
12034 | dest = TREE_TYPE (dest); | |
12035 | /* Case where SOURCE is a class type */ | |
12036 | if (TYPE_CLASS_P (source)) | |
12037 | { | |
12038 | if (TYPE_CLASS_P (dest)) | |
12039 | return source == dest || inherits_from_p (source, dest) | |
12040 | || (cast && inherits_from_p (dest, source)); | |
12041 | if (TYPE_INTERFACE_P (dest)) | |
12042 | { | |
12043 | /* If doing a cast and SOURCE is final, the operation is | |
12044 | always correct a compile time (because even if SOURCE | |
12045 | does not implement DEST, a subclass of SOURCE might). */ | |
12046 | if (cast && !CLASS_FINAL (TYPE_NAME (source))) | |
12047 | return 1; | |
12048 | /* Otherwise, SOURCE must implement DEST */ | |
12049 | return interface_of_p (dest, source); | |
12050 | } | |
12051 | /* DEST is an array, cast permited if SOURCE is of Object type */ | |
12052 | return (cast && source == object_type_node ? 1 : 0); | |
12053 | } | |
12054 | if (TYPE_INTERFACE_P (source)) | |
12055 | { | |
12056 | if (TYPE_CLASS_P (dest)) | |
12057 | { | |
12058 | /* If not casting, DEST must be the Object type */ | |
12059 | if (!cast) | |
12060 | return dest == object_type_node; | |
12061 | /* We're doing a cast. The cast is always valid is class | |
12062 | DEST is not final, otherwise, DEST must implement SOURCE */ | |
12063 | else if (!CLASS_FINAL (TYPE_NAME (dest))) | |
12064 | return 1; | |
12065 | else | |
12066 | return interface_of_p (source, dest); | |
12067 | } | |
12068 | if (TYPE_INTERFACE_P (dest)) | |
12069 | { | |
12070 | /* If doing a cast, then if SOURCE and DEST contain method | |
12071 | with the same signature but different return type, then | |
12072 | this is a (compile time) error */ | |
12073 | if (cast) | |
12074 | { | |
12075 | tree method_source, method_dest; | |
12076 | tree source_type; | |
12077 | tree source_sig; | |
12078 | tree source_name; | |
12079 | for (method_source = TYPE_METHODS (source); method_source; | |
12080 | method_source = TREE_CHAIN (method_source)) | |
12081 | { | |
12082 | source_sig = | |
12083 | build_java_argument_signature (TREE_TYPE (method_source)); | |
12084 | source_type = TREE_TYPE (TREE_TYPE (method_source)); | |
12085 | source_name = DECL_NAME (method_source); | |
12086 | for (method_dest = TYPE_METHODS (dest); | |
12087 | method_dest; method_dest = TREE_CHAIN (method_dest)) | |
12088 | if (source_sig == | |
12089 | build_java_argument_signature (TREE_TYPE (method_dest)) | |
12090 | && source_name == DECL_NAME (method_dest) | |
12091 | && source_type != TREE_TYPE (TREE_TYPE (method_dest))) | |
12092 | return 0; | |
12093 | } | |
12094 | return 1; | |
12095 | } | |
12096 | else | |
12097 | return source == dest || interface_of_p (dest, source); | |
12098 | } | |
12099 | else /* Array */ | |
93024893 APB |
12100 | return (cast ? |
12101 | (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0); | |
8b27f225 PB |
12102 | } |
12103 | if (TYPE_ARRAY_P (source)) | |
12104 | { | |
12105 | if (TYPE_CLASS_P (dest)) | |
12106 | return dest == object_type_node; | |
09ed0f70 APB |
12107 | /* Can't cast an array to an interface unless the interface is |
12108 | java.lang.Cloneable */ | |
8b27f225 | 12109 | if (TYPE_INTERFACE_P (dest)) |
09ed0f70 | 12110 | return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0); |
8b27f225 PB |
12111 | else /* Arrays */ |
12112 | { | |
12113 | tree source_element_type = TYPE_ARRAY_ELEMENT (source); | |
12114 | tree dest_element_type = TYPE_ARRAY_ELEMENT (dest); | |
12115 | ||
12116 | /* In case of severe errors, they turn out null */ | |
12117 | if (!dest_element_type || !source_element_type) | |
12118 | return 0; | |
12119 | if (source_element_type == dest_element_type) | |
12120 | return 1; | |
12121 | return valid_ref_assignconv_cast_p (source_element_type, | |
12122 | dest_element_type, cast); | |
12123 | } | |
12124 | return 0; | |
12125 | } | |
12126 | return 0; | |
12127 | } | |
12128 | ||
12129 | static int | |
12130 | valid_cast_to_p (source, dest) | |
12131 | tree source; | |
12132 | tree dest; | |
12133 | { | |
12134 | if (TREE_CODE (source) == POINTER_TYPE) | |
12135 | source = TREE_TYPE (source); | |
12136 | if (TREE_CODE (dest) == POINTER_TYPE) | |
12137 | dest = TREE_TYPE (dest); | |
12138 | ||
12139 | if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE) | |
12140 | return valid_ref_assignconv_cast_p (source, dest, 1); | |
12141 | ||
12142 | else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest)) | |
12143 | return 1; | |
12144 | ||
12145 | return 0; | |
12146 | } | |
12147 | ||
12148 | /* Method invocation conversion test. Return 1 if type SOURCE can be | |
12149 | converted to type DEST through the methond invocation conversion | |
12150 | process (5.3) */ | |
12151 | ||
12472854 PB |
12152 | static tree |
12153 | do_unary_numeric_promotion (arg) | |
12154 | tree arg; | |
12155 | { | |
12156 | tree type = TREE_TYPE (arg); | |
12157 | if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32 | |
12158 | : TREE_CODE (type) == CHAR_TYPE) | |
12159 | arg = convert (int_type_node, arg); | |
12160 | return arg; | |
12161 | } | |
12162 | ||
acd663ee APB |
12163 | /* Return a non zero value if SOURCE can be converted into DEST using |
12164 | the method invocation conversion rule (5.3). */ | |
8b27f225 PB |
12165 | static int |
12166 | valid_method_invocation_conversion_p (dest, source) | |
12167 | tree dest, source; | |
12168 | { | |
0b4d333e | 12169 | return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest) |
acd663ee APB |
12170 | && valid_builtin_assignconv_identity_widening_p (dest, source)) |
12171 | || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source)) | |
12172 | && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest)) | |
12173 | && valid_ref_assignconv_cast_p (source, dest, 0))); | |
8b27f225 PB |
12174 | } |
12175 | ||
12176 | /* Build an incomplete binop expression. */ | |
12177 | ||
12178 | static tree | |
12179 | build_binop (op, op_location, op1, op2) | |
12180 | enum tree_code op; | |
12181 | int op_location; | |
12182 | tree op1, op2; | |
12183 | { | |
5e942c50 | 12184 | tree binop = build (op, NULL_TREE, op1, op2); |
8b27f225 PB |
12185 | TREE_SIDE_EFFECTS (binop) = 1; |
12186 | /* Store the location of the operator, for better error report. The | |
12187 | string of the operator will be rebuild based on the OP value. */ | |
12188 | EXPR_WFL_LINECOL (binop) = op_location; | |
12189 | return binop; | |
12190 | } | |
12191 | ||
12192 | /* Build the string of the operator retained by NODE. If NODE is part | |
12193 | of a compound expression, add an '=' at the end of the string. This | |
12194 | function is called when an error needs to be reported on an | |
12195 | operator. The string is returned as a pointer to a static character | |
12196 | buffer. */ | |
12197 | ||
12198 | static char * | |
12199 | operator_string (node) | |
12200 | tree node; | |
12201 | { | |
12202 | #define BUILD_OPERATOR_STRING(S) \ | |
12203 | { \ | |
12204 | sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \ | |
12205 | return buffer; \ | |
12206 | } | |
12207 | ||
12208 | static char buffer [10]; | |
12209 | switch (TREE_CODE (node)) | |
12210 | { | |
12211 | case MULT_EXPR: BUILD_OPERATOR_STRING ("*"); | |
12212 | case RDIV_EXPR: BUILD_OPERATOR_STRING ("/"); | |
12213 | case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%"); | |
12214 | case PLUS_EXPR: BUILD_OPERATOR_STRING ("+"); | |
12215 | case MINUS_EXPR: BUILD_OPERATOR_STRING ("-"); | |
12216 | case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<"); | |
12217 | case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>"); | |
12218 | case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>"); | |
12219 | case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&"); | |
12220 | case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^"); | |
12221 | case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|"); | |
12222 | case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&"); | |
12223 | case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||"); | |
12224 | case EQ_EXPR: BUILD_OPERATOR_STRING ("=="); | |
12225 | case NE_EXPR: BUILD_OPERATOR_STRING ("!="); | |
12226 | case GT_EXPR: BUILD_OPERATOR_STRING (">"); | |
12227 | case GE_EXPR: BUILD_OPERATOR_STRING (">="); | |
12228 | case LT_EXPR: BUILD_OPERATOR_STRING ("<"); | |
12229 | case LE_EXPR: BUILD_OPERATOR_STRING ("<="); | |
12230 | case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+"); | |
12231 | case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-"); | |
12232 | case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!"); | |
12233 | case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~"); | |
12234 | case PREINCREMENT_EXPR: /* Fall through */ | |
12235 | case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++"); | |
12236 | case PREDECREMENT_EXPR: /* Fall through */ | |
12237 | case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--"); | |
12238 | default: | |
12239 | fatal ("unregistered operator %s - operator_string", | |
12240 | tree_code_name [TREE_CODE (node)]); | |
12241 | } | |
12242 | return NULL; | |
12243 | #undef BUILD_OPERATOR_STRING | |
12244 | } | |
12245 | ||
5cbdba64 APB |
12246 | /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2. */ |
12247 | ||
12248 | static int | |
12249 | java_decl_equiv (var_acc1, var_acc2) | |
12250 | tree var_acc1, var_acc2; | |
12251 | { | |
12252 | if (JDECL_P (var_acc1)) | |
12253 | return (var_acc1 == var_acc2); | |
12254 | ||
12255 | return (TREE_CODE (var_acc1) == COMPONENT_REF | |
12256 | && TREE_CODE (var_acc2) == COMPONENT_REF | |
12257 | && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0) | |
12258 | == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0) | |
12259 | && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1)); | |
12260 | } | |
12261 | ||
12262 | /* Return a non zero value if CODE is one of the operators that can be | |
12263 | used in conjunction with the `=' operator in a compound assignment. */ | |
12264 | ||
12265 | static int | |
12266 | binop_compound_p (code) | |
12267 | enum tree_code code; | |
12268 | { | |
12269 | int i; | |
12270 | for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++) | |
12271 | if (binop_lookup [i] == code) | |
12272 | break; | |
12273 | ||
12274 | return i < BINOP_COMPOUND_CANDIDATES; | |
12275 | } | |
12276 | ||
12277 | /* Reorganize after a fold to get SAVE_EXPR to generate what we want. */ | |
12278 | ||
12279 | static tree | |
12280 | java_refold (t) | |
12281 | tree t; | |
12282 | { | |
12283 | tree c, b, ns, decl; | |
12284 | ||
12285 | if (TREE_CODE (t) != MODIFY_EXPR) | |
12286 | return t; | |
12287 | ||
12288 | c = TREE_OPERAND (t, 1); | |
12289 | if (! (c && TREE_CODE (c) == COMPOUND_EXPR | |
12290 | && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR | |
12291 | && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1))))) | |
12292 | return t; | |
12293 | ||
12294 | /* Now the left branch of the binary operator. */ | |
12295 | b = TREE_OPERAND (TREE_OPERAND (c, 1), 0); | |
12296 | if (! (b && TREE_CODE (b) == NOP_EXPR | |
12297 | && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR)) | |
12298 | return t; | |
12299 | ||
12300 | ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0); | |
12301 | if (! (ns && TREE_CODE (ns) == NOP_EXPR | |
12302 | && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR)) | |
12303 | return t; | |
12304 | ||
12305 | decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0); | |
12306 | if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF) | |
12307 | /* It's got to be the an equivalent decl */ | |
12308 | && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0))) | |
12309 | { | |
12310 | /* Shorten the NOP_EXPR/SAVE_EXPR path. */ | |
12311 | TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0); | |
12312 | /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */ | |
12313 | TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1); | |
12314 | /* Change the right part of the BINOP_EXPR */ | |
12315 | TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0); | |
12316 | } | |
12317 | ||
12318 | return t; | |
12319 | } | |
12320 | ||
8b27f225 PB |
12321 | /* Binary operators (15.16 up to 15.18). We return error_mark_node on |
12322 | errors but we modify NODE so that it contains the type computed | |
12323 | according to the expression, when it's fixed. Otherwise, we write | |
12324 | error_mark_node as the type. It allows us to further the analysis | |
12325 | of remaining nodes and detects more errors in certain cases. */ | |
12326 | ||
12327 | static tree | |
12328 | patch_binop (node, wfl_op1, wfl_op2) | |
12329 | tree node; | |
12330 | tree wfl_op1; | |
12331 | tree wfl_op2; | |
12332 | { | |
12333 | tree op1 = TREE_OPERAND (node, 0); | |
12334 | tree op2 = TREE_OPERAND (node, 1); | |
12335 | tree op1_type = TREE_TYPE (op1); | |
12336 | tree op2_type = TREE_TYPE (op2); | |
ab3a6dd6 | 12337 | tree prom_type = NULL_TREE; |
8b27f225 PB |
12338 | int code = TREE_CODE (node); |
12339 | ||
12340 | /* If 1, tell the routine that we have to return error_mark_node | |
12341 | after checking for the initialization of the RHS */ | |
12342 | int error_found = 0; | |
12343 | ||
8b27f225 PB |
12344 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); |
12345 | ||
8b27f225 PB |
12346 | switch (code) |
12347 | { | |
12348 | /* 15.16 Multiplicative operators */ | |
12349 | case MULT_EXPR: /* 15.16.1 Multiplication Operator * */ | |
12350 | case RDIV_EXPR: /* 15.16.2 Division Operator / */ | |
12351 | case TRUNC_MOD_EXPR: /* 15.16.3 Remainder operator % */ | |
12352 | if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type)) | |
12353 | { | |
12354 | if (!JPRIMITIVE_TYPE_P (op1_type)) | |
12355 | ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type); | |
12356 | if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type)) | |
12357 | ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type); | |
12358 | TREE_TYPE (node) = error_mark_node; | |
12359 | error_found = 1; | |
12360 | break; | |
12361 | } | |
12362 | prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2); | |
12363 | /* Change the division operator if necessary */ | |
12364 | if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE) | |
12365 | TREE_SET_CODE (node, TRUNC_DIV_EXPR); | |
0b4d333e | 12366 | |
0b094f65 AH |
12367 | if (TREE_CODE (prom_type) == INTEGER_TYPE |
12368 | && flag_use_divide_subroutine | |
12369 | && ! flag_emit_class_files | |
12370 | && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR)) | |
12371 | return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2); | |
12372 | ||
0b4d333e APB |
12373 | /* This one is more complicated. FLOATs are processed by a |
12374 | function call to soft_fmod. Duplicate the value of the | |
12375 | COMPOUND_ASSIGN_P flag. */ | |
8b27f225 | 12376 | if (code == TRUNC_MOD_EXPR) |
0b4d333e APB |
12377 | { |
12378 | tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2); | |
12379 | COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node); | |
939d7216 PB |
12380 | TREE_SIDE_EFFECTS (mod) |
12381 | = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2); | |
0b4d333e APB |
12382 | return mod; |
12383 | } | |
8b27f225 PB |
12384 | break; |
12385 | ||
12386 | /* 15.17 Additive Operators */ | |
12387 | case PLUS_EXPR: /* 15.17.1 String Concatenation Operator + */ | |
12388 | ||
12389 | /* Operation is valid if either one argument is a string | |
12390 | constant, a String object or a StringBuffer crafted for the | |
12391 | purpose of the a previous usage of the String concatenation | |
12392 | operator */ | |
12393 | ||
12394 | if (TREE_CODE (op1) == STRING_CST | |
12395 | || TREE_CODE (op2) == STRING_CST | |
12396 | || JSTRING_TYPE_P (op1_type) | |
12397 | || JSTRING_TYPE_P (op2_type) | |
12398 | || IS_CRAFTED_STRING_BUFFER_P (op1) | |
12399 | || IS_CRAFTED_STRING_BUFFER_P (op2)) | |
12400 | return build_string_concatenation (op1, op2); | |
12401 | ||
12402 | case MINUS_EXPR: /* 15.17.2 Additive Operators (+ and -) for | |
12403 | Numeric Types */ | |
12404 | if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type)) | |
12405 | { | |
12406 | if (!JPRIMITIVE_TYPE_P (op1_type)) | |
12407 | ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type); | |
12408 | if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type)) | |
12409 | ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type); | |
12410 | TREE_TYPE (node) = error_mark_node; | |
12411 | error_found = 1; | |
12412 | break; | |
12413 | } | |
12414 | prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2); | |
12415 | break; | |
12416 | ||
12417 | /* 15.18 Shift Operators */ | |
12418 | case LSHIFT_EXPR: | |
12419 | case RSHIFT_EXPR: | |
12420 | case URSHIFT_EXPR: | |
12421 | if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type)) | |
12422 | { | |
12423 | if (!JINTEGRAL_TYPE_P (op1_type)) | |
12424 | ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type); | |
12425 | else | |
1ebadc60 KG |
12426 | { |
12427 | if (JPRIMITIVE_TYPE_P (op2_type)) | |
12428 | parse_error_context (wfl_operator, | |
781b0558 | 12429 | "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral", |
1ebadc60 KG |
12430 | operator_string (node), |
12431 | lang_printable_name (op2_type, 0)); | |
12432 | else | |
781b0558 KG |
12433 | parse_error_context (wfl_operator, |
12434 | "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral", | |
1ebadc60 KG |
12435 | operator_string (node), |
12436 | lang_printable_name (op2_type, 0)); | |
12437 | } | |
8b27f225 PB |
12438 | TREE_TYPE (node) = error_mark_node; |
12439 | error_found = 1; | |
12440 | break; | |
12441 | } | |
12442 | ||
12443 | /* Unary numeric promotion (5.6.1) is performed on each operand | |
12444 | separatly */ | |
12472854 PB |
12445 | op1 = do_unary_numeric_promotion (op1); |
12446 | op2 = do_unary_numeric_promotion (op2); | |
8b27f225 PB |
12447 | |
12448 | /* The type of the shift expression is the type of the promoted | |
12449 | type of the left-hand operand */ | |
12450 | prom_type = TREE_TYPE (op1); | |
12451 | ||
51149cc8 MK |
12452 | /* Shift int only up to 0x1f and long up to 0x3f. The bytecode |
12453 | generator should take care of removing this operation. FIXME */ | |
12454 | op2 = fold (build (BIT_AND_EXPR, prom_type, convert (prom_type, op2), | |
12455 | (prom_type == int_type_node ? build_int_2 (0x1f, 0) : | |
12456 | convert (prom_type, build_int_2 (0x3f, 0))))); | |
8b27f225 PB |
12457 | |
12458 | /* The >>> operator is a >> operating on unsigned quantities */ | |
12472854 | 12459 | if (code == URSHIFT_EXPR && ! flag_emit_class_files) |
8b27f225 | 12460 | { |
0b4d333e | 12461 | tree to_return; |
73333a87 AH |
12462 | tree utype = unsigned_type (prom_type); |
12463 | op1 = convert (utype, op1); | |
d4476be2 | 12464 | TREE_SET_CODE (node, RSHIFT_EXPR); |
73333a87 AH |
12465 | TREE_OPERAND (node, 0) = op1; |
12466 | TREE_OPERAND (node, 1) = op2; | |
12467 | TREE_TYPE (node) = utype; | |
0b4d333e APB |
12468 | to_return = convert (prom_type, node); |
12469 | /* Copy the original value of the COMPOUND_ASSIGN_P flag */ | |
12470 | COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node); | |
939d7216 PB |
12471 | TREE_SIDE_EFFECTS (to_return) |
12472 | = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2); | |
0b4d333e | 12473 | return to_return; |
8b27f225 PB |
12474 | } |
12475 | break; | |
5e942c50 APB |
12476 | |
12477 | /* 15.19.1 Type Comparison Operator instaceof */ | |
12478 | case INSTANCEOF_EXPR: | |
12479 | ||
12480 | TREE_TYPE (node) = boolean_type_node; | |
12481 | ||
12482 | if (!(op2_type = resolve_type_during_patch (op2))) | |
12483 | return error_mark_node; | |
12484 | ||
12485 | /* The first operand must be a reference type or the null type */ | |
12486 | if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node) | |
12487 | error_found = 1; /* Error reported further below */ | |
12488 | ||
12489 | /* The second operand must be a reference type */ | |
12490 | if (!JREFERENCE_TYPE_P (op2_type)) | |
12491 | { | |
12492 | SET_WFL_OPERATOR (wfl_operator, node, wfl_op2); | |
12493 | parse_error_context | |
12494 | (wfl_operator, "Invalid argument `%s' for `instanceof'", | |
12495 | lang_printable_name (op2_type, 0)); | |
12496 | error_found = 1; | |
12497 | } | |
12498 | ||
12499 | if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1)) | |
12500 | { | |
12501 | /* If the first operand is null, the result is always false */ | |
12502 | if (op1 == null_pointer_node) | |
12503 | return boolean_false_node; | |
12472854 PB |
12504 | else if (flag_emit_class_files) |
12505 | { | |
12506 | TREE_OPERAND (node, 1) = op2_type; | |
939d7216 | 12507 | TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1); |
12472854 PB |
12508 | return node; |
12509 | } | |
5e942c50 APB |
12510 | /* Otherwise we have to invoke instance of to figure it out */ |
12511 | else | |
12512 | { | |
12513 | tree call = | |
12514 | build (CALL_EXPR, boolean_type_node, | |
12515 | build_address_of (soft_instanceof_node), | |
12516 | tree_cons | |
12517 | (NULL_TREE, op1, | |
12518 | build_tree_list (NULL_TREE, | |
12519 | build_class_ref (op2_type))), | |
12520 | NULL_TREE); | |
939d7216 | 12521 | TREE_SIDE_EFFECTS (call) = TREE_SIDE_EFFECTS (op1); |
5e942c50 APB |
12522 | return call; |
12523 | } | |
12524 | } | |
12525 | /* There is no way the expression operand can be an instance of | |
12526 | the type operand. This is a compile time error. */ | |
12527 | else | |
12528 | { | |
c2e3db92 | 12529 | char *t1 = xstrdup (lang_printable_name (op1_type, 0)); |
5e942c50 APB |
12530 | SET_WFL_OPERATOR (wfl_operator, node, wfl_op1); |
12531 | parse_error_context | |
12532 | (wfl_operator, "Impossible for `%s' to be instance of `%s'", | |
12533 | t1, lang_printable_name (op2_type, 0)); | |
12534 | free (t1); | |
12535 | error_found = 1; | |
12536 | } | |
8b27f225 | 12537 | |
5e942c50 | 12538 | break; |
8b27f225 PB |
12539 | |
12540 | /* 15.21 Bitwise and Logical Operators */ | |
12541 | case BIT_AND_EXPR: | |
12542 | case BIT_XOR_EXPR: | |
12543 | case BIT_IOR_EXPR: | |
12544 | if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type)) | |
12545 | /* Binary numeric promotion is performed on both operand and the | |
12546 | expression retain that type */ | |
12547 | prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2); | |
12548 | ||
12549 | else if (TREE_CODE (op1_type) == BOOLEAN_TYPE | |
12550 | && TREE_CODE (op1_type) == BOOLEAN_TYPE) | |
12551 | /* The type of the bitwise operator expression is BOOLEAN */ | |
12552 | prom_type = boolean_type_node; | |
12553 | else | |
12554 | { | |
12555 | if (!JINTEGRAL_TYPE_P (op1_type)) | |
12556 | ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type); | |
12557 | if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type)) | |
12558 | ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type); | |
12559 | TREE_TYPE (node) = error_mark_node; | |
12560 | error_found = 1; | |
12561 | /* Insert a break here if adding thing before the switch's | |
12562 | break for this case */ | |
12563 | } | |
12564 | break; | |
12565 | ||
12566 | /* 15.22 Conditional-And Operator */ | |
12567 | case TRUTH_ANDIF_EXPR: | |
12568 | /* 15.23 Conditional-Or Operator */ | |
12569 | case TRUTH_ORIF_EXPR: | |
12570 | /* Operands must be of BOOLEAN type */ | |
12571 | if (TREE_CODE (op1_type) != BOOLEAN_TYPE || | |
12572 | TREE_CODE (op2_type) != BOOLEAN_TYPE) | |
12573 | { | |
12574 | if (TREE_CODE (op1_type) != BOOLEAN_TYPE) | |
12575 | ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type); | |
12576 | if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type)) | |
12577 | ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type); | |
12578 | TREE_TYPE (node) = boolean_type_node; | |
12579 | error_found = 1; | |
12580 | break; | |
12581 | } | |
12582 | /* The type of the conditional operators is BOOLEAN */ | |
12583 | prom_type = boolean_type_node; | |
12584 | break; | |
12585 | ||
12586 | /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */ | |
12587 | case LT_EXPR: | |
12588 | case GT_EXPR: | |
12589 | case LE_EXPR: | |
12590 | case GE_EXPR: | |
12591 | /* The type of each of the operands must be a primitive numeric | |
12592 | type */ | |
12593 | if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type)) | |
12594 | { | |
12595 | if (!JNUMERIC_TYPE_P (op1_type)) | |
12596 | ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type); | |
12597 | if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type)) | |
12598 | ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type); | |
12599 | TREE_TYPE (node) = boolean_type_node; | |
12600 | error_found = 1; | |
12601 | break; | |
12602 | } | |
12603 | /* Binary numeric promotion is performed on the operands */ | |
12604 | binary_numeric_promotion (op1_type, op2_type, &op1, &op2); | |
12605 | /* The type of the relation expression is always BOOLEAN */ | |
12606 | prom_type = boolean_type_node; | |
12607 | break; | |
12608 | ||
12609 | /* 15.20 Equality Operator */ | |
12610 | case EQ_EXPR: | |
12611 | case NE_EXPR: | |
12612 | /* 15.20.1 Numerical Equality Operators == and != */ | |
12613 | /* Binary numeric promotion is performed on the operands */ | |
5e942c50 | 12614 | if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type)) |
8b27f225 PB |
12615 | binary_numeric_promotion (op1_type, op2_type, &op1, &op2); |
12616 | ||
12617 | /* 15.20.2 Boolean Equality Operators == and != */ | |
12618 | else if (TREE_CODE (op1_type) == BOOLEAN_TYPE && | |
12619 | TREE_CODE (op2_type) == BOOLEAN_TYPE) | |
12620 | ; /* Nothing to do here */ | |
12621 | ||
12622 | /* 15.20.3 Reference Equality Operators == and != */ | |
5e942c50 APB |
12623 | /* Types have to be either references or the null type. If |
12624 | they're references, it must be possible to convert either | |
12625 | type to the other by casting conversion. */ | |
8b27f225 PB |
12626 | else if (op1 == null_pointer_node || op2 == null_pointer_node |
12627 | || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type) | |
5e942c50 APB |
12628 | && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1) |
12629 | || valid_ref_assignconv_cast_p (op2_type, | |
12630 | op1_type, 1)))) | |
8b27f225 PB |
12631 | ; /* Nothing to do here */ |
12632 | ||
12633 | /* Else we have an error figure what can't be converted into | |
12634 | what and report the error */ | |
12635 | else | |
12636 | { | |
12637 | char *t1; | |
c2e3db92 | 12638 | t1 = xstrdup (lang_printable_name (op1_type, 0)); |
8b27f225 | 12639 | parse_error_context |
781b0558 KG |
12640 | (wfl_operator, |
12641 | "Incompatible type for `%s'. Can't convert `%s' to `%s'", | |
12642 | operator_string (node), t1, | |
8b27f225 PB |
12643 | lang_printable_name (op2_type, 0)); |
12644 | free (t1); | |
12645 | TREE_TYPE (node) = boolean_type_node; | |
12646 | error_found = 1; | |
12647 | break; | |
12648 | } | |
12649 | prom_type = boolean_type_node; | |
12650 | break; | |
12651 | } | |
12652 | ||
8b27f225 PB |
12653 | if (error_found) |
12654 | return error_mark_node; | |
12655 | ||
12656 | TREE_OPERAND (node, 0) = op1; | |
12657 | TREE_OPERAND (node, 1) = op2; | |
12658 | TREE_TYPE (node) = prom_type; | |
939d7216 PB |
12659 | TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2); |
12660 | ||
ce6e9147 APB |
12661 | if (flag_emit_xref) |
12662 | return node; | |
12663 | ||
7c3f7c03 PB |
12664 | /* fold does not respect side-effect order as required for Java but not C. |
12665 | * Also, it sometimes create SAVE_EXPRs which are bad when emitting | |
12666 | * bytecode. | |
12667 | */ | |
12668 | if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2)) | |
12669 | : ! TREE_SIDE_EFFECTS (node)) | |
4fdea7b0 PB |
12670 | node = fold (node); |
12671 | return node; | |
8b27f225 PB |
12672 | } |
12673 | ||
12674 | /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non | |
12675 | zero value, the value of CSTE comes after the valude of STRING */ | |
12676 | ||
12677 | static tree | |
12678 | do_merge_string_cste (cste, string, string_len, after) | |
12679 | tree cste; | |
49f48c71 | 12680 | const char *string; |
8b27f225 PB |
12681 | int string_len, after; |
12682 | { | |
12683 | int len = TREE_STRING_LENGTH (cste) + string_len; | |
49f48c71 | 12684 | const char *old = TREE_STRING_POINTER (cste); |
8b27f225 PB |
12685 | TREE_STRING_LENGTH (cste) = len; |
12686 | TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1); | |
12687 | if (after) | |
12688 | { | |
12689 | strcpy (TREE_STRING_POINTER (cste), string); | |
12690 | strcat (TREE_STRING_POINTER (cste), old); | |
12691 | } | |
12692 | else | |
12693 | { | |
12694 | strcpy (TREE_STRING_POINTER (cste), old); | |
12695 | strcat (TREE_STRING_POINTER (cste), string); | |
12696 | } | |
12697 | return cste; | |
12698 | } | |
12699 | ||
12700 | /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a | |
12701 | new STRING_CST on success, NULL_TREE on failure */ | |
12702 | ||
12703 | static tree | |
12704 | merge_string_cste (op1, op2, after) | |
12705 | tree op1, op2; | |
12706 | int after; | |
12707 | { | |
12708 | /* Handle two string constants right away */ | |
12709 | if (TREE_CODE (op2) == STRING_CST) | |
12710 | return do_merge_string_cste (op1, TREE_STRING_POINTER (op2), | |
12711 | TREE_STRING_LENGTH (op2), after); | |
12712 | ||
12713 | /* Reasonable integer constant can be treated right away */ | |
12714 | if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2)) | |
12715 | { | |
49f48c71 KG |
12716 | static const char *boolean_true = "true"; |
12717 | static const char *boolean_false = "false"; | |
12718 | static const char *null_pointer = "null"; | |
8b27f225 | 12719 | char ch[3]; |
49f48c71 | 12720 | const char *string; |
8b27f225 PB |
12721 | |
12722 | if (op2 == boolean_true_node) | |
12723 | string = boolean_true; | |
12724 | else if (op2 == boolean_false_node) | |
12725 | string = boolean_false; | |
12726 | else if (op2 == null_pointer_node) | |
12727 | string = null_pointer; | |
12728 | else if (TREE_TYPE (op2) == char_type_node) | |
12729 | { | |
12730 | ch[0] = (char )TREE_INT_CST_LOW (op2); | |
12731 | ch[1] = '\0'; | |
12732 | string = ch; | |
12733 | } | |
12734 | else | |
12735 | string = print_int_node (op2); | |
12736 | ||
12737 | return do_merge_string_cste (op1, string, strlen (string), after); | |
12738 | } | |
12739 | return NULL_TREE; | |
12740 | } | |
12741 | ||
12742 | /* Tries to statically concatenate OP1 and OP2 if possible. Either one | |
12743 | has to be a STRING_CST and the other part must be a STRING_CST or a | |
12744 | INTEGRAL constant. Return a new STRING_CST if the operation | |
12745 | succeed, NULL_TREE otherwise. | |
12746 | ||
12747 | If the case we want to optimize for space, we might want to return | |
12748 | NULL_TREE for each invocation of this routine. FIXME */ | |
12749 | ||
12750 | static tree | |
12751 | string_constant_concatenation (op1, op2) | |
12752 | tree op1, op2; | |
12753 | { | |
12754 | if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST)) | |
12755 | { | |
12756 | tree string, rest; | |
12757 | int invert; | |
12758 | ||
12759 | string = (TREE_CODE (op1) == STRING_CST ? op1 : op2); | |
12760 | rest = (string == op1 ? op2 : op1); | |
12761 | invert = (string == op1 ? 0 : 1 ); | |
12762 | ||
12763 | /* Walk REST, only if it looks reasonable */ | |
12764 | if (TREE_CODE (rest) != STRING_CST | |
12765 | && !IS_CRAFTED_STRING_BUFFER_P (rest) | |
12766 | && !JSTRING_TYPE_P (TREE_TYPE (rest)) | |
12767 | && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION) | |
12768 | { | |
12769 | rest = java_complete_tree (rest); | |
12770 | if (rest == error_mark_node) | |
12771 | return error_mark_node; | |
12772 | rest = fold (rest); | |
12773 | } | |
12774 | return merge_string_cste (string, rest, invert); | |
12775 | } | |
12776 | return NULL_TREE; | |
12777 | } | |
12778 | ||
12779 | /* Implement the `+' operator. Does static optimization if possible, | |
12780 | otherwise create (if necessary) and append elements to a | |
12781 | StringBuffer. The StringBuffer will be carried around until it is | |
12782 | used for a function call or an assignment. Then toString() will be | |
12783 | called on it to turn it into a String object. */ | |
12784 | ||
12785 | static tree | |
12786 | build_string_concatenation (op1, op2) | |
12787 | tree op1, op2; | |
12788 | { | |
12789 | tree result; | |
939d7216 | 12790 | int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2); |
ce6e9147 APB |
12791 | |
12792 | if (flag_emit_xref) | |
12793 | return build (PLUS_EXPR, string_type_node, op1, op2); | |
8b27f225 PB |
12794 | |
12795 | /* Try to do some static optimization */ | |
12796 | if ((result = string_constant_concatenation (op1, op2))) | |
12797 | return result; | |
12798 | ||
c0d87ff6 PB |
12799 | /* Discard empty strings on either side of the expression */ |
12800 | if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0) | |
acd663ee APB |
12801 | { |
12802 | op1 = op2; | |
12803 | op2 = NULL_TREE; | |
12804 | } | |
c0d87ff6 | 12805 | else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0) |
acd663ee | 12806 | op2 = NULL_TREE; |
8b27f225 | 12807 | |
acd663ee | 12808 | /* If operands are string constant, turn then into object references */ |
8b27f225 PB |
12809 | if (TREE_CODE (op1) == STRING_CST) |
12810 | op1 = patch_string_cst (op1); | |
acd663ee | 12811 | if (op2 && TREE_CODE (op2) == STRING_CST) |
8b27f225 PB |
12812 | op2 = patch_string_cst (op2); |
12813 | ||
acd663ee APB |
12814 | /* If either one of the constant is null and the other non null |
12815 | operand is a String object, return it. */ | |
12816 | if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2) | |
12817 | return op1; | |
12818 | ||
8b27f225 PB |
12819 | /* If OP1 isn't already a StringBuffer, create and |
12820 | initialize a new one */ | |
12821 | if (!IS_CRAFTED_STRING_BUFFER_P (op1)) | |
12822 | { | |
12823 | /* Two solutions here: | |
c52b5771 AG |
12824 | 1) OP1 is a constant string reference, we call new StringBuffer(OP1) |
12825 | 2) OP1 is something else, we call new StringBuffer().append(OP1). */ | |
12826 | if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1))) | |
8b27f225 PB |
12827 | op1 = BUILD_STRING_BUFFER (op1); |
12828 | else | |
12829 | { | |
12830 | tree aNew = BUILD_STRING_BUFFER (NULL_TREE); | |
12831 | op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0); | |
12832 | } | |
12833 | } | |
12834 | ||
acd663ee APB |
12835 | if (op2) |
12836 | { | |
12837 | /* OP1 is no longer the last node holding a crafted StringBuffer */ | |
12838 | IS_CRAFTED_STRING_BUFFER_P (op1) = 0; | |
12839 | /* Create a node for `{new...,xxx}.append (op2)' */ | |
12840 | if (op2) | |
12841 | op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0); | |
12842 | } | |
12843 | ||
8b27f225 PB |
12844 | /* Mark the last node holding a crafted StringBuffer */ |
12845 | IS_CRAFTED_STRING_BUFFER_P (op1) = 1; | |
939d7216 PB |
12846 | |
12847 | TREE_SIDE_EFFECTS (op1) = side_effects; | |
8b27f225 PB |
12848 | return op1; |
12849 | } | |
12850 | ||
12851 | /* Patch the string node NODE. NODE can be a STRING_CST of a crafted | |
12852 | StringBuffer. If no string were found to be patched, return | |
12853 | NULL. */ | |
12854 | ||
12855 | static tree | |
12856 | patch_string (node) | |
12857 | tree node; | |
12858 | { | |
1179ebc2 APB |
12859 | if (node == error_mark_node) |
12860 | return error_mark_node; | |
8b27f225 PB |
12861 | if (TREE_CODE (node) == STRING_CST) |
12862 | return patch_string_cst (node); | |
12863 | else if (IS_CRAFTED_STRING_BUFFER_P (node)) | |
12864 | { | |
c877974e | 12865 | int saved = ctxp->explicit_constructor_p; |
8b27f225 | 12866 | tree invoke = build_method_invocation (wfl_to_string, NULL_TREE); |
c877974e APB |
12867 | tree ret; |
12868 | /* Temporary disable forbid the use of `this'. */ | |
12869 | ctxp->explicit_constructor_p = 0; | |
12870 | ret = java_complete_tree (make_qualified_primary (node, invoke, 0)); | |
12871 | /* Restore it at its previous value */ | |
12872 | ctxp->explicit_constructor_p = saved; | |
12873 | return ret; | |
8b27f225 PB |
12874 | } |
12875 | return NULL_TREE; | |
12876 | } | |
12877 | ||
12878 | /* Build the internal representation of a string constant. */ | |
12879 | ||
12880 | static tree | |
12881 | patch_string_cst (node) | |
12882 | tree node; | |
12883 | { | |
12884 | int location; | |
12472854 PB |
12885 | if (! flag_emit_class_files) |
12886 | { | |
12887 | push_obstacks (&permanent_obstack, &permanent_obstack); | |
12888 | node = get_identifier (TREE_STRING_POINTER (node)); | |
12889 | location = alloc_name_constant (CONSTANT_String, node); | |
12890 | node = build_ref_from_constant_pool (location); | |
8226320b | 12891 | pop_obstacks (); |
12472854 | 12892 | } |
cd9643f7 | 12893 | TREE_TYPE (node) = string_ptr_type_node; |
8b27f225 PB |
12894 | TREE_CONSTANT (node) = 1; |
12895 | return node; | |
12896 | } | |
12897 | ||
12898 | /* Build an incomplete unary operator expression. */ | |
12899 | ||
12900 | static tree | |
12901 | build_unaryop (op_token, op_location, op1) | |
12902 | int op_token, op_location; | |
12903 | tree op1; | |
12904 | { | |
12905 | enum tree_code op; | |
12906 | tree unaryop; | |
12907 | switch (op_token) | |
12908 | { | |
12909 | case PLUS_TK: op = UNARY_PLUS_EXPR; break; | |
12910 | case MINUS_TK: op = NEGATE_EXPR; break; | |
12911 | case NEG_TK: op = TRUTH_NOT_EXPR; break; | |
12912 | case NOT_TK: op = BIT_NOT_EXPR; break; | |
12913 | default: fatal ("Unknown token `%d' for unary operator - build_unaryop", | |
12914 | op_token); | |
12915 | } | |
12916 | ||
12917 | unaryop = build1 (op, NULL_TREE, op1); | |
12918 | TREE_SIDE_EFFECTS (unaryop) = 1; | |
12919 | /* Store the location of the operator, for better error report. The | |
12920 | string of the operator will be rebuild based on the OP value. */ | |
12921 | EXPR_WFL_LINECOL (unaryop) = op_location; | |
12922 | return unaryop; | |
12923 | } | |
12924 | ||
12925 | /* Special case for the ++/-- operators, since they require an extra | |
12926 | argument to build, which is set to NULL and patched | |
12927 | later. IS_POST_P is 1 if the operator, 0 otherwise. */ | |
12928 | ||
12929 | static tree | |
12930 | build_incdec (op_token, op_location, op1, is_post_p) | |
12931 | int op_token, op_location; | |
12932 | tree op1; | |
12933 | int is_post_p; | |
12934 | { | |
12935 | static enum tree_code lookup [2][2] = | |
12936 | { | |
12937 | { PREDECREMENT_EXPR, PREINCREMENT_EXPR, }, | |
12938 | { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, }, | |
12939 | }; | |
12940 | tree node = build (lookup [is_post_p][(op_token - DECR_TK)], | |
12941 | NULL_TREE, op1, NULL_TREE); | |
12942 | TREE_SIDE_EFFECTS (node) = 1; | |
12943 | /* Store the location of the operator, for better error report. The | |
12944 | string of the operator will be rebuild based on the OP value. */ | |
12945 | EXPR_WFL_LINECOL (node) = op_location; | |
12946 | return node; | |
12947 | } | |
12948 | ||
12949 | /* Build an incomplete cast operator, based on the use of the | |
12950 | CONVERT_EXPR. Note that TREE_TYPE of the constructed node is | |
12951 | set. java_complete_tree is trained to walk a CONVERT_EXPR even | |
12952 | though its type is already set. */ | |
12953 | ||
12954 | static tree | |
12955 | build_cast (location, type, exp) | |
12956 | int location; | |
12957 | tree type, exp; | |
12958 | { | |
12959 | tree node = build1 (CONVERT_EXPR, type, exp); | |
12960 | EXPR_WFL_LINECOL (node) = location; | |
12961 | return node; | |
12962 | } | |
12963 | ||
12964 | /* 15.14 Unary operators. We return error_mark_node in case of error, | |
12965 | but preserve the type of NODE if the type is fixed. */ | |
12966 | ||
12967 | static tree | |
12968 | patch_unaryop (node, wfl_op) | |
12969 | tree node; | |
12970 | tree wfl_op; | |
12971 | { | |
12972 | tree op = TREE_OPERAND (node, 0); | |
12973 | tree op_type = TREE_TYPE (op); | |
ab3a6dd6 | 12974 | tree prom_type = NULL_TREE, value, decl; |
8b27f225 PB |
12975 | int code = TREE_CODE (node); |
12976 | int error_found = 0; | |
12977 | ||
12978 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
12979 | ||
12980 | switch (code) | |
12981 | { | |
12982 | /* 15.13.2 Postfix Increment Operator ++ */ | |
12983 | case POSTINCREMENT_EXPR: | |
12984 | /* 15.13.3 Postfix Increment Operator -- */ | |
12985 | case POSTDECREMENT_EXPR: | |
12986 | /* 15.14.1 Prefix Increment Operator ++ */ | |
12987 | case PREINCREMENT_EXPR: | |
12988 | /* 15.14.2 Prefix Decrement Operator -- */ | |
12989 | case PREDECREMENT_EXPR: | |
5cbdba64 | 12990 | op = decl = strip_out_static_field_access_decl (op); |
a3f406ce | 12991 | /* We really should have a JAVA_ARRAY_EXPR to avoid this */ |
78d21f92 | 12992 | if (!JDECL_P (decl) |
b3edebcf APB |
12993 | && TREE_CODE (decl) != COMPONENT_REF |
12994 | && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF) | |
12995 | && TREE_CODE (decl) != INDIRECT_REF | |
12996 | && !(TREE_CODE (decl) == COMPOUND_EXPR | |
12997 | && TREE_OPERAND (decl, 1) | |
12998 | && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF))) | |
8b27f225 | 12999 | { |
5e942c50 APB |
13000 | tree lvalue; |
13001 | /* Before screaming, check that we're not in fact trying to | |
13002 | increment a optimized static final access, in which case | |
13003 | we issue an different error message. */ | |
13004 | if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION | |
13005 | && resolve_expression_name (wfl_op, &lvalue) | |
13006 | && check_final_assignment (lvalue, wfl_op))) | |
13007 | parse_error_context (wfl_operator, "Invalid argument to `%s'", | |
13008 | operator_string (node)); | |
8b27f225 PB |
13009 | TREE_TYPE (node) = error_mark_node; |
13010 | error_found = 1; | |
13011 | } | |
5e942c50 APB |
13012 | else if (check_final_assignment (op, wfl_op)) |
13013 | error_found = 1; | |
13014 | ||
8b27f225 PB |
13015 | /* From now on, we know that op if a variable and that it has a |
13016 | valid wfl. We use wfl_op to locate errors related to the | |
13017 | ++/-- operand. */ | |
13018 | else if (!JNUMERIC_TYPE_P (op_type)) | |
13019 | { | |
13020 | parse_error_context | |
13021 | (wfl_op, "Invalid argument type `%s' to `%s'", | |
13022 | lang_printable_name (op_type, 0), operator_string (node)); | |
13023 | TREE_TYPE (node) = error_mark_node; | |
13024 | error_found = 1; | |
13025 | } | |
13026 | else | |
13027 | { | |
4a5f66c3 | 13028 | /* Before the addition, binary numeric promotion is performed on |
5cbdba64 APB |
13029 | both operands, if really necessary */ |
13030 | if (JINTEGRAL_TYPE_P (op_type)) | |
13031 | { | |
13032 | value = build_int_2 (1, 0); | |
13033 | TREE_TYPE (value) = TREE_TYPE (node) = op_type; | |
13034 | } | |
13035 | else | |
13036 | { | |
13037 | value = build_int_2 (1, 0); | |
13038 | TREE_TYPE (node) = | |
13039 | binary_numeric_promotion (op_type, | |
13040 | TREE_TYPE (value), &op, &value); | |
13041 | } | |
13042 | /* And write back into the node. */ | |
4a5f66c3 | 13043 | TREE_OPERAND (node, 0) = op; |
8b27f225 | 13044 | TREE_OPERAND (node, 1) = value; |
5cbdba64 APB |
13045 | /* Convert the overall back into its original type, if |
13046 | necessary, and return */ | |
13047 | if (JINTEGRAL_TYPE_P (op_type)) | |
13048 | return fold (node); | |
13049 | else | |
13050 | return fold (convert (op_type, node)); | |
8b27f225 PB |
13051 | } |
13052 | break; | |
13053 | ||
13054 | /* 15.14.3 Unary Plus Operator + */ | |
13055 | case UNARY_PLUS_EXPR: | |
13056 | /* 15.14.4 Unary Minus Operator - */ | |
13057 | case NEGATE_EXPR: | |
13058 | if (!JNUMERIC_TYPE_P (op_type)) | |
13059 | { | |
13060 | ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type); | |
13061 | TREE_TYPE (node) = error_mark_node; | |
13062 | error_found = 1; | |
13063 | } | |
13064 | /* Unary numeric promotion is performed on operand */ | |
13065 | else | |
13066 | { | |
12472854 PB |
13067 | op = do_unary_numeric_promotion (op); |
13068 | prom_type = TREE_TYPE (op); | |
8b27f225 | 13069 | if (code == UNARY_PLUS_EXPR) |
4a5f66c3 | 13070 | return fold (op); |
8b27f225 PB |
13071 | } |
13072 | break; | |
13073 | ||
13074 | /* 15.14.5 Bitwise Complement Operator ~ */ | |
13075 | case BIT_NOT_EXPR: | |
13076 | if (!JINTEGRAL_TYPE_P (op_type)) | |
13077 | { | |
13078 | ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type); | |
13079 | TREE_TYPE (node) = error_mark_node; | |
13080 | error_found = 1; | |
13081 | } | |
13082 | else | |
13083 | { | |
12472854 PB |
13084 | op = do_unary_numeric_promotion (op); |
13085 | prom_type = TREE_TYPE (op); | |
8b27f225 PB |
13086 | } |
13087 | break; | |
13088 | ||
13089 | /* 15.14.6 Logical Complement Operator ! */ | |
13090 | case TRUTH_NOT_EXPR: | |
13091 | if (TREE_CODE (op_type) != BOOLEAN_TYPE) | |
13092 | { | |
13093 | ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type); | |
c877974e APB |
13094 | /* But the type is known. We will report an error if further |
13095 | attempt of a assignment is made with this rhs */ | |
8b27f225 PB |
13096 | TREE_TYPE (node) = boolean_type_node; |
13097 | error_found = 1; | |
13098 | } | |
13099 | else | |
13100 | prom_type = boolean_type_node; | |
13101 | break; | |
13102 | ||
13103 | /* 15.15 Cast Expression */ | |
13104 | case CONVERT_EXPR: | |
13105 | value = patch_cast (node, wfl_operator); | |
13106 | if (value == error_mark_node) | |
c877974e APB |
13107 | { |
13108 | /* If this cast is part of an assignment, we tell the code | |
13109 | that deals with it not to complain about a mismatch, | |
13110 | because things have been cast, anyways */ | |
13111 | TREE_TYPE (node) = error_mark_node; | |
13112 | error_found = 1; | |
13113 | } | |
13114 | else | |
939d7216 PB |
13115 | { |
13116 | value = fold (value); | |
13117 | TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op); | |
13118 | return value; | |
13119 | } | |
8b27f225 PB |
13120 | break; |
13121 | } | |
13122 | ||
8b27f225 PB |
13123 | if (error_found) |
13124 | return error_mark_node; | |
4a5f66c3 APB |
13125 | |
13126 | /* There are cases where node has been replaced by something else | |
13127 | and we don't end up returning here: UNARY_PLUS_EXPR, | |
13128 | CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */ | |
63a212ed | 13129 | TREE_OPERAND (node, 0) = fold (op); |
4a5f66c3 | 13130 | TREE_TYPE (node) = prom_type; |
939d7216 | 13131 | TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op); |
8b27f225 PB |
13132 | return fold (node); |
13133 | } | |
13134 | ||
13135 | /* Generic type resolution that sometimes takes place during node | |
13136 | patching. Returned the resolved type or generate an error | |
13137 | message. Return the resolved type or NULL_TREE. */ | |
13138 | ||
13139 | static tree | |
13140 | resolve_type_during_patch (type) | |
13141 | tree type; | |
13142 | { | |
13143 | if (unresolved_type_p (type, NULL)) | |
13144 | { | |
13145 | tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE); | |
13146 | if (!type_decl) | |
13147 | { | |
13148 | parse_error_context (type, | |
13149 | "Class `%s' not found in type declaration", | |
13150 | IDENTIFIER_POINTER (EXPR_WFL_NODE (type))); | |
13151 | return NULL_TREE; | |
13152 | } | |
13153 | else | |
5e942c50 APB |
13154 | { |
13155 | CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1; | |
13156 | return TREE_TYPE (type_decl); | |
13157 | } | |
8b27f225 PB |
13158 | } |
13159 | return type; | |
13160 | } | |
13161 | /* 5.5 Casting Conversion. error_mark_node is returned if an error is | |
13162 | found. Otherwise NODE or something meant to replace it is returned. */ | |
13163 | ||
13164 | static tree | |
13165 | patch_cast (node, wfl_operator) | |
13166 | tree node; | |
13167 | tree wfl_operator; | |
13168 | { | |
13169 | tree op = TREE_OPERAND (node, 0); | |
13170 | tree op_type = TREE_TYPE (op); | |
13171 | tree cast_type = TREE_TYPE (node); | |
13172 | char *t1; | |
13173 | ||
13174 | /* First resolve OP_TYPE if unresolved */ | |
13175 | if (!(cast_type = resolve_type_during_patch (cast_type))) | |
13176 | return error_mark_node; | |
13177 | ||
13178 | /* Check on cast that are proven correct at compile time */ | |
13179 | if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type)) | |
13180 | { | |
8b27f225 PB |
13181 | /* Same type */ |
13182 | if (cast_type == op_type) | |
13183 | return node; | |
13184 | ||
0b4d333e APB |
13185 | /* float and double type are converted to the original type main |
13186 | variant and then to the target type. */ | |
13187 | if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE) | |
13188 | op = convert (integer_type_node, op); | |
13189 | ||
8b27f225 PB |
13190 | /* Try widening/narowwing convertion. Potentially, things need |
13191 | to be worked out in gcc so we implement the extreme cases | |
13192 | correctly. fold_convert() needs to be fixed. */ | |
13193 | return convert (cast_type, op); | |
13194 | } | |
13195 | ||
0b4d333e APB |
13196 | /* It's also valid to cast a boolean into a boolean */ |
13197 | if (op_type == boolean_type_node && cast_type == boolean_type_node) | |
13198 | return node; | |
13199 | ||
5e942c50 APB |
13200 | /* null can be casted to references */ |
13201 | if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type)) | |
13202 | return build_null_of_type (cast_type); | |
13203 | ||
8b27f225 PB |
13204 | /* The remaining legal casts involve conversion between reference |
13205 | types. Check for their compile time correctness. */ | |
13206 | if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type) | |
09ed0f70 | 13207 | && valid_ref_assignconv_cast_p (op_type, cast_type, 1)) |
8b27f225 PB |
13208 | { |
13209 | TREE_TYPE (node) = promote_type (cast_type); | |
13210 | /* Now, the case can be determined correct at compile time if | |
13211 | OP_TYPE can be converted into CAST_TYPE by assignment | |
13212 | conversion (5.2) */ | |
13213 | ||
13214 | if (valid_ref_assignconv_cast_p (op_type, cast_type, 0)) | |
12472854 PB |
13215 | { |
13216 | TREE_SET_CODE (node, NOP_EXPR); | |
13217 | return node; | |
13218 | } | |
13219 | ||
13220 | if (flag_emit_class_files) | |
13221 | { | |
13222 | TREE_SET_CODE (node, CONVERT_EXPR); | |
13223 | return node; | |
13224 | } | |
8b27f225 PB |
13225 | |
13226 | /* The cast requires a run-time check */ | |
13227 | return build (CALL_EXPR, promote_type (cast_type), | |
13228 | build_address_of (soft_checkcast_node), | |
13229 | tree_cons (NULL_TREE, build_class_ref (cast_type), | |
13230 | build_tree_list (NULL_TREE, op)), | |
13231 | NULL_TREE); | |
13232 | } | |
13233 | ||
13234 | /* Any other casts are proven incorrect at compile time */ | |
c2e3db92 | 13235 | t1 = xstrdup (lang_printable_name (op_type, 0)); |
8b27f225 PB |
13236 | parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'", |
13237 | t1, lang_printable_name (cast_type, 0)); | |
13238 | free (t1); | |
13239 | return error_mark_node; | |
13240 | } | |
13241 | ||
5e942c50 APB |
13242 | /* Build a null constant and give it the type TYPE. */ |
13243 | ||
13244 | static tree | |
13245 | build_null_of_type (type) | |
13246 | tree type; | |
13247 | { | |
13248 | tree node = build_int_2 (0, 0); | |
13249 | TREE_TYPE (node) = promote_type (type); | |
13250 | return node; | |
13251 | } | |
13252 | ||
8b27f225 PB |
13253 | /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't |
13254 | a list of indices. */ | |
13255 | static tree | |
13256 | build_array_ref (location, array, index) | |
13257 | int location; | |
13258 | tree array, index; | |
13259 | { | |
13260 | tree node = build (ARRAY_REF, NULL_TREE, array, index); | |
13261 | EXPR_WFL_LINECOL (node) = location; | |
13262 | return node; | |
13263 | } | |
13264 | ||
13265 | /* 15.12 Array Access Expression */ | |
13266 | ||
13267 | static tree | |
c877974e APB |
13268 | patch_array_ref (node) |
13269 | tree node; | |
8b27f225 PB |
13270 | { |
13271 | tree array = TREE_OPERAND (node, 0); | |
13272 | tree array_type = TREE_TYPE (array); | |
13273 | tree index = TREE_OPERAND (node, 1); | |
13274 | tree index_type = TREE_TYPE (index); | |
8b27f225 PB |
13275 | int error_found = 0; |
13276 | ||
13277 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
13278 | ||
8b27f225 PB |
13279 | if (TREE_CODE (array_type) == POINTER_TYPE) |
13280 | array_type = TREE_TYPE (array_type); | |
13281 | ||
13282 | /* The array reference must be an array */ | |
13283 | if (!TYPE_ARRAY_P (array_type)) | |
13284 | { | |
13285 | parse_error_context | |
781b0558 KG |
13286 | (wfl_operator, |
13287 | "`[]' can only be applied to arrays. It can't be applied to `%s'", | |
13288 | lang_printable_name (array_type, 0)); | |
8b27f225 PB |
13289 | TREE_TYPE (node) = error_mark_node; |
13290 | error_found = 1; | |
13291 | } | |
13292 | ||
13293 | /* The array index underdoes unary numeric promotion. The promoted | |
13294 | type must be int */ | |
12472854 PB |
13295 | index = do_unary_numeric_promotion (index); |
13296 | if (TREE_TYPE (index) != int_type_node) | |
8b27f225 | 13297 | { |
1ebadc60 | 13298 | if (valid_cast_to_p (index_type, int_type_node)) |
781b0558 KG |
13299 | parse_error_context (wfl_operator, |
13300 | "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'", | |
1ebadc60 KG |
13301 | lang_printable_name (index_type, 0)); |
13302 | else | |
781b0558 KG |
13303 | parse_error_context (wfl_operator, |
13304 | "Incompatible type for `[]'. Can't convert `%s' to `int'", | |
1ebadc60 | 13305 | lang_printable_name (index_type, 0)); |
8b27f225 PB |
13306 | TREE_TYPE (node) = error_mark_node; |
13307 | error_found = 1; | |
13308 | } | |
13309 | ||
8b27f225 PB |
13310 | if (error_found) |
13311 | return error_mark_node; | |
8b27f225 | 13312 | |
5e942c50 | 13313 | array_type = TYPE_ARRAY_ELEMENT (array_type); |
5e942c50 | 13314 | |
7f1d4866 | 13315 | if (flag_emit_class_files || flag_emit_xref) |
8b27f225 | 13316 | { |
12472854 PB |
13317 | TREE_OPERAND (node, 0) = array; |
13318 | TREE_OPERAND (node, 1) = index; | |
8b27f225 PB |
13319 | } |
13320 | else | |
939d7216 PB |
13321 | { |
13322 | /* The save_expr is for correct evaluation order. It would be cleaner | |
13323 | to use force_evaluation_order (see comment there), but that is | |
13324 | difficult when we also have to deal with bounds checking. */ | |
13325 | if (TREE_SIDE_EFFECTS (index)) | |
13326 | array = save_expr (array); | |
13327 | node = build_java_arrayaccess (array, array_type, index); | |
13328 | if (TREE_SIDE_EFFECTS (index)) | |
13329 | node = build (COMPOUND_EXPR, array_type, array, node); | |
13330 | } | |
8b27f225 PB |
13331 | TREE_TYPE (node) = array_type; |
13332 | return node; | |
13333 | } | |
13334 | ||
13335 | /* 15.9 Array Creation Expressions */ | |
13336 | ||
13337 | static tree | |
13338 | build_newarray_node (type, dims, extra_dims) | |
13339 | tree type; | |
13340 | tree dims; | |
13341 | int extra_dims; | |
13342 | { | |
13343 | tree node = | |
13344 | build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims), | |
13345 | build_int_2 (extra_dims, 0)); | |
13346 | return node; | |
13347 | } | |
13348 | ||
13349 | static tree | |
13350 | patch_newarray (node) | |
13351 | tree node; | |
13352 | { | |
13353 | tree type = TREE_OPERAND (node, 0); | |
13354 | tree dims = TREE_OPERAND (node, 1); | |
13355 | tree cdim, array_type; | |
13356 | int error_found = 0; | |
13357 | int ndims = 0; | |
13358 | int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2)); | |
8b27f225 PB |
13359 | |
13360 | /* Dimension types are verified. It's better for the types to be | |
13361 | verified in order. */ | |
13362 | for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ ) | |
13363 | { | |
13364 | int dim_error = 0; | |
13365 | tree dim = TREE_VALUE (cdim); | |
13366 | ||
13367 | /* Dim might have been saved during its evaluation */ | |
13368 | dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim); | |
13369 | ||
13370 | /* The type of each specified dimension must be an integral type. */ | |
13371 | if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim))) | |
13372 | dim_error = 1; | |
13373 | ||
13374 | /* Each expression undergoes an unary numeric promotion (5.6.1) and the | |
13375 | promoted type must be int. */ | |
13376 | else | |
13377 | { | |
12472854 | 13378 | dim = do_unary_numeric_promotion (dim); |
8b27f225 PB |
13379 | if (TREE_TYPE (dim) != int_type_node) |
13380 | dim_error = 1; | |
13381 | } | |
13382 | ||
13383 | /* Report errors on types here */ | |
13384 | if (dim_error) | |
13385 | { | |
13386 | parse_error_context | |
13387 | (TREE_PURPOSE (cdim), | |
781b0558 | 13388 | "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'", |
8b27f225 PB |
13389 | (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ? |
13390 | "Explicit cast needed to" : "Can't"), | |
13391 | lang_printable_name (TREE_TYPE (dim), 0)); | |
13392 | error_found = 1; | |
13393 | } | |
13394 | ||
8b27f225 PB |
13395 | TREE_PURPOSE (cdim) = NULL_TREE; |
13396 | } | |
13397 | ||
13398 | /* Resolve array base type if unresolved */ | |
13399 | if (!(type = resolve_type_during_patch (type))) | |
13400 | error_found = 1; | |
13401 | ||
13402 | if (error_found) | |
13403 | { | |
13404 | /* We don't want further evaluation of this bogus array creation | |
13405 | operation */ | |
13406 | TREE_TYPE (node) = error_mark_node; | |
13407 | return error_mark_node; | |
13408 | } | |
13409 | ||
12472854 PB |
13410 | /* Set array_type to the actual (promoted) array type of the result. */ |
13411 | if (TREE_CODE (type) == RECORD_TYPE) | |
13412 | type = build_pointer_type (type); | |
13413 | while (--xdims >= 0) | |
13414 | { | |
13415 | type = promote_type (build_java_array_type (type, -1)); | |
13416 | } | |
13417 | dims = nreverse (dims); | |
13418 | array_type = type; | |
13419 | for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim)) | |
13420 | { | |
13421 | type = array_type; | |
13422 | array_type = build_java_array_type (type, | |
13423 | TREE_CODE (cdim) == INTEGER_CST ? | |
13424 | TREE_INT_CST_LOW (cdim) : -1); | |
13425 | array_type = promote_type (array_type); | |
13426 | } | |
13427 | dims = nreverse (dims); | |
13428 | ||
8b27f225 PB |
13429 | /* The node is transformed into a function call. Things are done |
13430 | differently according to the number of dimensions. If the number | |
13431 | of dimension is equal to 1, then the nature of the base type | |
13432 | (primitive or not) matters. */ | |
12472854 | 13433 | if (ndims == 1) |
63a212ed | 13434 | return build_new_array (type, TREE_VALUE (dims)); |
8b27f225 | 13435 | |
8b27f225 PB |
13436 | /* Can't reuse what's already written in expr.c because it uses the |
13437 | JVM stack representation. Provide a build_multianewarray. FIXME */ | |
12472854 | 13438 | return build (CALL_EXPR, array_type, |
8b27f225 | 13439 | build_address_of (soft_multianewarray_node), |
12472854 | 13440 | tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)), |
8b27f225 | 13441 | tree_cons (NULL_TREE, |
12472854 | 13442 | build_int_2 (ndims, 0), dims )), |
8b27f225 PB |
13443 | NULL_TREE); |
13444 | } | |
13445 | ||
f8976021 APB |
13446 | /* 10.6 Array initializer. */ |
13447 | ||
13448 | /* Build a wfl for array element that don't have one, so we can | |
13449 | pin-point errors. */ | |
13450 | ||
13451 | static tree | |
13452 | maybe_build_array_element_wfl (node) | |
13453 | tree node; | |
13454 | { | |
13455 | if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION) | |
13456 | return build_expr_wfl (NULL_TREE, ctxp->filename, | |
13457 | ctxp->elc.line, ctxp->elc.prev_col); | |
13458 | else | |
13459 | return NULL_TREE; | |
13460 | } | |
13461 | ||
13462 | /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes | |
13463 | identification of initialized arrays easier to detect during walk | |
13464 | and expansion. */ | |
13465 | ||
13466 | static tree | |
13467 | build_new_array_init (location, values) | |
13468 | int location; | |
13469 | tree values; | |
13470 | { | |
13471 | tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values); | |
13472 | tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor); | |
5bba4807 | 13473 | EXPR_WFL_LINECOL (to_return) = location; |
f8976021 APB |
13474 | return to_return; |
13475 | } | |
13476 | ||
13477 | /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error | |
13478 | occurred. Otherwise return NODE after having set its type | |
13479 | appropriately. */ | |
13480 | ||
13481 | static tree | |
13482 | patch_new_array_init (type, node) | |
13483 | tree type, node; | |
f8976021 APB |
13484 | { |
13485 | int error_seen = 0; | |
63a212ed | 13486 | tree current, element_type; |
f8976021 | 13487 | HOST_WIDE_INT length; |
63a212ed PB |
13488 | int all_constant = 1; |
13489 | tree init = TREE_OPERAND (node, 0); | |
f8976021 | 13490 | |
63a212ed PB |
13491 | if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type))) |
13492 | { | |
13493 | parse_error_context (node, | |
13494 | "Invalid array initializer for non-array type `%s'", | |
13495 | lang_printable_name (type, 1)); | |
13496 | return error_mark_node; | |
13497 | } | |
13498 | type = TREE_TYPE (type); | |
13499 | element_type = TYPE_ARRAY_ELEMENT (type); | |
13500 | ||
13501 | CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init)); | |
f8976021 | 13502 | |
63a212ed PB |
13503 | for (length = 0, current = CONSTRUCTOR_ELTS (init); |
13504 | current; length++, current = TREE_CHAIN (current)) | |
f8976021 | 13505 | { |
63a212ed PB |
13506 | tree elt = TREE_VALUE (current); |
13507 | if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT) | |
f8976021 | 13508 | { |
63a212ed | 13509 | error_seen |= array_constructor_check_entry (element_type, current); |
5bba4807 PB |
13510 | elt = TREE_VALUE (current); |
13511 | /* When compiling to native code, STRING_CST is converted to | |
13512 | INDIRECT_REF, but still with a TREE_CONSTANT flag. */ | |
13513 | if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF) | |
63a212ed | 13514 | all_constant = 0; |
f8976021 | 13515 | } |
63a212ed PB |
13516 | else |
13517 | { | |
13518 | TREE_VALUE (current) = patch_new_array_init (element_type, elt); | |
13519 | TREE_PURPOSE (current) = NULL_TREE; | |
13520 | all_constant = 0; | |
13521 | } | |
13522 | if (elt && TREE_VALUE (elt) == error_mark_node) | |
13523 | error_seen = 1; | |
f8976021 APB |
13524 | } |
13525 | ||
13526 | if (error_seen) | |
13527 | return error_mark_node; | |
13528 | ||
13529 | /* Create a new type. We can't reuse the one we have here by | |
13530 | patching its dimension because it originally is of dimension -1 | |
13531 | hence reused by gcc. This would prevent triangular arrays. */ | |
63a212ed PB |
13532 | type = build_java_array_type (element_type, length); |
13533 | TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type)))); | |
13534 | TREE_TYPE (node) = promote_type (type); | |
13535 | TREE_CONSTANT (init) = all_constant; | |
bc3ca41b | 13536 | TREE_CONSTANT (node) = all_constant; |
f8976021 APB |
13537 | return node; |
13538 | } | |
13539 | ||
13540 | /* Verify that one entry of the initializer element list can be | |
13541 | assigned to the array base type. Report 1 if an error occurred, 0 | |
13542 | otherwise. */ | |
13543 | ||
13544 | static int | |
13545 | array_constructor_check_entry (type, entry) | |
13546 | tree type, entry; | |
13547 | { | |
13548 | char *array_type_string = NULL; /* For error reports */ | |
13549 | tree value, type_value, new_value, wfl_value, patched; | |
13550 | int error_seen = 0; | |
13551 | ||
13552 | new_value = NULL_TREE; | |
13553 | wfl_value = TREE_VALUE (entry); | |
13554 | ||
100f7cd8 | 13555 | push_obstacks (&permanent_obstack, &permanent_obstack); |
f8976021 | 13556 | value = java_complete_tree (TREE_VALUE (entry)); |
1179ebc2 | 13557 | /* patch_string return error_mark_node if arg is error_mark_node */ |
f8976021 APB |
13558 | if ((patched = patch_string (value))) |
13559 | value = patched; | |
1179ebc2 APB |
13560 | if (value == error_mark_node) |
13561 | return 1; | |
f8976021 | 13562 | |
f8976021 APB |
13563 | type_value = TREE_TYPE (value); |
13564 | ||
1179ebc2 | 13565 | /* At anytime, try_builtin_assignconv can report a warning on |
f8976021 APB |
13566 | constant overflow during narrowing. */ |
13567 | SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value); | |
13568 | new_value = try_builtin_assignconv (wfl_operator, type, value); | |
13569 | if (!new_value && (new_value = try_reference_assignconv (type, value))) | |
13570 | type_value = promote_type (type); | |
100f7cd8 APB |
13571 | |
13572 | pop_obstacks (); | |
f8976021 APB |
13573 | /* Check and report errors */ |
13574 | if (!new_value) | |
13575 | { | |
49f48c71 | 13576 | const char *msg = (!valid_cast_to_p (type_value, type) ? |
f8976021 APB |
13577 | "Can't" : "Explicit cast needed to"); |
13578 | if (!array_type_string) | |
c2e3db92 | 13579 | array_type_string = xstrdup (lang_printable_name (type, 1)); |
f8976021 APB |
13580 | parse_error_context |
13581 | (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'", | |
13582 | msg, lang_printable_name (type_value, 1), array_type_string); | |
13583 | error_seen = 1; | |
13584 | } | |
13585 | ||
13586 | if (new_value) | |
13587 | { | |
13588 | new_value = maybe_build_primttype_type_ref (new_value, wfl_operator); | |
13589 | TREE_VALUE (entry) = new_value; | |
13590 | } | |
13591 | ||
13592 | if (array_type_string) | |
13593 | free (array_type_string); | |
1179ebc2 APB |
13594 | |
13595 | TREE_PURPOSE (entry) = NULL_TREE; | |
f8976021 APB |
13596 | return error_seen; |
13597 | } | |
13598 | ||
8b27f225 PB |
13599 | static tree |
13600 | build_this (location) | |
13601 | int location; | |
13602 | { | |
9ee9b555 | 13603 | tree node = build_wfl_node (this_identifier_node); |
8b27f225 PB |
13604 | TREE_SET_CODE (node, THIS_EXPR); |
13605 | EXPR_WFL_LINECOL (node) = location; | |
13606 | return node; | |
13607 | } | |
13608 | ||
13609 | /* 14.15 The return statement. It builds a modify expression that | |
13610 | assigns the returned value to the RESULT_DECL that hold the value | |
13611 | to be returned. */ | |
13612 | ||
13613 | static tree | |
13614 | build_return (location, op) | |
13615 | int location; | |
13616 | tree op; | |
13617 | { | |
13618 | tree node = build1 (RETURN_EXPR, NULL_TREE, op); | |
13619 | EXPR_WFL_LINECOL (node) = location; | |
13620 | node = build_debugable_stmt (location, node); | |
13621 | return node; | |
13622 | } | |
13623 | ||
13624 | static tree | |
13625 | patch_return (node) | |
13626 | tree node; | |
13627 | { | |
13628 | tree return_exp = TREE_OPERAND (node, 0); | |
13629 | tree meth = current_function_decl; | |
13630 | tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl)); | |
8b27f225 PB |
13631 | int error_found = 0; |
13632 | ||
13633 | TREE_TYPE (node) = error_mark_node; | |
13634 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
13635 | ||
13636 | /* It's invalid to have a return value within a function that is | |
13637 | declared with the keyword void or that is a constructor */ | |
13638 | if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth))) | |
13639 | error_found = 1; | |
13640 | ||
f099f336 | 13641 | /* It's invalid to use a return statement in a static block */ |
7f1d4866 | 13642 | if (IS_CLINIT (current_function_decl)) |
f099f336 APB |
13643 | error_found = 1; |
13644 | ||
8b27f225 PB |
13645 | /* It's invalid to have a no return value within a function that |
13646 | isn't declared with the keyword `void' */ | |
13647 | if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth))) | |
13648 | error_found = 2; | |
13649 | ||
13650 | if (error_found) | |
13651 | { | |
7f1d4866 | 13652 | if (IS_CLINIT (current_function_decl)) |
f099f336 APB |
13653 | parse_error_context (wfl_operator, |
13654 | "`return' inside static initializer."); | |
13655 | ||
13656 | else if (!DECL_CONSTRUCTOR_P (meth)) | |
22eed1e6 | 13657 | { |
c2e3db92 | 13658 | char *t = xstrdup (lang_printable_name (mtype, 0)); |
22eed1e6 APB |
13659 | parse_error_context (wfl_operator, |
13660 | "`return' with%s value from `%s %s'", | |
13661 | (error_found == 1 ? "" : "out"), | |
13662 | t, lang_printable_name (meth, 0)); | |
13663 | free (t); | |
13664 | } | |
13665 | else | |
13666 | parse_error_context (wfl_operator, | |
13667 | "`return' with value from constructor `%s'", | |
13668 | lang_printable_name (meth, 0)); | |
8b27f225 PB |
13669 | return error_mark_node; |
13670 | } | |
13671 | ||
5e942c50 APB |
13672 | /* If we have a return_exp, build a modify expression and expand |
13673 | it. Note: at that point, the assignment is declared valid, but we | |
13674 | may want to carry some more hacks */ | |
8b27f225 PB |
13675 | if (return_exp) |
13676 | { | |
5e942c50 APB |
13677 | tree exp = java_complete_tree (return_exp); |
13678 | tree modify, patched; | |
13679 | ||
13680 | /* If the function returned value and EXP are booleans, EXP has | |
13681 | to be converted into the type of DECL_RESULT, which is integer | |
13682 | (see complete_start_java_method) */ | |
13683 | if (TREE_TYPE (exp) == boolean_type_node && | |
13684 | TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node) | |
13685 | exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp); | |
13686 | ||
13687 | /* `null' can be assigned to a function returning a reference */ | |
13688 | if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) && | |
13689 | exp == null_pointer_node) | |
13690 | exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth))); | |
13691 | ||
13692 | if ((patched = patch_string (exp))) | |
13693 | exp = patched; | |
13694 | ||
13695 | modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp); | |
8b27f225 PB |
13696 | EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node); |
13697 | modify = java_complete_tree (modify); | |
5e942c50 | 13698 | |
8b27f225 PB |
13699 | if (modify != error_mark_node) |
13700 | { | |
13701 | TREE_SIDE_EFFECTS (modify) = 1; | |
13702 | TREE_OPERAND (node, 0) = modify; | |
13703 | } | |
13704 | else | |
13705 | return error_mark_node; | |
13706 | } | |
13707 | TREE_TYPE (node) = void_type_node; | |
13708 | TREE_SIDE_EFFECTS (node) = 1; | |
13709 | return node; | |
13710 | } | |
13711 | ||
13712 | /* 14.8 The if Statement */ | |
13713 | ||
13714 | static tree | |
13715 | build_if_else_statement (location, expression, if_body, else_body) | |
13716 | int location; | |
13717 | tree expression, if_body, else_body; | |
13718 | { | |
13719 | tree node; | |
8b27f225 | 13720 | if (!else_body) |
c877974e | 13721 | else_body = empty_stmt_node; |
8b27f225 PB |
13722 | node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body); |
13723 | EXPR_WFL_LINECOL (node) = location; | |
13724 | node = build_debugable_stmt (location, node); | |
13725 | return node; | |
13726 | } | |
13727 | ||
13728 | static tree | |
13729 | patch_if_else_statement (node) | |
13730 | tree node; | |
13731 | { | |
13732 | tree expression = TREE_OPERAND (node, 0); | |
13733 | ||
13734 | TREE_TYPE (node) = error_mark_node; | |
13735 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
13736 | ||
13737 | /* The type of expression must be boolean */ | |
13738 | if (TREE_TYPE (expression) != boolean_type_node | |
13739 | && TREE_TYPE (expression) != promoted_boolean_type_node) | |
13740 | { | |
13741 | parse_error_context | |
13742 | (wfl_operator, | |
13743 | "Incompatible type for `if'. Can't convert `%s' to `boolean'", | |
13744 | lang_printable_name (TREE_TYPE (expression), 0)); | |
13745 | return error_mark_node; | |
13746 | } | |
13747 | ||
13748 | TREE_TYPE (node) = void_type_node; | |
13749 | TREE_SIDE_EFFECTS (node) = 1; | |
12472854 | 13750 | CAN_COMPLETE_NORMALLY (node) |
c877974e APB |
13751 | = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)) |
13752 | | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2)); | |
8b27f225 PB |
13753 | return node; |
13754 | } | |
13755 | ||
13756 | /* 14.6 Labeled Statements */ | |
13757 | ||
13758 | /* Action taken when a lableled statement is parsed. a new | |
13759 | LABELED_BLOCK_EXPR is created. No statement is attached to the | |
e85ac860 | 13760 | label, yet. LABEL can be NULL_TREE for artificially-generated blocks. */ |
8b27f225 PB |
13761 | |
13762 | static tree | |
13763 | build_labeled_block (location, label) | |
13764 | int location; | |
13765 | tree label; | |
13766 | { | |
e85ac860 | 13767 | tree label_name ; |
8b27f225 | 13768 | tree label_decl, node; |
e85ac860 PB |
13769 | if (label == NULL_TREE || label == continue_identifier_node) |
13770 | label_name = label; | |
13771 | else | |
8b27f225 | 13772 | { |
e85ac860 PB |
13773 | label_name = merge_qualified_name (label_id, label); |
13774 | /* Issue an error if we try to reuse a label that was previously | |
13775 | declared */ | |
13776 | if (IDENTIFIER_LOCAL_VALUE (label_name)) | |
13777 | { | |
13778 | EXPR_WFL_LINECOL (wfl_operator) = location; | |
781b0558 KG |
13779 | parse_error_context (wfl_operator, |
13780 | "Declaration of `%s' shadows a previous label declaration", | |
e85ac860 PB |
13781 | IDENTIFIER_POINTER (label)); |
13782 | EXPR_WFL_LINECOL (wfl_operator) = | |
13783 | EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name)); | |
781b0558 KG |
13784 | parse_error_context (wfl_operator, |
13785 | "This is the location of the previous declaration of label `%s'", | |
e85ac860 PB |
13786 | IDENTIFIER_POINTER (label)); |
13787 | java_error_count--; | |
13788 | } | |
8b27f225 PB |
13789 | } |
13790 | ||
13791 | label_decl = create_label_decl (label_name); | |
13792 | node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE); | |
13793 | EXPR_WFL_LINECOL (node) = location; | |
13794 | TREE_SIDE_EFFECTS (node) = 1; | |
13795 | return node; | |
13796 | } | |
13797 | ||
8b27f225 PB |
13798 | /* A labeled statement LBE is attached a statement. */ |
13799 | ||
13800 | static tree | |
e85ac860 | 13801 | finish_labeled_statement (lbe, statement) |
8b27f225 PB |
13802 | tree lbe; /* Labeled block expr */ |
13803 | tree statement; | |
13804 | { | |
13805 | /* In anyways, tie the loop to its statement */ | |
13806 | LABELED_BLOCK_BODY (lbe) = statement; | |
e85ac860 PB |
13807 | pop_labeled_block (); |
13808 | POP_LABELED_BLOCK (); | |
8b27f225 PB |
13809 | return lbe; |
13810 | } | |
13811 | ||
13812 | /* 14.10, 14.11, 14.12 Loop Statements */ | |
13813 | ||
13814 | /* Create an empty LOOP_EXPR and make it the last in the nested loop | |
13815 | list. */ | |
13816 | ||
13817 | static tree | |
13818 | build_new_loop (loop_body) | |
13819 | tree loop_body; | |
13820 | { | |
13821 | tree loop = build (LOOP_EXPR, NULL_TREE, loop_body); | |
13822 | TREE_SIDE_EFFECTS (loop) = 1; | |
13823 | PUSH_LOOP (loop); | |
13824 | return loop; | |
13825 | } | |
13826 | ||
13827 | /* Create a loop body according to the following structure: | |
13828 | COMPOUND_EXPR | |
13829 | COMPOUND_EXPR (loop main body) | |
13830 | EXIT_EXPR (this order is for while/for loops. | |
13831 | LABELED_BLOCK_EXPR the order is reversed for do loops) | |
34f4db93 | 13832 | LABEL_DECL (a continue occuring here branches at the |
8b27f225 PB |
13833 | BODY end of this labeled block) |
13834 | INCREMENT (if any) | |
13835 | ||
13836 | REVERSED, if non zero, tells that the loop condition expr comes | |
13837 | after the body, like in the do-while loop. | |
13838 | ||
13839 | To obtain a loop, the loop body structure described above is | |
13840 | encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR: | |
13841 | ||
13842 | LABELED_BLOCK_EXPR | |
13843 | LABEL_DECL (use this label to exit the loop) | |
13844 | LOOP_EXPR | |
13845 | <structure described above> */ | |
13846 | ||
13847 | static tree | |
13848 | build_loop_body (location, condition, reversed) | |
13849 | int location; | |
13850 | tree condition; | |
13851 | int reversed; | |
13852 | { | |
13853 | tree first, second, body; | |
13854 | ||
13855 | condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */ | |
13856 | EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */ | |
13857 | condition = build_debugable_stmt (location, condition); | |
13858 | TREE_SIDE_EFFECTS (condition) = 1; | |
13859 | ||
e85ac860 | 13860 | body = build_labeled_block (0, continue_identifier_node); |
8b27f225 PB |
13861 | first = (reversed ? body : condition); |
13862 | second = (reversed ? condition : body); | |
13863 | return | |
13864 | build (COMPOUND_EXPR, NULL_TREE, | |
c877974e | 13865 | build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node); |
8b27f225 PB |
13866 | } |
13867 | ||
13868 | /* Install CONDITION (if any) and loop BODY (using REVERSED to tell | |
13869 | their order) on the current loop. Unlink the current loop from the | |
13870 | loop list. */ | |
13871 | ||
13872 | static tree | |
e85ac860 | 13873 | finish_loop_body (location, condition, body, reversed) |
8b27f225 PB |
13874 | int location; |
13875 | tree condition, body; | |
13876 | int reversed; | |
13877 | { | |
13878 | tree to_return = ctxp->current_loop; | |
13879 | tree loop_body = LOOP_EXPR_BODY (to_return); | |
13880 | if (condition) | |
13881 | { | |
13882 | tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed); | |
13883 | /* We wrapped the EXIT_EXPR around a WFL so we can debug it. | |
13884 | The real EXIT_EXPR is one operand further. */ | |
13885 | EXPR_WFL_LINECOL (cnode) = location; | |
13886 | /* This one is for accurate error reports */ | |
13887 | EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location; | |
13888 | TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition; | |
13889 | } | |
13890 | LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body; | |
13891 | POP_LOOP (); | |
13892 | return to_return; | |
13893 | } | |
13894 | ||
e85ac860 | 13895 | /* Tailored version of finish_loop_body for FOR loops, when FOR |
8b27f225 PB |
13896 | loops feature the condition part */ |
13897 | ||
13898 | static tree | |
e85ac860 | 13899 | finish_for_loop (location, condition, update, body) |
8b27f225 PB |
13900 | int location; |
13901 | tree condition, update, body; | |
13902 | { | |
13903 | /* Put the condition and the loop body in place */ | |
e85ac860 | 13904 | tree loop = finish_loop_body (location, condition, body, 0); |
8b27f225 PB |
13905 | /* LOOP is the current loop which has been now popped of the loop |
13906 | stack. Install the update block */ | |
13907 | LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update; | |
13908 | return loop; | |
13909 | } | |
13910 | ||
5cbdba64 APB |
13911 | /* Try to find the loop a block might be related to. This comprises |
13912 | the case where the LOOP_EXPR is found as the second operand of a | |
13913 | COMPOUND_EXPR, because the loop happens to have an initialization | |
13914 | part, then expressed as the first operand of the COMPOUND_EXPR. If | |
13915 | the search finds something, 1 is returned. Otherwise, 0 is | |
13916 | returned. The search is assumed to start from a | |
13917 | LABELED_BLOCK_EXPR's block. */ | |
13918 | ||
13919 | static tree | |
13920 | search_loop (statement) | |
13921 | tree statement; | |
13922 | { | |
13923 | if (TREE_CODE (statement) == LOOP_EXPR) | |
13924 | return statement; | |
13925 | ||
13926 | if (TREE_CODE (statement) == BLOCK) | |
13927 | statement = BLOCK_SUBBLOCKS (statement); | |
13928 | else | |
13929 | return NULL_TREE; | |
13930 | ||
13931 | if (statement && TREE_CODE (statement) == COMPOUND_EXPR) | |
13932 | while (statement && TREE_CODE (statement) == COMPOUND_EXPR) | |
13933 | statement = TREE_OPERAND (statement, 1); | |
13934 | ||
13935 | return (TREE_CODE (statement) == LOOP_EXPR | |
13936 | && IS_FOR_LOOP_P (statement) ? statement : NULL_TREE); | |
13937 | } | |
13938 | ||
13939 | /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is | |
13940 | returned otherwise. */ | |
13941 | ||
13942 | static int | |
13943 | labeled_block_contains_loop_p (block, loop) | |
13944 | tree block, loop; | |
13945 | { | |
13946 | if (!block) | |
13947 | return 0; | |
13948 | ||
13949 | if (LABELED_BLOCK_BODY (block) == loop) | |
13950 | return 1; | |
13951 | ||
13952 | if (IS_FOR_LOOP_P (loop) | |
13953 | && search_loop (LABELED_BLOCK_BODY (block)) == loop) | |
13954 | return 1; | |
13955 | ||
13956 | return 0; | |
13957 | } | |
13958 | ||
8b27f225 | 13959 | /* If the loop isn't surrounded by a labeled statement, create one and |
e85ac860 | 13960 | insert LOOP as its body. */ |
8b27f225 PB |
13961 | |
13962 | static tree | |
13963 | patch_loop_statement (loop) | |
13964 | tree loop; | |
13965 | { | |
cd9643f7 | 13966 | tree loop_label; |
5cbdba64 | 13967 | |
cd9643f7 | 13968 | TREE_TYPE (loop) = void_type_node; |
5cbdba64 APB |
13969 | if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop)) |
13970 | return loop; | |
13971 | ||
cd9643f7 | 13972 | loop_label = build_labeled_block (0, NULL_TREE); |
5cbdba64 APB |
13973 | /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL |
13974 | that LOOP_LABEL could enquire about, for a better accuracy. FIXME */ | |
cd9643f7 PB |
13975 | LABELED_BLOCK_BODY (loop_label) = loop; |
13976 | PUSH_LABELED_BLOCK (loop_label); | |
5cbdba64 | 13977 | return loop_label; |
8b27f225 PB |
13978 | } |
13979 | ||
13980 | /* 14.13, 14.14: break and continue Statements */ | |
13981 | ||
13982 | /* Build a break or a continue statement. a null NAME indicates an | |
13983 | unlabeled break/continue statement. */ | |
13984 | ||
13985 | static tree | |
13986 | build_bc_statement (location, is_break, name) | |
13987 | int location, is_break; | |
13988 | tree name; | |
13989 | { | |
13990 | tree break_continue, label_block_expr = NULL_TREE; | |
13991 | ||
13992 | if (name) | |
13993 | { | |
13994 | if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE | |
13995 | (merge_qualified_name (label_id, EXPR_WFL_NODE (name))))) | |
13996 | /* Null means that we don't have a target for this named | |
13997 | break/continue. In this case, we make the target to be the | |
13998 | label name, so that the error can be reported accuratly in | |
13999 | patch_bc_statement. */ | |
14000 | label_block_expr = EXPR_WFL_NODE (name); | |
14001 | } | |
14002 | /* Unlabeled break/continue will be handled during the | |
14003 | break/continue patch operation */ | |
14004 | break_continue | |
14005 | = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE); | |
14006 | ||
14007 | IS_BREAK_STMT_P (break_continue) = is_break; | |
14008 | TREE_SIDE_EFFECTS (break_continue) = 1; | |
14009 | EXPR_WFL_LINECOL (break_continue) = location; | |
14010 | break_continue = build_debugable_stmt (location, break_continue); | |
14011 | return break_continue; | |
14012 | } | |
14013 | ||
14014 | /* Verification of a break/continue statement. */ | |
14015 | ||
14016 | static tree | |
14017 | patch_bc_statement (node) | |
14018 | tree node; | |
14019 | { | |
14020 | tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt; | |
e85ac860 | 14021 | tree labeled_block = ctxp->current_labeled_block; |
8b27f225 PB |
14022 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); |
14023 | ||
8b27f225 | 14024 | /* Having an identifier here means that the target is unknown. */ |
e85ac860 | 14025 | if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE) |
8b27f225 PB |
14026 | { |
14027 | parse_error_context (wfl_operator, "No label definition found for `%s'", | |
14028 | IDENTIFIER_POINTER (bc_label)); | |
14029 | return error_mark_node; | |
14030 | } | |
e85ac860 | 14031 | if (! IS_BREAK_STMT_P (node)) |
8b27f225 | 14032 | { |
e85ac860 PB |
14033 | /* It's a continue statement. */ |
14034 | for (;; labeled_block = TREE_CHAIN (labeled_block)) | |
8b27f225 | 14035 | { |
e85ac860 PB |
14036 | if (labeled_block == NULL_TREE) |
14037 | { | |
14038 | if (bc_label == NULL_TREE) | |
14039 | parse_error_context (wfl_operator, | |
14040 | "`continue' must be in loop"); | |
14041 | else | |
1504b2b4 APB |
14042 | parse_error_context |
14043 | (wfl_operator, "continue label `%s' does not name a loop", | |
14044 | IDENTIFIER_POINTER (bc_label)); | |
e85ac860 PB |
14045 | return error_mark_node; |
14046 | } | |
14047 | if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block)) | |
14048 | == continue_identifier_node) | |
14049 | && (bc_label == NULL_TREE | |
14050 | || TREE_CHAIN (labeled_block) == bc_label)) | |
14051 | { | |
14052 | bc_label = labeled_block; | |
14053 | break; | |
14054 | } | |
8b27f225 | 14055 | } |
8b27f225 | 14056 | } |
e85ac860 | 14057 | else if (!bc_label) |
34f4db93 | 14058 | { |
e85ac860 | 14059 | for (;; labeled_block = TREE_CHAIN (labeled_block)) |
8b27f225 | 14060 | { |
e85ac860 PB |
14061 | if (labeled_block == NULL_TREE) |
14062 | { | |
14063 | parse_error_context (wfl_operator, | |
14064 | "`break' must be in loop or switch"); | |
14065 | return error_mark_node; | |
14066 | } | |
14067 | target_stmt = LABELED_BLOCK_BODY (labeled_block); | |
14068 | if (TREE_CODE (target_stmt) == SWITCH_EXPR | |
5cbdba64 | 14069 | || search_loop (target_stmt)) |
e85ac860 PB |
14070 | { |
14071 | bc_label = labeled_block; | |
14072 | break; | |
14073 | } | |
8b27f225 | 14074 | } |
8b27f225 PB |
14075 | } |
14076 | ||
e85ac860 | 14077 | EXIT_BLOCK_LABELED_BLOCK (node) = bc_label; |
12472854 PB |
14078 | CAN_COMPLETE_NORMALLY (bc_label) = 1; |
14079 | ||
8b27f225 PB |
14080 | /* Our break/continue don't return values. */ |
14081 | TREE_TYPE (node) = void_type_node; | |
14082 | /* Encapsulate the break within a compound statement so that it's | |
5cbdba64 | 14083 | expanded all the times by expand_expr (and not clobbered |
8b27f225 PB |
14084 | sometimes, like after a if statement) */ |
14085 | node = add_stmt_to_compound (NULL_TREE, void_type_node, node); | |
14086 | TREE_SIDE_EFFECTS (node) = 1; | |
14087 | return node; | |
14088 | } | |
14089 | ||
14090 | /* Process the exit expression belonging to a loop. Its type must be | |
14091 | boolean. */ | |
14092 | ||
14093 | static tree | |
14094 | patch_exit_expr (node) | |
14095 | tree node; | |
14096 | { | |
14097 | tree expression = TREE_OPERAND (node, 0); | |
14098 | TREE_TYPE (node) = error_mark_node; | |
14099 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
14100 | ||
14101 | /* The type of expression must be boolean */ | |
14102 | if (TREE_TYPE (expression) != boolean_type_node) | |
14103 | { | |
14104 | parse_error_context | |
14105 | (wfl_operator, | |
781b0558 | 14106 | "Incompatible type for loop conditional. Can't convert `%s' to `boolean'", |
8b27f225 PB |
14107 | lang_printable_name (TREE_TYPE (expression), 0)); |
14108 | return error_mark_node; | |
14109 | } | |
14110 | /* Now we know things are allright, invert the condition, fold and | |
14111 | return */ | |
14112 | TREE_OPERAND (node, 0) = | |
14113 | fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression)); | |
12472854 PB |
14114 | |
14115 | if (! integer_zerop (TREE_OPERAND (node, 0)) | |
14116 | && ctxp->current_loop != NULL_TREE | |
14117 | && TREE_CODE (ctxp->current_loop) == LOOP_EXPR) | |
14118 | CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1; | |
14119 | if (! integer_onep (TREE_OPERAND (node, 0))) | |
14120 | CAN_COMPLETE_NORMALLY (node) = 1; | |
14121 | ||
14122 | ||
8b27f225 PB |
14123 | TREE_TYPE (node) = void_type_node; |
14124 | return node; | |
14125 | } | |
14126 | ||
14127 | /* 14.9 Switch statement */ | |
14128 | ||
14129 | static tree | |
14130 | patch_switch_statement (node) | |
14131 | tree node; | |
14132 | { | |
c877974e | 14133 | tree se = TREE_OPERAND (node, 0), se_type; |
8b27f225 PB |
14134 | |
14135 | /* Complete the switch expression */ | |
14136 | se = TREE_OPERAND (node, 0) = java_complete_tree (se); | |
14137 | se_type = TREE_TYPE (se); | |
14138 | /* The type of the switch expression must be char, byte, short or | |
14139 | int */ | |
14140 | if (!JINTEGRAL_TYPE_P (se_type)) | |
14141 | { | |
14142 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); | |
781b0558 KG |
14143 | parse_error_context (wfl_operator, |
14144 | "Incompatible type for `switch'. Can't convert `%s' to `int'", | |
8b27f225 PB |
14145 | lang_printable_name (se_type, 0)); |
14146 | /* This is what java_complete_tree will check */ | |
14147 | TREE_OPERAND (node, 0) = error_mark_node; | |
14148 | return error_mark_node; | |
14149 | } | |
14150 | ||
12472854 | 14151 | TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1)); |
8b27f225 PB |
14152 | |
14153 | /* Ready to return */ | |
12472854 | 14154 | if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK) |
8b27f225 PB |
14155 | { |
14156 | TREE_TYPE (node) = error_mark_node; | |
14157 | return error_mark_node; | |
14158 | } | |
14159 | TREE_TYPE (node) = void_type_node; | |
14160 | TREE_SIDE_EFFECTS (node) = 1; | |
12472854 | 14161 | CAN_COMPLETE_NORMALLY (node) |
c877974e APB |
14162 | = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)) |
14163 | || ! SWITCH_HAS_DEFAULT (node); | |
8b27f225 PB |
14164 | return node; |
14165 | } | |
14166 | ||
8b27f225 PB |
14167 | /* 14.18 The try statement */ |
14168 | ||
8b27f225 | 14169 | static tree |
a7d8d81f | 14170 | build_try_statement (location, try_block, catches) |
8b27f225 | 14171 | int location; |
a7d8d81f PB |
14172 | tree try_block, catches; |
14173 | { | |
14174 | tree node = build (TRY_EXPR, NULL_TREE, try_block, catches); | |
8b27f225 | 14175 | EXPR_WFL_LINECOL (node) = location; |
a7d8d81f | 14176 | return node; |
8b27f225 PB |
14177 | } |
14178 | ||
a7d8d81f PB |
14179 | static tree |
14180 | build_try_finally_statement (location, try_block, finally) | |
14181 | int location; | |
14182 | tree try_block, finally; | |
8b27f225 | 14183 | { |
a7d8d81f PB |
14184 | tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally); |
14185 | EXPR_WFL_LINECOL (node) = location; | |
14186 | return node; | |
8b27f225 PB |
14187 | } |
14188 | ||
14189 | static tree | |
14190 | patch_try_statement (node) | |
14191 | tree node; | |
14192 | { | |
14193 | int error_found = 0; | |
14194 | tree try = TREE_OPERAND (node, 0); | |
14195 | /* Exception handlers are considered in left to right order */ | |
14196 | tree catch = nreverse (TREE_OPERAND (node, 1)); | |
8b27f225 PB |
14197 | tree current, caught_type_list = NULL_TREE; |
14198 | ||
14199 | /* Check catch clauses, if any. Every time we find an error, we try | |
14200 | to process the next catch clause. We process the catch clause before | |
14201 | the try block so that when processing the try block we can check thrown | |
14202 | exceptions againts the caught type list. */ | |
14203 | for (current = catch; current; current = TREE_CHAIN (current)) | |
14204 | { | |
14205 | tree carg_decl, carg_type; | |
14206 | tree sub_current, catch_block, catch_clause; | |
14207 | int unreachable; | |
14208 | ||
8b27f225 | 14209 | /* At this point, the structure of the catch clause is |
8b27f225 PB |
14210 | CATCH_EXPR (catch node) |
14211 | BLOCK (with the decl of the parameter) | |
14212 | COMPOUND_EXPR | |
63a212ed | 14213 | MODIFY_EXPR (assignment of the catch parameter) |
8b27f225 | 14214 | BLOCK (catch clause block) |
a7d8d81f PB |
14215 | */ |
14216 | catch_clause = TREE_OPERAND (current, 0); | |
8b27f225 PB |
14217 | carg_decl = BLOCK_EXPR_DECLS (catch_clause); |
14218 | carg_type = TREE_TYPE (TREE_TYPE (carg_decl)); | |
14219 | ||
14220 | /* Catch clauses can't have more than one parameter declared, | |
14221 | but it's already enforced by the grammar. Make sure that the | |
14222 | only parameter of the clause statement in of class Throwable | |
14223 | or a subclass of Throwable, but that was done earlier. The | |
14224 | catch clause parameter type has also been resolved. */ | |
14225 | ||
14226 | /* Just make sure that the catch clause parameter type inherits | |
14227 | from java.lang.Throwable */ | |
14228 | if (!inherits_from_p (carg_type, throwable_type_node)) | |
14229 | { | |
14230 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current); | |
14231 | parse_error_context (wfl_operator, | |
781b0558 | 14232 | "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'", |
8b27f225 PB |
14233 | lang_printable_name (carg_type, 0)); |
14234 | error_found = 1; | |
14235 | continue; | |
14236 | } | |
14237 | ||
14238 | /* Partial check for unreachable catch statement: The catch | |
14239 | clause is reachable iff is no earlier catch block A in | |
14240 | the try statement such that the type of the catch | |
14241 | clause's parameter is the same as or a subclass of the | |
14242 | type of A's parameter */ | |
14243 | unreachable = 0; | |
14244 | for (sub_current = catch; | |
14245 | sub_current != current; sub_current = TREE_CHAIN (sub_current)) | |
14246 | { | |
14247 | tree sub_catch_clause, decl; | |
a7d8d81f | 14248 | sub_catch_clause = TREE_OPERAND (sub_current, 0); |
8b27f225 PB |
14249 | decl = BLOCK_EXPR_DECLS (sub_catch_clause); |
14250 | ||
14251 | if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl)))) | |
14252 | { | |
14253 | EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current); | |
14254 | parse_error_context | |
781b0558 KG |
14255 | (wfl_operator, |
14256 | "`catch' not reached because of the catch clause at line %d", | |
14257 | EXPR_WFL_LINENO (sub_current)); | |
8b27f225 PB |
14258 | unreachable = error_found = 1; |
14259 | break; | |
14260 | } | |
14261 | } | |
8b27f225 PB |
14262 | /* Complete the catch clause block */ |
14263 | catch_block = java_complete_tree (TREE_OPERAND (current, 0)); | |
14264 | if (catch_block == error_mark_node) | |
14265 | { | |
14266 | error_found = 1; | |
14267 | continue; | |
14268 | } | |
12472854 PB |
14269 | if (CAN_COMPLETE_NORMALLY (catch_block)) |
14270 | CAN_COMPLETE_NORMALLY (node) = 1; | |
8b27f225 | 14271 | TREE_OPERAND (current, 0) = catch_block; |
12472854 PB |
14272 | |
14273 | if (unreachable) | |
14274 | continue; | |
14275 | ||
14276 | /* Things to do here: the exception must be thrown */ | |
14277 | ||
14278 | /* Link this type to the caught type list */ | |
14279 | caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list); | |
8b27f225 PB |
14280 | } |
14281 | ||
14282 | PUSH_EXCEPTIONS (caught_type_list); | |
14283 | if ((try = java_complete_tree (try)) == error_mark_node) | |
14284 | error_found = 1; | |
12472854 PB |
14285 | if (CAN_COMPLETE_NORMALLY (try)) |
14286 | CAN_COMPLETE_NORMALLY (node) = 1; | |
8b27f225 PB |
14287 | POP_EXCEPTIONS (); |
14288 | ||
8b27f225 PB |
14289 | /* Verification ends here */ |
14290 | if (error_found) | |
14291 | return error_mark_node; | |
14292 | ||
14293 | TREE_OPERAND (node, 0) = try; | |
14294 | TREE_OPERAND (node, 1) = catch; | |
8b27f225 PB |
14295 | TREE_TYPE (node) = void_type_node; |
14296 | return node; | |
14297 | } | |
14298 | ||
14299 | /* 14.17 The synchronized Statement */ | |
14300 | ||
14301 | static tree | |
14302 | patch_synchronized_statement (node, wfl_op1) | |
14303 | tree node, wfl_op1; | |
14304 | { | |
5a005d9e | 14305 | tree expr = java_complete_tree (TREE_OPERAND (node, 0)); |
8b27f225 | 14306 | tree block = TREE_OPERAND (node, 1); |
5a005d9e | 14307 | |
d8fccff5 | 14308 | tree enter, exit, expr_decl, assignment; |
5a005d9e PB |
14309 | |
14310 | if (expr == error_mark_node) | |
14311 | { | |
14312 | block = java_complete_tree (block); | |
14313 | return expr; | |
14314 | } | |
8b27f225 PB |
14315 | |
14316 | /* The TYPE of expr must be a reference type */ | |
5a005d9e | 14317 | if (!JREFERENCE_TYPE_P (TREE_TYPE (expr))) |
8b27f225 PB |
14318 | { |
14319 | SET_WFL_OPERATOR (wfl_operator, node, wfl_op1); | |
781b0558 | 14320 | parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'", |
8b27f225 PB |
14321 | lang_printable_name (TREE_TYPE (expr), 0)); |
14322 | return error_mark_node; | |
14323 | } | |
14324 | ||
ce6e9147 APB |
14325 | if (flag_emit_xref) |
14326 | { | |
14327 | TREE_OPERAND (node, 0) = expr; | |
14328 | TREE_OPERAND (node, 1) = java_complete_tree (block); | |
14329 | CAN_COMPLETE_NORMALLY (node) = 1; | |
14330 | return node; | |
14331 | } | |
14332 | ||
8b27f225 PB |
14333 | /* Generate a try-finally for the synchronized statement, except |
14334 | that the handler that catches all throw exception calls | |
14335 | _Jv_MonitorExit and then rethrow the exception. | |
14336 | The synchronized statement is then implemented as: | |
14337 | TRY | |
14338 | { | |
14339 | _Jv_MonitorEnter (expression) | |
14340 | synchronized_block | |
14341 | _Jv_MonitorExit (expression) | |
14342 | } | |
14343 | CATCH_ALL | |
14344 | { | |
14345 | e = _Jv_exception_info (); | |
14346 | _Jv_MonitorExit (expression) | |
14347 | Throw (e); | |
14348 | } */ | |
14349 | ||
5a005d9e PB |
14350 | expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr)); |
14351 | BUILD_MONITOR_ENTER (enter, expr_decl); | |
14352 | BUILD_MONITOR_EXIT (exit, expr_decl); | |
14353 | CAN_COMPLETE_NORMALLY (enter) = 1; | |
14354 | CAN_COMPLETE_NORMALLY (exit) = 1; | |
96847892 AH |
14355 | assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr); |
14356 | TREE_SIDE_EFFECTS (assignment) = 1; | |
5a005d9e PB |
14357 | node = build1 (CLEANUP_POINT_EXPR, NULL_TREE, |
14358 | build (COMPOUND_EXPR, NULL_TREE, | |
14359 | build (WITH_CLEANUP_EXPR, NULL_TREE, | |
14360 | build (COMPOUND_EXPR, NULL_TREE, | |
96847892 | 14361 | assignment, enter), |
5a005d9e PB |
14362 | NULL_TREE, exit), |
14363 | block)); | |
14364 | node = build_expr_block (node, expr_decl); | |
14365 | ||
14366 | return java_complete_tree (node); | |
8b27f225 PB |
14367 | } |
14368 | ||
14369 | /* 14.16 The throw Statement */ | |
14370 | ||
14371 | static tree | |
14372 | patch_throw_statement (node, wfl_op1) | |
14373 | tree node, wfl_op1; | |
14374 | { | |
14375 | tree expr = TREE_OPERAND (node, 0); | |
14376 | tree type = TREE_TYPE (expr); | |
14377 | int unchecked_ok = 0, tryblock_throws_ok = 0; | |
14378 | ||
14379 | /* Thrown expression must be assignable to java.lang.Throwable */ | |
14380 | if (!try_reference_assignconv (throwable_type_node, expr)) | |
14381 | { | |
14382 | SET_WFL_OPERATOR (wfl_operator, node, wfl_op1); | |
781b0558 KG |
14383 | parse_error_context (wfl_operator, |
14384 | "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'", | |
8b27f225 PB |
14385 | lang_printable_name (type, 0)); |
14386 | /* If the thrown expression was a reference, we further the | |
14387 | compile-time check. */ | |
14388 | if (!JREFERENCE_TYPE_P (type)) | |
14389 | return error_mark_node; | |
14390 | } | |
14391 | ||
14392 | /* At least one of the following must be true */ | |
14393 | ||
14394 | /* The type of the throw expression is a not checked exception, | |
14395 | i.e. is a unchecked expression. */ | |
c877974e | 14396 | unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type)); |
8b27f225 PB |
14397 | |
14398 | /* Throw is contained in a try statement and at least one catch | |
14399 | clause can receive the thrown expression or the current method is | |
14400 | declared to throw such an exception. Or, the throw statement is | |
14401 | contained in a method or constructor declaration and the type of | |
14402 | the Expression is assignable to at least one type listed in the | |
14403 | throws clause the declaration. */ | |
14404 | SET_WFL_OPERATOR (wfl_operator, node, wfl_op1); | |
14405 | if (!unchecked_ok) | |
f099f336 | 14406 | tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr)); |
8b27f225 PB |
14407 | if (!(unchecked_ok || tryblock_throws_ok)) |
14408 | { | |
14409 | /* If there is a surrounding try block that has no matching | |
14410 | clatch clause, report it first. A surrounding try block exits | |
14411 | only if there is something after the list of checked | |
14412 | exception thrown by the current function (if any). */ | |
14413 | if (IN_TRY_BLOCK_P ()) | |
781b0558 | 14414 | parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block", |
8b27f225 PB |
14415 | lang_printable_name (type, 0)); |
14416 | /* If we have no surrounding try statement and the method doesn't have | |
14417 | any throws, report it now. FIXME */ | |
f099f336 APB |
14418 | |
14419 | /* We report that the exception can't be throw from a try block | |
14420 | in all circumstances but when the `throw' is inside a static | |
14421 | block. */ | |
8b27f225 PB |
14422 | else if (!EXCEPTIONS_P (currently_caught_type_list) |
14423 | && !tryblock_throws_ok) | |
f099f336 | 14424 | { |
7f1d4866 | 14425 | if (IS_CLINIT (current_function_decl)) |
781b0558 KG |
14426 | parse_error_context (wfl_operator, |
14427 | "Checked exception `%s' can't be thrown in initializer", | |
f099f336 APB |
14428 | lang_printable_name (type, 0)); |
14429 | else | |
781b0558 KG |
14430 | parse_error_context (wfl_operator, |
14431 | "Checked exception `%s' isn't thrown from a `try' block", | |
f099f336 APB |
14432 | lang_printable_name (type, 0)); |
14433 | } | |
8b27f225 PB |
14434 | /* Otherwise, the current method doesn't have the appropriate |
14435 | throws declaration */ | |
14436 | else | |
781b0558 | 14437 | parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)", |
8b27f225 PB |
14438 | lang_printable_name (type, 0)); |
14439 | return error_mark_node; | |
14440 | } | |
14441 | ||
ce6e9147 | 14442 | if (! flag_emit_class_files && ! flag_emit_xref) |
12472854 | 14443 | BUILD_THROW (node, expr); |
ce6e9147 APB |
14444 | |
14445 | /* If doing xrefs, keep the location where the `throw' was seen. */ | |
14446 | if (flag_emit_xref) | |
14447 | EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1); | |
8b27f225 PB |
14448 | return node; |
14449 | } | |
14450 | ||
14451 | /* Check that exception said to be thrown by method DECL can be | |
14452 | effectively caught from where DECL is invoked. */ | |
14453 | ||
14454 | static void | |
14455 | check_thrown_exceptions (location, decl) | |
14456 | int location; | |
14457 | tree decl; | |
14458 | { | |
14459 | tree throws; | |
14460 | /* For all the unchecked exceptions thrown by DECL */ | |
14461 | for (throws = DECL_FUNCTION_THROWS (decl); throws; | |
14462 | throws = TREE_CHAIN (throws)) | |
14463 | if (!check_thrown_exceptions_do (TREE_VALUE (throws))) | |
14464 | { | |
59e4a38e PB |
14465 | #if 1 |
14466 | /* Temporary hack to suppresses errors about cloning arrays. FIXME */ | |
14467 | if (DECL_NAME (decl) == get_identifier ("clone")) | |
14468 | continue; | |
14469 | #endif | |
8b27f225 | 14470 | EXPR_WFL_LINECOL (wfl_operator) = location; |
7705e9db APB |
14471 | if (DECL_NAME (current_function_decl) == finit_identifier_node) |
14472 | parse_error_context | |
14473 | (wfl_operator, "Exception `%s' can't be thrown in initializer", | |
14474 | lang_printable_name (TREE_VALUE (throws), 0)); | |
14475 | else | |
14476 | { | |
14477 | parse_error_context | |
781b0558 | 14478 | (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'", |
7705e9db APB |
14479 | lang_printable_name (TREE_VALUE (throws), 0), |
14480 | (DECL_NAME (current_function_decl) == init_identifier_node ? | |
14481 | IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) : | |
14482 | IDENTIFIER_POINTER (DECL_NAME (current_function_decl)))); | |
14483 | } | |
8b27f225 PB |
14484 | } |
14485 | } | |
14486 | ||
c877974e | 14487 | /* Return 1 if checked EXCEPTION is caught at the current nesting level of |
8b27f225 PB |
14488 | try-catch blocks, OR is listed in the `throws' clause of the |
14489 | current method. */ | |
14490 | ||
14491 | static int | |
14492 | check_thrown_exceptions_do (exception) | |
14493 | tree exception; | |
14494 | { | |
14495 | tree list = currently_caught_type_list; | |
c877974e | 14496 | resolve_and_layout (exception, NULL_TREE); |
8b27f225 PB |
14497 | /* First, all the nested try-catch-finally at that stage. The |
14498 | last element contains `throws' clause exceptions, if any. */ | |
c877974e APB |
14499 | if (IS_UNCHECKED_EXCEPTION_P (exception)) |
14500 | return 1; | |
8b27f225 PB |
14501 | while (list) |
14502 | { | |
14503 | tree caught; | |
14504 | for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught)) | |
14505 | if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0)) | |
14506 | return 1; | |
14507 | list = TREE_CHAIN (list); | |
14508 | } | |
14509 | return 0; | |
14510 | } | |
14511 | ||
14512 | static void | |
14513 | purge_unchecked_exceptions (mdecl) | |
14514 | tree mdecl; | |
14515 | { | |
14516 | tree throws = DECL_FUNCTION_THROWS (mdecl); | |
14517 | tree new = NULL_TREE; | |
14518 | ||
14519 | while (throws) | |
14520 | { | |
14521 | tree next = TREE_CHAIN (throws); | |
c877974e | 14522 | if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws))) |
8b27f225 PB |
14523 | { |
14524 | TREE_CHAIN (throws) = new; | |
14525 | new = throws; | |
14526 | } | |
14527 | throws = next; | |
14528 | } | |
14529 | /* List is inverted here, but it doesn't matter */ | |
14530 | DECL_FUNCTION_THROWS (mdecl) = new; | |
14531 | } | |
22eed1e6 APB |
14532 | |
14533 | /* 15.24 Conditional Operator ?: */ | |
14534 | ||
14535 | static tree | |
14536 | patch_conditional_expr (node, wfl_cond, wfl_op1) | |
14537 | tree node, wfl_cond, wfl_op1; | |
14538 | { | |
14539 | tree cond = TREE_OPERAND (node, 0); | |
14540 | tree op1 = TREE_OPERAND (node, 1); | |
14541 | tree op2 = TREE_OPERAND (node, 2); | |
22eed1e6 | 14542 | tree resulting_type = NULL_TREE; |
ac825856 | 14543 | tree t1, t2, patched; |
22eed1e6 APB |
14544 | int error_found = 0; |
14545 | ||
ac825856 APB |
14546 | /* Operands of ?: might be StringBuffers crafted as a result of a |
14547 | string concatenation. Obtain a descent operand here. */ | |
14548 | if ((patched = patch_string (op1))) | |
14549 | TREE_OPERAND (node, 1) = op1 = patched; | |
14550 | if ((patched = patch_string (op2))) | |
14551 | TREE_OPERAND (node, 2) = op2 = patched; | |
14552 | ||
14553 | t1 = TREE_TYPE (op1); | |
14554 | t2 = TREE_TYPE (op2); | |
14555 | ||
22eed1e6 APB |
14556 | /* The first expression must be a boolean */ |
14557 | if (TREE_TYPE (cond) != boolean_type_node) | |
14558 | { | |
14559 | SET_WFL_OPERATOR (wfl_operator, node, wfl_cond); | |
781b0558 KG |
14560 | parse_error_context (wfl_operator, |
14561 | "Incompatible type for `?:'. Can't convert `%s' to `boolean'", | |
22eed1e6 APB |
14562 | lang_printable_name (TREE_TYPE (cond), 0)); |
14563 | error_found = 1; | |
14564 | } | |
14565 | ||
14566 | /* Second and third can be numeric, boolean (i.e. primitive), | |
14567 | references or null. Anything else results in an error */ | |
14568 | if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2)) | |
14569 | || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node) | |
14570 | && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node)) | |
14571 | || (t1 == boolean_type_node && t2 == boolean_type_node))) | |
14572 | error_found = 1; | |
14573 | ||
14574 | /* Determine the type of the conditional expression. Same types are | |
14575 | easy to deal with */ | |
14576 | else if (t1 == t2) | |
14577 | resulting_type = t1; | |
14578 | ||
14579 | /* There are different rules for numeric types */ | |
14580 | else if (JNUMERIC_TYPE_P (t1)) | |
14581 | { | |
14582 | /* if byte/short found, the resulting type is short */ | |
14583 | if ((t1 == byte_type_node && t2 == short_type_node) | |
14584 | || (t1 == short_type_node && t2 == byte_type_node)) | |
14585 | resulting_type = short_type_node; | |
14586 | ||
14587 | /* If t1 is a constant int and t2 is of type byte, short or char | |
14588 | and t1's value fits in t2, then the resulting type is t2 */ | |
14589 | else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1))) | |
14590 | && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2)) | |
14591 | resulting_type = t2; | |
14592 | ||
14593 | /* If t2 is a constant int and t1 is of type byte, short or char | |
14594 | and t2's value fits in t1, then the resulting type is t1 */ | |
14595 | else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2))) | |
14596 | && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1)) | |
14597 | resulting_type = t1; | |
14598 | ||
14599 | /* Otherwise, binary numeric promotion is applied and the | |
14600 | resulting type is the promoted type of operand 1 and 2 */ | |
14601 | else | |
93024893 | 14602 | resulting_type = binary_numeric_promotion (t1, t2, |
22eed1e6 APB |
14603 | &TREE_OPERAND (node, 1), |
14604 | &TREE_OPERAND (node, 2)); | |
14605 | } | |
14606 | ||
14607 | /* Cases of a reference and a null type */ | |
14608 | else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node) | |
14609 | resulting_type = t1; | |
14610 | ||
14611 | else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node) | |
14612 | resulting_type = t2; | |
14613 | ||
14614 | /* Last case: different reference types. If a type can be converted | |
14615 | into the other one by assignment conversion, the latter | |
14616 | determines the type of the expression */ | |
14617 | else if ((resulting_type = try_reference_assignconv (t1, op2))) | |
14618 | resulting_type = promote_type (t1); | |
14619 | ||
14620 | else if ((resulting_type = try_reference_assignconv (t2, op1))) | |
14621 | resulting_type = promote_type (t2); | |
14622 | ||
14623 | /* If we don't have any resulting type, we're in trouble */ | |
14624 | if (!resulting_type) | |
14625 | { | |
c2e3db92 | 14626 | char *t = xstrdup (lang_printable_name (t1, 0)); |
22eed1e6 | 14627 | SET_WFL_OPERATOR (wfl_operator, node, wfl_op1); |
781b0558 KG |
14628 | parse_error_context (wfl_operator, |
14629 | "Incompatible type for `?:'. Can't convert `%s' to `%s'", | |
14630 | t, lang_printable_name (t2, 0)); | |
22eed1e6 APB |
14631 | free (t); |
14632 | error_found = 1; | |
14633 | } | |
14634 | ||
14635 | if (error_found) | |
14636 | { | |
14637 | TREE_TYPE (node) = error_mark_node; | |
14638 | return error_mark_node; | |
14639 | } | |
14640 | ||
14641 | TREE_TYPE (node) = resulting_type; | |
14642 | TREE_SET_CODE (node, COND_EXPR); | |
12472854 | 14643 | CAN_COMPLETE_NORMALLY (node) = 1; |
22eed1e6 APB |
14644 | return node; |
14645 | } | |
ac825856 | 14646 | |
5b09b33e PB |
14647 | /* Try to constant fold NODE. |
14648 | If NODE is not a constant expression, return NULL_EXPR. | |
14649 | CONTEXT is a static final VAR_DECL whose initializer we are folding. */ | |
14650 | ||
14651 | static tree | |
14652 | fold_constant_for_init (node, context) | |
14653 | tree node; | |
14654 | tree context; | |
14655 | { | |
14656 | tree op0, op1, val; | |
14657 | enum tree_code code = TREE_CODE (node); | |
14658 | ||
93024893 | 14659 | if (code == STRING_CST) |
5b09b33e | 14660 | return node; |
93024893 APB |
14661 | |
14662 | if (code == INTEGER_CST || code == REAL_CST) | |
14663 | return convert (TREE_TYPE (context), node); | |
8576f094 | 14664 | if (TREE_TYPE (node) != NULL_TREE && code != VAR_DECL && code != FIELD_DECL) |
5b09b33e PB |
14665 | return NULL_TREE; |
14666 | ||
14667 | switch (code) | |
14668 | { | |
5b09b33e PB |
14669 | case PLUS_EXPR: |
14670 | case MINUS_EXPR: | |
bc3ca41b PB |
14671 | case MULT_EXPR: |
14672 | case TRUNC_MOD_EXPR: | |
14673 | case RDIV_EXPR: | |
5b09b33e PB |
14674 | case LSHIFT_EXPR: |
14675 | case RSHIFT_EXPR: | |
14676 | case URSHIFT_EXPR: | |
14677 | case BIT_AND_EXPR: | |
14678 | case BIT_XOR_EXPR: | |
14679 | case BIT_IOR_EXPR: | |
5b09b33e PB |
14680 | case TRUTH_ANDIF_EXPR: |
14681 | case TRUTH_ORIF_EXPR: | |
14682 | case EQ_EXPR: | |
14683 | case NE_EXPR: | |
14684 | case GT_EXPR: | |
14685 | case GE_EXPR: | |
14686 | case LT_EXPR: | |
14687 | case LE_EXPR: | |
14688 | op0 = TREE_OPERAND (node, 0); | |
14689 | op1 = TREE_OPERAND (node, 1); | |
14690 | val = fold_constant_for_init (op0, context); | |
14691 | if (val == NULL_TREE || ! TREE_CONSTANT (val)) | |
14692 | return NULL_TREE; | |
14693 | TREE_OPERAND (node, 0) = val; | |
14694 | val = fold_constant_for_init (op1, context); | |
14695 | if (val == NULL_TREE || ! TREE_CONSTANT (val)) | |
14696 | return NULL_TREE; | |
14697 | TREE_OPERAND (node, 1) = val; | |
14698 | return patch_binop (node, op0, op1); | |
14699 | ||
14700 | case UNARY_PLUS_EXPR: | |
14701 | case NEGATE_EXPR: | |
14702 | case TRUTH_NOT_EXPR: | |
14703 | case BIT_NOT_EXPR: | |
14704 | case CONVERT_EXPR: | |
14705 | op0 = TREE_OPERAND (node, 0); | |
14706 | val = fold_constant_for_init (op0, context); | |
14707 | if (val == NULL_TREE || ! TREE_CONSTANT (val)) | |
14708 | return NULL_TREE; | |
14709 | TREE_OPERAND (node, 0) = val; | |
5a005d9e | 14710 | return patch_unaryop (node, op0); |
5b09b33e PB |
14711 | break; |
14712 | ||
14713 | case COND_EXPR: | |
14714 | val = fold_constant_for_init (TREE_OPERAND (node, 0), context); | |
14715 | if (val == NULL_TREE || ! TREE_CONSTANT (val)) | |
14716 | return NULL_TREE; | |
14717 | TREE_OPERAND (node, 0) = val; | |
14718 | val = fold_constant_for_init (TREE_OPERAND (node, 1), context); | |
14719 | if (val == NULL_TREE || ! TREE_CONSTANT (val)) | |
14720 | return NULL_TREE; | |
14721 | TREE_OPERAND (node, 1) = val; | |
14722 | val = fold_constant_for_init (TREE_OPERAND (node, 2), context); | |
14723 | if (val == NULL_TREE || ! TREE_CONSTANT (val)) | |
14724 | return NULL_TREE; | |
14725 | TREE_OPERAND (node, 2) = val; | |
14726 | return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1) | |
14727 | : TREE_OPERAND (node, 2); | |
14728 | ||
14729 | case VAR_DECL: | |
8576f094 APB |
14730 | case FIELD_DECL: |
14731 | if (! FIELD_FINAL (node) | |
5b09b33e PB |
14732 | || DECL_INITIAL (node) == NULL_TREE) |
14733 | return NULL_TREE; | |
14734 | val = DECL_INITIAL (node); | |
14735 | /* Guard against infinite recursion. */ | |
14736 | DECL_INITIAL (node) = NULL_TREE; | |
cd9643f7 | 14737 | val = fold_constant_for_init (val, node); |
5b09b33e PB |
14738 | DECL_INITIAL (node) = val; |
14739 | return val; | |
14740 | ||
14741 | case EXPR_WITH_FILE_LOCATION: | |
14742 | /* Compare java_complete_tree and resolve_expression_name. */ | |
14743 | if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */ | |
14744 | || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE) | |
14745 | { | |
14746 | tree name = EXPR_WFL_NODE (node); | |
14747 | tree decl; | |
14748 | if (PRIMARY_P (node)) | |
14749 | return NULL_TREE; | |
14750 | else if (! QUALIFIED_P (name)) | |
14751 | { | |
14752 | decl = lookup_field_wrapper (DECL_CONTEXT (context), name); | |
8576f094 APB |
14753 | if (decl == NULL_TREE |
14754 | || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl))) | |
5b09b33e PB |
14755 | return NULL_TREE; |
14756 | return fold_constant_for_init (decl, decl); | |
14757 | } | |
14758 | else | |
14759 | { | |
5b09b33e PB |
14760 | /* Wait until the USE_COMPONENT_REF re-write. FIXME. */ |
14761 | qualify_ambiguous_name (node); | |
14762 | if (resolve_field_access (node, &decl, NULL) | |
14763 | && decl != NULL_TREE) | |
14764 | return fold_constant_for_init (decl, decl); | |
5b09b33e PB |
14765 | return NULL_TREE; |
14766 | } | |
14767 | } | |
14768 | else | |
14769 | { | |
14770 | op0 = TREE_OPERAND (node, 0); | |
14771 | val = fold_constant_for_init (op0, context); | |
14772 | if (val == NULL_TREE || ! TREE_CONSTANT (val)) | |
14773 | return NULL_TREE; | |
14774 | TREE_OPERAND (node, 0) = val; | |
14775 | return val; | |
14776 | } | |
14777 | ||
bc3ca41b PB |
14778 | #ifdef USE_COMPONENT_REF |
14779 | case IDENTIFIER: | |
14780 | case COMPONENT_REF: | |
14781 | ?; | |
14782 | #endif | |
14783 | ||
5b09b33e PB |
14784 | default: |
14785 | return NULL_TREE; | |
14786 | } | |
14787 | } | |
bc3ca41b PB |
14788 | |
14789 | #ifdef USE_COMPONENT_REF | |
14790 | /* Context is 'T' for TypeName, 'P' for PackageName, | |
14791 | 'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */ | |
14792 | ||
14793 | tree | |
14794 | resolve_simple_name (name, context) | |
14795 | tree name; | |
14796 | int context; | |
14797 | { | |
14798 | } | |
14799 | ||
14800 | tree | |
14801 | resolve_qualified_name (name, context) | |
14802 | tree name; | |
14803 | int context; | |
14804 | { | |
14805 | } | |
14806 | #endif |