Commit dc08e603 by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

All files with updated copyright when applicable.

2001-01-07  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	All files with updated copyright when applicable.
	* Make-lang.in (JVGENMAIN_OBS): Removed java/mangle.o.
	* class.c (mangle_class_field): Function removed.
	(append_gpp_mangled_type, mangle_static_field, mangle_field): Likewise.
	(utf8_cmp, cxx_keyword_p): Moved to lex.c.
	(build_class_ref): Call `java_mangle_class_field' instead of
	`mangle_class_field.'
	(build_dtable_decl): Rewritten to call `java_mangle_vtable.'
	(layout_class): Call `java_mangle_decl' instead of
	`mangle_static_field.'
	(cxx_keywords): Initialized static array moved to `lex.c.'
	(layout_class_method): Changed leading comment. Simplified to
	call `java_mangle_decl.' Local `ptr' moved in for loop body.
	* decl.c (lang_mark_tree): Mark field `package_list.'
	* java-tree.h (TYPE_PACKAGE_LIST): New macro.
	(struct lang_type): New field `package_list.'
	(unicode_mangling_length): Prototype removed.
	(append_gpp_mangled_name, append_gpp_mangled_classtype,
	emit_unicode_mangled_name): Likewise.
	(cxx_keyword_p): New prototype.
	(java_mangle_decl, java_mangle_class_field,
	java_mangle_class_field_from_string, java_mangle_vtable): Likewise.
	* jcf-parse.c (jcf_parse_source): Constify `file' argument to
	`build_expr_wfl.'
	* jvgenmain.c (main_method_prefix): Global variable removed.
	(main_method_suffix): Likewise.
	(do_mangle_classname): New function.
	(main): Call it. Format changed to accomodate new mangling scheme.
	* lex.c: (utf8_cmp): Conditionally prototyped.
	(cxx_keywords): Moved from class.c, conditionally defined.
	(utf8_cmp, cxx_keyword_p): Likewise.
	* mangle.c (obstack.h, ggc.h): Included.
	(mangle_field_decl): New function.
	(mangle_method_decl, mangle_type, mangle_pointer_type,
	mangle_array_type, mangle_record_type,
	find_compression_pointer_match, find_compression_array_match,
	find_compression_record_match,
	find_compression_array_template_match, set_type_package_list,
	entry_match_pointer_p, emit_compression_string, init_mangling,
	finish_mangling, compression_table_add, mangle_member_name): Likewise.
	(mangle_obstack): New global.
	(MANGLE_RAW_STRING): New macro.
	(unicode_mangling_length): Turned static.
	(append_unicode_mangled_name): Renamed from
	`emit_unicode_mangled_name.'  Turned static. `mangle_obstack'
	replaces `obstack', removed from the parameter list.
	(append_gpp_mangled_name): Turned static. `mangle_obstack'
	replaces parameter `obstack', removed from the parameter list. Call
	`append_unicode_mangled_name' instead of `emit_unicode_mangled_name.
	(append_gpp_mangled_classtype): Removed.
	(compression_table, compression_next): New static variables.
	* parse.y (temporary_obstack): Extern declaration removed.

