PPL  1.2
Concrete_Expression_inlines.hh
Go to the documentation of this file.
1 /* Concrete_Expression class implementation: inline functions.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Concrete_Expression_inlines_hh
25 #define PPL_Concrete_Expression_inlines_hh 1
26 
27 namespace Parma_Polyhedra_Library {
28 
29 inline
32  : impl(implementation) {
33 }
34 
38  const Bounded_Integer_Type_Representation representation,
39  const Bounded_Integer_Type_Overflow overflow) {
40  Implementation impl;
41  impl.bounded_integer = true;
42  impl.bounded_integer_type_width = width;
43  impl.bounded_integer_type_representation = representation;
44  impl.bounded_integer_type_overflow = overflow;
45  // Arbitrary choice to ensure determinism.
47  return Concrete_Expression_Type(impl);
48 }
49 
53  Implementation impl;
54  impl.bounded_integer = false;
55  impl.floating_point_format = format;
56  // Arbitrary choices to ensure determinism.
60  return Concrete_Expression_Type(impl);
61 }
62 
63 inline bool
65  return impl.bounded_integer;
66 }
67 
68 inline bool
70  return !impl.bounded_integer;
71 }
72 
75  const unsigned int u = impl.bounded_integer_type_width;
76  return static_cast<Bounded_Integer_Type_Width>(u);
77 }
78 
81  const unsigned int u = impl.bounded_integer_type_representation;
82  return static_cast<Bounded_Integer_Type_Representation>(u);
83 }
84 
87  const unsigned int u = impl.bounded_integer_type_overflow;
88  return static_cast<Bounded_Integer_Type_Overflow>(u);
89 }
90 
93  const unsigned int u = impl.floating_point_format;
94  return static_cast<Floating_Point_Format>(u);
95 }
96 
97 template <typename Target>
98 template <template <typename T> class Derived>
99 inline bool
101  return static_cast<const Concrete_Expression<Target>*>(this)->kind() ==
102  Derived<Target>::KIND;
103 }
104 
105 template <typename Target>
106 template <template <typename T> class Derived>
107 inline Derived<Target>*
109  PPL_ASSERT(is<Derived>());
110  return static_cast<Derived<Target>*>(this);
111 }
112 
113 template <typename Target>
114 template <template <typename T> class Derived>
115 inline const Derived<Target>*
117  PPL_ASSERT(is<Derived>());
118  return static_cast<const Derived<Target>*>(this);
119 }
120 
121 } // namespace Parma_Polyhedra_Library
122 
123 #endif // !defined(PPL_Concrete_Expression_inlines_hh)
bool is_bounded_integer() const
Returns true if and only if *this is a bounded integer type.
bool is() const
Tests if *this has the same kind as Derived.
Bounded_Integer_Type_Overflow bounded_integer_type_overflow() const
Returns the overflow behavior of the bounded integer type encoded by *this.
IEEE 754 half precision, 16 bits (5 exponent, 10 mantissa).
Concrete_Expression_Type(Implementation implementation)
Constructor from implementation.
Bounded_Integer_Type_Width bounded_integer_type_width() const
Returns the width in bits of the bounded integer type encoded by *this.
Bounded_Integer_Type_Representation bounded_integer_type_representation() const
Returns the representation of the bounded integer type encoded by *this.
static Concrete_Expression_Type bounded_integer(Bounded_Integer_Type_Width width, Bounded_Integer_Type_Representation representation, Bounded_Integer_Type_Overflow overflow)
Returns the bounded integer type corresponding to width, representation and overflow.
bool is_floating_point() const
Returns true if and only if *this is a floating point type.
The base class of all concrete expressions.
static Concrete_Expression_Type floating_point(Floating_Point_Format format)
Returns the floating point type corresponding to format.
The entire library is confined to this namespace.
Definition: version.hh:61
Signed binary where negative values are represented by the two's complement of the absolute value...
Derived< Target > * as()
Returns a pointer to *this converted to type Derived*.
Floating_Point_Format floating_point_format() const
Returns the format of the floating point type encoded by *this.