OSDN Git Service

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