(This is the new C++ ABI compatibility patch:
  http://gcc.gnu.org/ml/gcc-patches/2001-01/msg01225.html)

From-SVN: r39031
parent b9333bff
......@@ -70,6 +70,61 @@
(not_accessible_p): Grant `private' access from within
enclosing contexts.
2001-01-07 Alexandre Petit-Bianco <apbianco@cygnus.com>
All files with updated copyright when applicable.
* Make-lang.in (JVGENMAIN_OBS): Removed java/mangle.o.
* class.c (mangle_class_field): Function removed.
(append_gpp_mangled_type, mangle_static_field, mangle_field): Likewise.
(utf8_cmp, cxx_keyword_p): Moved to lex.c.
(build_class_ref): Call `java_mangle_class_field' instead of
`mangle_class_field.'
(build_dtable_decl): Rewritten to call `java_mangle_vtable.'
(layout_class): Call `java_mangle_decl' instead of
`mangle_static_field.'
(cxx_keywords): Initialized static array moved to `lex.c.'
(layout_class_method): Changed leading comment. Simplified to
call `java_mangle_decl.' Local `ptr' moved in for loop body.
* decl.c (lang_mark_tree): Mark field `package_list.'
* java-tree.h (TYPE_PACKAGE_LIST): New macro.
(struct lang_type): New field `package_list.'
(unicode_mangling_length): Prototype removed.
(append_gpp_mangled_name, append_gpp_mangled_classtype,
emit_unicode_mangled_name): Likewise.
(cxx_keyword_p): New prototype.
(java_mangle_decl, java_mangle_class_field,
java_mangle_class_field_from_string, java_mangle_vtable): Likewise.
* jcf-parse.c (jcf_parse_source): Constify `file' argument to
`build_expr_wfl.'
* jvgenmain.c (main_method_prefix): Global variable removed.
(main_method_suffix): Likewise.
(do_mangle_classname): New function.
(main): Call it. Format changed to accomodate new mangling scheme.
* lex.c: (utf8_cmp): Conditionally prototyped.
(cxx_keywords): Moved from class.c, conditionally defined.
(utf8_cmp, cxx_keyword_p): Likewise.
* mangle.c (obstack.h, ggc.h): Included.
(mangle_field_decl): New function.
(mangle_method_decl, mangle_type, mangle_pointer_type,
mangle_array_type, mangle_record_type,
find_compression_pointer_match, find_compression_array_match,
find_compression_record_match,
find_compression_array_template_match, set_type_package_list,
entry_match_pointer_p, emit_compression_string, init_mangling,
finish_mangling, compression_table_add, mangle_member_name): Likewise.
(mangle_obstack): New global.
(MANGLE_RAW_STRING): New macro.
(unicode_mangling_length): Turned static.
(append_unicode_mangled_name): Renamed from
`emit_unicode_mangled_name.' Turned static. `mangle_obstack'
replaces `obstack', removed from the parameter list.
(append_gpp_mangled_name): Turned static. `mangle_obstack'
replaces parameter `obstack', removed from the parameter list. Call
`append_unicode_mangled_name' instead of `emit_unicode_mangled_name.
(append_gpp_mangled_classtype): Removed.
(compression_table, compression_next): New static variables.
* parse.y (temporary_obstack): Extern declaration removed.
2001-01-05 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (patch_binop): Compute missing type in error situations.
......
# Top level makefile fragment for the GNU compiler for the Java(TM)
# language.
# Copyright (C) 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
# Copyright (C) 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
#This file is part of GNU CC.
......@@ -111,7 +111,7 @@ JVSCAN_OBJS = java/parse-scan.o java/jv-scan.o version.o
JCFDUMP_OBJS = java/jcf-dump.o java/jcf-io.o java/jcf-depend.o java/jcf-path.o \
java/zextract.o errors.o version.o mkdeps.o
JVGENMAIN_OBJS = java/jvgenmain.o java/mangle.o
JVGENMAIN_OBJS = java/jvgenmain.o
# Use loose warnings for this front end.
java-warn =
......
......@@ -1939,6 +1939,7 @@ lang_mark_tree (t)
ggc_mark_tree (lt->clinit_stmt_list);
ggc_mark_tree (lt->ii_block);
ggc_mark_tree (lt->dot_class);
ggc_mark_tree (lt->package_list);
}
}
}
/* Definitions for parsing and type checking for the GNU compiler for
the Java(TM) language.
Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
......@@ -892,6 +892,7 @@ struct lang_decl_var
/* The decl of the synthetic method `class$' used to handle `.class'
for non primitive types when compiling to bytecode. */
#define TYPE_DOT_CLASS(T) (TYPE_LANG_SPECIFIC(T)->dot_class)
#define TYPE_PACKAGE_LIST(T) (TYPE_LANG_SPECIFIC(T)->package_list)
#define TYPE_PRIVATE_INNER_CLASS(T) (TYPE_LANG_SPECIFIC(T)->pic)
#define TYPE_PROTECTED_INNER_CLASS(T) (TYPE_LANG_SPECIFIC(T)->poic)
#define TYPE_HAS_FINAL_VARIABLE(T) (TYPE_LANG_SPECIFIC(T)->afv)
......@@ -909,6 +910,7 @@ struct lang_type
needs to be invoked and generated when
compiling to bytecode to implement
<non_primitive_type>.class */
tree package_list; /* List of package names, progressive */
unsigned pic:1; /* Private Inner Class. */
unsigned poic:1; /* Protected Inner Class. */
unsigned afv:1; /* Has final variables */
......@@ -1042,7 +1044,6 @@ extern void check_for_initialization PARAMS ((tree));
extern tree pushdecl_top_level PARAMS ((tree));
extern int alloc_class_constant PARAMS ((tree));
extern int unicode_mangling_length PARAMS ((const char *, int));
extern void init_expr_processing PARAMS ((void));
extern void push_super_field PARAMS ((tree, tree));
extern void init_class_processing PARAMS ((void));
......@@ -1060,9 +1061,6 @@ extern int push_type_0 PARAMS ((tree));
extern void push_type PARAMS ((tree));
extern void load_type_state PARAMS ((tree));
extern void add_interface PARAMS ((tree, tree));
extern void append_gpp_mangled_name PARAMS ((struct obstack *, const char *, int));
extern void append_gpp_mangled_classtype PARAMS ((struct obstack *, const char *));
extern void emit_unicode_mangled_name PARAMS ((struct obstack *, const char *, int));
extern tree force_evaluation_order PARAMS ((tree));
extern int verify_constant_pool PARAMS ((struct JCF *));
extern void start_java_method PARAMS ((tree));
......@@ -1111,6 +1109,12 @@ extern boolean java_hash_compare_tree_node PARAMS ((hash_table_key,
hash_table_key));
extern void java_check_methods PARAMS ((tree));
extern void init_jcf_parse PARAMS((void));
extern int cxx_keyword_p PARAMS ((const char *, int));
extern tree java_mangle_decl PARAMS ((struct obstack *, tree));
extern tree java_mangle_class_field PARAMS ((struct obstack *, tree));
extern tree java_mangle_class_field_from_string PARAMS ((struct obstack *, char *));
extern tree java_mangle_vtable PARAMS ((struct obstack *, tree));
extern const char *lang_printable_name_wls PARAMS ((tree, int));
/* We use ARGS_SIZE_RTX to indicate that gcc/expr.h has been included
......
/* Parser for Java(TM) .class files.
Copyright (C) 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
......
/* Program to generate "main" a Java(TM) class containing a main method.
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
......@@ -32,8 +32,8 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "tree.h"
#include "java-tree.h"
const char main_method_prefix[] = "main__";
const char main_method_suffix[] = "Pt6JArray1ZPQ34java4lang6String";
static char * do_mangle_classname PARAMS ((const char *string));
const char class_mangling_suffix[] = "class$";
struct obstack name_obstack;
......@@ -116,9 +116,7 @@ main (int argc, const char **argv)
classname = argv[i];
gcc_obstack_init (&name_obstack);
append_gpp_mangled_classtype (&name_obstack, classname);
obstack_1grow (&name_obstack, '\0');
mangled_classname = obstack_finish (&name_obstack);
mangled_classname = do_mangle_classname (classname);
if (i < argc - 1 && strcmp (argv[i + 1], "-") != 0)
{
......@@ -155,13 +153,8 @@ main (int argc, const char **argv)
}
fprintf (stream, " 0\n};\n\n");
#ifndef NO_DOLLAR_IN_LABEL
fprintf (stream, "extern int class __attribute__ ((alias (\"_%s$%s\")));\n",
mangled_classname, class_mangling_suffix);
#else
fprintf (stream, "extern int class __attribute__ ((alias (\"_%s.%s\")));\n",
mangled_classname, class_mangling_suffix);
#endif
fprintf (stream, "extern int class __attribute__ ((alias (\"%s\")));\n",
mangled_classname);
fprintf (stream, "int main (int argc, const char **argv)\n");
fprintf (stream, "{\n");
fprintf (stream, " _Jv_Compiler_Properties = props;\n");
......@@ -175,3 +168,36 @@ main (int argc, const char **argv)
}
return 0;
}
static char *
do_mangle_classname (string)
const char *string;
{
char *ptr;
int count = 0;
#define MANGLE_NAME() \
{ \
char buffer [128]; \
sprintf (buffer, "%d", count); \
obstack_grow (&name_obstack, buffer, strlen (buffer)); \
obstack_grow (&name_obstack, & ptr [-count], count); \
count = 0; \
}
obstack_grow (&name_obstack, "_ZN", 3);
for (ptr = (char *)string; *ptr; ptr++ )
{
if (ptr[0] == '.')
{
MANGLE_NAME ();
}
else
count++;
}
MANGLE_NAME ();
obstack_grow0 (&name_obstack, "6class$E", 8);
return obstack_finish (&name_obstack);
}
/* Language lexer for the GNU compiler for the Java(TM) language.
Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
This file is part of GNU CC.
......@@ -61,6 +61,10 @@ static int java_read_char PARAMS ((java_lexer *));
static void java_allocate_new_line PARAMS ((void));
static void java_unget_unicode PARAMS ((void));
static unicode_t java_sneak_unicode PARAMS ((void));
#ifndef JC1_LITE
static int utf8_cmp PARAMS ((const unsigned char *, int, const char *));
#endif
java_lexer *java_new_lexer PARAMS ((FILE *, const char *));
/* This is nonzero if we have initialized `need_byteswap'. */
......@@ -1763,3 +1767,101 @@ java_get_line_col (filename, line, col)
return obstack_finish (&temporary_obstack);
#endif
}
#ifndef JC1_LITE
static int
utf8_cmp (str, length, name)
const unsigned char *str;
int length;
const char *name;
{
const unsigned char *limit = str + length;
int i;
for (i = 0; name[i]; ++i)
{
int ch = UTF8_GET (str, limit);
if (ch != name[i])
return ch - name[i];
}
return str == limit ? 0 : 1;
}
/* A sorted list of all C++ keywords. */
static const char *cxx_keywords[] =
{
"asm",
"auto",
"bool",
"const_cast",
"delete",
"dynamic_cast",
"enum",
"explicit",
"extern",
"friend",
"inline",
"mutable",
"namespace",
"overload",
"register",
"reinterpret_cast",
"signed",
"sizeof",
"static_cast",
"struct",
"template",
"typedef",
"typeid",
"typename",
"typenameopt",
"union",
"unsigned",
"using",
"virtual",
"volatile",
"wchar_t"
};
/* Return true if NAME is a C++ keyword. */
int
cxx_keyword_p (name, length)
const char *name;
int length;
{
int last = ARRAY_SIZE (cxx_keywords);
int first = 0;
int mid = (last + first) / 2;
int old = -1;
for (mid = (last + first) / 2;
mid != old;
old = mid, mid = (last + first) / 2)
{
int kwl = strlen (cxx_keywords[mid]);
int min_length = kwl > length ? length : kwl;
int r = utf8_cmp (name, min_length, cxx_keywords[mid]);
if (r == 0)
{
int i;
/* We've found a match if all the remaining characters are
`$'. */
for (i = min_length; i < length && name[i] == '$'; ++i)
;
if (i == length)
return 1;
r = 1;
}
if (r < 0)
last = mid;
else
first = mid;
}
return 0;
}
#endif /* JC1_LITE */
/* Source code parsing and tree node generation for the GNU compiler
for the Java(TM) language.
Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
This file is part of GNU CC.
......@@ -2973,7 +2973,6 @@ yyerror (msg)
int save_lineno;
char *remainder, *code_from_source;
extern struct obstack temporary_obstack;
if (!force_error && prev_lineno == lineno)
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment