[PPL-devel] [GIT] ppl/ppl(floating_point): Some progress in the definition of the classes.
Roberto Bagnara
bagnara at cs.unipr.it
Sun Jul 4 16:56:21 CEST 2010
Module: ppl/ppl
Branch: floating_point
Commit: df824f255b127832cf64d21ee9cd4b4cef9bdbc2
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=df824f255b127832cf64d21ee9cd4b4cef9bdbc2
Author: Roberto Bagnara <bagnara at cs.unipr.it>
Date: Sun Jul 4 16:56:01 2010 +0200
Some progress in the definition of the classes.
---
src/Concrete_Expression.defs.hh | 16 +++++++
src/Concrete_Expression.types.hh | 17 ++++++++
tests/Concrete_Expression/C_Expr.defs.hh | 58 +++++++++++++++++++++++----
tests/Concrete_Expression/C_Expr.inlines.hh | 17 ++++++++
4 files changed, 100 insertions(+), 8 deletions(-)
diff --git a/src/Concrete_Expression.defs.hh b/src/Concrete_Expression.defs.hh
index 2666d2b..f013170 100644
--- a/src/Concrete_Expression.defs.hh
+++ b/src/Concrete_Expression.defs.hh
@@ -30,6 +30,7 @@ namespace Parma_Polyhedra_Library {
template <typename Target>
class Concrete_Expression_Base {
+public:
//! Returns the type of \* this.
Concrete_Expression_Type type() const;
@@ -39,10 +40,25 @@ class Concrete_Expression_Base {
template <typename Target>
class Binary_Operator_Base : public Concrete_Expression<Target> {
+public:
+ //! Returns a constant identifying the operator of \p *this.
+ int get_bop() const;
+
+ //! Returns the left-hand side of \p *this.
+ const Concrete_Expression<Target>* get_lhs() const;
+
+ //! Returns the right-hand side of \p *this.
+ const Concrete_Expression<Target>* get_rhs() const;
};
template <typename Target>
class Unary_Operator_Base : public Concrete_Expression<Target> {
+public:
+ //! Returns a constant identifying the operator of \p *this.
+ int get_uop() const;
+
+ //! Returns the argument \p *this.
+ const Concrete_Expression<Target>* get_arg() const;
};
template <typename Target>
diff --git a/src/Concrete_Expression.types.hh b/src/Concrete_Expression.types.hh
index 6fe20eb..3f10c23 100644
--- a/src/Concrete_Expression.types.hh
+++ b/src/Concrete_Expression.types.hh
@@ -63,6 +63,23 @@ enum Concrete_Expression_Type {
*/
typedef int Concrete_Expression_Kind;
+/*! \brief
+ Encodes a binary operator of concrete expressions.
+
+ The values should be uniquely defined by the particular instance and
+ named: PLUS, MINUS, TIMES, DIV, REM, BAND, BOR, BXOR, LSHIFT,
+ RSHIFT.
+*/
+typedef int Concrete_Expression_BOP;
+
+/*! \brief
+ Encodes a unary operator of concrete expressions.
+
+ The values should be uniquely defined by the particular instance and
+ named: UPLUS, UMINUS, BNOT.
+*/
+typedef int Concrete_Expression_UOP;
+
} // namespace Parma_Polyhedra_Library
#endif // !defined(PPL_Concrete_Expression_types_hh)
diff --git a/tests/Concrete_Expression/C_Expr.defs.hh b/tests/Concrete_Expression/C_Expr.defs.hh
index 95042a7..05c2311 100644
--- a/tests/Concrete_Expression/C_Expr.defs.hh
+++ b/tests/Concrete_Expression/C_Expr.defs.hh
@@ -39,19 +39,43 @@ class C_Expr {
class Bin_Op : public C_Expr {
public:
+ //! Constructor from operator, lhs and rhs.
+ Bin_Op(Concrete_Expression_BOP binary_operator,
+ const C_Expr* left_hand_side, const C_Expr* right_hand_side);
+
+ //! Do-nothing destructor.
+ ~Bin_Op();
+
//! 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;
+
//! Returns the left-hand side of \p *this.
const C_Expr* left_hand_side() const;
//! Returns the right-hand side of \p *this.
const C_Expr* right_hand_side() const;
+ static const Concrete_Expression_BOP PLUS = 0;
+ static const Concrete_Expression_BOP MINUS = 1;
+ static const Concrete_Expression_BOP TIMES = 2;
+ static const Concrete_Expression_BOP DIV = 3;
+ static const Concrete_Expression_BOP REM = 4;
+ static const Concrete_Expression_BOP BAND = 5;
+ static const Concrete_Expression_BOP BOR = 6;
+ static const Concrete_Expression_BOP BXOR = 7;
+ static const Concrete_Expression_BOP LSHIFT = 8;
+ static const Concrete_Expression_BOP RSHIFT = 9;
+
private:
+ //! The operator of \p *this.
+ const Concrete_Expression_BOP bop;
+
//! The left-hand side of \p *this.
const C_Expr* lhs;
@@ -60,6 +84,31 @@ private:
};
class Un_Op : public C_Expr {
+ //! Constructor from operator, lhs and rhs.
+ Un_Op(Concrete_Expression_UOP unary_operator, const C_Expr* argument);
+
+ //! Do-nothing destructor.
+ ~Un_Op();
+
+ //! Returns the type of \p *this.
+ Concrete_Expression_Type type() const;
+
+ //! Returns the kind of \p *this.
+ Concrete_Expression_Kind kind() const;
+
+ //! Returns the argument of \p *this.
+ const C_Expr* argument() const;
+
+ static const Concrete_Expression_UOP UPLUS = 0;
+ static const Concrete_Expression_UOP UMINUS = 1;
+ static const Concrete_Expression_UOP BNOT = 2;
+
+private:
+ //! The operator of \p *this.
+ const Concrete_Expression_UOP uop;
+
+ //! The argument of \p *this.
+ const C_Expr* arg;
};
class Cast_Op : public C_Expr {
@@ -104,14 +153,6 @@ private:
typedef Exposed_To_Underlying<PPL_C_Expr,
Concrete_Expression<PPL_C_Expr> >::Type
Underlying;
-
-public:
-#if 0
- template <typename T>
- static bool classof(const T* expr) {
- return Underlying::classof(underlying(expr));
- }
-#endif
};
template <>
@@ -125,6 +166,7 @@ public:
} // namespace Parma_Polyhedra_Library
+#include "Concrete_Expression.defs.hh"
#include "C_Expr.inlines.hh"
//#include "C_Expr.templates.hh"
diff --git a/tests/Concrete_Expression/C_Expr.inlines.hh b/tests/Concrete_Expression/C_Expr.inlines.hh
index 47f35b5..69ffcd0 100644
--- a/tests/Concrete_Expression/C_Expr.inlines.hh
+++ b/tests/Concrete_Expression/C_Expr.inlines.hh
@@ -25,6 +25,23 @@ site: http://www.cs.unipr.it/ppl/ . */
namespace Parma_Polyhedra_Library {
+inline
+Bin_Op::Bin_Op(Concrete_Expression_BOP binary_operator,
+ const C_Expr* left_hand_side, const C_Expr* right_hand_side)
+ : bop(binary_operator),
+ lhs(left_hand_side),
+ rhs(right_hand_side) {
+}
+
+inline
+Bin_Op::~Bin_Op() {
+}
+
+inline Concrete_Expression_BOP
+Bin_Op:: binary_operator() const {
+ return bop;
+}
+
inline const C_Expr*
Bin_Op::left_hand_side() const {
return lhs;
More information about the PPL-devel
mailing list