cp-tree.h (cp_tree_index): Remove Java types.

* cp-tree.h (cp_tree_index): Remove Java types.
	(java_fundamental_type_kind): New enumeration type.
	(java_fundamental_types): New array.
	* class.c (push_lang_context): Use java_fundamental_types.
	* decl.c (java_fundamental_types): Define it.
	(initialize_java_fundamental_types): New function.
	(init_decl_processing): Call it
	* mangle.c (integer_type_codes): Make it const.
	(java_fundamental_type_codes): New variable.
	(write_source_name_from_string): New function.
	(write_identifier): Constify.
	(write_builtin_type): Handle Java types.  Use same_type_p for type
	comparison.

From-SVN: r34472
This commit is contained in:
Mark Mitchell 2000-06-09 16:41:10 +00:00 committed by Mark Mitchell
parent 669ec2b4f0
commit 97a6940904
5 changed files with 268 additions and 45 deletions

View File

@ -1,3 +1,19 @@
2000-06-09 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (cp_tree_index): Remove Java types.
(java_fundamental_type_kind): New enumeration type.
(java_fundamental_types): New array.
* class.c (push_lang_context): Use java_fundamental_types.
* decl.c (java_fundamental_types): Define it.
(initialize_java_fundamental_types): New function.
(init_decl_processing): Call it
* mangle.c (integer_type_codes): Make it const.
(java_fundamental_type_codes): New variable.
(write_source_name_from_string): New function.
(write_identifier): Constify.
(write_builtin_type): Handle Java types. Use same_type_p for type
comparison.
2000-06-09 Jason Merrill <jason@casey.soma.redhat.com>
* semantics.c (expand_body): Push to TV_EXPAND.
@ -6,6 +22,137 @@
* tinfo2.cc: Just declare abort.
2000-06-08 Mark Mitchell <mark@codesourcery.com>
Remove old ABI mangling code.
* cp-tree.h (cp_tree_index): Remove CPTI_TINFO_DECL_ID and
CPTI_TINFO_VAR_ID.
(tinfo_decl_id): Remove.
(tinfo_var_id): Likewise.
(name_mangling_version): Likewise.
(flag_do_squangling): Likewise.
(get_vtt_name): Likewise.
(init_method): Likewise.
(build_overload_name): Likewise.
(build_static_name): Likewise.
(build_decl_overload_real): Likewise.
(build_overload_with_type): Likewise.
(build_destructor_name): Likewise.
(get_id_2): Likewise.
(get_ctor_vtbl_name): Likewise.
(mangle_typeinfo_fn_for_type): New function.
(mangle_java_reflection_var_for_type): Likewise.
* call.c (build_new_method_call): Use mangle_vtt_for_type.
* class.c (get_vtable_name): Remove.
(get_vtt_name): Remove.
(get_vtable_decl): Use mangle_vtbl_for_type.
(build_vtt): Likewise.
(build_ctor_vtbl_group): Remove old ABI mangling support.
* decl.c (pushtag): Likewise.
(maybe_commonize_var): Use set_mangled_name_for_decl.
(grokfndecl): Remove old ABI mangling support.
(grokvardecl): Likewise.
(grokdeclarator): Likewise.
(grok_op_properties): Adjust use of DEF_OPERATOR.
* decl2.c (name_mangling_version): Remove.
(lang_f_options): Remove squangle.
(unsupported_options): Add squangle.
(lang_decode_options): Don't set flag_do_squangling. Issue a
warning for -fname-mangling-version.
(grokclassfn): Remove old ABI mangling support.
(finish_static_data_member_decl): Likewise.
(grokfield): Likewise.
(grokoptypename): Likewise.
(get_sentry): Likewise.
* init.c (build_java_class_ref): Use
mangle_java_reflection_var_for_type.
* lex.c (init_operators): Adjust use of DEF_OPERATOR.
(init_parse): Call init_mangle, not init_method.
* mangle.c (write_special_name_constructor): Handle
maybe-in-charge constructors.
(write_special_name_destructor): Handle
maybe-in-charge destructors.
(write_expression): Tweak code to handle non-type template
arguments with reference type.
(mangle_typeinfo_fn_for_type): New function.
(mangle_java_reflection_var_for_type): Likewise.
(mangle_conv_op_name_for_type): Don't use a name that the user
could type.
* method.c (enum mangling_flags): Remove.
(mangling_flags): Likewise.
(obstack_chunk_alloc): Likewise.
(obstack_chunk_free): Likewise.
(OB_INIT): Likewise.
(OB_PUTC): Likewise.
(OB_PUTC2): Likewise.
(OB_PUTS): Likewise.
(OB_PUTID): Likewise.
(OB_PUTCP): Likewise.
(OB_FINISH): Likewise.
(OB_LAST): Likewise.
(btypelist): Likewise.
(ktypelist): Likewise.
(maxbtype): Likewise.
(maxktype): Likewise.
(typevec): Likewise.
(maxtype): Likewise.
(init_method): Likewise.
(digit_buffer): Likewise.
(nofold): Likewise.
(start_squangling): Likewise.
(end_squangling): Likewise.
(icat): Likewise.
(dicat): Likewise.
(old_backref_index): Likewise.
(flush_repeats): Likewise.
(is_back_referenceable_type): Likewise.
(issue_nrepeats): Likewise.
(check_ktype): Likewise.
(issue_ktype): Likewise.
(build_overload_nested_name): Likewise.
(build_underscore_int): Likewise.
(build_overload_scope_ref): Likewise.
(mangle_expression): Likewise.
(build_overload_int): Likewise.
(mangled_C9x_name): Likewise.
(build_overload_value): Likewise.
(build_template_template_parm_names): Likewise.
(build_template_parm_names): Likewise.
(build_overload_identifier): Likewise.
(build_qualified_name): Likewise.
(build_mangled_name_for_type_with_Gcode): Likewise.
(build_mangled_name_for_type): Likewise.
(build_overload_name): Likewise.
(build_mangled_name): Likewise.
(process_modifiers): Likewise.
(check_btype): Likewise.
(process_overload_item): Likewise.
(build_static_name): Likewise.
(build_decl_overload_real): Likewise.
(set_mangled_name_for_decl): Remove old ABI mangling support.
(build_typename_overload): Remove.
(build_overload_with_type): Remove.
(get_id_2): Remove.
(get_ctor_vtbl_name): Remove.
(build_destructor_name): Likewise.
(set_mangled_name_for_decl): Likewise.
(make_thunk): Remove old ABI mangling support.
* operators.def: Likewise.
* pt.c (check_explicit_specialization): Don't call
set_mangled_name_for_template_decl.
(lookup_template_class): Remove old ABI mangling support.
(tsubst_friend_function): Update comment.
(tsubst_decl): Remove old ABI mangling support.
(tsubst_copy): Likewise.
(set_mangled_name_for_template_decl): Remove.
* rtti.c (init_rtti_processing): Use std_identifier. Don't set
tinfo_decl_id or tinfo_var_id.
(get_tinfo_var): Use mangle_typeinfo_for_type.
(tinfo_name): Remove old ABI mangling support.
(get_tinfo_decl): Likewise.
(tinfo_base_init): Likewise.
(create_real_tinfo_var): Use a name that the user can't type.
2000-06-09 Gabriel Dos Reis <gdr@codesourcery.com>
* lex.c (DEF_OPERATOR): Say `operator@' -not- `operator @'

