[PPL-devel] [GIT] ppl/ppl(floating_point): Improved inheritance relations.

Abramo Bagnara abramo.bagnara at gmail.com
Tue Jul 27 14:07:52 CEST 2010


Module: ppl/ppl
Branch: floating_point
Commit: 90eaae7fe8a19eccdd7bac2763131a20ecaf616f
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=90eaae7fe8a19eccdd7bac2763131a20ecaf616f

Author: Abramo Bagnara <abramo.bagnara at gmail.com>
Date:   Tue Jul 27 14:07:38 2010 +0200

Improved inheritance relations.

---

 src/Concrete_Expression.defs.hh             |   14 ++++----
 tests/Concrete_Expression/C_Expr.defs.hh    |   40 +++++++++----------------
 tests/Concrete_Expression/C_Expr.inlines.hh |   42 +++++---------------------
 3 files changed, 29 insertions(+), 67 deletions(-)

diff --git a/src/Concrete_Expression.defs.hh b/src/Concrete_Expression.defs.hh
index 217e239..88fbca8 100644
--- a/src/Concrete_Expression.defs.hh
+++ b/src/Concrete_Expression.defs.hh
@@ -116,7 +116,7 @@ private:
 };
 
 template <typename Target>
-class Concrete_Expression_Base {
+class Concrete_Expression_Common {
 public:
   //! Returns the type of \* this.
   Concrete_Expression_Type type() const;
@@ -126,7 +126,7 @@ public:
 };
 
 template <typename Target>
-class Binary_Operator_Base : public Concrete_Expression<Target> {
+class Binary_Operator_Common {
 public:
   //! Returns a constant identifying the operator of \p *this.
   Concrete_Expression_BOP binary_operator() const;
@@ -139,7 +139,7 @@ public:
 };
 
 template <typename Target>
-class Unary_Operator_Base : public Concrete_Expression<Target> {
+class Unary_Operator_Common {
 public:
   //! Returns a constant identifying the operator of \p *this.
   Concrete_Expression_UOP unary_operator() const;
@@ -149,17 +149,17 @@ public:
 };
 
 template <typename Target>
-class Cast_Operator_Base : public Concrete_Expression<Target> {
+class Cast_Operator_Common {
   //! Returns the casted expression.
   const Concrete_Expression<Target>* argument() const;
 };
 
 template <typename Target>
-class Integer_Constant_Base : public Concrete_Expression<Target> {
+class Integer_Constant_Common {
 };
 
 template <typename Target>
-class Floating_Point_Constant_Base : public Concrete_Expression<Target> {
+class Floating_Point_Constant_Common {
   /*! \brief
     Returns a string for the floating point constant as written
     in the analyzed program.
@@ -168,7 +168,7 @@ class Floating_Point_Constant_Base : public Concrete_Expression<Target> {
 };
 
 template <typename Target>
-class Approximable_Reference_Base : public Concrete_Expression<Target> {
+class Approximable_Reference_Common {
 public:
   /*! \brief
     If \p *this is a variable reference, returns the variable's
diff --git a/tests/Concrete_Expression/C_Expr.defs.hh b/tests/Concrete_Expression/C_Expr.defs.hh
index 1e2336e..96bc1cd 100644
--- a/tests/Concrete_Expression/C_Expr.defs.hh
+++ b/tests/Concrete_Expression/C_Expr.defs.hh
@@ -39,7 +39,7 @@ enum C_Expr_Kind {
 };
 
 template <>
-class Concrete_Expression<C_Expr> : public Concrete_Expression_Base<C_Expr> {
+class Concrete_Expression<C_Expr> : public Concrete_Expression_Common<C_Expr> {
 public:
   //! Builds a concrete expression of the given kind.
   Concrete_Expression<C_Expr>(C_Expr_Kind KIND);
@@ -48,14 +48,15 @@ public:
   Concrete_Expression_Type type() const;
 
   //! Returns the kind of \* this.
-  virtual Concrete_Expression_Kind kind() const = 0;
+  Concrete_Expression_Kind kind() const;
 private:
   //! The expression's kind.
   C_Expr_Kind expr_kind;
 };
 
 template <>
-class Binary_Operator<C_Expr> : public Binary_Operator_Base<C_Expr> {
+class Binary_Operator<C_Expr> : public Concrete_Expression<C_Expr>,
+                                public Binary_Operator_Common<C_Expr> {
 public:
   //! Constructor from operator, lhs and rhs.
   Binary_Operator<C_Expr>(Concrete_Expression_BOP binary_operator,
@@ -68,9 +69,6 @@ public:
   //! Returns the type of \p *this.
   Concrete_Expression_Type type() const;
 
-  //! Returns the kind of \p *this.
-  Concrete_Expression_Kind kind() const;
-
   //! Returns the binary operator of \p *this.
   Concrete_Expression_BOP binary_operator() const;
 
@@ -111,7 +109,8 @@ private:
 };
 
 template <>
-class Unary_Operator<C_Expr> : public Unary_Operator_Base<C_Expr> {
+class Unary_Operator<C_Expr> : public Concrete_Expression<C_Expr>,
+                               public Unary_Operator_Common<C_Expr> {
 public:
   //! Constructor from operator and argument.
   Unary_Operator<C_Expr>(Concrete_Expression_UOP unary_operator,
@@ -123,9 +122,6 @@ public:
   //! Returns the type of \p *this.
   Concrete_Expression_Type type() const;
 
-  //! Returns the kind of \p *this.
-  Concrete_Expression_Kind kind() const;
-
   //! Returns the unary operator of \p *this.
   Concrete_Expression_UOP unary_operator() const;
 
@@ -154,7 +150,8 @@ private:
 
 template <>
 class Cast_Operator<C_Expr>
-  : public Cast_Operator_Base<C_Expr> {
+  : public Concrete_Expression<C_Expr>,
+    public Cast_Operator_Common<C_Expr> {
 public:
   //! Constructor from cast type and argument.
   Cast_Operator<C_Expr>(Concrete_Expression_Type c_type,
@@ -166,9 +163,6 @@ public:
   //! Returns the type of \p *this.
   Concrete_Expression_Type type() const;
 
-  //! Returns the kind of \p *this.
-  Concrete_Expression_Kind kind() const;
-
   //! Returns the casted expression.
   const Concrete_Expression<C_Expr>* argument() const;
 
@@ -185,7 +179,8 @@ private:
 
 template <>
 class Integer_Constant<C_Expr>
-  : public Integer_Constant_Base<C_Expr> {
+  : public Concrete_Expression<C_Expr>,
+    public Integer_Constant_Common<C_Expr> {
 public:
   //! Do-nothing destructor.
   ~Integer_Constant<C_Expr>();
@@ -193,16 +188,14 @@ public:
   //! Returns the type of \p *this.
   Concrete_Expression_Type type() const;
 
-  //! Returns the kind of \p *this.
-  Concrete_Expression_Kind kind() const;
-
   //! Constant identifying integer constant nodes.
   enum { KIND = INT_CON };
 };
 
 template <>
 class Floating_Point_Constant<C_Expr>
-  : public Floating_Point_Constant_Base<C_Expr> {
+  : public Concrete_Expression<C_Expr>,
+    public Floating_Point_Constant_Common<C_Expr> {
 public:
   //! Constructor from value.
   Floating_Point_Constant<C_Expr>(const char* value_string,
@@ -214,9 +207,6 @@ public:
   //! Returns the type of \p *this.
   Concrete_Expression_Type type() const;
 
-  //! Returns the kind of \p *this.
-  Concrete_Expression_Kind kind() const;
-
   /*! \brief
     Returns a string for the floating point constant as written
     in the analyzed program.
@@ -234,7 +224,8 @@ private:
 // We currently only consider references to floating point variables.
 template <>
 class Approximable_Reference<C_Expr>
-  : public Approximable_Reference_Base<C_Expr> {
+  : public Concrete_Expression<C_Expr>,
+    public Approximable_Reference_Common<C_Expr> {
 public:
   //! Builds a reference to the variable having the given index.
   Approximable_Reference<C_Expr>(dimension_type var_index);
@@ -245,9 +236,6 @@ public:
   //! Returns the type of \p *this.
   Concrete_Expression_Type type() const;
 
-  //! Returns the kind of \p *this.
-  Concrete_Expression_Kind kind() const;
-
   /*! \brief
     If \p *this is a variable reference, returns the variable's
     index. Returns <CODE>not_a_dimension()</CODE> otherwise.
diff --git a/tests/Concrete_Expression/C_Expr.inlines.hh b/tests/Concrete_Expression/C_Expr.inlines.hh
index 819de51..232d38c 100644
--- a/tests/Concrete_Expression/C_Expr.inlines.hh
+++ b/tests/Concrete_Expression/C_Expr.inlines.hh
@@ -41,7 +41,8 @@ Binary_Operator<C_Expr>
 ::Binary_Operator(Concrete_Expression_BOP binary_operator,
                   const Concrete_Expression<C_Expr>* left_hand_side,
                   const Concrete_Expression<C_Expr>* right_hand_side)
-  : bop(binary_operator),
+  : Concrete_Expressione<C_Expr>(BOP),
+    bop(binary_operator),
     lhs(left_hand_side),
     rhs(right_hand_side) {
 }
@@ -55,11 +56,6 @@ Binary_Operator<C_Expr>::type() const {
   return Concrete_Expression_Type::floating_point(ANALYZED_FP_FORMAT);
 }
 
-inline Concrete_Expression_Kind
-Binary_Operator<C_Expr>::kind() const {
-  return KIND;
-}
-
 inline Concrete_Expression_BOP
 Binary_Operator<C_Expr>::binary_operator() const {
   return bop;
@@ -79,7 +75,8 @@ inline
 Unary_Operator<C_Expr>
 ::Unary_Operator(Concrete_Expression_UOP unary_operator,
                  const Concrete_Expression<C_Expr>* argument)
-  : uop(unary_operator),
+  : Concrete_Expressione<C_Expr>(UOP),
+    uop(unary_operator),
     arg(argument) {
 }
 
@@ -92,11 +89,6 @@ Unary_Operator<C_Expr>::type() const {
   return Concrete_Expression_Type::floating_point(ANALYZED_FP_FORMAT);
 }
 
-inline Concrete_Expression_Kind
-Unary_Operator<C_Expr>::kind() const {
-  return KIND;
-}
-
 inline Concrete_Expression_BOP
 Unary_Operator<C_Expr>::unary_operator() const {
   return uop;
@@ -111,7 +103,8 @@ inline
 Cast_Operator<C_Expr>::
 Cast_Operator(Concrete_Expression_Type c_type,
               const Concrete_Expression<C_Expr>* ar)
-  : cast_type(c_type),
+  : Concrete_Expressione<C_Expr>(CAST),
+    cast_type(c_type),
     arg(ar) {
 }
 
@@ -124,11 +117,6 @@ Cast_Operator<C_Expr>::type() const {
   return cast_type;
 }
 
-inline Concrete_Expression_Kind
-Cast_Operator<C_Expr>::kind() const {
-  return KIND;
-}
-
 inline const Concrete_Expression<C_Expr>*
 Cast_Operator<C_Expr>::argument() const {
   return arg;
@@ -138,16 +126,12 @@ inline
 Integer_Constant<C_Expr>::~Integer_Constant<C_Expr>() {
 }
 
-inline Concrete_Expression_Kind
-Integer_Constant<C_Expr>::kind() const {
-  return KIND;
-}
-
 inline
 Floating_Point_Constant<C_Expr>::
 Floating_Point_Constant(const char* value_string,
                         const unsigned int string_size)
-  : value(new char[string_size]) {
+  : Concrete_Expressione<C_Expr>(FP_CON),
+    value(new char[string_size]) {
   strcpy(value, value_string);
 }
 
@@ -161,11 +145,6 @@ Floating_Point_Constant<C_Expr>::type() const {
   return Concrete_Expression_Type::floating_point(ANALYZED_FP_FORMAT);
 }
 
-inline Concrete_Expression_Kind
-Floating_Point_Constant<C_Expr>::kind() const {
-  return KIND;
-}
-
 inline const char*
 Floating_Point_Constant<C_Expr>::get_value_as_string() const {
   return value;
@@ -186,11 +165,6 @@ Approximable_Reference<C_Expr>::type() const {
   return Concrete_Expression_Type::floating_point(ANALYZED_FP_FORMAT);
 }
 
-inline Concrete_Expression_Kind
-Approximable_Reference<C_Expr>::kind() const {
-  return KIND;
-}
-
 inline dimension_type
 Approximable_Reference<C_Expr>::associated_dimension() const {
   return var_dimension;




More information about the PPL-devel mailing list