diff options
author | daney <daney@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-23 23:00:39 +0000 |
---|---|---|
committer | daney <daney@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-01-23 23:00:39 +0000 |
commit | 0ac26f7554a5ea2d7acfbef1887c5ce4b13bdb8b (patch) | |
tree | c5724340e6d582282ffea2d456a266bb7efcdf72 /gcc/java | |
parent | 248c1389d7a1a79373e3ae5793c27784849dbd4c (diff) | |
download | gcc-0ac26f7554a5ea2d7acfbef1887c5ce4b13bdb8b.tar.gz |
2008-01-23 David Daney <ddaney@avtrex.com>
* class.c (hide) Rename to...
(java_hide_decl) ... this throughout, and make public.
* resource.c (Jr_count): Remove.
(compile_resource_data): Call java_mangle_resource_name to generate
decl name. Make resource decl public and hidden.
* mangle.c (java_mangle_resource_name): New function.
* java-tree.h (java_hide_decl, java_mangle_resource_name): Declare
functions.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131767 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/java/class.c | 14 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 2 | ||||
-rw-r--r-- | gcc/java/mangle.c | 53 | ||||
-rw-r--r-- | gcc/java/resource.c | 11 |
5 files changed, 76 insertions, 15 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 3d8701795dc..d93dd3d43eb 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,14 @@ +2008-01-23 David Daney <ddaney@avtrex.com> + + * class.c (hide) Rename to... + (java_hide_decl) ... this throughout, and make public. + * resource.c (Jr_count): Remove. + (compile_resource_data): Call java_mangle_resource_name to generate + decl name. Make resource decl public and hidden. + * mangle.c (java_mangle_resource_name): New function. + * java-tree.h (java_hide_decl, java_mangle_resource_name): Declare + functions. + 2008-01-04 Andrew Haley <aph@redhat.com> PR java/17779 diff --git a/gcc/java/class.c b/gcc/java/class.c index 029d9ac68b1..2aec3a5addf 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -742,8 +742,8 @@ build_java_method_type (tree fntype, tree this_class, int access_flags) return fntype; } -static void -hide (tree decl ATTRIBUTE_UNUSED) +void +java_hide_decl (tree decl ATTRIBUTE_UNUSED) { #ifdef HAVE_GAS_HIDDEN DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN; @@ -872,7 +872,7 @@ add_field (tree class, tree name, tree field_type, int flags) /* Hide everything that shouldn't be visible outside a DSO. */ if (flag_indirect_classes || (FIELD_PRIVATE (field))) - hide (field); + java_hide_decl (field); /* Considered external unless we are compiling it into this object file. */ DECL_EXTERNAL (field) = (is_compiled_class (class) != 2); @@ -1031,7 +1031,7 @@ build_static_class_ref (tree type) { TREE_PUBLIC (decl) = 1; if (CLASS_PRIVATE (TYPE_NAME (type))) - hide (decl); + java_hide_decl (decl); } DECL_IGNORED_P (decl) = 1; DECL_ARTIFICIAL (decl) = 1; @@ -1071,7 +1071,7 @@ build_classdollar_field (tree type) TREE_CONSTANT (decl) = 1; TREE_READONLY (decl) = 1; TREE_PUBLIC (decl) = 1; - hide (decl); + java_hide_decl (decl); DECL_IGNORED_P (decl) = 1; DECL_ARTIFICIAL (decl) = 1; MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); @@ -1760,7 +1760,7 @@ make_class_data (tree type) /* The only dispatch table exported from a DSO is the dispatch table for java.lang.Class. */ if (DECL_NAME (type_decl) != id_class) - hide (dtable_decl); + java_hide_decl (dtable_decl); if (! flag_indirect_classes) rest_of_decl_compilation (dtable_decl, 1, 0); /* Maybe we're compiling Class as the first class. If so, set @@ -2613,7 +2613,7 @@ layout_class_method (tree this_class, tree super_class, || (METHOD_PRIVATE (method_decl) && METHOD_STATIC (method_decl) && ! METHOD_NATIVE (method_decl) && ! special_method_p (method_decl))) - hide (method_decl); + java_hide_decl (method_decl); /* Considered external unless it is being compiled into this object file, or it was already flagged as external. */ diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 75ccdca6540..a19d400d608 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -1026,6 +1026,7 @@ extern tree parse_signature (struct JCF *jcf, int sig_index); extern tree add_field (tree, tree, tree, int); extern tree add_method (tree, int, tree, tree); extern tree add_method_1 (tree, int, tree, tree); +extern void java_hide_decl (tree); extern tree make_class (void); extern tree push_class (tree, tree); extern tree unmangle_classname (const char *name, int name_length); @@ -1205,6 +1206,7 @@ extern void java_check_methods (tree); extern void java_mangle_decl (tree); extern tree java_mangle_class_field (struct obstack *, tree); extern tree java_mangle_vtable (struct obstack *, tree); +extern tree java_mangle_resource_name (const char *); extern void append_gpp_mangled_name (const char *, int); extern void add_predefined_file (tree); diff --git a/gcc/java/mangle.c b/gcc/java/mangle.c index c7624d5345e..c92be1c0693 100644 --- a/gcc/java/mangle.c +++ b/gcc/java/mangle.c @@ -796,6 +796,59 @@ compression_table_add (tree type) TREE_VEC_ELT (compression_table, compression_next++) = type; } +/* Mangle an embedded resource file name. "_ZGr" is the prefix. A + '_' is prepended to the name so that names starting with a digit + can be demangled. The length and then the resulting name itself + are appended while escaping '$', '.', and '/' to: "$$", "$_", and + "$S". */ + +tree +java_mangle_resource_name (const char *name) +{ + int len = strlen (name); + char *buf = (char *) alloca (2 * len + 1); + char *pos; + const unsigned char *w1 = (const unsigned char *) name; + const unsigned char *w2; + const unsigned char *limit = w1 + len; + + pos = buf; + + init_mangling (); + MANGLE_RAW_STRING ("Gr"); + + *pos++ = '_'; + while (w1 < limit) + { + int ch; + w2 = w1; + ch = UTF8_GET (w1, limit); + gcc_assert (ch > 0); + switch (ch) + { + case '$': + *pos++ = '$'; + *pos++ = '$'; + break; + case '.': + *pos++ = '$'; + *pos++ = '_'; + break; + case '/': + *pos++ = '$'; + *pos++ = 'S'; + break; + default: + memcpy (pos, w2, w1 - w2); + pos += w1 - w2; + break; + } + } + append_gpp_mangled_name (buf, pos - buf); + + return finish_mangling (); +} + /* Mangling initialization routine. */ static void diff --git a/gcc/java/resource.c b/gcc/java/resource.c index b5cbd2e86b8..e0a403e7a0a 100644 --- a/gcc/java/resource.c +++ b/gcc/java/resource.c @@ -51,14 +51,10 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ /* A list of all the resources files. */ static GTY(()) tree resources = NULL; -/* Count of all the resources compiled in this invocation. */ -static int Jr_count = 0; - void compile_resource_data (const char *name, const char *buffer, int length) { tree rtype, field = NULL_TREE, data_type, rinit, data, decl; - char buf[60]; data_type = build_prim_array_type (unsigned_byte_type_node, strlen (name) + length); @@ -79,11 +75,10 @@ compile_resource_data (const char *name, const char *buffer, int length) TREE_CONSTANT (rinit) = 1; TREE_INVARIANT (rinit) = 1; - /* Generate a unique-enough identifier. */ - sprintf (buf, "_Jr%d", ++Jr_count); - - decl = build_decl (VAR_DECL, get_identifier (buf), rtype); + decl = build_decl (VAR_DECL, java_mangle_resource_name (name), rtype); TREE_STATIC (decl) = 1; + TREE_PUBLIC (decl) = 1; + java_hide_decl (decl); DECL_ARTIFICIAL (decl) = 1; DECL_IGNORED_P (decl) = 1; TREE_READONLY (decl) = 1; |