@@ -61,54 +61,23 @@ class value_sett
61
61
typedef irep_idt idt;
62
62
63
63
// / Represents the offset into an object: either a unique integer offset,
64
- // / or an unknown value, represented by `!offset_is_set`.
65
- class objectt
64
+ // / or an unknown value, represented by `!offset`.
65
+ typedef optionalt<mp_integer> offsett;
66
+ bool offset_is_zero (const offsett &offset) const
66
67
{
67
- public:
68
- // / Constructs an unknown offset
69
- objectt ():offset_is_set(false )
70
- {
71
- }
72
-
73
- // / Constructs a known offset
74
- explicit objectt (const mp_integer &_offset):
75
- offset(_offset),
76
- offset_is_set(true )
77
- {
78
- }
79
-
80
- // / Offset into the target object. Ignored if `offset_is_set` is false.
81
- mp_integer offset;
82
-
83
- // / If true, `offset` gives a unique integer offset; if false, represents
84
- // / an unknown offset.
85
- bool offset_is_set;
86
-
87
- bool offset_is_zero () const
88
- { return offset_is_set && offset.is_zero (); }
89
-
90
- bool operator ==(const objectt &other) const
91
- {
92
- return
93
- offset_is_set==other.offset_is_set &&
94
- (!offset_is_set || offset==other.offset );
95
- }
96
- bool operator !=(const objectt &other) const
97
- {
98
- return !(*this ==other);
99
- }
100
- };
68
+ return offset && offset->is_zero ();
69
+ }
101
70
102
71
// / Represents a set of expressions (`exprt` instances) with corresponding
103
- // / offsets (`objectt ` instances). This is the RHS set of a single row of
72
+ // / offsets (`offsett ` instances). This is the RHS set of a single row of
104
73
// / the enclosing `value_sett`, such as `{ null, dynamic_object1 }`.
105
- // / The set is represented as a map from numbered `exprt`s to `objectt `
74
+ // / The set is represented as a map from numbered `exprt`s to `offsett `
106
75
// / instead of a set of pairs to make lookup by `exprt` easier. All
107
76
// / methods matching the interface of `std::map` forward those methods
108
77
// / to the internal map.
109
78
class object_map_dt
110
79
{
111
- typedef std::map<object_numberingt::number_type, objectt > data_typet;
80
+ typedef std::map<object_numberingt::number_type, offsett > data_typet;
112
81
data_typet data;
113
82
114
83
public:
@@ -135,9 +104,18 @@ class value_sett
135
104
void erase (key_type i) { data.erase (i); }
136
105
void erase (const_iterator it) { data.erase (it); }
137
106
138
- objectt &operator [](key_type i) { return data[i]; }
139
- objectt &at (key_type i) { return data.at (i); }
140
- const objectt &at (key_type i) const { return data.at (i); }
107
+ offsett &operator [](key_type i)
108
+ {
109
+ return data[i];
110
+ }
111
+ offsett &at (key_type i)
112
+ {
113
+ return data.at (i);
114
+ }
115
+ const offsett &at (key_type i) const
116
+ {
117
+ return data.at (i);
118
+ }
141
119
142
120
template <typename It>
143
121
void insert (It b, It e) { data.insert (b, e); }
@@ -210,21 +188,21 @@ class value_sett
210
188
// / \param src: expression to add
211
189
bool insert (object_mapt &dest, const exprt &src) const
212
190
{
213
- return insert (dest, object_numbering.number (src), objectt ());
191
+ return insert (dest, object_numbering.number (src), offsett ());
214
192
}
215
193
216
194
// / Adds an expression to an object map, with known offset. If the
217
195
// / destination map has an existing entry for the same expression
218
196
// / with a differing offset its offset is marked unknown.
219
197
// / \param dest: object map to update
220
198
// / \param src: expression to add
221
- // / \param offset : offset into `src`
199
+ // / \param offset_value : offset into `src`
222
200
bool insert (
223
201
object_mapt &dest,
224
202
const exprt &src,
225
- const mp_integer &offset ) const
203
+ const mp_integer &offset_value ) const
226
204
{
227
- return insert (dest, object_numbering.number (src), objectt (offset ));
205
+ return insert (dest, object_numbering.number (src), offsett (offset_value ));
228
206
}
229
207
230
208
// / Adds a numbered expression and offset to an object map. If the
@@ -237,17 +215,17 @@ class value_sett
237
215
bool insert (
238
216
object_mapt &dest,
239
217
object_numberingt::number_type n,
240
- const objectt &object ) const ;
218
+ const offsett &offset ) const ;
241
219
242
220
// / Adds an expression and offset to an object map. If the
243
221
// / destination map has an existing entry for the same expression
244
222
// / with a differing offset its offset is marked unknown.
245
223
// / \param dest: object map to update
246
224
// / \param expr: expression to add
247
225
// / \param object: offset into `expr` (may be unknown).
248
- bool insert (object_mapt &dest, const exprt &expr, const objectt &object ) const
226
+ bool insert (object_mapt &dest, const exprt &expr, const offsett &offset ) const
249
227
{
250
- return insert (dest, object_numbering.number (expr), object );
228
+ return insert (dest, object_numbering.number (expr), offset );
251
229
}
252
230
253
231
// / Represents a row of a `value_sett`. For example, this might represent
0 commit comments