OSDN Git Service

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