PPL  1.2
Determinate_inlines.hh
Go to the documentation of this file.
1 /* Determinate 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_Determinate_inlines_hh
25 #define PPL_Determinate_inlines_hh 1
26 
27 #include "assertions.hh"
28 
29 namespace Parma_Polyhedra_Library {
30 
31 template <typename PSET>
32 inline
34  Degenerate_Element kind)
35  : references(0), pset(num_dimensions, kind) {
36 }
37 
38 template <typename PSET>
39 inline
41  : references(0), pset(p) {
42 }
43 
44 template <typename PSET>
45 inline
47  : references(0), pset(cs) {
48 }
49 
50 template <typename PSET>
51 inline
53  : references(0), pset(cgs) {
54 }
55 
56 template <typename PSET>
57 inline
59  PPL_ASSERT(references == 0);
60 }
61 
62 template <typename PSET>
63 inline void
65  ++references;
66 }
67 
68 template <typename PSET>
69 inline bool
71  return --references == 0;
72 }
73 
74 template <typename PSET>
75 inline bool
77  return references > 1;
78 }
79 
80 template <typename PSET>
81 inline memory_size_type
83  return pset.external_memory_in_bytes();
84 }
85 
86 template <typename PSET>
87 inline memory_size_type
89  return sizeof(*this) + external_memory_in_bytes();
90 }
91 
92 template <typename PSET>
93 inline
95  : prep(new Rep(pset)) {
97 }
98 
99 template <typename PSET>
100 inline
102  : prep(new Rep(cs)) {
103  prep->new_reference();
104 }
105 
106 template <typename PSET>
107 inline
109  : prep(new Rep(cgs)) {
110  prep->new_reference();
111 }
112 
113 template <typename PSET>
114 inline
116  : prep(y.prep) {
117  prep->new_reference();
118 }
119 
120 template <typename PSET>
121 inline
123  if (prep->del_reference()) {
124  delete prep;
125  }
126 }
127 
128 template <typename PSET>
129 inline Determinate<PSET>&
131  y.prep->new_reference();
132  if (prep->del_reference()) {
133  delete prep;
134  }
135  prep = y.prep;
136  return *this;
137 }
138 
139 template <typename PSET>
140 inline void
142  using std::swap;
143  swap(prep, y.prep);
144 }
145 
146 template <typename PSET>
147 inline void
149  if (prep->is_shared()) {
150  Rep* const new_prep = new Rep(prep->pset);
151  (void) prep->del_reference();
152  new_prep->new_reference();
153  prep = new_prep;
154  }
155 }
156 
157 template <typename PSET>
158 inline const PSET&
160  return prep->pset;
161 }
162 
163 template <typename PSET>
164 inline PSET&
166  mutate();
167  return prep->pset;
168 }
169 
170 template <typename PSET>
171 inline void
173  pointset().upper_bound_assign(y.pointset());
174 }
175 
176 template <typename PSET>
177 inline void
179  pointset().intersection_assign(y.pointset());
180 }
181 
182 template <typename PSET>
183 inline bool
185  // FIXME: the following should be turned into a query to PSET. This
186  // can be postponed until the time the ask-and-tell construction is
187  // revived.
188  return false;
189 }
190 
191 template <typename PSET>
192 inline void
194  // FIXME: the following should be turned into a proper
195  // implementation. This can be postponed until the time the
196  // ask-and-tell construction is revived.
197  pointset().difference_assign(y.pointset());
198 }
199 
200 template <typename PSET>
201 inline void
203  pointset().concatenate_assign(y.pointset());
204 }
205 
206 template <typename PSET>
207 inline bool
209  return prep == y.prep || y.prep->pset.contains(prep->pset);
210 }
211 
212 template <typename PSET>
213 inline bool
215  return prep == y.prep || prep->pset == y.prep->pset;
216 }
217 
218 template <typename PSET>
219 inline bool
221  return prep->pset.is_universe();
222 }
223 
224 template <typename PSET>
225 inline bool
227  return prep->pset.is_empty();
228 }
229 
230 template <typename PSET>
231 inline memory_size_type
233  return prep->total_memory_in_bytes();
234 }
235 
236 template <typename PSET>
237 inline memory_size_type
239  return sizeof(*this) + external_memory_in_bytes();
240 }
241 
242 template <typename PSET>
243 inline bool
245  return prep->pset.OK();
246 }
247 
248 namespace IO_Operators {
249 
251 template <typename PSET>
252 inline std::ostream&
253 operator<<(std::ostream& s, const Determinate<PSET>& x) {
254  s << x.pointset();
255  return s;
256 }
257 
258 } // namespace IO_Operators
259 
261 template <typename PSET>
262 inline bool
264  return x.prep == y.prep || x.prep->pset == y.prep->pset;
265 }
266 
268 template <typename PSET>
269 inline bool
271  return x.prep != y.prep && x.prep->pset != y.prep->pset;
272 }
273 
274 template <typename PSET>
275 template <typename Binary_Operator_Assign>
276 inline
278 Binary_Operator_Assign_Lifter(Binary_Operator_Assign op_assign)
279  : op_assign_(op_assign) {
280 }
281 
282 template <typename PSET>
283 template <typename Binary_Operator_Assign>
284 inline void
286 operator()(Determinate& x, const Determinate& y) const {
287  op_assign_(x.pointset(), y.pointset());
288 }
289 
290 template <typename PSET>
291 template <typename Binary_Operator_Assign>
292 inline
294 Determinate<PSET>::lift_op_assign(Binary_Operator_Assign op_assign) {
296 }
297 
299 template <typename PSET>
300 inline void
302  x.m_swap(y);
303 }
304 
305 } // namespace Parma_Polyhedra_Library
306 
307 #endif // !defined(PPL_Determinate_inlines_hh)
static Binary_Operator_Assign_Lifter< Binary_Operator_Assign > lift_op_assign(Binary_Operator_Assign op_assign)
Helper function returning a Binary_Operator_Assign_Lifter object, also allowing for the deduction of ...
void new_reference() const
Registers a new reference.
The possibly shared representation of a Determinate object.
memory_size_type external_memory_in_bytes() const
Returns a lower bound to the size in bytes of the memory managed by *this.
void swap(CO_Tree &x, CO_Tree &y)
size_t dimension_type
An unsigned integral type for representing space dimensions.
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
bool is_top() const
Returns true if and only if *this embeds the universe element PSET.
Determinate & operator=(const Determinate &y)
Assignment operator.
bool operator==(const Determinate< PSET > &x, const Determinate< PSET > &y)
void weakening_assign(const Determinate &y)
Assigns to *this the result of weakening *this with y.
void swap(Determinate< PSET > &x, Determinate< PSET > &y)
void concatenate_assign(const Determinate &y)
Assigns to *this the concatenation of *this and y, taken in this order.
bool is_definitely_equivalent_to(const Determinate &y) const
Returns true if and only if *this and y are definitely equivalent.
void upper_bound_assign(const Determinate &y)
Assigns to *this the upper bound of *this and y.
void mutate()
On return from this method, the representation of *this is not shared by different Determinate object...
A wrapper for PPL pointsets, providing them with a determinate constraint system interface, as defined in [Bag98].
Determinate(const PSET &pset)
Constructs a COW-wrapped object corresponding to the pointset pset.
bool OK() const
Checks if all the invariants are satisfied.
bool definitely_entails(const Determinate &y) const
Returns true if and only if *this entails y.
Degenerate_Element
Kinds of degenerate abstract elements.
Enable_If< Is_Native< T >::value, memory_size_type >::type external_memory_in_bytes(const T &)
For native types, returns the size in bytes of the memory managed by the type of the (unused) paramet...
bool operator!=(const Determinate< PSET > &x, const Determinate< PSET > &y)
Rep * prep
A pointer to the possibly shared representation of the base-level domain element. ...
bool is_bottom() const
Returns true if and only if *this embeds the empty element of PSET.
memory_size_type external_memory_in_bytes() const
Returns a lower bound to the size in bytes of the memory managed by *this.
The entire library is confined to this namespace.
Definition: version.hh:61
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
PSET pset
The possibly shared, embedded pointset.
bool del_reference() const
Unregisters one reference; returns true if and only if the representation has become unreferenced...
bool is_shared() const
True if and only if this representation is currently shared.
void meet_assign(const Determinate &y)
Assigns to *this the meet of *this and y.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void m_swap(Determinate &y)
Swaps *this with y.
Rep()
Private and unimplemented: default construction not allowed.
const PSET & pointset() const
Returns a const reference to the embedded pointset.