public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gcjx] Patch: FYI: minor inheritance cleanups
@ 2005-10-09 20:07 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2005-10-09 20:07 UTC (permalink / raw)
  To: Java Patch List

I'm checking this in on the gcjx branch.

While adding documentation I noticed a few places where a base class
had a public constructor.  I made these constructors protected
instead.  I also made this change to model_element; this required a
small workaround in the parser where we were making a dummy element
for error reporting -- instead we now make a dummy empty statement.

I also found one place where there was an unused class in the type
hierarchy.  I removed this class.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* model/element.hh (model_element): Constructor now protected.
	* source/parse.cc (compilation_unit): Make an empty statement,
	not a model_element, for error reporting.
	* model/binary.cc (resolve): Updated for removal of model_binary.
	* model/binary.hh (model_binary_base): Constructor now protected.
	(class model_binary): Removed.
	(class model_plus): Updated.
	(class model_arith_shift): Likewise.
	(class model_equality_comparison): Likewise.
	(class model_numeric_comparison): Likewise.
	(class model_logical_binary): Likewise.  Constructor now
	protected.
	* model/expr.hh (model_expression): Constructor now protected.
	* model/invoke.hh (model_invocation_base): Constructor now
	protected.
	* model/literal.hh (model_literal_base): Constructor now
	protected.
	* model/primitive.hh (model_primitive_base): Constructor now
	protected.
	(model_primitive): Likewise.
	* model/stmt.hh (model_stmt): Constructor now protected.
	* model/type.hh (model_type): Constructor now protected.
	* model/loop.hh (model_loop): Constructor now protected.
	* model/for.hh (model_for_base): Constructor now protected.

