This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gcjx] Patch: FYI: super.<init> handling


I'm checking this in on the gcjx branch.

Our handling of super.<init> was pretty lame, and in the tree back end
failed entirely.  Calling 'visit' twice from the super's visitor
method was a bad idea -- better to pass a possible 'finit' call as an
argument and let the concrete visitor work it out.

Tom

Index: gcjx/ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* model/invoke.cc (visit): Pass 'finit' as argument to visitor.
	* defassign.cc (definite_assignment_visitor::visit_super_invocation):
	Updated.
	* fold.cc (fold_visitor::visit_super_invocation): Updated.
	* bytecode/generate.cc (visit_super_invocation): Updated.
	* bytecode/generate.hh (bytecode_generator::visit_super_invocation):
	Updated.
	* dump.cc (dumper::visit_super_invocation): Updated.
	(pretty_printer::visit_super_invocation): Likewise.
	* visitor.hh (visitor::visit_super_invocation): Added argument.

Index: gcc/java/ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* tree.cc (visit_super_invocation): Added argument.
	* tree.hh (tree_generator::visit_super_invocation): Added
	argument.

Index: gcjx/defassign.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/defassign.cc,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 defassign.cc
--- gcjx/defassign.cc 11 Oct 2005 05:36:12 -0000 1.1.2.9
+++ gcjx/defassign.cc 12 Oct 2005 00:43:38 -0000
@@ -1391,10 +1391,13 @@
 
   void visit_super_invocation (model_super_invocation *,
 			       const model_method *,
-			       const std::list<ref_expression> &exprs)
+			       const std::list<ref_expression> &exprs,
+			       const ref_expression &finit)
   {
     assert (constructor);
     visit (exprs);
+    if (finit)
+      finit->visit (this);
   }
 
   void visit_this_invocation (model_this_invocation *,
Index: gcjx/dump.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/dump.cc,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 dump.cc
--- gcjx/dump.cc 11 Oct 2005 05:36:12 -0000 1.1.2.5
+++ gcjx/dump.cc 12 Oct 2005 00:43:38 -0000
@@ -820,10 +820,13 @@
 
   void visit_super_invocation (model_super_invocation *,
 			       const model_method *,
-			       const std::list<ref_expression> &args)
+			       const std::list<ref_expression> &args,
+			       const ref_expression &finit)
   {
     out << "super";
     handle_args (args);
+    if (finit)
+      finit->visit (this);
   }
 
   void visit_this_invocation (model_this_invocation *,
@@ -2132,7 +2135,8 @@
 
   void visit_super_invocation (model_super_invocation *si,
                                const model_method *meth,
-                               const std::list<ref_expression> &args)
+                               const std::list<ref_expression> &args,
+			       const ref_expression &finit)
   {
     begin_element (si, "super_invocation");
     if (meth != NULL)
@@ -2141,6 +2145,8 @@
       out << " NULL";
     descend (args);
     end_element ();
+    if (finit)
+      finit->visit (this);
   }
 
   void visit_this_invocation (model_this_invocation *ti,
Index: gcjx/fold.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/fold.cc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 fold.cc
--- gcjx/fold.cc 11 Oct 2005 05:36:12 -0000 1.1.2.4
+++ gcjx/fold.cc 12 Oct 2005 00:43:38 -0000
@@ -539,9 +539,13 @@
 
   void visit_super_invocation (model_super_invocation *invocation,
 			       const model_method *,
-			       const std::list<ref_expression> &arguments)
+			       const std::list<ref_expression> &arguments,
+			       const ref_expression &finit)
   {
     invocation->set_arguments (fold (arguments));
+    // We can't fold the call but perhaps we can fold an argument.
+    if (finit)
+      finit->visit (this);
   }
 
   void visit_this_invocation (model_this_invocation *invocation,
Index: gcjx/visitor.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/visitor.hh,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 visitor.hh
--- gcjx/visitor.hh 11 Oct 2005 05:36:12 -0000 1.1.2.5
+++ gcjx/visitor.hh 12 Oct 2005 00:43:38 -0000
@@ -294,7 +294,8 @@
 
   virtual void visit_super_invocation (model_super_invocation *,
 				       const model_method *,
-				       const std::list<ref_expression> &) = 0;
+				       const std::list<ref_expression> &,
+				       const ref_expression &) = 0;
 
   virtual void visit_this_invocation (model_this_invocation *,
 				      const model_method *,
Index: gcjx/bytecode/generate.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/generate.cc,v
retrieving revision 1.1.2.24
diff -u -r1.1.2.24 generate.cc
--- gcjx/bytecode/generate.cc 9 Oct 2005 21:59:48 -0000 1.1.2.24
+++ gcjx/bytecode/generate.cc 12 Oct 2005 00:43:39 -0000
@@ -3246,7 +3246,8 @@
 bytecode_generator::visit_super_invocation
     (model_super_invocation *inv,
      const model_method *meth,
-     const std::list<ref_expression> &args)
+     const std::list<ref_expression> &args,
+     const ref_expression &finit)
 {
   // FIXME: duplicate code.
   model_class *accessed;
@@ -3261,6 +3262,9 @@
   handle_invocation (op_invokespecial, inv->get_qualifying_class (),
 		     meth, args, inv->get_expression () != NULL,
 		     nonstatic_accessor);
+
+  if (finit)
+    finit->visit (this);
 }
 
 void
