@@ -712,22 +712,24 @@ exprt interpretert::get_value(
712
712
if (rhs[offset]<memory.size ())
713
713
{
714
714
// We want the symbol pointed to
715
- memory_cellt &cell=memory[integer2unsigned (rhs[offset])];
716
- const typet type=get_type (cell.identifier );
715
+ std::size_t address=integer2size_t (rhs[offset]);
716
+ irep_idt identifier=address_to_identifier (address);
717
+ size_t offset=address_to_offset (address);
718
+ const typet type=get_type (identifier);
717
719
exprt symbol_expr (ID_symbol, type);
718
- symbol_expr.set (ID_identifier, cell. identifier );
720
+ symbol_expr.set (ID_identifier, identifier);
719
721
720
- if (cell. offset ==0 )
722
+ if (offset==0 )
721
723
return address_of_exprt (symbol_expr);
722
724
if (ns.follow (type).id ()==ID_struct)
723
725
{
724
- irep_idt member_id=get_component_id (cell. identifier , cell. offset );
726
+ irep_idt member_id=get_component_id (identifier, offset);
725
727
member_exprt member_expr (symbol_expr, member_id);
726
728
return address_of_exprt (member_expr);
727
729
}
728
730
index_exprt index_expr (
729
731
symbol_expr,
730
- from_integer (cell. offset , integer_typet ()));
732
+ from_integer (offset, integer_typet ()));
731
733
return index_expr;
732
734
}
733
735
@@ -828,12 +830,13 @@ void interpretert::assign(
828
830
{
829
831
if ((address+i)<memory.size ())
830
832
{
831
- memory_cellt &cell=memory[integer2unsigned (address+i)];
833
+ std::size_t address_val=integer2size_t (address+i);
834
+ memory_cellt &cell=memory[address_val];
832
835
if (show)
833
836
{
834
837
status () << total_steps << " ** assigning "
835
- << cell. identifier << " ["
836
- << cell. offset << " ]:=" << rhs[i]
838
+ << address_to_identifier (address_val) << " ["
839
+ << address_to_offset (address_val) << " ]:=" << rhs[i]
837
840
<< " \n " << eom;
838
841
}
839
842
cell.value =rhs[i];
@@ -913,8 +916,9 @@ void interpretert::execute_function_call()
913
916
// Retrieve the empty last trace step struct we pushed for this step
914
917
// of the interpreter run to fill it with the corresponding data
915
918
goto_trace_stept &trace_step=steps.get_last_step ();
916
- const memory_cellt &cell=memory[integer2size_t (a)];
917
- const irep_idt &identifier=cell.identifier ;
919
+ std::size_t address=integer2size_t (a);
920
+ const memory_cellt &cell=memory[address];
921
+ const irep_idt &identifier=address_to_identifier (address);
918
922
trace_step.identifier =identifier;
919
923
920
924
const goto_functionst::function_mapt::const_iterator f_it=
@@ -1020,9 +1024,7 @@ void interpretert::build_memory_map()
1020
1024
{
1021
1025
// put in a dummy for NULL
1022
1026
memory.resize (1 );
1023
- memory[0 ].offset =0 ;
1024
- memory[0 ].identifier =" NULL-OBJECT" ;
1025
- memory[0 ].initialized =0 ;
1027
+ inverse_memory_map[0 ]=" NULL-OBJECT" ;
1026
1028
1027
1029
num_dynamic_objects=0 ;
1028
1030
dynamic_types.clear ();
@@ -1062,18 +1064,10 @@ void interpretert::build_memory_map(const symbolt &symbol)
1062
1064
1063
1065
if (size!=0 )
1064
1066
{
1065
- unsigned address=memory.size ();
1067
+ std:: size_t address=memory.size ();
1066
1068
memory.resize (address+size);
1067
1069
memory_map[symbol.name ]=address;
1068
-
1069
- for (size_t i=0 ; i<size; i++)
1070
- {
1071
- memory_cellt &cell=memory[address+i];
1072
- cell.identifier =symbol.name ;
1073
- cell.offset =i;
1074
- cell.value =0 ;
1075
- cell.initialized =0 ;
1076
- }
1070
+ inverse_memory_map[address]=symbol.name ;
1077
1071
}
1078
1072
}
1079
1073
@@ -1136,12 +1130,10 @@ mp_integer interpretert::build_memory_map(
1136
1130
1137
1131
if (it!=dynamic_types.end ())
1138
1132
{
1139
- unsigned offset=1 ;
1140
- unsigned address=memory_map[id];
1141
- while (memory[address+offset].offset >0 ) offset++;
1142
-
1133
+ std::size_t address=memory_map[id];
1134
+ std::size_t current_size=base_address_to_alloc_size (address);
1143
1135
// current size <= size already recorded
1144
- if (size<=offset )
1136
+ if (size<=current_size )
1145
1137
return memory_map[id];
1146
1138
}
1147
1139
@@ -1151,19 +1143,12 @@ mp_integer interpretert::build_memory_map(
1151
1143
if (size==0 )
1152
1144
size=1 ; // This is a hack to create existence
1153
1145
1154
- unsigned address=memory.size ();
1146
+ std:: size_t address=memory.size ();
1155
1147
memory.resize (address+size);
1156
1148
memory_map[id]=address;
1149
+ inverse_memory_map[address]=id;
1157
1150
dynamic_types.insert (std::pair<const irep_idt, typet>(id, alloc_type));
1158
1151
1159
- for (size_t i=0 ; i<size; i++)
1160
- {
1161
- memory_cellt &cell=memory[address+i];
1162
- cell.identifier =id;
1163
- cell.offset =i;
1164
- cell.value =0 ;
1165
- cell.initialized =0 ;
1166
- }
1167
1152
return address;
1168
1153
}
1169
1154
0 commit comments