@@ -448,10 +448,11 @@ nondet_length(allocate_objectst &allocate, source_locationt loc)
448
448
// / For the assignment of the array elements, see
449
449
// / \ref assign_array_data_component_from_json.
450
450
// / For the overall algorithm, see \ref assign_from_json_rec.
451
- static code_with_references_listt assign_det_length_array_from_json (
451
+ // / \return code for the assignment and length of the created array.
452
+ static std::pair<code_with_references_listt, exprt>
453
+ assign_det_length_array_from_json (
452
454
const exprt &expr,
453
455
const jsont &json,
454
- const exprt &given_length_expr,
455
456
const optionalt<std::string> &type_from_array,
456
457
object_creation_infot &info)
457
458
{
@@ -461,12 +462,9 @@ static code_with_references_listt assign_det_length_array_from_json(
461
462
const json_arrayt json_array = get_untyped_array (json, element_type);
462
463
const auto number_of_elements =
463
464
from_integer (json_array.size (), java_int_type ());
464
- code_with_references_listt result;
465
- result.add (code_without_referencest{
466
- code_assumet{equal_exprt{given_length_expr, number_of_elements}}});
467
- result.append (
468
- assign_array_data_component_from_json (expr, json, type_from_array, info));
469
- return result;
465
+ return {
466
+ assign_array_data_component_from_json (expr, json, type_from_array, info),
467
+ number_of_elements};
470
468
}
471
469
472
470
// / One of the cases in the recursive algorithm: the case where \p expr
@@ -479,6 +477,7 @@ static code_with_references_listt assign_det_length_array_from_json(
479
477
// / For the assignment of the array elements, see
480
478
// / \ref assign_array_data_component_from_json.
481
479
// / For the overall algorithm, see \ref assign_from_json_rec.
480
+ // / \return code for the assignment and length of the created array.
482
481
static code_with_references_listt assign_nondet_length_array_from_json (
483
482
const exprt &array,
484
483
const jsont &json,
@@ -491,8 +490,7 @@ static code_with_references_listt assign_nondet_length_array_from_json(
491
490
java_array_element_type (to_struct_tag_type (array.type ().subtype ()));
492
491
const json_arrayt json_array = get_untyped_array (json, element_type);
493
492
code_with_references_listt result;
494
- const auto number_of_elements =
495
- from_integer (json_array.size (), java_int_type ());
493
+ exprt number_of_elements = from_integer (json_array.size (), java_int_type ());
496
494
result.add (code_without_referencest{code_assumet{and_exprt{
497
495
binary_predicate_exprt{given_length_expr, ID_ge, number_of_elements},
498
496
binary_predicate_exprt{
@@ -823,12 +821,10 @@ static code_with_references_listt assign_reference_from_json(
823
821
}
824
822
else
825
823
{
826
- result.append (assign_det_length_array_from_json (
827
- reference.expr ,
828
- json,
829
- *reference.array_length ,
830
- type_from_array,
831
- info));
824
+ auto code_length_pair = assign_det_length_array_from_json (
825
+ reference.expr , json, type_from_array, info);
826
+ result.append (std::move (code_length_pair.first ));
827
+ reference.array_length = std::move (code_length_pair.second );
832
828
}
833
829
}
834
830
else
0 commit comments