@@ -445,10 +445,11 @@ nondet_length(allocate_objectst &allocate, source_locationt loc)
445
445
// / For the assignment of the array elements, see
446
446
// / \ref assign_array_data_component_from_json.
447
447
// / For the overall algorithm, see \ref assign_from_json_rec.
448
- static code_with_references_listt assign_det_length_array_from_json (
448
+ // / \return code for the assignment and length of the created array.
449
+ static std::pair<code_with_references_listt, exprt>
450
+ assign_det_length_array_from_json (
449
451
const exprt &expr,
450
452
const jsont &json,
451
- const exprt &given_length_expr,
452
453
const optionalt<std::string> &type_from_array,
453
454
object_creation_infot &info)
454
455
{
@@ -458,11 +459,9 @@ static code_with_references_listt assign_det_length_array_from_json(
458
459
const json_arrayt json_array = get_untyped_array (json, element_type);
459
460
const auto number_of_elements =
460
461
from_integer (json_array.size (), java_int_type ());
461
- code_with_references_listt result;
462
- result.add (code_assumet{equal_exprt{given_length_expr, number_of_elements}});
463
- result.append (
464
- assign_array_data_component_from_json (expr, json, type_from_array, info));
465
- return result;
462
+ return {
463
+ assign_array_data_component_from_json (expr, json, type_from_array, info),
464
+ number_of_elements};
466
465
}
467
466
468
467
// / One of the cases in the recursive algorithm: the case where \p expr
@@ -475,6 +474,7 @@ static code_with_references_listt assign_det_length_array_from_json(
475
474
// / For the assignment of the array elements, see
476
475
// / \ref assign_array_data_component_from_json.
477
476
// / For the overall algorithm, see \ref assign_from_json_rec.
477
+ // / \return code for the assignment and length of the created array.
478
478
static code_with_references_listt assign_nondet_length_array_from_json (
479
479
const exprt &array,
480
480
const jsont &json,
@@ -487,8 +487,7 @@ static code_with_references_listt assign_nondet_length_array_from_json(
487
487
java_array_element_type (to_struct_tag_type (array.type ().subtype ()));
488
488
const json_arrayt json_array = get_untyped_array (json, element_type);
489
489
code_with_references_listt result;
490
- const auto number_of_elements =
491
- from_integer (json_array.size (), java_int_type ());
490
+ exprt number_of_elements = from_integer (json_array.size (), java_int_type ());
492
491
result.add (code_assumet{and_exprt{
493
492
binary_predicate_exprt{given_length_expr, ID_ge, number_of_elements},
494
493
binary_predicate_exprt{
@@ -814,12 +813,10 @@ static code_with_references_listt assign_reference_from_json(
814
813
}
815
814
else
816
815
{
817
- result.append (assign_det_length_array_from_json (
818
- reference.expr ,
819
- json,
820
- *reference.array_length ,
821
- type_from_array,
822
- info));
816
+ auto code_length_pair = assign_det_length_array_from_json (
817
+ reference.expr , json, type_from_array, info);
818
+ result.append (std::move (code_length_pair.first ));
819
+ reference.array_length = std::move (code_length_pair.second );
823
820
}
824
821
}
825
822
else
0 commit comments