24
24
// / reads a memory address and loads it into the dest variable marks cell as
25
25
// / read before written if cell has never been written
26
26
void interpretert::read (
27
- mp_integer address,
27
+ const mp_integer & address,
28
28
mp_vectort &dest) const
29
29
{
30
30
// copy memory region
@@ -36,8 +36,8 @@ void interpretert::read(
36
36
{
37
37
const memory_cellt &cell=memory[integer2size_t (address+i)];
38
38
value=cell.value ;
39
- if (cell.initialized ==0 )
40
- cell.initialized =- 1 ;
39
+ if (cell.initialized ==memory_cellt::initializedt::UNKNOWN )
40
+ cell.initialized =memory_cellt::initializedt::READ_BEFORE_WRITTEN ;
41
41
}
42
42
else
43
43
value=0 ;
@@ -47,7 +47,7 @@ void interpretert::read(
47
47
}
48
48
49
49
void interpretert::read_unbounded (
50
- mp_integer address,
50
+ const mp_integer & address,
51
51
mp_vectort &dest) const
52
52
{
53
53
// copy memory region
@@ -64,8 +64,8 @@ void interpretert::read_unbounded(
64
64
{
65
65
const memory_cellt &cell=memory[integer2size_t (address+i)];
66
66
value=cell.value ;
67
- if (cell.initialized ==0 )
68
- cell.initialized =- 1 ;
67
+ if (cell.initialized ==memory_cellt::initializedt::UNKNOWN )
68
+ cell.initialized =memory_cellt::initializedt::READ_BEFORE_WRITTEN ;
69
69
}
70
70
else
71
71
value=0 ;
@@ -76,7 +76,7 @@ void interpretert::read_unbounded(
76
76
77
77
// / reserves memory block of size at address
78
78
void interpretert::allocate (
79
- mp_integer address,
79
+ const mp_integer & address,
80
80
size_t size)
81
81
{
82
82
// clear memory region
@@ -86,7 +86,7 @@ void interpretert::allocate(
86
86
{
87
87
memory_cellt &cell=memory[integer2size_t (address+i)];
88
88
cell.value =0 ;
89
- cell.initialized =0 ;
89
+ cell.initialized =memory_cellt::initializedt::UNKNOWN ;
90
90
}
91
91
}
92
92
}
@@ -96,8 +96,9 @@ void interpretert::clear_input_flags()
96
96
{
97
97
for (auto &cell : memory)
98
98
{
99
- if (cell.second .initialized >0 )
100
- cell.second .initialized =0 ;
99
+ if (cell.second .initialized ==
100
+ memory_cellt::initializedt::WRITTEN_BEFORE_READ)
101
+ cell.second .initialized =memory_cellt::initializedt::UNKNOWN;
101
102
}
102
103
}
103
104
@@ -147,7 +148,7 @@ bool interpretert::count_type_leaves(const typet &ty, mp_integer &result)
147
148
// / \return Offset into a vector of interpreter values; returns true on error
148
149
bool interpretert::byte_offset_to_memory_offset (
149
150
const typet &source_type,
150
- mp_integer offset,
151
+ const mp_integer & offset,
151
152
mp_integer &result)
152
153
{
153
154
if (source_type.id ()==ID_struct)
@@ -227,7 +228,7 @@ bool interpretert::byte_offset_to_memory_offset(
227
228
// / \return The corresponding byte offset. Returns true on error
228
229
bool interpretert::memory_offset_to_byte_offset (
229
230
const typet &source_type,
230
- mp_integer cell_offset ,
231
+ const mp_integer &full_cell_offset ,
231
232
mp_integer &result)
232
233
{
233
234
if (source_type.id ()==ID_struct)
@@ -236,6 +237,7 @@ bool interpretert::memory_offset_to_byte_offset(
236
237
const struct_typet::componentst &components=st.components ();
237
238
member_offset_iterator offsets (st, ns);
238
239
mp_integer previous_member_sizes;
240
+ mp_integer cell_offset=full_cell_offset;
239
241
for (; offsets->first <components.size () && offsets->second !=-1 ; ++offsets)
240
242
{
241
243
const auto &component_type=components[offsets->first ].type ();
@@ -277,13 +279,14 @@ bool interpretert::memory_offset_to_byte_offset(
277
279
mp_integer elem_count;
278
280
if (count_type_leaves (at.subtype (), elem_count))
279
281
return true ;
280
- mp_integer this_idx=cell_offset /elem_count;
282
+ mp_integer this_idx=full_cell_offset /elem_count;
281
283
if (this_idx>=array_size_vec[0 ])
282
284
return true ;
283
285
mp_integer subtype_result;
284
286
bool ret=
285
- memory_offset_to_byte_offset (at.subtype (),
286
- cell_offset%elem_count,
287
+ memory_offset_to_byte_offset (
288
+ at.subtype (),
289
+ full_cell_offset%elem_count,
287
290
subtype_result);
288
291
result=subtype_result+(elem_size*this_idx);
289
292
return ret;
@@ -292,7 +295,7 @@ bool interpretert::memory_offset_to_byte_offset(
292
295
{
293
296
// Primitive type.
294
297
result=0 ;
295
- return cell_offset !=0 ;
298
+ return full_cell_offset !=0 ;
296
299
}
297
300
}
298
301
0 commit comments