OSDN Git Service

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