@@ -160,13 +160,6 @@ class java_object_factoryt
160
160
size_t depth,
161
161
const source_locationt &location);
162
162
163
- const symbol_exprt gen_nondet_int_init (
164
- code_blockt &assignments,
165
- const std::string &basename_prefix,
166
- const exprt &min_length_expr,
167
- const exprt &max_length_expr,
168
- const source_locationt &location);
169
-
170
163
void gen_method_call_if_present (
171
164
code_blockt &assignments,
172
165
const exprt &instance_expr,
@@ -1103,53 +1096,6 @@ void java_object_factoryt::declare_created_symbols(code_blockt &init_code)
1103
1096
allocate_objects.declare_created_symbols (init_code);
1104
1097
}
1105
1098
1106
- // / Nondeterministically initializes an int i in the range min <= i <= max,
1107
- // / where min is the integer represented by `min_value_expr` and max is the
1108
- // / integer represented by `max_value_expr`.
1109
- // / \param [out] assignments: A code block that the initializing assignments
1110
- // / will be appended to.
1111
- // / \param basename_prefix: Used for naming the newly created symbol.
1112
- // / \param min_value_expr: Represents the minimum value for the integer.
1113
- // / \param max_value_expr: Represents the maximum value for the integer.
1114
- // / \param location: Source location associated with nondet-initialization.
1115
- // / \return A symbol expression for the resulting integer.
1116
- const symbol_exprt java_object_factoryt::gen_nondet_int_init (
1117
- code_blockt &assignments,
1118
- const std::string &basename_prefix,
1119
- const exprt &min_value_expr,
1120
- const exprt &max_value_expr,
1121
- const source_locationt &location)
1122
- {
1123
- PRECONDITION (min_value_expr.type () == max_value_expr.type ());
1124
-
1125
- const symbol_exprt &int_symbol_expr =
1126
- allocate_objects.allocate_automatic_local_object (
1127
- min_value_expr.type (), basename_prefix);
1128
-
1129
- // Nondet-initialize it
1130
- gen_nondet_init (
1131
- assignments,
1132
- int_symbol_expr,
1133
- false , // is_sub
1134
- irep_idt (),
1135
- false , // skip_classid
1136
- lifetimet::AUTOMATIC_LOCAL, // immaterial, type is primitive
1137
- {}, // no override type
1138
- 0 , // depth is immaterial, always non-null
1139
- update_in_placet::NO_UPDATE_IN_PLACE,
1140
- location);
1141
-
1142
- // Insert assumptions to bound its value
1143
- const auto min_assume_expr =
1144
- binary_relation_exprt (int_symbol_expr, ID_ge, min_value_expr);
1145
- const auto max_assume_expr =
1146
- binary_relation_exprt (int_symbol_expr, ID_le, max_value_expr);
1147
- assignments.add (code_assumet (min_assume_expr));
1148
- assignments.add (code_assumet (max_assume_expr));
1149
-
1150
- return int_symbol_expr;
1151
- }
1152
-
1153
1099
// / Allocates a fresh array and emits an assignment writing to \p lhs the
1154
1100
// / address of the new array. Single-use at the moment, but useful to keep as a
1155
1101
// / separate function for downstream branches.
@@ -1172,12 +1118,13 @@ void java_object_factoryt::allocate_nondet_length_array(
1172
1118
const typet &element_type,
1173
1119
const source_locationt &location)
1174
1120
{
1175
- const auto &length_sym_expr = gen_nondet_int_init (
1176
- assignments,
1177
- " nondet_array_length" ,
1121
+ const auto &length_sym_expr = generate_nondet_int (
1178
1122
from_integer (0 , java_int_type ()),
1179
1123
max_length_expr,
1180
- location);
1124
+ " nondet_array_length" ,
1125
+ location,
1126
+ allocate_objects,
1127
+ assignments);
1181
1128
1182
1129
side_effect_exprt java_new_array (ID_java_new_array, lhs.type (), loc);
1183
1130
java_new_array.copy_to_operands (length_sym_expr);
@@ -1476,12 +1423,13 @@ bool java_object_factoryt::gen_nondet_enum_init(
1476
1423
const member_exprt enum_array_expr =
1477
1424
member_exprt (deref_expr, " data" , comps[2 ].type ());
1478
1425
1479
- const symbol_exprt &index_expr = gen_nondet_int_init (
1480
- assignments,
1481
- " enum_index_init" ,
1426
+ const symbol_exprt &index_expr = generate_nondet_int (
1482
1427
from_integer (0 , java_int_type ()),
1483
1428
minus_exprt (length_expr, from_integer (1 , java_int_type ())),
1484
- location);
1429
+ " enum_index_init" ,
1430
+ location,
1431
+ allocate_objects,
1432
+ assignments);
1485
1433
1486
1434
// Generate statement using pointer arithmetic to access array element:
1487
1435
// expr = (expr.type())*(enum_array_expr + index_expr);
0 commit comments