[gcjx] Patch: FYI: outer 'this' handling
Tom Tromey
tromey@redhat.com
Mon Oct 10 20:22:00 GMT 2005
I'm checking this in on the gcjx branch.
The tree generator did not handle outer 'this' at all.
This patch fixes the problem. This fixes a few of the failures in
libjava.lang.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* tree.cc (visit_this): Rewrote.
Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.56
diff -u -r1.1.2.56 tree.cc
--- tree.cc 10 Oct 2005 20:04:25 -0000 1.1.2.56
+++ tree.cc 10 Oct 2005 20:21:32 -0000
@@ -2388,10 +2388,49 @@
}
void
-tree_generator::visit_this (model_this *)
+tree_generator::visit_this (model_this *this_expr)
{
assert (this_tree != NULL_TREE);
- current = this_tree;
+
+ model_class *rtype = assert_cast<model_class *> (this_expr->type ());
+ model_class *prev = rtype;
+ model_class *iter = method->get_declaring_class ();
+
+ tree expr_tree;
+ if (method->constructor_p () && ! this_expr->check_match (rtype, iter))
+ {
+ // In <init>, we want to reference the argument
+ // corresponding to this$0, not the field. This is more
+ // efficient, and also without it we can create unverifiable
+ // bytecode before invoking the superclass constructor.
+ // Obviously this doesn't make sense for a pure "this", only
+ // an outer "this".
+ model_constructor *cons
+ = assert_cast<model_constructor *> (method);
+ model_variable_decl *th0 = cons->get_this0_parameter ();
+ expr_tree = gcc_builtins->map_variable (method_tree, th0);
+ prev = iter;
+ iter = iter->get_lexically_enclosing_class ();
+ }
+ else
+ expr_tree = this_tree;
+
+ for (;
+ ! this_expr->check_match (rtype, iter);
+ iter = iter->get_lexically_enclosing_class ())
+ {
+ assert (iter != NULL);
+
+ ref_field th0 = iter->get_this_0 ();
+ gcc_builtins->lay_out_class (iter);
+ expr_tree = gcc_builtins->map_field_ref (class_wrapper, expr_tree,
+ th0.get ());
+
+ prev = iter;
+ }
+
+ current = expr_tree;
+ // Note: can't annotate here as we have a DECL, not an expression.
}
void
More information about the Java-patches
mailing list