[PPL-devel] [GIT] ppl/ppl(floating_point): Concrete_Expression:

Fabio Bossi bossi at cs.unipr.it
Mon Jul 26 15:24:05 CEST 2010


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

Author: Fabio Bossi <bossi at cs.unipr.it>
Date:   Mon Jul 26 15:22:50 2010 +0200

Concrete_Expression:
  - Added method associated_dimension().

C_Expr:
  - Small progress in the implementation.

---

 src/Concrete_Expression.defs.hh             |    6 +++++
 tests/Concrete_Expression/C_Expr.defs.hh    |   30 ++++++++++++++++++++++++--
 tests/Concrete_Expression/C_Expr.inlines.hh |   25 ++++++++++++++++++++++
 3 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/src/Concrete_Expression.defs.hh b/src/Concrete_Expression.defs.hh
index 0442195..f6777cd 100644
--- a/src/Concrete_Expression.defs.hh
+++ b/src/Concrete_Expression.defs.hh
@@ -162,6 +162,12 @@ class Floating_Point_Constant_Base : public Concrete_Expression<Target> {
 
 template <typename Target>
 class Approximable_Reference_Base : public Concrete_Expression<Target> {
+public:
+  /*! \brief
+    If \p *this is a variable reference, returns the variable's
+    index. Returns <CODE>not_a_dimension()</CODE> otherwise.
+  */
+  dimension_type associated_dimension() const;
 };
 
 } // namespace Parma_Polyhedra_Library
diff --git a/tests/Concrete_Expression/C_Expr.defs.hh b/tests/Concrete_Expression/C_Expr.defs.hh
index 2d7b4c2..41c2053 100644
--- a/tests/Concrete_Expression/C_Expr.defs.hh
+++ b/tests/Concrete_Expression/C_Expr.defs.hh
@@ -54,10 +54,10 @@ public:
   Concrete_Expression_Type type() const;
 
   //! Returns the kind of \p *this.
-  int kind() const;
+  Concrete_Expression_Kind kind() const;
 
   //! Returns the binary operator of \p *this.
-  int binary_operator() const;
+  Concrete_Expression_BOP binary_operator() const;
 
   //! Returns the left-hand side of \p *this.
   const Concrete_Expression<C_Expr>* left_hand_side() const;
@@ -97,6 +97,7 @@ private:
 
 template <>
 class Unary_Operator<C_Expr> : public Unary_Operator_Base<C_Expr> {
+public:
   //! Constructor from operator and argument.
   Unary_Operator<C_Expr>(int unary_operator,
                          const Concrete_Expression<C_Expr>* argument);
@@ -111,7 +112,7 @@ class Unary_Operator<C_Expr> : public Unary_Operator_Base<C_Expr> {
   Concrete_Expression_Kind kind() const;
 
   //! Returns the unary operator of \p *this.
-  int unary_operator() const;
+  Concrete_Expression_UOP unary_operator() const;
 
   //! Returns the argument of \p *this.
   const Concrete_Expression<C_Expr>* argument() const;
@@ -160,12 +161,35 @@ public:
   enum { KIND = 5 };
 };
 
+// We currently only consider variable references.
 template <>
 class Approximable_Reference<C_Expr>
   : public Approximable_Reference_Base<C_Expr> {
 public:
+  //! Builds a reference to the variable having the given index.
+  Approximable_Reference<C_Expr>(dimension_type var_index);
+
+  //! Do-nothing destructor.
+  ~Approximable_Reference<C_Expr>();
+
+  //! 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.
+  */
+  dimension_type associated_dimension() const;
+
   //! Constant identifying approximable reference nodes.
   enum { KIND = 6 };
+
+private:
+  //! The index of the referenced variable.
+  dimension_type var_dimension;
 };
 
 } // namespace Parma_Polyhedra_Library
diff --git a/tests/Concrete_Expression/C_Expr.inlines.hh b/tests/Concrete_Expression/C_Expr.inlines.hh
index 41fef95..f92c79f 100644
--- a/tests/Concrete_Expression/C_Expr.inlines.hh
+++ b/tests/Concrete_Expression/C_Expr.inlines.hh
@@ -39,6 +39,11 @@ inline
 Binary_Operator<C_Expr>::~Binary_Operator<C_Expr>() {
 }
 
+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;
@@ -66,6 +71,11 @@ inline
 Unary_Operator<C_Expr>::~Unary_Operator<C_Expr>() {
 }
 
+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;
@@ -76,6 +86,21 @@ Unary_Operator<C_Expr>::argument() const {
   return arg;
 }
 
+inline
+Approximable_Reference<C_Expr>::
+Approximable_Reference(dimension_type var_index)
+: var_dimension(var_index) {
+}
+
+inline
+Approximable_Reference<C_Expr>::~Approximable_Reference<C_Expr>() {
+}
+
+inline Concrete_Expression_Kind
+Approximable_Reference<C_Expr>::kind() const {
+  return KIND;
+}
+
 } // namespace Parma_Polyhedra_Library
 
 #endif // !defined(PPL_C_Expr_inlines_hh)




More information about the PPL-devel mailing list