@@ -61,54 +61,23 @@ class value_sett
6161 typedef irep_idt idt;
6262
6363 // / 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
6667 {
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+ }
10170
10271 // / 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
10473 // / 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 `
10675 // / instead of a set of pairs to make lookup by `exprt` easier. All
10776 // / methods matching the interface of `std::map` forward those methods
10877 // / to the internal map.
10978 class object_map_dt
11079 {
111- typedef std::map<object_numberingt::number_type, objectt > data_typet;
80+ typedef std::map<object_numberingt::number_type, offsett > data_typet;
11281 data_typet data;
11382
11483 public:
@@ -135,9 +104,18 @@ class value_sett
135104 void erase (key_type i) { data.erase (i); }
136105 void erase (const_iterator it) { data.erase (it); }
137106
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+ }
141119
142120 template <typename It>
143121 void insert (It b, It e) { data.insert (b, e); }
@@ -210,21 +188,21 @@ class value_sett
210188 // / \param src: expression to add
211189 bool insert (object_mapt &dest, const exprt &src) const
212190 {
213- return insert (dest, object_numbering.number (src), objectt ());
191+ return insert (dest, object_numbering.number (src), offsett ());
214192 }
215193
216194 // / Adds an expression to an object map, with known offset. If the
217195 // / destination map has an existing entry for the same expression
218196 // / with a differing offset its offset is marked unknown.
219197 // / \param dest: object map to update
220198 // / \param src: expression to add
221- // / \param offset : offset into `src`
199+ // / \param offset_value : offset into `src`
222200 bool insert (
223201 object_mapt &dest,
224202 const exprt &src,
225- const mp_integer &offset ) const
203+ const mp_integer &offset_value ) const
226204 {
227- return insert (dest, object_numbering.number (src), objectt (offset ));
205+ return insert (dest, object_numbering.number (src), offsett (offset_value ));
228206 }
229207
230208 // / Adds a numbered expression and offset to an object map. If the
@@ -237,17 +215,17 @@ class value_sett
237215 bool insert (
238216 object_mapt &dest,
239217 object_numberingt::number_type n,
240- const objectt &object ) const ;
218+ const offsett &offset ) const ;
241219
242220 // / Adds an expression and offset to an object map. If the
243221 // / destination map has an existing entry for the same expression
244222 // / with a differing offset its offset is marked unknown.
245223 // / \param dest: object map to update
246224 // / \param expr: expression to add
247225 // / \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
249227 {
250- return insert (dest, object_numbering.number (expr), object );
228+ return insert (dest, object_numbering.number (expr), offset );
251229 }
252230
253231 // / Represents a row of a `value_sett`. For example, this might represent
0 commit comments