1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
/* Determinate class implementation: inline functions.
Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
Copyright (C) 2010-2012 BUGSENG srl (http://bugseng.com)
This file is part of the Parma Polyhedra Library (PPL).
The PPL is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
The PPL is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
For the most up-to-date information see the Parma Polyhedra Library
site: http://bugseng.com/products/ppl/ . */
#ifndef PPL_Determinate_inlines_hh
#define PPL_Determinate_inlines_hh 1
#include "assert.hh"
namespace Parma_Polyhedra_Library {
template <typename PSET>
inline
Determinate<PSET>::Rep::Rep(dimension_type num_dimensions,
Degenerate_Element kind)
: references(0), pset(num_dimensions, kind) {
}
template <typename PSET>
inline
Determinate<PSET>::Rep::Rep(const PSET& p)
: references(0), pset(p) {
}
template <typename PSET>
inline
Determinate<PSET>::Rep::Rep(const Constraint_System& cs)
: references(0), pset(cs) {
}
template <typename PSET>
inline
Determinate<PSET>::Rep::Rep(const Congruence_System& cgs)
: references(0), pset(cgs) {
}
template <typename PSET>
inline
Determinate<PSET>::Rep::~Rep() {
PPL_ASSERT(references == 0);
}
template <typename PSET>
inline void
Determinate<PSET>::Rep::new_reference() const {
++references;
}
template <typename PSET>
inline bool
Determinate<PSET>::Rep::del_reference() const {
return --references == 0;
}
template <typename PSET>
inline bool
Determinate<PSET>::Rep::is_shared() const {
return references > 1;
}
template <typename PSET>
inline memory_size_type
Determinate<PSET>::Rep::external_memory_in_bytes() const {
return pset.external_memory_in_bytes();
}
template <typename PSET>
inline memory_size_type
Determinate<PSET>::Rep::total_memory_in_bytes() const {
return sizeof(*this) + external_memory_in_bytes();
}
template <typename PSET>
inline
Determinate<PSET>::Determinate(const PSET& pset)
: prep(new Rep(pset)) {
prep->new_reference();
}
template <typename PSET>
inline
Determinate<PSET>::Determinate(const Constraint_System& cs)
: prep(new Rep(cs)) {
prep->new_reference();
}
template <typename PSET>
inline
Determinate<PSET>::Determinate(const Congruence_System& cgs)
: prep(new Rep(cgs)) {
prep->new_reference();
}
template <typename PSET>
inline
Determinate<PSET>::Determinate(const Determinate& y)
: prep(y.prep) {
prep->new_reference();
}
template <typename PSET>
inline
Determinate<PSET>::~Determinate() {
if (prep->del_reference())
delete prep;
}
template <typename PSET>
inline Determinate<PSET>&
Determinate<PSET>::operator=(const Determinate& y) {
y.prep->new_reference();
if (prep->del_reference())
delete prep;
prep = y.prep;
return *this;
}
template <typename PSET>
inline void
Determinate<PSET>::m_swap(Determinate& y) {
using std::swap;
swap(prep, y.prep);
}
template <typename PSET>
inline void
Determinate<PSET>::mutate() {
if (prep->is_shared()) {
Rep* new_prep = new Rep(prep->pset);
(void) prep->del_reference();
new_prep->new_reference();
prep = new_prep;
}
}
template <typename PSET>
inline const PSET&
Determinate<PSET>::pointset() const {
return prep->pset;
}
template <typename PSET>
inline PSET&
Determinate<PSET>::pointset() {
mutate();
return prep->pset;
}
template <typename PSET>
inline void
Determinate<PSET>::upper_bound_assign(const Determinate& y) {
pointset().upper_bound_assign(y.pointset());
}
template <typename PSET>
inline void
Determinate<PSET>::meet_assign(const Determinate& y) {
pointset().intersection_assign(y.pointset());
}
template <typename PSET>
inline bool
Determinate<PSET>::has_nontrivial_weakening() {
// FIXME: the following should be turned into a query to PSET. This
// can be postponed until the time the ask-and-tell construction is
// revived.
return false;
}
template <typename PSET>
inline void
Determinate<PSET>::weakening_assign(const Determinate& y) {
// FIXME: the following should be turned into a proper
// implementation. This can be postponed until the time the
// ask-and-tell construction is revived.
pointset().difference_assign(y.pointset());
}
template <typename PSET>
inline void
Determinate<PSET>::concatenate_assign(const Determinate& y) {
pointset().concatenate_assign(y.pointset());
}
template <typename PSET>
inline bool
Determinate<PSET>::definitely_entails(const Determinate& y) const {
return prep == y.prep || y.prep->pset.contains(prep->pset);
}
template <typename PSET>
inline bool
Determinate<PSET>::is_definitely_equivalent_to(const Determinate& y) const {
return prep == y.prep || prep->pset == y.prep->pset;
}
template <typename PSET>
inline bool
Determinate<PSET>::is_top() const {
return prep->pset.is_universe();
}
template <typename PSET>
inline bool
Determinate<PSET>::is_bottom() const {
return prep->pset.is_empty();
}
template <typename PSET>
inline memory_size_type
Determinate<PSET>::external_memory_in_bytes() const {
return prep->total_memory_in_bytes();
}
template <typename PSET>
inline memory_size_type
Determinate<PSET>::total_memory_in_bytes() const {
return sizeof(*this) + external_memory_in_bytes();
}
template <typename PSET>
inline bool
Determinate<PSET>::OK() const {
return prep->pset.OK();
}
namespace IO_Operators {
/*! \relates Parma_Polyhedra_Library::Determinate */
template <typename PSET>
inline std::ostream&
operator<<(std::ostream& s, const Determinate<PSET>& x) {
s << x.pointset();
return s;
}
} // namespace IO_Operators
/*! \relates Determinate */
template <typename PSET>
inline bool
operator==(const Determinate<PSET>& x, const Determinate<PSET>& y) {
return x.prep == y.prep || x.prep->pset == y.prep->pset;
}
/*! \relates Determinate */
template <typename PSET>
inline bool
operator!=(const Determinate<PSET>& x, const Determinate<PSET>& y) {
return x.prep != y.prep && x.prep->pset != y.prep->pset;
}
template <typename PSET>
template <typename Binary_Operator_Assign>
inline
Determinate<PSET>::Binary_Operator_Assign_Lifter<Binary_Operator_Assign>::
Binary_Operator_Assign_Lifter(Binary_Operator_Assign op_assign)
: op_assign_(op_assign) {
}
template <typename PSET>
template <typename Binary_Operator_Assign>
inline void
Determinate<PSET>::Binary_Operator_Assign_Lifter<Binary_Operator_Assign>::
operator()(Determinate& x, const Determinate& y) const {
op_assign_(x.pointset(), y.pointset());
}
template <typename PSET>
template <typename Binary_Operator_Assign>
inline
Determinate<PSET>::Binary_Operator_Assign_Lifter<Binary_Operator_Assign>
Determinate<PSET>::lift_op_assign(Binary_Operator_Assign op_assign) {
return Binary_Operator_Assign_Lifter<Binary_Operator_Assign>(op_assign);
}
/*! \relates Determinate */
template <typename PSET>
inline void
swap(Determinate<PSET>& x, Determinate<PSET>& y) {
x.m_swap(y);
}
} // namespace Parma_Polyhedra_Library
#endif // !defined(PPL_Determinate_inlines_hh)
|