1 /* Process declarations and variables for the GNU compiler for the
4 Copyright (C) 1996, 1998 Free Software Foundation, Inc.
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.
23 Java and all Java-based marks are trademarks or registered trademarks
24 of Sun Microsystems, Inc. in the United States and other countries.
25 The Free Software Foundation is independent of Sun Microsystems, Inc. */
27 /* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */
32 #include "java-tree.h"
37 #define INT_TYPE_SIZE BITS_PER_WORD
40 /* The DECL_MAP is a mapping from (index, type) to a decl node.
41 If index < max_locals, it is the index of a local variable.
42 if index >= max_locals, then index-max_locals is a stack slot.
43 The DECL_MAP mapping is represented as a TREE_VEC whose elements
44 are a list of decls (VAR_DECL or PARM_DECL) chained by
45 DECL_LOCAL_SLOT_CHAIN; the index finds the TREE_VEC element, and then
46 we search the chain for a decl with a matching TREE_TYPE. */
50 /* A list of local variables VAR_DECLs for this method that we have seen
51 debug information, but we have not reached their starting (byte) PC yet. */
53 tree pending_local_decls = NULL_TREE;
55 /* Push a local variable or stack slot into the decl_map,
56 and assign it an rtl. */
59 push_jvm_slot (index, decl)
63 struct rtx_def *rtl = NULL;
64 tree type = TREE_TYPE (decl);
67 DECL_CONTEXT (decl) = current_function_decl;
68 layout_decl (decl, 0);
70 /* See if we have an appropriate rtl (i.e. same mode) at this index.
71 If so, we must use it. */
72 tmp = TREE_VEC_ELT (decl_map, index);
73 while (tmp != NULL_TREE)
75 if (TYPE_MODE (type) == TYPE_MODE (TREE_TYPE (tmp)))
79 tmp = DECL_LOCAL_SLOT_CHAIN (tmp);
82 DECL_RTL (decl) = rtl;
85 if (index >= DECL_MAX_LOCALS (current_function_decl))
86 DECL_REGISTER (decl) = 1;
90 /* Now link the decl into the decl_map. */
91 if (DECL_LANG_SPECIFIC (decl) == NULL)
93 DECL_LANG_SPECIFIC (decl)
94 = (struct lang_decl *) permalloc (sizeof (struct lang_decl_var));
95 DECL_LOCAL_START_PC (decl) = 0;
96 DECL_LOCAL_END_PC (decl) = DECL_CODE_LENGTH (current_function_decl);
97 DECL_LOCAL_SLOT_NUMBER (decl) = index;
99 DECL_LOCAL_SLOT_CHAIN (decl) = TREE_VEC_ELT (decl_map, index);
100 TREE_VEC_ELT (decl_map, index) = decl;
104 /* Find a VAR_DECL (or PARM_DECL) at local index INDEX that has type TYPE,
105 that is valid at PC (or -1 if any pc).
106 If there is no existing matching decl, allocate one.
107 If we find a decl with matching modes but different types,
108 we re-use the rtl, but create a new decl. */
111 find_local_variable (index, type, pc)
116 struct rtx_def *rtl = NULL;
117 tree decl = TREE_VEC_ELT (decl_map, index);
118 tree best = NULL_TREE;
119 while (decl != NULL_TREE)
123 || (pc >= DECL_LOCAL_START_PC (decl)
124 && pc < DECL_LOCAL_END_PC (decl));
126 if ((TREE_TYPE (decl) == type
127 || (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
128 && type == ptr_type_node))
131 if (best == NULL_TREE
132 || (TREE_TYPE (decl) == type && TREE_TYPE (best) != type)
133 || DECL_LOCAL_START_PC (decl) > DECL_LOCAL_START_PC (best)
134 || DECL_LOCAL_END_PC (decl) < DECL_LOCAL_START_PC (decl))
137 decl = DECL_LOCAL_SLOT_CHAIN (decl);
139 if (best != NULL_TREE)
141 return push_jvm_slot (index, build_decl (VAR_DECL, NULL_TREE, type));
145 /* Same as find_local_index, except that INDEX is a stack index. */
148 find_stack_slot (index, type)
152 return find_local_variable (index + DECL_MAX_LOCALS (current_function_decl),
158 /* A chain of _DECL nodes for all variables, constants, functions,
159 * and typedef types. These are in the reverse of the order supplied.
163 /* For each level, a list of shadowed outer-level local definitions
164 to be restored when this level is popped.
165 Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
166 whose TREE_VALUE is its old definition (a kind of ..._DECL node). */
169 /* For each level (except not the global one),
170 a chain of BLOCK nodes for all the levels
171 that were entered and exited one level down. */
174 /* The BLOCK node for this level, if one has been preallocated.
175 If 0, the BLOCK is allocated (if needed) when the level is popped. */
178 /* The binding level which this one is contained in (inherits from). */
179 struct binding_level *level_chain;
181 /* 1 means make a BLOCK for this level regardless of all else.
182 2 for temporary binding contours created by the compiler. */
185 /* Nonzero means make a BLOCK if this level has any subblocks. */
186 char keep_if_subblocks;
188 /* Nonzero if this level can safely have additional
189 cleanup-needing variables added to it. */
190 char more_cleanups_ok;
193 /* The bytecode PC that marks the end of this level. */
197 #define NULL_BINDING_LEVEL (struct binding_level *) NULL
199 /* The binding level currently in effect. */
201 static struct binding_level *current_binding_level;
203 /* A chain of binding_level structures awaiting reuse. */
205 static struct binding_level *free_binding_level;
207 /* The outermost binding level, for names of file scope.
208 This is created when the compiler is started and exists
209 through the entire run. */
211 static struct binding_level *global_binding_level;
213 /* Binding level structures are initialized by copying this one. */
215 static struct binding_level clear_binding_level
216 = {NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE,
217 NULL_BINDING_LEVEL, 0, 0, 0, 0, 1000000000};
220 /* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
221 that have names. Here so we can clear out their names' definitions
222 at the end of the function. */
224 static tree named_labels;
226 /* A list of LABEL_DECLs from outer contexts that are currently shadowed. */
228 static tree shadowed_labels;
231 int flag_traditional;
233 /* Nonzero means unconditionally make a BLOCK for the next level pushed. */
235 static int keep_next_level_flag;
237 /* Nonzero means make a BLOCK for the next level pushed
238 if it has subblocks. */
240 static int keep_next_if_subblocks;
242 /* The FUNCTION_DECL for the function currently being compiled,
243 or 0 if between functions. */
244 tree current_function_decl;
246 /* The type node for the ordinary character type. */
249 tree object_type_node;
250 tree object_ptr_type_node;
251 tree string_type_node;
252 tree throwable_type_node;
253 tree runtime_exception_type_node;
254 tree error_exception_type_node;
256 tree boolean_type_node;
258 tree float_type_node;
259 tree double_type_node;
261 /* a VOID_TYPE node. */
265 tree return_address_type_node;
267 tree integer_type_node;
270 tree short_type_node;
274 tree promoted_byte_type_node;
275 tree promoted_short_type_node;
276 tree promoted_char_type_node;
277 tree promoted_boolean_type_node;
279 tree unsigned_byte_type_node;
280 tree unsigned_short_type_node;
281 tree unsigned_int_type_node;
282 tree unsigned_long_type_node;
284 /* The type for struct methodtable. */
285 tree methodtable_type;
286 tree methodtable_ptr_type;
289 tree utf8const_ptr_type;
290 tree class_type_node;
292 tree field_type_node;
293 tree field_ptr_type_node;
294 tree field_info_union_node;
295 tree jexception_type;
296 tree jexception_ptr_type;
297 tree lineNumberEntry_type;
298 tree lineNumbers_type;
299 tree constants_type_node;
301 tree dtable_ptr_type;
302 tree method_type_node;
303 tree method_ptr_type_node;
304 tree nativecode_ptr_array_type_node;
305 tree one_elt_array_domain_type;
306 tree access_flags_type_node;
307 tree class_dtable_decl;
309 /* a node which has tree code ERROR_MARK, and whose type is itself.
310 All erroneous expressions are replaced with this node. All functions
311 that accept nodes as arguments should avoid generating error messages
312 if this node is one of the arguments, since it is undesirable to get
313 multiple error messages from one error in the input. */
315 tree error_mark_node;
317 /* Two expressions that are constants with value zero.
318 The first is of type `int', the second of type `void *'. */
319 tree integer_zero_node;
320 tree null_pointer_node;
322 /* Nodes for boolean constants TRUE and FALSE. */
323 tree boolean_true_node, boolean_false_node;
325 tree TYPE_identifier_node;
326 tree init_identifier_node;
327 tree clinit_identifier_node;
328 tree void_signature_node;
329 tree length_identifier_node;
330 tree this_identifier_node;
331 tree super_identifier_node;
333 /* References to internal libjava functions we use. */
334 tree alloc_object_node;
335 tree soft_instanceof_node;
336 tree soft_checkcast_node;
337 tree soft_initclass_node;
338 tree soft_newarray_node;
339 tree soft_anewarray_node;
340 tree soft_multianewarray_node;
341 tree soft_badarrayindex_node;
343 tree soft_checkarraystore_node;
344 tree soft_monitorenter_node;
345 tree soft_monitorexit_node;
346 tree soft_lookupinterfacemethod_node;
348 tree soft_exceptioninfo_call_node;
350 /* Build (and pushdecl) a "promoted type" for all standard
351 types shorter than int. */
354 push_promoted_type (name, actual_type)
358 tree type = make_node (TREE_CODE (actual_type));
360 tree in_min = TYPE_MIN_VALUE (int_type_node);
361 tree in_max = TYPE_MAX_VALUE (int_type_node);
363 tree in_min = TYPE_MIN_VALUE (actual_type);
364 tree in_max = TYPE_MAX_VALUE (actual_type);
366 TYPE_MIN_VALUE (type) = build_int_2 (TREE_INT_CST_LOW (in_min),
367 TREE_INT_CST_HIGH (in_min));
368 TREE_TYPE (TYPE_MIN_VALUE (type)) = type;
369 TYPE_MAX_VALUE (type) = build_int_2 (TREE_INT_CST_LOW (in_max),
370 TREE_INT_CST_HIGH (in_max));
371 TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
372 TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node);
374 pushdecl (build_decl (TYPE_DECL, get_identifier (name), type));
378 /* Nodes for integer constants. */
379 tree integer_one_node, integer_two_node, integer_four_node;
380 tree integer_negative_one_node;
382 /* Return a definition for a builtin function named NAME and whose data type
383 is TYPE. TYPE should be a function type with argument types.
384 FUNCTION_CODE tells later passes how to compile calls to this function.
385 See tree.h for its possible values.
387 If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
388 the name to be called if we can't opencode the function. */
391 builtin_function (name, type, function_code, library_name)
394 enum built_in_function function_code;
397 tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
398 DECL_EXTERNAL (decl) = 1;
399 TREE_PUBLIC (decl) = 1;
401 DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
402 make_decl_rtl (decl, NULL_PTR, 1);
404 if (function_code != NOT_BUILT_IN)
406 DECL_BUILT_IN (decl) = 1;
407 DECL_FUNCTION_CODE (decl) = function_code;
413 init_decl_processing ()
418 current_function_decl = NULL;
419 current_binding_level = NULL_BINDING_LEVEL;
420 free_binding_level = NULL_BINDING_LEVEL;
421 pushlevel (0); /* make the binding_level structure for global names */
422 global_binding_level = current_binding_level;
424 error_mark_node = make_node (ERROR_MARK);
425 TREE_TYPE (error_mark_node) = error_mark_node;
427 /* Create sizetype first - needed for other types. */
428 sizetype = make_unsigned_type (POINTER_SIZE);
429 size_zero_node = build_int_2 (0, 0);
430 TREE_TYPE (size_zero_node) = sizetype;
431 size_one_node = build_int_2 (1, 0);
432 TREE_TYPE (size_one_node) = sizetype;
434 byte_type_node = make_signed_type (8);
435 pushdecl (build_decl (TYPE_DECL, get_identifier ("byte"), byte_type_node));
436 short_type_node = make_signed_type (16);
437 pushdecl (build_decl (TYPE_DECL, get_identifier ("short"), short_type_node));
438 int_type_node = make_signed_type (32);
439 pushdecl (build_decl (TYPE_DECL, get_identifier ("int"), int_type_node));
440 long_type_node = make_signed_type (64);
441 pushdecl (build_decl (TYPE_DECL, get_identifier ("long"), long_type_node));
443 unsigned_byte_type_node = make_unsigned_type (8);
444 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned byte"),
445 unsigned_byte_type_node));
446 unsigned_short_type_node = make_unsigned_type (16);
447 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned short"),
448 unsigned_short_type_node));
449 unsigned_int_type_node = make_unsigned_type (32);
450 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"),
451 unsigned_int_type_node));
452 unsigned_long_type_node = make_unsigned_type (64);
453 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned long"),
454 unsigned_long_type_node));
456 integer_type_node = type_for_size (INT_TYPE_SIZE, 0);
458 integer_zero_node = build_int_2 (0, 0);
459 integer_one_node = build_int_2 (1, 0);
460 integer_two_node = build_int_2 (2, 0);
461 integer_four_node = build_int_2 (4, 0);
462 integer_negative_one_node = build_int_2 (-1, 0);
464 void_type_node = make_node (VOID_TYPE);
465 pushdecl (build_decl (TYPE_DECL, get_identifier ("void"), void_type_node));
466 layout_type (void_type_node); /* Uses size_zero_node */
467 ptr_type_node = build_pointer_type (void_type_node);
468 t = make_node (VOID_TYPE);
469 layout_type (t); /* Uses size_zero_node */
470 return_address_type_node = build_pointer_type (t);
472 null_pointer_node = build_int_2 (0, 0);
473 TREE_TYPE (null_pointer_node) = ptr_type_node;
476 /* Make a type to be the domain of a few array types
477 whose domains don't really matter.
478 200 is small enough that it always fits in size_t
479 and large enough that it can hold most function names for the
480 initializations of __FUNCTION__ and __PRETTY_FUNCTION__. */
481 short_array_type_node = build_prim_array_type (short_type_node, 200);
483 char_type_node = make_node (CHAR_TYPE);
484 TYPE_PRECISION (char_type_node) = 16;
485 fixup_unsigned_type (char_type_node);
486 pushdecl (build_decl (TYPE_DECL, get_identifier ("char"), char_type_node));
488 boolean_type_node = make_node (BOOLEAN_TYPE);
489 TYPE_PRECISION (boolean_type_node) = 1;
490 fixup_unsigned_type (boolean_type_node);
491 pushdecl (build_decl (TYPE_DECL, get_identifier ("boolean"),
493 boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
494 boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
496 promoted_byte_type_node
497 = push_promoted_type ("promoted_byte", byte_type_node);
498 promoted_short_type_node
499 = push_promoted_type ("promoted_short", short_type_node);
500 promoted_char_type_node
501 = push_promoted_type ("promoted_char", char_type_node);
502 promoted_boolean_type_node
503 = push_promoted_type ("promoted_boolean", boolean_type_node);
505 float_type_node = make_node (REAL_TYPE);
506 TYPE_PRECISION (float_type_node) = 32;
507 pushdecl (build_decl (TYPE_DECL, get_identifier ("float"),
509 layout_type (float_type_node);
511 double_type_node = make_node (REAL_TYPE);
512 TYPE_PRECISION (double_type_node) = 64;
513 pushdecl (build_decl (TYPE_DECL, get_identifier ("double"),
515 layout_type (double_type_node);
517 object_type_node = lookup_class (get_identifier ("java.lang.Object"));
518 object_ptr_type_node = promote_type (object_type_node);
519 string_type_node = lookup_class (get_identifier ("java.lang.String"));
520 class_type_node = lookup_class (get_identifier ("java.lang.Class"));
521 throwable_type_node = lookup_class (get_identifier ("java.lang.Throwable"));
522 runtime_exception_type_node =
523 lookup_class (get_identifier ("java.lang.RuntimeException"));
524 error_exception_type_node =
525 lookup_class (get_identifier ("java.lang.Error"));
527 methodtable_type = make_node (RECORD_TYPE);
528 layout_type (methodtable_type);
529 pushdecl (build_decl (TYPE_DECL, get_identifier ("methodtable"),
531 methodtable_ptr_type = build_pointer_type (methodtable_type);
533 TYPE_identifier_node = get_identifier ("TYPE");
534 init_identifier_node = get_identifier ("<init>");
535 clinit_identifier_node = get_identifier ("<clinit>");
536 void_signature_node = get_identifier ("()V");
537 length_identifier_node = get_identifier ("length");
538 this_identifier_node = get_identifier ("this");
539 super_identifier_node = get_identifier ("super");
541 /* for lack of a better place to put this stub call */
542 init_expr_processing();
544 utf8const_type = make_node (RECORD_TYPE);
545 PUSH_FIELD (utf8const_type, field, "hash", unsigned_short_type_node);
546 PUSH_FIELD (utf8const_type, field, "length", unsigned_short_type_node);
547 FINISH_RECORD (utf8const_type);
548 utf8const_ptr_type = build_pointer_type (utf8const_type);
550 constants_type_node = make_node (RECORD_TYPE);
551 PUSH_FIELD (constants_type_node, field, "size", unsigned_int_type_node);
552 PUSH_FIELD (constants_type_node, field, "tags", ptr_type_node);
553 PUSH_FIELD (constants_type_node, field, "data", ptr_type_node);
554 FINISH_RECORD (constants_type_node);
555 pushdecl (build_decl (TYPE_DECL, get_identifier ("constants"),
556 constants_type_node));
558 access_flags_type_node = unsigned_short_type_node;
560 dtable_type = make_node (RECORD_TYPE);
561 dtable_ptr_type = build_pointer_type (dtable_type);
563 PUSH_FIELD (object_type_node, field, "dtable", dtable_ptr_type);
564 PUSH_FIELD (object_type_node, field, "sync_info", ptr_type_node);
565 for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
566 FIELD_PRIVATE (t) = 1;
567 FINISH_RECORD (object_type_node);
569 class_dtable_decl = build_dtable_decl (class_type_node);
570 TREE_STATIC (class_dtable_decl) = 1;
571 DECL_ARTIFICIAL (class_dtable_decl) = 1;
572 DECL_IGNORED_P (class_dtable_decl) = 1;
573 rest_of_decl_compilation (class_dtable_decl, (char*) 0, 1, 0);
575 field_type_node = make_node (RECORD_TYPE);
576 field_ptr_type_node = build_pointer_type (field_type_node);
577 method_type_node = make_node (RECORD_TYPE);
578 method_ptr_type_node = build_pointer_type (method_type_node);
580 set_super_info (0, class_type_node, object_type_node, 0);
581 set_super_info (0, string_type_node, object_type_node, 0);
582 class_ptr_type = build_pointer_type (class_type_node);
584 PUSH_FIELD (class_type_node, field, "next", class_ptr_type);
585 PUSH_FIELD (class_type_node, field, "name", utf8const_ptr_type);
586 PUSH_FIELD (class_type_node, field, "accflags", access_flags_type_node);
587 PUSH_FIELD (class_type_node, field, "superclass", class_ptr_type);
588 PUSH_FIELD (class_type_node, field, "constants", constants_type_node);
589 PUSH_FIELD (class_type_node, field, "methods", method_ptr_type_node);
590 PUSH_FIELD (class_type_node, field, "nmethods", short_type_node);
591 PUSH_FIELD (class_type_node, field, "method_count", short_type_node);
592 PUSH_FIELD (class_type_node, field, "fields", field_ptr_type_node);
593 PUSH_FIELD (class_type_node, field, "size_in_bytes", int_type_node);
594 PUSH_FIELD (class_type_node, field, "field_count", short_type_node);
595 PUSH_FIELD (class_type_node, field, "static_field_count", short_type_node);
596 PUSH_FIELD (class_type_node, field, "dtable", dtable_ptr_type);
597 PUSH_FIELD (class_type_node, field, "interfaces",
598 build_pointer_type (class_ptr_type));
599 PUSH_FIELD (class_type_node, field, "loader", ptr_type_node);
600 PUSH_FIELD (class_type_node, field, "interface_count", short_type_node);
601 PUSH_FIELD (class_type_node, field, "state", byte_type_node);
602 PUSH_FIELD (class_type_node, field, "thread", ptr_type_node);
603 for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
604 FIELD_PRIVATE (t) = 1;
605 push_super_field (class_type_node, object_type_node);
606 FINISH_RECORD (class_type_node);
607 pushdecl (build_decl (TYPE_DECL, get_identifier ("Class"), class_type_node));
609 field_info_union_node = make_node (UNION_TYPE);
610 PUSH_FIELD (field_info_union_node, field, "boffset", int_type_node);
611 PUSH_FIELD (field_info_union_node, field, "addr", ptr_type_node);
613 PUSH_FIELD (field_info_union_node, field, "idx", unsigned_short_type_node);
615 layout_type (field_info_union_node);
617 PUSH_FIELD (field_type_node, field, "name", utf8const_ptr_type);
618 PUSH_FIELD (field_type_node, field, "type", class_ptr_type);
619 PUSH_FIELD (field_type_node, field, "accflags", access_flags_type_node);
620 PUSH_FIELD (field_type_node, field, "bsize", unsigned_short_type_node);
621 PUSH_FIELD (field_type_node, field, "info", field_info_union_node);
622 FINISH_RECORD (field_type_node);
623 CLASS_LOADED_P (field_type_node) = 1;
624 pushdecl (build_decl (TYPE_DECL, get_identifier ("Field"), field_type_node));
626 one_elt_array_domain_type = build_index_type (integer_one_node);
627 nativecode_ptr_array_type_node
628 = build_array_type (nativecode_ptr_type_node, one_elt_array_domain_type);
630 PUSH_FIELD (dtable_type, field, "class", class_ptr_type);
631 PUSH_FIELD (dtable_type, field, "methods", nativecode_ptr_array_type_node);
632 FINISH_RECORD (dtable_type);
633 pushdecl (build_decl (TYPE_DECL, get_identifier ("dispatchTable"), dtable_type));
635 #define jint_type int_type_node
636 #define jint_ptr_type ptr_type_node
638 jexception_type = make_node (RECORD_TYPE);
639 PUSH_FIELD (jexception_type, field, "start_pc", ptr_type_node);
640 PUSH_FIELD (jexception_type, field, "end_pc", ptr_type_node);
641 PUSH_FIELD (jexception_type, field, "handler_pc", ptr_type_node);
642 PUSH_FIELD (jexception_type, field, "catch_type", class_ptr_type);
643 FINISH_RECORD (jexception_type);
644 pushdecl (build_decl (TYPE_DECL, get_identifier ("jexception"), field_type_node));
645 jexception_ptr_type = build_pointer_type (jexception_type);
647 lineNumberEntry_type = make_node (RECORD_TYPE);
648 PUSH_FIELD (lineNumberEntry_type, field, "line_nr", unsigned_short_type_node);
649 PUSH_FIELD (lineNumberEntry_type, field, "start_pc", ptr_type_node);
650 FINISH_RECORD (lineNumberEntry_type);
652 lineNumbers_type = make_node (RECORD_TYPE);
653 PUSH_FIELD (lineNumbers_type, field, "length", unsigned_int_type_node);
654 FINISH_RECORD (lineNumbers_type);
656 #define instn_ptr_type_node ptr_type_node /* XXX JH */
658 #define lineNumbers_ptr_type_node build_pointer_type(lineNumbers_type)
660 PUSH_FIELD (method_type_node, field, "name", utf8const_ptr_type);
661 PUSH_FIELD (method_type_node, field, "signature", utf8const_ptr_type);
662 PUSH_FIELD (method_type_node, field, "accflags", access_flags_type_node);
663 PUSH_FIELD (method_type_node, field, "ncode", nativecode_ptr_type_node);
664 FINISH_RECORD (method_type_node);
665 CLASS_LOADED_P (method_type_node) = 1;
666 pushdecl (build_decl (TYPE_DECL, get_identifier ("Method"), method_type_node));
668 t = tree_cons (NULL_TREE, class_ptr_type,
669 build_tree_list (NULL_TREE, int_type_node));
670 alloc_object_node = builtin_function ("_Jv_AllocObject",
671 build_function_type (ptr_type_node, t),
672 NOT_BUILT_IN, NULL_PTR);
673 soft_initclass_node = builtin_function ("_Jv_InitClass",
674 build_function_type (void_type_node,
676 NOT_BUILT_IN, NULL_PTR);
677 t = build_tree_list (NULL_TREE, void_type_node);
678 throw_node = builtin_function ("_Jv_Throw",
679 build_function_type (ptr_type_node, t),
680 NOT_BUILT_IN, NULL_PTR);
681 soft_monitorenter_node
682 = builtin_function ("_Jv_MonitorEnter",
683 build_function_type (int_type_node, t),
684 NOT_BUILT_IN, NULL_PTR);
685 soft_monitorexit_node
686 = builtin_function ("_Jv_MonitorExit",
687 build_function_type (int_type_node, t),
688 NOT_BUILT_IN, NULL_PTR);
690 t = tree_cons (NULL_TREE, int_type_node,
691 build_tree_list (NULL_TREE, int_type_node));
693 = builtin_function ("_Jv_NewArray",
694 build_function_type(ptr_type_node, t),
695 NOT_BUILT_IN, NULL_PTR );
697 t = tree_cons (NULL_TREE, int_type_node,
698 tree_cons (NULL_TREE, class_ptr_type,
699 build_tree_list (NULL_TREE,
700 object_ptr_type_node)));
702 = builtin_function ("_Jv_NewObjectArray",
703 build_function_type (ptr_type_node, t),
704 NOT_BUILT_IN, NULL_PTR );
706 t = tree_cons (NULL_TREE, ptr_type_node,
707 build_tree_list (NULL_TREE, int_type_node));
708 soft_multianewarray_node
709 = builtin_function ("_Jv_NewMultiArray",
710 build_function_type (ptr_type_node, t),
711 NOT_BUILT_IN, NULL_PTR );
713 t = build_function_type (void_type_node,
714 build_tree_list (NULL_TREE, int_type_node));
715 soft_badarrayindex_node
716 = builtin_function ("_Jv_ThrowBadArrayIndex", t,
717 NOT_BUILT_IN, NULL_PTR);
718 TREE_THIS_VOLATILE (soft_badarrayindex_node) = 1;
719 TREE_SIDE_EFFECTS (soft_badarrayindex_node) = 1;
721 t = tree_cons (NULL_TREE, class_ptr_type,
722 build_tree_list (NULL_TREE, object_ptr_type_node));
724 = builtin_function ("_Jv_CheckCast",
725 build_function_type (ptr_type_node, t),
726 NOT_BUILT_IN, NULL_PTR);
727 t = tree_cons (NULL_TREE, object_ptr_type_node,
728 build_tree_list (NULL_TREE, class_ptr_type));
730 = builtin_function ("_Jv_IsInstanceOf",
731 build_function_type (promoted_boolean_type_node, t),
732 NOT_BUILT_IN, NULL_PTR);
733 t = tree_cons (NULL_TREE, object_ptr_type_node,
734 build_tree_list (NULL_TREE, object_ptr_type_node));
735 soft_checkarraystore_node
736 = builtin_function ("_Jv_CheckArrayStore",
737 build_function_type (void_type_node, t),
738 NOT_BUILT_IN, NULL_PTR);
739 t = tree_cons (NULL_TREE, ptr_type_node,
740 tree_cons (NULL_TREE, ptr_type_node,
741 build_tree_list (NULL_TREE, ptr_type_node)));
742 soft_lookupinterfacemethod_node
743 = builtin_function ("_Jv_LookupInterfaceMethod",
744 build_function_type (ptr_type_node, t),
745 NOT_BUILT_IN, NULL_PTR);
746 t = tree_cons (NULL_TREE, double_type_node,
747 build_tree_list (NULL_TREE, double_type_node));
749 = builtin_function ("__builtin_fmod",
750 build_function_type (double_type_node, t),
751 BUILT_IN_FMOD, "fmod");
753 t = build_tree_list (NULL_TREE, void_type_node);
754 soft_exceptioninfo_call_node
758 (builtin_function ("_Jv_exception_info",
759 build_function_type (ptr_type_node, t),
760 NOT_BUILT_IN, NULL_PTR)),
761 NULL_TREE, NULL_TREE);
762 TREE_SIDE_EFFECTS (soft_exceptioninfo_call_node) = 1;
764 t = tree_cons (NULL_TREE, float_type_node,
765 build_tree_list (NULL_TREE, float_type_node));
767 = builtin_function ("__builtin_fmodf",
768 build_function_type (float_type_node, t),
769 BUILT_IN_FMOD, "fmodf");
772 init_class_processing ();
776 /* Look up NAME in the current binding level and its superiors
777 in the namespace of variables, functions and typedefs.
778 Return a ..._DECL node of some kind representing its definition,
779 or return 0 if it is undefined. */
786 if (current_binding_level != global_binding_level
787 && IDENTIFIER_LOCAL_VALUE (name))
788 val = IDENTIFIER_LOCAL_VALUE (name);
790 val = IDENTIFIER_GLOBAL_VALUE (name);
794 /* Similar to `lookup_name' but look only at current binding level and
795 the previous one if its the parameter level. */
798 lookup_name_current_level (name)
803 if (current_binding_level == global_binding_level)
804 return IDENTIFIER_GLOBAL_VALUE (name);
806 if (IDENTIFIER_LOCAL_VALUE (name) == 0)
809 for (t = current_binding_level->names; t; t = TREE_CHAIN (t))
810 if (DECL_NAME (t) == name)
816 /* Use a binding level to record a labeled block declaration */
819 push_labeled_block (lb)
822 register tree name = DECL_NAME (LABELED_BLOCK_LABEL (lb));
823 register struct binding_level *b = current_binding_level;
824 tree oldlocal = IDENTIFIER_LOCAL_VALUE (name);
826 b->shadowed = tree_cons (name, oldlocal, b->shadowed);
827 TREE_CHAIN (lb) = b->names;
829 IDENTIFIER_LOCAL_VALUE (name) = lb;
832 /* Pop the current binding level, reinstalling values for the previous
838 struct binding_level *b = current_binding_level;
839 tree label = b->names;
840 IDENTIFIER_LOCAL_VALUE (DECL_NAME (LABELED_BLOCK_LABEL (label))) =
843 IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (b->shadowed)) =
844 TREE_VALUE (b->shadowed);
846 /* Pop the current level, and free the structure for reuse. */
847 current_binding_level = current_binding_level->level_chain;
848 b->level_chain = free_binding_level;
849 free_binding_level = b;
852 /* Record a decl-node X as belonging to the current lexical scope.
853 Check for errors (such as an incompatible declaration for the same
854 name already seen in the same scope).
856 Returns either X or an old decl for the same name.
857 If an old decl is returned, it may have been smashed
858 to agree with what X says. */
865 register tree name = DECL_NAME (x);
866 register struct binding_level *b = current_binding_level;
868 DECL_CONTEXT (x) = current_function_decl;
873 int different_binding_level = 0;
875 t = lookup_name_current_level (name);
876 if (t != 0 && t == error_mark_node)
877 /* error_mark_node is 0 for a while during initialization! */
880 error_with_decl (x, "`%s' used prior to declaration");
885 file = DECL_SOURCE_FILE (t);
886 line = DECL_SOURCE_LINE (t);
889 /* If we're naming a hitherto-unnamed type, set its TYPE_NAME
890 to point to the TYPE_DECL.
891 Since Java does not have typedefs, a type can only have
892 one (true) name, given by a class, interface, or builtin. */
893 if (TREE_CODE (x) == TYPE_DECL
894 && TYPE_NAME (TREE_TYPE (x)) == 0
895 && TREE_TYPE (x) != error_mark_node)
897 TYPE_NAME (TREE_TYPE (x)) = x;
898 TYPE_STUB_DECL (TREE_TYPE (x)) = x;
901 /* This name is new in its binding level.
902 Install the new declaration and return it. */
903 if (b == global_binding_level)
905 /* Install a global value. */
907 IDENTIFIER_GLOBAL_VALUE (name) = x;
911 /* Here to install a non-global value. */
912 tree oldlocal = IDENTIFIER_LOCAL_VALUE (name);
913 tree oldglobal = IDENTIFIER_GLOBAL_VALUE (name);
914 IDENTIFIER_LOCAL_VALUE (name) = x;
917 /* Warn if shadowing an argument at the top level of the body. */
918 if (oldlocal != 0 && !DECL_EXTERNAL (x)
919 /* This warning doesn't apply to the parms of a nested fcn. */
920 && ! current_binding_level->parm_flag
921 /* Check that this is one level down from the parms. */
922 && current_binding_level->level_chain->parm_flag
923 /* Check that the decl being shadowed
924 comes from the parm level, one level up. */
925 && chain_member (oldlocal, current_binding_level->level_chain->names))
927 if (TREE_CODE (oldlocal) == PARM_DECL)
928 pedwarn ("declaration of `%s' shadows a parameter",
929 IDENTIFIER_POINTER (name));
931 pedwarn ("declaration of `%s' shadows a symbol from the parameter list",
932 IDENTIFIER_POINTER (name));
935 /* Maybe warn if shadowing something else. */
936 else if (warn_shadow && !DECL_EXTERNAL (x)
937 /* No shadow warnings for internally generated vars. */
938 && DECL_SOURCE_LINE (x) != 0
939 /* No shadow warnings for vars made for inlining. */
940 && ! DECL_FROM_INLINE (x))
942 char *warnstring = 0;
944 if (TREE_CODE (x) == PARM_DECL
945 && current_binding_level->level_chain->parm_flag)
946 /* Don't warn about the parm names in function declarator
947 within a function declarator.
948 It would be nice to avoid warning in any function
949 declarator in a declaration, as opposed to a definition,
950 but there is no way to tell it's not a definition. */
952 else if (oldlocal != 0 && TREE_CODE (oldlocal) == PARM_DECL)
953 warnstring = "declaration of `%s' shadows a parameter";
954 else if (oldlocal != 0)
955 warnstring = "declaration of `%s' shadows previous local";
956 else if (IDENTIFIER_GLOBAL_VALUE (name) != 0
957 && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node)
958 warnstring = "declaration of `%s' shadows global declaration";
961 warning (warnstring, IDENTIFIER_POINTER (name));
965 /* If storing a local value, there may already be one (inherited).
966 If so, record it for restoration when this binding level ends. */
968 b->shadowed = tree_cons (name, oldlocal, b->shadowed);
972 /* Put decls on list in reverse order.
973 We will reverse them later if necessary. */
974 TREE_CHAIN (x) = b->names;
980 pushdecl_force_head (x)
983 current_binding_level->names = x;
986 /* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, if appropriate. */
989 pushdecl_top_level (x)
993 register struct binding_level *b = current_binding_level;
995 current_binding_level = global_binding_level;
997 current_binding_level = b;
1001 /* Nonzero if we are currently in the global binding level. */
1004 global_bindings_p ()
1006 return current_binding_level == global_binding_level;
1009 /* Return the list of declarations of the current level.
1010 Note that this list is in reverse order unless/until
1011 you nreverse it; and when you do nreverse it, you must
1012 store the result back using `storedecls' or you will lose. */
1017 return current_binding_level->names;
1020 /* Create a new `struct binding_level'. */
1023 struct binding_level *
1024 make_binding_level ()
1027 return (struct binding_level *) xmalloc (sizeof (struct binding_level));
1034 register struct binding_level *newlevel = NULL_BINDING_LEVEL;
1037 /* If this is the top level of a function,
1038 just make sure that NAMED_LABELS is 0. */
1040 if (current_binding_level == global_binding_level)
1044 /* Reuse or create a struct for this binding level. */
1046 if (free_binding_level)
1048 newlevel = free_binding_level;
1049 free_binding_level = free_binding_level->level_chain;
1053 newlevel = make_binding_level ();
1056 /* Add this level to the front of the chain (stack) of levels that
1059 *newlevel = clear_binding_level;
1060 newlevel->level_chain = current_binding_level;
1061 current_binding_level = newlevel;
1062 newlevel->keep = keep_next_level_flag;
1063 keep_next_level_flag = 0;
1064 newlevel->keep_if_subblocks = keep_next_if_subblocks;
1065 keep_next_if_subblocks = 0;
1068 /* Exit a binding level.
1069 Pop the level off, and restore the state of the identifier-decl mappings
1070 that were in effect when this level was entered.
1072 If KEEP is nonzero, this level had explicit declarations, so
1073 and create a "block" (a BLOCK node) for the level
1074 to record its declarations and subblocks for symbol table output.
1076 If FUNCTIONBODY is nonzero, this level is the body of a function,
1077 so create a block as if KEEP were set and also clear out all
1080 If REVERSE is nonzero, reverse the order of decls before putting
1081 them into the BLOCK. */
1084 poplevel (keep, reverse, functionbody)
1090 /* The chain of decls was accumulated in reverse order.
1091 Put it into forward order, just for cleanliness. */
1093 tree subblocks = current_binding_level->blocks;
1096 int block_previously_created;
1098 keep |= current_binding_level->keep;
1100 /* Get the decls in the order they were written.
1101 Usually current_binding_level->names is in reverse order.
1102 But parameter decls were previously put in forward order. */
1105 current_binding_level->names
1106 = decls = nreverse (current_binding_level->names);
1108 decls = current_binding_level->names;
1110 /* Output any nested inline functions within this block
1111 if they weren't already output. */
1113 for (decl = decls; decl; decl = TREE_CHAIN (decl))
1114 if (TREE_CODE (decl) == FUNCTION_DECL
1115 && ! TREE_ASM_WRITTEN (decl)
1116 && DECL_INITIAL (decl) != 0
1117 && TREE_ADDRESSABLE (decl))
1119 /* If this decl was copied from a file-scope decl
1120 on account of a block-scope extern decl,
1121 propagate TREE_ADDRESSABLE to the file-scope decl.
1123 DECL_ABSTRACT_ORIGIN can be set to itself if warn_return_type is
1124 true, since then the decl goes through save_for_inline_copying. */
1125 if (DECL_ABSTRACT_ORIGIN (decl) != 0
1126 && DECL_ABSTRACT_ORIGIN (decl) != decl)
1127 TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1;
1130 push_function_context ();
1131 output_inline_function (decl);
1132 pop_function_context ();
1136 /* If there were any declarations in that level,
1137 or if this level is a function body,
1138 create a BLOCK to record them for the life of this function. */
1141 block_previously_created = (current_binding_level->this_block != 0);
1142 if (block_previously_created)
1143 block = current_binding_level->this_block;
1144 else if (keep || functionbody
1145 || (current_binding_level->keep_if_subblocks && subblocks != 0))
1146 block = make_node (BLOCK);
1149 BLOCK_VARS (block) = decls;
1150 BLOCK_TYPE_TAGS (block) = NULL_TREE;
1151 BLOCK_SUBBLOCKS (block) = subblocks;
1152 remember_end_note (block);
1155 /* In each subblock, record that this is its superior. */
1157 for (link = subblocks; link; link = TREE_CHAIN (link))
1158 BLOCK_SUPERCONTEXT (link) = block;
1160 /* Clear out the meanings of the local variables of this level. */
1162 for (link = decls; link; link = TREE_CHAIN (link))
1164 tree name = DECL_NAME (link);
1165 if (name != 0 && IDENTIFIER_LOCAL_VALUE (name) == link)
1167 /* If the ident. was used or addressed via a local extern decl,
1168 don't forget that fact. */
1169 if (DECL_EXTERNAL (link))
1171 if (TREE_USED (link))
1172 TREE_USED (name) = 1;
1173 if (TREE_ADDRESSABLE (link))
1174 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
1176 IDENTIFIER_LOCAL_VALUE (name) = 0;
1180 /* Restore all name-meanings of the outer levels
1181 that were shadowed by this level. */
1183 for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
1184 IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
1186 /* If the level being exited is the top level of a function,
1187 check over all the labels, and clear out the current
1188 (function local) meanings of their names. */
1192 /* If this is the top level block of a function,
1193 the vars are the function's parameters.
1194 Don't leave them in the BLOCK because they are
1195 found in the FUNCTION_DECL instead. */
1197 BLOCK_VARS (block) = 0;
1199 /* Clear out the definitions of all label names,
1200 since their scopes end here,
1201 and add them to BLOCK_VARS. */
1204 for (link = named_labels; link; link = TREE_CHAIN (link))
1206 register tree label = TREE_VALUE (link);
1208 if (DECL_INITIAL (label) == 0)
1210 error_with_decl (label, "label `%s' used but not defined");
1211 /* Avoid crashing later. */
1212 define_label (input_filename, lineno,
1215 else if (warn_unused && !TREE_USED (label))
1216 warning_with_decl (label, "label `%s' defined but not used");
1217 IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0;
1219 /* Put the labels into the "variables" of the
1220 top-level block, so debugger can see them. */
1221 TREE_CHAIN (label) = BLOCK_VARS (block);
1222 BLOCK_VARS (block) = label;
1227 /* Pop the current level, and free the structure for reuse. */
1230 register struct binding_level *level = current_binding_level;
1231 current_binding_level = current_binding_level->level_chain;
1233 level->level_chain = free_binding_level;
1234 free_binding_level = level;
1237 /* Dispose of the block that we just made inside some higher level. */
1239 DECL_INITIAL (current_function_decl) = block;
1242 if (!block_previously_created)
1243 current_binding_level->blocks
1244 = chainon (current_binding_level->blocks, block);
1246 /* If we did not make a block for the level just exited,
1247 any blocks made for inner levels
1248 (since they cannot be recorded as subblocks in that level)
1249 must be carried forward so they will later become subblocks
1250 of something else. */
1252 current_binding_level->blocks
1253 = chainon (current_binding_level->blocks, subblocks);
1255 /* Set the TYPE_CONTEXTs for all of the tagged types belonging to this
1256 binding contour so that they point to the appropriate construct, i.e.
1257 either to the current FUNCTION_DECL node, or else to the BLOCK node
1258 we just constructed.
1260 Note that for tagged types whose scope is just the formal parameter
1261 list for some function type specification, we can't properly set
1262 their TYPE_CONTEXTs here, because we don't have a pointer to the
1263 appropriate FUNCTION_TYPE node readily available to us. For those
1264 cases, the TYPE_CONTEXTs of the relevant tagged type nodes get set
1265 in `grokdeclarator' as soon as we have created the FUNCTION_TYPE
1266 node which will represent the "scope" for these "parameter list local"
1271 TREE_USED (block) = 1;
1276 maybe_pushlevels (pc)
1279 while (pending_local_decls != NULL_TREE &&
1280 DECL_LOCAL_START_PC (pending_local_decls) <= pc)
1282 tree *ptr = &pending_local_decls;
1284 int end_pc = DECL_LOCAL_END_PC (decl);
1286 while (*ptr != NULL_TREE
1287 && DECL_LOCAL_START_PC (*ptr) <= pc
1288 && DECL_LOCAL_END_PC (*ptr) == end_pc)
1289 ptr = &TREE_CHAIN (*ptr);
1290 pending_local_decls = *ptr;
1293 /* Force non-nested range to be nested in current range. */
1294 if (end_pc > current_binding_level->end_pc)
1295 end_pc = current_binding_level->end_pc;
1298 expand_start_bindings (0);
1299 current_binding_level->end_pc = end_pc;
1301 current_binding_level->names = decl;
1302 for ( ; decl != NULL_TREE; decl = TREE_CHAIN (decl))
1304 push_jvm_slot (DECL_LOCAL_SLOT_NUMBER (decl), decl);
1310 maybe_poplevels (pc)
1313 while (current_binding_level->end_pc <= pc)
1315 expand_end_bindings (getdecls (), 1, 0);
1320 /* Insert BLOCK at the end of the list of subblocks of the
1321 current binding level. This is used when a BIND_EXPR is expanded,
1322 to handle the BLOCK node inside the BIND_EXPR. */
1325 insert_block (block)
1328 TREE_USED (block) = 1;
1330 current_binding_level->blocks
1331 = chainon (current_binding_level->blocks, block);
1334 /* Set the BLOCK node for the innermost scope
1335 (the one we are currently in). */
1339 register tree block;
1341 current_binding_level->this_block = block;
1344 /* integrate_decl_tree calls this function. */
1347 copy_lang_decl (node)
1351 = TREE_CODE (node) == VAR_DECL ? sizeof (struct lang_decl_var)
1352 : sizeof (struct lang_decl);
1353 struct lang_decl *x = (struct lang_decl *) oballoc (lang_decl_size);
1354 bcopy (DECL_LANG_SPECIFIC (node), x, lang_decl_size);
1355 DECL_LANG_SPECIFIC (node) = x;
1358 /* If DECL has a cleanup, build and return that cleanup here.
1359 This is a callback called by expand_expr. */
1362 maybe_build_cleanup (decl)
1365 /* There are no cleanups in Java (I think). */
1370 give_name_to_locals (jcf)
1373 int i, n = DECL_LOCALVARIABLES_OFFSET (current_function_decl);
1375 pending_local_decls = NULL_TREE;
1379 n = JCF_readu2 (jcf);
1380 for (i = 0; i < n; i++)
1382 int start_pc = JCF_readu2 (jcf);
1383 int length = JCF_readu2 (jcf);
1384 int name_index = JCF_readu2 (jcf);
1385 int signature_index = JCF_readu2 (jcf);
1386 int slot = JCF_readu2 (jcf);
1387 tree name = get_name_constant (jcf, name_index);
1388 tree type = parse_signature (jcf, signature_index);
1389 if (slot < DECL_ARG_SLOT_COUNT (current_function_decl)
1391 && length == DECL_CODE_LENGTH (current_function_decl))
1393 tree decl = TREE_VEC_ELT (decl_map, slot);
1394 DECL_NAME (decl) = name;
1395 DECL_ASSEMBLER_NAME (decl) = name;
1396 if (TREE_CODE (decl) != PARM_DECL || TREE_TYPE (decl) != type)
1397 warning ("bad type in parameter debug info");
1402 int end_pc = start_pc + length;
1403 tree decl = build_decl (VAR_DECL, name, type);
1404 if (end_pc > DECL_CODE_LENGTH (current_function_decl))
1406 warning_with_decl (decl,
1407 "bad PC range for debug info for local `%s'");
1408 end_pc = DECL_CODE_LENGTH (current_function_decl);
1410 DECL_LANG_SPECIFIC (decl)
1411 = (struct lang_decl *) permalloc (sizeof (struct lang_decl_var));
1412 DECL_LOCAL_SLOT_NUMBER (decl) = slot;
1413 DECL_LOCAL_START_PC (decl) = start_pc;
1414 DECL_LOCAL_END_PC (decl) = end_pc;
1416 /* Now insert the new decl in the proper place in
1417 pending_local_decls. We are essentially doing an insertion sort,
1418 which works fine, since the list input will normally already
1420 ptr = &pending_local_decls;
1421 while (*ptr != NULL_TREE
1422 && (DECL_LOCAL_START_PC (*ptr) > start_pc
1423 || (DECL_LOCAL_START_PC (*ptr) == start_pc
1424 && DECL_LOCAL_END_PC (*ptr) < end_pc)))
1425 ptr = &TREE_CHAIN (*ptr);
1426 TREE_CHAIN (decl) = *ptr;
1431 pending_local_decls = nreverse (pending_local_decls);
1433 /* Fill in default names for the parameters. */
1434 for (parm = DECL_ARGUMENTS (current_function_decl), i = 0;
1435 parm != NULL_TREE; parm = TREE_CHAIN (parm), i++)
1437 if (DECL_NAME (parm) == NULL_TREE)
1439 int arg_i = METHOD_STATIC (current_function_decl) ? i+1 : i;
1441 DECL_NAME (parm) = get_identifier ("this");
1445 sprintf (buffer, "ARG_%d", arg_i);
1446 DECL_NAME (parm) = get_identifier (buffer);
1448 DECL_ASSEMBLER_NAME (parm) = DECL_NAME (parm);
1454 complete_start_java_method (fndecl)
1457 tree restype = TREE_TYPE (TREE_TYPE (fndecl));
1458 /* To be compatible with C_PROMOTING_INTEGER_TYPE_P in cc1/cc1plus. */
1459 if (INTEGRAL_TYPE_P (restype)
1460 && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node))
1461 restype = integer_type_node;
1462 DECL_RESULT (fndecl) = build_decl (RESULT_DECL, NULL_TREE, restype);
1464 if (! flag_emit_class_files)
1466 /* Initialize the RTL code for the function. */
1467 init_function_start (fndecl, input_filename, lineno);
1469 /* Set up parameters and prepare for return, for the function. */
1470 expand_function_start (fndecl, 0);
1473 /* Allocate further tree nodes temporarily during compilation
1474 of this function only. */
1475 temporary_allocation ();
1478 /* If this fcn was already referenced via a block-scope `extern' decl (or
1479 an implicit decl), propagate certain information about the usage. */
1480 if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (current_function_decl)))
1481 TREE_ADDRESSABLE (current_function_decl) = 1;
1485 if (METHOD_STATIC (fndecl) && ! METHOD_PRIVATE (fndecl))
1487 tree clas = DECL_CONTEXT (fndecl);
1488 tree init = build (CALL_EXPR, void_type_node,
1489 build_address_of (soft_initclass_node),
1490 build_tree_list (NULL_TREE, build_class_ref (clas)),
1492 TREE_SIDE_EFFECTS (init) = 1;
1493 expand_expr_stmt (init);
1496 if (METHOD_SYNCHRONIZED (fndecl))
1498 /* FIXME: surround the function body by a try/finally set. */
1501 /* Push local variables. Function compiled from source code are
1502 using a different local variables management, and for them,
1503 pushlevel shouldn't be called from here. */
1504 if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (fndecl)))
1507 if (! flag_emit_class_files)
1508 expand_start_bindings (1);
1513 start_java_method (fndecl)
1519 current_function_decl = fndecl;
1520 announce_function (fndecl);
1522 i = DECL_MAX_LOCALS(fndecl) + DECL_MAX_STACK(fndecl);
1523 decl_map = make_tree_vec (i);
1524 type_map = (tree *) oballoc (i * sizeof (tree));
1526 pushlevel (1); /* Push parameters. */
1528 ptr = &DECL_ARGUMENTS (fndecl);
1529 for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
1530 tem != NULL_TREE; tem = TREE_CHAIN (tem), i++)
1532 tree parm_name = NULL_TREE, parm_decl;
1533 tree parm_type = TREE_VALUE (tem);
1534 if (i >= DECL_MAX_LOCALS(fndecl))
1535 fatal ("function has more parameters than local slots");
1537 parm_decl = build_decl (PARM_DECL, parm_name, parm_type);
1538 DECL_CONTEXT (parm_decl) = fndecl;
1539 #ifdef PROMOTE_PROTOTYPES
1540 if (TYPE_PRECISION (parm_type) < TYPE_PRECISION (integer_type_node)
1541 && INTEGRAL_TYPE_P (parm_type))
1542 parm_type = integer_type_node;
1544 DECL_ARG_TYPE (parm_decl) = parm_type;
1547 ptr = &TREE_CHAIN (parm_decl);
1549 /* Add parm_decl to the decl_map. */
1550 push_jvm_slot (i, parm_decl);
1552 type_map[i] = TREE_TYPE (parm_decl);
1553 if (TYPE_IS_WIDE (TREE_TYPE (parm_decl)))
1556 type_map[i] = void_type_node;
1560 DECL_ARG_SLOT_COUNT (current_function_decl) = i;
1562 while (i < DECL_MAX_LOCALS(fndecl))
1563 type_map[i++] = NULL_TREE;
1565 complete_start_java_method (fndecl);
1571 tree fndecl = current_function_decl;
1573 expand_end_bindings (getdecls (), 1, 0);
1574 /* pop out of function */
1577 /* pop out of its parameters */
1580 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
1584 /* Generate rtl for function exit. */
1585 expand_function_end (input_filename, lineno, 0);
1587 /* Run the optimizers and output assembler code for this function. */
1588 rest_of_compilation (fndecl);
1590 current_function_decl = NULL_TREE;
1591 permanent_allocation (1);
1595 build_decl_no_layout (code, name, type)
1596 enum tree_code code;
1599 tree decl = build_decl (TYPE_DECL, name, type);
1600 TREE_SET_CODE (decl, code);