OSDN Git Service

2000-03-06 Bryce McKinlay <bryce@albatross.co.nz>
[pf3gnuchains/gcc-fork.git] / gcc / java / java-tree.h
1 /* Definitions for parsing and type checking for the GNU compiler for
2    the Java(TM) language.
3    Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
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)
10 any later version.
11
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.
16
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.  
21
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.  */
25
26 /* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */
27
28 #include "hash.h"
29
30 /* Java language-specific tree codes.  */
31 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
32 enum java_tree_code {
33   __DUMMY = LAST_AND_UNUSED_TREE_CODE,
34 #include "java-tree.def"
35   LAST_JAVA_TREE_CODE
36 };
37 #undef DEFTREECODE
38
39 struct JCF;
40
41 /* Usage of TREE_LANG_FLAG_?:
42    0: IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (in IDENTIFIER_NODE)
43       RESOLVE_EXPRESSION_NAME_P (in EXPR_WITH_FILE_LOCATION)
44       IS_FOR_LOOP_P (in LOOP_EXPR)
45    1: CLASS_HAS_SUPER_FLAG (in TREE_VEC).
46       IS_A_CLASSFILE_NAME (in IDENTIFIER_NODE)
47       COMPOUND_ASSIGN_P (in EXPR (binop_*))
48    2: RETURN_MAP_ADJUSTED (in TREE_VEC).
49       QUALIFIED_P (in IDENTIFIER_NODE)
50       PRIMARY_P (in EXPR_WITH_FILE_LOCATION)
51       MODIFY_EXPR_FROM_INITIALIZATION_P (in MODIFY_EXPR)
52    3: IS_AN_IMPORT_ON_DEMAND_P (in IDENTIFIER_NODE)
53       RESOLVE_PACKAGE_NAME_P (in EXPR_WITH_FILE_LOCATION)
54       SWITCH_HAS_DEFAULT (in SWITCH_EXPR)
55    4: IS_A_COMMAND_LINE_FILENAME_P (in IDENTIFIER_NODE)
56       RESOLVE_TYPE_NAME_P (in EXPR_WITH_FILE_LOCATION)
57       CALL_USING_SUPER (in CALL_EXPR)
58    5: HAS_BEEN_ALREADY_PARSED_P (in IDENTIFIER_NODE)
59       IS_BREAK_STMT_P (in EXPR_WITH_FILE_LOCATION)
60       IS_CRAFTED_STRING_BUFFER_P (in CALL_EXPR)
61    6: CAN_COMPLETE_NORMALLY (in statement nodes).
62
63    Usage of TYPE_LANG_FLAG_?:
64    1: TYPE_ARRAY_P (in RECORD_TYPE).
65    2: CLASS_LOADED_P (in RECORD_TYPE).
66    3: CLASS_FROM_SOURCE_P (in RECORD_TYPE).
67    4: CLASS_P (in RECORD_TYPE).
68    5: CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (in RECORD_TYPE)
69    6: CLASS_HAS_FINIT_P (in RECORD_TYPE)
70
71    Usage of DECL_LANG_FLAG_?:
72    0: METHOD_DEPRECATED (in FUNCTION_DECL).
73       FIELD_DEPRECATED (in FIELD_DECL).
74       CLASS_DEPRECATED (in TYPE_DECL).
75    1: METHOD_PUBLIC (in FUNCTION_DECL).
76       FIELD_PUBLIC (in FIELD_DECL).
77       CLASS_PUBLIC (in TYPE_DECL).
78    2: METHOD_STATIC (in FUNCTION_DECL).
79       (But note that FIELD_STATIC uses TREE_STATIC!)
80       CLASS_COMPLETE_P (in TYPE_DECL)
81    3: METHOD_FINAL (in FUNCTION_DECL)
82       FIELD_FINAL (in FIELD_DECL)
83       CLASS_FINAL (in TYPE_DECL)
84    4: METHOD_SYNCHRONIZED (in FUNCTION_DECL).
85       LABEL_IN_SUBR (in LABEL_DECL)
86       CLASS_INTERFACE (in TYPE_DECL)
87       FIELD_VOLATILE (int FIELD_DECL)
88    5: METHOD_ABSTRACT (in FUNCTION_DECL).
89       LABEL_IS_SUBR_START (in LABEL_DECL)
90       CLASS_ABSTRACT (in TYPE_DECL)
91       FIELD_TRANSIENT (in FIELD_DECL)
92    6: METHOD_TRANSIENT (in FUNCTION_DECL)
93       LABEL_CHANGED (in LABEL_DECL)
94       CLASS_SUPER (in TYPE_DECL, ACC_SUPER flag)
95    7: DECL_CONSTRUCTOR_P (in FUNCTION_DECL).
96 */
97
98 /* True if the class whose TYPE_BINFO this is has a superclass.
99    (True of all classes except Object.) */
100 #define CLASS_HAS_SUPER_FLAG(BINFO) TREE_LANG_FLAG_1(BINFO)
101 #define CLASS_HAS_SUPER(TYPE) CLASS_HAS_SUPER_FLAG (TYPE_BINFO (TYPE))
102
103 /* Return the supertype of class TYPE, or NULL_TREE is it has none. */
104 #define CLASSTYPE_SUPER(TYPE) (CLASS_HAS_SUPER (TYPE) ? \
105   BINFO_TYPE (TREE_VEC_ELT (TYPE_BINFO_BASETYPES (TYPE), 0)) : NULL_TREE)
106
107 /* True if the class we are compiling is a .java source file;
108    false if it is a .class bytecode file. */
109 extern int compiling_from_source;
110
111 /* The class defined by the actual (main) file we are compiling. */
112 extern tree main_class;
113
114 /* The class we are currently processing. */
115 extern tree current_class;
116
117 /* List of all class DECLs seen so far.  */
118 extern tree all_class_list;
119
120 /* Nonzero if we should make is_compiled_class always return 1 for
121    appropriate classes that we're referencing.  */
122
123 extern int flag_assume_compiled;
124
125 extern int flag_emit_class_files;
126
127 /* When non zero, we emit xref strings. Values of the flag for xref
128    backends are defined in xref.h.  */
129
130 extern int flag_emit_xref;
131
132 /* When doing xrefs, tell when not to fold.   */
133 extern int do_not_fold;
134
135 /* Turned to 1 if -Wall was encountered. See lang.c for their meanings.  */
136 extern int flag_wall;
137 extern int flag_redundant;
138 extern int flag_not_overriding;
139 extern int flag_static_local_jdk1_1;
140
141 /* When non zero, call a library routine to do integer divisions. */
142 extern int flag_use_divide_subroutine;
143
144 /* When non zero, generate code for the Boehm GC.  */
145 extern int flag_use_boehm_gc;
146
147 /* The Java .class file that provides main_class;  the main input file. */
148 extern struct JCF *current_jcf;
149
150 typedef struct CPool constant_pool;
151
152 #define CONSTANT_ResolvedFlag 16
153
154 /* The cpool->data[i] for a ResolvedString points to a STRING_CST. */
155 #define CONSTANT_ResolvedString    (CONSTANT_String+CONSTANT_ResolvedFlag)
156
157 /* The cpool->data[i] for a ResolvedClass points to a RECORD_TYPE. */
158 #define CONSTANT_ResolvedClass     (CONSTANT_Class+CONSTANT_ResolvedFlag)
159
160 #define CPOOL_UTF(CPOOL, INDEX) ((tree) (CPOOL)->data[INDEX])
161
162 /* A NameAndType constant is represented as a TREE_LIST.
163    The type is the signature string (as an IDENTIFIER_NODE).  */
164
165 #define NAME_AND_TYPE_NAME(CPOOL, IDX) \
166   CPOOL_UTF(CPOOL, CPOOL_USHORT1(CPOOL, IDX))
167 #define NAME_AND_TYPE_SIGNATURE(CPOOL, IDX) \
168   CPOOL_UTF(CPOOL, CPOOL_USHORT2(CPOOL, IDX))
169
170 /* A FieldRef, MethodRef or InterfaceMethodRef constant
171    is represented as a TREE_LIST. */
172
173 #define COMPONENT_REF_CLASS_INDEX(CPOOL, IDX) CPOOL_USHORT1(CPOOL, IDX)
174 #define COMPONENT_REF_NAME_AND_TYPE(CPOOL, IDX) CPOOL_USHORT2(CPOOL, IDX)
175 #define COMPONENT_REF_NAME(CPOOL, IDX) \
176   NAME_AND_TYPE_NAME (CPOOL, COMPONENT_REF_NAME_AND_TYPE(CPOOL, IDX))
177 #define COMPONENT_REF_SIGNATURE(CPOOL, IDX) \
178   NAME_AND_TYPE_SIGNATURE (CPOOL, COMPONENT_REF_NAME_AND_TYPE(CPOOL, IDX))
179
180 /* "Promoted types" that are used for primitive types smaller
181    than int.  We could use int_type_node, but then we would lose
182    type information (such as needed for debugging). */
183 extern tree promoted_byte_type_node;
184 extern tree promoted_short_type_node;
185 extern tree promoted_char_type_node;
186 extern tree promoted_boolean_type_node;
187
188 extern tree byte_type_node;
189 extern tree short_type_node;
190 extern tree int_type_node;
191 extern tree long_type_node;
192
193 extern tree unsigned_byte_type_node;
194 extern tree unsigned_short_type_node;
195 extern tree unsigned_int_type_node;
196 extern tree unsigned_long_type_node;
197
198 extern tree boolean_type_node;
199
200 extern tree object_type_node;
201 extern tree unqualified_object_id_node;
202 extern tree object_ptr_type_node;
203 extern tree string_type_node;
204 extern tree string_ptr_type_node;
205 extern tree throwable_type_node;
206 extern tree runtime_exception_type_node;
207 extern tree error_exception_type_node;
208
209 extern tree *predef_filenames;
210 extern int predef_filenames_size;
211
212 extern tree byte_array_type_node;
213 extern tree short_array_type_node;
214 extern tree int_array_type_node;
215 extern tree long_array_type_node;
216 extern tree boolean_array_type_node;
217 extern tree char_array_type_node;
218 extern tree double_array_type_node;
219 extern tree float_array_type_node;
220 extern tree array_array_type_node;
221 extern tree object_array_type_node;
222 extern tree string_array_type_node;
223 extern tree TYPE_identifier_node;      /* "TYPE" */
224 extern tree init_identifier_node;      /* "<init>" */
225 extern tree clinit_identifier_node;      /* "<clinit>" */
226 extern tree finit_identifier_node;      /* "$finit$" */
227 extern tree void_signature_node;       /* "()V" */
228 extern tree length_identifier_node;  /* "length" */
229 extern tree this_identifier_node;  /* "this" */
230 extern tree super_identifier_node;  /* "super" */
231 extern tree continue_identifier_node;  /* "continue" */
232 extern tree one_elt_array_domain_type;
233 /* The type of the return address of a subroutine. */
234 extern tree return_address_type_node;
235
236 /* Nodes for boolean constants TRUE and FALSE. */
237 extern tree boolean_true_node, boolean_false_node;
238
239 /* Integer constants not declared in tree.h. */
240 extern tree long_zero_node;
241 extern tree float_zero_node;
242 extern tree double_zero_node;
243 extern tree integer_negative_one_node;
244 extern tree integer_two_node;
245 extern tree integer_four_node;
246 extern tree empty_stmt_node;
247
248 /* The type for struct methodtable. */
249 extern tree methodtable_type;
250 extern tree methodtable_ptr_type;
251
252 extern tree utf8const_type;
253 extern tree utf8const_ptr_type;
254
255 extern tree class_type_node;
256 extern tree class_ptr_type;
257 extern tree field_type_node;
258 extern tree constants_type_node;
259 extern tree dtable_type, dtable_ptr_type;
260 extern tree field_ptr_type_node;
261 extern tree field_info_union_node;
262 extern tree method_type_node;
263 extern tree method_ptr_type_node;
264 #define nativecode_ptr_type_node ptr_type_node
265
266 extern tree end_params_node;
267
268 /* References to internal libjava functions we use. */
269 extern tree alloc_object_node;
270 extern tree soft_instanceof_node;
271 extern tree soft_checkcast_node;
272 extern tree soft_initclass_node;
273 extern tree soft_newarray_node;
274 extern tree soft_anewarray_node;
275 extern tree soft_multianewarray_node;
276 extern tree soft_badarrayindex_node;
277 extern tree throw_node[];
278 extern tree soft_checkarraystore_node;
279 extern tree soft_monitorenter_node;
280 extern tree soft_monitorexit_node;
281 extern tree soft_lookupinterfacemethod_node;
282 extern tree soft_fmod_node;
283 extern tree soft_exceptioninfo_call_node;
284 extern tree soft_idiv_node;
285 extern tree soft_irem_node;
286 extern tree soft_ldiv_node;
287 extern tree soft_lrem_node;
288
289 extern tree access_flags_type_node;
290
291 extern tree class_dtable_decl;
292
293 /* They need to be reset before processing each class */
294 extern struct CPool *outgoing_cpool; 
295 extern tree current_constant_pool_data_ref;
296
297 extern tree wfl_operator;
298
299 struct lang_identifier
300 {
301   struct tree_identifier ignore;
302   tree global_value, local_value;
303
304   /* If non-NULL:  An ADDR_REF to a VAR_DECL that contains
305    * the Utf8Const representation of the identifier.  */
306   tree utf8_ref;
307 };
308
309 /* Macros for access to language-specific slots in an identifier.  */
310 /* UNless specifide, each of these slots contains a DECL node or null.  */
311
312 /* This represents the value which the identifier has in the
313    file-scope namespace.  */
314 #define IDENTIFIER_GLOBAL_VALUE(NODE)   \
315   (((struct lang_identifier *)(NODE))->global_value)
316 /* This represents the value which the identifier has in the current
317    scope.  */
318 #define IDENTIFIER_LOCAL_VALUE(NODE)    \
319   (((struct lang_identifier *)(NODE))->local_value)
320
321 /* Given an identifier NODE, get the corresponding (non-handle) class.
322    For get_identifier ("java.lang.Number"), the result is
323    the struct whose DECL_ASSEMBLER_NAME is "Classjava_lang_Number". */
324 #define IDENTIFIER_CLASS_VALUE(NODE) IDENTIFIER_GLOBAL_VALUE(NODE)
325
326 /* Given an identifier NODE, get the corresponding handle class.
327    For get_identifier ("java.lang.Number"), the result is
328    the struct whose DECL_ASSEMBLER_NAME is "Hjava_lang_Number". */
329 #define IDENTIFIER_HANDLECLASS_VALUE(NODE) ???
330
331 /* Given a signature of a reference (or array) type, or a method, return the
332    corresponding type (if one has been allocated).
333    Do not use for primitive types, since they may be ambiguous.
334    (E.g. is "I" a signature or a class name?) */
335 #define IDENTIFIER_SIGNATURE_TYPE(NODE) IDENTIFIER_GLOBAL_VALUE(NODE)
336
337 /* If non-NULL:  An ADDR_REF to a VAR_DECL that contains
338    the Utf8Const representation of the identifier.  */
339 #define IDENTIFIER_UTF8_REF(NODE) \
340   (((struct lang_identifier *)(NODE))->utf8_ref)
341
342 #define IDENTIFIER_UTF8_DECL(NODE) \
343   TREE_OPERAND((((struct lang_identifier *)(NODE))->utf8_ref), 0)
344
345 /* For a FUNCTION_DECL, if we are compiling a .class file, then this is
346    the position in the .class file of the method code.
347    Specifically, this is the code itself, not the code attribute. */
348 #define DECL_CODE_OFFSET(DECL) (DECL_LANG_SPECIFIC(DECL)->code_offset)
349 /* Similarly, the length of the bytecode. */
350 #define DECL_CODE_LENGTH(DECL) (DECL_LANG_SPECIFIC(DECL)->code_length)
351 /* Similarly, the position of the LineNumberTable attribute. */
352 #define DECL_LINENUMBERS_OFFSET(DECL) \
353   (DECL_LANG_SPECIFIC(DECL)->linenumbers_offset)
354 /* Similarly, the position of the LocalVariableTable attribute
355    (following the standard attribute header). */
356 #define DECL_LOCALVARIABLES_OFFSET(DECL) \
357   (DECL_LANG_SPECIFIC(DECL)->localvariables_offset)
358
359 #define DECL_MAX_LOCALS(DECL) (DECL_LANG_SPECIFIC(DECL)->max_locals)
360 #define DECL_MAX_STACK(DECL) (DECL_LANG_SPECIFIC(DECL)->max_stack)
361 /* Number of local variable slots needed for the arguments of this function. */
362 #define DECL_ARG_SLOT_COUNT(DECL) (DECL_LANG_SPECIFIC(DECL)->arg_slot_count)
363 /* List of checked thrown exceptions, as specified with the `throws'
364    keyword */
365 #define DECL_FUNCTION_THROWS(DECL) (DECL_LANG_SPECIFIC(DECL)->throws_list)
366 /* List of other constructors of the same class that this constructor
367    calls */
368 #define DECL_CONSTRUCTOR_CALLS(DECL) \
369   (DECL_LANG_SPECIFIC(DECL)->called_constructor)
370 /* Pointer to the function's current's COMPOUND_EXPR tree (while
371    completing its body) or the function's block */
372 #define DECL_FUNCTION_BODY(DECL) (DECL_LANG_SPECIFIC(DECL)->function_decl_body)
373 /* How specific the function is (for method selection - Java source
374    code front-end */
375 #define DECL_SPECIFIC_COUNT(DECL) DECL_ARG_SLOT_COUNT(DECL)
376 /* For each function decl, init_test_table contains a hash table whose
377    entries are keyed on class names, and whose values are local
378    boolean decls.  The variables are intended to be TRUE when the
379    class has been initialized in this function, and FALSE otherwise.  */
380 #define DECL_FUNCTION_INIT_TEST_TABLE(DECL) \
381   (DECL_LANG_SPECIFIC(DECL)->init_test_table)
382
383 /* In a LABEL_DECL, a TREE_VEC that saves the type_map at that point. */
384 #define LABEL_TYPE_STATE(NODE) (DECL_INITIAL (NODE))
385
386 /* In the label of a subroutine, a dummy label that records the
387    state following a merge of all the ret instructions in this subroutine. */
388 #define LABEL_RETURN_LABEL(DECL) DECL_ARGUMENTS(DECL)
389
390 /* In the label of a sub-routine, records the type state at return.
391  * A local may be TYPE_UNUSED, which means that the local is not
392  * used (stored to or loaded from) in this subroutine - at least for
393  * code that we have verified so far. */
394 #define LABEL_RETURN_TYPE_STATE(NODE) LABEL_TYPE_STATE (LABEL_RETURN_LABEL (NODE))
395
396 /* In a TREE_VEC for a LABEL_RETURN_TYPE_STATE, notes that
397    TREE_VEC_LENGTH has been adjust to the correct stack size. */
398 #define RETURN_MAP_ADJUSTED(NODE) TREE_LANG_FLAG_2(NODE)
399
400 /* In the label of a sub-routine, a chain of the return location labels. */
401 #define LABEL_RETURN_LABELS(node) DECL_RESULT (LABEL_RETURN_LABEL(node))
402
403 /* In a LABEL_DECL, the next pending label.
404    See pending_blocks in expr.c. */
405 #define LABEL_PENDING_CHAIN(NODE) DECL_RESULT(NODE)
406
407 /* In a LABEL_DECL, the corresponding bytecode program counter. */
408 #define LABEL_PC(NODE) ((NODE)->decl.u2.i)
409
410 /* Used during verification to mark the label has "changed". (See JVM Spec). */
411 #define LABEL_CHANGED(NODE) DECL_LANG_FLAG_6(NODE)
412
413 /* In a LABEL_DECL, true if we have verified instructions starting here. */
414 #define LABEL_VERIFIED(NODE) (instruction_bits[LABEL_PC(NODE)]&BCODE_VERIFIED)
415
416 /* True if this code is within a subroutine (target of a jsr). */
417 #define LABEL_IN_SUBR(NODE) DECL_LANG_FLAG_4(NODE)
418 /* True if this code is the start of a subroutine (target of a jsr). */
419 #define LABEL_IS_SUBR_START(NODE) DECL_LANG_FLAG_5(NODE)
420
421 /* In a LABEL_DECL, if LABEL_IN_SUBR(NODE), points to start of subroutine. */
422 #define LABEL_SUBR_START(NODE) DECL_ABSTRACT_ORIGIN(NODE)
423
424 /* In a LABEL_DECL that has LABEL_IS_SUBR_START, this points to the start
425    of surrounding subroutine in the case of a nested subroutine,
426    and NULL_TREE otherwise. */
427 #define LABEL_SUBR_CONTEXT(NODE) DECL_CONTEXT (LABEL_RETURN_LABEL (NODE))
428
429 /* The slot number for this local variable. */
430 #define DECL_LOCAL_SLOT_NUMBER(NODE) \
431   (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->slot_number)
432 /* The start (bytecode) pc for the valid range of this local variable. */
433 #define DECL_LOCAL_START_PC(NODE) \
434   (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->start_pc)
435 /* The end (bytecode) pc for the valid range of this local variable. */
436 #define DECL_LOCAL_END_PC(NODE) \
437   (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->end_pc)
438 /* For a VAR_DECLor PARM_DECL, used to chain decls with the same
439    slot_number in decl_map. */
440 #define DECL_LOCAL_SLOT_CHAIN(NODE) \
441   (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->slot_chain)
442
443 /* For a local VAR_DECL, holds the index into a words bitstring that
444    specifies if this decl is definitively assigned.
445    A DECL_BIT_INDEX of -1 means we no longer care. */
446 #define DECL_BIT_INDEX(DECL) (DECL_CHECK (DECL)->decl.u2.i)
447
448 /* DECL_LANG_SPECIFIC for FUNCTION_DECLs. */
449 struct lang_decl
450 {
451   /*  tree chain; not yet used. */
452   long code_offset;
453   int code_length;
454   long linenumbers_offset;
455   long localvariables_offset;
456   int arg_slots;
457   int max_locals, max_stack, arg_slot_count;
458   tree throws_list;             /* Exception specified by `throws' */
459   tree function_decl_body;      /* Hold all function's statements */
460   tree called_constructor;      /* When decl is a constructor, the
461                                    list of other constructor it calls. */
462   struct hash_table init_test_table;
463                                 /* Class initialization test variables.  */
464 };
465
466 /* init_test_table hash table entry structure.  */
467 struct init_test_hash_entry
468 {
469   struct hash_entry root;
470   tree init_test_decl;
471 };
472
473
474 /* DECL_LANG_SPECIFIC for VAR_DECL and PARM_DECL. */
475 struct lang_decl_var
476 {
477   int slot_number;
478   int start_pc;
479   int end_pc;
480   tree slot_chain;
481 };
482
483 struct lang_type
484 {
485   tree signature;
486   struct JCF *jcf;
487 };
488
489 #ifdef JAVA_USE_HANDLES
490 /* TYPE_BINFO_HANDLE points from a handle-class to its corresponding
491    non-handle-class, and vice verse. */
492
493 #define BINFO_HANDLE(NODE) TREE_VEC_ELT ((NODE), 6)
494
495 /* Given a RECORD_TYPE for a handle type, return the corresponding class. */
496 #define HANDLE_TO_CLASS_TYPE(HTYPE) BINFO_HANDLE (TYPE_BINFO (HTYPE))
497
498 /* Given a RECORD_TYPE for a class, return the corresponding handle type. */
499 #define CLASS_TO_HANDLE_TYPE(TYPE) BINFO_HANDLE (TYPE_BINFO (TYPE))
500 #else
501 #define HANDLE_TO_CLASS_TYPE(HTYPE) (HTYPE)
502 #define CLASS_TO_HANDLE_TYPE(TYPE) (TYPE)
503 #endif
504
505 #define JCF_u4 unsigned long
506 #define JCF_u2 unsigned short
507
508 extern void add_assume_compiled PARAMS ((const char *, int));
509 extern tree lookup_class PARAMS ((tree));
510 extern tree lookup_java_constructor PARAMS ((tree, tree));
511 extern tree lookup_java_method PARAMS ((tree, tree, tree));
512 extern tree lookup_argument_method PARAMS ((tree, tree, tree));
513 extern tree lookup_argument_method2 PARAMS ((tree, tree, tree));
514 extern tree promote_type PARAMS ((tree));
515 extern tree get_constant PARAMS ((struct JCF*, int));
516 extern tree get_name_constant PARAMS ((struct JCF*, int));
517 extern tree get_class_constant PARAMS ((struct JCF*, int));
518 extern tree parse_signature PARAMS ((struct JCF *jcf, int sig_index));
519 extern void jcf_parse PARAMS ((struct JCF*));
520 extern tree add_field PARAMS ((tree, tree, tree, int));
521 extern tree add_method PARAMS ((tree, int, tree, tree));
522 extern tree add_method_1 PARAMS ((tree, int, tree, tree));
523 extern tree make_class PARAMS ((void));
524 extern tree push_class PARAMS ((tree, tree));
525 extern tree unmangle_classname PARAMS ((const char *name, int name_length));
526 extern tree parse_signature_string PARAMS ((const unsigned char *, int));
527 extern tree get_type_from_signature PARAMS ((tree));
528 extern void layout_class PARAMS ((tree));
529 extern tree layout_class_method PARAMS ((tree, tree, tree, tree));
530 extern void layout_class_methods PARAMS ((tree));
531 extern tree build_class_ref PARAMS ((tree));
532 extern tree build_dtable_decl PARAMS ((tree));
533 extern tree build_internal_class_name PARAMS ((tree));
534 extern tree build_constants_constructor PARAMS ((void));
535 extern tree build_ref_from_constant_pool PARAMS ((int));
536 extern tree build_utf8_ref PARAMS ((tree));
537 extern tree ident_subst PARAMS ((const char*, int,
538                                 const char*, int, int, const char*));
539 extern tree identifier_subst PARAMS ((const tree,
540                                      const char *, int, int, const char *));
541 extern tree build_java_signature PARAMS ((tree));
542 extern tree build_java_argument_signature PARAMS ((tree));
543 extern void set_java_signature PARAMS ((tree, tree));
544 extern tree build_static_field_ref PARAMS ((tree));
545 extern tree build_address_of PARAMS ((tree));
546 extern tree find_local_variable PARAMS ((int index, tree type, int pc));
547 extern tree find_stack_slot PARAMS ((int index, tree type));
548 extern tree build_prim_array_type PARAMS ((tree, HOST_WIDE_INT));
549 extern tree build_java_array_type PARAMS ((tree, HOST_WIDE_INT));
550 extern int is_compiled_class PARAMS ((tree));
551 extern tree mangled_classname PARAMS ((const char*, tree));
552 extern tree lookup_label PARAMS ((int));
553 extern tree pop_type_0 PARAMS ((tree));
554 extern tree pop_type PARAMS ((tree));
555 extern void pop_argument_types PARAMS ((tree));
556 extern tree decode_newarray_type PARAMS ((int));
557 extern tree lookup_field PARAMS ((tree*, tree));
558 extern int is_array_type_p PARAMS ((tree));
559 extern HOST_WIDE_INT java_array_type_length PARAMS ((tree));
560 extern int read_class PARAMS ((tree));
561 extern void load_class PARAMS ((tree, int));
562
563 extern tree lookup_name PARAMS ((tree));
564 extern tree build_known_method_ref PARAMS ((tree, tree, tree, tree, tree));
565 extern tree build_class_init PARAMS ((tree, tree));
566 extern tree build_invokevirtual PARAMS ((tree, tree));
567 extern tree build_invokeinterface PARAMS ((tree, tree));
568 extern tree invoke_build_dtable PARAMS ((int, tree));
569 extern tree build_field_ref PARAMS ((tree, tree, tree));
570 extern void pushdecl_force_head PARAMS ((tree));
571 extern tree build_java_binop PARAMS ((enum tree_code, tree, tree, tree));
572 extern tree build_java_soft_divmod PARAMS ((enum tree_code, tree, tree, tree));
573 extern tree binary_numeric_promotion PARAMS ((tree, tree, tree *, tree *));
574 extern tree build_java_arrayaccess PARAMS ((tree, tree, tree));
575 extern tree build_newarray PARAMS ((int, tree));
576 extern tree build_anewarray PARAMS ((tree, tree));
577 extern tree build_new_array PARAMS ((tree, tree));
578 extern tree build_java_array_length_access PARAMS ((tree));
579 extern tree build_java_arraynull_check PARAMS ((tree, tree, tree));
580 extern tree create_label_decl PARAMS ((tree));
581 extern void push_labeled_block PARAMS ((tree));
582 extern tree prepare_eh_table_type PARAMS ((tree));
583 extern void java_set_exception_lang_code PARAMS ((void));
584 extern tree generate_name PARAMS ((void));
585 extern void pop_labeled_block PARAMS ((void));
586 extern const char *lang_printable_name PARAMS ((tree, int));
587 extern tree maybe_add_interface PARAMS ((tree, tree));
588 extern void set_super_info PARAMS ((int, tree, tree, int));
589 extern int get_access_flags_from_decl PARAMS ((tree));
590 extern int interface_of_p PARAMS ((tree, tree));
591 extern int inherits_from_p PARAMS ((tree, tree));
592 extern void complete_start_java_method PARAMS ((tree));
593 extern tree build_result_decl PARAMS ((tree));
594 extern void emit_handlers PARAMS ((void));
595 extern void init_outgoing_cpool PARAMS ((void));
596 extern void make_class_data PARAMS ((tree));
597 extern void register_class PARAMS ((void));
598 extern int alloc_name_constant PARAMS ((int, tree));
599 extern void emit_register_classes PARAMS ((void));
600 extern void lang_init_source PARAMS ((int));
601 extern void write_classfile PARAMS ((tree));
602 extern char *print_int_node PARAMS ((tree));
603 extern void parse_error_context PARAMS ((tree cl, const char *, ...))
604   ATTRIBUTE_PRINTF_2;
605 extern tree build_primtype_type_ref PARAMS ((const char *));
606 extern tree java_get_real_method_name PARAMS ((tree));
607 extern void finish_class PARAMS ((void));
608 extern void java_layout_seen_class_methods PARAMS ((void));
609 extern void check_for_initialization PARAMS ((tree));
610
611 extern tree pushdecl_top_level PARAMS ((tree));
612 extern int alloc_class_constant PARAMS ((tree));
613 extern int unicode_mangling_length PARAMS ((const char *, int));
614 extern void init_expr_processing PARAMS ((void));
615 extern void push_super_field PARAMS ((tree, tree));
616 extern void init_class_processing PARAMS ((void));
617 extern int can_widen_reference_to PARAMS ((tree, tree));
618 extern int class_depth PARAMS ((tree));
619 extern int verify_jvm_instructions PARAMS ((struct JCF *, const unsigned char *, long));
620 extern void maybe_pushlevels PARAMS ((int));
621 extern void maybe_poplevels PARAMS ((int));
622 extern void force_poplevels PARAMS ((int));
623 extern int process_jvm_instruction PARAMS ((int, const unsigned char *, long));
624 extern void set_local_type PARAMS ((int, tree));
625 extern int merge_type_state PARAMS ((tree));
626 extern void push_type PARAMS ((tree));
627 extern void load_type_state PARAMS ((tree));
628 extern void add_interface PARAMS ((tree, tree));
629 extern void append_gpp_mangled_name PARAMS ((struct obstack *, const char *, int));
630 extern void append_gpp_mangled_classtype PARAMS ((struct obstack *, const char *));
631 extern void emit_unicode_mangled_name PARAMS ((struct obstack *, const char *, int));
632 extern tree force_evaluation_order PARAMS ((tree));
633 extern int verify_constant_pool PARAMS ((struct JCF *));
634 extern void start_java_method PARAMS ((tree));
635 extern void end_java_method PARAMS ((void));
636 extern void give_name_to_locals PARAMS ((struct JCF *));
637 extern void expand_byte_code PARAMS ((struct JCF *, tree));
638 extern int open_in_zip PARAMS ((struct JCF *, const char *, const char *, int));
639 extern void set_constant_value PARAMS ((tree, tree));
640 #ifdef jword
641 extern int find_constant1 PARAMS ((struct CPool *, int, jword));
642 extern int find_constant2 PARAMS ((struct CPool *, int, jword, jword));
643 #endif
644 extern int find_utf8_constant PARAMS ((struct CPool *, tree));
645 extern int find_string_constant PARAMS ((struct CPool *, tree));
646 extern int find_class_constant PARAMS ((struct CPool *, tree));
647 extern int find_fieldref_index PARAMS ((struct CPool *, tree));
648 extern int find_methodref_index PARAMS ((struct CPool *, tree));
649 extern void write_constant_pool PARAMS ((struct CPool *, unsigned char *, int));
650 extern int count_constant_pool_bytes PARAMS ((struct CPool *));
651 extern int encode_newarray_type PARAMS ((tree));
652 #ifdef uint64
653 extern void format_int PARAMS ((char *, jlong, int));
654 extern void format_uint PARAMS ((char *, uint64, int));
655 #endif
656 extern void jcf_trim_old_input PARAMS ((struct JCF *));
657 #ifdef BUFSIZ
658 extern void jcf_print_utf8 PARAMS ((FILE *, const unsigned char *, int));
659 extern void jcf_print_char PARAMS ((FILE *, int));
660 extern void jcf_print_utf8_replace PARAMS ((FILE *, const unsigned char *,
661                                            int, int, int));
662 # if JCF_USE_STDIO
663 extern char* open_class PARAMS ((char *, struct JCF *, FILE *, const char *));
664 # else
665 extern char* open_class PARAMS ((char *, struct JCF *, int, const char *));
666 # endif /* JCF_USE_STDIO */
667 #endif
668 void java_debug_context PARAMS ((void));
669 void safe_layout_class PARAMS ((tree));
670
671 extern tree get_boehm_type_descriptor PARAMS ((tree));
672
673 /* We use ARGS_SIZE_RTX to indicate that gcc/expr.h has been included
674    to declare `enum expand_modifier'. */
675 #if defined (TREE_CODE) && defined(RTX_CODE) && defined (HAVE_MACHINE_MODES) && defined (ARGS_SIZE_RTX)
676 struct rtx_def * java_lang_expand_expr PARAMS ((tree, rtx, enum machine_mode,
677                                                enum expand_modifier)); 
678 #endif /* TREE_CODE && RTX_CODE && HAVE_MACHINE_MODES && ARGS_SIZE_RTX */
679
680 /* Access flags etc for a method (a FUNCTION_DECL): */
681
682 #define METHOD_PUBLIC(DECL) DECL_LANG_FLAG_1 (DECL)
683 #define METHOD_PRIVATE(DECL) TREE_PRIVATE (DECL)
684 #define METHOD_PROTECTED(DECL) TREE_PROTECTED (DECL)
685 #define METHOD_STATIC(DECL) DECL_LANG_FLAG_2 (DECL)
686 #define METHOD_FINAL(DECL) DECL_LANG_FLAG_3 (DECL)
687 #define METHOD_SYNCHRONIZED(DECL) DECL_LANG_FLAG_4 (DECL)
688 #define METHOD_NATIVE(DECL) DECL_EXTERNAL(DECL)
689 #define METHOD_ABSTRACT(DECL) DECL_LANG_FLAG_5 (DECL)
690 #define METHOD_TRANSIENT(DECL) DECL_LANG_FLAG_6 (DECL)
691
692 #define DECL_CONSTRUCTOR_P(DECL) DECL_LANG_FLAG_7(DECL)
693
694 /* Access flags etc for a variable/field (a FIELD_DECL): */
695
696 #define FIELD_PRIVATE(DECL) TREE_PRIVATE (DECL)
697 #define FIELD_PROTECTED(DECL) TREE_PROTECTED (DECL)
698 #define FIELD_PUBLIC(DECL) DECL_LANG_FLAG_1 (DECL)
699 #define FIELD_STATIC(DECL) TREE_STATIC (DECL)
700 #define FIELD_FINAL(DECL) DECL_LANG_FLAG_3 (DECL)
701 #define FIELD_VOLATILE(DECL) DECL_LANG_FLAG_4 (DECL)
702 #define FIELD_TRANSIENT(DECL) DECL_LANG_FLAG_5 (DECL)
703
704 /* Access flags etc for a class (a TYPE_DECL): */
705
706 #define CLASS_PUBLIC(DECL) DECL_LANG_FLAG_1 (DECL)
707 #define CLASS_FINAL(DECL) DECL_LANG_FLAG_3 (DECL)
708 #define CLASS_INTERFACE(DECL) DECL_LANG_FLAG_4 (DECL)
709 #define CLASS_ABSTRACT(DECL) DECL_LANG_FLAG_5 (DECL)
710 #define CLASS_SUPER(DECL) DECL_LANG_FLAG_6 (DECL)
711
712 /* @deprecated marker flag on methods, fields and classes */
713
714 #define METHOD_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
715 #define FIELD_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
716 #define CLASS_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
717 #define DECL_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
718
719 /* The number of virtual methods in this class's dispatch table.
720  Does not include initial two dummy entries (one points to the
721  Class object, and the other is for G++ -fvtable-thunks compatibility). */
722 #define TYPE_NVIRTUALS(TYPE) TYPE_BINFO_VIRTUALS (TYPE)
723
724 /* A TREE_VEC (indexed by DECL_VINDEX) containing this class's
725    virtual methods. */
726 #define TYPE_VTABLE(TYPE) TYPE_BINFO_VTABLE(TYPE)
727
728 /* Use CLASS_LOADED_P? FIXME */
729 #define CLASS_COMPLETE_P(DECL) DECL_LANG_FLAG_2 (DECL) 
730
731 /* This maps a bytecode offset (PC) to various flags,
732    listed below (starting with BCODE_). */
733 extern char *instruction_bits;
734
735 /* True iff the byte is the start of an instruction. */
736 #define BCODE_INSTRUCTION_START 1
737
738 /* True iff there is a jump to this location. */
739 #define BCODE_JUMP_TARGET 2
740
741 /* True iff there is a return to this location.
742    (I.e. the preceedng instruction was a call.) */
743 #define BCODE_RETURN_TARGET 4
744
745 /* True iff this is the start of an exception handler. */
746 #define BCODE_EXCEPTION_TARGET 16
747
748 /* True iff there is a jump to this location (and it needs a label). */
749 #define BCODE_TARGET \
750   (BCODE_JUMP_TARGET|BCODE_RETURN_TARGET \
751    | BCODE_EXCEPTION_TARGET)
752
753 /* True iff there is an entry in the linenumber table for this location. */
754 #define BCODE_HAS_LINENUMBER 32
755
756 /* True iff there is more than one entry in the linenumber table for
757    this location.  (This probably does not make much sense.)  */
758 #define BCODE_HAS_MULTI_LINENUMBERS 64
759
760 /* True if this instruction has been verified. */
761 #define BCODE_VERIFIED 8
762
763 /* A pointer to the line number table of the current method. */
764 extern const unsigned char *linenumber_table;
765 /* The length (in items) of the line number table. */
766 extern int linenumber_count;
767
768 /* In type_map, means that slot is uninitialized or otherwise unusable. */
769 #define TYPE_UNKNOWN NULL_TREE
770
771 /* In type_map, means the second half of a 64-bit double or long. */
772 #define TYPE_SECOND void_type_node
773
774 /* In type_map, means the null type (i.e. type of a null reference). */ 
775 #define TYPE_NULL ptr_type_node
776
777 /* In a type map means the type the address subroutine return address. */
778 #define TYPE_RETURN_ADDR return_address_type_node
779
780 /* In a subroutine's return type map, indicates that the slot was neither
781    used nor set in the subroutine. */
782 #define TYPE_UNUSED error_mark_node
783
784 /* A array mapping variable/stack slot index to the type current
785    in that variable/stack slot.
786    TYPE_UNKNOWN, TYPE_SECOND, and TYPE_NULL are special cases. */
787 extern tree *type_map;
788
789 /* Map a stack index to the type currently in that slot. */
790 #define stack_type_map (type_map+DECL_MAX_LOCALS(current_function_decl))
791
792 /* True iff TYPE takes two variable/stack slots. */
793 #define TYPE_IS_WIDE(TYPE) \
794   ((TYPE) == double_type_node || (TYPE) == long_type_node)
795
796 /* True iff TYPE is a Java array type. */
797 #define TYPE_ARRAY_P(TYPE) TYPE_LANG_FLAG_1 (TYPE)
798
799 /* If FUNCTION_TYPE or METHOD_TYPE: cache for build_java_argument_signature. */
800 #define TYPE_ARGUMENT_SIGNATURE(TYPE) TYPE_VFIELD(TYPE)
801
802 /* Given an array type, give the type of the elements. */
803 /* FIXME this use of TREE_TYPE conflicts with something or other. */
804 #define TYPE_ARRAY_ELEMENT(ATYPE) TREE_TYPE(ATYPE)
805
806 /* True if class TYPE has been loaded. */
807 #define CLASS_LOADED_P(TYPE) TYPE_LANG_FLAG_2 (TYPE)
808
809 /* True if class TYPE was defined in Java source code. */
810 #define CLASS_FROM_SOURCE_P(TYPE) TYPE_LANG_FLAG_3 (TYPE)
811
812 /* True of a RECORD_TYPE of a class/interface type (not array type) */
813 #define CLASS_P(TYPE) TYPE_LANG_FLAG_4 (TYPE)
814
815 /* True if class TYPE was defined in a Java source file compiled. */
816 #define CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P(TYPE) \
817   TYPE_LANG_FLAG_5 (TYPE)
818
819 /* True if class TYPE has a field initializer $finit$ function */
820 #define CLASS_HAS_FINIT_P(TYPE) TYPE_LANG_FLAG_6 (TYPE)
821
822 /* True if identifier ID was seen while processing a single type import stmt */
823 #define IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P(ID) TREE_LANG_FLAG_0 (ID)
824
825 /* True if identifier ID was seen while processing an import statement */
826 #define IS_A_CLASSFILE_NAME(ID) TREE_LANG_FLAG_1 (ID)
827
828 /* True if ID is a qualified named (contains . or /) */
829 #define QUALIFIED_P(ID) TREE_LANG_FLAG_2 (ID)
830
831 /* True if ID is an already processed import on demand */
832 #define IS_AN_IMPORT_ON_DEMAND_P(ID) TREE_LANG_FLAG_3 (ID)
833
834 /* True if ID is a command-line specified filename */
835 #define IS_A_COMMAND_LINE_FILENAME_P(ID) TREE_LANG_FLAG_4 (ID)
836
837 /* True if filename ID has already been parsed */
838 #define HAS_BEEN_ALREADY_PARSED_P(ID) TREE_LANG_FLAG_5 (ID)
839
840 /* True if EXPR is RHS sub-tree of a compound assign expression */
841 #define COMPOUND_ASSIGN_P(EXPR) TREE_LANG_FLAG_1 (EXPR)
842
843 /* True if a SWITCH_EXPR has a DEFAULT_EXPR. */
844 #define SWITCH_HAS_DEFAULT(NODE) TREE_LANG_FLAG_3 (NODE)
845
846 /* True if EXPR (a WFL in that case) was created after the
847    reduction of PRIMARY . XXX */
848 #define PRIMARY_P(EXPR) TREE_LANG_FLAG_2 (EXPR)
849
850 /* True if EXPR (a MODIFY_EXPR in that case) is the result of variable
851    initialization during its declaration */
852 #define MODIFY_EXPR_FROM_INITIALIZATION_P(EXPR) TREE_LANG_FLAG_2 (EXPR)
853
854 /* True if EXPR (a WFL in that case) resolves into an expression name */
855 #define RESOLVE_EXPRESSION_NAME_P(WFL) TREE_LANG_FLAG_0 (WFL)
856
857 /* True if EXPR (a LOOP_EXPR in that case) is part of a for statement */
858 #define IS_FOR_LOOP_P(EXPR) TREE_LANG_FLAG_0 (EXPR)
859
860 /* True if EXPR (a WFL in that case) resolves into a package name */
861 #define RESOLVE_PACKAGE_NAME_P(WFL) TREE_LANG_FLAG_3 (WFL)
862
863 /* True if EXPR (a WFL in that case) resolves into a type name */
864 #define RESOLVE_TYPE_NAME_P(WFL) TREE_LANG_FLAG_4 (WFL)
865
866 /* True if STMT (a WFL in that case) holds a BREAK statement */
867 #define IS_BREAK_STMT_P(WFL) TREE_LANG_FLAG_5 (WFL)
868
869 /* True if EXPR (a CALL_EXPR in that case) is a crafted StringBuffer */
870 #define IS_CRAFTED_STRING_BUFFER_P(EXPR) TREE_LANG_FLAG_5 (EXPR)
871
872 /* If set in CALL_EXPR, the receiver is 'super'. */
873 #define CALL_USING_SUPER(EXPR) TREE_LANG_FLAG_4 (EXPR)
874
875 /* True if NODE (a statement) can complete normally. */
876 #define CAN_COMPLETE_NORMALLY(NODE) TREE_LANG_FLAG_6(NODE)
877
878 /* Add a FIELD_DECL to RECORD_TYPE RTYPE.
879    The field has name NAME (a char*), and type FTYPE.
880    Unless this is the first field, FIELD most hold the previous field.
881    FIELD is set to the newly created FIELD_DECL.
882
883    We set DECL_ARTIFICIAL so these fields get skipped by make_class_data
884    if compiling java.lang.Object or java.lang.Class. */
885
886 #define PUSH_FIELD(RTYPE, FIELD, NAME, FTYPE) \
887 { tree tmp_field = build_decl (FIELD_DECL, get_identifier(NAME), FTYPE); \
888   if (TYPE_FIELDS (RTYPE) == NULL_TREE) TYPE_FIELDS (RTYPE) = tmp_field; \
889   else TREE_CHAIN(FIELD) = tmp_field; \
890   DECL_CONTEXT (tmp_field) = RTYPE; \
891   DECL_ARTIFICIAL (tmp_field) = 1; \
892   FIELD = tmp_field; }
893
894 #define FINISH_RECORD(RTYPE) layout_type (RTYPE)
895
896 /* Start building a RECORD_TYPE constructor with a given TYPE in CONS. */
897 #define START_RECORD_CONSTRUCTOR(CONS, CTYPE) { \
898   CONS = build (CONSTRUCTOR, CTYPE, NULL_TREE, NULL_TREE);\
899   TREE_CHAIN(CONS) = TYPE_FIELDS (CTYPE); }
900
901 /* Append a field initializer to CONS for the dummy field for the inherited
902    fields.  The dummy field has the given VALUE, and the same type as the
903    super-class.   Must be specified before calls to PUSH_FIELD_VALUE. */
904
905 #define PUSH_SUPER_VALUE(CONS, VALUE) {\
906   tree field = TREE_CHAIN(CONS);\
907   if (DECL_NAME (field) != NULL_TREE) abort();\
908   CONSTRUCTOR_ELTS(CONS) = tree_cons (field, VALUE, CONSTRUCTOR_ELTS(CONS));\
909   TREE_CHAIN(CONS) = TREE_CHAIN (field); }
910
911 /* Append a field initializer to CONS for a field with the given VALUE.
912    NAME is a char* string used for error checking;
913    the initializer must be specified in order. */
914 #define PUSH_FIELD_VALUE(CONS, NAME, VALUE) {\
915   tree field = TREE_CHAIN(CONS);\
916   if (strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), NAME) != 0) abort();\
917   CONSTRUCTOR_ELTS(CONS) = tree_cons (field, VALUE, CONSTRUCTOR_ELTS(CONS));\
918   TREE_CHAIN(CONS) = TREE_CHAIN (field); }
919
920 /* Finish creating a record CONSTRUCTOR CONS. */
921 #define FINISH_RECORD_CONSTRUCTOR(CONS) \
922   CONSTRUCTOR_ELTS(CONS) = nreverse (CONSTRUCTOR_ELTS(CONS))
923
924 /* Macros on constructors invocations.  */
925 #define CALL_CONSTRUCTOR_P(NODE)                \
926   (TREE_CODE (NODE) == NEW_CLASS_EXPR || CALL_EXPLICIT_CONSTRUCTOR_P (NODE))
927
928 #define CALL_EXPLICIT_CONSTRUCTOR_P(NODE)                               \
929   (CALL_THIS_CONSTRUCTOR_P (NODE) || CALL_SUPER_CONSTRUCTOR_P (NODE))
930
931 #define CALL_THIS_CONSTRUCTOR_P(NODE)                                   \
932   (TREE_CODE (NODE) == CALL_EXPR                                        \
933    && EXPR_WFL_NODE (TREE_OPERAND (NODE, 0)) == this_identifier_node)
934
935 #define CALL_SUPER_CONSTRUCTOR_P(NODE)                                  \
936   (TREE_CODE (NODE) == CALL_EXPR                                        \
937    && EXPR_WFL_NODE (TREE_OPERAND (NODE, 0)) == super_identifier_node)
938
939 /* Using a FINALLY_EXPR node */
940 #define FINALLY_EXPR_LABEL(NODE) TREE_OPERAND ((NODE), 0)
941 #define FINALLY_EXPR_BLOCK(NODE) TREE_OPERAND ((NODE), 1)
942
943 #define BLOCK_EXPR_DECLS(NODE)  BLOCK_VARS(NODE)
944 #define BLOCK_EXPR_BODY(NODE)   BLOCK_SUBBLOCKS(NODE)
945
946 #define BUILD_MONITOR_ENTER(WHERE, ARG)                         \
947   {                                                             \
948     (WHERE) = build (CALL_EXPR, int_type_node,                  \
949                      build_address_of (soft_monitorenter_node), \
950                      build_tree_list (NULL_TREE, (ARG)),        \
951                      NULL_TREE);                                \
952     TREE_SIDE_EFFECTS (WHERE) = 1;                              \
953   }
954
955 #define BUILD_MONITOR_EXIT(WHERE, ARG)                          \
956   {                                                             \
957     (WHERE) = build (CALL_EXPR, int_type_node,                  \
958                      build_address_of (soft_monitorexit_node),  \
959                      build_tree_list (NULL_TREE, (ARG)),        \
960                      NULL_TREE);                                \
961     TREE_SIDE_EFFECTS (WHERE) = 1;                              \
962   }
963
964 /* Non zero if TYPE is an unchecked exception */
965 #define IS_UNCHECKED_EXCEPTION_P(TYPE)                          \
966   (inherits_from_p ((TYPE), runtime_exception_type_node)        \
967    || inherits_from_p ((TYPE), error_exception_type_node))
968
969 extern int java_error_count;                                    \
970
971 /* Make the current function where this macro is invoked report error
972    messages and and return, if any */
973 #define java_parse_abort_on_error()                                     \
974   {                                                                     \
975      if (java_error_count > save_error_count)                           \
976        return;                                                          \
977    }
978
979 #undef DEBUG_JAVA_BINDING_LEVELS