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 /* Pedantic warning on obsolete modifiers. Note: when cl is NULL,
133 flags was set artificially, such as for a interface method */
134 #define OBSOLETE_MODIFIER_WARNING(cl, flags, modifier, format, arg) \
136 if (flag_redundant && (cl) && ((flags) & (modifier))) \
137 parse_warning_context (cl, \
138 "Discouraged redundant use of `%s' modifier " \
139 "in declaration of " format, \
140 java_accstring_lookup (modifier), arg); \
143 /* Quickly build a temporary pointer on hypothetical type NAME. */
144 #define BUILD_PTR_FROM_NAME(ptr, name) \
146 ptr = build (POINTER_TYPE, NULL_TREE); \
147 TYPE_NAME (ptr) = name; \
150 #define INCOMPLETE_TYPE_P(NODE) \
151 ((TREE_CODE (NODE) == POINTER_TYPE) \
152 && !TREE_TYPE (NODE) \
153 && TREE_CODE (TYPE_NAME (NODE)) == IDENTIFIER_NODE)
155 /* Set the EMIT_LINE_NOTE flag of a EXPR_WLF to 1 if debug information
156 are requested. Works in the context of a parser rule. */
157 #define JAVA_MAYBE_GENERATE_DEBUG_INFO(node) \
158 (debug_info_level != DINFO_LEVEL_NONE ? \
159 EXPR_WFL_EMIT_LINE_NOTE (node) = 1, node : node)
161 /* Types classification, according to the JLS, section 4.2 */
162 #define JFLOAT_TYPE_P(TYPE) (TYPE && TREE_CODE ((TYPE)) == REAL_TYPE)
163 #define JINTEGRAL_TYPE_P(TYPE) ((TYPE) \
164 && (TREE_CODE ((TYPE)) == INTEGER_TYPE \
165 || TREE_CODE ((TYPE)) == CHAR_TYPE))
166 #define JNUMERIC_TYPE_P(TYPE) ((TYPE) \
167 && (JFLOAT_TYPE_P ((TYPE)) \
168 || JINTEGRAL_TYPE_P ((TYPE))))
169 #define JPRIMITIVE_TYPE_P(TYPE) ((TYPE) \
170 && (JNUMERIC_TYPE_P ((TYPE)) \
171 || TREE_CODE ((TYPE)) == BOOLEAN_TYPE))
173 #define JBSC_TYPE_P(TYPE) ((TYPE) && (((TYPE) == byte_type_node) \
174 || ((TYPE) == short_type_node) \
175 || ((TYPE) == char_type_node)))
177 /* Not defined in the LRM */
178 #define JSTRING_TYPE_P(TYPE) ((TYPE) \
179 && ((TYPE) == string_type_node || \
180 (TREE_CODE (TYPE) == POINTER_TYPE && \
181 TREE_TYPE (TYPE) == string_type_node)))
182 #define JSTRING_P(NODE) ((NODE) \
183 && (TREE_CODE (NODE) == STRING_CST \
184 || IS_CRAFTED_STRING_BUFFER_P (NODE) \
185 || JSTRING_TYPE_P (TREE_TYPE (NODE))))
187 #define JREFERENCE_TYPE_P(TYPE) ((TYPE) \
188 && (TREE_CODE (TYPE) == RECORD_TYPE \
189 || (TREE_CODE (TYPE) == POINTER_TYPE \
190 && TREE_CODE (TREE_TYPE (TYPE)) == \
192 #define JNULLP_TYPE_P(TYPE) ((TYPE) && (TREE_CODE (TYPE) == POINTER_TYPE) \
193 && (TYPE) == TREE_TYPE (null_pointer_node))
195 /* Other predicate */
196 #define JDECL_P(NODE) (NODE && (TREE_CODE (NODE) == PARM_DECL \
197 || TREE_CODE (NODE) == VAR_DECL \
198 || TREE_CODE (NODE) == FIELD_DECL))
200 #define TYPE_INTERFACE_P(TYPE) \
201 (CLASS_P (TYPE) && CLASS_INTERFACE (TYPE_NAME (TYPE)))
203 #define TYPE_CLASS_P(TYPE) (CLASS_P (TYPE) \
204 && !CLASS_INTERFACE (TYPE_NAME (TYPE)) \
205 && !TYPE_ARRAY_P (TYPE))
207 /* Standard error messages */
208 #define ERROR_CANT_CONVERT_TO_BOOLEAN(OPERATOR, NODE, TYPE) \
209 parse_error_context \
210 ((OPERATOR), "Incompatible type for `%s'. Can't convert `%s' to " \
211 "boolean", operator_string ((NODE)), lang_printable_name ((TYPE),0))
213 #define ERROR_CANT_CONVERT_TO_NUMERIC(OPERATOR, NODE, TYPE) \
214 parse_error_context \
215 ((OPERATOR), "Incompatible type for `%s'. Can't convert `%s' to " \
216 "numeric type", operator_string ((NODE)), lang_printable_name ((TYPE), 0))
218 #define ERROR_CAST_NEEDED_TO_INTEGRAL(OPERATOR, NODE, TYPE) \
219 parse_error_context \
220 ((OPERATOR), (JPRIMITIVE_TYPE_P (TYPE) ? \
221 "Incompatible type for `%s'. Explicit cast needed to convert " \
222 "`%s' to integral" : "Incompatible type for `%s'. Can't convert " \
223 "`%s' to integral"), operator_string ((NODE)), \
224 lang_printable_name ((TYPE), 0))
226 #define ERROR_VARIABLE_NOT_INITIALIZED(WFL, V) \
227 parse_error_context \
228 ((WFL), "Variable `%s' may not have been initialized", \
229 IDENTIFIER_POINTER (V))
231 /* Definition for loop handling. This is Java's own definition of a
232 loop body. See parse.y for documentation. It's valid once you hold
233 a loop's body (LOOP_EXPR_BODY) */
235 /* The loop main block is the one hold the condition and the loop body */
236 #define LOOP_EXPR_BODY_MAIN_BLOCK(NODE) TREE_OPERAND (NODE, 0)
237 /* And then there is the loop update block */
238 #define LOOP_EXPR_BODY_UPDATE_BLOCK(NODE) TREE_OPERAND (NODE, 1)
240 /* Inside the loop main block, there is the loop condition and the
241 loop body. They may be reversed if the loop being described is a
242 do-while loop. NOTE: if you use a WFL around the EXIT_EXPR so you
243 can issue debug info for it, the EXIT_EXPR will be one operand
245 #define LOOP_EXPR_BODY_CONDITION_EXPR(NODE, R) \
246 TREE_OPERAND (LOOP_EXPR_BODY_MAIN_BLOCK (NODE), (R ? 1 : 0))
248 /* Here is the labeled block the loop real body is encapsulated in */
249 #define LOOP_EXPR_BODY_LABELED_BODY(NODE, R) \
250 TREE_OPERAND (LOOP_EXPR_BODY_MAIN_BLOCK (NODE), (R ? 0 : 1))
251 /* And here is the loop's real body */
252 #define LOOP_EXPR_BODY_BODY_EXPR(NODE, R) \
253 LABELED_BLOCK_BODY (LOOP_EXPR_BODY_LABELED_BODY(NODE, R))
255 /* Does a loop have a label ? */
256 #define LOOP_HAS_LABEL_P(LOOP) \
257 (ctxp->current_labeled_block \
258 && LABELED_BLOCK_BODY (ctxp->current_labeled_block) == (LOOP))
260 /* Same operation than the one performed above, but considering the
261 previous labeled block */
262 #define LOOP_HAS_LABEL_SKIP_P(LOOP) \
263 (ctxp->current_labeled_block \
264 && TREE_CHAIN (ctxp->current_labeled_block) \
265 && LABELED_BLOCK_BODY (TREE_CHAIN (ctxp->current_labeled_block)) == (LOOP))
267 #define PUSH_LABELED_BLOCK(B) \
269 TREE_CHAIN (B) = ctxp->current_labeled_block; \
270 ctxp->current_labeled_block = (B); \
272 #define POP_LABELED_BLOCK() \
273 ctxp->current_labeled_block = TREE_CHAIN (ctxp->current_labeled_block)
275 #define PUSH_LOOP(L) \
277 TREE_CHAIN (L) = ctxp->current_loop; \
278 ctxp->current_loop = (L); \
280 #define POP_LOOP() ctxp->current_loop = TREE_CHAIN (ctxp->current_loop)
282 #define PUSH_EXCEPTIONS(E) \
283 currently_caught_type_list = \
284 tree_cons (NULL_TREE, (E), currently_caught_type_list);
286 #define POP_EXCEPTIONS() \
287 currently_caught_type_list = TREE_CHAIN (currently_caught_type_list)
289 /* Check that we're inside a try block. */
290 #define IN_TRY_BLOCK_P() \
291 (currently_caught_type_list \
292 && ((TREE_VALUE (currently_caught_type_list) != \
293 DECL_FUNCTION_THROWS (current_function_decl)) \
294 || TREE_CHAIN (currently_caught_type_list)))
296 /* Check that we have exceptions in E. */
297 #define EXCEPTIONS_P(E) ((E) ? TREE_VALUE (E) : NULL_TREE)
299 /* Invocation modes, as returned by invocation_mode (). */
308 /* We need the resolution stuff only if we compile jc1 */
311 /* Unresolved type identifiers handling. When we process the source
312 code, we blindly accept an unknown type identifier and try to
313 resolve it later. When an unknown type identifier is encountered
314 and used, we record in a struct jdep element what the incomplete
315 type is and what it should patch. Later, java_complete_class will
316 process all classes known to have unresolved type
317 dependencies. Within each of these classes, this routine will
318 process unresolved type dependencies (JDEP_TO_RESOLVE), patch what
319 needs to be patched in the dependent tree node (JDEP_GET_PATCH,
320 JDEP_APPLY_PATCH) and perform other actions dictated by the context
321 of the patch (JDEP_KIND). The ideas are: we patch only what needs
322 to be patched, and with java_complete_class called at the right
323 time, we will start processing incomplete function bodies tree
324 nodes with everything external to function's bodies already
325 completed, it makes things much simpler. */
328 JDEP_NO_PATCH, /* Must be first */
329 JDEP_SUPER, /* Patch the type of one type
330 supertype. Requires some check
332 JDEP_FIELD, /* Patch the type of a class field */
334 /* JDEP_{METHOD,METHOD_RETURN,METHOD_END} to be kept in order */
335 JDEP_METHOD, /* Mark the beginning of the patching
336 of a method declaration, including
338 JDEP_METHOD_RETURN, /* Mark the beginning of the patching
339 of a method declaration. Arguments
340 aren't patched, only the returned
342 JDEP_METHOD_END, /* Mark the end of the patching of a
343 method declaration. It indicates
344 that it's time to compute and
345 install a new signature */
347 JDEP_INTERFACE, /* Patch the type of a Class/interface
349 JDEP_VARIABLE, /* Patch the type of a variable declaration */
350 JDEP_PARM, /* Patch the type of a parm declaration */
351 JDEP_TYPE, /* Patch a random tree node type,
352 without the need for any specific
354 JDEP_EXCEPTION, /* Patch exceptions specified by `throws' */
357 typedef struct _jdep {
358 #ifdef ONLY_INT_FIELDS
359 int kind : 8; /* Type of patch */
361 enum jdep_code kind : 8;
364 int flag0 : 1; /* Some flags */
365 tree decl; /* Tied decl/or WFL */
366 tree solv; /* What to solve */
367 tree wfl; /* Where thing to resolve where found */
368 tree misc; /* Miscellaneous info (optional). */
369 tree *patch; /* Address of a location to patch */
370 struct _jdep *next; /* Linked list */
374 #define JDEP_DECL(J) ((J)->decl)
375 #define JDEP_DECL_WFL(J) ((J)->decl)
376 #define JDEP_KIND(J) ((J)->kind)
377 #define JDEP_SOLV(J) ((J)->solv)
378 #define JDEP_WFL(J) ((J)->wfl)
379 #define JDEP_MISC(J) ((J)->misc)
380 #define JDEP_CLASS(J) ((J)->class)
381 #define JDEP_APPLY_PATCH(J,P) (*(J)->patch = (P))
382 #define JDEP_GET_PATCH(J) ((J)->patch)
383 #define JDEP_CHAIN(J) ((J)->next)
384 #define JDEP_TO_RESOLVE(J) ((J)->solv)
385 #define JDEP_RESOLVED_DECL(J) ((J)->solv)
386 #define JDEP_RESOLVED(J, D) ((J)->solv = D)
387 #define JDEP_RESOLVED_P(J) \
388 (!(J)->solv || TREE_CODE ((J)->solv) != POINTER_TYPE)
390 typedef struct _jdeplist {
393 struct _jdeplist *next;
395 static jdeplist *reverse_jdep_list ();
397 #endif /* JC1_LITE */
399 #define CLASSD_FIRST(CD) ((CD)->first)
400 #define CLASSD_LAST(CD) ((CD)->last)
401 #define CLASSD_CHAIN(CD) ((CD)->next)
403 #define JDEP_INSERT(L,J) \
406 (L)->last = (L)->first = (J); \
409 JDEP_CHAIN ((L)->last) = (J); \
414 /* if TYPE can't be resolved, obtain something suitable for its
415 resolution (TYPE is saved in SAVE before being changed). and set
416 CHAIN to 1. Otherwise, type is set to something usable. CHAIN is
417 usually used to determine that a new DEP must be installed on TYPE.
418 Note that when compiling java.lang.Object, references to Object are
420 #define SET_TYPE_FOR_RESOLUTION(TYPE, SAVE, CHAIN) \
422 tree returned_type; \
424 if (TREE_TYPE (ctxp->current_parsed_class) == object_type_node \
425 && TREE_CODE (TYPE) == EXPR_WITH_FILE_LOCATION \
426 && EXPR_WFL_NODE (TYPE) == unqualified_object_id_node) \
427 (TYPE) = object_type_node; \
430 if (unresolved_type_p (type, &returned_type)) \
433 (TYPE) = returned_type; \
437 (TYPE) = obtain_incomplete_type (TYPE); \
443 /* Promote a type if it won't be registered as a patch */
444 #define PROMOTE_RECORD_IF_COMPLETE(TYPE, IS_INCOMPLETE) \
446 if (!(IS_INCOMPLETE) && TREE_CODE (TYPE) == RECORD_TYPE) \
447 (TYPE) = promote_type (TYPE); \
450 /* Insert a DECL in the current block */
451 #define BLOCK_CHAIN_DECL(NODE) \
453 TREE_CHAIN ((NODE)) = \
454 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)); \
455 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) = (NODE); \
458 /* For an artificial BLOCK (created to house a local variable declaration not
459 at the start of an existing block), the parent block; otherwise NULL. */
460 #define BLOCK_EXPR_ORIGIN(NODE) BLOCK_ABSTRACT_ORIGIN(NODE)
462 /* Merge an other line to the source line number of a decl. Used to
463 remember function's end. */
464 #define DECL_SOURCE_LINE_MERGE(DECL,NO) DECL_SOURCE_LINE(DECL) |= (NO << 16)
466 /* Retrieve those two info separately. */
467 #define DECL_SOURCE_LINE_FIRST(DECL) (DECL_SOURCE_LINE(DECL) & 0x0000ffff)
468 #define DECL_SOURCE_LINE_LAST(DECL) (DECL_SOURCE_LINE(DECL) >> 16)
470 /* Build a WFL for expression nodes */
471 #define BUILD_EXPR_WFL(NODE, WFL) \
472 build_expr_wfl ((NODE), input_filename, EXPR_WFL_LINENO ((WFL)), \
473 EXPR_WFL_COLNO ((WFL)))
475 #define EXPR_WFL_QUALIFICATION(WFL) TREE_OPERAND ((WFL), 1)
476 #define QUAL_WFL(NODE) TREE_PURPOSE (NODE)
477 #define QUAL_RESOLUTION(NODE) TREE_VALUE (NODE)
478 #define QUAL_DECL_TYPE(NODE) GET_SKIP_TYPE (NODE)
480 #define GET_SKIP_TYPE(NODE) \
481 (TREE_CODE (TREE_TYPE (NODE)) == POINTER_TYPE ? \
482 TREE_TYPE (TREE_TYPE (NODE)): TREE_TYPE (NODE))
484 /* Handy macros for the walk operation */
485 #define COMPLETE_CHECK_OP(NODE, N) \
487 TREE_OPERAND ((NODE), (N)) = \
488 java_complete_tree (TREE_OPERAND ((NODE), (N))); \
489 if (TREE_OPERAND ((NODE), (N)) == error_mark_node) \
490 return error_mark_node; \
492 #define COMPLETE_CHECK_OP_0(NODE) COMPLETE_CHECK_OP(NODE, 0)
493 #define COMPLETE_CHECK_OP_1(NODE) COMPLETE_CHECK_OP(NODE, 1)
494 #define COMPLETE_CHECK_OP_2(NODE) COMPLETE_CHECK_OP(NODE, 2)
496 /* Building invocations: append(ARG) and StringBuffer(ARG) */
497 #define BUILD_APPEND(ARG) \
498 ((JSTRING_TYPE_P (TREE_TYPE (ARG)) || JPRIMITIVE_TYPE_P (TREE_TYPE (ARG))) \
499 ? build_method_invocation (wfl_append, \
500 ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE)\
501 : build_method_invocation (wfl_append, \
502 ARG ? build_tree_list (NULL, \
503 build1 (CONVERT_EXPR, \
507 #define BUILD_STRING_BUFFER(ARG) \
508 build_new_invocation (wfl_string_buffer, \
509 (ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE))
511 /* For exception handling, build diverse function calls */
512 #define BUILD_ASSIGN_EXCEPTION_INFO(WHERE, TO) \
514 (WHERE) = build (MODIFY_EXPR, void_type_node, (TO), \
515 soft_exceptioninfo_call_node); \
516 TREE_SIDE_EFFECTS (WHERE) = 1; \
519 #define BUILD_THROW(WHERE, WHAT) \
521 (WHERE) = build (CALL_EXPR, void_type_node, \
522 build_address_of (throw_node), \
523 build_tree_list (NULL_TREE, (WHAT)), NULL_TREE); \
524 TREE_SIDE_EFFECTS ((WHERE)) = 1; \
527 /* Set wfl_operator for the most accurate error location */
528 #define SET_WFL_OPERATOR(WHICH, NODE, WFL) \
529 EXPR_WFL_LINECOL (WHICH) = \
530 (TREE_CODE (WFL) == EXPR_WITH_FILE_LOCATION ? \
531 EXPR_WFL_LINECOL (WFL) : EXPR_WFL_LINECOL (NODE))
533 #define PATCH_METHOD_RETURN_ERROR() \
536 *ret_decl = NULL_TREE; \
537 return error_mark_node; \
540 /* Convenient macro to check. Assumes that CLASS is a CLASS_DECL. */
541 #define CHECK_METHODS(CLASS) \
543 if (CLASS_INTERFACE ((CLASS))) \
544 java_check_abstract_methods ((CLASS)); \
546 java_check_regular_methods ((CLASS)); \
549 /* Using and reseting the @deprecated tag flag */
550 #define CHECK_DEPRECATED(DECL) \
552 if (ctxp->deprecated) \
553 DECL_DEPRECATED (DECL) = 1; \
554 ctxp->deprecated = 0; \
557 /* Register an import */
558 #define REGISTER_IMPORT(WHOLE, NAME) \
560 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P ((NAME)) = 1; \
561 node = build_tree_list ((WHOLE), (NAME)); \
562 TREE_CHAIN (node) = ctxp->import_list; \
563 ctxp->import_list = node; \
566 /* Macro to access the osb (opening square bracket) count */
567 #define CURRENT_OSB(C) (C)->osb_number [(C)->osb_depth]
569 /* Parser context data structure. */
572 char *filename; /* Current filename */
573 FILE *finput; /* Current file input stream */
574 struct parser_ctxt *next;
576 struct java_line *p_line, *c_line; /* Previous and current line */
577 java_lc elc; /* Error's line column info */
578 unicode_t unget_utf8_value; /* An unget utf8 value */
579 int ccb_indent; /* Keep track of {} indent, lexer */
580 int first_ccb_indent1; /* First { at ident level 1 */
581 int last_ccb_indent1; /* Last } at ident level 1 */
582 int parser_ccb_indent; /* Keep track of {} indent, parser */
583 int osb_depth; /* Current depth of [ in an expression */
584 int osb_limit; /* Limit of this depth */
585 int *osb_number; /* Keep track of ['s */
586 int minus_seen; /* Integral literal overflow */
587 int lineno; /* Current lineno */
588 int java_error_flag; /* Report error when true */
589 int deprecated; /* @deprecated tag seen */
591 /* This section is defined only if we compile jc1 */
593 tree modifier_ctx [11]; /* WFL of modifiers */
594 tree current_class; /* Current class */
595 tree current_function_decl; /* Current function decl, save/restore */
597 JCF *current_jcf; /* CU jcf */
599 int prevent_ese; /* Prevent expression statement error */
600 int class_err; /* Flag to report certain errors */
602 int formal_parameter_number; /* Number of parameters found */
603 int interface_number; /* # itfs declared to extend an itf def */
605 tree package; /* Defined package ID */
607 /* Those tow list are saved accross file traversal */
608 tree incomplete_class; /* List of non-complete classes */
609 tree gclass_list; /* All classes seen from source code */
611 /* These two lists won't survive file traversal */
612 tree class_list; /* List of classes in a CU */
613 jdeplist *classd_list; /* Classe dependencies in a CU */
615 tree current_parsed_class; /* Class currently parsed */
616 tree current_parsed_class_un; /* Curr. parsed class unqualified name */
618 tree non_static_initialized; /* List of non static initialized fields */
619 tree static_initialized; /* List of static non final initialized */
621 tree import_list; /* List of import */
622 tree import_demand_list; /* List of import on demand */
624 tree current_loop; /* List of the currently nested
626 tree current_labeled_block; /* List of currently nested
629 int pending_block; /* Pending block to close */
631 int explicit_constructor_p; /* True when processing an explicit
632 constructor. This flag is used to trap
633 illegal argument usage during an
634 explicit constructor invocation. */
635 #endif /* JC1_LITE */
639 void safe_layout_class PROTO ((tree));
640 void java_complete_class PROTO ((void));
641 void java_check_circular_reference PROTO ((void));
642 void java_check_final PROTO ((void));
643 void java_layout_classes PROTO ((void));
644 tree java_method_add_stmt PROTO ((tree, tree));
645 char *java_get_line_col PROTO ((char *, int, int));
646 void java_expand_switch PROTO ((tree));
647 int java_report_errors PROTO (());
648 extern tree do_resolve_class PROTO ((tree, tree, tree));
651 /* Always in use, no matter what you compile */
652 void java_push_parser_context PROTO ((void));
653 void java_pop_parser_context PROTO ((int));
654 void java_init_lex PROTO ((void));
655 int yyparse PROTO ((void));
657 void yyerror PROTO ((char *));