OSDN Git Service

2007-04-21 Andrew Pinski <andrew_pinski@playstation.sony.com>
[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, 2001, 2002, 2003, 2004,
4    2005, 2006, 2007 Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.  
22
23 Java and all Java-based marks are trademarks or registered trademarks
24 of Sun Microsystems, Inc. in the United States and other countries.
25 The Free Software Foundation is independent of Sun Microsystems, Inc.  */
26
27 /* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */
28
29 #ifndef GCC_JAVA_TREE_H
30 #define GCC_JAVA_TREE_H
31
32 #include "hashtab.h"
33
34 /* Java language-specific tree codes.  */
35 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
36 enum java_tree_code {
37   __DUMMY = LAST_AND_UNUSED_TREE_CODE,
38 #include "java-tree.def"
39   LAST_JAVA_TREE_CODE
40 };
41 #undef DEFTREECODE
42
43 struct JCF;
44
45 /* Usage of TREE_LANG_FLAG_?:
46    2: QUALIFIED_P (in IDENTIFIER_NODE)
47       CLASS_FILE_P (in a TRANSLATION_UNIT_DECL in current_file_list)
48    3: HAS_FINALIZER (in RECORD_TYPE)
49    4: IS_A_COMMAND_LINE_FILENAME_P (in IDENTIFIER_NODE)
50       IS_ARRAY_LENGTH_ACCESS (in INDIRECT_REF)
51    5: HAS_BEEN_ALREADY_PARSED_P (in IDENTIFIER_NODE)
52    6: CAN_COMPLETE_NORMALLY (in statement nodes)
53
54    Usage of TYPE_LANG_FLAG_?:
55    1: TYPE_ARRAY_P (in RECORD_TYPE).
56    2: CLASS_PARSED_P (in RECORD_TYPE).
57    3: CLASS_FROM_SOURCE_P (in RECORD_TYPE).
58    4: CLASS_P (in RECORD_TYPE).
59    5: CLASS_FROM_CURRENTLY_COMPILED_P (in RECORD_TYPE)
60    6: CLASS_BEING_LAIDOUT (in RECORD_TYPE)
61
62    Usage of DECL_LANG_FLAG_?:
63    0: METHOD_DEPRECATED (in FUNCTION_DECL).
64       FIELD_DEPRECATED (in FIELD_DECL).
65       CLASS_DEPRECATED (in TYPE_DECL).
66    1: METHOD_PUBLIC (in FUNCTION_DECL).
67       FIELD_PUBLIC (in FIELD_DECL).
68       CLASS_PUBLIC (in TYPE_DECL).
69    2: METHOD_STATIC (in FUNCTION_DECL).
70       (But note that FIELD_STATIC uses TREE_STATIC!)
71       FIELD_SYNTHETIC (in FIELD_DECL)
72       CLASS_COMPLETE_P (in TYPE_DECL)
73    3: METHOD_FINAL (in FUNCTION_DECL)
74       FIELD_FINAL (in FIELD_DECL)
75       CLASS_FINAL (in TYPE_DECL)
76       DECL_FINAL (in any decl)
77    4: METHOD_SYNCHRONIZED (in FUNCTION_DECL).
78       CLASS_INTERFACE (in TYPE_DECL)
79       FIELD_VOLATILE (int FIELD_DECL)
80    5: METHOD_ABSTRACT (in FUNCTION_DECL).
81       CLASS_ABSTRACT (in TYPE_DECL)
82       FIELD_TRANSIENT (in FIELD_DECL)
83    6: CLASS_SUPER (in TYPE_DECL, ACC_SUPER flag)
84       FIELD_LOCAL_ALIAS (in FIELD_DECL)
85    7: DECL_CONSTRUCTOR_P (in FUNCTION_DECL).
86       CLASS_STATIC (in TYPE_DECL)
87       FIELD_LOCAL_ALIAS_USED (in FIELD_DECL)
88       FIELD_THISN (in FIELD_DECL)
89 */
90
91 #define VAR_OR_FIELD_CHECK(DECL) \
92   TREE_CHECK3 (DECL, FIELD_DECL, VAR_DECL, PARM_DECL)
93
94 /* True if the class whose TYPE_BINFO this is has a superclass.
95    (True of all classes except Object.) */
96 #define CLASS_HAS_SUPER_FLAG(BINFO) BINFO_FLAG_1 (BINFO)
97 #define CLASS_HAS_SUPER(TYPE) \
98   (TYPE_BINFO (TYPE) && CLASS_HAS_SUPER_FLAG (TYPE_BINFO (TYPE)))
99
100 /* Return the supertype of class TYPE, or NULL_TREE is it has none. */
101 #define CLASSTYPE_SUPER(TYPE) (CLASS_HAS_SUPER (TYPE) \
102   ? BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (TYPE), 0)) \
103   : NULL_TREE)
104
105 /* The class defined by the actual (main) file we are compiling. */
106 #define main_class \
107   java_global_trees[JTI_MAIN_CLASS]
108
109 /* The class we use as the base for name resolution.  It's usually the
110    class we're generating code for but sometimes it points to an inner
111    class.  If you really want to know the class we're currently
112    generating code for, use output_class instead.  */
113 #define current_class \
114   java_global_trees[JTI_CURRENT_CLASS]
115
116 /* The class we are currently generating.  Really.  */
117 #define output_class \
118   java_global_trees[JTI_OUTPUT_CLASS]
119
120 /* List of all class DECLs seen so far.  */
121 #define all_class_list \
122   java_global_trees[JTI_ALL_CLASS_LIST]
123
124 /* List of virtual decls referred to by this translation unit, used to
125    generate virtual method offset symbol table.  */
126
127 /* The virtual offset table.  This is emitted as uninitialized data of
128    the required length, and filled out at run time during class
129    linking. */
130
131 /* The virtual offset symbol table. Used by the runtime to fill out
132    the otable. */
133
134 extern int flag_filelist_file;
135
136 /* When nonzero, permit the use of the assert keyword.  */
137
138 extern int flag_assert;
139
140 /* When nonzero, assume all native functions are implemented with
141    JNI, not CNI.  */
142
143 extern int flag_jni;
144
145 /* When nonzero, always check for a non gcj generated classes archive.  */
146
147 extern int flag_force_classes_archive_check;
148
149 /* Resource name.  */
150 extern const char *resource_name;
151
152 /* Turned to 1 if -Wall was encountered. See lang.c for their meanings.  */
153 extern int flag_wall;
154 extern int flag_redundant;
155
156 /* When nonzero, warn when source file is newer than matching class
157    file.  */
158 extern int flag_newer;
159
160 /* When nonzero, call a library routine to do integer divisions. */
161 extern int flag_use_divide_subroutine;
162
163 /* When nonzero, generate code for the Boehm GC.  */
164 extern int flag_use_boehm_gc;
165
166 /* When nonzero, assume the runtime uses a hash table to map an
167    object to its synchronization structure.  */
168 extern int flag_hash_synchronization;
169
170 /* When nonzero, generate checks for references to NULL.  */
171 extern int flag_check_references;
172
173 /* Used through STATIC_CLASS_INIT_OPT_P to check whether static
174    initialization optimization should be performed.  */
175 extern int flag_optimize_sci;
176
177 /* Generate instances of Class at runtime.  */
178 extern int flag_indirect_classes;
179
180 /* When nonzero, use offset tables for virtual method calls
181    in order to improve binary compatibility. */
182 extern int flag_indirect_dispatch;
183
184 /* When zero, don't generate runtime array store checks. */
185 extern int flag_store_check;
186
187 /* When nonzero, generate only a limited set of class meta-data. */
188 extern int flag_reduced_reflection;
189
190 /* The Java .class file that provides main_class;  the main input file. */
191 extern GTY(()) struct JCF * current_jcf;
192
193 /* Set to nonzero value in order to emit class initialization code
194    before static field references.  */
195 extern int always_initialize_class_p;
196
197 extern int flag_verify_invocations;
198
199 /* Largest pc so far in this method that has been passed to lookup_label. */
200 extern int highest_label_pc_this_method;
201
202 /* Base value for this method to add to pc to get generated label. */
203 extern int start_label_pc_this_method;
204
205 typedef struct CPool constant_pool;
206
207 #define CONSTANT_ResolvedFlag 16
208
209 /* Don't eagerly resolve this entry.  When this flag is set, constant
210    pool entries are resolved only at runtime when the entry is first
211    referred to.  */
212 #define CONSTANT_LazyFlag 32
213
214 /* The cpool->data[i] for a ResolvedString points to a STRING_CST. */
215 #define CONSTANT_ResolvedString    (CONSTANT_String+CONSTANT_ResolvedFlag)
216
217 /* The cpool->data[i] for a ResolvedClass points to a RECORD_TYPE. */
218 #define CONSTANT_ResolvedClass     (CONSTANT_Class+CONSTANT_ResolvedFlag)
219
220 #define CPOOL_UTF(CPOOL, INDEX) ((CPOOL)->data[INDEX].t)
221
222 /* A NameAndType constant is represented as a TREE_LIST.
223    The type is the signature string (as an IDENTIFIER_NODE).  */
224
225 #define NAME_AND_TYPE_NAME(CPOOL, IDX) \
226   CPOOL_UTF(CPOOL, CPOOL_USHORT1(CPOOL, IDX))
227 #define NAME_AND_TYPE_SIGNATURE(CPOOL, IDX) \
228   CPOOL_UTF(CPOOL, CPOOL_USHORT2(CPOOL, IDX))
229
230 /* A FieldRef, MethodRef or InterfaceMethodRef constant
231    is represented as a TREE_LIST. */
232
233 #define COMPONENT_REF_CLASS_INDEX(CPOOL, IDX) CPOOL_USHORT1(CPOOL, IDX)
234 #define COMPONENT_REF_NAME_AND_TYPE(CPOOL, IDX) CPOOL_USHORT2(CPOOL, IDX)
235 #define COMPONENT_REF_NAME(CPOOL, IDX) \
236   NAME_AND_TYPE_NAME (CPOOL, COMPONENT_REF_NAME_AND_TYPE(CPOOL, IDX))
237 #define COMPONENT_REF_SIGNATURE(CPOOL, IDX) \
238   NAME_AND_TYPE_SIGNATURE (CPOOL, COMPONENT_REF_NAME_AND_TYPE(CPOOL, IDX))
239
240 extern GTY(()) tree java_lang_cloneable_identifier_node;
241 extern GTY(()) tree java_io_serializable_identifier_node;
242 extern GTY(()) tree gcj_abi_version;
243
244 /* The decl for the .constants field of an instance of Class.  */
245 extern GTY(()) tree constants_field_decl_node;
246
247 /* The decl for the .data field of an instance of Class.  */
248 extern GTY(()) tree constants_data_field_decl_node;
249
250 enum java_tree_index
251 {
252   JTI_PROMOTED_BYTE_TYPE_NODE,
253   JTI_PROMOTED_SHORT_TYPE_NODE,
254   JTI_PROMOTED_CHAR_TYPE_NODE,
255   JTI_PROMOTED_BOOLEAN_TYPE_NODE,
256
257   JTI_BYTE_TYPE_NODE,
258   JTI_SHORT_TYPE_NODE,
259   JTI_INT_TYPE_NODE,
260   JTI_LONG_TYPE_NODE,
261   
262   JTI_UNSIGNED_BYTE_TYPE_NODE,
263   JTI_UNSIGNED_SHORT_TYPE_NODE,
264   JTI_UNSIGNED_INT_TYPE_NODE,
265   JTI_UNSIGNED_LONG_TYPE_NODE,
266   
267   JTI_DECIMAL_INT_MAX_NODE,
268   JTI_DECIMAL_LONG_MAX_NODE,
269
270   JTI_OBJECT_TYPE_NODE,
271   JTI_UNQUALIFIED_OBJECT_ID_NODE,
272   JTI_OBJECT_PTR_TYPE_NODE,
273   JTI_STRING_TYPE_NODE,
274   JTI_STRING_PTR_TYPE_NODE,
275   JTI_THROWABLE_TYPE_NODE,
276   JTI_EXCEPTION_TYPE_NODE,
277   JTI_RUNTIME_EXCEPTION_TYPE_NODE,
278   JTI_ERROR_EXCEPTION_TYPE_NODE,
279   JTI_RAWDATA_PTR_TYPE_NODE,
280
281   JTI_BYTE_ARRAY_TYPE_NODE,
282   JTI_SHORT_ARRAY_TYPE_NODE,
283   JTI_INT_ARRAY_TYPE_NODE,
284   JTI_LONG_ARRAY_TYPE_NODE,
285   JTI_BOOLEAN_ARRAY_TYPE_NODE,
286   JTI_CHAR_ARRAY_TYPE_NODE,
287   JTI_DOUBLE_ARRAY_TYPE_NODE,
288   JTI_FLOAT_ARRAY_TYPE_NODE,
289   JTI_ARRAY_ARRAY_TYPE_NODE,
290   JTI_OBJECT_ARRAY_TYPE_NODE,
291   JTI_STRING_ARRAY_TYPE_NODE,
292   JTI_BOOLEAN_ARRAY_VTABLE,
293   JTI_BYTE_ARRAY_VTABLE,
294   JTI_CHAR_ARRAY_VTABLE,
295   JTI_SHORT_ARRAY_VTABLE,
296   JTI_INT_ARRAY_VTABLE,
297   JTI_LONG_ARRAY_VTABLE,
298   JTI_FLOAT_ARRAY_VTABLE,
299   JTI_DOUBLE_ARRAY_VTABLE,
300   JTI_TYPE_IDENTIFIER_NODE,      
301   JTI_INIT_IDENTIFIER_NODE,      
302   JTI_CLINIT_IDENTIFIER_NODE,      
303   JTI_VOID_SIGNATURE_NODE,       
304   JTI_FINALIZE_IDENTIFIER_NODE,
305   JTI_THIS_IDENTIFIER_NODE,  
306   JTI_CLASSDOLLAR_IDENTIFIER_NODE,
307   JTI_ONE_ELT_ARRAY_DOMAIN_TYPE,
308
309   JTI_RETURN_ADDRESS_TYPE_NODE,
310
311   JTI_LONG_ZERO_NODE,
312   JTI_FLOAT_ZERO_NODE,
313   JTI_DOUBLE_ZERO_NODE,
314   JTI_INTEGER_TWO_NODE,
315   JTI_INTEGER_FOUR_NODE,
316
317   JTI_METHODTABLE_TYPE,
318   JTI_METHODTABLE_PTR_TYPE,
319
320   JTI_UTF8CONST_TYPE,
321   JTI_UTF8CONST_PTR_TYPE,
322
323   JTI_CLASS_TYPE_NODE,
324   JTI_CLASS_PTR_TYPE,
325   JTI_FIELD_TYPE_NODE,
326   JTI_CONSTANTS_TYPE_NODE,
327   JTI_DTABLE_TYPE, 
328   JTI_DTABLE_PTR_TYPE,
329   JTI_FIELD_PTR_TYPE_NODE,
330   JTI_FIELD_INFO_UNION_NODE,
331   JTI_EXCEPTION_TYPE,
332   JTI_EXCEPTION_PTR_TYPE,
333   JTI_LINENUMBERENTRY_TYPE,
334   JTI_LINENUMBERS_TYPE,
335   JTI_METHOD_TYPE_NODE,
336   JTI_METHOD_PTR_TYPE_NODE,
337   JTI_OTABLE_TYPE,
338   JTI_OTABLE_PTR_TYPE,
339   JTI_ATABLE_TYPE,
340   JTI_ATABLE_PTR_TYPE,
341   JTI_ITABLE_TYPE,
342   JTI_ITABLE_PTR_TYPE,
343   JTI_SYMBOL_TYPE,
344   JTI_SYMBOLS_ARRAY_TYPE,
345   JTI_SYMBOLS_ARRAY_PTR_TYPE,
346   JTI_ASSERTION_ENTRY_TYPE,
347   JTI_ASSERTION_TABLE_TYPE,
348
349   JTI_END_PARAMS_NODE,
350
351   JTI_THROW_NODE,
352   JTI_ALLOC_OBJECT_NODE,
353   JTI_ALLOC_NO_FINALIZER_NODE,
354   JTI_SOFT_INSTANCEOF_NODE,
355   JTI_SOFT_CHECKCAST_NODE,
356   JTI_SOFT_INITCLASS_NODE,
357   JTI_SOFT_NEWARRAY_NODE,
358   JTI_SOFT_ANEWARRAY_NODE,
359   JTI_SOFT_MULTIANEWARRAY_NODE,
360   JTI_SOFT_BADARRAYINDEX_NODE,
361   JTI_SOFT_NULLPOINTER_NODE,
362   JTI_SOFT_ABSTRACTMETHOD_NODE,
363   JTI_SOFT_NOSUCHFIELD_NODE,
364   JTI_SOFT_CHECKARRAYSTORE_NODE,
365   JTI_SOFT_MONITORENTER_NODE,
366   JTI_SOFT_MONITOREXIT_NODE,
367   JTI_SOFT_LOOKUPINTERFACEMETHOD_NODE,
368   JTI_SOFT_LOOKUPINTERFACEMETHODBYNAME_NODE,
369   JTI_SOFT_LOOKUPJNIMETHOD_NODE,
370   JTI_SOFT_GETJNIENVNEWFRAME_NODE,
371   JTI_SOFT_JNIPOPSYSTEMFRAME_NODE,
372   JTI_SOFT_UNWRAPJNI_NODE,
373   JTI_SOFT_FMOD_NODE,
374   JTI_SOFT_IDIV_NODE,
375   JTI_SOFT_IREM_NODE,
376   JTI_SOFT_LDIV_NODE,
377   JTI_SOFT_LREM_NODE,
378
379   JTI_ACCESS_FLAGS_TYPE_NODE,
380
381   JTI_NATIVECODE_PTR_ARRAY_TYPE_NODE,
382
383   JTI_MAIN_CLASS,
384   JTI_CURRENT_CLASS,
385   JTI_OUTPUT_CLASS,
386   JTI_ALL_CLASS_LIST,
387
388   JTI_PREDEF_FILENAMES,
389
390   JTI_MAX
391 };
392
393 extern GTY(()) tree java_global_trees[JTI_MAX];
394
395 /* "Promoted types" that are used for primitive types smaller
396    than int.  We could use int_type_node, but then we would lose
397    type information (such as needed for debugging). */
398 #define promoted_byte_type_node \
399   java_global_trees[JTI_PROMOTED_BYTE_TYPE_NODE]
400 #define promoted_short_type_node \
401   java_global_trees[JTI_PROMOTED_SHORT_TYPE_NODE]
402 #define promoted_char_type_node \
403   java_global_trees[JTI_PROMOTED_CHAR_TYPE_NODE]
404 #define promoted_boolean_type_node \
405   java_global_trees[JTI_PROMOTED_BOOLEAN_TYPE_NODE]
406
407 #define byte_type_node \
408   java_global_trees[JTI_BYTE_TYPE_NODE]
409 #define short_type_node \
410   java_global_trees[JTI_SHORT_TYPE_NODE]
411 #define int_type_node \
412   java_global_trees[JTI_INT_TYPE_NODE]
413 #define long_type_node \
414   java_global_trees[JTI_LONG_TYPE_NODE]
415
416 #define unsigned_byte_type_node \
417   java_global_trees[JTI_UNSIGNED_BYTE_TYPE_NODE]
418 #define unsigned_short_type_node \
419   java_global_trees[JTI_UNSIGNED_SHORT_TYPE_NODE]
420 #define unsigned_int_type_node \
421   java_global_trees[JTI_UNSIGNED_INT_TYPE_NODE]
422 #define unsigned_long_type_node \
423   java_global_trees[JTI_UNSIGNED_LONG_TYPE_NODE]
424
425 #define decimal_int_max \
426   java_global_trees[JTI_DECIMAL_INT_MAX_NODE]
427 #define decimal_long_max \
428   java_global_trees[JTI_DECIMAL_LONG_MAX_NODE]
429
430 #define object_type_node \
431   java_global_trees[JTI_OBJECT_TYPE_NODE]
432 #define unqualified_object_id_node \
433   java_global_trees[JTI_UNQUALIFIED_OBJECT_ID_NODE]
434 #define object_ptr_type_node \
435   java_global_trees[JTI_OBJECT_PTR_TYPE_NODE]
436 #define string_type_node \
437   java_global_trees[JTI_STRING_TYPE_NODE]
438 #define string_ptr_type_node \
439   java_global_trees[JTI_STRING_PTR_TYPE_NODE]
440 #define throwable_type_node \
441   java_global_trees[JTI_THROWABLE_TYPE_NODE]
442 #define exception_type_node \
443   java_global_trees[JTI_EXCEPTION_TYPE_NODE]
444 #define runtime_exception_type_node \
445   java_global_trees[JTI_RUNTIME_EXCEPTION_TYPE_NODE]
446 #define error_exception_type_node \
447   java_global_trees[JTI_ERROR_EXCEPTION_TYPE_NODE]
448 #define rawdata_ptr_type_node \
449   java_global_trees[JTI_RAWDATA_PTR_TYPE_NODE]
450
451 #define byte_array_type_node \
452   java_global_trees[JTI_BYTE_ARRAY_TYPE_NODE]
453 #define short_array_type_node \
454   java_global_trees[JTI_SHORT_ARRAY_TYPE_NODE]
455 #define int_array_type_node \
456   java_global_trees[JTI_INT_ARRAY_TYPE_NODE]
457 #define long_array_type_node \
458   java_global_trees[JTI_LONG_ARRAY_TYPE_NODE]
459 #define boolean_array_type_node \
460   java_global_trees[JTI_BOOLEAN_ARRAY_TYPE_NODE]
461 #define char_array_type_node \
462   java_global_trees[JTI_CHAR_ARRAY_TYPE_NODE]
463 #define double_array_type_node \
464   java_global_trees[JTI_DOUBLE_ARRAY_TYPE_NODE]
465 #define float_array_type_node \
466   java_global_trees[JTI_FLOAT_ARRAY_TYPE_NODE]
467 #define array_array_type_node \
468   java_global_trees[JTI_ARRAY_ARRAY_TYPE_NODE]
469 #define object_array_type_node \
470   java_global_trees[JTI_OBJECT_ARRAY_TYPE_NODE]
471 #define string_array_type_node \
472   java_global_trees[JTI_STRING_ARRAY_TYPE_NODE]
473 #define boolean_array_vtable \
474   java_global_trees[JTI_BOOLEAN_ARRAY_VTABLE]
475 #define byte_array_vtable \
476   java_global_trees[JTI_BYTE_ARRAY_VTABLE]
477 #define char_array_vtable \
478   java_global_trees[JTI_CHAR_ARRAY_VTABLE]
479 #define short_array_vtable \
480   java_global_trees[JTI_SHORT_ARRAY_VTABLE]
481 #define int_array_vtable \
482   java_global_trees[JTI_INT_ARRAY_VTABLE]
483 #define long_array_vtable \
484   java_global_trees[JTI_LONG_ARRAY_VTABLE]
485 #define float_array_vtable \
486   java_global_trees[JTI_FLOAT_ARRAY_VTABLE]
487 #define double_array_vtable \
488   java_global_trees[JTI_DOUBLE_ARRAY_VTABLE]
489 #define TYPE_identifier_node \
490   java_global_trees[JTI_TYPE_IDENTIFIER_NODE]      /* "TYPE" */
491 #define init_identifier_node \
492   java_global_trees[JTI_INIT_IDENTIFIER_NODE]      /* "<init>" */
493 #define clinit_identifier_node \
494   java_global_trees[JTI_CLINIT_IDENTIFIER_NODE]      /* "<clinit>" */
495 #define void_signature_node \
496   java_global_trees[JTI_VOID_SIGNATURE_NODE]       /* "()V" */
497 #define finalize_identifier_node \
498   java_global_trees[JTI_FINALIZE_IDENTIFIER_NODE]  /* "finalize" */
499 #define this_identifier_node \
500   java_global_trees[JTI_THIS_IDENTIFIER_NODE]  /* "this" */
501 #define classdollar_identifier_node \
502   java_global_trees[JTI_CLASSDOLLAR_IDENTIFIER_NODE] /* "class$" */
503 #define one_elt_array_domain_type \
504   java_global_trees[JTI_ONE_ELT_ARRAY_DOMAIN_TYPE]
505 /* The type of the return address of a subroutine. */
506 #define return_address_type_node \
507   java_global_trees[JTI_RETURN_ADDRESS_TYPE_NODE]
508
509 /* Integer constants not declared in tree.h. */
510 #define long_zero_node \
511   java_global_trees[JTI_LONG_ZERO_NODE]
512 #define float_zero_node \
513   java_global_trees[JTI_FLOAT_ZERO_NODE]
514 #define double_zero_node \
515   java_global_trees[JTI_DOUBLE_ZERO_NODE]
516 #define integer_two_node \
517   java_global_trees[JTI_INTEGER_TWO_NODE]
518 #define integer_four_node \
519   java_global_trees[JTI_INTEGER_FOUR_NODE]
520
521 /* The type for struct methodtable. */
522 #define methodtable_type \
523   java_global_trees[JTI_METHODTABLE_TYPE]
524 #define methodtable_ptr_type \
525   java_global_trees[JTI_METHODTABLE_PTR_TYPE]
526
527 #define utf8const_type \
528   java_global_trees[JTI_UTF8CONST_TYPE]
529 #define utf8const_ptr_type \
530   java_global_trees[JTI_UTF8CONST_PTR_TYPE]
531
532 #define class_type_node \
533   java_global_trees[JTI_CLASS_TYPE_NODE]
534 #define class_ptr_type \
535   java_global_trees[JTI_CLASS_PTR_TYPE]
536 #define field_type_node \
537   java_global_trees[JTI_FIELD_TYPE_NODE]
538 #define constants_type_node \
539   java_global_trees[JTI_CONSTANTS_TYPE_NODE]
540 #define dtable_type \
541   java_global_trees[JTI_DTABLE_TYPE]
542 #define dtable_ptr_type \
543   java_global_trees[JTI_DTABLE_PTR_TYPE]
544 #define field_ptr_type_node \
545   java_global_trees[JTI_FIELD_PTR_TYPE_NODE]
546 #define field_info_union_node \
547   java_global_trees[JTI_FIELD_INFO_UNION_NODE]
548 #define jexception_type \
549   java_global_trees[JTI_EXCEPTION_TYPE]
550 #define jexception_ptr_type \
551   java_global_trees[JTI_EXCEPTION_PTR_TYPE]
552 #define lineNumberEntry_type \
553   java_global_trees[JTI_LINENUMBERENTRY_TYPE]
554 #define lineNumbers_type \
555   java_global_trees[JTI_LINENUMBERS_TYPE]
556 #define method_type_node \
557   java_global_trees[JTI_METHOD_TYPE_NODE]
558 #define method_ptr_type_node \
559   java_global_trees[JTI_METHOD_PTR_TYPE_NODE]
560 #define otable_type \
561   java_global_trees[JTI_OTABLE_TYPE]
562 #define atable_type \
563   java_global_trees[JTI_ATABLE_TYPE]
564 #define itable_type \
565   java_global_trees[JTI_ITABLE_TYPE]
566 #define otable_ptr_type \
567   java_global_trees[JTI_OTABLE_PTR_TYPE]
568 #define atable_ptr_type \
569   java_global_trees[JTI_ATABLE_PTR_TYPE]
570 #define itable_ptr_type \
571   java_global_trees[JTI_ITABLE_PTR_TYPE]
572 #define symbol_type \
573   java_global_trees[JTI_SYMBOL_TYPE]
574 #define symbols_array_type \
575   java_global_trees[JTI_SYMBOLS_ARRAY_TYPE]
576 #define symbols_array_ptr_type \
577   java_global_trees[JTI_SYMBOLS_ARRAY_PTR_TYPE]  
578 #define assertion_entry_type \
579   java_global_trees[JTI_ASSERTION_ENTRY_TYPE]
580 #define assertion_table_type \
581   java_global_trees[JTI_ASSERTION_TABLE_TYPE]
582
583 #define end_params_node \
584   java_global_trees[JTI_END_PARAMS_NODE]
585
586 /* References to internal libjava functions we use. */
587 #define throw_node \
588   java_global_trees[JTI_THROW_NODE]
589 #define alloc_object_node \
590   java_global_trees[JTI_ALLOC_OBJECT_NODE]
591 #define alloc_no_finalizer_node \
592   java_global_trees[JTI_ALLOC_NO_FINALIZER_NODE]
593 #define soft_instanceof_node \
594   java_global_trees[JTI_SOFT_INSTANCEOF_NODE]
595 #define soft_checkcast_node \
596   java_global_trees[JTI_SOFT_CHECKCAST_NODE]
597 #define soft_initclass_node \
598   java_global_trees[JTI_SOFT_INITCLASS_NODE]
599 #define soft_newarray_node \
600   java_global_trees[JTI_SOFT_NEWARRAY_NODE]
601 #define soft_anewarray_node \
602   java_global_trees[JTI_SOFT_ANEWARRAY_NODE]
603 #define soft_multianewarray_node \
604   java_global_trees[JTI_SOFT_MULTIANEWARRAY_NODE]
605 #define soft_badarrayindex_node \
606   java_global_trees[JTI_SOFT_BADARRAYINDEX_NODE]
607 #define soft_nullpointer_node \
608   java_global_trees[JTI_SOFT_NULLPOINTER_NODE]
609 #define soft_abstractmethod_node \
610   java_global_trees[JTI_SOFT_ABSTRACTMETHOD_NODE]
611 #define soft_nosuchfield_node \
612   java_global_trees[JTI_SOFT_NOSUCHFIELD_NODE]
613 #define soft_checkarraystore_node \
614   java_global_trees[JTI_SOFT_CHECKARRAYSTORE_NODE]
615 #define soft_monitorenter_node \
616   java_global_trees[JTI_SOFT_MONITORENTER_NODE]
617 #define soft_monitorexit_node \
618   java_global_trees[JTI_SOFT_MONITOREXIT_NODE]
619 #define soft_lookupinterfacemethod_node \
620   java_global_trees[JTI_SOFT_LOOKUPINTERFACEMETHOD_NODE]
621 #define soft_lookupinterfacemethodbyname_node \
622   java_global_trees[JTI_SOFT_LOOKUPINTERFACEMETHODBYNAME_NODE]
623 #define soft_lookupjnimethod_node \
624   java_global_trees[JTI_SOFT_LOOKUPJNIMETHOD_NODE]
625 #define soft_getjnienvnewframe_node \
626   java_global_trees[JTI_SOFT_GETJNIENVNEWFRAME_NODE]
627 #define soft_jnipopsystemframe_node \
628   java_global_trees[JTI_SOFT_JNIPOPSYSTEMFRAME_NODE]
629 #define soft_unwrapjni_node \
630   java_global_trees[JTI_SOFT_UNWRAPJNI_NODE]
631 #define soft_fmod_node \
632   java_global_trees[JTI_SOFT_FMOD_NODE]
633 #define soft_idiv_node \
634   java_global_trees[JTI_SOFT_IDIV_NODE]
635 #define soft_irem_node \
636   java_global_trees[JTI_SOFT_IREM_NODE]
637 #define soft_ldiv_node \
638   java_global_trees[JTI_SOFT_LDIV_NODE]
639 #define soft_lrem_node \
640   java_global_trees[JTI_SOFT_LREM_NODE]
641
642 #define access_flags_type_node \
643   java_global_trees[JTI_ACCESS_FLAGS_TYPE_NODE]
644
645 #define nativecode_ptr_array_type_node \
646   java_global_trees[JTI_NATIVECODE_PTR_ARRAY_TYPE_NODE]
647
648 #define predef_filenames \
649   java_global_trees[JTI_PREDEF_FILENAMES]
650
651 #define nativecode_ptr_type_node ptr_type_node
652
653 /* The decl for "_Jv_ResolvePoolEntry".  */
654 extern GTY(()) tree soft_resolvepoolentry_node;
655
656 struct lang_identifier GTY(())
657 {
658   struct tree_identifier ignore;
659   tree global_value;
660   tree local_value;
661
662   /* If non-NULL:  An ADDR_REF to a VAR_DECL that contains
663    * the Utf8Const representation of the identifier.  */
664   tree utf8_ref;
665 };
666
667 /* The resulting tree type.  */
668 union lang_tree_node 
669   GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
670        chain_next ("(union lang_tree_node *)GENERIC_NEXT (&%h.generic)")))
671
672 {
673   union tree_node GTY ((tag ("0"), 
674                         desc ("tree_node_structure (&%h)"))) 
675     generic;
676   struct lang_identifier GTY ((tag ("1"))) identifier;
677 };
678
679 /* Macros for access to language-specific slots in an identifier.  */
680 /* Unless specified, each of these slots contains a DECL node or null.  */
681
682 /* This represents the value which the identifier has in the
683    file-scope namespace.  */
684 #define IDENTIFIER_GLOBAL_VALUE(NODE)   \
685   (((struct lang_identifier *)(NODE))->global_value)
686 /* This represents the value which the identifier has in the current
687    scope.  */
688 #define IDENTIFIER_LOCAL_VALUE(NODE)    \
689   (((struct lang_identifier *)(NODE))->local_value)
690
691 /* Given an identifier NODE, get the corresponding class.
692    E.g. IDENTIFIER_CLASS_VALUE(get_identifier ("java.lang.Number"))
693    is the corresponding RECORD_TYPE. */
694 #define IDENTIFIER_CLASS_VALUE(NODE) IDENTIFIER_GLOBAL_VALUE(NODE)
695
696 /* Given a signature of a reference (or array) type, or a method, return the
697    corresponding type (if one has been allocated).
698    Do not use for primitive types, since they may be ambiguous.
699    (E.g. is "I" a signature or a class name?) */
700 #define IDENTIFIER_SIGNATURE_TYPE(NODE) IDENTIFIER_GLOBAL_VALUE(NODE)
701
702 /* If non-NULL:  An ADDR_REF to a VAR_DECL that contains
703    the Utf8Const representation of the identifier.  */
704 #define IDENTIFIER_UTF8_REF(NODE) \
705   (((struct lang_identifier *)(NODE))->utf8_ref)
706
707 #define IDENTIFIER_UTF8_DECL(NODE) \
708   TREE_OPERAND((((struct lang_identifier *)(NODE))->utf8_ref), 0)
709
710 /* For a FUNCTION_DECL, if we are compiling a .class file, then this is
711    the position in the .class file of the method code.
712    Specifically, this is the code itself, not the code attribute. */
713 #define DECL_CODE_OFFSET(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.code_offset)
714 /* Similarly, the length of the bytecode. */
715 #define DECL_CODE_LENGTH(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.code_length)
716 /* Similarly, the position of the LineNumberTable attribute. */
717 #define DECL_LINENUMBERS_OFFSET(DECL) \
718   (DECL_LANG_SPECIFIC(DECL)->u.f.linenumbers_offset)
719 /* Similarly, the position of the LocalVariableTable attribute
720    (following the standard attribute header). */
721 #define DECL_LOCALVARIABLES_OFFSET(DECL) \
722   (DECL_LANG_SPECIFIC(DECL)->u.f.localvariables_offset)
723
724 #define DECL_MAX_LOCALS(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.max_locals)
725 #define DECL_MAX_STACK(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.max_stack)
726 /* Number of local variable slots needed for the arguments of this function. */
727 #define DECL_ARG_SLOT_COUNT(DECL) \
728   (DECL_LANG_SPECIFIC(DECL)->u.f.arg_slot_count)
729 /* Source location of end of function. */
730 #define DECL_FUNCTION_LAST_LINE(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.last_line)
731 /* List of checked thrown exceptions, as specified with the `throws'
732    keyword */
733 #define DECL_FUNCTION_THROWS(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.throws_list)
734 /* Pointer to the function's current's COMPOUND_EXPR tree (while
735    completing its body) or the function's block */
736 #define DECL_FUNCTION_BODY(DECL) \
737   (DECL_LANG_SPECIFIC(DECL)->u.f.function_decl_body)
738 /* For each function decl, init_test_table contains a hash table whose
739    entries are keyed on class names, and whose values are local
740    boolean decls.  The variables are intended to be TRUE when the
741    class has been initialized in this function, and FALSE otherwise.  */
742 #define DECL_FUNCTION_INIT_TEST_TABLE(DECL) \
743   (DECL_LANG_SPECIFIC(DECL)->u.f.init_test_table)
744 /* If LOCAL_CLASS_INITIALIZATION_FLAG_P(decl), give class it initializes. */
745 #define DECL_FUNCTION_INIT_TEST_CLASS(DECL) \
746   (DECL_LANG_SPECIFIC(DECL)->u.v.slot_chain)
747 /* For each static function decl, itc contains a hash table whose
748    entries are keyed on class named that are definitively initialized
749    in DECL.  */
750 #define DECL_FUNCTION_INITIALIZED_CLASS_TABLE(DECL) \
751   (DECL_LANG_SPECIFIC(DECL)->u.f.ict)
752
753 #define DECL_LOCAL_CNI_METHOD_P(NODE) \
754     (DECL_LANG_SPECIFIC (NODE)->u.f.local_cni)
755
756 /* A constructor that calls this. */
757 #define DECL_INIT_CALLS_THIS(DECL) \
758   (DECL_LANG_SPECIFIC(DECL)->u.f.init_calls_this)
759
760 /* True when DECL (a field) is Synthetic.  */
761 #define FIELD_SYNTHETIC(DECL) DECL_LANG_FLAG_2 (VAR_OR_FIELD_CHECK (DECL))
762
763 /* True when DECL aliases an outer context local variable.  */
764 #define FIELD_LOCAL_ALIAS(DECL) DECL_LANG_FLAG_6 (VAR_OR_FIELD_CHECK (DECL))
765
766 /* True when DECL, which aliases an outer context local variable is
767    used by the inner classes.  */
768 #define FIELD_LOCAL_ALIAS_USED(DECL) DECL_LANG_FLAG_7 (VAR_OR_FIELD_CHECK (DECL))
769
770 /* True when DECL is a this$<n> field. Note that
771    FIELD_LOCAL_ALIAS_USED can be differentiated when tested against
772    FIELD_LOCAL_ALIAS.  */
773 #define FIELD_THISN(DECL) DECL_LANG_FLAG_7 (VAR_OR_FIELD_CHECK (DECL))
774
775 /* In a LABEL_DECL, a TREE_VEC that saves the type_map at that point. */
776 #define LABEL_TYPE_STATE(NODE) (LABEL_DECL_CHECK (NODE)->label_decl.java_field_1)
777
778 /* In a LABEL_DECL, the corresponding bytecode program counter. */
779 #define LABEL_PC(NODE) (LABEL_DECL_CHECK (NODE)->label_decl.java_field_4)
780
781 /* In a LABEL_DECL, true if we have verified instructions starting here. */
782 #define LABEL_VERIFIED(NODE) \
783   (instruction_bits[LABEL_PC (NODE)] & BCODE_VERIFIED)
784
785 /* The slot number for this local variable. */
786 #define DECL_LOCAL_SLOT_NUMBER(NODE) \
787   (DECL_LANG_SPECIFIC (NODE)->u.v.slot_number)
788 /* The start (bytecode) pc for the valid range of this local variable. */
789 #define DECL_LOCAL_START_PC(NODE)  (DECL_LANG_SPECIFIC (NODE)->u.v.start_pc)
790 /* The end (bytecode) pc for the valid range of this local variable. */
791 #define DECL_LOCAL_END_PC(NODE)    (DECL_LANG_SPECIFIC (NODE)->u.v.end_pc)
792 /* For a VAR_DECL or PARM_DECL, used to chain decls with the same
793    slot_number in decl_map. */
794 #define DECL_LOCAL_SLOT_CHAIN(NODE) (DECL_LANG_SPECIFIC(NODE)->u.v.slot_chain)
795 /* For a FIELD_DECL, holds the name of the access method. Used to
796    read/write the content of the field across nested class boundaries.  */
797 #define FIELD_NESTED_ACCESS(DECL) \
798   (DECL_LANG_SPECIFIC (VAR_OR_FIELD_CHECK (DECL))->u.v.am)
799 /* Safely tests whether FIELD_NESTED_ACCESS exists or not.  */
800 #define FIELD_NESTED_ACCESS_P(DECL) \
801   DECL_LANG_SPECIFIC (DECL) && FIELD_NESTED_ACCESS (DECL)
802 /* True if a final field was initialized upon its declaration
803    or in an initializer.  Set after definite assignment.  */
804 #define DECL_FIELD_FINAL_IUD(NODE)  (DECL_LANG_SPECIFIC (NODE)->u.v.final_iud)
805 /* The class that's the owner of a dynamic binding table.  */
806 #define DECL_OWNER(NODE)            (DECL_LANG_SPECIFIC(NODE)->u.v.owner)
807 /* True if NODE is a local variable final. */
808 #define LOCAL_FINAL_P(NODE) (DECL_LANG_SPECIFIC (NODE) && DECL_FINAL (NODE))
809 /* True if a final local variable was initialized upon its declaration.  */
810 #define DECL_LOCAL_FINAL_IUD(NODE)  (DECL_LANG_SPECIFIC (NODE)->u.v.final_iud)
811 /* True if NODE is a final field. */
812 #define FINAL_VARIABLE_P(NODE) (FIELD_FINAL (NODE) && !FIELD_STATIC (NODE))
813 /* True if NODE is a class final field. */
814 #define FIELD_ENUM(DECL)            (DECL_LANG_SPECIFIC (DECL)->u.v.field_enum)
815 #define CLASS_FINAL_VARIABLE_P(NODE) \
816   (FIELD_FINAL (NODE) && FIELD_STATIC (NODE))
817 /* True if NODE is a class initialization flag. This macro accesses
818    the flag to read or set it.  */
819 #define LOCAL_CLASS_INITIALIZATION_FLAG(NODE) \
820     (DECL_LANG_SPECIFIC (NODE)->u.v.cif)
821 /* True if NODE is a class initialization flag. */
822 #define LOCAL_CLASS_INITIALIZATION_FLAG_P(NODE) \
823     (DECL_LANG_SPECIFIC (NODE) && LOCAL_CLASS_INITIALIZATION_FLAG(NODE))
824 /* True if NODE is a variable that is out of scope.  */
825 #define LOCAL_VAR_OUT_OF_SCOPE_P(NODE) \
826     (DECL_LANG_SPECIFIC (NODE)->u.v.freed)
827 #define LOCAL_SLOT_P(NODE) \
828     (DECL_LANG_SPECIFIC (NODE)->u.v.local_slot)
829
830 #define DECL_CLASS_FIELD_P(NODE) \
831     (DECL_LANG_SPECIFIC (NODE)->u.v.class_field)
832 #define DECL_VTABLE_P(NODE) \
833     (DECL_LANG_SPECIFIC (NODE)->u.v.vtable)
834
835 /* Create a DECL_LANG_SPECIFIC if necessary. */
836 #define MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC(T)                  \
837   if (DECL_LANG_SPECIFIC (T) == NULL)                           \
838     {                                                           \
839       DECL_LANG_SPECIFIC ((T))                                  \
840         = ggc_alloc_cleared (sizeof (struct lang_decl));        \
841       DECL_LANG_SPECIFIC (T)->desc = LANG_DECL_VAR;             \
842     }
843
844 /* A ConstantExpression, after folding and name resolution. */
845 #define CONSTANT_VALUE_P(NODE) \
846   (TREE_CODE (NODE) == STRING_CST \
847    || (TREE_CODE (NODE) == INTEGER_CST \
848        && TREE_CODE (TREE_TYPE (NODE)) != POINTER_TYPE) \
849    || TREE_CODE (NODE) == REAL_CST)
850
851 /* For a local VAR_DECL or PARM_DECL, holds the index into a words bitstring
852    that specifies if this decl is definitively assigned.
853    The value -1 means the variable has been definitely assigned (and not
854    definitely unassigned).  The value -2 means we already reported an error. */
855 #define DECL_BIT_INDEX(DECL) VAR_OR_FIELD_CHECK (DECL)->decl_common.pointer_alias_set
856
857 /* DECL_LANG_SPECIFIC for FUNCTION_DECLs. */
858 struct lang_decl_func GTY(())
859 {
860   /*  tree chain; not yet used. */
861   long code_offset;
862   int code_length;
863   long linenumbers_offset;
864   long localvariables_offset;
865   int arg_slots;
866   int max_locals;
867   int max_stack;
868   int arg_slot_count;
869   /* A temporary lie for the sake of ggc.  Actually, last_line is
870      only a source_location if USE_MAPPED_LOCATION.  FIXME.  */
871   source_location last_line;    /* End line number for a function decl */
872   tree throws_list;             /* Exception specified by `throws' */
873   tree function_decl_body;      /* Hold all function's statements */
874
875   /* Class initialization test variables  */
876   htab_t GTY ((param_is (struct treetreehash_entry))) init_test_table;
877                                 
878   /* Initialized (static) Class Table */
879   htab_t GTY ((param_is (union tree_node))) ict;
880
881   unsigned int native : 1;      /* Nonzero if this is a native method  */
882   unsigned int init_final : 1;  /* Nonzero all finals are initialized */
883   unsigned int init_calls_this : 1;
884   unsigned int strictfp : 1;
885   unsigned int invisible : 1;   /* Set for methods we generate
886                                    internally but which shouldn't be
887                                    written to the .class file.  */
888   unsigned int dummy : 1;
889   unsigned int local_cni : 1;   /* Decl needs mangle_local_cni_method.  */
890   unsigned int bridge : 1;      /* Bridge method.  */
891   unsigned int varargs : 1;     /* Varargs method.  */
892 };
893
894 struct treetreehash_entry GTY(())
895 {
896   tree key;
897   tree value;
898 };
899
900 /* These represent the possible assertion_codes that can be emitted in the
901    type assertion table.  */
902 enum
903 {
904   JV_ASSERT_END_OF_TABLE = 0,     /* Last entry in table.  */
905   JV_ASSERT_TYPES_COMPATIBLE = 1, /* Operand A is assignable to Operand B.  */
906   JV_ASSERT_IS_INSTANTIABLE = 2   /* Operand A is an instantiable class.  */
907 };
908
909 /* Annotation types used in the reflection_data.  See
910    java.lang.Class.getDeclaredAnnotations() in the runtime library for
911    an example of how these are used.  */
912
913 typedef enum
914 {
915   JV_CLASS_ATTR,
916   JV_METHOD_ATTR,
917   JV_FIELD_ATTR,
918   JV_DONE_ATTR
919 } jv_attr_type;
920
921 typedef enum
922 {
923   JV_INNER_CLASSES_KIND,
924   JV_ENCLOSING_METHOD_KIND,
925   JV_SIGNATURE_KIND,
926   JV_ANNOTATIONS_KIND,
927   JV_PARAMETER_ANNOTATIONS_KIND,
928   JV_ANNOTATION_DEFAULT_KIND
929 } jv_attr_kind;
930
931 typedef struct type_assertion GTY(())
932 {
933   int assertion_code; /* 'opcode' for the type of this assertion. */
934   tree op1;           /* First operand. */
935   tree op2;           /* Second operand. */
936 } type_assertion;
937
938 extern tree java_treetreehash_find (htab_t, tree);
939 extern tree * java_treetreehash_new (htab_t, tree);
940 extern htab_t java_treetreehash_create (size_t size, int ggc);
941
942 /* DECL_LANG_SPECIFIC for VAR_DECL, PARM_DECL and sometimes FIELD_DECL
943    (access methods on outer class fields) and final fields. */
944 struct lang_decl_var GTY(())
945 {
946   int slot_number;
947   int start_pc;
948   int end_pc;
949   tree slot_chain;
950   tree am;                      /* Access method for this field (1.1) */
951   tree owner;
952   unsigned int final_iud : 1;   /* Final initialized upon declaration */
953   unsigned int cif : 1;         /* True: decl is a class initialization flag */
954   unsigned int freed : 1;               /* Decl is no longer in scope.  */
955   unsigned int local_slot : 1;  /* Decl is a temporary in the stack frame.  */
956   unsigned int class_field : 1; /* Decl needs mangle_class_field.  */
957   unsigned int vtable : 1;      /* Decl needs mangle_vtable.  */
958   unsigned int field_enum:1;    /* Field is an enum.  */
959 };
960
961 /* This is what 'lang_decl' really points to.  */
962
963 enum lang_decl_desc {LANG_DECL_FUNC, LANG_DECL_VAR};
964
965 struct lang_decl GTY(())
966 {
967   enum lang_decl_desc desc;
968   union lang_decl_u
969     {
970       struct lang_decl_func GTY ((tag ("LANG_DECL_FUNC"))) f;
971       struct lang_decl_var GTY ((tag ("LANG_DECL_VAR"))) v;
972     } GTY ((desc ("%0.desc"))) u;
973 };
974
975 /* Macro to access fields in `struct lang_type'.  */
976
977 #define TYPE_SIGNATURE(T)       (TYPE_LANG_SPECIFIC (T)->signature)
978 #define TYPE_JCF(T)             (TYPE_LANG_SPECIFIC (T)->jcf)
979 #define TYPE_CPOOL(T)           (TYPE_LANG_SPECIFIC (T)->cpool)
980 #define TYPE_CPOOL_DATA_REF(T)  (TYPE_LANG_SPECIFIC (T)->cpool_data_ref)
981 #define MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC(T) \
982   if (TYPE_LANG_SPECIFIC ((T)) == NULL)         \
983      TYPE_LANG_SPECIFIC ((T))                   \
984      = ggc_alloc_cleared (sizeof (struct lang_type));
985
986 #define TYPE_DUMMY(T)           (TYPE_LANG_SPECIFIC(T)->dummy_class)
987
988 /* The decl of the synthetic method `class$' used to handle `.class'
989    for non primitive types when compiling to bytecode. */
990
991 #define TYPE_DOT_CLASS(T)        (TYPE_LANG_SPECIFIC (T)->dot_class)
992 #define TYPE_PACKAGE_LIST(T)     (TYPE_LANG_SPECIFIC (T)->package_list)
993 #define TYPE_PRIVATE_INNER_CLASS(T) (TYPE_LANG_SPECIFIC (T)->pic)
994 #define TYPE_PROTECTED_INNER_CLASS(T) (TYPE_LANG_SPECIFIC (T)->poic)
995 #define TYPE_STRICTFP(T) (TYPE_LANG_SPECIFIC (T)->strictfp)
996 #define TYPE_ENUM(T)            (TYPE_LANG_SPECIFIC (T)->enum_class)
997 #define TYPE_SYNTHETIC(T)       (TYPE_LANG_SPECIFIC (T)->synthetic)
998 #define TYPE_ANNOTATION(T)      (TYPE_LANG_SPECIFIC (T)->annotation)
999
1000 #define TYPE_USES_ASSERTIONS(T) (TYPE_LANG_SPECIFIC (T)->assertions)
1001
1002 #define TYPE_ATABLE_METHODS(T)   (TYPE_LANG_SPECIFIC (T)->atable_methods)
1003 #define TYPE_ATABLE_SYMS_DECL(T) (TYPE_LANG_SPECIFIC (T)->atable_syms_decl)
1004 #define TYPE_ATABLE_DECL(T)      (TYPE_LANG_SPECIFIC (T)->atable_decl)
1005
1006 #define TYPE_OTABLE_METHODS(T)   (TYPE_LANG_SPECIFIC (T)->otable_methods)
1007 #define TYPE_OTABLE_SYMS_DECL(T) (TYPE_LANG_SPECIFIC (T)->otable_syms_decl)
1008 #define TYPE_OTABLE_DECL(T)      (TYPE_LANG_SPECIFIC (T)->otable_decl)
1009
1010 #define TYPE_ITABLE_METHODS(T)   (TYPE_LANG_SPECIFIC (T)->itable_methods)
1011 #define TYPE_ITABLE_SYMS_DECL(T) (TYPE_LANG_SPECIFIC (T)->itable_syms_decl)
1012 #define TYPE_ITABLE_DECL(T)      (TYPE_LANG_SPECIFIC (T)->itable_decl)
1013
1014 #define TYPE_CTABLE_DECL(T)      (TYPE_LANG_SPECIFIC (T)->ctable_decl)
1015 #define TYPE_CATCH_CLASSES(T)    (TYPE_LANG_SPECIFIC (T)->catch_classes)
1016 #define TYPE_VERIFY_METHOD(T)    (TYPE_LANG_SPECIFIC (T)->verify_method)
1017
1018 #define TYPE_TO_RUNTIME_MAP(T)   (TYPE_LANG_SPECIFIC (T)->type_to_runtime_map)
1019 #define TYPE_ASSERTIONS(T)       (TYPE_LANG_SPECIFIC (T)->type_assertions)
1020 #define TYPE_PACKAGE(T)          (TYPE_LANG_SPECIFIC (T)->package)
1021
1022 #define TYPE_REFLECTION_DATA(T)  (TYPE_LANG_SPECIFIC (T)->reflection_data)
1023 #define TYPE_REFLECTION_DATASIZE(T)                                     \
1024                                 (TYPE_LANG_SPECIFIC (T)->reflection_datasize)
1025
1026 struct lang_type GTY(())
1027 {
1028   tree signature;
1029   struct JCF *jcf;
1030   struct CPool *cpool;
1031   tree cpool_data_ref;          /* Cached */
1032   tree dot_class;               /* The decl of the `class$' function that
1033                                    needs to be invoked and generated when
1034                                    compiling to bytecode to implement
1035                                    <non_primitive_type>.class */
1036   tree package_list;            /* List of package names, progressive */
1037
1038   tree otable_methods;          /* List of static decls referred to by this
1039                                    class.  */
1040   tree otable_decl;             /* The static address table.  */
1041   tree otable_syms_decl;
1042
1043   tree atable_methods;          /* List of static decls referred to by this
1044                                    class.  */
1045   tree atable_decl;             /* The static address table.  */
1046   tree atable_syms_decl;
1047
1048   tree itable_methods;          /* List of interfaces methods referred
1049                                    to by this class.  */
1050   tree itable_decl;             /* The interfaces table.  */
1051   tree itable_syms_decl;
1052
1053   tree ctable_decl;             /* The table of classes for the runtime
1054                                    type matcher.  */
1055   tree catch_classes;
1056
1057   tree verify_method;           /* The verify method for this class.
1058                                    Used in split verification.  */
1059
1060   htab_t GTY ((param_is (struct treetreehash_entry))) type_to_runtime_map;   
1061                                 /* The mapping of classes to exception region
1062                                    markers.  */
1063
1064   htab_t GTY ((param_is (struct type_assertion))) type_assertions;
1065                                 /* Table of type assertions to be evaluated 
1066                                    by the runtime when this class is loaded. */
1067
1068   tree package;                 /* IDENTIFIER_NODE for package this class is
1069                                    a member of.  */
1070
1071   unsigned char* GTY((skip)) reflection_data;   /* The raw reflection
1072                                                    data for this
1073                                                    class.  */
1074   long reflection_datasize;     /* The size of the raw reflection data
1075                                    for this class, in bytes.  */
1076
1077   unsigned pic:1;               /* Private Inner Class. */
1078   unsigned poic:1;              /* Protected Inner Class. */
1079   unsigned strictfp:1;          /* `strictfp' class.  */
1080   unsigned assertions:1;        /* Any method uses `assert'.  */
1081   unsigned dummy_class:1;       /* Not a real class, just a placeholder.  */
1082   unsigned enum_class:1;        /* Class is an enum type.  */
1083   unsigned synthetic:1;         /* Class is synthetic.  */
1084   unsigned annotation:1;        /* Class is an annotation type.  */
1085 };
1086
1087 #define JCF_u4 unsigned long
1088 #define JCF_u2 unsigned short
1089
1090 /* Possible values to pass to lookup_argument_method_generic.  */
1091 #define SEARCH_INTERFACE      1
1092 #define SEARCH_SUPER          2
1093 #define SEARCH_VISIBLE        4
1094
1095 /* Defined in java-except.h  */
1096 struct eh_range;
1097
1098 extern void java_parse_file (int);
1099 extern bool java_mark_addressable (tree);
1100 extern tree java_type_for_mode (enum machine_mode, int);
1101 extern tree java_type_for_size (unsigned int, int);
1102 extern tree java_unsigned_type (tree);
1103 extern tree java_signed_type (tree);
1104 extern tree java_truthvalue_conversion (tree);
1105 extern void add_assume_compiled (const char *, int);
1106 extern void add_enable_assert (const char *, int);
1107 extern bool enable_assertions (tree);
1108 extern tree lookup_class (tree);
1109 extern tree lookup_java_constructor (tree, tree);
1110 extern tree lookup_java_method (tree, tree, tree);
1111 extern tree lookup_argument_method (tree, tree, tree);
1112 extern tree lookup_argument_method_generic (tree, tree, tree, int);
1113 extern int has_method (tree, tree);
1114 extern tree promote_type (tree);
1115 extern tree get_constant (struct JCF*, int);
1116 extern tree get_name_constant (struct JCF*, int);
1117 extern tree get_class_constant (struct JCF*, int);
1118 extern tree parse_signature (struct JCF *jcf, int sig_index);
1119 extern tree add_field (tree, tree, tree, int);
1120 extern tree add_method (tree, int, tree, tree);
1121 extern tree add_method_1 (tree, int, tree, tree);
1122 extern tree make_class (void);
1123 extern tree push_class (tree, tree);
1124 extern tree unmangle_classname (const char *name, int name_length);
1125 extern tree parse_signature_string (const unsigned char *, int);
1126 extern tree get_type_from_signature (tree);
1127 extern void layout_class (tree);
1128 extern int get_interface_method_index (tree, tree);
1129 extern tree layout_class_method (tree, tree, tree, tree);
1130 extern void layout_class_methods (tree);
1131 extern void cache_this_class_ref (tree);
1132 extern void uncache_this_class_ref (tree);
1133 extern tree build_class_ref (tree);
1134 extern tree build_dtable_decl (tree);
1135 extern tree build_internal_class_name (tree);
1136 extern tree build_constants_constructor (void);
1137 extern tree build_constant_data_ref (bool);
1138 extern tree build_ref_from_constant_pool (int);
1139 extern tree build_utf8_ref (tree);
1140 extern tree ident_subst (const char *, int, const char *, int, int,
1141                          const char *);
1142 extern tree identifier_subst (const tree, const char *, int, int,
1143                               const char *);
1144 extern int global_bindings_p (void);
1145 extern tree getdecls (void);
1146 extern void pushlevel (int);
1147 extern tree poplevel (int,int, int);
1148 extern void insert_block (tree);
1149 extern tree pushdecl (tree);
1150 extern void java_init_decl_processing (void);
1151 extern void java_dup_lang_specific_decl (tree);
1152 extern tree build_java_signature (tree);
1153 extern tree build_java_argument_signature (tree);
1154 extern void set_java_signature (tree, tree);
1155 extern tree build_static_field_ref (tree);
1156 extern tree build_address_of (tree);
1157 extern tree find_local_variable (int index, tree type, int pc);
1158 extern tree find_stack_slot (int index, tree type);
1159 extern tree build_prim_array_type (tree, HOST_WIDE_INT);
1160 extern tree build_java_array_type (tree, HOST_WIDE_INT);
1161 extern int is_compiled_class (tree);
1162 extern tree mangled_classname (const char *, tree);
1163 extern tree lookup_label (int);
1164 extern tree pop_type_0 (tree, char **);
1165 extern tree pop_type (tree);
1166 extern tree decode_newarray_type (int);
1167 extern tree lookup_field (tree *, tree);
1168 extern int is_array_type_p (tree);
1169 extern HOST_WIDE_INT java_array_type_length (tree);
1170 extern int read_class (tree);
1171 extern void load_class (tree, int);
1172
1173 extern tree check_for_builtin (tree, tree);
1174 extern void initialize_builtins (void);
1175
1176 extern tree lookup_name (tree);
1177 extern bool special_method_p (tree);
1178 extern void maybe_rewrite_invocation (tree *, tree *, tree *, tree *);
1179 extern tree build_known_method_ref (tree, tree, tree, tree, tree, tree);
1180 extern tree build_class_init (tree, tree);
1181 extern int attach_init_test_initialization_flags (void **, void *);
1182 extern tree build_invokevirtual (tree, tree, tree);
1183 extern tree build_invokeinterface (tree, tree);
1184 extern tree build_jni_stub (tree);
1185 extern tree invoke_build_dtable (int, tree);
1186 extern tree build_field_ref (tree, tree, tree);
1187 extern tree java_modify_addr_for_volatile (tree);
1188 extern void pushdecl_force_head (tree);
1189 extern tree build_java_binop (enum tree_code, tree, tree, tree);
1190 extern tree build_java_soft_divmod (enum tree_code, tree, tree, tree);
1191 extern tree binary_numeric_promotion (tree, tree, tree *, tree *);
1192 extern tree build_java_arrayaccess (tree, tree, tree);
1193 extern tree build_java_arraystore_check (tree, tree);
1194 extern tree build_newarray (int, tree);
1195 extern tree build_anewarray (tree, tree);
1196 extern tree build_new_array (tree, tree);
1197 extern tree build_java_array_length_access (tree);
1198 extern tree build_java_indirect_ref (tree, tree, int);
1199 extern tree java_check_reference (tree, int);
1200 extern tree build_get_class (tree);
1201 extern tree build_instanceof (tree, tree);
1202 extern tree create_label_decl (tree);
1203 extern void push_labeled_block (tree);
1204 extern tree prepare_eh_table_type (tree);
1205 extern void java_expand_catch_classes (tree);
1206 extern tree build_exception_object_ref (tree);
1207 extern tree generate_name (void);
1208 extern void pop_labeled_block (void);
1209 extern const char *lang_printable_name (tree, int);
1210 extern tree maybe_add_interface (tree, tree);
1211 extern void set_super_info (int, tree, tree, int);
1212 extern void set_class_decl_access_flags (int, tree);
1213 extern int get_access_flags_from_decl (tree);
1214 extern int interface_of_p (tree, tree);
1215 extern int inherits_from_p (tree, tree);
1216 extern int common_enclosing_context_p (tree, tree);
1217 extern int common_enclosing_instance_p (tree, tree);
1218 extern int enclosing_context_p (tree, tree);
1219 extern tree build_result_decl (tree);
1220 extern void set_method_index (tree decl, tree method_index);
1221 extern tree get_method_index (tree decl);
1222 extern void make_class_data (tree);
1223 extern int alloc_name_constant (int, tree);
1224 extern int alloc_constant_fieldref (tree, tree);
1225 extern void emit_register_classes (tree *);
1226 extern tree emit_symbol_table (tree, tree, tree, tree, tree, int);
1227 extern void lang_init_source (int);
1228 extern void write_classfile (tree);
1229 extern char *print_int_node (tree);
1230 extern void finish_class (void);
1231 extern void check_for_initialization (tree, tree);
1232 extern struct CPool *cpool_for_class (tree);
1233 extern int find_class_or_string_constant (struct CPool *, int, tree);
1234
1235 extern tree pushdecl_top_level (tree);
1236 extern tree pushdecl_function_level (tree);
1237 extern tree java_replace_reference (tree, bool);
1238 extern int alloc_class_constant (tree);
1239 extern void init_expr_processing (void);
1240 extern void push_super_field (tree, tree);
1241 extern void init_class_processing (void);
1242 extern void add_type_assertion (tree, int, tree, tree);
1243 extern int can_widen_reference_to (tree, tree);
1244 extern int class_depth (tree);
1245 extern int verify_jvm_instructions_new (struct JCF *, const unsigned char *,
1246                                         long);
1247 extern void maybe_pushlevels (int);
1248 extern void maybe_poplevels (int);
1249 extern void force_poplevels (int);
1250 extern int process_jvm_instruction (int, const unsigned char *, long);
1251 extern int maybe_adjust_start_pc (struct JCF *, int, int, int);
1252 extern void set_local_type (int, tree);
1253 extern int merge_type_state (tree);
1254 extern int push_type_0 (tree);
1255 extern void push_type (tree);
1256 extern void load_type_state (tree);
1257 extern void add_interface (tree, tree);
1258 extern tree force_evaluation_order (tree);
1259 extern tree java_create_object (tree);
1260 extern int verify_constant_pool (struct JCF *);
1261 extern void start_java_method (tree);
1262 extern void end_java_method (void);
1263 extern void give_name_to_locals (struct JCF *);
1264 extern void note_instructions (struct JCF *, tree);
1265 extern void expand_byte_code (struct JCF *, tree);
1266 extern int open_in_zip (struct JCF *, const char *, const char *, int);
1267 extern void set_constant_value (tree, tree);
1268 #ifdef jword
1269 extern int find_constant1 (struct CPool *, int, jword);
1270 extern int find_constant2 (struct CPool *, int, jword, jword);
1271 #endif
1272 extern int find_utf8_constant (struct CPool *, tree);
1273 extern int find_string_constant (struct CPool *, tree);
1274 extern int find_class_constant (struct CPool *, tree);
1275 extern int find_fieldref_index (struct CPool *, tree);
1276 extern int find_methodref_index (struct CPool *, tree);
1277 extern int find_methodref_with_class_index (struct CPool *, tree, tree);
1278 extern void write_constant_pool (struct CPool *, unsigned char *, int);
1279 extern int count_constant_pool_bytes (struct CPool *);
1280 extern int encode_newarray_type (tree);
1281 #ifdef uint64
1282 extern void format_int (char *, jlong, int);
1283 extern void format_uint (char *, uint64, int);
1284 #endif
1285 extern void jcf_trim_old_input (struct JCF *);
1286 #ifdef BUFSIZ
1287 extern void jcf_print_utf8 (FILE *, const unsigned char *, int);
1288 extern void jcf_print_char (FILE *, int);
1289 extern void jcf_print_utf8_replace (FILE *, const unsigned char *, int,
1290                                     int, int);
1291 extern const char* open_class (const char *, struct JCF *, int, const char *);
1292 #endif
1293 extern void java_debug_context (void);
1294 extern void safe_layout_class (tree);
1295
1296 extern tree get_boehm_type_descriptor (tree);
1297 extern bool uses_jv_markobj_p (tree);
1298 extern bool class_has_finalize_method (tree);
1299 extern void java_check_methods (tree);
1300
1301 extern void java_mangle_decl (tree);
1302 extern tree java_mangle_class_field (struct obstack *, tree);
1303 extern tree java_mangle_vtable (struct obstack *, tree);
1304 extern void append_gpp_mangled_name (const char *, int);
1305
1306 extern void add_predefined_file (tree);
1307 extern int predefined_filename_p (tree);
1308
1309 extern tree decl_constant_value (tree);
1310
1311 extern void java_mark_class_local (tree);
1312
1313 extern void java_inlining_merge_static_initializers (tree, void *);
1314 extern void java_inlining_map_static_initializers (tree, void *);
1315
1316 extern void compile_resource_data (const char *name, const char *buffer, int);
1317 extern void compile_resource_file (const char *, const char *);
1318 extern void write_resource_constructor (tree *);
1319 extern tree build_java_empty_stmt (void);
1320 extern tree add_stmt_to_compound (tree, tree, tree);
1321 extern tree java_add_stmt (tree);
1322 extern tree java_add_local_var (tree decl);
1323 extern tree *get_stmts (void);
1324 extern void register_exception_range(struct eh_range *, int, int);
1325
1326 extern void finish_method (tree);
1327 extern void java_expand_body (tree);
1328
1329 extern int get_symbol_table_index (tree, tree, tree *);
1330
1331 extern tree make_catch_class_record (tree, tree);
1332 extern tree emit_catch_table (tree);
1333
1334 extern void gen_indirect_dispatch_tables (tree type);
1335 extern int split_qualified_name (tree *left, tree *right, tree source);
1336 extern int in_same_package (tree, tree);
1337
1338 extern void java_read_sourcefilenames (const char *fsource_filename);
1339
1340 extern void rewrite_reflection_indexes (void *);
1341
1342 #define DECL_FINAL(DECL) DECL_LANG_FLAG_3 (DECL)
1343
1344 /* Access flags etc for a method (a FUNCTION_DECL): */
1345
1346 #define METHOD_DUMMY(DECL) (DECL_LANG_SPECIFIC (DECL)->u.f.dummy)
1347
1348 #define METHOD_PUBLIC(DECL) DECL_LANG_FLAG_1 (FUNCTION_DECL_CHECK (DECL))
1349 #define METHOD_PRIVATE(DECL) TREE_PRIVATE (FUNCTION_DECL_CHECK (DECL))
1350 #define METHOD_PROTECTED(DECL) TREE_PROTECTED (FUNCTION_DECL_CHECK (DECL))
1351 #define METHOD_STATIC(DECL) DECL_LANG_FLAG_2 (FUNCTION_DECL_CHECK (DECL))
1352 #define METHOD_FINAL(DECL) DECL_FINAL (FUNCTION_DECL_CHECK (DECL))
1353 #define METHOD_SYNCHRONIZED(DECL) DECL_LANG_FLAG_4 (FUNCTION_DECL_CHECK (DECL))
1354 #define METHOD_NATIVE(DECL) \
1355   (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.native)
1356 #define METHOD_ABSTRACT(DECL) DECL_LANG_FLAG_5 (FUNCTION_DECL_CHECK (DECL))
1357 #define METHOD_STRICTFP(DECL) \
1358   (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.strictfp)
1359 #define METHOD_INVISIBLE(DECL) \
1360   (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.invisible)
1361 #define METHOD_BRIDGE(DECL) \
1362   (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.bridge)
1363 #define METHOD_VARARGS(DECL) \
1364   (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.f.varargs)
1365
1366 #define CLASS_FILE_P(NODE) TREE_LANG_FLAG_3 (NODE)
1367
1368 /* Other predicates on method decls  */
1369
1370 #define DECL_CONSTRUCTOR_P(DECL) DECL_LANG_FLAG_7 (FUNCTION_DECL_CHECK (DECL))
1371
1372 #define DECL_INIT_P(DECL)   (ID_INIT_P (DECL_NAME (DECL)))
1373 #define DECL_CLINIT_P(DECL) (ID_CLINIT_P (DECL_NAME (DECL)))
1374
1375 /* Predicates on method identifiers. Kept close to other macros using
1376    them  */
1377 #define ID_INIT_P(ID)   ((ID) == init_identifier_node)
1378 #define ID_CLINIT_P(ID) ((ID) == clinit_identifier_node)
1379 #define ID_CLASSDOLLAR_P(ID) ((ID) == classdollar_identifier_node)
1380
1381 /* Access flags etc for variable/field (FIELD_DECL, VAR_DECL, or PARM_DECL): */
1382
1383 #define FIELD_PRIVATE(DECL)     TREE_PRIVATE (VAR_OR_FIELD_CHECK (DECL))
1384 #define FIELD_PROTECTED(DECL)   TREE_PROTECTED (VAR_OR_FIELD_CHECK (DECL))
1385 #define FIELD_PUBLIC(DECL)      DECL_LANG_FLAG_1 (VAR_OR_FIELD_CHECK (DECL))
1386 #define FIELD_STATIC(DECL)      TREE_STATIC (VAR_OR_FIELD_CHECK (DECL))
1387 #define FIELD_FINAL(DECL)       DECL_FINAL (VAR_OR_FIELD_CHECK (DECL))
1388 #define FIELD_VOLATILE(DECL)    DECL_LANG_FLAG_4 (VAR_OR_FIELD_CHECK (DECL))
1389 #define FIELD_TRANSIENT(DECL)   DECL_LANG_FLAG_5 (VAR_OR_FIELD_CHECK (DECL))
1390
1391 /* Access flags etc for a class (a TYPE_DECL): */
1392
1393 #define CLASS_PUBLIC(DECL)      DECL_LANG_FLAG_1 (TYPE_DECL_CHECK (DECL))
1394 #define CLASS_FINAL(DECL)       DECL_FINAL (TYPE_DECL_CHECK (DECL))
1395 #define CLASS_INTERFACE(DECL)   DECL_LANG_FLAG_4 (TYPE_DECL_CHECK (DECL))
1396 #define CLASS_ABSTRACT(DECL)    DECL_LANG_FLAG_5 (TYPE_DECL_CHECK (DECL))
1397 #define CLASS_SUPER(DECL)       DECL_LANG_FLAG_6 (TYPE_DECL_CHECK (DECL))
1398 #define CLASS_STATIC(DECL)      DECL_LANG_FLAG_7 (TYPE_DECL_CHECK (DECL))
1399 #define CLASS_PRIVATE(DECL)     (TYPE_PRIVATE_INNER_CLASS (TREE_TYPE (DECL)))
1400 #define CLASS_PROTECTED(DECL)   (TYPE_PROTECTED_INNER_CLASS (TREE_TYPE (DECL)))
1401 #define CLASS_STRICTFP(DECL)    (TYPE_STRICTFP (TREE_TYPE (DECL)))
1402 #define CLASS_ENUM(DECL)        (TYPE_ENUM (TREE_TYPE (DECL)))
1403 #define CLASS_USES_ASSERTIONS(DECL) (TYPE_USES_ASSERTIONS (TREE_TYPE (DECL)))
1404 #define CLASS_SYNTHETIC(DECL)   (TYPE_SYNTHETIC (TREE_TYPE (DECL)))
1405 #define CLASS_ANNOTATION(DECL)  (TYPE_ANNOTATION (TREE_TYPE (DECL)))
1406
1407 /* @deprecated marker flag on methods, fields and classes */
1408
1409 #define METHOD_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
1410 #define FIELD_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
1411 #define CLASS_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
1412 #define DECL_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
1413
1414 /* The number of virtual methods in this class's dispatch table.
1415    Does not include initial two dummy entries (one points to the
1416    Class object, and the other is for G++ -fvtable-thunks compatibility). */
1417 #define TYPE_NVIRTUALS(TYPE) BINFO_VIRTUALS (TYPE_BINFO (TYPE))
1418
1419 /* A TREE_VEC (indexed by DECL_VINDEX) containing this class's
1420    virtual methods. */
1421 #define TYPE_VTABLE(TYPE) BINFO_VTABLE(TYPE_BINFO (TYPE))
1422
1423 /* Use CLASS_LOADED_P? FIXME */
1424 #define CLASS_COMPLETE_P(DECL) DECL_LANG_FLAG_2 (DECL) 
1425
1426 /* This maps a bytecode offset (PC) to various flags,
1427    listed below (starting with BCODE_). */
1428 extern char *instruction_bits;
1429
1430 /* True iff the byte is the start of an instruction. */
1431 #define BCODE_INSTRUCTION_START 1
1432
1433 /* True iff there is a jump or a return to this location. */
1434 #define BCODE_JUMP_TARGET 2
1435
1436 /* True iff this is the start of an exception handler. */
1437 #define BCODE_EXCEPTION_TARGET 16
1438
1439 /* True iff there is a jump to this location (and it needs a label). */
1440 #define BCODE_TARGET (BCODE_JUMP_TARGET| BCODE_EXCEPTION_TARGET)
1441
1442 /* True iff there is an entry in the linenumber table for this location. */
1443 #define BCODE_HAS_LINENUMBER 32
1444
1445 /* True iff there is more than one entry in the linenumber table for
1446    this location.  (This probably does not make much sense.)  */
1447 #define BCODE_HAS_MULTI_LINENUMBERS 64
1448
1449 /* True if this instruction has been verified. */
1450 #define BCODE_VERIFIED 8
1451
1452 /* A pointer to the line number table of the current method. */
1453 extern const unsigned char *linenumber_table;
1454 /* The length (in items) of the line number table. */
1455 extern int linenumber_count;
1456
1457 /* In type_map, means that slot is uninitialized or otherwise unusable. */
1458 #define TYPE_UNKNOWN NULL_TREE
1459
1460 /* In type_map, means the second half of a 64-bit double or long. */
1461 #define TYPE_SECOND void_type_node
1462
1463 /* In type_map, means the null type (i.e. type of a null reference). */ 
1464 #define TYPE_NULL ptr_type_node
1465
1466 /* In a type map means the type the address subroutine return address. */
1467 #define TYPE_RETURN_ADDR return_address_type_node
1468
1469 /* A array mapping variable/stack slot index to the type current
1470    in that variable/stack slot.
1471    TYPE_UNKNOWN, TYPE_SECOND, and TYPE_NULL are special cases. */
1472 extern tree *type_map;
1473
1474 /* Map a stack index to the type currently in that slot. */
1475 #define stack_type_map (type_map + DECL_MAX_LOCALS (current_function_decl))
1476
1477 /* True iff TYPE takes two variable/stack slots. */
1478 #define TYPE_IS_WIDE(TYPE) \
1479   ((TYPE) == double_type_node || (TYPE) == long_type_node)
1480
1481 /* True iff TYPE is a Java array type. */
1482 #define TYPE_ARRAY_P(TYPE) TYPE_LANG_FLAG_1 (TYPE)
1483
1484 /* True for an INDIRECT_REF created from a 'ARRAY.length' operation. */
1485 #define IS_ARRAY_LENGTH_ACCESS(NODE) TREE_LANG_FLAG_4 (NODE)
1486
1487 /* If FUNCTION_TYPE or METHOD_TYPE: cache for build_java_argument_signature. */
1488 #define TYPE_ARGUMENT_SIGNATURE(TYPE) \
1489   (TREE_CHECK2 (TYPE, FUNCTION_TYPE, METHOD_TYPE)->type.minval)
1490
1491 /* Given an array type, give the type of the elements. */
1492 /* FIXME this use of TREE_TYPE conflicts with something or other. */
1493 #define TYPE_ARRAY_ELEMENT(ATYPE) TREE_TYPE (ATYPE)
1494
1495 /* True if class TYPE has been loaded (i.e. parsed plus laid out).
1496    (The check for CLASS_PARSED_P is needed because of Object and Class.) */
1497 #define CLASS_LOADED_P(TYPE) (TYPE_SIZE (TYPE) != NULL_TREE \
1498                               && (CLASS_PARSED_P(TYPE) || TYPE_ARRAY_P(TYPE)))
1499
1500 /* True if class TYPE has been parsed (first pass). */
1501 #define CLASS_PARSED_P(TYPE) TYPE_LANG_FLAG_2 (TYPE)
1502
1503 /* True if class TYPE was defined in Java source code. */
1504 #define CLASS_FROM_SOURCE_P(TYPE) TYPE_LANG_FLAG_3 (TYPE)
1505
1506 /* True of a RECORD_TYPE of a class/interface type (not array type) */
1507 #define CLASS_P(TYPE) TYPE_LANG_FLAG_4 (TYPE)
1508
1509 /* True if class TYPE was requested (on command line) to be compiled.*/
1510 #define CLASS_FROM_CURRENTLY_COMPILED_P(TYPE) TYPE_LANG_FLAG_5 (TYPE)
1511
1512 /* True if class TYPE is currently being laid out. Helps in detection
1513    of inheritance cycle occurring as a side effect of performing the
1514    layout of a class.  */
1515 #define CLASS_BEING_LAIDOUT(TYPE) TYPE_LANG_FLAG_6 (TYPE)
1516
1517 /* True if ID is a qualified named (contains . or /) */
1518 #define QUALIFIED_P(ID) TREE_LANG_FLAG_2 (ID)
1519
1520 /* True if ID is a command-line specified filename */
1521 #define IS_A_COMMAND_LINE_FILENAME_P(ID) TREE_LANG_FLAG_4 (ID)
1522
1523 /* True if filename ID has already been parsed */
1524 #define HAS_BEEN_ALREADY_PARSED_P(ID) TREE_LANG_FLAG_5 (ID)
1525
1526 /* True if TYPE (a TREE_TYPE denoting a class type) was found to
1527    feature a finalizer method. */
1528 #define HAS_FINALIZER_P(EXPR) TREE_LANG_FLAG_3 (EXPR)
1529
1530 /* True if NODE (a statement) can complete normally. */
1531 #define CAN_COMPLETE_NORMALLY(NODE) TREE_LANG_FLAG_6 (NODE)
1532
1533 /* True if NODE belongs to an inner class TYPE_DECL node.
1534    Verifies that NODE as the attributes of a decl.  */
1535 #define INNER_CLASS_DECL_P(NODE) (TYPE_NAME (TREE_TYPE (NODE)) == NODE  \
1536                                   && DECL_CONTEXT (NODE))
1537
1538 /* True if NODE belongs to an inner class RECORD_TYPE node. Checks
1539    that TYPE_NAME bears a decl. An array type wouldn't.  */
1540 #define INNER_CLASS_TYPE_P(NODE) (TREE_CODE (TYPE_NAME (NODE)) == TYPE_DECL \
1541                                   && DECL_CONTEXT (TYPE_NAME (NODE)))
1542
1543 /* True if the class type NODE was declared in an inner scope and is
1544    not a toplevel class */
1545 #define PURE_INNER_CLASS_TYPE_P(NODE) \
1546   (INNER_CLASS_TYPE_P (NODE) && !CLASS_STATIC (TYPE_NAME (NODE)))
1547
1548 /* True if NODE (a TYPE_DECL or a RECORD_TYPE) is an inner class.  */
1549 #define INNER_CLASS_P(NODE) (TREE_CODE (NODE) == TYPE_DECL ?                  \
1550                              INNER_CLASS_DECL_P (NODE) :                      \
1551                              (TREE_CODE (NODE) == RECORD_TYPE ?               \
1552                               INNER_CLASS_TYPE_P (NODE) :                     \
1553                               (abort (), 0)))
1554
1555 /* On a TYPE_DECL, hold the list of inner classes defined within the
1556    scope of TYPE_DECL.  */
1557 #define DECL_INNER_CLASS_LIST(NODE) DECL_INITIAL (TYPE_DECL_CHECK (NODE))
1558
1559 /* Add a FIELD_DECL to RECORD_TYPE RTYPE.
1560    The field has name NAME (a char*), and type FTYPE.
1561    Unless this is the first field, FIELD most hold the previous field.
1562    FIELD is set to the newly created FIELD_DECL.
1563
1564    We set DECL_ARTIFICIAL so these fields get skipped by make_class_data
1565    if compiling java.lang.Object or java.lang.Class. */
1566
1567 #define PUSH_FIELD(RTYPE, FIELD, NAME, FTYPE) \
1568 { tree _field = build_decl (FIELD_DECL, get_identifier ((NAME)), (FTYPE)); \
1569   if (TYPE_FIELDS (RTYPE) == NULL_TREE) \
1570     TYPE_FIELDS (RTYPE) = _field;       \
1571   else                                  \
1572     TREE_CHAIN(FIELD) = _field;         \
1573   DECL_CONTEXT (_field) = (RTYPE);      \
1574   DECL_ARTIFICIAL (_field) = 1;         \
1575   FIELD = _field; }
1576
1577 #define FINISH_RECORD(RTYPE) layout_type (RTYPE)
1578
1579 /* Start building a RECORD_TYPE constructor with a given TYPE in CONS. */
1580 #define START_RECORD_CONSTRUCTOR(CONS, CTYPE) \
1581   do \
1582     { \
1583       CONS = build_constructor ((CTYPE), VEC_alloc (constructor_elt, gc, 0)); \
1584       CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (CONS), TYPE_FIELDS (CTYPE), \
1585                               NULL); \
1586     } \
1587   while (0)
1588
1589 /* Append a field initializer to CONS for the dummy field for the inherited
1590    fields.  The dummy field has the given VALUE, and the same type as the
1591    super-class.   Must be specified before calls to PUSH_FIELD_VALUE. */
1592 #define PUSH_SUPER_VALUE(CONS, VALUE) \
1593   do \
1594     { \
1595       constructor_elt *_elt___ = VEC_last (constructor_elt, \
1596                                            CONSTRUCTOR_ELTS (CONS)); \
1597       tree _next___ = TREE_CHAIN (_elt___->index); \
1598       gcc_assert (!DECL_NAME (_elt___->index)); \
1599       _elt___->value = VALUE; \
1600       CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (CONS), _next___, NULL); \
1601     } \
1602   while (0)
1603
1604 /* Append a field initializer to CONS for a field with the given VALUE.
1605    NAME is a char* string used for error checking;
1606    the initializer must be specified in order. */
1607 #define PUSH_FIELD_VALUE(CONS, NAME, VALUE)                             \
1608   do \
1609     { \
1610       constructor_elt *_elt___ = VEC_last (constructor_elt, \
1611                                            CONSTRUCTOR_ELTS (CONS)); \
1612       tree _next___ = TREE_CHAIN (_elt___->index); \
1613       gcc_assert (strcmp (IDENTIFIER_POINTER (DECL_NAME (_elt___->index)), \
1614                           NAME) == 0); \
1615       _elt___->value = VALUE; \
1616       CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (CONS), _next___, NULL); \
1617     } \
1618   while (0)
1619
1620 /* Finish creating a record CONSTRUCTOR CONS. */
1621 #define FINISH_RECORD_CONSTRUCTOR(CONS) \
1622   VEC_pop (constructor_elt, CONSTRUCTOR_ELTS (CONS))
1623
1624 #define BLOCK_EXPR_DECLS(NODE)  BLOCK_VARS(NODE)
1625 #define BLOCK_EXPR_BODY(NODE)   BLOCK_SUBBLOCKS(NODE)
1626
1627 #define BUILD_MONITOR_ENTER(WHERE, ARG)                                 \
1628   {                                                                     \
1629     (WHERE) = build_call_nary (int_type_node,                           \
1630                                build_address_of (soft_monitorenter_node), \
1631                                1, (ARG));                               \
1632     TREE_SIDE_EFFECTS (WHERE) = 1;                                      \
1633   }
1634
1635 #define BUILD_MONITOR_EXIT(WHERE, ARG)                                  \
1636   {                                                                     \
1637     (WHERE) = build_call_nary (int_type_node,                           \
1638                                build_address_of (soft_monitorexit_node), \
1639                                1, (ARG));                               \
1640     TREE_SIDE_EFFECTS (WHERE) = 1;                                      \
1641   }
1642
1643 /* True when we can perform static class initialization optimization */
1644 #define STATIC_CLASS_INIT_OPT_P() \
1645   (flag_optimize_sci && (optimize >= 2))
1646
1647 /* These are the possible values for the `state' field of the class
1648    structure.  This must be kept in sync with libgcj.  */
1649 enum
1650 {
1651   JV_STATE_NOTHING = 0,         /* Set by compiler.  */
1652
1653   JV_STATE_PRELOADING = 1,      /* Can do _Jv_FindClass.  */
1654   JV_STATE_LOADING = 3,         /* Has super installed.  */
1655   JV_STATE_READ = 4,            /* Has been completely defined.  */
1656   JV_STATE_LOADED = 5,          /* Has Miranda methods defined.  */
1657
1658   JV_STATE_COMPILED = 6,        /* This was a compiled class.  */
1659
1660   JV_STATE_PREPARED = 7,        /* Layout & static init done.  */
1661   JV_STATE_LINKED = 9,          /* Strings interned.  */
1662
1663   JV_STATE_IN_PROGRESS = 10,    /* <Clinit> running.  */
1664   JV_STATE_ERROR = 12,
1665
1666   JV_STATE_DONE = 14            /* Must be last.  */
1667 };
1668
1669 #undef DEBUG_JAVA_BINDING_LEVELS
1670
1671 /* In a LABELED_BLOCK_EXPR node.  */
1672 #define LABELED_BLOCK_LABEL(NODE) \
1673   TREE_OPERAND_CHECK_CODE (NODE, LABELED_BLOCK_EXPR, 0)
1674 #define LABELED_BLOCK_BODY(NODE) \
1675   TREE_OPERAND_CHECK_CODE (NODE, LABELED_BLOCK_EXPR, 1)
1676
1677 /* In an EXIT_BLOCK_EXPR node.  */
1678 #define EXIT_BLOCK_LABELED_BLOCK(NODE) \
1679   TREE_OPERAND_CHECK_CODE (NODE, EXIT_BLOCK_EXPR, 0)
1680
1681 extern void java_genericize (tree);
1682 extern int java_gimplify_expr (tree *, tree *, tree *);
1683
1684 extern FILE *finput;
1685
1686 #endif /* ! GCC_JAVA_TREE_H */