/* Definitions for parsing and type checking for the GNU compiler for
the Java(TM) language.
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
This file is part of GCC.
#include "hashtab.h"
-/* Java language-specific tree codes. */
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
-enum java_tree_code {
- __DUMMY = LAST_AND_UNUSED_TREE_CODE,
-#include "java-tree.def"
- LAST_JAVA_TREE_CODE
-};
-#undef DEFTREECODE
-
struct JCF;
/* Usage of TREE_LANG_FLAG_?:
#define output_class \
java_global_trees[JTI_OUTPUT_CLASS]
-/* List of all class DECLs seen so far. */
-#define all_class_list \
- java_global_trees[JTI_ALL_CLASS_LIST]
-
/* List of virtual decls referred to by this translation unit, used to
generate virtual method offset symbol table. */
/* When nonzero, call a library routine to do integer divisions. */
extern int flag_use_divide_subroutine;
+/* When nonzero, use atomic builtins. */
+extern int flag_use_atomic_builtins;
+
/* When nonzero, generate code for the Boehm GC. */
extern int flag_use_boehm_gc;
JTI_MAIN_CLASS,
JTI_CURRENT_CLASS,
JTI_OUTPUT_CLASS,
- JTI_ALL_CLASS_LIST,
-
- JTI_PREDEF_FILENAMES,
JTI_MAX
};
#define nativecode_ptr_array_type_node \
java_global_trees[JTI_NATIVECODE_PTR_ARRAY_TYPE_NODE]
-#define predef_filenames \
- java_global_trees[JTI_PREDEF_FILENAMES]
-
#define nativecode_ptr_type_node ptr_type_node
/* The decl for "_Jv_ResolvePoolEntry". */
extern GTY(()) tree soft_resolvepoolentry_node;
-struct lang_identifier GTY(())
-{
+struct GTY(()) lang_identifier {
struct tree_identifier ignore;
tree global_value;
tree local_value;
};
/* The resulting tree type. */
-union lang_tree_node
- GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
- chain_next ("(union lang_tree_node *)GENERIC_NEXT (&%h.generic)")))
-
-{
+union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
+ chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
+
+ lang_tree_node {
union tree_node GTY ((tag ("0"),
desc ("tree_node_structure (&%h)")))
generic;
/* List of checked thrown exceptions, as specified with the `throws'
keyword */
#define DECL_FUNCTION_THROWS(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.throws_list)
+/* VAR_DECL containing the caught exception object. */
+#define DECL_FUNCTION_EXC_OBJ(DECL) (DECL_LANG_SPECIFIC(DECL)->u.f.exc_obj)
/* For each function decl, init_test_table contains a hash table whose
entries are keyed on class names, and whose values are local
boolean decls. The variables are intended to be TRUE when the
(DECL_LANG_SPECIFIC (NODE)->u.v.vtable)
/* Create a DECL_LANG_SPECIFIC if necessary. */
-#define MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC(T) \
- if (DECL_LANG_SPECIFIC (T) == NULL) \
- { \
- DECL_LANG_SPECIFIC ((T)) \
- = ggc_alloc_cleared (sizeof (struct lang_decl)); \
- DECL_LANG_SPECIFIC (T)->desc = LANG_DECL_VAR; \
+#define MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC(T) \
+ if (DECL_LANG_SPECIFIC (T) == NULL) \
+ { \
+ DECL_LANG_SPECIFIC ((T)) \
+ = ggc_alloc_cleared_lang_decl (sizeof (struct lang_decl)); \
+ DECL_LANG_SPECIFIC (T)->desc = LANG_DECL_VAR; \
}
/* A ConstantExpression, after folding and name resolution. */
|| TREE_CODE (NODE) == REAL_CST)
/* DECL_LANG_SPECIFIC for FUNCTION_DECLs. */
-struct lang_decl_func GTY(())
-{
+struct GTY(()) lang_decl_func {
/* tree chain; not yet used. */
long code_offset;
int code_length;
int max_locals;
int max_stack;
int arg_slot_count;
- /* A temporary lie for the sake of ggc. Actually, last_line is
- only a source_location if USE_MAPPED_LOCATION. FIXME. */
source_location last_line; /* End line number for a function decl */
- tree throws_list; /* Exception specified by `throws' */
+ VEC(tree,gc) *throws_list; /* Exception specified by `throws' */
+ tree exc_obj; /* Decl holding the exception object. */
/* Class initialization test variables */
htab_t GTY ((param_is (struct treetreehash_entry))) init_test_table;
unsigned int varargs : 1; /* Varargs method. */
};
-struct treetreehash_entry GTY(())
-{
+struct GTY(()) treetreehash_entry {
tree key;
tree value;
};
JV_ANNOTATION_DEFAULT_KIND
} jv_attr_kind;
-typedef struct type_assertion GTY(())
-{
+typedef struct GTY(()) type_assertion {
int assertion_code; /* 'opcode' for the type of this assertion. */
tree op1; /* First operand. */
tree op2; /* Second operand. */
extern tree java_treetreehash_find (htab_t, tree);
extern tree * java_treetreehash_new (htab_t, tree);
-extern htab_t java_treetreehash_create (size_t size, int ggc);
+extern htab_t java_treetreehash_create (size_t size);
/* DECL_LANG_SPECIFIC for VAR_DECL, PARM_DECL and sometimes FIELD_DECL
(access methods on outer class fields) and final fields. */
-struct lang_decl_var GTY(())
-{
+struct GTY(()) lang_decl_var {
int slot_number;
int start_pc;
int end_pc;
enum lang_decl_desc {LANG_DECL_FUNC, LANG_DECL_VAR};
-struct lang_decl GTY(())
-{
+struct GTY((variable_size)) lang_decl {
enum lang_decl_desc desc;
union lang_decl_u
{
#define MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC(T) \
if (TYPE_LANG_SPECIFIC ((T)) == NULL) \
TYPE_LANG_SPECIFIC ((T)) \
- = ggc_alloc_cleared (sizeof (struct lang_type));
+ = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
#define TYPE_DUMMY(T) (TYPE_LANG_SPECIFIC(T)->dummy_class)
#define TYPE_REFLECTION_DATASIZE(T) \
(TYPE_LANG_SPECIFIC (T)->reflection_datasize)
-struct lang_type GTY(())
-{
+typedef struct GTY(()) method_entry_d {
+ tree method;
+ tree special;
+} method_entry;
+
+DEF_VEC_O(method_entry);
+DEF_VEC_ALLOC_O(method_entry,gc);
+
+/* FIXME: the variable_size annotation here is needed because these types are
+ variable-sized in some other frontends. Due to gengtype deficiency the GTY
+ options of such types have to agree across all frontends. */
+struct GTY((variable_size)) lang_type {
tree signature;
struct JCF *jcf;
struct CPool *cpool;
tree cpool_data_ref; /* Cached */
tree package_list; /* List of package names, progressive */
- tree otable_methods; /* List of static decls referred to by this
- class. */
+ VEC(method_entry,gc) *otable_methods; /* List of static decls referred
+ to by this class. */
tree otable_decl; /* The static address table. */
tree otable_syms_decl;
- tree atable_methods; /* List of static decls referred to by this
- class. */
+ VEC(method_entry,gc) *atable_methods; /* List of abstract methods
+ referred to by this class. */
tree atable_decl; /* The static address table. */
tree atable_syms_decl;
- tree itable_methods; /* List of interfaces methods referred
- to by this class. */
+ VEC(method_entry,gc) *itable_methods; /* List of interface methods
+ referred to by this class. */
tree itable_decl; /* The interfaces table. */
tree itable_syms_decl;
tree ctable_decl; /* The table of classes for the runtime
type matcher. */
- tree catch_classes;
+ VEC(constructor_elt,gc) *catch_classes;
htab_t GTY ((param_is (struct treetreehash_entry))) type_to_runtime_map;
/* The mapping of classes to exception region
struct eh_range;
extern void java_parse_file (int);
-extern bool java_mark_addressable (tree);
extern tree java_type_for_mode (enum machine_mode, int);
extern tree java_type_for_size (unsigned int, int);
extern tree java_truthvalue_conversion (tree);
extern tree getdecls (void);
extern void pushlevel (int);
extern tree poplevel (int,int, int);
-extern void insert_block (tree);
extern tree pushdecl (tree);
extern void java_init_decl_processing (void);
extern void java_dup_lang_specific_decl (tree);
extern tree lookup_name (tree);
extern bool special_method_p (tree);
-extern void maybe_rewrite_invocation (tree *, tree *, tree *, tree *);
-extern tree build_known_method_ref (tree, tree, tree, tree, tree, tree);
+extern void maybe_rewrite_invocation (tree *, VEC(tree,gc) **, tree *, tree *);
+extern tree build_known_method_ref (tree, tree, tree, tree, VEC(tree,gc) *, tree);
extern tree build_class_init (tree, tree);
extern int attach_init_test_initialization_flags (void **, void *);
extern tree build_invokevirtual (tree, tree, tree);
extern tree build_invokeinterface (tree, tree);
extern tree build_jni_stub (tree);
-extern tree invoke_build_dtable (int, tree);
+extern tree invoke_build_dtable (int, VEC(tree,gc) *);
extern tree build_field_ref (tree, tree, tree);
extern tree java_modify_addr_for_volatile (tree);
extern void pushdecl_force_head (tree);
extern int alloc_name_constant (int, tree);
extern int alloc_constant_fieldref (tree, tree);
extern void emit_register_classes (tree *);
-extern tree emit_symbol_table (tree, tree, tree, tree, tree, int);
+extern tree emit_symbol_table (tree, tree, VEC(method_entry,gc) *,
+ tree, tree, int);
extern void lang_init_source (int);
extern void write_classfile (tree);
extern char *print_int_node (tree);
extern tree pushdecl_top_level (tree);
extern tree pushdecl_function_level (tree);
-extern tree java_replace_reference (tree, bool);
+extern tree java_replace_references (tree *, int *, void *);
extern int alloc_class_constant (tree);
extern void init_expr_processing (void);
extern void push_super_field (tree, tree);
extern void finish_method (tree);
extern void java_expand_body (tree);
-extern int get_symbol_table_index (tree, tree, tree *);
+extern int get_symbol_table_index (tree, tree, VEC(method_entry,gc) **);
extern tree make_catch_class_record (tree, tree);
extern tree emit_catch_table (tree);
extern void rewrite_reflection_indexes (void *);
+int cxx_keyword_p (const char *name, int length);
+
+extern GTY(()) VEC(tree,gc) *pending_static_fields;
+
+extern void java_write_globals (void);
+
#define DECL_FINAL(DECL) DECL_LANG_FLAG_3 (DECL)
/* Access flags etc for a method (a FUNCTION_DECL): */
#define DECL_INNER_CLASS_LIST(NODE) DECL_INITIAL (TYPE_DECL_CHECK (NODE))
/* Add a FIELD_DECL to RECORD_TYPE RTYPE.
- The field has name NAME (a char*), and type FTYPE.
+ The field has name NAME (a char*), a type FTYPE, and a location of LOC.
Unless this is the first field, FIELD most hold the previous field.
FIELD is set to the newly created FIELD_DECL.
We set DECL_ARTIFICIAL so these fields get skipped by make_class_data
if compiling java.lang.Object or java.lang.Class. */
-#define PUSH_FIELD(RTYPE, FIELD, NAME, FTYPE) \
-{ tree _field = build_decl (FIELD_DECL, get_identifier ((NAME)), (FTYPE)); \
+#define PUSH_FIELD(LOC, RTYPE, FIELD, NAME, FTYPE) \
+{ tree _field = build_decl (LOC, FIELD_DECL, get_identifier ((NAME)), (FTYPE)); \
if (TYPE_FIELDS (RTYPE) == NULL_TREE) \
TYPE_FIELDS (RTYPE) = _field; \
else \
- TREE_CHAIN(FIELD) = _field; \
+ DECL_CHAIN(FIELD) = _field; \
DECL_CONTEXT (_field) = (RTYPE); \
DECL_ARTIFICIAL (_field) = 1; \
FIELD = _field; }
#define FINISH_RECORD(RTYPE) layout_type (RTYPE)
-/* Start building a RECORD_TYPE constructor with a given TYPE in CONS. */
-#define START_RECORD_CONSTRUCTOR(CONS, CTYPE) \
+/* Start building a RECORD_TYPE constructor's elements in V. The
+ constructor will have type CTYPE. */
+#define START_RECORD_CONSTRUCTOR(V, CTYPE) \
do \
{ \
- CONS = build_constructor ((CTYPE), VEC_alloc (constructor_elt, gc, 0)); \
- CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (CONS), TYPE_FIELDS (CTYPE), \
- NULL); \
+ V = VEC_alloc (constructor_elt, gc, 0); \
+ CONSTRUCTOR_APPEND_ELT (V, TYPE_FIELDS (CTYPE), NULL); \
} \
while (0)
-/* Append a field initializer to CONS for the dummy field for the inherited
+/* Append a field initializer to V for the dummy field for the inherited
fields. The dummy field has the given VALUE, and the same type as the
super-class. Must be specified before calls to PUSH_FIELD_VALUE. */
-#define PUSH_SUPER_VALUE(CONS, VALUE) \
+#define PUSH_SUPER_VALUE(V, VALUE) \
do \
{ \
- constructor_elt *_elt___ = VEC_last (constructor_elt, \
- CONSTRUCTOR_ELTS (CONS)); \
- tree _next___ = TREE_CHAIN (_elt___->index); \
+ constructor_elt *_elt___ = VEC_last (constructor_elt, V); \
+ tree _next___ = DECL_CHAIN (_elt___->index); \
gcc_assert (!DECL_NAME (_elt___->index)); \
_elt___->value = VALUE; \
- CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (CONS), _next___, NULL); \
+ CONSTRUCTOR_APPEND_ELT (V, _next___, NULL); \
} \
while (0)
-/* Append a field initializer to CONS for a field with the given VALUE.
+/* Append a field initializer to V for a field with the given VALUE.
NAME is a char* string used for error checking;
the initializer must be specified in order. */
-#define PUSH_FIELD_VALUE(CONS, NAME, VALUE) \
+#define PUSH_FIELD_VALUE(V, NAME, VALUE) \
do \
{ \
- constructor_elt *_elt___ = VEC_last (constructor_elt, \
- CONSTRUCTOR_ELTS (CONS)); \
- tree _next___ = TREE_CHAIN (_elt___->index); \
+ constructor_elt *_elt___ = VEC_last (constructor_elt, V); \
+ tree _next___ = DECL_CHAIN (_elt___->index); \
gcc_assert (strcmp (IDENTIFIER_POINTER (DECL_NAME (_elt___->index)), \
NAME) == 0); \
_elt___->value = VALUE; \
- CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (CONS), _next___, NULL); \
+ CONSTRUCTOR_APPEND_ELT (V, _next___, NULL); \
} \
while (0)
-/* Finish creating a record CONSTRUCTOR CONS. */
-#define FINISH_RECORD_CONSTRUCTOR(CONS) \
- VEC_pop (constructor_elt, CONSTRUCTOR_ELTS (CONS))
+/* Finish creating a record CONSTRUCTOR CONS with type CTYPE and elements V. */
+#define FINISH_RECORD_CONSTRUCTOR(CONS, V, CTYPE) \
+ do \
+ { \
+ VEC_pop (constructor_elt, V); \
+ CONS = build_constructor (CTYPE, V); \
+ TREE_CONSTANT (CONS) = 0; \
+ } \
+ while (0)
#define BLOCK_EXPR_DECLS(NODE) BLOCK_VARS(NODE)
#define BLOCK_EXPR_BODY(NODE) BLOCK_SUBBLOCKS(NODE)
#undef DEBUG_JAVA_BINDING_LEVELS
extern void java_genericize (tree);
-extern int java_gimplify_expr (tree *, tree *, tree *);
+extern int java_gimplify_expr (tree *, gimple_seq *, gimple_seq *);
extern FILE *finput;