@@ -468,7 +468,7 @@ static symbol_exprt nondet_length(
468
468
// / For the assignment of the array elements, see
469
469
// / \ref assign_array_data_component_from_json.
470
470
// / For the overall algorithm, see \ref assign_from_json_rec.
471
- static void assign_array_from_json (
471
+ static void assign_det_length_array_from_json (
472
472
const exprt &expr,
473
473
const jsont &json,
474
474
const exprt &given_length_expr,
@@ -481,18 +481,30 @@ static void assign_array_from_json(
481
481
const json_arrayt json_array = get_untyped_array (json, element_type);
482
482
const auto number_of_elements =
483
483
from_integer (json_array.size (), java_int_type ());
484
- info.block .add (code_assumet{[&]() -> exprt {
485
- if (has_nondet_length (json))
486
- {
487
- return and_exprt{
488
- binary_predicate_exprt{given_length_expr, ID_ge, number_of_elements},
489
- binary_predicate_exprt{
490
- given_length_expr,
491
- ID_le,
492
- from_integer (info.max_user_array_length , java_int_type ())}};
493
- }
494
- return equal_exprt{given_length_expr, number_of_elements};
495
- }()});
484
+ info.block .add (
485
+ code_assumet{equal_exprt{given_length_expr, number_of_elements}});
486
+ assign_array_data_component_from_json (expr, json, type_from_array, info);
487
+ }
488
+
489
+ static void assign_nondet_length_array_from_json (
490
+ const exprt &expr,
491
+ const jsont &json,
492
+ const exprt &given_length_expr,
493
+ const optionalt<std::string> &type_from_array,
494
+ object_creation_infot &info)
495
+ {
496
+ PRECONDITION (is_java_array_type (expr.type ()));
497
+ const auto &element_type =
498
+ java_array_element_type (to_struct_tag_type (expr.type ().subtype ()));
499
+ const json_arrayt json_array = get_untyped_array (json, element_type);
500
+ const auto number_of_elements =
501
+ from_integer (json_array.size (), java_int_type ());
502
+ info.block .add (code_assumet{and_exprt{
503
+ binary_predicate_exprt{given_length_expr, ID_ge, number_of_elements},
504
+ binary_predicate_exprt{
505
+ given_length_expr,
506
+ ID_le,
507
+ from_integer (info.max_user_array_length , java_int_type ())}}});
496
508
assign_array_data_component_from_json (expr, json, type_from_array, info);
497
509
}
498
510
@@ -771,8 +783,16 @@ static void assign_reference_from_json(
771
783
{
772
784
INVARIANT (
773
785
reference.array_length , " an array reference should stores its length" );
774
- assign_array_from_json (
775
- reference.expr , json, *reference.array_length , type_from_array, info);
786
+ if (has_nondet_length (json))
787
+ {
788
+ assign_nondet_length_array_from_json (
789
+ reference.expr , json, *reference.array_length , type_from_array, info);
790
+ }
791
+ else
792
+ {
793
+ assign_det_length_array_from_json (
794
+ reference.expr , json, *reference.array_length , type_from_array, info);
795
+ }
776
796
}
777
797
else
778
798
assign_struct_from_json (dereference_exprt (reference.expr ), json, info);
@@ -814,7 +834,16 @@ void assign_from_json_rec(
814
834
const exprt length =
815
835
nondet_length (info.allocate_objects , info.block , info.loc );
816
836
allocate_array (expr, length, info);
817
- assign_array_from_json (expr, json, length, type_from_array, info);
837
+ if (has_nondet_length (json))
838
+ {
839
+ assign_nondet_length_array_from_json (
840
+ expr, json, length, type_from_array, info);
841
+ }
842
+ else
843
+ {
844
+ assign_det_length_array_from_json (
845
+ expr, json, length, type_from_array, info);
846
+ }
818
847
}
819
848
else if (
820
849
const auto runtime_type =
0 commit comments