diff options
author | Alexandre Petit-Bianco <apbianco@cygnus.com> | 2000-08-08 03:33:36 +0000 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 2000-08-07 20:33:36 -0700 |
commit | f0f3a77740016ecd1168ce689bbc36d705ddff49 (patch) | |
tree | 3231a690fb29e8d59f05640bc2d73c4114d8b28e /gcc/java/parse-scan.y | |
parent | 0da9afa6d6ac1ca516bc62d97ef1b8e727ea96b7 (diff) | |
download | gcc-f0f3a77740016ecd1168ce689bbc36d705ddff49.zip gcc-f0f3a77740016ecd1168ce689bbc36d705ddff49.tar.gz gcc-f0f3a77740016ecd1168ce689bbc36d705ddff49.tar.bz2 |
2000-08-07 Alexandre Petit-Bianco <apbianco@cygnus.com
* parse.y (build_dot_class_method_invocation): Changed parameter
name to `type.' Build signature from `type' and convert it to a
STRING_CST if it's an array.
(patch_incomplete_class_ref): `build_dot_class_method_invocation'
to use `ref_type' directly.
2000-08-01 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (maybe_yank_clinit): When generating bytecode: non empty
method bodies not to rule out discarding `<clinit>'; don't use
<clinit> to initialize static fields with constant initializers.
2000-08-01 Alexandre Petit-Bianco <apbianco@cygnus.com>
* gjavah.c (print_method_info): Added `synth' parameter. Skip
synthetic methods.
(method_synthetic): New global.
(HANDLE_METHOD): Recognize synthetic method and tell
`print_method_info' about it.
(HANDLE_END_METHOD): Do not issue an additional `;\n' if we're
processing a synthetic method.
* jcf-reader.c (skip_attribute): New function.
( skip_attribute): Likewise.
2000-08-01 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (build_outer_field_access): Fixed comments.
(fix_constructors): Emit the initialization of this$<n> before
calling $finit$.
(resolve_qualified_expression_name): Build an access to `decl' if
necessary.
2000-07-31 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse-scan.y (curent_class): Non longer const.
(inner_qualifier, inner_qualifier_length): Deleted.
(current_class_length): New global.
(bracket_count): Fixed typo in leading comment.
(anonymous_count): New global.
(class_instance_creation_expression:): Handle anonymous classes.
(anonymous_class_creation:): New rule.
(push_class_context): Rewritten.
(pop_class_context): Likewise.
(INNER_QUALIFIER): Macro deleted.
(report_class_declaration): call `push_class_context' when
entering the function. `fprintf' format modified not to use
INNER_QUALIFIER.
(report_class_declaration): Assign `package_name' and
`current_class' to NULL separatly.
2000-07-31 Alexandre Petit-Bianco <apbianco@cygnus.com>
* expr.c (build_invokeinterface): Call layout_class_methods on
target interface.
(http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00339.html)
From-SVN: r35560
Diffstat (limited to 'gcc/java/parse-scan.y')
-rw-r--r-- | gcc/java/parse-scan.y | 99 |
1 files changed, 67 insertions, 32 deletions
diff --git a/gcc/java/parse-scan.y b/gcc/java/parse-scan.y index f4d10b8..2b8b78d 100644 --- a/gcc/java/parse-scan.y +++ b/gcc/java/parse-scan.y @@ -63,12 +63,11 @@ static int absorber; #define USE_ABSORBER absorber = 0 /* Keep track of the current class name and package name. */ -static const char *current_class; +static char *current_class; static const char *package_name; /* Keep track of the current inner class qualifier. */ -static char *inner_qualifier; -static int inner_qualifier_length; +static int current_class_length; /* Keep track of whether things have be listed before. */ static int previous_output; @@ -76,10 +75,13 @@ static int previous_output; /* Record modifier uses */ static int modifier_value; -/* Keep track of number of bracket pairs after a variable declarator +/* Keeps track of number of bracket pairs after a variable declarator id. */ static int bracket_count; +/* Numbers anonymous classes */ +static int anonymous_count; + /* Record a method declaration */ struct method_declarator { const char *method_name; @@ -897,20 +899,22 @@ primary_no_new_array: class_instance_creation_expression: NEW_TK class_type OP_TK argument_list CP_TK | NEW_TK class_type OP_TK CP_TK - /* Added, JDK1.1 inner classes but modified to use - 'class_type' instead of 'TypeName' (type_name) mentionned - in the documentation but doesn't exist. */ -| NEW_TK class_type OP_TK argument_list CP_TK class_body -| NEW_TK class_type OP_TK CP_TK class_body - /* Added, JDK1.1 inner classes, modified to use name or - primary instead of primary solely which couldn't work in - all situations. */ +| anonymous_class_creation | something_dot_new identifier OP_TK CP_TK | something_dot_new identifier OP_TK CP_TK class_body | something_dot_new identifier OP_TK argument_list CP_TK | something_dot_new identifier OP_TK argument_list CP_TK class_body ; +anonymous_class_creation: + NEW_TK class_type OP_TK CP_TK + { report_class_declaration (NULL); } + class_body +| NEW_TK class_type OP_TK argument_list CP_TK + { report_class_declaration (NULL); } + class_body +; + something_dot_new: /* Added, not part of the specs. */ name DOT_TK NEW_TK { USE_ABSORBER; } @@ -1128,29 +1132,61 @@ static void push_class_context (name) const char *name; { - size_t name_length = strlen (name); - inner_qualifier = xrealloc (inner_qualifier, - inner_qualifier_length + name_length+2); - memcpy (inner_qualifier+inner_qualifier_length, name, name_length); - inner_qualifier_length += name_length; - inner_qualifier [inner_qualifier_length] = '$'; - inner_qualifier [++inner_qualifier_length] = '\0'; + /* If we already have CURRENT_CLASS set, we're in an inter + class. Mangle its name. */ + if (current_class) + { + const char *p; + char anonymous [3]; + int additional_length; + + /* NAME set to NULL indicates an anonymous class, which are named by + numbering them. */ + if (!name) + { + sprintf (anonymous, "%d", ++anonymous_count); + p = anonymous; + } + else + p = name; + + additional_length = strlen (p)+1; /* +1 for `$' */ + current_class = xrealloc (current_class, + current_class_length + additional_length + 1); + current_class [current_class_length] = '$'; + strcpy (¤t_class [current_class_length+1], p); + current_class_length += additional_length; + } + else + { + if (!name) + return; + current_class_length = strlen (name); + current_class = xmalloc (current_class_length+1); + strcpy (current_class, name); + } } static void pop_class_context () { - while (--inner_qualifier_length > 0 - && inner_qualifier [inner_qualifier_length-1] != '$') + /* Go back to the last `$' and cut. */ + while (--current_class_length > 0 + && current_class [current_class_length] != '$') ; - inner_qualifier = xrealloc (inner_qualifier, inner_qualifier_length+1); - if (inner_qualifier_length == -1) - inner_qualifier_length = 0; - inner_qualifier [inner_qualifier_length] = '\0'; + if (current_class_length) + { + current_class = xrealloc (current_class, current_class_length+1); + current_class [current_class_length] = '\0'; + } + else + { + current_class = NULL; + anonymous_count = 0; + } } /* Actions defined here */ -#define INNER_QUALIFIER (inner_qualifier ? inner_qualifier : "") static void report_class_declaration (name) @@ -1158,6 +1194,7 @@ report_class_declaration (name) { extern int flag_dump_class, flag_list_filename; + push_class_context (name); if (flag_dump_class) { if (!previous_output) @@ -1168,13 +1205,10 @@ report_class_declaration (name) } if (package_name) - fprintf (out, "%s.%s%s ", package_name, INNER_QUALIFIER, name); + fprintf (out, "%s.%s ", package_name, current_class); else - fprintf (out, "%s%s ", INNER_QUALIFIER, name); + fprintf (out, "%s ", current_class); } - - push_class_context (name); - current_class = name; } static void @@ -1208,7 +1242,8 @@ report_main_declaration (declarator) void reset_report () { previous_output = 0; - current_class = package_name = NULL; + package_name = NULL; + current_class = NULL; } void |