View File

@ -5642,20 +5642,16 @@ push_lang_context (name)
}
else if (name == lang_name_java)
{
java_fundamental_type_kind jtk;
strict_prototype = strict_prototypes_lang_cplusplus;
current_lang_name = name;
/* DECL_IGNORED_P is initially set for these types, to avoid clutter.
(See record_builtin_java_type in decl.c.) However, that causes
incorrect debug entries if these types are actually used.
So we re-enable debug output after extern "Java". */
DECL_IGNORED_P (java_byte_type_node) = 0;
DECL_IGNORED_P (java_short_type_node) = 0;
DECL_IGNORED_P (java_int_type_node) = 0;
DECL_IGNORED_P (java_long_type_node) = 0;
DECL_IGNORED_P (java_float_type_node) = 0;
DECL_IGNORED_P (java_double_type_node) = 0;
DECL_IGNORED_P (java_char_type_node) = 0;
DECL_IGNORED_P (java_boolean_type_node) = 0;
for (jtk = jtk_first; jtk < jtk_last; ++jtk)
DECL_IGNORED_P (java_fundamental_types[jtk]) = 0;
}
else if (name == lang_name_c)
{

View File

@ -516,15 +516,6 @@ extern tree exception_throw_decl;
enum cp_tree_index
{
CPTI_JAVA_BYTE_TYPE,
CPTI_JAVA_SHORT_TYPE,
CPTI_JAVA_INT_TYPE,
CPTI_JAVA_LONG_TYPE,
CPTI_JAVA_FLOAT_TYPE,
CPTI_JAVA_DOUBLE_TYPE,
CPTI_JAVA_CHAR_TYPE,
CPTI_JAVA_BOOLEAN_TYPE,
CPTI_VOID_ZERO,
CPTI_WCHAR_DECL,
CPTI_VTABLE_ENTRY_TYPE,
@ -608,15 +599,6 @@ enum cp_tree_index
extern tree cp_global_trees[CPTI_MAX];
#define java_byte_type_node cp_global_trees[CPTI_JAVA_BYTE_TYPE]
#define java_short_type_node cp_global_trees[CPTI_JAVA_SHORT_TYPE]
#define java_int_type_node cp_global_trees[CPTI_JAVA_INT_TYPE]
#define java_long_type_node cp_global_trees[CPTI_JAVA_LONG_TYPE]
#define java_float_type_node cp_global_trees[CPTI_JAVA_FLOAT_TYPE]
#define java_double_type_node cp_global_trees[CPTI_JAVA_DOUBLE_TYPE]
#define java_char_type_node cp_global_trees[CPTI_JAVA_CHAR_TYPE]
#define java_boolean_type_node cp_global_trees[CPTI_JAVA_BOOLEAN_TYPE]
#define void_zero_node cp_global_trees[CPTI_VOID_ZERO]
#define wchar_decl_node cp_global_trees[CPTI_WCHAR_DECL]
#define vtable_entry_type cp_global_trees[CPTI_VTABLE_ENTRY_TYPE]
@ -746,6 +728,26 @@ extern tree cp_global_trees[CPTI_MAX];
destructors. */
#define vtt_parm_type cp_global_trees[CPTI_VTT_PARM_TYPE]
/* The various kinds of fundamental Java types. */
typedef enum java_fundamental_type_kind
{
jtk_first, /* Must be first. */
jtk_byte = jtk_first,
jtk_short,
jtk_int,
jtk_long,
jtk_float,
jtk_double,
jtk_char,
jtk_boolean,
jtk_last /* Must be last */
} java_fundamental_type_kind;
/* The fundamental Java types. */
extern tree java_fundamental_types[jtk_last];
/* Global state. */
struct stmt_tree {

View File

@ -186,6 +186,7 @@ static tree start_cleanup_fn PARAMS ((void));
static void end_cleanup_fn PARAMS ((void));
static tree cp_make_fname_decl PARAMS ((tree, const char *, int));
static void initialize_predefined_identifiers PARAMS ((void));
static void initialize_java_fundamental_types PARAMS ((void));
static tree check_special_function_return_type
PARAMS ((special_function_kind, tree, tree, tree));
static tree push_cp_library_fn PARAMS ((enum tree_code, tree));
@ -261,6 +262,10 @@ tree error_mark_list;
tree cp_global_trees[CPTI_MAX];
/* The fundamental Java types. */
tree java_fundamental_types[jtk_last];
/* Indicates that there is a type value in some namespace, although
that is not necessarily in scope at the moment. */
@ -6142,9 +6147,9 @@ record_builtin_type (rid_index, name, type)
}
/* Record one of the standard Java types.
* Declare it as having the given NAME.
* If SIZE > 0, it is the size of one of the integral types;
* otherwise it is the negative of the size of one of the other types. */
Declare it as having the given NAME.
If SIZE > 0, it is the size of one of the integral types;
otherwise it is the negative of the size of one of the other types. */
static tree
record_builtin_java_type (name, size)
@ -6248,6 +6253,38 @@ initialize_predefined_identifiers ()
}
}
/* Create nodes representing the fundamental Java types. */
static void
initialize_java_fundamental_types ()
{
typedef struct jft_info
{
/* The name of the type. */
const char *name;
/* The number of bits in the type. */
int size;
} jft_info;
static jft_info jft_infos[jtk_last] = {
{ "__java_byte", 8 },
{ "__java_short", 16 },
{ "__java_int", 32 },
{ "__java_long", 64 },
{ "__java_float", -32 },
{ "__java_double", -64 },
{ "__java_char", -16 },
{ "__java_boolean", -1 }
};
java_fundamental_type_kind jtk;
for (jtk = jtk_first; jtk < jtk_last; ++jtk)
java_fundamental_types[jtk]
= record_builtin_java_type (jft_infos[jtk].name,
jft_infos[jtk].size);
}
/* Create the predefined scalar types of C,
and some nodes representing standard constants (0, 1, (void *)0).
Initialize the global binding level.
@ -6397,14 +6434,7 @@ init_decl_processing ()
build_common_tree_nodes_2 (flag_short_double);
java_byte_type_node = record_builtin_java_type ("__java_byte", 8);
java_short_type_node = record_builtin_java_type ("__java_short", 16);
java_int_type_node = record_builtin_java_type ("__java_int", 32);
java_long_type_node = record_builtin_java_type ("__java_long", 64);
java_float_type_node = record_builtin_java_type ("__java_float", -32);
java_double_type_node = record_builtin_java_type ("__java_double", -64);
java_char_type_node = record_builtin_java_type ("__java_char", -16);
java_boolean_type_node = record_builtin_java_type ("__java_boolean", -1);
initialize_java_fundamental_types ();
integer_two_node = build_int_2 (2, 0);
TREE_TYPE (integer_two_node) = integer_type_node;
@ -6656,6 +6686,8 @@ init_decl_processing ()
/* Add GC roots for all of our global variables. */
ggc_add_tree_root (c_global_trees, sizeof c_global_trees / sizeof(tree));
ggc_add_tree_root (cp_global_trees, sizeof cp_global_trees / sizeof(tree));
ggc_add_tree_root (java_fundamental_types,
sizeof (java_fundamental_types) / sizeof (tree));
ggc_add_tree_root (&integer_three_node, 1);
ggc_add_tree_root (&integer_two_node, 1);
ggc_add_tree_root (&signed_size_zero_node, 1);

