OSDN Git Service

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