1 /* Language parser definitions for the GNU compiler for the Java(TM) language.
2 Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
3 Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
22 Java and all Java-based marks are trademarks or registered trademarks
23 of Sun Microsystems, Inc. in the United States and other countries.
24 The Free Software Foundation is independent of Sun Microsystems, Inc. */
31 /* Extern global variable declarations */
32 extern int java_error_count;
33 extern struct obstack temporary_obstack;
34 extern struct obstack permanent_obstack;
35 extern int quiet_flag;
38 /* Function extern to java/ */
39 extern int int_fits_type_p PROTO ((tree, tree));
40 extern tree stabilize_reference PROTO ((tree));
43 /* Macros for verbose debug info */
44 #ifdef VERBOSE_SKELETON
45 #define RULE( rule ) printf ( "jv_yacc:%d: rule %s\n", lineno, rule )
50 #ifdef VERBOSE_SKELETON
51 #undef SOURCE_FRONTEND_DEBUG
52 #define SOURCE_FRONTEND_DEBUG(X) \
53 {if (!quiet_flag) {printf ("* "); printf X; putchar ('\n');} }
55 #define SOURCE_FRONTEND_DEBUG(X)
58 /* Macro for error recovering */
61 { if (!quiet_flag) {printf ("** Recovered\n");} }
62 #define DRECOVERED(s) \
63 { if (!quiet_flag) {printf ("** Recovered (%s)\n", #s);}}
69 #define DRECOVER(s) {yyerrok; DRECOVERED(s)}
70 #define RECOVER {yyerrok; RECOVERED}
72 #define YYERROR_NOW ctxp->java_error_flag = 1
73 #define YYNOT_TWICE if (ctxp->prevent_ese != lineno)
75 /* Accepted modifiers */
76 #define CLASS_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT|ACC_FINAL
77 #define FIELD_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_FINAL| \
78 ACC_STATIC|ACC_TRANSIENT|ACC_VOLATILE
79 #define METHOD_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_ABSTRACT| \
80 ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE
81 #define INTERFACE_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT
82 #define INTERFACE_METHOD_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT
83 #define INTERFACE_FIELD_MODIFIERS ACC_PUBLIC|ACC_STATIC|ACC_FINAL
85 /* Getting a modifier WFL */
86 #define MODIFIER_WFL(M) (ctxp->modifier_ctx [(M) - PUBLIC_TK])
88 /* Check on modifiers */
89 #define THIS_MODIFIER_ONLY(f, m, v, count, l) \
92 tree node = ctxp->modifier_ctx [v]; \
94 && ((EXPR_WFL_COLNO (node) > EXPR_WFL_COLNO (l)) \
95 || (EXPR_WFL_LINENO (node) > EXPR_WFL_LINENO (l)))) \
102 #define ABSTRACT_CHECK(FLAG, V, CL, S) \
104 parse_error_context ((CL), S " method can't be abstract");
106 #define JCONSTRUCTOR_CHECK(FLAG, V, CL, S) \
108 parse_error_context ((CL), "Constructor can't be %s", (S)); \
111 #define exit_java_complete_class() \
117 #define CLASS_OR_INTERFACE(decl, s1, s2) \
119 ((get_access_flags_from_decl (TYPE_NAME (TREE_TYPE (decl))) \
121 s2 : s1) : ((s1 [0]=='S'|| s1 [0]=='s') ? \
122 (s1 [0]=='S' ? "Supertype" : "supertype") : \
123 (s1 [0] > 'A' ? "Type" : "type")))
125 #define GET_REAL_TYPE(TYPE) \
126 (TREE_CODE (TYPE) == TREE_LIST ? TREE_PURPOSE (TYPE) : TYPE)
128 #define GET_METHOD_NAME(METHOD) \
129 (TREE_CODE (DECL_NAME (METHOD)) == EXPR_WITH_FILE_LOCATION ? \
130 EXPR_WFL_NODE (DECL_NAME (METHOD)) : DECL_NAME (METHOD))
132 /* Get TYPE name string, regardless whether TYPE is a class or an
134 #define GET_TYPE_NAME(TYPE) \
135 (TREE_CODE (TYPE_NAME (TYPE)) == IDENTIFIER_NODE ? \
136 IDENTIFIER_POINTER (TYPE_NAME (TYPE)) : \
137 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TYPE))))
139 /* Pedantic warning on obsolete modifiers. Note: when cl is NULL,
140 flags was set artificially, such as for a interface method */
141 #define OBSOLETE_MODIFIER_WARNING(cl, flags, modifier, format, arg) \
143 if (flag_redundant && (cl) && ((flags) & (modifier))) \
144 parse_warning_context (cl, \
145 "Discouraged redundant use of `%s' modifier " \
146 "in declaration of " format, \
147 java_accstring_lookup (modifier), arg); \
150 /* Quickly build a temporary pointer on hypothetical type NAME. */
151 #define BUILD_PTR_FROM_NAME(ptr, name) \
153 ptr = build (POINTER_TYPE, NULL_TREE); \
154 TYPE_NAME (ptr) = name; \
157 #define INCOMPLETE_TYPE_P(NODE) \
158 ((TREE_CODE (NODE) == POINTER_TYPE) \
159 && !TREE_TYPE (NODE) \
160 && TREE_CODE (TYPE_NAME (NODE)) == IDENTIFIER_NODE)
162 /* Set the EMIT_LINE_NOTE flag of a EXPR_WLF to 1 if debug information
163 are requested. Works in the context of a parser rule. */
164 #define JAVA_MAYBE_GENERATE_DEBUG_INFO(node) \
165 (debug_info_level != DINFO_LEVEL_NONE ? \
166 EXPR_WFL_EMIT_LINE_NOTE (node) = 1, node : node)
168 /* Types classification, according to the JLS, section 4.2 */
169 #define JFLOAT_TYPE_P(TYPE) (TYPE && TREE_CODE ((TYPE)) == REAL_TYPE)
170 #define JINTEGRAL_TYPE_P(TYPE) ((TYPE) \
171 && (TREE_CODE ((TYPE)) == INTEGER_TYPE \
172 || TREE_CODE ((TYPE)) == CHAR_TYPE))
173 #define JNUMERIC_TYPE_P(TYPE) ((TYPE) \
174 && (JFLOAT_TYPE_P ((TYPE)) \
175 || JINTEGRAL_TYPE_P ((TYPE))))
176 #define JPRIMITIVE_TYPE_P(TYPE) ((TYPE) \
177 && (JNUMERIC_TYPE_P ((TYPE)) \
178 || TREE_CODE ((TYPE)) == BOOLEAN_TYPE))
180 #define JBSC_TYPE_P(TYPE) ((TYPE) && (((TYPE) == byte_type_node) \
181 || ((TYPE) == short_type_node) \
182 || ((TYPE) == char_type_node)))
184 /* Not defined in the LRM */
185 #define JSTRING_TYPE_P(TYPE) ((TYPE) \
186 && ((TYPE) == string_type_node || \
187 (TREE_CODE (TYPE) == POINTER_TYPE && \
188 TREE_TYPE (TYPE) == string_type_node)))
189 #define JSTRING_P(NODE) ((NODE) \
190 && (TREE_CODE (NODE) == STRING_CST \
191 || IS_CRAFTED_STRING_BUFFER_P (NODE) \
192 || JSTRING_TYPE_P (TREE_TYPE (NODE))))
194 #define JREFERENCE_TYPE_P(TYPE) ((TYPE) \
195 && (TREE_CODE (TYPE) == RECORD_TYPE \
196 || (TREE_CODE (TYPE) == POINTER_TYPE \
197 && TREE_CODE (TREE_TYPE (TYPE)) == \
199 #define JNULLP_TYPE_P(TYPE) ((TYPE) && (TREE_CODE (TYPE) == POINTER_TYPE) \
200 && (TYPE) == TREE_TYPE (null_pointer_node))
202 /* Other predicate */
203 #define JDECL_P(NODE) (NODE && (TREE_CODE (NODE) == PARM_DECL \
204 || TREE_CODE (NODE) == VAR_DECL \
205 || TREE_CODE (NODE) == FIELD_DECL))
207 #define TYPE_INTERFACE_P(TYPE) \
208 (CLASS_P (TYPE) && CLASS_INTERFACE (TYPE_NAME (TYPE)))
210 #define TYPE_CLASS_P(TYPE) (CLASS_P (TYPE) \
211 && !CLASS_INTERFACE (TYPE_NAME (TYPE)))
213 /* Standard error messages */
214 #define ERROR_CANT_CONVERT_TO_BOOLEAN(OPERATOR, NODE, TYPE) \
215 parse_error_context \
216 ((OPERATOR), "Incompatible type for `%s'. Can't convert `%s' to " \
217 "boolean", operator_string ((NODE)), lang_printable_name ((TYPE),0))
219 #define ERROR_CANT_CONVERT_TO_NUMERIC(OPERATOR, NODE, TYPE) \
220 parse_error_context \
221 ((OPERATOR), "Incompatible type for `%s'. Can't convert `%s' to " \
222 "numeric type", operator_string ((NODE)), lang_printable_name ((TYPE), 0))
224 #define ERROR_CAST_NEEDED_TO_INTEGRAL(OPERATOR, NODE, TYPE) \
225 parse_error_context \
226 ((OPERATOR), (JPRIMITIVE_TYPE_P (TYPE) ? \
227 "Incompatible type for `%s'. Explicit cast needed to convert " \
228 "`%s' to integral" : "Incompatible type for `%s'. Can't convert " \
229 "`%s' to integral"), operator_string ((NODE)), \
230 lang_printable_name ((TYPE), 0))
232 #define ERROR_VARIABLE_NOT_INITIALIZED(WFL, V) \
233 parse_error_context \
234 ((WFL), "Variable `%s' may not have been initialized", \
235 IDENTIFIER_POINTER (V))
237 /* Definition for loop handling. This is Java's own definition of a
238 loop body. See parse.y for documentation. It's valid once you hold
239 a loop's body (LOOP_EXPR_BODY) */
241 /* The loop main block is the one hold the condition and the loop body */
242 #define LOOP_EXPR_BODY_MAIN_BLOCK(NODE) TREE_OPERAND (NODE, 0)
243 /* And then there is the loop update block */
244 #define LOOP_EXPR_BODY_UPDATE_BLOCK(NODE) TREE_OPERAND (NODE, 1)
246 /* Inside the loop main block, there is the loop condition and the
247 loop body. They may be reversed if the loop being described is a
248 do-while loop. NOTE: if you use a WFL around the EXIT_EXPR so you
249 can issue debug info for it, the EXIT_EXPR will be one operand
251 #define LOOP_EXPR_BODY_CONDITION_EXPR(NODE, R) \
252 TREE_OPERAND (LOOP_EXPR_BODY_MAIN_BLOCK (NODE), (R ? 1 : 0))
254 /* Here is the labeled block the loop real body is encapsulated in */
255 #define LOOP_EXPR_BODY_LABELED_BODY(NODE, R) \
256 TREE_OPERAND (LOOP_EXPR_BODY_MAIN_BLOCK (NODE), (R ? 0 : 1))
257 /* And here is the loop's real body */
258 #define LOOP_EXPR_BODY_BODY_EXPR(NODE, R) \
259 LABELED_BLOCK_BODY (LOOP_EXPR_BODY_LABELED_BODY(NODE, R))
261 #define PUSH_LABELED_BLOCK(B) \
263 TREE_CHAIN (B) = ctxp->current_labeled_block; \
264 ctxp->current_labeled_block = (B); \
266 #define POP_LABELED_BLOCK() \
267 ctxp->current_labeled_block = TREE_CHAIN (ctxp->current_labeled_block)
269 #define PUSH_LOOP(L) \
271 TREE_CHAIN (L) = ctxp->current_loop; \
272 ctxp->current_loop = (L); \
274 #define POP_LOOP() ctxp->current_loop = TREE_CHAIN (ctxp->current_loop)
276 #define PUSH_EXCEPTIONS(E) \
277 currently_caught_type_list = \
278 tree_cons (NULL_TREE, (E), currently_caught_type_list);
280 #define POP_EXCEPTIONS() \
281 currently_caught_type_list = TREE_CHAIN (currently_caught_type_list)
283 /* Check that we're inside a try block. */
284 #define IN_TRY_BLOCK_P() \
285 (currently_caught_type_list \
286 && ((TREE_VALUE (currently_caught_type_list) != \
287 DECL_FUNCTION_THROWS (current_function_decl)) \
288 || TREE_CHAIN (currently_caught_type_list)))
290 /* Check that we have exceptions in E. */
291 #define EXCEPTIONS_P(E) ((E) ? TREE_VALUE (E) : NULL_TREE)
293 /* Invocation modes, as returned by invocation_mode (). */
302 /* We need the resolution stuff only if we compile jc1 */
305 /* Unresolved type identifiers handling. When we process the source
306 code, we blindly accept an unknown type identifier and try to
307 resolve it later. When an unknown type identifier is encountered
308 and used, we record in a struct jdep element what the incomplete
309 type is and what it should patch. Later, java_complete_class will
310 process all classes known to have unresolved type
311 dependencies. Within each of these classes, this routine will
312 process unresolved type dependencies (JDEP_TO_RESOLVE), patch what
313 needs to be patched in the dependent tree node (JDEP_GET_PATCH,
314 JDEP_APPLY_PATCH) and perform other actions dictated by the context
315 of the patch (JDEP_KIND). The ideas are: we patch only what needs
316 to be patched, and with java_complete_class called at the right
317 time, we will start processing incomplete function bodies tree
318 nodes with everything external to function's bodies already
319 completed, it makes things much simpler. */
322 JDEP_NO_PATCH, /* Must be first */
323 JDEP_SUPER, /* Patch the type of one type
324 supertype. Requires some check
326 JDEP_FIELD, /* Patch the type of a class field */
328 /* JDEP_{METHOD,METHOD_RETURN,METHOD_END} to be kept in order */
329 JDEP_METHOD, /* Mark the beginning of the patching
330 of a method declaration, including
332 JDEP_METHOD_RETURN, /* Mark the beginning of the patching
333 of a method declaration. Arguments
334 aren't patched, only the returned
336 JDEP_METHOD_END, /* Mark the end of the patching of a
337 method declaration. It indicates
338 that it's time to compute and
339 install a new signature */
341 JDEP_INTERFACE, /* Patch the type of a Class/interface
343 JDEP_VARIABLE, /* Patch the type of a variable declaration */
344 JDEP_PARM, /* Patch the type of a parm declaration */
345 JDEP_TYPE, /* Patch a random tree node type,
346 without the need for any specific
348 JDEP_EXCEPTION /* Patch exceptions specified by `throws' */
351 typedef struct _jdep {
352 #ifdef ONLY_INT_FIELDS
353 int kind : 8; /* Type of patch */
355 enum jdep_code kind : 8;
358 int flag0 : 1; /* Some flags */
359 tree decl; /* Tied decl/or WFL */
360 tree solv; /* What to solve */
361 tree wfl; /* Where thing to resolve where found */
362 tree misc; /* Miscellaneous info (optional). */
363 tree *patch; /* Address of a location to patch */
364 struct _jdep *next; /* Linked list */
368 #define JDEP_DECL(J) ((J)->decl)
369 #define JDEP_DECL_WFL(J) ((J)->decl)
370 #define JDEP_KIND(J) ((J)->kind)
371 #define JDEP_SOLV(J) ((J)->solv)
372 #define JDEP_WFL(J) ((J)->wfl)
373 #define JDEP_MISC(J) ((J)->misc)
374 #define JDEP_CLASS(J) ((J)->class)
375 #define JDEP_APPLY_PATCH(J,P) (*(J)->patch = (P))
376 #define JDEP_GET_PATCH(J) ((J)->patch)
377 #define JDEP_CHAIN(J) ((J)->next)
378 #define JDEP_TO_RESOLVE(J) ((J)->solv)
379 #define JDEP_RESOLVED_DECL(J) ((J)->solv)
380 #define JDEP_RESOLVED(J, D) ((J)->solv = D)
381 #define JDEP_RESOLVED_P(J) \
382 (!(J)->solv || TREE_CODE ((J)->solv) != POINTER_TYPE)
384 typedef struct _jdeplist {
387 struct _jdeplist *next;
390 #endif /* JC1_LITE */
392 #define CLASSD_FIRST(CD) ((CD)->first)
393 #define CLASSD_LAST(CD) ((CD)->last)
394 #define CLASSD_CHAIN(CD) ((CD)->next)
396 #define JDEP_INSERT(L,J) \
399 (L)->last = (L)->first = (J); \
402 JDEP_CHAIN ((L)->last) = (J); \
407 /* if TYPE can't be resolved, obtain something suitable for its
408 resolution (TYPE is saved in SAVE before being changed). and set
409 CHAIN to 1. Otherwise, type is set to something usable. CHAIN is
410 usually used to determine that a new DEP must be installed on TYPE.
411 Note that when compiling java.lang.Object, references to Object are
413 #define SET_TYPE_FOR_RESOLUTION(TYPE, SAVE, CHAIN) \
415 tree returned_type; \
417 if (TREE_TYPE (ctxp->current_parsed_class) == object_type_node \
418 && TREE_CODE (TYPE) == EXPR_WITH_FILE_LOCATION \
419 && EXPR_WFL_NODE (TYPE) == unqualified_object_id_node) \
420 (TYPE) = object_type_node; \
423 if (unresolved_type_p (type, &returned_type)) \
426 (TYPE) = returned_type; \
430 (TYPE) = obtain_incomplete_type (TYPE); \
436 /* Promote a type if it won't be registered as a patch */
437 #define PROMOTE_RECORD_IF_COMPLETE(TYPE, IS_INCOMPLETE) \
439 if (!(IS_INCOMPLETE) && TREE_CODE (TYPE) == RECORD_TYPE) \
440 (TYPE) = promote_type (TYPE); \
443 /* Insert a DECL in the current block */
444 #define BLOCK_CHAIN_DECL(NODE) \
446 TREE_CHAIN ((NODE)) = \
447 BLOCK_EXPR_DECLS (GET_CURRENT_BLOCK (current_function_decl)); \
448 BLOCK_EXPR_DECLS (GET_CURRENT_BLOCK (current_function_decl)) = (NODE); \
451 /* Return the current block, either found in the body of the currently
452 declared function or in the current static block being defined. */
453 #define GET_CURRENT_BLOCK(F) ((F) ? DECL_FUNCTION_BODY ((F)) : \
454 current_static_block)
456 /* For an artificial BLOCK (created to house a local variable declaration not
457 at the start of an existing block), the parent block; otherwise NULL. */
458 #define BLOCK_EXPR_ORIGIN(NODE) BLOCK_ABSTRACT_ORIGIN(NODE)
460 /* Merge an other line to the source line number of a decl. Used to
461 remember function's end. */
462 #define DECL_SOURCE_LINE_MERGE(DECL,NO) DECL_SOURCE_LINE(DECL) |= (NO << 16)
464 /* Retrieve those two info separately. */
465 #define DECL_SOURCE_LINE_FIRST(DECL) (DECL_SOURCE_LINE(DECL) & 0x0000ffff)
466 #define DECL_SOURCE_LINE_LAST(DECL) (DECL_SOURCE_LINE(DECL) >> 16)
468 /* Retrieve line/column from a WFL. */
469 #define EXPR_WFL_GET_LINECOL(V,LINE,COL) \
471 (LINE) = (V) >> 12; \
472 (COL) = (V) & 0xfff; \
474 /* Add X to the column number information */
475 #define EXPR_WFL_ADD_COL(V, X) \
476 (V) = (((V) & 0xfffff000) | ((((V) & 0xfff) + (X)) & 0xfff))
478 /* Build a WFL for expression nodes */
479 #define BUILD_EXPR_WFL(NODE, WFL) \
480 build_expr_wfl ((NODE), input_filename, EXPR_WFL_LINENO ((WFL)), \
481 EXPR_WFL_COLNO ((WFL)))
483 #define EXPR_WFL_QUALIFICATION(WFL) TREE_OPERAND ((WFL), 1)
484 #define QUAL_WFL(NODE) TREE_PURPOSE (NODE)
485 #define QUAL_RESOLUTION(NODE) TREE_VALUE (NODE)
486 #define QUAL_DECL_TYPE(NODE) GET_SKIP_TYPE (NODE)
488 #define GET_SKIP_TYPE(NODE) \
489 (TREE_CODE (TREE_TYPE (NODE)) == POINTER_TYPE ? \
490 TREE_TYPE (TREE_TYPE (NODE)): TREE_TYPE (NODE))
492 /* Handy macros for the walk operation */
493 #define COMPLETE_CHECK_OP(NODE, N) \
495 TREE_OPERAND ((NODE), (N)) = \
496 java_complete_tree (TREE_OPERAND ((NODE), (N))); \
497 if (TREE_OPERAND ((NODE), (N)) == error_mark_node) \
498 return error_mark_node; \
500 #define COMPLETE_CHECK_OP_0(NODE) COMPLETE_CHECK_OP(NODE, 0)
501 #define COMPLETE_CHECK_OP_1(NODE) COMPLETE_CHECK_OP(NODE, 1)
502 #define COMPLETE_CHECK_OP_2(NODE) COMPLETE_CHECK_OP(NODE, 2)
504 /* Building invocations: append(ARG) and StringBuffer(ARG) */
505 #define BUILD_APPEND(ARG) \
506 ((JSTRING_TYPE_P (TREE_TYPE (ARG)) || JPRIMITIVE_TYPE_P (TREE_TYPE (ARG))) \
507 ? build_method_invocation (wfl_append, \
508 ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE)\
509 : build_method_invocation (wfl_append, \
510 ARG ? build_tree_list (NULL, \
511 build1 (CONVERT_EXPR, \
515 #define BUILD_STRING_BUFFER(ARG) \
516 build_new_invocation (wfl_string_buffer, \
517 (ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE))
519 /* For exception handling, build diverse function calls */
520 #define BUILD_ASSIGN_EXCEPTION_INFO(WHERE, TO) \
522 (WHERE) = build (MODIFY_EXPR, void_type_node, (TO), \
523 soft_exceptioninfo_call_node); \
524 TREE_SIDE_EFFECTS (WHERE) = 1; \
527 #define BUILD_THROW(WHERE, WHAT) \
529 (WHERE) = build (CALL_EXPR, void_type_node, \
530 build_address_of (throw_node), \
531 build_tree_list (NULL_TREE, (WHAT)), NULL_TREE); \
532 TREE_SIDE_EFFECTS ((WHERE)) = 1; \
535 /* Set wfl_operator for the most accurate error location */
536 #define SET_WFL_OPERATOR(WHICH, NODE, WFL) \
537 EXPR_WFL_LINECOL (WHICH) = \
538 (TREE_CODE (WFL) == EXPR_WITH_FILE_LOCATION ? \
539 EXPR_WFL_LINECOL (WFL) : EXPR_WFL_LINECOL (NODE))
541 #define PATCH_METHOD_RETURN_ERROR() \
544 *ret_decl = NULL_TREE; \
545 return error_mark_node; \
548 /* Convenient macro to check. Assumes that CLASS is a CLASS_DECL. */
549 #define CHECK_METHODS(CLASS) \
551 if (CLASS_INTERFACE ((CLASS))) \
552 java_check_abstract_methods ((CLASS)); \
554 java_check_regular_methods ((CLASS)); \
557 /* Using and reseting the @deprecated tag flag */
558 #define CHECK_DEPRECATED(DECL) \
560 if (ctxp->deprecated) \
561 DECL_DEPRECATED (DECL) = 1; \
562 ctxp->deprecated = 0; \
565 /* Register an import */
566 #define REGISTER_IMPORT(WHOLE, NAME) \
568 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P ((NAME)) = 1; \
569 node = build_tree_list ((WHOLE), (NAME)); \
570 TREE_CHAIN (node) = ctxp->import_list; \
571 ctxp->import_list = node; \
574 /* Safe check that DECL is <clinit> */
575 #define IS_CLINIT(DECL) \
576 (DECL != NULL_TREE && DECL_NAME (DECL) == clinit_identifier_node)
578 /* Macro to access the osb (opening square bracket) count */
579 #define CURRENT_OSB(C) (C)->osb_number [(C)->osb_depth]
581 /* Macro for the xreferencer */
582 #define DECL_END_SOURCE_LINE(DECL) DECL_FRAME_SIZE (DECL)
583 #define DECL_INHERITED_SOURCE_LINE(DECL) DECL_FIELD_SIZE (DECL)
585 /* Parser context data structure. */
588 char *filename; /* Current filename */
589 FILE *finput; /* Current file input stream */
590 struct parser_ctxt *next;
592 struct java_line *p_line, *c_line; /* Previous and current line */
593 java_lc elc; /* Error's line column info */
594 unicode_t unget_utf8_value; /* An unget utf8 value */
595 int ccb_indent; /* Keep track of {} indent, lexer */
596 int first_ccb_indent1; /* First { at ident level 1 */
597 int last_ccb_indent1; /* Last } at ident level 1 */
598 int parser_ccb_indent; /* Keep track of {} indent, parser */
599 int osb_depth; /* Current depth of [ in an expression */
600 int osb_limit; /* Limit of this depth */
601 int *osb_number; /* Keep track of ['s */
602 int minus_seen; /* Integral literal overflow */
603 int lineno; /* Current lineno */
604 int java_error_flag; /* Report error when true */
605 int deprecated; /* @deprecated tag seen */
607 /* This section is defined only if we compile jc1 */
609 tree modifier_ctx [11]; /* WFL of modifiers */
610 tree current_class; /* Current class */
611 tree current_function_decl; /* Current function decl, save/restore */
613 struct JCF *current_jcf; /* CU jcf */
615 int prevent_ese; /* Prevent expression statement error */
616 int class_err; /* Flag to report certain errors */
618 int formal_parameter_number; /* Number of parameters found */
619 int interface_number; /* # itfs declared to extend an itf def */
621 tree package; /* Defined package ID */
623 /* Those tow list are saved accross file traversal */
624 tree incomplete_class; /* List of non-complete classes */
625 tree gclass_list; /* All classes seen from source code */
627 /* These two lists won't survive file traversal */
628 tree class_list; /* List of classes in a CU */
629 jdeplist *classd_list; /* Classe dependencies in a CU */
631 tree current_parsed_class; /* Class currently parsed */
632 tree current_parsed_class_un; /* Curr. parsed class unqualified name */
634 tree non_static_initialized; /* List of non static initialized fields */
635 tree static_initialized; /* List of static non final initialized */
637 tree import_list; /* List of import */
638 tree import_demand_list; /* List of import on demand */
640 tree current_loop; /* List of the currently nested
642 tree current_labeled_block; /* List of currently nested
645 int pending_block; /* Pending block to close */
647 int explicit_constructor_p; /* True when processing an explicit
648 constructor. This flag is used to trap
649 illegal argument usage during an
650 explicit constructor invocation. */
651 #endif /* JC1_LITE */
655 void safe_layout_class PROTO ((tree));
656 void java_complete_class PROTO ((void));
657 void java_check_circular_reference PROTO ((void));
658 void java_check_final PROTO ((void));
659 void java_layout_classes PROTO ((void));
660 tree java_method_add_stmt PROTO ((tree, tree));
661 void java_expand_switch PROTO ((tree));
662 int java_report_errors PROTO ((void));
663 extern tree do_resolve_class PROTO ((tree, tree, tree));
665 char *java_get_line_col PROTO ((char *, int, int));
666 extern void reset_report PROTO ((void));
668 /* Always in use, no matter what you compile */
669 void java_push_parser_context PROTO ((void));
670 void java_pop_parser_context PROTO ((int));
671 void java_init_lex PROTO ((void));
672 extern void java_parser_context_save_global PROTO ((void));
673 extern void java_parser_context_restore_global PROTO ((void));
674 int yyparse PROTO ((void));
675 extern int java_parse PROTO ((void));
677 void yyerror PROTO ((const char *));
678 extern void java_expand_classes PROTO ((void));