OSDN Git Service

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