OSDN Git Service

* stor-layout.c (layout_type, set_sizetype): early_type_list is
[pf3gnuchains/gcc-fork.git] / gcc / java / decl.c
1 /* Process declarations and variables for the GNU compiler for the
2    Java(TM) language.
3    Copyright (C) 1996, 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 "config.h"
29 #include "system.h"
30 #include "tree.h"
31 #include "toplev.h"
32 #include "flags.h"
33 #include "java-tree.h"
34 #include "jcf.h"
35 #include "toplev.h"
36 #include "function.h"
37 #include "except.h"
38 #include "defaults.h"
39 #include "java-except.h"
40
41 #if defined (DEBUG_JAVA_BINDING_LEVELS)
42 extern void indent PROTO((void));
43 #endif
44
45 static tree push_jvm_slot PARAMS ((int, tree));
46 static tree lookup_name_current_level PARAMS ((tree));
47 static tree push_promoted_type PARAMS ((const char *, tree));
48 static struct binding_level *make_binding_level PARAMS ((void));
49
50 /* Set to non-zero value in order to emit class initilization code
51    before static field references.  */
52 extern int always_initialize_class_p;
53
54 #ifndef INT_TYPE_SIZE
55 #define INT_TYPE_SIZE BITS_PER_WORD
56 #endif
57
58 /* The DECL_MAP is a mapping from (index, type) to a decl node.
59    If index < max_locals, it is the index of a local variable.
60    if index >= max_locals, then index-max_locals is a stack slot.
61    The DECL_MAP mapping is represented as a TREE_VEC whose elements
62    are a list of decls (VAR_DECL or PARM_DECL) chained by
63    DECL_LOCAL_SLOT_CHAIN; the index finds the TREE_VEC element, and then
64    we search the chain for a decl with a matching TREE_TYPE. */
65
66 tree decl_map;
67
68 /* A list of local variables VAR_DECLs for this method that we have seen
69    debug information, but we have not reached their starting (byte) PC yet. */
70
71 tree pending_local_decls = NULL_TREE;
72
73 /* Push a local variable or stack slot into the decl_map,
74    and assign it an rtl. */
75
76 #if defined(DEBUG_JAVA_BINDING_LEVELS)
77 int binding_depth = 0;
78 int is_class_level = 0;
79 int current_pc;
80
81 void
82 indent ()
83 {
84   register unsigned i;
85
86   for (i = 0; i < binding_depth*2; i++)
87     putc (' ', stderr);
88 }
89 #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
90
91 static tree
92 push_jvm_slot (index, decl)
93      int index;
94      tree decl;
95 {
96   struct rtx_def *rtl = NULL;
97   tree type = TREE_TYPE (decl);
98   tree tmp;
99
100   DECL_CONTEXT (decl) = current_function_decl;
101   layout_decl (decl, 0);
102
103   /* See if we have an appropriate rtl (i.e. same mode) at this index.
104      If so, we must use it. */ 
105   tmp = TREE_VEC_ELT (decl_map, index);
106   while (tmp != NULL_TREE)
107     {
108       if (TYPE_MODE (type) == TYPE_MODE (TREE_TYPE (tmp)))
109         rtl = DECL_RTL (tmp);
110       if (rtl != NULL)
111         break;
112      tmp = DECL_LOCAL_SLOT_CHAIN (tmp);
113     }
114   if (rtl != NULL)
115     DECL_RTL (decl) = rtl;
116   else
117     {
118       if (index >= DECL_MAX_LOCALS (current_function_decl))
119         DECL_REGISTER (decl) = 1;
120       expand_decl (decl);
121     }
122
123   /* Now link the decl into the decl_map. */
124   if (DECL_LANG_SPECIFIC (decl) == NULL)
125     {
126       DECL_LANG_SPECIFIC (decl)
127         = (struct lang_decl *) permalloc (sizeof (struct lang_decl_var));
128       DECL_LOCAL_START_PC (decl) = 0;
129       DECL_LOCAL_END_PC (decl) = DECL_CODE_LENGTH (current_function_decl);
130       DECL_LOCAL_SLOT_NUMBER (decl) = index;
131     }
132   DECL_LOCAL_SLOT_CHAIN (decl) = TREE_VEC_ELT (decl_map, index);
133   TREE_VEC_ELT (decl_map, index) = decl;
134   return decl;
135 }
136
137 /* Find a VAR_DECL (or PARM_DECL) at local index INDEX that has type TYPE,
138    that is valid at PC (or -1 if any pc).
139    If there is no existing matching decl, allocate one.  */
140
141 tree
142 find_local_variable (index, type, pc)
143      int index;
144      tree type;
145      int pc;
146 {
147   tree decl = TREE_VEC_ELT (decl_map, index);
148   tree best = NULL_TREE;
149
150   while (decl != NULL_TREE)
151     {
152       int in_range;
153       in_range = pc < 0
154         || (pc >= DECL_LOCAL_START_PC (decl)
155             && pc < DECL_LOCAL_END_PC (decl));
156
157       if ((TREE_TYPE (decl) == type
158            || (TREE_CODE (TREE_TYPE (decl)) == TREE_CODE (type)
159                && TYPE_PRECISION (TREE_TYPE (decl)) <= 32
160                && TYPE_PRECISION (type) <= 32
161                && TREE_CODE (type) != POINTER_TYPE)
162            || (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
163                && type == ptr_type_node))
164            && in_range)
165         {
166           if (best == NULL_TREE
167               || (TREE_TYPE (decl) == type && TREE_TYPE (best) != type)
168               || DECL_LOCAL_START_PC (decl) > DECL_LOCAL_START_PC (best)
169               || DECL_LOCAL_END_PC (decl) < DECL_LOCAL_START_PC (decl))
170             best = decl;
171         }
172       decl = DECL_LOCAL_SLOT_CHAIN (decl);
173     }
174   if (best != NULL_TREE)
175     return best;
176   return push_jvm_slot (index, build_decl (VAR_DECL, NULL_TREE, type));
177 }
178
179
180 /* Same as find_local_index, except that INDEX is a stack index. */
181
182 tree
183 find_stack_slot (index, type)
184      int index;
185      tree type;
186 {
187   return find_local_variable (index + DECL_MAX_LOCALS (current_function_decl),
188                               type, -1);
189 }
190
191 struct binding_level
192   {
193     /* A chain of _DECL nodes for all variables, constants, functions,
194      * and typedef types.  These are in the reverse of the order supplied.
195      */
196     tree names;
197
198     /* For each level, a list of shadowed outer-level local definitions
199        to be restored when this level is popped.
200        Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
201        whose TREE_VALUE is its old definition (a kind of ..._DECL node).  */
202     tree shadowed;
203
204     /* For each level (except not the global one),
205        a chain of BLOCK nodes for all the levels
206        that were entered and exited one level down.  */
207     tree blocks;
208
209     /* The BLOCK node for this level, if one has been preallocated.
210        If 0, the BLOCK is allocated (if needed) when the level is popped.  */
211     tree this_block;
212
213     /* The binding level which this one is contained in (inherits from).  */
214     struct binding_level *level_chain;
215
216     /* 1 means make a BLOCK for this level regardless of all else.
217        2 for temporary binding contours created by the compiler.  */
218     char keep;
219
220     /* Nonzero means make a BLOCK if this level has any subblocks.  */
221     char keep_if_subblocks;
222
223     /* Nonzero if this level can safely have additional
224        cleanup-needing variables added to it.  */
225     char more_cleanups_ok;
226     char have_cleanups;
227
228     /* The bytecode PC that marks the end of this level. */
229     int end_pc;
230     /* The bytecode PC that marks the start of this level. */
231     int start_pc;
232
233 #if defined(DEBUG_JAVA_BINDING_LEVELS)
234     /* Binding depth at which this level began.  */
235     unsigned binding_depth;
236 #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
237   };
238
239 #define NULL_BINDING_LEVEL (struct binding_level *) NULL
240
241 /* The binding level currently in effect.  */
242
243 static struct binding_level *current_binding_level;
244
245 /* A chain of binding_level structures awaiting reuse.  */
246
247 static struct binding_level *free_binding_level;
248
249 /* The outermost binding level, for names of file scope.
250    This is created when the compiler is started and exists
251    through the entire run.  */
252
253 static struct binding_level *global_binding_level;
254
255 /* A PC value bigger than any PC value we may ever may encounter. */
256
257 #define LARGEST_PC (( (unsigned int)1 << (HOST_BITS_PER_INT - 1)) - 1)
258
259 /* Binding level structures are initialized by copying this one.  */
260
261 static struct binding_level clear_binding_level
262   = {NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE,
263        NULL_BINDING_LEVEL, 0, 0, 0, 0, LARGEST_PC, 0};
264
265 #if 0
266 /* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
267    that have names.  Here so we can clear out their names' definitions
268    at the end of the function.  */
269
270 static tree named_labels;
271
272 /* A list of LABEL_DECLs from outer contexts that are currently shadowed.  */
273
274 static tree shadowed_labels;
275 #endif
276
277 int flag_traditional;
278
279 /* Nonzero means unconditionally make a BLOCK for the next level pushed.  */
280
281 static int keep_next_level_flag;
282
283 /* Nonzero means make a BLOCK for the next level pushed
284    if it has subblocks.  */
285
286 static int keep_next_if_subblocks;
287   
288 tree object_type_node;
289 tree unqualified_object_id_node;
290 tree object_ptr_type_node;
291 tree string_type_node;
292 tree string_ptr_type_node;
293 tree throwable_type_node;
294 tree runtime_exception_type_node;
295 tree error_exception_type_node;
296 tree *predef_filenames;
297 int  predef_filenames_size;
298
299 tree boolean_type_node;
300
301 tree return_address_type_node;
302
303 tree byte_type_node;
304 tree short_type_node;
305 tree int_type_node;
306 tree long_type_node;
307
308 tree promoted_byte_type_node;
309 tree promoted_short_type_node;
310 tree promoted_char_type_node;
311 tree promoted_boolean_type_node;
312
313 tree unsigned_byte_type_node;
314 tree unsigned_short_type_node;
315 tree unsigned_int_type_node;
316 tree unsigned_long_type_node;
317
318 /* The type for struct methodtable. */
319 tree methodtable_type;
320 tree methodtable_ptr_type;
321
322 tree utf8const_type;
323 tree utf8const_ptr_type;
324 tree class_type_node;
325 tree class_ptr_type;
326 tree field_type_node;
327 tree field_ptr_type_node;
328 tree field_info_union_node;
329 tree jexception_type;
330 tree jexception_ptr_type;
331 tree lineNumberEntry_type;
332 tree lineNumbers_type;
333 tree constants_type_node;
334 tree dtable_type;
335 tree dtable_ptr_type;
336 tree method_type_node;
337 tree method_ptr_type_node;
338 tree nativecode_ptr_array_type_node;
339 tree one_elt_array_domain_type;
340 tree access_flags_type_node;
341 tree class_dtable_decl;
342
343 /* Expressions that are constants with value zero, of types
344    `long', `float' and `double'.  */
345 tree long_zero_node;
346 tree float_zero_node;
347 tree double_zero_node;
348
349 tree empty_stmt_node;
350
351 /* Nodes for boolean constants TRUE and FALSE. */
352 tree boolean_true_node;
353 tree boolean_false_node;
354
355 tree TYPE_identifier_node;
356 tree init_identifier_node;
357 tree clinit_identifier_node;
358 tree finit_identifier_node;
359 tree void_signature_node;
360 tree length_identifier_node;
361 tree this_identifier_node;
362 tree super_identifier_node;
363 tree continue_identifier_node;
364 tree access0_identifier_node;   /* 1.1 */
365 tree end_params_node;
366
367 /* References to internal libjava functions we use. */
368 tree alloc_object_node;
369 tree soft_instanceof_node;
370 tree soft_checkcast_node;
371 tree soft_initclass_node;
372 tree soft_newarray_node;
373 tree soft_anewarray_node;
374 tree soft_multianewarray_node;
375 tree soft_badarrayindex_node;
376 tree throw_node [2];
377 tree soft_checkarraystore_node;
378 tree soft_monitorenter_node;
379 tree soft_monitorexit_node;
380 tree soft_lookupinterfacemethod_node;
381 tree soft_fmod_node;
382 tree soft_exceptioninfo_call_node;
383 tree soft_idiv_node;
384 tree soft_irem_node;
385 tree soft_ldiv_node;
386 tree soft_lrem_node;
387
388 /* Build (and pushdecl) a "promoted type" for all standard
389    types shorter than int.  */
390
391 static tree
392 push_promoted_type (name, actual_type)
393      const char *name;
394      tree actual_type;
395 {
396   tree type = make_node (TREE_CODE (actual_type));
397 #if 1
398   tree in_min = TYPE_MIN_VALUE (int_type_node);
399   tree in_max = TYPE_MAX_VALUE (int_type_node);
400 #else
401   tree in_min = TYPE_MIN_VALUE (actual_type);
402   tree in_max = TYPE_MAX_VALUE (actual_type);
403 #endif
404   TYPE_MIN_VALUE (type) = copy_node (in_min);
405   TREE_TYPE (TYPE_MIN_VALUE (type)) = type;
406   TYPE_MAX_VALUE (type) = copy_node (in_max);
407   TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
408   TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node);
409   layout_type (type);
410   pushdecl (build_decl (TYPE_DECL, get_identifier (name), type));
411   return type;
412 }
413
414 /* Nodes for integer constants.  */
415 tree integer_two_node;
416 tree integer_four_node;
417 tree integer_negative_one_node;
418
419 /* Return a definition for a builtin function named NAME and whose data type
420    is TYPE.  TYPE should be a function type with argument types.
421    FUNCTION_CODE tells later passes how to compile calls to this function.
422    See tree.h for its possible values.
423
424    If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
425    the name to be called if we can't opencode the function.  */
426
427 tree
428 builtin_function (name, type, function_code, class, library_name)
429      const char *name;
430      tree type;
431      int function_code;
432      enum built_in_class class;
433      const char *library_name;
434 {
435   tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
436   DECL_EXTERNAL (decl) = 1;
437   TREE_PUBLIC (decl) = 1;
438   if (library_name)
439     DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
440   make_decl_rtl (decl, NULL_PTR, 1);
441   pushdecl (decl);
442   DECL_BUILT_IN_CLASS (decl) = class;
443   DECL_FUNCTION_CODE (decl) = function_code;
444   return decl;
445 }
446
447 void
448 init_decl_processing ()
449 {
450   register tree endlink;
451   tree field = NULL_TREE;
452   tree t;
453
454   current_function_decl = NULL;
455   current_binding_level = NULL_BINDING_LEVEL;
456   free_binding_level = NULL_BINDING_LEVEL;
457   pushlevel (0);        /* make the binding_level structure for global names */
458   global_binding_level = current_binding_level;
459
460   /* The code here must be similar to build_common_tree_nodes{,_2} in
461      tree.c, especially as to the order of initializing common nodes.  */
462   error_mark_node = make_node (ERROR_MARK);
463   TREE_TYPE (error_mark_node) = error_mark_node;
464
465   /* Create sizetype first - needed for other types. */
466   initialize_sizetypes ();
467
468   byte_type_node = make_signed_type (8);
469   pushdecl (build_decl (TYPE_DECL, get_identifier ("byte"), byte_type_node));
470   short_type_node = make_signed_type (16);
471   pushdecl (build_decl (TYPE_DECL, get_identifier ("short"), short_type_node));
472   int_type_node = make_signed_type (32);
473   pushdecl (build_decl (TYPE_DECL, get_identifier ("int"), int_type_node));
474   long_type_node = make_signed_type (64);
475   pushdecl (build_decl (TYPE_DECL, get_identifier ("long"), long_type_node));
476
477   unsigned_byte_type_node = make_unsigned_type (8);
478   pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned byte"),
479                         unsigned_byte_type_node));
480   unsigned_short_type_node = make_unsigned_type (16);
481   pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned short"),
482                         unsigned_short_type_node));
483   unsigned_int_type_node = make_unsigned_type (32);
484   pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"),
485                         unsigned_int_type_node));
486   unsigned_long_type_node = make_unsigned_type (64);
487   pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned long"),
488                         unsigned_long_type_node));
489
490   set_sizetype (make_unsigned_type (POINTER_SIZE));
491
492   /* Define these next since types below may used them.  */
493   integer_type_node = type_for_size (INT_TYPE_SIZE, 0);
494   integer_zero_node = build_int_2 (0, 0);
495   integer_one_node = build_int_2 (1, 0);
496   integer_two_node = build_int_2 (2, 0);
497   integer_four_node = build_int_2 (4, 0);
498   integer_negative_one_node = build_int_2 (-1, 0);
499
500   size_zero_node = size_int (0);
501   size_one_node = size_int (1);
502   bitsize_zero_node = bitsize_int (0);
503   bitsize_one_node = bitsize_int (1);
504   bitsize_unit_node = bitsize_int (BITS_PER_UNIT);
505
506   long_zero_node = build_int_2 (0, 0);
507   TREE_TYPE (long_zero_node) = long_type_node;
508
509   void_type_node = make_node (VOID_TYPE);
510   pushdecl (build_decl (TYPE_DECL, get_identifier ("void"), void_type_node));
511   layout_type (void_type_node); /* Uses size_zero_node */
512   ptr_type_node = build_pointer_type (void_type_node);
513   t = make_node (VOID_TYPE);
514   layout_type (t); /* Uses size_zero_node */
515   return_address_type_node = build_pointer_type (t);
516
517   null_pointer_node = build_int_2 (0, 0);
518   TREE_TYPE (null_pointer_node) = ptr_type_node;
519
520   /* Used by the parser to represent empty statements and blocks. */
521   empty_stmt_node = build1 (NOP_EXPR, void_type_node, size_zero_node);
522   CAN_COMPLETE_NORMALLY (empty_stmt_node) = 1;
523
524 #if 0
525   /* Make a type to be the domain of a few array types
526      whose domains don't really matter.
527      200 is small enough that it always fits in size_t
528      and large enough that it can hold most function names for the
529      initializations of __FUNCTION__ and __PRETTY_FUNCTION__.  */
530   short_array_type_node = build_prim_array_type (short_type_node, 200);
531 #endif
532   char_type_node = make_node (CHAR_TYPE);
533   TYPE_PRECISION (char_type_node) = 16;
534   fixup_unsigned_type (char_type_node);
535   pushdecl (build_decl (TYPE_DECL, get_identifier ("char"), char_type_node));
536
537   boolean_type_node = make_node (BOOLEAN_TYPE);
538   TYPE_PRECISION (boolean_type_node) = 1;
539   fixup_unsigned_type (boolean_type_node);
540   pushdecl (build_decl (TYPE_DECL, get_identifier ("boolean"),
541                         boolean_type_node));
542   boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
543   boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
544
545   promoted_byte_type_node
546     = push_promoted_type ("promoted_byte", byte_type_node);
547   promoted_short_type_node
548     = push_promoted_type ("promoted_short", short_type_node);
549   promoted_char_type_node
550     = push_promoted_type ("promoted_char", char_type_node);
551   promoted_boolean_type_node
552     = push_promoted_type ("promoted_boolean", boolean_type_node);
553
554   float_type_node = make_node (REAL_TYPE);
555   TYPE_PRECISION (float_type_node) = 32;
556   pushdecl (build_decl (TYPE_DECL, get_identifier ("float"),
557                         float_type_node));
558   layout_type (float_type_node);
559
560   double_type_node = make_node (REAL_TYPE);
561   TYPE_PRECISION (double_type_node) = 64;
562   pushdecl (build_decl (TYPE_DECL, get_identifier ("double"),
563                         double_type_node));
564   layout_type (double_type_node);
565
566   float_zero_node = build_real (float_type_node, dconst0);
567   double_zero_node = build_real (double_type_node, dconst0);
568
569   /* As your adding items here, please update the code right after
570      this section, so that the filename containing the source code of
571      the pre-defined class gets registered correctly. */
572   unqualified_object_id_node = get_identifier ("Object");
573   object_type_node = lookup_class (get_identifier ("java.lang.Object"));
574   object_ptr_type_node = promote_type (object_type_node);
575   string_type_node = lookup_class (get_identifier ("java.lang.String"));
576   string_ptr_type_node = promote_type (string_type_node);
577   class_type_node = lookup_class (get_identifier ("java.lang.Class"));
578   throwable_type_node = lookup_class (get_identifier ("java.lang.Throwable"));
579   runtime_exception_type_node = 
580     lookup_class (get_identifier ("java.lang.RuntimeException"));
581   error_exception_type_node = 
582     lookup_class (get_identifier ("java.lang.Error"));
583
584   /* This section has to be updated as items are added to the previous
585      section. */
586   predef_filenames_size = 6;
587   predef_filenames = (tree *)xmalloc (predef_filenames_size * sizeof (tree));
588   predef_filenames [0] = get_identifier ("java/lang/Class.java");
589   predef_filenames [1] = get_identifier ("java/lang/Error.java");
590   predef_filenames [2] = get_identifier ("java/lang/Object.java");
591   predef_filenames [3] = get_identifier ("java/lang/RuntimeException.java");
592   predef_filenames [4] = get_identifier ("java/lang/String.java");
593   predef_filenames [5] = get_identifier ("java/lang/Throwable.java");
594
595   methodtable_type = make_node (RECORD_TYPE);
596   layout_type (methodtable_type);
597   build_decl (TYPE_DECL, get_identifier ("methodtable"), methodtable_type);
598   methodtable_ptr_type = build_pointer_type (methodtable_type);
599
600   TYPE_identifier_node = get_identifier ("TYPE");
601   init_identifier_node = get_identifier ("<init>");
602   clinit_identifier_node = get_identifier ("<clinit>");
603   finit_identifier_node = get_identifier ("$finit$");
604   void_signature_node = get_identifier ("()V");
605   length_identifier_node = get_identifier ("length");
606   this_identifier_node = get_identifier ("this");
607   super_identifier_node = get_identifier ("super");
608   continue_identifier_node = get_identifier ("continue");
609   access0_identifier_node = get_identifier ("access$0");
610
611   /* for lack of a better place to put this stub call */
612   init_expr_processing();
613
614   utf8const_type = make_node (RECORD_TYPE);
615   PUSH_FIELD (utf8const_type, field, "hash", unsigned_short_type_node);
616   PUSH_FIELD (utf8const_type, field, "length", unsigned_short_type_node);
617   FINISH_RECORD (utf8const_type);
618   utf8const_ptr_type = build_pointer_type (utf8const_type);
619
620   constants_type_node = make_node (RECORD_TYPE);
621   PUSH_FIELD (constants_type_node, field, "size", unsigned_int_type_node);
622   PUSH_FIELD (constants_type_node, field, "tags", ptr_type_node);
623   PUSH_FIELD (constants_type_node, field, "data", ptr_type_node);
624   FINISH_RECORD (constants_type_node);
625   build_decl (TYPE_DECL, get_identifier ("constants"), constants_type_node);
626
627   access_flags_type_node = unsigned_short_type_node;
628
629   dtable_type = make_node (RECORD_TYPE);
630   dtable_ptr_type = build_pointer_type (dtable_type);
631
632   PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type);
633   /* This isn't exactly true, but it is what we have in the source.
634      There is an unresolved issue here, which is whether the vtable
635      should be marked by the GC.  */
636   if (! flag_hash_synchronization)
637     PUSH_FIELD (object_type_node, field, "sync_info",
638                 build_pointer_type (object_type_node));
639   for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
640     FIELD_PRIVATE (t) = 1;
641   FINISH_RECORD (object_type_node);
642
643   class_dtable_decl = build_dtable_decl (class_type_node);
644   TREE_STATIC (class_dtable_decl) = 1;
645   DECL_ARTIFICIAL (class_dtable_decl) = 1;
646   DECL_IGNORED_P (class_dtable_decl) = 1;
647   rest_of_decl_compilation (class_dtable_decl, (char*) 0, 1, 0);
648
649   field_type_node = make_node (RECORD_TYPE);
650   field_ptr_type_node = build_pointer_type (field_type_node);
651   method_type_node = make_node (RECORD_TYPE);
652   method_ptr_type_node = build_pointer_type (method_type_node);
653
654   set_super_info (0, class_type_node, object_type_node, 0);
655   set_super_info (0, string_type_node, object_type_node, 0);
656   class_ptr_type = build_pointer_type (class_type_node);
657
658   PUSH_FIELD (class_type_node, field, "next", class_ptr_type);
659   PUSH_FIELD (class_type_node, field, "name", utf8const_ptr_type);
660   PUSH_FIELD (class_type_node, field, "accflags", access_flags_type_node);
661   PUSH_FIELD (class_type_node, field, "superclass", class_ptr_type);
662   PUSH_FIELD (class_type_node, field, "constants", constants_type_node);
663   PUSH_FIELD (class_type_node, field, "methods", method_ptr_type_node);
664   PUSH_FIELD (class_type_node, field, "method_count", short_type_node);
665   PUSH_FIELD (class_type_node, field, "vtable_method_count", short_type_node);
666   PUSH_FIELD (class_type_node, field, "fields", field_ptr_type_node);
667   PUSH_FIELD (class_type_node, field, "size_in_bytes", int_type_node);
668   PUSH_FIELD (class_type_node, field, "field_count", short_type_node);
669   PUSH_FIELD (class_type_node, field, "static_field_count", short_type_node);
670   PUSH_FIELD (class_type_node, field, "vtable", dtable_ptr_type);
671   PUSH_FIELD (class_type_node, field, "interfaces",
672               build_pointer_type (class_ptr_type));
673   PUSH_FIELD (class_type_node, field, "loader", ptr_type_node);
674   PUSH_FIELD (class_type_node, field, "interface_count", short_type_node);
675   PUSH_FIELD (class_type_node, field, "state", byte_type_node);
676   PUSH_FIELD (class_type_node, field, "thread", ptr_type_node);
677   PUSH_FIELD (class_type_node, field, "depth", short_type_node);
678   PUSH_FIELD (class_type_node, field, "ancestors", ptr_type_node);
679   PUSH_FIELD (class_type_node, field, "idt", ptr_type_node);  
680   for (t = TYPE_FIELDS (class_type_node);  t != NULL_TREE;  t = TREE_CHAIN (t))
681     FIELD_PRIVATE (t) = 1;
682   push_super_field (class_type_node, object_type_node);
683   FINISH_RECORD (class_type_node);
684   build_decl (TYPE_DECL, get_identifier ("Class"), class_type_node);
685
686   field_info_union_node = make_node (UNION_TYPE);
687   PUSH_FIELD (field_info_union_node, field, "boffset", int_type_node);
688   PUSH_FIELD (field_info_union_node, field, "addr", ptr_type_node);
689 #if 0
690   PUSH_FIELD (field_info_union_node, field, "idx", unsigned_short_type_node);
691 #endif
692   layout_type (field_info_union_node);
693
694   PUSH_FIELD (field_type_node, field, "name", utf8const_ptr_type);
695   PUSH_FIELD (field_type_node, field, "type", class_ptr_type);
696   PUSH_FIELD (field_type_node, field, "accflags", access_flags_type_node);
697   PUSH_FIELD (field_type_node, field, "bsize", unsigned_short_type_node);
698   PUSH_FIELD (field_type_node, field, "info", field_info_union_node);
699   FINISH_RECORD (field_type_node);
700   CLASS_LOADED_P (field_type_node) = 1;
701   build_decl (TYPE_DECL, get_identifier ("Field"), field_type_node);
702
703   one_elt_array_domain_type = build_index_type (integer_one_node);
704   nativecode_ptr_array_type_node
705     = build_array_type (nativecode_ptr_type_node, one_elt_array_domain_type);
706
707   PUSH_FIELD (dtable_type, field, "class", class_ptr_type);
708   PUSH_FIELD (dtable_type, field, "methods", nativecode_ptr_array_type_node);
709   FINISH_RECORD (dtable_type);
710   build_decl (TYPE_DECL, get_identifier ("dispatchTable"), dtable_type);
711
712 #define jint_type int_type_node
713 #define jint_ptr_type ptr_type_node
714
715   jexception_type = make_node (RECORD_TYPE);
716   PUSH_FIELD (jexception_type, field, "start_pc", ptr_type_node);
717   PUSH_FIELD (jexception_type, field, "end_pc", ptr_type_node);
718   PUSH_FIELD (jexception_type, field, "handler_pc", ptr_type_node);
719   PUSH_FIELD (jexception_type, field, "catch_type", class_ptr_type);
720   FINISH_RECORD (jexception_type);
721   build_decl (TYPE_DECL, get_identifier ("jexception"), field_type_node);
722   jexception_ptr_type = build_pointer_type (jexception_type);
723
724   lineNumberEntry_type = make_node (RECORD_TYPE);
725   PUSH_FIELD (lineNumberEntry_type, field, "line_nr", unsigned_short_type_node);
726   PUSH_FIELD (lineNumberEntry_type, field, "start_pc", ptr_type_node);
727   FINISH_RECORD (lineNumberEntry_type);
728
729   lineNumbers_type = make_node (RECORD_TYPE);
730   PUSH_FIELD (lineNumbers_type, field, "length", unsigned_int_type_node);
731   FINISH_RECORD (lineNumbers_type);
732
733 #define instn_ptr_type_node ptr_type_node       /* XXX JH */
734
735 #define lineNumbers_ptr_type_node build_pointer_type(lineNumbers_type)
736
737   PUSH_FIELD (method_type_node, field, "name", utf8const_ptr_type);
738   PUSH_FIELD (method_type_node, field, "signature", utf8const_ptr_type);
739   PUSH_FIELD (method_type_node, field, "accflags", access_flags_type_node);
740   PUSH_FIELD (method_type_node, field, "ncode", nativecode_ptr_type_node);
741   FINISH_RECORD (method_type_node);
742   CLASS_LOADED_P (method_type_node) = 1;
743   build_decl (TYPE_DECL, get_identifier ("Method"), method_type_node);
744
745   endlink = end_params_node = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
746
747   t = tree_cons (NULL_TREE, class_ptr_type,
748                  tree_cons (NULL_TREE, int_type_node, endlink));
749   alloc_object_node = builtin_function ("_Jv_AllocObject",
750                                         build_function_type (ptr_type_node, t),
751                                         0, NOT_BUILT_IN, NULL_PTR);
752   DECL_IS_MALLOC (alloc_object_node) = 1;
753   soft_initclass_node = builtin_function ("_Jv_InitClass",
754                                           build_function_type (void_type_node,
755                                                                t),
756                                           0, NOT_BUILT_IN,
757                                           NULL_PTR);
758   t = tree_cons (NULL_TREE, ptr_type_node, endlink);
759   throw_node[0] = builtin_function ("_Jv_Throw",
760                                     build_function_type (ptr_type_node, t),
761                                     0, NOT_BUILT_IN, NULL_PTR);
762   /* Mark throw_nodes as `noreturn' functions with side effects.  */
763   TREE_THIS_VOLATILE (throw_node[0]) = 1;
764   TREE_SIDE_EFFECTS (throw_node[0]) = 1;
765   t = tree_cons (NULL_TREE, ptr_type_node, endlink);
766   throw_node[1] = builtin_function ("_Jv_Sjlj_Throw",
767                                     build_function_type (ptr_type_node, t),
768                                     0, NOT_BUILT_IN, NULL_PTR);
769   TREE_THIS_VOLATILE (throw_node[1]) = 1;
770   TREE_SIDE_EFFECTS (throw_node[1]) = 1;
771   t = build_function_type (int_type_node, endlink);
772   soft_monitorenter_node 
773     = builtin_function ("_Jv_MonitorEnter", t, 0, NOT_BUILT_IN,
774                         NULL_PTR);
775   soft_monitorexit_node 
776     = builtin_function ("_Jv_MonitorExit", t, 0, NOT_BUILT_IN,
777                         NULL_PTR);
778   
779   t = tree_cons (NULL_TREE, int_type_node, 
780                  tree_cons (NULL_TREE, int_type_node, endlink));
781   soft_newarray_node
782       = builtin_function ("_Jv_NewArray",
783                           build_function_type(ptr_type_node, t),
784                           0, NOT_BUILT_IN, NULL_PTR);
785   DECL_IS_MALLOC (soft_newarray_node) = 1;
786
787   t = tree_cons (NULL_TREE, int_type_node,
788                  tree_cons (NULL_TREE, class_ptr_type,
789                             tree_cons (NULL_TREE, object_ptr_type_node, endlink)));
790   soft_anewarray_node
791       = builtin_function ("_Jv_NewObjectArray",
792                           build_function_type (ptr_type_node, t),
793                           0, NOT_BUILT_IN, NULL_PTR);
794   DECL_IS_MALLOC (soft_anewarray_node) = 1;
795
796   t = tree_cons (NULL_TREE, ptr_type_node,
797                  tree_cons (NULL_TREE, int_type_node, endlink));
798   soft_multianewarray_node
799       = builtin_function ("_Jv_NewMultiArray",
800                           build_function_type (ptr_type_node, t),
801                           0, NOT_BUILT_IN, NULL_PTR);
802   DECL_IS_MALLOC (soft_multianewarray_node) = 1;
803
804   t = build_function_type (void_type_node, 
805                            tree_cons (NULL_TREE, int_type_node, endlink));
806   soft_badarrayindex_node
807       = builtin_function ("_Jv_ThrowBadArrayIndex", t, 
808                           0, NOT_BUILT_IN, NULL_PTR);
809   /* Mark soft_badarrayindex_node as a `noreturn' function with side
810      effects.  */
811   TREE_THIS_VOLATILE (soft_badarrayindex_node) = 1;
812   TREE_SIDE_EFFECTS (soft_badarrayindex_node) = 1;
813
814   t = tree_cons (NULL_TREE, class_ptr_type,
815                  tree_cons (NULL_TREE, object_ptr_type_node, endlink));
816   soft_checkcast_node
817     = builtin_function ("_Jv_CheckCast",
818                         build_function_type (ptr_type_node, t),
819                         0, NOT_BUILT_IN, NULL_PTR);
820   t = tree_cons (NULL_TREE, object_ptr_type_node,
821                  tree_cons (NULL_TREE, class_ptr_type, endlink));
822   soft_instanceof_node
823     = builtin_function ("_Jv_IsInstanceOf",
824                         build_function_type (boolean_type_node, t),
825                         0, NOT_BUILT_IN, NULL_PTR);
826   t = tree_cons (NULL_TREE, object_ptr_type_node,
827                  tree_cons (NULL_TREE, object_ptr_type_node, endlink));
828   soft_checkarraystore_node
829     = builtin_function ("_Jv_CheckArrayStore",
830                         build_function_type (void_type_node, t),
831                         0, NOT_BUILT_IN, NULL_PTR);
832   t = tree_cons (NULL_TREE, ptr_type_node,
833                  tree_cons (NULL_TREE, ptr_type_node,
834                             tree_cons (NULL_TREE, int_type_node, endlink)));
835   soft_lookupinterfacemethod_node 
836     = builtin_function ("_Jv_LookupInterfaceMethodIdx",
837                         build_function_type (ptr_type_node, t),
838                         0, NOT_BUILT_IN, NULL_PTR);
839   t = tree_cons (NULL_TREE, double_type_node,
840                  tree_cons (NULL_TREE, double_type_node, endlink));
841   soft_fmod_node
842     = builtin_function ("__builtin_fmod",
843                         build_function_type (double_type_node, t),
844                         BUILT_IN_FMOD, BUILT_IN_NORMAL, "fmod");
845
846   soft_exceptioninfo_call_node
847     = build (CALL_EXPR, 
848              ptr_type_node,
849              build_address_of 
850                (builtin_function ("_Jv_exception_info", 
851                                   build_function_type (ptr_type_node, endlink),
852                                   0, NOT_BUILT_IN, NULL_PTR)),
853              NULL_TREE, NULL_TREE);
854   TREE_SIDE_EFFECTS (soft_exceptioninfo_call_node) = 1;
855 #if 0
856   t = tree_cons (NULL_TREE, float_type_node,
857                  tree_cons (NULL_TREE, float_type_node, endlink));
858   soft_fmodf_node
859     = builtin_function ("__builtin_fmodf",
860                         build_function_type (float_type_node, t),
861                         BUILT_IN_FMOD, BUILT_IN_NORMAL, "fmodf");
862 #endif
863     
864   soft_idiv_node
865     = builtin_function ("_Jv_divI",
866                         build_function_type (int_type_node, t),
867                         0, NOT_BUILT_IN, NULL_PTR);
868
869   soft_irem_node
870     = builtin_function ("_Jv_remI",
871                         build_function_type (int_type_node, t),
872                         0, NOT_BUILT_IN, NULL_PTR);
873
874   soft_ldiv_node
875     = builtin_function ("_Jv_divJ",
876                         build_function_type (long_type_node, t),
877                         0, NOT_BUILT_IN, NULL_PTR);
878
879   soft_lrem_node
880     = builtin_function ("_Jv_remJ",
881                         build_function_type (long_type_node, t),
882                         0, NOT_BUILT_IN, NULL_PTR);
883
884   init_class_processing ();
885 }
886
887
888 /* Look up NAME in the current binding level and its superiors
889    in the namespace of variables, functions and typedefs.
890    Return a ..._DECL node of some kind representing its definition,
891    or return 0 if it is undefined.  */
892
893 tree
894 lookup_name (name)
895      tree name;
896 {
897   register tree val;
898   if (current_binding_level != global_binding_level
899       && IDENTIFIER_LOCAL_VALUE (name))
900     val = IDENTIFIER_LOCAL_VALUE (name);
901   else
902     val = IDENTIFIER_GLOBAL_VALUE (name);
903   return val;
904 }
905
906 /* Similar to `lookup_name' but look only at current binding level and
907    the previous one if its the parameter level.  */
908
909 static tree
910 lookup_name_current_level (name)
911      tree name;
912 {
913   register tree t;
914
915   if (current_binding_level == global_binding_level)
916     return IDENTIFIER_GLOBAL_VALUE (name);
917
918   if (IDENTIFIER_LOCAL_VALUE (name) == 0)
919     return 0;
920
921   for (t = current_binding_level->names; t; t = TREE_CHAIN (t))
922     if (DECL_NAME (t) == name)
923       break;
924
925   return t;
926 }
927
928 /* Use a binding level to record a labeled block declaration */
929
930 void
931 push_labeled_block (lb)
932     tree lb;
933 {
934   register tree name = DECL_NAME (LABELED_BLOCK_LABEL (lb));
935   register struct binding_level *b = current_binding_level;
936   tree oldlocal = IDENTIFIER_LOCAL_VALUE (name);
937   if (oldlocal != 0)
938       b->shadowed = tree_cons (name, oldlocal, b->shadowed);
939   TREE_CHAIN (lb) = b->names;
940   b->names = lb;
941   IDENTIFIER_LOCAL_VALUE (name) = lb;
942 }
943
944 /* Pop the current binding level, reinstalling values for the previous
945    labeled block */
946
947 void
948 pop_labeled_block ()
949 {
950   struct binding_level *b = current_binding_level;
951   tree label =  b->names;
952   IDENTIFIER_LOCAL_VALUE (DECL_NAME (LABELED_BLOCK_LABEL (label))) = 
953     NULL_TREE;
954   if (b->shadowed)
955     IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (b->shadowed)) = 
956       TREE_VALUE (b->shadowed);
957
958   /* Pop the current level, and free the structure for reuse.  */
959   current_binding_level = current_binding_level->level_chain;
960   b->level_chain = free_binding_level;
961   free_binding_level = b;
962 }
963
964 /* Record a decl-node X as belonging to the current lexical scope.
965    Check for errors (such as an incompatible declaration for the same
966    name already seen in the same scope).
967
968    Returns either X or an old decl for the same name.
969    If an old decl is returned, it may have been smashed
970    to agree with what X says.  */
971
972 tree
973 pushdecl (x)
974      tree x;
975 {
976   register tree t;
977   register tree name = DECL_NAME (x);
978   register struct binding_level *b = current_binding_level;
979   
980   if (TREE_CODE (x) != TYPE_DECL)
981     DECL_CONTEXT (x) = current_function_decl;
982   if (name)
983     {
984       const char *file;
985       int line;
986
987       t = lookup_name_current_level (name);
988       if (t != 0 && t == error_mark_node)
989         /* error_mark_node is 0 for a while during initialization!  */
990         {
991           t = 0;
992           error_with_decl (x, "`%s' used prior to declaration");
993         }
994
995       if (t != 0)
996         {
997           file = DECL_SOURCE_FILE (t);
998           line = DECL_SOURCE_LINE (t);
999         }
1000
1001       /* If we're naming a hitherto-unnamed type, set its TYPE_NAME
1002          to point to the TYPE_DECL.
1003          Since Java does not have typedefs, a type can only have
1004          one (true) name, given by a class, interface, or builtin. */
1005       if (TREE_CODE (x) == TYPE_DECL
1006           && TYPE_NAME (TREE_TYPE (x)) == 0
1007           && TREE_TYPE (x) != error_mark_node)
1008         {
1009           TYPE_NAME (TREE_TYPE (x)) = x;
1010           TYPE_STUB_DECL (TREE_TYPE (x)) = x;
1011         }
1012
1013       /* This name is new in its binding level.
1014          Install the new declaration and return it.  */
1015       if (b == global_binding_level)
1016         {
1017           /* Install a global value.  */
1018           
1019           IDENTIFIER_GLOBAL_VALUE (name) = x;
1020         }
1021       else
1022         {
1023           /* Here to install a non-global value.  */
1024           tree oldlocal = IDENTIFIER_LOCAL_VALUE (name);
1025           IDENTIFIER_LOCAL_VALUE (name) = x;
1026
1027 #if 0
1028           /* Warn if shadowing an argument at the top level of the body.  */
1029           if (oldlocal != 0 && !DECL_EXTERNAL (x)
1030               /* This warning doesn't apply to the parms of a nested fcn.  */
1031               && ! current_binding_level->parm_flag
1032               /* Check that this is one level down from the parms.  */
1033               && current_binding_level->level_chain->parm_flag
1034               /* Check that the decl being shadowed
1035                  comes from the parm level, one level up.  */
1036               && chain_member (oldlocal, current_binding_level->level_chain->names))
1037             {
1038               if (TREE_CODE (oldlocal) == PARM_DECL)
1039                 pedwarn ("declaration of `%s' shadows a parameter",
1040                          IDENTIFIER_POINTER (name));
1041               else
1042                 pedwarn ("declaration of `%s' shadows a symbol from the parameter list",
1043                          IDENTIFIER_POINTER (name));
1044             }
1045
1046           /* Maybe warn if shadowing something else.  */
1047           else if (warn_shadow && !DECL_EXTERNAL (x)
1048                    /* No shadow warnings for internally generated vars.  */
1049                    && DECL_SOURCE_LINE (x) != 0
1050                    /* No shadow warnings for vars made for inlining.  */
1051                    && ! DECL_FROM_INLINE (x))
1052             {
1053               const char *warnstring = 0;
1054
1055               if (TREE_CODE (x) == PARM_DECL
1056                   && current_binding_level->level_chain->parm_flag)
1057                 /* Don't warn about the parm names in function declarator
1058                    within a function declarator.
1059                    It would be nice to avoid warning in any function
1060                    declarator in a declaration, as opposed to a definition,
1061                    but there is no way to tell it's not a definition.  */
1062                 ;
1063               else if (oldlocal != 0 && TREE_CODE (oldlocal) == PARM_DECL)
1064                 warnstring = "declaration of `%s' shadows a parameter";
1065               else if (oldlocal != 0)
1066                 warnstring = "declaration of `%s' shadows previous local";
1067               else if (IDENTIFIER_GLOBAL_VALUE (name) != 0
1068                        && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node)
1069                 warnstring = "declaration of `%s' shadows global declaration";
1070
1071               if (warnstring)
1072                 warning (warnstring, IDENTIFIER_POINTER (name));
1073             }
1074 #endif
1075
1076           /* If storing a local value, there may already be one (inherited).
1077              If so, record it for restoration when this binding level ends.  */
1078           if (oldlocal != 0)
1079             b->shadowed = tree_cons (name, oldlocal, b->shadowed);
1080         }
1081     }
1082
1083   /* Put decls on list in reverse order.
1084      We will reverse them later if necessary.  */
1085   TREE_CHAIN (x) = b->names;
1086   b->names = x;
1087
1088   return x;
1089 }
1090
1091 void
1092 pushdecl_force_head (x)
1093      tree x;
1094 {
1095   current_binding_level->names = x;
1096 }
1097
1098 /* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, if appropriate.  */
1099
1100 tree
1101 pushdecl_top_level (x)
1102      tree x;
1103 {
1104   register tree t;
1105   register struct binding_level *b = current_binding_level;
1106
1107   current_binding_level = global_binding_level;
1108   t = pushdecl (x);
1109   current_binding_level = b;
1110   return t;
1111 }
1112
1113 /* Nonzero if we are currently in the global binding level.  */
1114
1115 int
1116 global_bindings_p ()
1117 {
1118   return current_binding_level == global_binding_level;
1119 }
1120
1121 /* Return the list of declarations of the current level.
1122    Note that this list is in reverse order unless/until
1123    you nreverse it; and when you do nreverse it, you must
1124    store the result back using `storedecls' or you will lose.  */
1125
1126 tree
1127 getdecls ()
1128 {
1129   return current_binding_level->names;
1130 }
1131
1132 /* Create a new `struct binding_level'.  */
1133
1134 static struct binding_level *
1135 make_binding_level ()
1136 {
1137   /* NOSTRICT */
1138   return (struct binding_level *) xmalloc (sizeof (struct binding_level));
1139 }
1140
1141 void
1142 pushlevel (unused)
1143   int unused ATTRIBUTE_UNUSED;
1144 {
1145   register struct binding_level *newlevel = NULL_BINDING_LEVEL;
1146
1147 #if 0
1148   /* If this is the top level of a function,
1149      just make sure that NAMED_LABELS is 0.  */
1150
1151   if (current_binding_level == global_binding_level)
1152     named_labels = 0;
1153 #endif
1154
1155   /* Reuse or create a struct for this binding level.  */
1156
1157   if (free_binding_level)
1158     {
1159       newlevel = free_binding_level;
1160       free_binding_level = free_binding_level->level_chain;
1161     }
1162   else
1163     {
1164       newlevel = make_binding_level ();
1165     }
1166
1167   /* Add this level to the front of the chain (stack) of levels that
1168      are active.  */
1169
1170   *newlevel = clear_binding_level;
1171   newlevel->level_chain = current_binding_level;
1172   current_binding_level = newlevel;
1173   newlevel->keep = keep_next_level_flag;
1174   keep_next_level_flag = 0;
1175   newlevel->keep_if_subblocks = keep_next_if_subblocks;
1176   keep_next_if_subblocks = 0;
1177 #if defined(DEBUG_JAVA_BINDING_LEVELS)
1178   newlevel->binding_depth = binding_depth;
1179   indent ();
1180   fprintf (stderr, "push %s level 0x%08x pc %d\n",
1181            (is_class_level) ? "class" : "block", newlevel, current_pc);
1182   is_class_level = 0;
1183   binding_depth++;
1184 #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
1185 }
1186
1187 /* Exit a binding level.
1188    Pop the level off, and restore the state of the identifier-decl mappings
1189    that were in effect when this level was entered.
1190
1191    If KEEP is nonzero, this level had explicit declarations, so
1192    and create a "block" (a BLOCK node) for the level
1193    to record its declarations and subblocks for symbol table output.
1194
1195    If FUNCTIONBODY is nonzero, this level is the body of a function,
1196    so create a block as if KEEP were set and also clear out all
1197    label names.
1198
1199    If REVERSE is nonzero, reverse the order of decls before putting
1200    them into the BLOCK.  */
1201
1202 tree
1203 poplevel (keep, reverse, functionbody)
1204      int keep;
1205      int reverse;
1206      int functionbody;
1207 {
1208   register tree link;
1209   /* The chain of decls was accumulated in reverse order.
1210      Put it into forward order, just for cleanliness.  */
1211   tree decls;
1212   tree subblocks = current_binding_level->blocks;
1213   tree block = 0;
1214   tree decl;
1215   int block_previously_created;
1216
1217 #if defined(DEBUG_JAVA_BINDING_LEVELS)
1218   binding_depth--;
1219   indent ();
1220   if (current_binding_level->end_pc != LARGEST_PC)
1221     fprintf (stderr, "pop  %s level 0x%08x pc %d (end pc %d)\n",
1222              (is_class_level) ? "class" : "block", current_binding_level, current_pc,
1223              current_binding_level->end_pc);
1224   else
1225     fprintf (stderr, "pop  %s level 0x%08x pc %d\n",
1226              (is_class_level) ? "class" : "block", current_binding_level, current_pc);
1227 #if 0
1228   if (is_class_level != (current_binding_level == class_binding_level))
1229     {
1230       indent ();
1231       fprintf (stderr, "XXX is_class_level != (current_binding_level == class_binding_level)\n");
1232     }
1233   is_class_level = 0;
1234 #endif
1235 #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
1236
1237   keep |= current_binding_level->keep;
1238
1239   /* Get the decls in the order they were written.
1240      Usually current_binding_level->names is in reverse order.
1241      But parameter decls were previously put in forward order.  */
1242
1243   if (reverse)
1244     current_binding_level->names
1245       = decls = nreverse (current_binding_level->names);
1246   else
1247     decls = current_binding_level->names;
1248
1249   /* Output any nested inline functions within this block
1250      if they weren't already output.  */
1251
1252   for (decl = decls; decl; decl = TREE_CHAIN (decl))
1253     if (TREE_CODE (decl) == FUNCTION_DECL
1254         && ! TREE_ASM_WRITTEN (decl)
1255         && DECL_INITIAL (decl) != 0
1256         && TREE_ADDRESSABLE (decl))
1257       {
1258         /* If this decl was copied from a file-scope decl
1259            on account of a block-scope extern decl,
1260            propagate TREE_ADDRESSABLE to the file-scope decl.
1261
1262            DECL_ABSTRACT_ORIGIN can be set to itself if warn_return_type is
1263            true, since then the decl goes through save_for_inline_copying.  */
1264         if (DECL_ABSTRACT_ORIGIN (decl) != 0
1265             && DECL_ABSTRACT_ORIGIN (decl) != decl)
1266           TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1;
1267         else
1268           {
1269             push_function_context ();
1270             output_inline_function (decl);
1271             pop_function_context ();
1272           }
1273       }
1274
1275   /* If there were any declarations in that level,
1276      or if this level is a function body,
1277      create a BLOCK to record them for the life of this function.  */
1278
1279   block = 0;
1280   block_previously_created = (current_binding_level->this_block != 0);
1281   if (block_previously_created)
1282     block = current_binding_level->this_block;
1283   else if (keep || functionbody
1284            || (current_binding_level->keep_if_subblocks && subblocks != 0))
1285     block = make_node (BLOCK);
1286   if (block != 0)
1287     {
1288       BLOCK_VARS (block) = decls;
1289       BLOCK_SUBBLOCKS (block) = subblocks;
1290     }
1291
1292   /* In each subblock, record that this is its superior.  */
1293
1294   for (link = subblocks; link; link = TREE_CHAIN (link))
1295     BLOCK_SUPERCONTEXT (link) = block;
1296
1297   /* Clear out the meanings of the local variables of this level.  */
1298
1299   for (link = decls; link; link = TREE_CHAIN (link))
1300     {
1301       tree name = DECL_NAME (link);
1302       if (name != 0 && IDENTIFIER_LOCAL_VALUE (name) == link)
1303         {
1304           /* If the ident. was used or addressed via a local extern decl,
1305              don't forget that fact.  */
1306           if (DECL_EXTERNAL (link))
1307             {
1308               if (TREE_USED (link))
1309                 TREE_USED (name) = 1;
1310               if (TREE_ADDRESSABLE (link))
1311                 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
1312             }
1313           IDENTIFIER_LOCAL_VALUE (name) = 0;
1314         }
1315     }
1316
1317   /* Restore all name-meanings of the outer levels
1318      that were shadowed by this level.  */
1319
1320   for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
1321     IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
1322
1323   /* If the level being exited is the top level of a function,
1324      check over all the labels, and clear out the current
1325      (function local) meanings of their names.  */
1326
1327   if (functionbody)
1328     {
1329       /* If this is the top level block of a function,
1330          the vars are the function's parameters.
1331          Don't leave them in the BLOCK because they are
1332          found in the FUNCTION_DECL instead.  */
1333
1334       BLOCK_VARS (block) = 0;
1335
1336       /* Clear out the definitions of all label names,
1337          since their scopes end here,
1338          and add them to BLOCK_VARS.  */
1339
1340 #if 0
1341       for (link = named_labels; link; link = TREE_CHAIN (link))
1342         {
1343           register tree label = TREE_VALUE (link);
1344
1345           if (DECL_INITIAL (label) == 0)
1346             {
1347               error_with_decl (label, "label `%s' used but not defined");
1348               /* Avoid crashing later.  */
1349               define_label (input_filename, lineno,
1350                             DECL_NAME (label));
1351             }
1352           else if (warn_unused && !TREE_USED (label))
1353             warning_with_decl (label, "label `%s' defined but not used");
1354           IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0;
1355
1356           /* Put the labels into the "variables" of the
1357              top-level block, so debugger can see them.  */
1358           TREE_CHAIN (label) = BLOCK_VARS (block);
1359           BLOCK_VARS (block) = label;
1360         }
1361 #endif
1362     }
1363
1364   /* Pop the current level, and free the structure for reuse.  */
1365
1366   {
1367     register struct binding_level *level = current_binding_level;
1368     current_binding_level = current_binding_level->level_chain;
1369
1370     level->level_chain = free_binding_level;
1371     free_binding_level = level;
1372   }
1373
1374   /* Dispose of the block that we just made inside some higher level.  */
1375   if (functionbody)
1376     DECL_INITIAL (current_function_decl) = block;
1377   else if (block)
1378     {
1379       if (!block_previously_created)
1380         current_binding_level->blocks
1381           = chainon (current_binding_level->blocks, block);
1382     }
1383   /* If we did not make a block for the level just exited,
1384      any blocks made for inner levels
1385      (since they cannot be recorded as subblocks in that level)
1386      must be carried forward so they will later become subblocks
1387      of something else.  */
1388   else if (subblocks)
1389     current_binding_level->blocks
1390       = chainon (current_binding_level->blocks, subblocks);
1391
1392   /* Set the TYPE_CONTEXTs for all of the tagged types belonging to this
1393      binding contour so that they point to the appropriate construct, i.e.
1394      either to the current FUNCTION_DECL node, or else to the BLOCK node
1395      we just constructed.
1396
1397      Note that for tagged types whose scope is just the formal parameter
1398      list for some function type specification, we can't properly set
1399      their TYPE_CONTEXTs here, because we don't have a pointer to the
1400      appropriate FUNCTION_TYPE node readily available to us.  For those
1401      cases, the TYPE_CONTEXTs of the relevant tagged type nodes get set
1402      in `grokdeclarator' as soon as we have created the FUNCTION_TYPE
1403      node which will represent the "scope" for these "parameter list local"
1404      tagged types.
1405   */
1406
1407   if (block)
1408     TREE_USED (block) = 1;
1409   return block;
1410 }
1411
1412 void
1413 maybe_pushlevels (pc)
1414      int pc;
1415 {
1416 #if defined(DEBUG_JAVA_BINDING_LEVELS)
1417   current_pc = pc;
1418 #endif
1419
1420   while (pending_local_decls != NULL_TREE &&
1421          DECL_LOCAL_START_PC (pending_local_decls) <= pc)
1422     {
1423       tree *ptr = &pending_local_decls;
1424       tree decl = *ptr;
1425       int end_pc = DECL_LOCAL_END_PC (decl);
1426
1427       while (*ptr != NULL_TREE
1428              && DECL_LOCAL_START_PC (*ptr) <= pc
1429              && DECL_LOCAL_END_PC (*ptr) == end_pc)
1430         ptr = &TREE_CHAIN (*ptr);
1431       pending_local_decls = *ptr;
1432       *ptr = NULL_TREE;
1433
1434       /* Force non-nested range to be nested in current range. */
1435       if (end_pc > current_binding_level->end_pc)
1436         end_pc = current_binding_level->end_pc;
1437
1438       maybe_start_try (pc, end_pc);
1439       
1440       pushlevel (1);
1441       expand_start_bindings (0);
1442
1443       current_binding_level->end_pc = end_pc;
1444       current_binding_level->start_pc = pc;      
1445       current_binding_level->names = decl;
1446       for ( ; decl != NULL_TREE;  decl = TREE_CHAIN (decl))
1447         {
1448           push_jvm_slot (DECL_LOCAL_SLOT_NUMBER (decl), decl);
1449         }
1450     }      
1451
1452   maybe_start_try (pc, 0);
1453 }
1454
1455 void
1456 maybe_poplevels (pc)
1457      int pc;
1458 {
1459 #if defined(DEBUG_JAVA_BINDING_LEVELS)
1460   current_pc = pc;
1461 #endif
1462
1463   while (current_binding_level->end_pc <= pc)
1464     {
1465       expand_end_bindings (getdecls (), 1, 0);
1466       maybe_end_try (current_binding_level->start_pc, pc);
1467       poplevel (1, 0, 0);
1468     }
1469   maybe_end_try (0, pc);
1470 }
1471
1472 /* Terminate any binding which began during the range beginning at
1473    start_pc.  This tidies up improperly nested local variable ranges
1474    and exception handlers; a variable declared within an exception
1475    range is forcibly terminated when that exception ends. */
1476
1477 void
1478 force_poplevels (start_pc)
1479      int start_pc;
1480 {
1481   while (current_binding_level->start_pc > start_pc)
1482     {
1483       if (pedantic && current_binding_level->start_pc > start_pc)
1484         warning_with_decl (current_function_decl, 
1485                            "In %s: overlapped variable and exception ranges at %d",
1486                            current_binding_level->start_pc);
1487       expand_end_bindings (getdecls (), 1, 0);
1488       poplevel (1, 0, 0);
1489     }
1490 }
1491
1492 /* Insert BLOCK at the end of the list of subblocks of the
1493    current binding level.  This is used when a BIND_EXPR is expanded,
1494    to handle the BLOCK node inside the BIND_EXPR.  */
1495
1496 void
1497 insert_block (block)
1498      tree block;
1499 {
1500   TREE_USED (block) = 1;
1501   current_binding_level->blocks
1502     = chainon (current_binding_level->blocks, block);
1503 }
1504
1505 /* Set the BLOCK node for the innermost scope
1506    (the one we are currently in).  */
1507
1508 void
1509 set_block (block)
1510      register tree block;
1511 {
1512   current_binding_level->this_block = block;
1513 }
1514
1515 /* integrate_decl_tree calls this function. */
1516
1517 void
1518 copy_lang_decl (node)
1519      tree node;
1520 {
1521   int lang_decl_size
1522     = TREE_CODE (node) == VAR_DECL ? sizeof (struct lang_decl_var)
1523     : sizeof (struct lang_decl);
1524   struct lang_decl *x = (struct lang_decl *) oballoc (lang_decl_size);
1525   bcopy ((PTR) DECL_LANG_SPECIFIC (node), (PTR) x, lang_decl_size);
1526   DECL_LANG_SPECIFIC (node) = x;
1527 }
1528
1529 /* If DECL has a cleanup, build and return that cleanup here.
1530    This is a callback called by expand_expr.  */
1531
1532 tree
1533 maybe_build_cleanup (decl)
1534   tree decl ATTRIBUTE_UNUSED;
1535 {
1536   /* There are no cleanups in Java (I think).  */
1537   return NULL_TREE;
1538 }
1539
1540 void
1541 give_name_to_locals (jcf)
1542      JCF *jcf;
1543 {
1544   int i, n = DECL_LOCALVARIABLES_OFFSET (current_function_decl);
1545   tree parm;
1546   pending_local_decls = NULL_TREE;
1547   if (n == 0)
1548     return;
1549   JCF_SEEK (jcf, n);
1550   n = JCF_readu2 (jcf);
1551   for (i = 0; i < n; i++)
1552     {
1553       int start_pc = JCF_readu2 (jcf);
1554       int length = JCF_readu2 (jcf);
1555       int name_index = JCF_readu2 (jcf);
1556       int signature_index = JCF_readu2 (jcf);
1557       int slot = JCF_readu2 (jcf);
1558       tree name = get_name_constant (jcf, name_index);
1559       tree type = parse_signature (jcf, signature_index);
1560       if (slot < DECL_ARG_SLOT_COUNT (current_function_decl)
1561           && start_pc == 0
1562           && length == DECL_CODE_LENGTH (current_function_decl))
1563         {
1564           tree decl = TREE_VEC_ELT (decl_map, slot);
1565           DECL_NAME (decl) = name;
1566           DECL_ASSEMBLER_NAME (decl) = name;
1567           if (TREE_CODE (decl) != PARM_DECL || TREE_TYPE (decl) != type)
1568             warning ("bad type in parameter debug info");
1569         }
1570       else
1571         {
1572           tree *ptr;
1573           int end_pc = start_pc + length;
1574           tree decl = build_decl (VAR_DECL, name, type);
1575           if (end_pc > DECL_CODE_LENGTH (current_function_decl))
1576             {
1577               warning_with_decl (decl,
1578                          "bad PC range for debug info for local `%s'");
1579               end_pc = DECL_CODE_LENGTH (current_function_decl);
1580             }
1581           DECL_LANG_SPECIFIC (decl)
1582             = (struct lang_decl *) permalloc (sizeof (struct lang_decl_var));
1583           DECL_LOCAL_SLOT_NUMBER (decl) = slot;
1584           DECL_LOCAL_START_PC (decl) = start_pc;
1585 #if 0
1586           /* FIXME: The range used internally for exceptions and local
1587              variable ranges, is a half-open interval: 
1588              start_pc <= pc < end_pc.  However, the range used in the
1589              Java VM spec is inclusive at both ends: 
1590              start_pc <= pc <= end_pc. */
1591           end_pc++;
1592 #endif
1593           DECL_LOCAL_END_PC (decl) = end_pc;
1594
1595           /* Now insert the new decl in the proper place in
1596              pending_local_decls.  We are essentially doing an insertion sort,
1597              which works fine, since the list input will normally already
1598              be sorted. */
1599           ptr = &pending_local_decls;
1600           while (*ptr != NULL_TREE
1601                  && (DECL_LOCAL_START_PC (*ptr) > start_pc
1602                      || (DECL_LOCAL_START_PC (*ptr) == start_pc
1603                          && DECL_LOCAL_END_PC (*ptr) < end_pc)))
1604             ptr = &TREE_CHAIN (*ptr);
1605           TREE_CHAIN (decl) = *ptr;
1606           *ptr = decl;
1607         }
1608     }
1609
1610   pending_local_decls = nreverse (pending_local_decls);
1611
1612   /* Fill in default names for the parameters. */ 
1613   for (parm = DECL_ARGUMENTS (current_function_decl), i = 0;
1614        parm != NULL_TREE;  parm = TREE_CHAIN (parm), i++)
1615     {
1616       if (DECL_NAME (parm) == NULL_TREE)
1617         {
1618           int arg_i = METHOD_STATIC (current_function_decl) ? i+1 : i;
1619           if (arg_i == 0)
1620             DECL_NAME (parm) = get_identifier ("this");
1621           else
1622             {
1623               char buffer[12];
1624               sprintf (buffer, "ARG_%d", arg_i);
1625               DECL_NAME (parm) = get_identifier (buffer);
1626             }
1627           DECL_ASSEMBLER_NAME (parm) = DECL_NAME (parm);
1628         }
1629     }
1630 }
1631
1632 tree
1633 build_result_decl (fndecl)
1634   tree fndecl;
1635 {
1636   tree restype = TREE_TYPE (TREE_TYPE (fndecl));
1637   /* To be compatible with C_PROMOTING_INTEGER_TYPE_P in cc1/cc1plus. */
1638   if (INTEGRAL_TYPE_P (restype)
1639       && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node))
1640     restype = integer_type_node;
1641   return (DECL_RESULT (fndecl) = build_decl (RESULT_DECL, NULL_TREE, restype));
1642 }
1643
1644 /* Called for every element in DECL_FUNCTION_INIT_TEST_TABLE in order
1645    to emit initialization code for each test flag.  */
1646    
1647 static boolean
1648 emit_init_test_initialization (entry, key)
1649   struct hash_entry *entry;
1650   hash_table_key key ATTRIBUTE_UNUSED;
1651 {
1652   struct init_test_hash_entry *ite = (struct init_test_hash_entry *) entry;
1653   expand_decl (ite->init_test_decl);
1654
1655   expand_expr_stmt (build (MODIFY_EXPR, boolean_type_node, 
1656                            ite->init_test_decl, boolean_false_node));
1657
1658   return true;
1659 }
1660
1661 void
1662 complete_start_java_method (fndecl)
1663   tree fndecl;
1664 {
1665   if (! flag_emit_class_files)
1666     {
1667       /* Initialize the RTL code for the function.  */
1668       init_function_start (fndecl, input_filename, lineno);
1669
1670       /* Set up parameters and prepare for return, for the function.  */
1671       expand_function_start (fndecl, 0);
1672
1673       /* Emit initialization code for test flags.  */
1674       if (! always_initialize_class_p)
1675         hash_traverse (&DECL_FUNCTION_INIT_TEST_TABLE (fndecl),
1676                        emit_init_test_initialization, 0);
1677     }
1678
1679   /* Allocate further tree nodes temporarily during compilation
1680      of this function only.  */
1681   temporary_allocation ();
1682
1683 #if 0
1684       /* If this fcn was already referenced via a block-scope `extern' decl (or
1685          an implicit decl), propagate certain information about the usage. */
1686       if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (current_function_decl)))
1687         TREE_ADDRESSABLE (current_function_decl) = 1;
1688
1689 #endif
1690
1691   if (METHOD_STATIC (fndecl) && ! METHOD_PRIVATE (fndecl)
1692       && ! flag_emit_class_files
1693       && ! CLASS_INTERFACE (TYPE_NAME (current_class)))
1694     {
1695       tree clas = DECL_CONTEXT (fndecl);
1696       tree init = build (CALL_EXPR, void_type_node,
1697                          build_address_of (soft_initclass_node),
1698                          build_tree_list (NULL_TREE, build_class_ref (clas)),
1699                          NULL_TREE);
1700       TREE_SIDE_EFFECTS (init) = 1;
1701       expand_expr_stmt (init);
1702     }
1703
1704   /* Push local variables. Function compiled from source code are
1705      using a different local variables management, and for them,
1706      pushlevel shouldn't be called from here.  */
1707   if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (fndecl)))
1708     {
1709       pushlevel (2);
1710       if (! flag_emit_class_files)
1711         expand_start_bindings (1);
1712     }
1713
1714   if (METHOD_SYNCHRONIZED (fndecl) && ! flag_emit_class_files)
1715     {
1716       /* Warp function body with a monitorenter plus monitorexit cleanup. */
1717       tree enter, exit, lock;
1718       if (METHOD_STATIC (fndecl))
1719         lock = build_class_ref (DECL_CONTEXT (fndecl));
1720       else
1721         lock = DECL_ARGUMENTS (fndecl);
1722       BUILD_MONITOR_ENTER (enter, lock);
1723       BUILD_MONITOR_EXIT (exit, lock);
1724       if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (fndecl)))
1725         {
1726           expand_expr_stmt (enter);
1727           expand_decl_cleanup (NULL_TREE, exit);
1728         }
1729       else
1730         {
1731           tree function_body = DECL_FUNCTION_BODY (fndecl);
1732           tree body = BLOCK_EXPR_BODY (function_body);
1733           lock = build (WITH_CLEANUP_EXPR, void_type_node,
1734                         enter,  NULL_TREE, exit);
1735           TREE_SIDE_EFFECTS (lock) = 1;
1736           lock = build (COMPOUND_EXPR, TREE_TYPE (body), lock, body);
1737           TREE_SIDE_EFFECTS (lock) = 1;
1738           lock = build1 (CLEANUP_POINT_EXPR, TREE_TYPE (body), lock);
1739           TREE_SIDE_EFFECTS (lock) = 1;
1740           BLOCK_EXPR_BODY (function_body) = lock;
1741         }
1742     }
1743 }
1744
1745 void
1746 start_java_method (fndecl)
1747      tree fndecl;
1748 {
1749   tree tem, *ptr;
1750   int i;
1751
1752   current_function_decl = fndecl;
1753   announce_function (fndecl);
1754
1755   i = DECL_MAX_LOCALS(fndecl) + DECL_MAX_STACK(fndecl);
1756   decl_map = make_tree_vec (i);
1757   type_map = (tree *) oballoc (i * sizeof (tree));
1758
1759 #if defined(DEBUG_JAVA_BINDING_LEVELS)
1760   fprintf (stderr, "%s:\n", (*decl_printable_name) (fndecl, 2));
1761   current_pc = 0;
1762 #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
1763   pushlevel (1);  /* Push parameters. */
1764
1765   ptr = &DECL_ARGUMENTS (fndecl);
1766   for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
1767        tem != end_params_node; tem = TREE_CHAIN (tem), i++)
1768     {
1769       tree parm_name = NULL_TREE, parm_decl;
1770       tree parm_type = TREE_VALUE (tem);
1771       if (i >= DECL_MAX_LOCALS(fndecl))
1772         fatal ("function has more parameters than local slots");
1773
1774       parm_decl = build_decl (PARM_DECL, parm_name, parm_type);
1775       DECL_CONTEXT (parm_decl) = fndecl;
1776       if (PROMOTE_PROTOTYPES
1777           && TYPE_PRECISION (parm_type) < TYPE_PRECISION (integer_type_node)
1778           && INTEGRAL_TYPE_P (parm_type))
1779         parm_type = integer_type_node;
1780       DECL_ARG_TYPE (parm_decl) = parm_type;
1781
1782       *ptr = parm_decl;
1783       ptr = &TREE_CHAIN (parm_decl);
1784
1785       /* Add parm_decl to the decl_map. */
1786       push_jvm_slot (i, parm_decl);
1787
1788       type_map[i] = TREE_TYPE (parm_decl);
1789       if (TYPE_IS_WIDE (TREE_TYPE (parm_decl)))
1790         {
1791           i++;
1792           type_map[i] = void_type_node;
1793         }
1794     }
1795   *ptr = NULL_TREE;
1796   DECL_ARG_SLOT_COUNT (current_function_decl) = i;
1797
1798   while (i < DECL_MAX_LOCALS(fndecl))
1799     type_map[i++] = NULL_TREE;
1800
1801   build_result_decl (fndecl);
1802   complete_start_java_method (fndecl);
1803 }
1804
1805 void
1806 end_java_method ()
1807 {
1808   tree fndecl = current_function_decl;
1809   int flag_asynchronous_exceptions = asynchronous_exceptions;
1810
1811   expand_end_bindings (getdecls (), 1, 0);
1812   /* pop out of function */
1813   poplevel (1, 1, 0);
1814
1815   /* pop out of its parameters */
1816   poplevel (1, 0, 1);
1817
1818   BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
1819
1820   emit_handlers ();
1821
1822   /* Generate rtl for function exit.  */
1823   expand_function_end (input_filename, lineno, 0);
1824
1825   /* FIXME: If the current method contains any exception handlers,
1826      force asynchronous_exceptions: this is necessary because signal
1827      handlers in libjava may throw exceptions.  This is far from being
1828      a perfect solution, but it's better than doing nothing at all.*/
1829   if (catch_clauses)
1830     asynchronous_exceptions = 1;
1831
1832   /* Run the optimizers and output assembler code for this function. */
1833   rest_of_compilation (fndecl);
1834
1835   current_function_decl = NULL_TREE;
1836   permanent_allocation (1);
1837   asynchronous_exceptions = flag_asynchronous_exceptions;
1838 }