[GIT] ppl/ppl(floating_point): Various changes.
Module: ppl/ppl Branch: floating_point Commit: 0ec45a70db9cc1e9829e04477ea0f3b2cc7c701d URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=0ec45a70db9cc... Author: Fabio Bossi <bossi@cs.unipr.it> Date: Tue Jul 27 12:53:04 2010 +0200 Various changes. --- tests/Concrete_Expression/C_Expr.defs.hh | 40 +++++++++++++++++++-------- tests/Concrete_Expression/C_Expr.inlines.hh | 17 +++++++++--- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/tests/Concrete_Expression/C_Expr.defs.hh b/tests/Concrete_Expression/C_Expr.defs.hh index 039d97f..1e2336e 100644 --- a/tests/Concrete_Expression/C_Expr.defs.hh +++ b/tests/Concrete_Expression/C_Expr.defs.hh @@ -29,21 +29,36 @@ namespace Parma_Polyhedra_Library { struct C_Expr; +enum C_Expr_Kind { + BOP, + UOP, + CAST, + INT_CON, + FP_CON, + APPROX_REF +}; + template <> class Concrete_Expression<C_Expr> : public Concrete_Expression_Base<C_Expr> { public: + //! Builds a concrete expression of the given kind. + Concrete_Expression<C_Expr>(C_Expr_Kind KIND); + //! Returns the type of \* this. Concrete_Expression_Type type() const; //! Returns the kind of \* this. virtual Concrete_Expression_Kind kind() const = 0; +private: + //! The expression's kind. + C_Expr_Kind expr_kind; }; template <> class Binary_Operator<C_Expr> : public Binary_Operator_Base<C_Expr> { public: //! Constructor from operator, lhs and rhs. - Binary_Operator<C_Expr>(int binary_operator, + Binary_Operator<C_Expr>(Concrete_Expression_BOP binary_operator, const Concrete_Expression<C_Expr>* left_hand_side, const Concrete_Expression<C_Expr>* right_hand_side); @@ -67,7 +82,7 @@ public: //! Constant identifying binary operator nodes. enum { - KIND = 1 + KIND = BOP }; //! Constants encoding the different binary operators. @@ -86,7 +101,7 @@ public: private: //! The operator of \p *this. - const int bop; + const Concrete_Expression_BOP bop; //! The left-hand side of \p *this. const Concrete_Expression<C_Expr>* lhs; @@ -99,7 +114,7 @@ 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, + Unary_Operator<C_Expr>(Concrete_Expression_UOP unary_operator, const Concrete_Expression<C_Expr>* argument); //! Do-nothing destructor. @@ -119,7 +134,7 @@ public: //! Constant identifying unary operator nodes. enum { - KIND = 2 + KIND = UOP }; //! Constants encoding the different unary operators. @@ -131,7 +146,7 @@ public: private: //! The operator of \p *this. - const int uop; + const Concrete_Expression_UOP uop; //! The argument of \p *this. const Concrete_Expression<C_Expr>* arg; @@ -158,7 +173,7 @@ public: const Concrete_Expression<C_Expr>* argument() const; //! Constant identifying cast nodes. - enum { KIND = 3 }; + enum { KIND = CAST }; private: //! The type of the cast expression. @@ -182,7 +197,7 @@ public: Concrete_Expression_Kind kind() const; //! Constant identifying integer constant nodes. - enum { KIND = 4 }; + enum { KIND = INT_CON }; }; template <> @@ -190,7 +205,8 @@ class Floating_Point_Constant<C_Expr> : public Floating_Point_Constant_Base<C_Expr> { public: //! Constructor from value. - Floating_Point_Constant<C_Expr>(const char* value_string); + Floating_Point_Constant<C_Expr>(const char* value_string, + unsigned int string_size); //! Do-nothing destructor. ~Floating_Point_Constant<C_Expr>(); @@ -208,11 +224,11 @@ public: const char* get_value_as_string() const; //! Constant identifying floating constant nodes. - enum { KIND = 5 }; + enum { KIND = FP_CON }; private: //! The floating point constant as written. - const char* value; + char* value; }; // We currently only consider references to floating point variables. @@ -239,7 +255,7 @@ public: dimension_type associated_dimension() const; //! Constant identifying approximable reference nodes. - enum { KIND = 6 }; + enum { KIND = APPROX_REF }; private: //! The index of the referenced variable. diff --git a/tests/Concrete_Expression/C_Expr.inlines.hh b/tests/Concrete_Expression/C_Expr.inlines.hh index 689fe29..819de51 100644 --- a/tests/Concrete_Expression/C_Expr.inlines.hh +++ b/tests/Concrete_Expression/C_Expr.inlines.hh @@ -25,6 +25,12 @@ site: http://www.cs.unipr.it/ppl/ . */ namespace Parma_Polyhedra_Library { +inline +Concrete_Expression<C_Expr>:: +Concrete_Expression(const C_Expr_Kind KIND) + : expr_kind(KIND) { +} + inline Concrete_Expression_Type Concrete_Expression<C_Expr>::type() const { return Concrete_Expression_Type::floating_point(ANALYZED_FP_FORMAT); @@ -32,7 +38,7 @@ Concrete_Expression<C_Expr>::type() const { inline Binary_Operator<C_Expr> -::Binary_Operator(int binary_operator, +::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), @@ -71,7 +77,7 @@ Binary_Operator<C_Expr>::right_hand_side() const { inline Unary_Operator<C_Expr> -::Unary_Operator(int unary_operator, +::Unary_Operator(Concrete_Expression_UOP unary_operator, const Concrete_Expression<C_Expr>* argument) : uop(unary_operator), arg(argument) { @@ -139,12 +145,15 @@ Integer_Constant<C_Expr>::kind() const { inline Floating_Point_Constant<C_Expr>:: -Floating_Point_Constant(const char* value_string) - : value(value_string) { +Floating_Point_Constant(const char* value_string, + const unsigned int string_size) + : value(new char[string_size]) { + strcpy(value, value_string); } inline Floating_Point_Constant<C_Expr>::~Floating_Point_Constant<C_Expr>() { + delete[] value; } inline Concrete_Expression_Type
participants (1)
-
Fabio Bossi