1 /* Process declarations and variables for the GNU compiler for the
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC 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 GCC 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 GCC; 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. */
31 #include "coretypes.h"
38 #include "java-tree.h"
44 #include "java-except.h"
48 #include "tree-inline.h"
51 #if defined (DEBUG_JAVA_BINDING_LEVELS)
52 extern void indent (void);
55 static tree
push_jvm_slot (int, tree
);
56 static tree
lookup_name_current_level (tree
);
57 static tree
push_promoted_type (const char *, tree
);
58 static struct binding_level
*make_binding_level (void);
59 static tree
create_primitive_vtable (const char *);
60 static tree
check_local_unnamed_variable (tree
, tree
, tree
);
62 /* Name of the Cloneable class. */
63 tree java_lang_cloneable_identifier_node
;
65 /* Name of the Serializable class. */
66 tree java_io_serializable_identifier_node
;
68 /* The DECL_MAP is a mapping from (index, type) to a decl node.
69 If index < max_locals, it is the index of a local variable.
70 if index >= max_locals, then index-max_locals is a stack slot.
71 The DECL_MAP mapping is represented as a TREE_VEC whose elements
72 are a list of decls (VAR_DECL or PARM_DECL) chained by
73 DECL_LOCAL_SLOT_CHAIN; the index finds the TREE_VEC element, and then
74 we search the chain for a decl with a matching TREE_TYPE. */
76 static GTY(()) tree decl_map
;
78 /* The base_decl_map is contains one variable of ptr_type: this is
79 used to contain every variable of reference type that is ever
80 stored in a local variable slot. */
82 static GTY(()) tree base_decl_map
;
84 /* An index used to make temporary identifiers unique. */
87 /* A list of local variables VAR_DECLs for this method that we have seen
88 debug information, but we have not reached their starting (byte) PC yet. */
90 static GTY(()) tree pending_local_decls
;
92 #if defined(DEBUG_JAVA_BINDING_LEVELS)
93 int binding_depth
= 0;
94 int is_class_level
= 0;
102 for (i
= 0; i
< binding_depth
*2; i
++)
105 #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
107 /* True if decl is a named local variable, i.e. if it is an alias
108 that's used only for debugging purposes. */
111 debug_variable_p (tree decl
)
113 if (TREE_CODE (decl
) == PARM_DECL
)
116 if (LOCAL_SLOT_P (decl
))
122 /* Copy the value in decl into every live alias in the same local
123 variable slot. Some of these will be dead stores removed by the
127 update_aliases (tree decl
, int index
, int pc
)
129 tree decl_type
= TREE_TYPE (decl
);
132 if (debug_variable_p (decl
))
135 for (tmp
= TREE_VEC_ELT (decl_map
, index
);
137 tmp
= DECL_LOCAL_SLOT_CHAIN (tmp
))
139 tree tmp_type
= TREE_TYPE (tmp
);
141 && LOCAL_SLOT_P (tmp
) == 0
143 || (pc
>= DECL_LOCAL_START_PC (tmp
)
144 && pc
<= DECL_LOCAL_END_PC (tmp
)))
145 && (tmp_type
== decl_type
146 || (INTEGRAL_TYPE_P (tmp_type
)
147 && INTEGRAL_TYPE_P (decl_type
)
148 && TYPE_PRECISION (decl_type
) <= 32
149 && TYPE_PRECISION (tmp_type
) <= 32)
150 || (TREE_CODE (tmp_type
) == POINTER_TYPE
151 && TREE_CODE (decl_type
) == POINTER_TYPE
)))
153 tree src
= build1 (NOP_EXPR
, tmp_type
, decl
);
154 if (LOCAL_VAR_OUT_OF_SCOPE_P (tmp
))
157 (build (MODIFY_EXPR
, tmp_type
, tmp
, src
));
163 push_jvm_slot (int index
, tree decl
)
165 DECL_CONTEXT (decl
) = current_function_decl
;
166 layout_decl (decl
, 0);
168 /* Now link the decl into the decl_map. */
169 if (DECL_LANG_SPECIFIC (decl
) == NULL
)
171 MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl
);
172 DECL_LOCAL_START_PC (decl
) = 0;
173 DECL_LOCAL_END_PC (decl
) = DECL_CODE_LENGTH (current_function_decl
);
174 DECL_LOCAL_SLOT_NUMBER (decl
) = index
;
176 DECL_LOCAL_SLOT_CHAIN (decl
) = TREE_VEC_ELT (decl_map
, index
);
177 TREE_VEC_ELT (decl_map
, index
) = decl
;
182 /* At the point of its creation a local variable decl inherits
183 whatever is already in the same slot. In the case of a local
184 variable that is declared but unused, we won't find anything. */
187 initialize_local_variable (tree decl
, int index
)
189 tree decl_type
= TREE_TYPE (decl
);
190 if (TREE_CODE (decl_type
) == POINTER_TYPE
)
192 tree tmp
= TREE_VEC_ELT (base_decl_map
, index
);
196 /* At the point of its creation this decl inherits whatever
198 tree src
= build1 (NOP_EXPR
, decl_type
, tmp
);
200 (build (MODIFY_EXPR
, decl_type
, decl
, src
));
207 for (tmp
= TREE_VEC_ELT (decl_map
, index
);
209 tmp
= DECL_LOCAL_SLOT_CHAIN (tmp
))
211 tree tmp_type
= TREE_TYPE (tmp
);
213 && ! debug_variable_p (tmp
)
214 && (tmp_type
== decl_type
215 || (INTEGRAL_TYPE_P (tmp_type
)
216 && INTEGRAL_TYPE_P (decl_type
)
217 && TYPE_PRECISION (decl_type
) <= 32
218 && TYPE_PRECISION (tmp_type
) <= 32
219 && TYPE_PRECISION (tmp_type
) >= TYPE_PRECISION (decl_type
))))
222 (build (MODIFY_EXPR
, decl_type
, decl
, tmp
));
229 /* Find the best declaration based upon type. If 'decl' fits 'type' better
230 than 'best', return 'decl'. Otherwise return 'best'. */
233 check_local_unnamed_variable (tree best
, tree decl
, tree type
)
235 tree decl_type
= TREE_TYPE (decl
);
237 if (LOCAL_VAR_OUT_OF_SCOPE_P (decl
))
240 /* Use the same decl for all integer types <= 32 bits. This is
241 necessary because sometimes a value is stored as (for example)
242 boolean but loaded as int. */
243 if (decl_type
== type
244 || (INTEGRAL_TYPE_P (decl_type
)
245 && INTEGRAL_TYPE_P (type
)
246 && TYPE_PRECISION (decl_type
) <= 32
247 && TYPE_PRECISION (type
) <= 32
248 && TYPE_PRECISION (decl_type
) >= TYPE_PRECISION (type
))
249 || (TREE_CODE (TREE_TYPE (decl
)) == POINTER_TYPE
250 && type
== ptr_type_node
))
252 if (best
== NULL_TREE
253 || (decl_type
== type
&& TREE_TYPE (best
) != type
))
261 /* Find a VAR_DECL (or PARM_DECL) at local index INDEX that has type TYPE,
262 that is valid at PC (or -1 if any pc).
263 If there is no existing matching decl, allocate one. */
266 find_local_variable (int index
, tree type
, int pc ATTRIBUTE_UNUSED
)
268 tree tmp
= TREE_VEC_ELT (decl_map
, index
);
269 tree decl
= NULL_TREE
;
271 /* Scan through every declaration that has been created in this
272 slot. We're only looking for variables that correspond to local
273 index declarations and PARM_DECLs, not named variables: such
274 local variables are used only for debugging information. */
275 while (tmp
!= NULL_TREE
)
277 if (! debug_variable_p (tmp
))
278 decl
= check_local_unnamed_variable (decl
, tmp
, type
);
279 tmp
= DECL_LOCAL_SLOT_CHAIN (tmp
);
282 /* If we don't find a match, create one with the type passed in.
283 The name of the variable is #n#m, which n is the variable index
284 in the local variable area and m is a dummy identifier for
285 uniqueness -- multiple variables may share the same local
286 variable index. We don't call pushdecl() to push pointer types
287 into a binding expr because they'll all be replaced by a single
288 variable that is used for every reference in that local variable
294 sprintf (buf
, "#slot#%d#%d", index
, uniq
++);
295 name
= get_identifier (buf
);
296 decl
= build_decl (VAR_DECL
, name
, type
);
297 DECL_IGNORED_P (decl
) = 1;
298 DECL_ARTIFICIAL (decl
) = 1;
299 decl
= push_jvm_slot (index
, decl
);
300 LOCAL_SLOT_P (decl
) = 1;
302 if (TREE_CODE (type
) != POINTER_TYPE
)
303 pushdecl_function_level (decl
);
306 /* As well as creating a local variable that matches the type, we
307 also create a base variable (of ptr_type) that will hold all its
309 if (TREE_CODE (type
) == POINTER_TYPE
310 && ! TREE_VEC_ELT (base_decl_map
, index
))
315 sprintf (buf
, "#ref#%d#%d", index
, uniq
++);
316 name
= get_identifier (buf
);
318 = TREE_VEC_ELT (base_decl_map
, index
)
319 = build_decl (VAR_DECL
, name
, ptr_type_node
);
320 pushdecl_function_level (base_decl
);
321 DECL_IGNORED_P (base_decl
) = 1;
322 DECL_ARTIFICIAL (base_decl
) = 1;
328 /* Called during gimplification for every variable. If the variable
329 is a temporary of pointer type, replace it with a common variable
330 thath is used to hold all pointer types that are ever stored in
331 that slot. Set WANT_LVALUE if you want a variable that is to be
335 java_replace_reference (tree var_decl
, bool want_lvalue
)
342 decl_type
= TREE_TYPE (var_decl
);
344 if (TREE_CODE (decl_type
) == POINTER_TYPE
)
346 if (DECL_LANG_SPECIFIC (var_decl
)
347 && LOCAL_SLOT_P (var_decl
))
349 int index
= DECL_LOCAL_SLOT_NUMBER (var_decl
);
350 tree base_decl
= TREE_VEC_ELT (base_decl_map
, index
);
356 base_decl
= build1 (NOP_EXPR
, decl_type
, base_decl
);
366 /* Same as find_local_index, except that INDEX is a stack index. */
369 find_stack_slot (int index
, tree type
)
371 return find_local_variable (index
+ DECL_MAX_LOCALS (current_function_decl
),
375 struct binding_level
GTY(())
377 /* A chain of _DECL nodes for all variables, constants, functions,
378 * and typedef types. These are in the reverse of the order supplied.
382 /* For each level, a list of shadowed outer-level local definitions
383 to be restored when this level is popped.
384 Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
385 whose TREE_VALUE is its old definition (a kind of ..._DECL node). */
388 /* For each level (except not the global one),
389 a chain of BLOCK nodes for all the levels
390 that were entered and exited one level down. */
393 /* The binding level which this one is contained in (inherits from). */
394 struct binding_level
*level_chain
;
396 /* The bytecode PC that marks the end of this level. */
398 /* The bytecode PC that marks the start of this level. */
401 /* The statements in this binding level. */
404 /* An exception range associated with this binding level. */
405 struct eh_range
* GTY((skip (""))) exception_range
;
407 /* Binding depth at which this level began. Used only for debugging. */
408 unsigned binding_depth
;
411 #define NULL_BINDING_LEVEL (struct binding_level *) NULL
413 /* The binding level currently in effect. */
415 static GTY(()) struct binding_level
*current_binding_level
;
417 /* A chain of binding_level structures awaiting reuse. */
419 static GTY(()) struct binding_level
*free_binding_level
;
421 /* The outermost binding level, for names of file scope.
422 This is created when the compiler is started and exists
423 through the entire run. */
425 static GTY(()) struct binding_level
*global_binding_level
;
427 /* The binding level that holds variables declared at the outermost
428 level within a function body. */
430 static struct binding_level
*function_binding_level
;
432 /* A PC value bigger than any PC value we may ever may encounter. */
434 #define LARGEST_PC (( (unsigned int)1 << (HOST_BITS_PER_INT - 1)) - 1)
436 /* Binding level structures are initialized by copying this one. */
438 static const struct binding_level clear_binding_level
440 NULL_TREE
, /* names */
441 NULL_TREE
, /* shadowed */
442 NULL_TREE
, /* blocks */
443 NULL_BINDING_LEVEL
, /* level_chain */
444 LARGEST_PC
, /* end_pc */
447 NULL
, /* exception_range */
448 0, /* binding_depth */
452 /* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
453 that have names. Here so we can clear out their names' definitions
454 at the end of the function. */
456 static tree named_labels
;
458 /* A list of LABEL_DECLs from outer contexts that are currently shadowed. */
460 static tree shadowed_labels
;
463 tree java_global_trees
[JTI_MAX
];
465 /* Build (and pushdecl) a "promoted type" for all standard
466 types shorter than int. */
469 push_promoted_type (const char *name
, tree actual_type
)
471 tree type
= make_node (TREE_CODE (actual_type
));
473 tree in_min
= TYPE_MIN_VALUE (int_type_node
);
474 tree in_max
= TYPE_MAX_VALUE (int_type_node
);
476 tree in_min
= TYPE_MIN_VALUE (actual_type
);
477 tree in_max
= TYPE_MAX_VALUE (actual_type
);
479 TYPE_MIN_VALUE (type
) = copy_node (in_min
);
480 TREE_TYPE (TYPE_MIN_VALUE (type
)) = type
;
481 TYPE_MAX_VALUE (type
) = copy_node (in_max
);
482 TREE_TYPE (TYPE_MAX_VALUE (type
)) = type
;
483 TYPE_PRECISION (type
) = TYPE_PRECISION (int_type_node
);
485 pushdecl (build_decl (TYPE_DECL
, get_identifier (name
), type
));
489 /* Return a definition for a builtin function named NAME and whose data type
490 is TYPE. TYPE should be a function type with argument types.
491 FUNCTION_CODE tells later passes how to compile calls to this function.
492 See tree.h for its possible values.
494 If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
495 the name to be called if we can't opencode the function. If
496 ATTRS is nonzero, use that for the function's attribute list. */
499 builtin_function (const char *name
,
502 enum built_in_class
class,
503 const char *library_name
,
504 tree
ARG_UNUSED (attrs
))
506 tree decl
= build_decl (FUNCTION_DECL
, get_identifier (name
), type
);
507 DECL_EXTERNAL (decl
) = 1;
508 TREE_PUBLIC (decl
) = 1;
510 SET_DECL_ASSEMBLER_NAME (decl
, get_identifier (library_name
));
511 make_decl_rtl (decl
, NULL
);
513 DECL_BUILT_IN_CLASS (decl
) = class;
514 DECL_FUNCTION_CODE (decl
) = function_code
;
518 /* Return tree that represents a vtable for a primitive array. */
520 create_primitive_vtable (const char *name
)
525 sprintf (buf
, "_Jv_%sVTable", name
);
526 r
= build_decl (VAR_DECL
, get_identifier (buf
), ptr_type_node
);
527 DECL_EXTERNAL (r
) = 1;
539 java_init_decl_processing (void)
542 tree field
= NULL_TREE
;
545 init_class_processing ();
547 current_function_decl
= NULL
;
548 current_binding_level
= NULL_BINDING_LEVEL
;
549 free_binding_level
= NULL_BINDING_LEVEL
;
550 pushlevel (0); /* make the binding_level structure for global names */
551 global_binding_level
= current_binding_level
;
553 /* The code here must be similar to build_common_tree_nodes{,_2} in
554 tree.c, especially as to the order of initializing common nodes. */
555 error_mark_node
= make_node (ERROR_MARK
);
556 TREE_TYPE (error_mark_node
) = error_mark_node
;
558 /* Create sizetype first - needed for other types. */
559 initialize_sizetypes ();
561 byte_type_node
= make_signed_type (8);
562 pushdecl (build_decl (TYPE_DECL
, get_identifier ("byte"), byte_type_node
));
563 short_type_node
= make_signed_type (16);
564 pushdecl (build_decl (TYPE_DECL
, get_identifier ("short"), short_type_node
));
565 int_type_node
= make_signed_type (32);
566 pushdecl (build_decl (TYPE_DECL
, get_identifier ("int"), int_type_node
));
567 long_type_node
= make_signed_type (64);
568 pushdecl (build_decl (TYPE_DECL
, get_identifier ("long"), long_type_node
));
570 unsigned_byte_type_node
= make_unsigned_type (8);
571 pushdecl (build_decl (TYPE_DECL
, get_identifier ("unsigned byte"),
572 unsigned_byte_type_node
));
573 unsigned_short_type_node
= make_unsigned_type (16);
574 pushdecl (build_decl (TYPE_DECL
, get_identifier ("unsigned short"),
575 unsigned_short_type_node
));
576 unsigned_int_type_node
= make_unsigned_type (32);
577 pushdecl (build_decl (TYPE_DECL
, get_identifier ("unsigned int"),
578 unsigned_int_type_node
));
579 unsigned_long_type_node
= make_unsigned_type (64);
580 pushdecl (build_decl (TYPE_DECL
, get_identifier ("unsigned long"),
581 unsigned_long_type_node
));
583 /* This is not a java type, however tree-dfa requires a definition for
585 size_type_node
= make_unsigned_type (POINTER_SIZE
);
586 set_sizetype (size_type_node
);
588 /* Define these next since types below may used them. */
589 integer_type_node
= java_type_for_size (INT_TYPE_SIZE
, 0);
590 integer_zero_node
= build_int_2 (0, 0);
591 integer_one_node
= build_int_2 (1, 0);
592 integer_two_node
= build_int_2 (2, 0);
593 integer_four_node
= build_int_2 (4, 0);
594 integer_minus_one_node
= build_int_2 (-1, -1);
596 /* A few values used for range checking in the lexer. */
597 decimal_int_max
= build_int_2 (0x80000000, 0);
598 TREE_TYPE (decimal_int_max
) = unsigned_int_type_node
;
599 #if HOST_BITS_PER_WIDE_INT == 64
600 decimal_long_max
= build_int_2 (0x8000000000000000LL
, 0);
602 #if HOST_BITS_PER_WIDE_INT == 32
603 decimal_long_max
= build_int_2 (0, 0x80000000);
605 #error "unsupported size"
608 TREE_TYPE (decimal_long_max
) = unsigned_long_type_node
;
610 size_zero_node
= size_int (0);
611 size_one_node
= size_int (1);
612 bitsize_zero_node
= bitsize_int (0);
613 bitsize_one_node
= bitsize_int (1);
614 bitsize_unit_node
= bitsize_int (BITS_PER_UNIT
);
616 long_zero_node
= build_int_2 (0, 0);
617 TREE_TYPE (long_zero_node
) = long_type_node
;
619 void_type_node
= make_node (VOID_TYPE
);
620 pushdecl (build_decl (TYPE_DECL
, get_identifier ("void"), void_type_node
));
621 layout_type (void_type_node
); /* Uses size_zero_node */
622 ptr_type_node
= build_pointer_type (void_type_node
);
623 t
= make_node (VOID_TYPE
);
624 layout_type (t
); /* Uses size_zero_node */
625 return_address_type_node
= build_pointer_type (t
);
627 null_pointer_node
= build_int_2 (0, 0);
628 TREE_TYPE (null_pointer_node
) = ptr_type_node
;
631 /* Make a type to be the domain of a few array types
632 whose domains don't really matter.
633 200 is small enough that it always fits in size_t
634 and large enough that it can hold most function names for the
635 initializations of __FUNCTION__ and __PRETTY_FUNCTION__. */
636 short_array_type_node
= build_prim_array_type (short_type_node
, 200);
638 char_type_node
= make_node (CHAR_TYPE
);
639 TYPE_PRECISION (char_type_node
) = 16;
640 fixup_unsigned_type (char_type_node
);
641 pushdecl (build_decl (TYPE_DECL
, get_identifier ("char"), char_type_node
));
643 boolean_type_node
= make_node (BOOLEAN_TYPE
);
644 TYPE_PRECISION (boolean_type_node
) = 1;
645 fixup_unsigned_type (boolean_type_node
);
646 pushdecl (build_decl (TYPE_DECL
, get_identifier ("boolean"),
648 boolean_false_node
= TYPE_MIN_VALUE (boolean_type_node
);
649 boolean_true_node
= TYPE_MAX_VALUE (boolean_type_node
);
651 promoted_byte_type_node
652 = push_promoted_type ("promoted_byte", byte_type_node
);
653 promoted_short_type_node
654 = push_promoted_type ("promoted_short", short_type_node
);
655 promoted_char_type_node
656 = push_promoted_type ("promoted_char", char_type_node
);
657 promoted_boolean_type_node
658 = push_promoted_type ("promoted_boolean", boolean_type_node
);
660 float_type_node
= make_node (REAL_TYPE
);
661 TYPE_PRECISION (float_type_node
) = 32;
662 pushdecl (build_decl (TYPE_DECL
, get_identifier ("float"),
664 layout_type (float_type_node
);
666 double_type_node
= make_node (REAL_TYPE
);
667 TYPE_PRECISION (double_type_node
) = 64;
668 pushdecl (build_decl (TYPE_DECL
, get_identifier ("double"),
670 layout_type (double_type_node
);
672 float_zero_node
= build_real (float_type_node
, dconst0
);
673 double_zero_node
= build_real (double_type_node
, dconst0
);
675 /* These are the vtables for arrays of primitives. */
676 boolean_array_vtable
= create_primitive_vtable ("boolean");
677 byte_array_vtable
= create_primitive_vtable ("byte");
678 char_array_vtable
= create_primitive_vtable ("char");
679 short_array_vtable
= create_primitive_vtable ("short");
680 int_array_vtable
= create_primitive_vtable ("int");
681 long_array_vtable
= create_primitive_vtable ("long");
682 float_array_vtable
= create_primitive_vtable ("float");
683 double_array_vtable
= create_primitive_vtable ("double");
685 one_elt_array_domain_type
= build_index_type (integer_one_node
);
686 utf8const_type
= make_node (RECORD_TYPE
);
687 PUSH_FIELD (utf8const_type
, field
, "hash", unsigned_short_type_node
);
688 PUSH_FIELD (utf8const_type
, field
, "length", unsigned_short_type_node
);
689 FINISH_RECORD (utf8const_type
);
690 utf8const_ptr_type
= build_pointer_type (utf8const_type
);
692 atable_type
= build_array_type (ptr_type_node
,
693 one_elt_array_domain_type
);
694 TYPE_NONALIASED_COMPONENT (atable_type
) = 1;
695 atable_ptr_type
= build_pointer_type (atable_type
);
697 symbol_type
= make_node (RECORD_TYPE
);
698 PUSH_FIELD (symbol_type
, field
, "clname", utf8const_ptr_type
);
699 PUSH_FIELD (symbol_type
, field
, "name", utf8const_ptr_type
);
700 PUSH_FIELD (symbol_type
, field
, "signature", utf8const_ptr_type
);
701 FINISH_RECORD (symbol_type
);
703 symbols_array_type
= build_array_type (symbol_type
,
704 one_elt_array_domain_type
);
705 symbols_array_ptr_type
= build_pointer_type (symbols_array_type
);
707 /* As you're adding items here, please update the code right after
708 this section, so that the filename containing the source code of
709 the pre-defined class gets registered correctly. */
710 unqualified_object_id_node
= get_identifier ("Object");
711 object_type_node
= lookup_class (get_identifier ("java.lang.Object"));
712 object_ptr_type_node
= promote_type (object_type_node
);
713 string_type_node
= lookup_class (get_identifier ("java.lang.String"));
714 string_ptr_type_node
= promote_type (string_type_node
);
715 class_type_node
= lookup_class (get_identifier ("java.lang.Class"));
716 throwable_type_node
= lookup_class (get_identifier ("java.lang.Throwable"));
717 exception_type_node
= lookup_class (get_identifier ("java.lang.Exception"));
718 runtime_exception_type_node
=
719 lookup_class (get_identifier ("java.lang.RuntimeException"));
720 error_exception_type_node
=
721 lookup_class (get_identifier ("java.lang.Error"));
723 rawdata_ptr_type_node
724 = promote_type (lookup_class (get_identifier ("gnu.gcj.RawData")));
726 add_predefined_file (get_identifier ("java/lang/Class.java"));
727 add_predefined_file (get_identifier ("java/lang/Error.java"));
728 add_predefined_file (get_identifier ("java/lang/Object.java"));
729 add_predefined_file (get_identifier ("java/lang/RuntimeException.java"));
730 add_predefined_file (get_identifier ("java/lang/String.java"));
731 add_predefined_file (get_identifier ("java/lang/Throwable.java"));
732 add_predefined_file (get_identifier ("gnu/gcj/RawData.java"));
733 add_predefined_file (get_identifier ("java/lang/Exception.java"));
734 add_predefined_file (get_identifier ("java/lang/ClassNotFoundException.java"));
735 add_predefined_file (get_identifier ("java/lang/NoClassDefFoundError.java"));
737 methodtable_type
= make_node (RECORD_TYPE
);
738 layout_type (methodtable_type
);
739 build_decl (TYPE_DECL
, get_identifier ("methodtable"), methodtable_type
);
740 methodtable_ptr_type
= build_pointer_type (methodtable_type
);
742 TYPE_identifier_node
= get_identifier ("TYPE");
743 init_identifier_node
= get_identifier ("<init>");
744 clinit_identifier_node
= get_identifier ("<clinit>");
745 finit_identifier_node
= get_identifier ("finit$");
746 instinit_identifier_node
= get_identifier ("instinit$");
747 void_signature_node
= get_identifier ("()V");
748 length_identifier_node
= get_identifier ("length");
749 finalize_identifier_node
= get_identifier ("finalize");
750 this_identifier_node
= get_identifier ("this");
751 super_identifier_node
= get_identifier ("super");
752 continue_identifier_node
= get_identifier ("continue");
753 access0_identifier_node
= get_identifier ("access$0");
754 classdollar_identifier_node
= get_identifier ("class$");
756 java_lang_cloneable_identifier_node
= get_identifier ("java.lang.Cloneable");
757 java_io_serializable_identifier_node
=
758 get_identifier ("java.io.Serializable");
760 /* for lack of a better place to put this stub call */
761 init_expr_processing();
763 constants_type_node
= make_node (RECORD_TYPE
);
764 PUSH_FIELD (constants_type_node
, field
, "size", unsigned_int_type_node
);
765 PUSH_FIELD (constants_type_node
, field
, "tags", ptr_type_node
);
766 PUSH_FIELD (constants_type_node
, field
, "data", ptr_type_node
);
767 FINISH_RECORD (constants_type_node
);
768 build_decl (TYPE_DECL
, get_identifier ("constants"), constants_type_node
);
770 access_flags_type_node
= unsigned_short_type_node
;
772 dtable_type
= make_node (RECORD_TYPE
);
773 dtable_ptr_type
= build_pointer_type (dtable_type
);
775 otable_type
= build_array_type (integer_type_node
,
776 one_elt_array_domain_type
);
777 TYPE_NONALIASED_COMPONENT (otable_type
) = 1;
778 otable_ptr_type
= build_pointer_type (otable_type
);
780 PUSH_FIELD (object_type_node
, field
, "vtable", dtable_ptr_type
);
781 DECL_FCONTEXT (field
) = object_type_node
;
782 TYPE_VFIELD (object_type_node
) = field
;
784 /* This isn't exactly true, but it is what we have in the source.
785 There is an unresolved issue here, which is whether the vtable
786 should be marked by the GC. */
787 if (! flag_hash_synchronization
)
788 PUSH_FIELD (object_type_node
, field
, "sync_info",
789 build_pointer_type (object_type_node
));
790 for (t
= TYPE_FIELDS (object_type_node
); t
!= NULL_TREE
; t
= TREE_CHAIN (t
))
791 FIELD_PRIVATE (t
) = 1;
792 FINISH_RECORD (object_type_node
);
794 field_type_node
= make_node (RECORD_TYPE
);
795 field_ptr_type_node
= build_pointer_type (field_type_node
);
796 method_type_node
= make_node (RECORD_TYPE
);
797 method_ptr_type_node
= build_pointer_type (method_type_node
);
799 set_super_info (0, class_type_node
, object_type_node
, 0);
800 set_super_info (0, string_type_node
, object_type_node
, 0);
801 class_ptr_type
= build_pointer_type (class_type_node
);
803 PUSH_FIELD (class_type_node
, field
, "next", class_ptr_type
);
804 PUSH_FIELD (class_type_node
, field
, "name", utf8const_ptr_type
);
805 PUSH_FIELD (class_type_node
, field
, "accflags", access_flags_type_node
);
806 PUSH_FIELD (class_type_node
, field
, "superclass", class_ptr_type
);
807 PUSH_FIELD (class_type_node
, field
, "constants", constants_type_node
);
808 PUSH_FIELD (class_type_node
, field
, "methods", method_ptr_type_node
);
809 PUSH_FIELD (class_type_node
, field
, "method_count", short_type_node
);
810 PUSH_FIELD (class_type_node
, field
, "vtable_method_count", short_type_node
);
811 PUSH_FIELD (class_type_node
, field
, "fields", field_ptr_type_node
);
812 PUSH_FIELD (class_type_node
, field
, "size_in_bytes", int_type_node
);
813 PUSH_FIELD (class_type_node
, field
, "field_count", short_type_node
);
814 PUSH_FIELD (class_type_node
, field
, "static_field_count", short_type_node
);
815 PUSH_FIELD (class_type_node
, field
, "vtable", dtable_ptr_type
);
816 PUSH_FIELD (class_type_node
, field
, "otable", otable_ptr_type
);
817 PUSH_FIELD (class_type_node
, field
, "otable_syms",
818 symbols_array_ptr_type
);
819 PUSH_FIELD (class_type_node
, field
, "atable", atable_ptr_type
);
820 PUSH_FIELD (class_type_node
, field
, "atable_syms",
821 symbols_array_ptr_type
);
822 PUSH_FIELD (class_type_node
, field
, "catch_classes", ptr_type_node
);
823 PUSH_FIELD (class_type_node
, field
, "interfaces",
824 build_pointer_type (class_ptr_type
));
825 PUSH_FIELD (class_type_node
, field
, "loader", ptr_type_node
);
826 PUSH_FIELD (class_type_node
, field
, "interface_count", short_type_node
);
827 PUSH_FIELD (class_type_node
, field
, "state", byte_type_node
);
828 PUSH_FIELD (class_type_node
, field
, "thread", ptr_type_node
);
829 PUSH_FIELD (class_type_node
, field
, "depth", short_type_node
);
830 PUSH_FIELD (class_type_node
, field
, "ancestors", ptr_type_node
);
831 PUSH_FIELD (class_type_node
, field
, "idt", ptr_type_node
);
832 PUSH_FIELD (class_type_node
, field
, "arrayclass", ptr_type_node
);
833 PUSH_FIELD (class_type_node
, field
, "protectionDomain", ptr_type_node
);
834 PUSH_FIELD (class_type_node
, field
, "hack_signers", ptr_type_node
);
835 PUSH_FIELD (class_type_node
, field
, "chain", ptr_type_node
);
836 PUSH_FIELD (class_type_node
, field
, "aux_info", ptr_type_node
);
837 for (t
= TYPE_FIELDS (class_type_node
); t
!= NULL_TREE
; t
= TREE_CHAIN (t
))
838 FIELD_PRIVATE (t
) = 1;
839 push_super_field (class_type_node
, object_type_node
);
841 FINISH_RECORD (class_type_node
);
842 build_decl (TYPE_DECL
, get_identifier ("Class"), class_type_node
);
844 field_info_union_node
= make_node (UNION_TYPE
);
845 PUSH_FIELD (field_info_union_node
, field
, "boffset", int_type_node
);
846 PUSH_FIELD (field_info_union_node
, field
, "addr", ptr_type_node
);
848 PUSH_FIELD (field_info_union_node
, field
, "idx", unsigned_short_type_node
);
850 layout_type (field_info_union_node
);
852 PUSH_FIELD (field_type_node
, field
, "name", utf8const_ptr_type
);
853 PUSH_FIELD (field_type_node
, field
, "type", class_ptr_type
);
854 PUSH_FIELD (field_type_node
, field
, "accflags", access_flags_type_node
);
855 PUSH_FIELD (field_type_node
, field
, "bsize", unsigned_short_type_node
);
856 PUSH_FIELD (field_type_node
, field
, "info", field_info_union_node
);
857 FINISH_RECORD (field_type_node
);
858 build_decl (TYPE_DECL
, get_identifier ("Field"), field_type_node
);
860 nativecode_ptr_array_type_node
861 = build_array_type (nativecode_ptr_type_node
, one_elt_array_domain_type
);
863 PUSH_FIELD (dtable_type
, field
, "class", class_ptr_type
);
864 PUSH_FIELD (dtable_type
, field
, "methods", nativecode_ptr_array_type_node
);
865 FINISH_RECORD (dtable_type
);
866 build_decl (TYPE_DECL
, get_identifier ("dispatchTable"), dtable_type
);
868 #define jint_type int_type_node
869 #define jint_ptr_type ptr_type_node
871 jexception_type
= make_node (RECORD_TYPE
);
872 PUSH_FIELD (jexception_type
, field
, "start_pc", ptr_type_node
);
873 PUSH_FIELD (jexception_type
, field
, "end_pc", ptr_type_node
);
874 PUSH_FIELD (jexception_type
, field
, "handler_pc", ptr_type_node
);
875 PUSH_FIELD (jexception_type
, field
, "catch_type", class_ptr_type
);
876 FINISH_RECORD (jexception_type
);
877 build_decl (TYPE_DECL
, get_identifier ("jexception"), field_type_node
);
878 jexception_ptr_type
= build_pointer_type (jexception_type
);
880 lineNumberEntry_type
= make_node (RECORD_TYPE
);
881 PUSH_FIELD (lineNumberEntry_type
, field
, "line_nr", unsigned_short_type_node
);
882 PUSH_FIELD (lineNumberEntry_type
, field
, "start_pc", ptr_type_node
);
883 FINISH_RECORD (lineNumberEntry_type
);
885 lineNumbers_type
= make_node (RECORD_TYPE
);
886 PUSH_FIELD (lineNumbers_type
, field
, "length", unsigned_int_type_node
);
887 FINISH_RECORD (lineNumbers_type
);
889 #define instn_ptr_type_node ptr_type_node /* XXX JH */
891 #define lineNumbers_ptr_type_node build_pointer_type(lineNumbers_type)
893 PUSH_FIELD (method_type_node
, field
, "name", utf8const_ptr_type
);
894 PUSH_FIELD (method_type_node
, field
, "signature", utf8const_ptr_type
);
895 PUSH_FIELD (method_type_node
, field
, "accflags", access_flags_type_node
);
896 PUSH_FIELD (method_type_node
, field
, "index", unsigned_short_type_node
);
897 PUSH_FIELD (method_type_node
, field
, "ncode", nativecode_ptr_type_node
);
898 PUSH_FIELD (method_type_node
, field
, "throws", ptr_type_node
);
899 FINISH_RECORD (method_type_node
);
900 build_decl (TYPE_DECL
, get_identifier ("Method"), method_type_node
);
902 endlink
= end_params_node
= tree_cons (NULL_TREE
, void_type_node
, NULL_TREE
);
904 t
= tree_cons (NULL_TREE
, class_ptr_type
,
905 tree_cons (NULL_TREE
, int_type_node
, endlink
));
906 alloc_object_node
= builtin_function ("_Jv_AllocObject",
907 build_function_type (ptr_type_node
, t
),
908 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
909 DECL_IS_MALLOC (alloc_object_node
) = 1;
910 alloc_no_finalizer_node
=
911 builtin_function ("_Jv_AllocObjectNoFinalizer",
912 build_function_type (ptr_type_node
, t
),
913 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
914 DECL_IS_MALLOC (alloc_no_finalizer_node
) = 1;
916 t
= tree_cons (NULL_TREE
, ptr_type_node
, endlink
);
917 soft_initclass_node
= builtin_function ("_Jv_InitClass",
918 build_function_type (void_type_node
,
920 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
922 throw_node
= builtin_function ("_Jv_Throw",
923 build_function_type (ptr_type_node
, t
),
924 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
925 /* Mark throw_nodes as `noreturn' functions with side effects. */
926 TREE_THIS_VOLATILE (throw_node
) = 1;
927 TREE_SIDE_EFFECTS (throw_node
) = 1;
929 t
= build_function_type (int_type_node
, endlink
);
930 soft_monitorenter_node
931 = builtin_function ("_Jv_MonitorEnter", t
, 0, NOT_BUILT_IN
,
933 soft_monitorexit_node
934 = builtin_function ("_Jv_MonitorExit", t
, 0, NOT_BUILT_IN
,
937 t
= tree_cons (NULL_TREE
, int_type_node
,
938 tree_cons (NULL_TREE
, int_type_node
, endlink
));
940 = builtin_function ("_Jv_NewPrimArray",
941 build_function_type(ptr_type_node
, t
),
942 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
943 DECL_IS_MALLOC (soft_newarray_node
) = 1;
945 t
= tree_cons (NULL_TREE
, int_type_node
,
946 tree_cons (NULL_TREE
, class_ptr_type
,
947 tree_cons (NULL_TREE
, object_ptr_type_node
, endlink
)));
949 = builtin_function ("_Jv_NewObjectArray",
950 build_function_type (ptr_type_node
, t
),
951 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
952 DECL_IS_MALLOC (soft_anewarray_node
) = 1;
954 /* There is no endlink here because _Jv_NewMultiArray is a varargs
956 t
= tree_cons (NULL_TREE
, ptr_type_node
,
957 tree_cons (NULL_TREE
, int_type_node
, NULL_TREE
));
958 soft_multianewarray_node
959 = builtin_function ("_Jv_NewMultiArray",
960 build_function_type (ptr_type_node
, t
),
961 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
962 DECL_IS_MALLOC (soft_multianewarray_node
) = 1;
964 t
= build_function_type (void_type_node
,
965 tree_cons (NULL_TREE
, int_type_node
, endlink
));
966 soft_badarrayindex_node
967 = builtin_function ("_Jv_ThrowBadArrayIndex", t
,
968 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
969 /* Mark soft_badarrayindex_node as a `noreturn' function with side
971 TREE_THIS_VOLATILE (soft_badarrayindex_node
) = 1;
972 TREE_SIDE_EFFECTS (soft_badarrayindex_node
) = 1;
974 soft_nullpointer_node
975 = builtin_function ("_Jv_ThrowNullPointerException",
976 build_function_type (void_type_node
, endlink
),
977 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
978 /* Mark soft_nullpointer_node as a `noreturn' function with side
980 TREE_THIS_VOLATILE (soft_nullpointer_node
) = 1;
981 TREE_SIDE_EFFECTS (soft_nullpointer_node
) = 1;
983 t
= tree_cons (NULL_TREE
, class_ptr_type
,
984 tree_cons (NULL_TREE
, object_ptr_type_node
, endlink
));
986 = builtin_function ("_Jv_CheckCast",
987 build_function_type (ptr_type_node
, t
),
988 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
989 t
= tree_cons (NULL_TREE
, object_ptr_type_node
,
990 tree_cons (NULL_TREE
, class_ptr_type
, endlink
));
992 = builtin_function ("_Jv_IsInstanceOf",
993 build_function_type (boolean_type_node
, t
),
994 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
995 t
= tree_cons (NULL_TREE
, object_ptr_type_node
,
996 tree_cons (NULL_TREE
, object_ptr_type_node
, endlink
));
997 soft_checkarraystore_node
998 = builtin_function ("_Jv_CheckArrayStore",
999 build_function_type (void_type_node
, t
),
1000 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
1001 t
= tree_cons (NULL_TREE
, ptr_type_node
,
1002 tree_cons (NULL_TREE
, ptr_type_node
,
1003 tree_cons (NULL_TREE
, int_type_node
, endlink
)));
1004 soft_lookupinterfacemethod_node
1005 = builtin_function ("_Jv_LookupInterfaceMethodIdx",
1006 build_function_type (ptr_type_node
, t
),
1007 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
1009 t
= tree_cons (NULL_TREE
, object_ptr_type_node
,
1010 tree_cons (NULL_TREE
, ptr_type_node
,
1011 tree_cons (NULL_TREE
, ptr_type_node
,
1012 tree_cons (NULL_TREE
, int_type_node
,
1014 soft_lookupjnimethod_node
1015 = builtin_function ("_Jv_LookupJNIMethod",
1016 build_function_type (ptr_type_node
, t
),
1017 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
1018 t
= tree_cons (NULL_TREE
, ptr_type_node
, endlink
);
1019 soft_getjnienvnewframe_node
1020 = builtin_function ("_Jv_GetJNIEnvNewFrame",
1021 build_function_type (ptr_type_node
, t
),
1022 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
1023 soft_jnipopsystemframe_node
1024 = builtin_function ("_Jv_JNI_PopSystemFrame",
1025 build_function_type (ptr_type_node
, t
),
1026 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
1029 = builtin_function ("_Jv_divI",
1030 build_function_type (int_type_node
, t
),
1031 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
1034 = builtin_function ("_Jv_remI",
1035 build_function_type (int_type_node
, t
),
1036 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
1039 = builtin_function ("_Jv_divJ",
1040 build_function_type (long_type_node
, t
),
1041 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
1044 = builtin_function ("_Jv_remJ",
1045 build_function_type (long_type_node
, t
),
1046 0, NOT_BUILT_IN
, NULL
, NULL_TREE
);
1048 /* Initialize variables for except.c. */
1049 eh_personality_libfunc
= init_one_libfunc (USING_SJLJ_EXCEPTIONS
1050 ? "__gcj_personality_sj0"
1051 : "__gcj_personality_v0");
1053 lang_eh_runtime_type
= do_nothing
;
1057 initialize_builtins ();
1058 soft_fmod_node
= built_in_decls
[BUILT_IN_FMOD
];
1060 soft_fmodf_node
= built_in_decls
[BUILT_IN_FMODF
];
1065 /* Look up NAME in the current binding level and its superiors
1066 in the namespace of variables, functions and typedefs.
1067 Return a ..._DECL node of some kind representing its definition,
1068 or return 0 if it is undefined. */
1071 lookup_name (tree name
)
1074 if (current_binding_level
!= global_binding_level
1075 && IDENTIFIER_LOCAL_VALUE (name
))
1076 val
= IDENTIFIER_LOCAL_VALUE (name
);
1078 val
= IDENTIFIER_GLOBAL_VALUE (name
);
1082 /* Similar to `lookup_name' but look only at current binding level and
1083 the previous one if its the parameter level. */
1086 lookup_name_current_level (tree name
)
1090 if (current_binding_level
== global_binding_level
)
1091 return IDENTIFIER_GLOBAL_VALUE (name
);
1093 if (IDENTIFIER_LOCAL_VALUE (name
) == 0)
1096 for (t
= current_binding_level
->names
; t
; t
= TREE_CHAIN (t
))
1097 if (DECL_NAME (t
) == name
)
1103 /* Use a binding level to record a labeled block declaration */
1106 push_labeled_block (tree lb
)
1108 tree name
= DECL_NAME (LABELED_BLOCK_LABEL (lb
));
1109 struct binding_level
*b
= current_binding_level
;
1110 tree oldlocal
= IDENTIFIER_LOCAL_VALUE (name
);
1112 b
->shadowed
= tree_cons (name
, oldlocal
, b
->shadowed
);
1113 TREE_CHAIN (lb
) = b
->names
;
1115 IDENTIFIER_LOCAL_VALUE (name
) = lb
;
1118 /* Pop the current binding level, reinstalling values for the previous
1122 pop_labeled_block (void)
1124 struct binding_level
*b
= current_binding_level
;
1125 tree label
= b
->names
;
1126 IDENTIFIER_LOCAL_VALUE (DECL_NAME (LABELED_BLOCK_LABEL (label
))) =
1129 IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (b
->shadowed
)) =
1130 TREE_VALUE (b
->shadowed
);
1132 /* Pop the current level, and free the structure for reuse. */
1133 current_binding_level
= current_binding_level
->level_chain
;
1134 b
->level_chain
= free_binding_level
;
1135 free_binding_level
= b
;
1138 /* Record a decl-node X as belonging to the current lexical scope.
1139 Check for errors (such as an incompatible declaration for the same
1140 name already seen in the same scope).
1142 Returns either X or an old decl for the same name.
1143 If an old decl is returned, it may have been smashed
1144 to agree with what X says. */
1150 tree name
= DECL_NAME (x
);
1151 struct binding_level
*b
= current_binding_level
;
1153 if (TREE_CODE (x
) != TYPE_DECL
)
1154 DECL_CONTEXT (x
) = current_function_decl
;
1157 t
= lookup_name_current_level (name
);
1158 if (t
!= 0 && t
== error_mark_node
)
1159 /* error_mark_node is 0 for a while during initialization! */
1162 error ("%J'%D' used prior to declaration", x
, x
);
1165 /* If we're naming a hitherto-unnamed type, set its TYPE_NAME
1166 to point to the TYPE_DECL.
1167 Since Java does not have typedefs, a type can only have
1168 one (true) name, given by a class, interface, or builtin. */
1169 if (TREE_CODE (x
) == TYPE_DECL
1170 && TYPE_NAME (TREE_TYPE (x
)) == 0
1171 && TREE_TYPE (x
) != error_mark_node
)
1173 TYPE_NAME (TREE_TYPE (x
)) = x
;
1174 TYPE_STUB_DECL (TREE_TYPE (x
)) = x
;
1177 /* This name is new in its binding level.
1178 Install the new declaration and return it. */
1179 if (b
== global_binding_level
)
1181 /* Install a global value. */
1183 IDENTIFIER_GLOBAL_VALUE (name
) = x
;
1187 /* Here to install a non-global value. */
1188 tree oldlocal
= IDENTIFIER_LOCAL_VALUE (name
);
1189 IDENTIFIER_LOCAL_VALUE (name
) = x
;
1192 /* Warn if shadowing an argument at the top level of the body. */
1193 if (oldlocal
!= 0 && !DECL_EXTERNAL (x
)
1194 /* This warning doesn't apply to the parms of a nested fcn. */
1195 && ! current_binding_level
->parm_flag
1196 /* Check that this is one level down from the parms. */
1197 && current_binding_level
->level_chain
->parm_flag
1198 /* Check that the decl being shadowed
1199 comes from the parm level, one level up. */
1200 && chain_member (oldlocal
, current_binding_level
->level_chain
->names
))
1202 if (TREE_CODE (oldlocal
) == PARM_DECL
)
1203 pedwarn ("declaration of `%s' shadows a parameter",
1204 IDENTIFIER_POINTER (name
));
1206 pedwarn ("declaration of `%s' shadows a symbol from the parameter list",
1207 IDENTIFIER_POINTER (name
));
1210 /* Maybe warn if shadowing something else. */
1211 else if (warn_shadow
&& !DECL_EXTERNAL (x
)
1212 /* No shadow warnings for internally generated vars. */
1213 && DECL_SOURCE_LINE (x
) != 0
1214 /* No shadow warnings for vars made for inlining. */
1215 && ! DECL_FROM_INLINE (x
))
1217 const char *warnstring
= 0;
1219 if (TREE_CODE (x
) == PARM_DECL
1220 && current_binding_level
->level_chain
->parm_flag
)
1221 /* Don't warn about the parm names in function declarator
1222 within a function declarator.
1223 It would be nice to avoid warning in any function
1224 declarator in a declaration, as opposed to a definition,
1225 but there is no way to tell it's not a definition. */
1227 else if (oldlocal
!= 0 && TREE_CODE (oldlocal
) == PARM_DECL
)
1228 warnstring
= "declaration of `%s' shadows a parameter";
1229 else if (oldlocal
!= 0)
1230 warnstring
= "declaration of `%s' shadows previous local";
1231 else if (IDENTIFIER_GLOBAL_VALUE (name
) != 0
1232 && IDENTIFIER_GLOBAL_VALUE (name
) != error_mark_node
)
1233 warnstring
= "declaration of `%s' shadows global declaration";
1236 warning (warnstring
, IDENTIFIER_POINTER (name
));
1240 /* If storing a local value, there may already be one (inherited).
1241 If so, record it for restoration when this binding level ends. */
1243 b
->shadowed
= tree_cons (name
, oldlocal
, b
->shadowed
);
1247 /* Put decls on list in reverse order.
1248 We will reverse them later if necessary. */
1249 TREE_CHAIN (x
) = b
->names
;
1256 pushdecl_force_head (tree x
)
1258 current_binding_level
->names
= x
;
1261 /* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, if appropriate. */
1264 pushdecl_top_level (tree x
)
1267 struct binding_level
*b
= current_binding_level
;
1269 current_binding_level
= global_binding_level
;
1271 current_binding_level
= b
;
1275 /* Like pushdecl, only it places X in FUNCTION_BINDING_LEVEL, if appropriate. */
1278 pushdecl_function_level (tree x
)
1281 struct binding_level
*b
= current_binding_level
;
1283 current_binding_level
= function_binding_level
;
1285 current_binding_level
= b
;
1289 /* Nonzero if we are currently in the global binding level. */
1292 global_bindings_p (void)
1294 return current_binding_level
== global_binding_level
;
1297 /* Return the list of declarations of the current level.
1298 Note that this list is in reverse order unless/until
1299 you nreverse it; and when you do nreverse it, you must
1300 store the result back using `storedecls' or you will lose. */
1305 return current_binding_level
->names
;
1308 /* Create a new `struct binding_level'. */
1310 static struct binding_level
*
1311 make_binding_level (void)
1314 return ggc_alloc_cleared (sizeof (struct binding_level
));
1318 pushlevel (int unused ATTRIBUTE_UNUSED
)
1320 struct binding_level
*newlevel
= NULL_BINDING_LEVEL
;
1323 /* If this is the top level of a function,
1324 just make sure that NAMED_LABELS is 0. */
1326 if (current_binding_level
== global_binding_level
)
1330 /* Reuse or create a struct for this binding level. */
1332 if (free_binding_level
)
1334 newlevel
= free_binding_level
;
1335 free_binding_level
= free_binding_level
->level_chain
;
1339 newlevel
= make_binding_level ();
1342 /* Add this level to the front of the chain (stack) of levels that
1345 *newlevel
= clear_binding_level
;
1346 newlevel
->level_chain
= current_binding_level
;
1347 current_binding_level
= newlevel
;
1348 #if defined(DEBUG_JAVA_BINDING_LEVELS)
1349 newlevel
->binding_depth
= binding_depth
;
1351 fprintf (stderr
, "push %s level %p pc %d\n",
1352 (is_class_level
) ? "class" : "block", newlevel
, current_pc
);
1355 #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
1358 /* Exit a binding level.
1359 Pop the level off, and restore the state of the identifier-decl mappings
1360 that were in effect when this level was entered.
1362 If KEEP is nonzero, this level had explicit declarations, so
1363 and create a "block" (a BLOCK node) for the level
1364 to record its declarations and subblocks for symbol table output.
1366 If FUNCTIONBODY is nonzero, this level is the body of a function,
1367 so create a block as if KEEP were set and also clear out all
1370 If REVERSE is nonzero, reverse the order of decls before putting
1371 them into the BLOCK. */
1374 poplevel (int keep
, int reverse
, int functionbody
)
1377 /* The chain of decls was accumulated in reverse order.
1378 Put it into forward order, just for cleanliness. */
1380 tree subblocks
= current_binding_level
->blocks
;
1385 #if defined(DEBUG_JAVA_BINDING_LEVELS)
1388 if (current_binding_level
->end_pc
!= LARGEST_PC
)
1389 fprintf (stderr
, "pop %s level %p pc %d (end pc %d)\n",
1390 (is_class_level
) ? "class" : "block", current_binding_level
, current_pc
,
1391 current_binding_level
->end_pc
);
1393 fprintf (stderr
, "pop %s level %p pc %d\n",
1394 (is_class_level
) ? "class" : "block", current_binding_level
, current_pc
);
1396 if (is_class_level
!= (current_binding_level
== class_binding_level
))
1399 fprintf (stderr
, "XXX is_class_level != (current_binding_level == class_binding_level)\n");
1403 #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
1405 /* Get the decls in the order they were written.
1406 Usually current_binding_level->names is in reverse order.
1407 But parameter decls were previously put in forward order. */
1410 current_binding_level
->names
1411 = decls
= nreverse (current_binding_level
->names
);
1413 decls
= current_binding_level
->names
;
1415 for (decl
= decls
; decl
; decl
= TREE_CHAIN (decl
))
1416 if (TREE_CODE (decl
) == VAR_DECL
1417 && DECL_LANG_SPECIFIC (decl
) != NULL
1418 && DECL_LOCAL_SLOT_NUMBER (decl
))
1419 LOCAL_VAR_OUT_OF_SCOPE_P (decl
) = 1;
1421 /* If there were any declarations in that level,
1422 or if this level is a function body,
1423 create a BLOCK to record them for the life of this function. */
1426 if (keep
|| functionbody
)
1428 block
= make_node (BLOCK
);
1429 TREE_TYPE (block
) = void_type_node
;
1432 if (current_binding_level
->exception_range
)
1433 expand_end_java_handler (current_binding_level
->exception_range
);
1437 /* If any statements have been generated at this level, create a
1438 BIND_EXPR to hold them and copy the variables to it. This
1439 only applies to the bytecode compiler. */
1440 if (current_binding_level
->stmts
)
1443 tree
*var
= &BLOCK_VARS (block
);
1445 /* Copy decls from names list, ignoring labels. */
1448 tree next
= TREE_CHAIN (decl
);
1449 if (TREE_CODE (decl
) != LABEL_DECL
)
1452 var
= &TREE_CHAIN (decl
);
1458 bind
= build3 (BIND_EXPR
, TREE_TYPE (block
), BLOCK_VARS (block
),
1459 BLOCK_EXPR_BODY (block
), block
);
1460 BIND_EXPR_BODY (bind
) = current_binding_level
->stmts
;
1462 if (BIND_EXPR_BODY (bind
)
1463 && TREE_SIDE_EFFECTS (BIND_EXPR_BODY (bind
)))
1464 TREE_SIDE_EFFECTS (bind
) = 1;
1466 /* FIXME: gimplifier brain damage. */
1467 if (BIND_EXPR_BODY (bind
) == NULL
)
1468 BIND_EXPR_BODY (bind
) = build_java_empty_stmt ();
1470 current_binding_level
->stmts
= NULL
;
1474 BLOCK_VARS (block
) = decls
;
1476 BLOCK_SUBBLOCKS (block
) = subblocks
;
1479 /* In each subblock, record that this is its superior. */
1481 for (link
= subblocks
; link
; link
= TREE_CHAIN (link
))
1482 BLOCK_SUPERCONTEXT (link
) = block
;
1484 /* Clear out the meanings of the local variables of this level. */
1486 for (link
= decls
; link
; link
= TREE_CHAIN (link
))
1488 tree name
= DECL_NAME (link
);
1489 if (name
!= 0 && IDENTIFIER_LOCAL_VALUE (name
) == link
)
1491 /* If the ident. was used or addressed via a local extern decl,
1492 don't forget that fact. */
1493 if (DECL_EXTERNAL (link
))
1495 if (TREE_USED (link
))
1496 TREE_USED (name
) = 1;
1497 if (TREE_ADDRESSABLE (link
))
1498 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link
)) = 1;
1500 IDENTIFIER_LOCAL_VALUE (name
) = 0;
1504 /* Restore all name-meanings of the outer levels
1505 that were shadowed by this level. */
1507 for (link
= current_binding_level
->shadowed
; link
; link
= TREE_CHAIN (link
))
1508 IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link
)) = TREE_VALUE (link
);
1510 /* If the level being exited is the top level of a function,
1511 check over all the labels, and clear out the current
1512 (function local) meanings of their names. */
1516 /* If this is the top level block of a function,
1517 the vars are the function's parameters.
1518 Don't leave them in the BLOCK because they are
1519 found in the FUNCTION_DECL instead. */
1521 BLOCK_VARS (block
) = 0;
1523 /* Clear out the definitions of all label names,
1524 since their scopes end here,
1525 and add them to BLOCK_VARS. */
1528 for (link
= named_labels
; link
; link
= TREE_CHAIN (link
))
1530 tree label
= TREE_VALUE (link
);
1532 if (DECL_INITIAL (label
) == 0)
1534 error ("%Jlabel '%D' used but not defined", label
, label
);
1535 /* Avoid crashing later. */
1536 define_label (input_location
, DECL_NAME (label
));
1538 else if (warn_unused
[UNUSED_LABEL
] && !TREE_USED (label
))
1539 warning ("%Jlabel '%D' defined but not used", label
, label
);
1540 IDENTIFIER_LABEL_VALUE (DECL_NAME (label
)) = 0;
1542 /* Put the labels into the "variables" of the
1543 top-level block, so debugger can see them. */
1544 TREE_CHAIN (label
) = BLOCK_VARS (block
);
1545 BLOCK_VARS (block
) = label
;
1550 /* Pop the current level, and free the structure for reuse. */
1553 struct binding_level
*level
= current_binding_level
;
1554 current_binding_level
= current_binding_level
->level_chain
;
1556 level
->level_chain
= free_binding_level
;
1557 free_binding_level
= level
;
1560 /* Dispose of the block that we just made inside some higher level. */
1563 DECL_INITIAL (current_function_decl
) = block
;
1564 DECL_SAVED_TREE (current_function_decl
) = bind
;
1570 current_binding_level
->blocks
1571 = chainon (current_binding_level
->blocks
, block
);
1573 /* If we did not make a block for the level just exited,
1574 any blocks made for inner levels
1575 (since they cannot be recorded as subblocks in that level)
1576 must be carried forward so they will later become subblocks
1577 of something else. */
1579 current_binding_level
->blocks
1580 = chainon (current_binding_level
->blocks
, subblocks
);
1583 java_add_stmt (bind
);
1587 TREE_USED (block
) = 1;
1592 maybe_pushlevels (int pc
)
1594 #if defined(DEBUG_JAVA_BINDING_LEVELS)
1598 while (pending_local_decls
!= NULL_TREE
&&
1599 DECL_LOCAL_START_PC (pending_local_decls
) <= pc
)
1601 tree
*ptr
= &pending_local_decls
;
1602 tree decl
= *ptr
, next
;
1603 int end_pc
= DECL_LOCAL_END_PC (decl
);
1605 while (*ptr
!= NULL_TREE
1606 && DECL_LOCAL_START_PC (*ptr
) <= pc
1607 && DECL_LOCAL_END_PC (*ptr
) == end_pc
)
1608 ptr
= &TREE_CHAIN (*ptr
);
1609 pending_local_decls
= *ptr
;
1612 /* Force non-nested range to be nested in current range by
1613 truncating variable lifetimes. */
1614 if (end_pc
> current_binding_level
->end_pc
)
1616 end_pc
= current_binding_level
->end_pc
;
1617 DECL_LOCAL_END_PC (decl
) = end_pc
;
1620 maybe_start_try (pc
, end_pc
);
1624 current_binding_level
->end_pc
= end_pc
;
1625 current_binding_level
->start_pc
= pc
;
1626 current_binding_level
->names
= NULL
;
1627 for ( ; decl
!= NULL_TREE
; decl
= next
)
1629 next
= TREE_CHAIN (decl
);
1630 push_jvm_slot (DECL_LOCAL_SLOT_NUMBER (decl
), decl
);
1632 initialize_local_variable (decl
, DECL_LOCAL_SLOT_NUMBER (decl
));
1636 maybe_start_try (pc
, 0);
1640 maybe_poplevels (int pc
)
1642 #if defined(DEBUG_JAVA_BINDING_LEVELS)
1646 while (current_binding_level
->end_pc
<= pc
)
1650 /* Terminate any binding which began during the range beginning at
1651 start_pc. This tidies up improperly nested local variable ranges
1652 and exception handlers; a variable declared within an exception
1653 range is forcibly terminated when that exception ends. */
1656 force_poplevels (int start_pc
)
1658 while (current_binding_level
->start_pc
> start_pc
)
1660 if (pedantic
&& current_binding_level
->start_pc
> start_pc
)
1661 warning ("%JIn %D: overlapped variable and exception ranges at %d",
1662 current_function_decl
, current_function_decl
,
1663 current_binding_level
->start_pc
);
1668 /* Insert BLOCK at the end of the list of subblocks of the
1669 current binding level. This is used when a BIND_EXPR is expanded,
1670 to handle the BLOCK node inside the BIND_EXPR. */
1673 insert_block (tree block
)
1675 TREE_USED (block
) = 1;
1676 current_binding_level
->blocks
1677 = chainon (current_binding_level
->blocks
, block
);
1680 /* integrate_decl_tree calls this function. */
1683 java_dup_lang_specific_decl (tree node
)
1686 struct lang_decl
*x
;
1688 if (!DECL_LANG_SPECIFIC (node
))
1691 lang_decl_size
= sizeof (struct lang_decl
);
1692 x
= ggc_alloc (lang_decl_size
);
1693 memcpy (x
, DECL_LANG_SPECIFIC (node
), lang_decl_size
);
1694 DECL_LANG_SPECIFIC (node
) = x
;
1698 give_name_to_locals (JCF
*jcf
)
1700 int i
, n
= DECL_LOCALVARIABLES_OFFSET (current_function_decl
);
1701 int code_offset
= DECL_CODE_OFFSET (current_function_decl
);
1703 pending_local_decls
= NULL_TREE
;
1707 n
= JCF_readu2 (jcf
);
1708 for (i
= 0; i
< n
; i
++)
1710 int start_pc
= JCF_readu2 (jcf
);
1711 int length
= JCF_readu2 (jcf
);
1712 int name_index
= JCF_readu2 (jcf
);
1713 int signature_index
= JCF_readu2 (jcf
);
1714 int slot
= JCF_readu2 (jcf
);
1715 tree name
= get_name_constant (jcf
, name_index
);
1716 tree type
= parse_signature (jcf
, signature_index
);
1717 if (slot
< DECL_ARG_SLOT_COUNT (current_function_decl
)
1719 && length
== DECL_CODE_LENGTH (current_function_decl
))
1721 tree decl
= TREE_VEC_ELT (decl_map
, slot
);
1722 DECL_NAME (decl
) = name
;
1723 SET_DECL_ASSEMBLER_NAME (decl
, name
);
1724 if (TREE_CODE (decl
) != PARM_DECL
|| TREE_TYPE (decl
) != type
)
1725 warning ("bad type in parameter debug info");
1730 int end_pc
= start_pc
+ length
;
1731 tree decl
= build_decl (VAR_DECL
, name
, type
);
1732 if (end_pc
> DECL_CODE_LENGTH (current_function_decl
))
1734 warning ("%Jbad PC range for debug info for local '%D'",
1736 end_pc
= DECL_CODE_LENGTH (current_function_decl
);
1739 /* Adjust start_pc if necessary so that the local's first
1740 store operation will use the relevant DECL as a
1741 destination. Fore more information, read the leading
1742 comments for expr.c:maybe_adjust_start_pc. */
1743 start_pc
= maybe_adjust_start_pc (jcf
, code_offset
, start_pc
, slot
);
1745 MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl
);
1746 DECL_LOCAL_SLOT_NUMBER (decl
) = slot
;
1747 DECL_LOCAL_START_PC (decl
) = start_pc
;
1749 /* FIXME: The range used internally for exceptions and local
1750 variable ranges, is a half-open interval:
1751 start_pc <= pc < end_pc. However, the range used in the
1752 Java VM spec is inclusive at both ends:
1753 start_pc <= pc <= end_pc. */
1756 DECL_LOCAL_END_PC (decl
) = end_pc
;
1758 /* Now insert the new decl in the proper place in
1759 pending_local_decls. We are essentially doing an insertion sort,
1760 which works fine, since the list input will normally already
1762 ptr
= &pending_local_decls
;
1763 while (*ptr
!= NULL_TREE
1764 && (DECL_LOCAL_START_PC (*ptr
) > start_pc
1765 || (DECL_LOCAL_START_PC (*ptr
) == start_pc
1766 && DECL_LOCAL_END_PC (*ptr
) < end_pc
)))
1767 ptr
= &TREE_CHAIN (*ptr
);
1768 TREE_CHAIN (decl
) = *ptr
;
1773 pending_local_decls
= nreverse (pending_local_decls
);
1775 /* Fill in default names for the parameters. */
1776 for (parm
= DECL_ARGUMENTS (current_function_decl
), i
= 0;
1777 parm
!= NULL_TREE
; parm
= TREE_CHAIN (parm
), i
++)
1779 if (DECL_NAME (parm
) == NULL_TREE
)
1781 int arg_i
= METHOD_STATIC (current_function_decl
) ? i
+1 : i
;
1783 DECL_NAME (parm
) = get_identifier ("this");
1787 sprintf (buffer
, "ARG_%d", arg_i
);
1788 DECL_NAME (parm
) = get_identifier (buffer
);
1790 SET_DECL_ASSEMBLER_NAME (parm
, DECL_NAME (parm
));
1796 build_result_decl (tree fndecl
)
1798 tree restype
= TREE_TYPE (TREE_TYPE (fndecl
));
1799 tree result
= DECL_RESULT (fndecl
);
1802 /* To be compatible with C_PROMOTING_INTEGER_TYPE_P in cc1/cc1plus. */
1803 if (INTEGRAL_TYPE_P (restype
)
1804 && TYPE_PRECISION (restype
) < TYPE_PRECISION (integer_type_node
))
1805 restype
= integer_type_node
;
1806 result
= build_decl (RESULT_DECL
, NULL_TREE
, restype
);
1807 DECL_ARTIFICIAL (result
) = 1;
1808 DECL_IGNORED_P (result
) = 1;
1809 DECL_CONTEXT (result
) = fndecl
;
1810 DECL_RESULT (fndecl
) = result
;
1816 start_java_method (tree fndecl
)
1823 current_function_decl
= fndecl
;
1824 announce_function (fndecl
);
1826 i
= DECL_MAX_LOCALS(fndecl
) + DECL_MAX_STACK(fndecl
);
1827 decl_map
= make_tree_vec (i
);
1828 base_decl_map
= make_tree_vec (i
);
1829 type_map
= xrealloc (type_map
, i
* sizeof (tree
));
1831 #if defined(DEBUG_JAVA_BINDING_LEVELS)
1832 fprintf (stderr
, "%s:\n", lang_printable_name (fndecl
, 2));
1834 #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */
1835 pushlevel (1); /* Push parameters. */
1837 ptr
= &DECL_ARGUMENTS (fndecl
);
1838 for (tem
= TYPE_ARG_TYPES (TREE_TYPE (fndecl
)), i
= 0;
1839 tem
!= end_params_node
; tem
= TREE_CHAIN (tem
), i
++)
1841 tree parm_name
= NULL_TREE
, parm_decl
;
1842 tree parm_type
= TREE_VALUE (tem
);
1843 if (i
>= DECL_MAX_LOCALS (fndecl
))
1846 parm_decl
= build_decl (PARM_DECL
, parm_name
, parm_type
);
1847 DECL_CONTEXT (parm_decl
) = fndecl
;
1848 if (targetm
.calls
.promote_prototypes (parm_type
)
1849 && TYPE_PRECISION (parm_type
) < TYPE_PRECISION (integer_type_node
)
1850 && INTEGRAL_TYPE_P (parm_type
))
1851 parm_type
= integer_type_node
;
1852 DECL_ARG_TYPE (parm_decl
) = parm_type
;
1855 ptr
= &TREE_CHAIN (parm_decl
);
1857 /* Add parm_decl to the decl_map. */
1858 push_jvm_slot (i
, parm_decl
);
1860 type_map
[i
] = TREE_TYPE (parm_decl
);
1861 if (TYPE_IS_WIDE (TREE_TYPE (parm_decl
)))
1864 type_map
[i
] = void_type_node
;
1868 DECL_ARG_SLOT_COUNT (current_function_decl
) = i
;
1870 while (i
< DECL_MAX_LOCALS(fndecl
))
1871 type_map
[i
++] = NULL_TREE
;
1873 build_result_decl (fndecl
);
1875 /* Push local variables. */
1878 function_binding_level
= current_binding_level
;
1882 end_java_method (void)
1884 tree fndecl
= current_function_decl
;
1886 /* pop out of function */
1889 /* pop out of its parameters */
1892 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl
)) = fndecl
;
1894 flag_unit_at_a_time
= 0;
1895 finish_method (fndecl
);
1897 if (! flag_unit_at_a_time
)
1899 /* Nulling these fields when we no longer need them saves
1901 DECL_SAVED_TREE (fndecl
) = NULL
;
1902 DECL_STRUCT_FUNCTION (fndecl
) = NULL
;
1903 DECL_INITIAL (fndecl
) = NULL_TREE
;
1905 if (! flag_unit_at_a_time
)
1907 /* Nulling these fields when we no longer need them saves
1909 DECL_SAVED_TREE (fndecl
) = NULL
;
1910 DECL_STRUCT_FUNCTION (fndecl
) = NULL
;
1911 DECL_INITIAL (fndecl
) = NULL_TREE
;
1913 current_function_decl
= NULL_TREE
;
1916 /* Prepare a method for expansion. */
1919 finish_method (tree fndecl
)
1921 tree
*tp
= &DECL_SAVED_TREE (fndecl
);
1923 /* Wrap body of synchronized methods in a monitorenter,
1924 plus monitorexit cleanup. */
1925 if (METHOD_SYNCHRONIZED (fndecl
))
1927 tree enter
, exit
, lock
;
1928 if (METHOD_STATIC (fndecl
))
1929 lock
= build_class_ref (DECL_CONTEXT (fndecl
));
1931 lock
= DECL_ARGUMENTS (fndecl
);
1932 BUILD_MONITOR_ENTER (enter
, lock
);
1933 BUILD_MONITOR_EXIT (exit
, lock
);
1934 *tp
= build2 (COMPOUND_EXPR
, void_type_node
, enter
,
1935 build2 (TRY_FINALLY_EXPR
, void_type_node
, *tp
, exit
));
1938 /* Prepend class initialization for static methods reachable from
1940 if (METHOD_STATIC (fndecl
) && ! METHOD_PRIVATE (fndecl
)
1941 && ! DECL_CLINIT_P (fndecl
)
1942 && ! CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (fndecl
))))
1944 tree clas
= DECL_CONTEXT (fndecl
);
1945 tree init
= build3 (CALL_EXPR
, void_type_node
,
1946 build_address_of (soft_initclass_node
),
1947 build_tree_list (NULL_TREE
, build_class_ref (clas
)),
1949 *tp
= build2 (COMPOUND_EXPR
, TREE_TYPE (*tp
), init
, *tp
);
1952 /* Convert function tree to GENERIC prior to inlining. */
1953 java_genericize (fndecl
);
1955 /* Store the end of the function, so that we get good line number
1956 info for the epilogue. */
1957 if (DECL_STRUCT_FUNCTION (fndecl
))
1958 cfun
= DECL_STRUCT_FUNCTION (fndecl
);
1960 allocate_struct_function (fndecl
);
1961 cfun
->function_end_locus
.file
= DECL_SOURCE_FILE (fndecl
);
1962 cfun
->function_end_locus
.line
= DECL_FUNCTION_LAST_LINE (fndecl
);
1964 /* Defer inlining and expansion to the cgraph optimizers. */
1965 cgraph_finalize_function (fndecl
, false);
1968 /* Optimize and expand a function's entire body. */
1971 java_expand_body (tree fndecl
)
1973 tree_rest_of_compilation (fndecl
, 0);
1976 /* We pessimistically marked all methods and fields external until we
1977 knew what set of classes we were planning to compile. Now mark those
1978 associated with CLASS to be generated locally as not external. */
1981 java_mark_decl_local (tree decl
)
1983 DECL_EXTERNAL (decl
) = 0;
1985 /* If we've already constructed DECL_RTL, give encode_section_info
1986 a second chance, now that we've changed the flags. */
1987 if (DECL_RTL_SET_P (decl
))
1988 make_decl_rtl (decl
, NULL
);
1992 java_mark_class_local (tree
class)
1996 for (t
= TYPE_FIELDS (class); t
; t
= TREE_CHAIN (t
))
1997 if (FIELD_STATIC (t
))
1998 java_mark_decl_local (t
);
2000 for (t
= TYPE_METHODS (class); t
; t
= TREE_CHAIN (t
))
2001 if (!METHOD_ABSTRACT (t
) && (!METHOD_NATIVE (t
) || flag_jni
))
2002 java_mark_decl_local (t
);
2005 /* Add a statement to a compound_expr. */
2008 add_stmt_to_compound (tree existing
, tree type
, tree stmt
)
2014 tree expr
= build2 (COMPOUND_EXPR
, type
, existing
, stmt
);
2015 TREE_SIDE_EFFECTS (expr
) = TREE_SIDE_EFFECTS (existing
)
2016 | TREE_SIDE_EFFECTS (stmt
);
2023 /* Add a statement to the compound_expr currently being
2027 java_add_stmt (tree stmt
)
2030 annotate_with_locus (stmt
, input_location
);
2032 return current_binding_level
->stmts
2033 = add_stmt_to_compound (current_binding_level
->stmts
,
2034 TREE_TYPE (stmt
), stmt
);
2037 /* Add a variable to the current scope. */
2040 java_add_local_var (tree decl
)
2042 tree
*vars
= ¤t_binding_level
->names
;
2044 TREE_CHAIN (decl
) = next
;
2046 DECL_CONTEXT (decl
) = current_function_decl
;
2047 MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl
);
2051 /* Return a pointer to the compound_expr currently being
2057 return ¤t_binding_level
->stmts
;
2060 /* Register an exception range as belonging to the current binding
2061 level. There may only be one: if there are more, we'll create more
2062 binding levels. However, each range can have multiple handlers,
2063 and these are expanded when we call expand_end_java_handler(). */
2066 register_exception_range (struct eh_range
*range
, int pc
, int end_pc
)
2068 if (current_binding_level
->exception_range
)
2070 current_binding_level
->exception_range
= range
;
2071 current_binding_level
->end_pc
= end_pc
;
2072 current_binding_level
->start_pc
= pc
;
2075 #include "gt-java-decl.h"