Index: gcjx/bytecode/generate.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/generate.hh,v
retrieving revision 1.1.2.13
diff -u -r1.1.2.13 generate.hh
--- gcjx/bytecode/generate.hh 11 Oct 2005 05:36:13 -0000 1.1.2.13
+++ gcjx/bytecode/generate.hh 12 Oct 2005 00:43:39 -0000
@@ -496,7 +496,8 @@
 
   void visit_super_invocation (model_super_invocation *,
 			       const model_method *,
-			       const std::list<ref_expression> &);
+			       const std::list<ref_expression> &,
+			       const ref_expression &);
 
   void visit_this_invocation (model_this_invocation *,
 			      const model_method *,
Index: gcjx/model/invoke.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/invoke.cc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 invoke.cc
--- gcjx/model/invoke.cc 23 Apr 2005 06:09:34 -0000 1.1.2.4
+++ gcjx/model/invoke.cc 12 Oct 2005 00:43:39 -0000
@@ -555,10 +555,7 @@
 void
 model_super_invocation::visit (visitor *v)
 {
-  v->visit_super_invocation (this, method, arguments);
-  // Now separately visit the invocation.
-  if (finit)
-    finit->visit (v);
+  v->visit_super_invocation (this, method, arguments, finit);
 }
 
 
Index: gcc/java/tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.65
diff -u -r1.1.2.65 tree.cc
--- gcc/java/tree.cc 11 Oct 2005 23:04:19 -0000 1.1.2.65
+++ gcc/java/tree.cc 12 Oct 2005 00:43:48 -0000
@@ -2220,10 +2220,20 @@
 void
 tree_generator::visit_super_invocation (model_super_invocation *elt,
 					const model_method *meth,
-					const std::list<ref_expression> &args)
+					const std::list<ref_expression> &args,
+					const ref_expression &finit)
 {
   handle_invocation (meth, this_tree, args, true);
   annotate (current, elt);
+
+  if (finit)
+    {
+      tree save = current;
+      finit->visit (this);
+      current = build2 (COMPOUND_EXPR, TREE_TYPE (current), save, current);
+      TREE_SIDE_EFFECTS (current) = 1;
+      annotate (current, elt);
+    }
 }
 
 void
@@ -2249,7 +2259,7 @@
   gcc_builtins->lay_out_class (klassp);
   current
     = gcc_builtins->map_new (class_wrapper, klassp,
-			     const_cast<model_method *>(constructor),
+			     const_cast<model_method *> (constructor),
 			     arg_tree);
   if (compound != NULL_TREE)
     current = build2 (COMPOUND_EXPR, TREE_TYPE (current), compound, current);
Index: gcc/java/tree.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.hh,v
retrieving revision 1.1.2.18
diff -u -r1.1.2.18 tree.hh
--- gcc/java/tree.hh 11 Oct 2005 21:14:56 -0000 1.1.2.18
+++ gcc/java/tree.hh 12 Oct 2005 00:43:48 -0000
@@ -450,7 +450,8 @@
 
   void visit_super_invocation (model_super_invocation *,
 			       const model_method *,
-			       const std::list<ref_expression> &);
+			       const std::list<ref_expression> &,
+			       const ref_expression &);
 
   void visit_this_invocation (model_this_invocation *,
 			      const model_method *,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]