Index: model/binary.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/binary.cc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 binary.cc
--- model/binary.cc 13 Jan 2005 03:18:36 -0000 1.1.2.1
+++ model/binary.cc 9 Oct 2005 19:49:06 -0000
@@ -1,6 +1,6 @@
 // Binary operators.
 
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -203,7 +203,7 @@
 void
 model_plus::resolve (resolution_scope *scope)
 {
-  model_binary::resolve (scope);
+  model_binary_base::resolve (scope);
 
   model_type *t;
   model_type *strtype
@@ -310,7 +310,7 @@
 void
 model_arith_shift<OP, NAME>::resolve (resolution_scope *scope)
 {
-  model_binary::resolve (scope);
+  model_binary_base::resolve (scope);
   model_type *nt = unary_numeric_promotion (rhs);
   if (nt == NULL)
     throw rhs->error ("couldn't apply unary numeric promotion "
@@ -414,7 +414,7 @@
 void
 model_equality_comparison<OP, NAME>::resolve (resolution_scope *scope)
 {
-  model_binary::resolve (scope);
+  model_binary_base::resolve (scope);
   model_type *ltype = lhs->type ();
   model_type *rtype = rhs->type ();
 
@@ -481,7 +481,7 @@
 void
 model_numeric_comparison<OP, NAME>::resolve (resolution_scope *scope)
 {
-  model_binary::resolve (scope);
+  model_binary_base::resolve (scope);
 
   // FIXME: can't tell which argument was the problem.
   // Could give more precise error message.
@@ -499,7 +499,7 @@
 void
 model_logical_binary::resolve (resolution_scope *scope)
 {
-  model_binary::resolve (scope);
+  model_binary_base::resolve (scope);
   if (! boolean_conversion (lhs))
     throw lhs->error ("boolean type required as operand to %1")
       % get_name ();
Index: model/binary.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/binary.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 binary.hh
--- model/binary.hh 9 Oct 2005 18:18:06 -0000 1.1.2.2
+++ model/binary.hh 9 Oct 2005 19:49:06 -0000
@@ -38,13 +38,13 @@
     return lhs->constant_p () && rhs->constant_p ();
   }
 
-public:
-
   model_binary_base (const location &w)
     : model_expression (w)
   {
   }
 
+public:
+
   void set_lhs (const ref_expression &n)
   {
     lhs = n;
@@ -73,16 +73,6 @@
   }
 };
 
-class model_binary : public model_binary_base
-{
-public:
-
-  model_binary (const location &w)
-    : model_binary_base (w)
-  {
-  }
-};
-
 // This enum is used solely for mapping a binary operator to its name.
 typedef enum
   {
@@ -135,12 +125,12 @@
   }
 };
 
-class model_plus : public model_binary
+class model_plus : public model_binary_base
 {
 public:
 
   model_plus (const location &w)
-    : model_binary (w)
+    : model_binary_base (w)
   {
   }
 
@@ -194,12 +184,12 @@
 typedef model_bitwise_binary<&model_primitive_base::bxor, OP_XOR> model_xor;
 
 template<binary_function OP, operator_name NAME>
-class model_arith_shift : public model_binary
+class model_arith_shift : public model_binary_base
 {
 public:
 
   model_arith_shift (const location &w)
-    : model_binary (w)
+    : model_binary_base (w)
   {
   }
 
@@ -225,7 +215,7 @@
 
 
 template<comparator OP, operator_name NAME>
-class model_equality_comparison : public model_binary
+class model_equality_comparison : public model_binary_base
 {
 protected:
 
@@ -236,7 +226,7 @@
 public:
 
   model_equality_comparison (const location &w)
-    : model_binary (w),
+    : model_binary_base (w),
       promoted_type (NULL)
   {
   }
@@ -260,7 +250,7 @@
   model_notequal;
 
 template<comparator OP, operator_name NAME>
-class model_numeric_comparison : public model_binary
+class model_numeric_comparison : public model_binary_base
 {
 protected:
 
@@ -271,7 +261,7 @@
 public:
 
   model_numeric_comparison (const location &w)
-    : model_binary (w),
+    : model_binary_base (w),
       promoted_type (NULL)
   {
   }
@@ -302,19 +292,19 @@
   model_greaterthanequal;
 
 
-class model_logical_binary : public model_binary
+class model_logical_binary : public model_binary_base
 {
 protected:
   // Overloaded in subclasses to return name of operator.
   virtual const char *get_name () = 0;
 
-public:
-
   model_logical_binary (const location &w)
-    : model_binary (w)
+    : model_binary_base (w)
   {
   }
 
+public:
+
   void resolve (resolution_scope *);
 };
 
Index: model/element.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/element.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 element.hh
--- model/element.hh 7 Oct 2005 02:01:43 -0000 1.1.2.2
+++ model/element.hh 9 Oct 2005 19:49:06 -0000
@@ -55,8 +55,6 @@
   {
   }
 
-public:
-
   /// Constructor.
   /// @param w Location of this object in the source.
   model_element (const location &w)
@@ -65,6 +63,8 @@
   {
   }
 
+public:
+
   virtual ~model_element ()
   {
   }
Index: model/expr.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/expr.hh,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 expr.hh
--- model/expr.hh 13 Jan 2005 03:18:36 -0000 1.1.2.1
+++ model/expr.hh 9 Oct 2005 19:49:06 -0000
@@ -1,6 +1,6 @@
 // Represent an expression.
 
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -49,13 +49,13 @@
   /// constant.
   virtual bool compute_constant_p () = 0;
 
-public:
-
   model_expression (const location &w)
     : model_element (w)
   {
   }
 
+public:
+
   /// Determine whether or not this is a constant expression.  Note
   /// that "constant expression" is precisely defined; see the JLS for
   /// details.
Index: model/for.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/for.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 for.hh
--- model/for.hh 9 Oct 2005 18:18:06 -0000 1.1.2.2
+++ model/for.hh 9 Oct 2005 19:49:06 -0000
@@ -31,13 +31,13 @@
   // Body.
   ref_stmt body;
 
-public:
-
   model_for_base (const location &w)
     : model_loop (w)
   {
   }
 
+public:
+
   void set_body (const ref_stmt &b)
   {
     body = b;
Index: model/invoke.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/invoke.hh,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 invoke.hh
--- model/invoke.hh 13 Jan 2005 03:18:36 -0000 1.1.2.1
+++ model/invoke.hh 9 Oct 2005 19:49:06 -0000
@@ -80,8 +80,6 @@
   // A helper function that handles most of the steps of resolution.
   void handle_resolve (resolution_scope *, bool = false);
 
-public:
-
   model_invocation_base (const location &w)
     : model_expression (w),
       method (NULL),
@@ -90,6 +88,8 @@
   {
   }
 
+public:
+
   void set_method (const std::string &mname)
   {
     name = mname;
Index: model/literal.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/literal.hh,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 literal.hh
--- model/literal.hh 13 Jan 2005 03:18:36 -0000 1.1.2.1
+++ model/literal.hh 9 Oct 2005 19:49:06 -0000
@@ -1,6 +1,6 @@
 // Represent a literal.
 
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -31,7 +31,7 @@
     return true;
   }
 
-public:
+protected:
 
   model_literal_base (const location &w)
     : model_expression (w)
Index: model/loop.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/loop.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 loop.hh
--- model/loop.hh 9 Oct 2005 18:18:06 -0000 1.1.2.2
+++ model/loop.hh 9 Oct 2005 19:49:06 -0000
@@ -34,8 +34,6 @@
   // True if a reachable break statement was found.
   bool break_found;
 
-public:
-
   model_loop (const location &w)
     : model_stmt (w),
       continue_found (false),
@@ -43,6 +41,8 @@
   {
   }
 
+public:
+
   void continue_reached ()
   {
     continue_found = true;
Index: model/primitive.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/primitive.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 primitive.hh
--- model/primitive.hh 7 Oct 2005 02:01:43 -0000 1.1.2.2
+++ model/primitive.hh 9 Oct 2005 19:49:06 -0000
@@ -55,7 +55,7 @@
   // Pretty name of this type.
   const char *pretty_name;
 
-public:
+protected:
 
   model_primitive_base (char sig_char, const char *pname)
     : model_type (LOCATION_UNKNOWN),
@@ -64,6 +64,8 @@
     descriptor = std::string (1, sig_char);
   }
 
+public:
+
   bool primitive_p () const
   {
     return true;
@@ -263,13 +265,15 @@
 template<typename T, char sig_char>
 class model_primitive : public model_primitive_base
 {
-public:
+protected:
 
   model_primitive (const char *pname)
     : model_primitive_base (sig_char, pname)
   {
   }
 
+public:
+
   std::string to_string (const jvalue &val) const
   {
     return primitive_format ((T) val);
Index: model/stmt.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/stmt.hh,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 stmt.hh
--- model/stmt.hh 13 Jan 2005 03:18:36 -0000 1.1.2.1
+++ model/stmt.hh 9 Oct 2005 19:49:06 -0000
@@ -1,6 +1,6 @@
 // Represent a statement.
 
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -100,13 +100,13 @@
   friend bool compute_normal_completion (normal_completion_state &,
 					 std::list< owner<model_stmt> > &);
 
-public:
-
   model_stmt (const location &w)
     : model_element (w)
   {
   }
 
+public:
+
   /// This is called for a statement which is the target of a "break"
   /// statement.  It is used to indicate that the particular label
   /// that is the target of the "break" has been referenced.  The
Index: model/type.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/type.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 type.hh
--- model/type.hh 7 Oct 2005 02:01:43 -0000 1.1.2.2
+++ model/type.hh 9 Oct 2005 19:49:06 -0000
@@ -46,13 +46,13 @@
   {
   }
 
-public:
-
   model_type (const location &w)
     : model_element (w)
   {
   }
 
+public:
+
   std::string get_descriptor ()
   {
     if (descriptor.empty ())
Index: source/parse.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/source/Attic/parse.cc,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 parse.cc
--- source/parse.cc 3 Oct 2005 20:44:51 -0000 1.1.2.6
+++ source/parse.cc 9 Oct 2005 19:49:07 -0000
@@ -3134,10 +3134,10 @@
   token t = peek ();		// FIXME
   if (t == TOKEN_PACKAGE)
     {
+      assume (TOKEN_PACKAGE);
       // FIXME: we make a bogus new element just to hold the location
       // as an error target.
-      assume (TOKEN_PACKAGE);
-      ref_element loc (new model_element (t));
+      ref_empty loc (new model_empty (t));
       std::list<std::string> name (qualified_identifier ());
       require (TOKEN_SEMI);
       // It is simple enough to create the package now, and it means

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-09 20:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-09 20:07 [gcjx] Patch: FYI: minor inheritance cleanups Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).