Skip to content

Commit 0640789

Browse files
Refactor assume statements of assign_array_from_json
This makes it so that we only have one block.add(code_assumet(...)) instruction, it is thus easier to figure out what the assumption is depending on the parameters.
1 parent fde5b4d commit 0640789

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

jbmc/src/java_bytecode/assignments_from_json.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -481,20 +481,18 @@ static void assign_array_from_json(
481481
const json_arrayt json_array = get_untyped_array(json, element_type);
482482
const auto number_of_elements =
483483
from_integer(json_array.size(), java_int_type());
484-
info.block.add(code_assumet{
485-
binary_predicate_exprt{given_length_expr, ID_ge, number_of_elements}});
486-
if(has_nondet_length(json))
487-
{
488-
info.block.add(code_assumet{binary_predicate_exprt{
489-
given_length_expr,
490-
ID_le,
491-
from_integer(info.max_user_array_length, java_int_type())}});
492-
}
493-
else
494-
{
495-
info.block.add(code_assumet{
496-
binary_predicate_exprt{given_length_expr, ID_le, number_of_elements}});
497-
}
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+
}()});
498496
assign_array_data_component_from_json(expr, json, type_from_array, info);
499497
}
500498

0 commit comments

Comments
 (0)