View File

@ -120,7 +120,7 @@ static tree subst_identifiers[SUBID_MAX];
/* Single-letter codes for builtin integer types, defined in
<builtin-type>. These are indexed by integer_type_kind values. */
static char
static const char
integer_type_codes[itk_none] =
{
'c', /* itk_char */
@ -136,6 +136,21 @@ integer_type_codes[itk_none] =
'y' /* itk_unsigned_long_long */
};
/* Manglings for the various builtin Java types. */
static const char *
java_fundamental_type_codes[jtk_last] =
{
"jb", /* jtk_byte */
"js", /* jtk_short */
"ji", /* jtk_int */
"jl", /* jtk_long */
"jf", /* jtk_float */
"jd", /* jtk_double */
"jc", /* jtk_char */
"jt" /* jtk_boolean */
};
/* Functions for handling substitutions. */
static inline tree canonicalize_for_substitution PARAMS ((tree));
@ -156,10 +171,11 @@ static void write_prefix PARAMS ((tree));
static void write_template_prefix PARAMS ((tree));
static void write_component PARAMS ((tree));
static void write_unqualified_name PARAMS ((tree));
static void write_source_name_from_string PARAMS ((const char *));
static void write_source_name PARAMS ((tree));
static void write_number PARAMS ((int, int));
static void write_integer_cst PARAMS ((tree));
static void write_identifier PARAMS ((char *));
static void write_identifier PARAMS ((const char *));
static void write_special_name_constructor PARAMS ((tree));
static void write_special_name_destructor PARAMS ((tree));
static void write_type PARAMS ((tree));
@ -898,6 +914,18 @@ write_unqualified_name (decl)
write_source_name (DECL_NAME (decl));
}
/* Non-termial <source-name>. NAME is a NTBS.
<source-name> ::= </length/ number> <identifier> */
static void
write_source_name_from_string (name)
const char *name;
{
write_number (strlen (name), 10);
write_identifier (name);
}
/* Non-termial <source-name>. IDENTIFIER is an IDENTIFIER_NODE.
<source-name> ::= </length/ number> <identifier> */
@ -969,7 +997,7 @@ write_integer_cst (cst)
static void
write_identifier (identifier)
char *identifier;
const char *identifier;
{
MANGLE_TRACE ("identifier", identifier);
write_string (identifier);
@ -1307,6 +1335,24 @@ static void
write_builtin_type (type)
tree type;
{
/* If this is a Java type, mangle it specially, as a vendor
extension. */
if (TYPE_FOR_JAVA (type))
{
java_fundamental_type_kind jtk;
for (jtk = jtk_first; jtk < jtk_last; ++jtk)
if (same_type_p (type, java_fundamental_types[jtk]))
{
/* The `u' indicates a vendor extension. */
write_char ('u');
write_source_name_from_string (java_fundamental_type_codes[jtk]);
return;
}
my_friendly_abort (20000609);
}
switch (TREE_CODE (type))
{
case VOID_TYPE:
@ -1324,7 +1370,7 @@ write_builtin_type (type)
/* TYPE may still be wchar_t, since that isn't in
integer_type_nodes. */
if (type == wchar_type_node)
if (same_type_p (type, wchar_type_node))
write_char ('w');
else
{
@ -1332,7 +1378,7 @@ write_builtin_type (type)
/* Assume TYPE is one of the shared integer type nodes. Find
it in the array of these nodes. */
for (itk = 0; itk < itk_none; ++itk)
if (type == integer_types[itk])
if (same_type_p (type, integer_types[itk]))
{
/* Print the corresponding single-letter code. */
write_char (integer_type_codes[itk]);
@ -1346,11 +1392,11 @@ write_builtin_type (type)
break;
case REAL_TYPE:
if (type == float_type_node)
if (same_type_p (type, float_type_node))
write_char ('f');
else if (type == double_type_node)
else if (same_type_p (type, double_type_node))
write_char ('d');
else if (type == long_double_type_node)
else if (same_type_p (type, long_double_type_node))
write_char ('e');
else
my_friendly_abort (20000409);