gjavah.c (add_class_decl): Removed unused variables tname', tlen' and `name_index'.

2000-10-18  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* gjavah.c (add_class_decl): Removed unused variables `tname',
	`tlen' and `name_index'.
	* java-tree.h (BUILD_FILENAME_IDENTIFIER_NODE): New macro.
	* jcf-parse.c (jcf_parse_source): Use it and set EXPR_WFL_FILENAME
	in `wfl_operator' with value.
	(yyparse): Use BUILD_FILENAME_IDENTIFIER_NODE.
	(jcf_figure_file_type): Fixed identation.
	* lex.c (java_get_line_col): Use EOF. Tuned `^' placement.
	* parse.y (analyze_clinit_body): New function.
	(static_initializer:): Reset `current_static_block'.
	(java_parser_context_restore_global): Set EXPR_WFL_FIILENAME_NODE in
	`wfl_operator' with new value.
	(lookup_cl): Use EXPR_WFL_FILENAME.
	(maybe_yank_clinit): Handle bogus <clinit> bodies, call
	analyze_clinit_body.
	(build_outer_field_access): Access to this$<n> built from
	current_class, not its outer context.
	(build_access_to_thisn): Fixed leading comment. Tidied things up.
	(resolve_qualified_expression_name): Handle `T.this' and `T.this.f()'.
	(patch_method_invocation): Use `is_static_flag' when already
	initialized.
	(patch_newarray): Removed assignment in ternary operator.

(http://gcc.gnu.org/ml/gcc-patches/2000-10/msg00629.html)

From-SVN: r36946
This commit is contained in:
Alexandre Petit-Bianco 2000-10-19 04:19:09 +00:00 committed by Alexandre Petit-Bianco
parent 0a8c4c0cd9
commit dba41d307e
6 changed files with 152 additions and 69 deletions

View File

@ -1,6 +1,31 @@
2000-10-18 Alexandre Petit-Bianco <apbianco@cygnus.com>
* gjavah.c (add_class_decl): Removed unused variables `tname',
`tlen' and `name_index'.
* java-tree.h (BUILD_FILENAME_IDENTIFIER_NODE): New macro.
* jcf-parse.c (jcf_parse_source): Use it and set EXPR_WFL_FILENAME
in `wfl_operator' with value.
(yyparse): Use BUILD_FILENAME_IDENTIFIER_NODE.
(jcf_figure_file_type): Fixed identation.
* lex.c (java_get_line_col): Use EOF. Tuned `^' placement.
* parse.y (analyze_clinit_body): New function.
(static_initializer:): Reset `current_static_block'.
(java_parser_context_restore_global): Set EXPR_WFL_FIILENAME_NODE in
`wfl_operator' with new value.
(lookup_cl): Use EXPR_WFL_FILENAME.
(maybe_yank_clinit): Handle bogus <clinit> bodies, call
analyze_clinit_body.
(build_outer_field_access): Access to this$<n> built from
current_class, not its outer context.
(build_access_to_thisn): Fixed leading comment. Tidied things up.
(resolve_qualified_expression_name): Handle `T.this' and `T.this.f()'.
(patch_method_invocation): Use `is_static_flag' when already
initialized.
(patch_newarray): Removed assignment in ternary operator.
2000-10-17 Alexandre Petit-Bianco <apbianco@cygnus.com>
* except.c (free_eh_ranges): Don't free `whole_range.'
* except.c (free_eh_ranges): Don't free `whole_range'.
2000-10-15 Anthony Green <green@redhat.com>
@ -157,14 +182,14 @@ Tue Oct 3 13:44:37 2000 Alexandre Petit-Bianco <apbianco@cygnus.com>
Wed Sep 13 16:06:52 2000 Alexandre Petit-Bianco <apbianco@cygnus.com>
* decl.c (give_name_to_locals): New local `code_offset'. Call
`maybe_adjust_start_pc.'
`maybe_adjust_start_pc'.
* expr.c (note_instructions): New function.
(expand_byte_code): Don't collect insn starts here.
(peek_opcode_at_pc): New function.
(maybe_adjust_start_pc): Likewise.
* java-tree.h (maybe_adjust_start_pc): Declare.
(note_instructions): Likewise.
* jcf-parse.c (parse_class_file): Call `note_instructions.'
* jcf-parse.c (parse_class_file): Call `note_instructions'.
Wed Sep 13 11:50:35 2000 Alexandre Petit-Bianco <apbianco@cygnus.com>
@ -483,10 +508,10 @@ Sun Aug 13 09:41:49 2000 Anthony Green <green@redhat.com>
of a `invokeinterface' at the right time.
* parse.h (WFL_STRIP_BRACKET): New macro.
(SET_TYPE_FOR_RESOLUTION): Use it.
* parse.y (build_unresolved_array_type): Reuse `type_or_wfl.'
* parse.y (build_unresolved_array_type): Reuse `type_or_wfl'.
(check_class_interface_creation): Don't check for cross package
innerclass name clashes.
(method_header): Behave properly if MDECL is `error_mark_node.'
(method_header): Behave properly if MDECL is `error_mark_node'.
(method_declarator): Return `error_mark_node' if bogus current
class.
(resolve_class): Apply WFL_STRIP_BRACKET on `cl' if necessary.
@ -520,7 +545,7 @@ Sun Aug 13 09:41:49 2000 Anthony Green <green@redhat.com>
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
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.
@ -703,7 +728,7 @@ Sun Aug 6 00:47:24 2000 Ovidiu Predescu <ovidiu@cup.hp.com>
classes.
* java-tree.h (TYPE_PROTECTED_INNER_CLASS): New macro.
(CLASS_PROTECTED): Likewise.
(struct lang_type): New bitfield `poic.'
(struct lang_type): New bitfield `poic'.
* parse.y (jdep_resolve_class): Call check_inner_class_access on
inner classes only.
(check_inner_class_access): Renamed arguments, added
@ -713,7 +738,7 @@ Sun Aug 6 00:47:24 2000 Ovidiu Predescu <ovidiu@cup.hp.com>
2000-07-10 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (resolve_qualified_expression_name): Verify qualified
access to `this.' Fixes gcj/239.
access to `this'. Fixes gcj/239.
2000-07-10 Alexandre Petit-Bianco <apbianco@cygnus.com>
@ -745,7 +770,7 @@ Sun Aug 6 00:47:24 2000 Ovidiu Predescu <ovidiu@cup.hp.com>
2000-07-05 Alexandre Petit-Bianco <apbianco@cygnus.com>
* java-tree.h (java_debug_context): Declared `extern.'
* java-tree.h (java_debug_context): Declared `extern'.
(safe_layout_class): Likewise.
* parse.y (resolve_field_access): Field must be `static' in order
to be replaced by its initial value. Added comments.
@ -754,7 +779,7 @@ Sun Aug 6 00:47:24 2000 Ovidiu Predescu <ovidiu@cup.hp.com>
take over methods founds in the enclosing contexts.
(java_complete_tree): Loosen restrictions on the type of DECLs
that can be replaced by their initialization values.
(valid_ref_assignconv_cast_p): Removed call to `enclosing_context_p.'
(valid_ref_assignconv_cast_p): Removed call to `enclosing_context_p'.
2000-07-05 Tom Tromey <tromey@cygnus.com>
@ -848,7 +873,7 @@ Sun Aug 6 00:47:24 2000 Ovidiu Predescu <ovidiu@cup.hp.com>
* class.c (set_super_info): Handle ACC_PRIVATE for (inner)
classes.
* java-tree.h (TYPE_PRIVATE_INNER_CLASS): New macro.
(struct lang_type): New field `pic.'
(struct lang_type): New field `pic'.
(CLASS_PRIVATE): New macro.
* parse.y (check_inner_class_access): New function.
(jdep_resolve_class): Call it.
@ -1446,7 +1471,7 @@ Sat Mar 25 09:12:10 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
Mon Mar 20 08:58:51 2000 Alexandre Petit-Bianco <apbianco@cygnus.com>
* jcf-write.c (generate_bytecode_insns): TRY_FINALLY_EXPR:
properly initialize `finished_label.' Don't emit gotos for empty
properly initialize `finished_label'. Don't emit gotos for empty
try statements.
2000-03-19 Martin v. Löwis <loewis@informatik.hu-berlin.de>
@ -1922,7 +1947,7 @@ Thu Feb 10 20:10:43 2000 Alexandre Petit-Bianco <apbianco@cygnus.com>
Thu Feb 10 16:04:26 2000 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (resolve_package): New local `acc.' Try to progressively
* parse.y (resolve_package): New local `acc'. Try to progressively
build and guess a package and type name.
Thu Feb 10 12:52:09 2000 Alexandre Petit-Bianco <apbianco@cygnus.com>
@ -1936,7 +1961,7 @@ Thu Feb 10 12:52:09 2000 Alexandre Petit-Bianco <apbianco@cygnus.com>
* class.c (layout_class): Set and test CLASS_BEING_LAIDOUT.
Generate error message if circularity is detected. New static
local `list.'
local `list'.
* java-tree.h (CLASS_BEING_LAIDOUT): New flag usage, new macro. *
* jcf-write.c (generate_bytecode_insns): Very simply handle
SAVE_EXPR.

View File

@ -1561,10 +1561,6 @@ add_class_decl (out, jcf, signature)
const unsigned char *s = JPOOL_UTF_DATA (jcf, signature);
int len = JPOOL_UTF_LENGTH (jcf, signature);
int i;
/* Name of class we are processing. */
int name_index = JPOOL_USHORT1 (jcf, jcf->this_class);
int tlen = JPOOL_UTF_LENGTH (jcf, name_index);
const char *tname = JPOOL_UTF_DATA (jcf, name_index);
for (i = 0; i < len; ++i)
{

View File

@ -1359,6 +1359,16 @@ extern tree *type_map;
scope of TYPE_DECL. */
#define DECL_INNER_CLASS_LIST(NODE) DECL_INITIAL (NODE)
/* Build a IDENTIFIER_POINTER for a file name we're considering. We
need to register the root, but we're trying to register it only
once. */
#define BUILD_FILENAME_IDENTIFIER_NODE(F, S) \
if (!((F) = maybe_get_identifier ((S)))) \
{ \
(F) = get_identifier ((S)); \
ggc_mark_tree ((F)); \
}
/* Add a FIELD_DECL to RECORD_TYPE RTYPE.
The field has name NAME (a char*), and type FTYPE.
Unless this is the first field, FIELD most hold the previous field.

View File

@ -558,8 +558,9 @@ jcf_parse_source ()
java_parser_context_save_global ();
java_push_parser_context ();
BUILD_FILENAME_IDENTIFIER_NODE (file, current_jcf->filename);
EXPR_WFL_FILENAME_NODE (wfl_operator) = file;
input_filename = ggc_strdup (current_jcf->filename);
file = get_identifier (input_filename);
current_class = NULL_TREE;
current_function_decl = NULL_TREE;
if (!HAS_BEEN_ALREADY_PARSED_P (file))
@ -855,7 +856,7 @@ yyparse ()
}
else
{
node = get_identifier (value);
BUILD_FILENAME_IDENTIFIER_NODE (node, value);
IS_A_COMMAND_LINE_FILENAME_P (node) = 1;
current_file_list = tree_cons (NULL_TREE, node,
current_file_list);
@ -1068,7 +1069,8 @@ DEFUN(jcf_figure_file_type, (jcf),
&& !open_in_zip (jcf, input_filename, NULL, 0))
{
localToFile = ALLOC (sizeof (struct ZipFileCache));
bcopy ((PTR) SeenZipFiles, (PTR) localToFile, sizeof (struct ZipFileCache));
bcopy ((PTR) SeenZipFiles, (PTR) localToFile,
sizeof (struct ZipFileCache));
process_zip_dir (); /* Register all the class defined there */
return JCF_ZIP;
}

View File

@ -1526,7 +1526,7 @@ java_get_line_col (filename, line, col)
while (cline != line)
{
c = getc (fp);
if (c < 0)
if (c == EOF)
{
static char msg[] = "<<file too short - unexpected EOF>>";
obstack_grow (&temporary_obstack, msg, sizeof(msg)-1);
@ -1563,7 +1563,7 @@ java_get_line_col (filename, line, col)
/* Place the '^' a the right position */
base = obstack_base (&temporary_obstack);
for (ccol = 1; ccol <= col; ccol++)
for (ccol = 1; ccol <= col+3; ccol++)
{
/* Compute \t when reaching first_non_space */
char c = (first_non_space ?

View File

@ -140,6 +140,7 @@ static tree obtain_incomplete_type PARAMS ((tree));
static tree java_complete_lhs PARAMS ((tree));
static tree java_complete_tree PARAMS ((tree));
static tree maybe_generate_pre_expand_clinit PARAMS ((tree));
static int analyze_clinit_body PARAMS ((tree));
static int maybe_yank_clinit PARAMS ((tree));
static void java_complete_expand_method PARAMS ((tree));
static int unresolved_type_p PARAMS ((tree, tree *));
@ -1131,6 +1132,7 @@ static_initializer:
{
TREE_CHAIN ($2) = CPC_STATIC_INITIALIZER_STMT (ctxp);
SET_CPC_STATIC_INITIALIZER_STMT (ctxp, $2);
current_static_block = NULL_TREE;
}
;
@ -2711,6 +2713,12 @@ java_parser_context_restore_global ()
lineno = ctxp->lineno;
current_class = ctxp->class_type;
input_filename = ctxp->filename;
if (wfl_operator)
{
tree s;
BUILD_FILENAME_IDENTIFIER_NODE (s, input_filename);
EXPR_WFL_FILENAME_NODE (wfl_operator) = s;
}
current_function_decl = ctxp->function_decl;
ctxp->saved_data = 0;
if (ctxp->saved_data_ctx)
@ -6443,7 +6451,7 @@ lookup_cl (decl)
EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
line = java_get_line_col (EXPR_WFL_FILENAME (cl),
EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
found = strstr ((const char *)line,
@ -7583,6 +7591,42 @@ maybe_generate_pre_expand_clinit (class_type)
return mdecl;
}
/* Analyzes a method body and look for something that isn't a
MODIFY_EXPR. */
static int
analyze_clinit_body (bbody)
tree bbody;
{
while (bbody)
switch (TREE_CODE (bbody))
{
case BLOCK:
bbody = BLOCK_EXPR_BODY (bbody);
break;
case EXPR_WITH_FILE_LOCATION:
bbody = EXPR_WFL_NODE (bbody);
break;
case COMPOUND_EXPR:
if (analyze_clinit_body (TREE_OPERAND (bbody, 0)))
return 1;
bbody = TREE_OPERAND (bbody, 1);
break;
case MODIFY_EXPR:
bbody = NULL_TREE;
break;
default:
bbody = NULL_TREE;
return 1;
}
return 0;
}
/* See whether we could get rid of <clinit>. Criteria are: all static
final fields have constant initial values and the body of <clinit>
is empty. Return 1 if <clinit> was discarded, 0 otherwise. */
@ -7602,8 +7646,11 @@ maybe_yank_clinit (mdecl)
we're emitting classfiles, this isn't enough not to rule it
out. */
fbody = DECL_FUNCTION_BODY (mdecl);
if ((bbody = BLOCK_EXPR_BODY (fbody)))
bbody = BLOCK_EXPR_BODY (fbody);
if (bbody && bbody != error_mark_node)
bbody = BLOCK_EXPR_BODY (bbody);
else
return 0;
if (bbody && ! flag_emit_class_files && bbody != empty_stmt_node)
return 0;
@ -7644,30 +7691,9 @@ maybe_yank_clinit (mdecl)
/* Now we analyze the method body and look for something that
isn't a MODIFY_EXPR */
if (bbody == empty_stmt_node)
bbody = NULL_TREE;
while (bbody)
switch (TREE_CODE (bbody))
{
case BLOCK:
bbody = BLOCK_EXPR_BODY (bbody);
break;
case EXPR_WITH_FILE_LOCATION:
bbody = EXPR_WFL_NODE (bbody);
break;
case COMPOUND_EXPR:
bbody = TREE_OPERAND (bbody, 0);
break;
case MODIFY_EXPR:
bbody = NULL_TREE;
break;
default:
bbody = NULL_TREE;
found = 1;
}
found = 0;
else
found = analyze_clinit_body (bbody);
if (current || found)
return 0;
@ -7808,7 +7834,7 @@ build_outer_field_access (id, decl)
/* Now we chain the required number of calls to the access$0 to
get a hold to the enclosing instance we need, and then we
build the field access. */
access = build_access_to_thisn (ctx, DECL_CONTEXT (decl), lc);
access = build_access_to_thisn (current_class, DECL_CONTEXT (decl), lc);
/* If the field is private and we're generating bytecode, then
we generate an access method */
@ -8135,9 +8161,11 @@ build_outer_method_access_method (decl)
kept in a generated field called this$<n>, with <n> being the
inner class nesting level (starting from 0.) */
/* Build an access to a given this$<n>, possibly by chaining access
call to others. Access methods to this$<n> are build on the fly if
necessary */
/* Build an access to a given this$<n>, always chaining access call to
others. Access methods to this$<n> are build on the fly if
necessary. This CAN'T be used to solely access this$<n-1> from
this$<n> (which alway yield to special cases and optimization, see
for example build_outer_field_access). */
static tree
build_access_to_thisn (from, to, lc)
@ -8148,21 +8176,23 @@ build_access_to_thisn (from, to, lc)
while (from != to)
{
tree access0_wfl, cn;
maybe_build_thisn_access_method (from);
access0_wfl = build_wfl_node (access0_identifier_node);
cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
EXPR_WFL_LINECOL (access0_wfl) = lc;
if (!access)
{
access = build_current_thisn (from);
access = build_wfl_node (access);
}
else
{
access = build_current_thisn (current_class);
access = build_wfl_node (access);
tree access0_wfl, cn;
maybe_build_thisn_access_method (from);
access0_wfl = build_wfl_node (access0_identifier_node);
cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
EXPR_WFL_LINECOL (access0_wfl) = lc;
access = build_tree_list (NULL_TREE, access);
access = build_method_invocation (access0_wfl, access);
access = make_qualified_primary (cn, access, lc);
}
access = build_tree_list (NULL_TREE, access);
access = build_method_invocation (access0_wfl, access);
access = make_qualified_primary (cn, access, lc);
from = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (from)));
}
@ -9014,10 +9044,21 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
saved and restored shortly after */
saved_current = current_class;
saved_this = current_this;
if (decl && TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
if (decl
&& (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
|| from_qualified_this))
{
/* If we still have `from_qualified_this', we have the form
<T>.this.f() and we need to build <T>.this */
if (from_qualified_this)
{
decl = build_access_to_thisn (current_class, type, 0);
decl = java_complete_tree (decl);
type = TREE_TYPE (TREE_TYPE (decl));
}
current_class = type;
current_this = decl;
from_qualified_this = 0;
}
if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
@ -9174,8 +9215,17 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
free (p);
return 1;
}
*where_found = decl = build_current_thisn (type);
from_qualified_this = 1;
/* If there's nothing else after that, we need to
produce something now, otherwise, the section of the
code that needs to produce <T>.this will generate
what is necessary. */
if (!TREE_CHAIN (q))
{
decl = build_access_to_thisn (current_class, type, 0);
*where_found = decl = java_complete_tree (decl);
*type_found = type = TREE_TYPE (decl);
}
}
from_type = 0;
@ -9925,7 +9975,7 @@ patch_method_invocation (patch, primary, where, is_static, ret_decl)
}
is_static_flag = METHOD_STATIC (list);
if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
if (! is_static_flag && this_arg != NULL_TREE)
args = tree_cons (NULL_TREE, this_arg, args);
/* In the context of an explicit constructor invocation, we can't
@ -13748,7 +13798,7 @@ patch_newarray (node)
tree dim = TREE_VALUE (cdim);
/* Dim might have been saved during its evaluation */
dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
dim = (TREE_CODE (dim) == SAVE_EXPR ? TREE_OPERAND (dim, 0) : dim);
/* The type of each specified dimension must be an integral type. */
if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))