@@ -366,21 +366,10 @@ void initialize_nondet_string_fields(
366
366
bool printable,
367
367
allocate_objectst &allocate_objects)
368
368
{
369
- PRECONDITION (
370
- java_string_library_preprocesst
371
- ::implements_java_char_sequence (struct_expr.type()));
372
-
373
369
namespacet ns (symbol_table);
374
-
375
370
const struct_typet &struct_type =
376
371
to_struct_type (ns.follow (struct_expr.type ()));
377
-
378
- // In case the type for String was not added to the symbol table,
379
- // (typically when string refinement is not activated), `struct_type`
380
- // just contains the standard Object fields (or may have some other model
381
- // entirely), and in particular has no length and data fields.
382
- PRECONDITION (
383
- struct_type.has_component (" length" ) && struct_type.has_component (" data" ));
372
+ PRECONDITION (is_java_string_type (struct_type));
384
373
385
374
// We allow type StringBuffer and StringBuilder to be initialized
386
375
// in the same way has String, because they have the same structure and
@@ -774,7 +763,6 @@ void java_object_factoryt::gen_nondet_struct_init(
774
763
{
775
764
const namespacet ns (symbol_table);
776
765
PRECONDITION (ns.follow (expr.type ()).id ()==ID_struct);
777
- PRECONDITION (struct_type.id ()==ID_struct);
778
766
779
767
typedef struct_typet::componentst componentst;
780
768
const irep_idt &struct_tag=struct_type.get_tag ();
@@ -792,15 +780,12 @@ void java_object_factoryt::gen_nondet_struct_init(
792
780
// generated differently from object fields in the general case, see
793
781
// \ref java_object_factoryt::initialize_nondet_string_fields.
794
782
795
- const bool is_char_sequence =
796
- java_string_library_preprocesst::implements_java_char_sequence (struct_type);
797
- const bool has_length_and_data =
798
- struct_type.has_component (" length" ) && struct_type.has_component (" data" );
799
- const bool is_string_type = is_char_sequence && has_length_and_data;
800
783
const bool has_string_input_values =
801
784
!object_factory_parameters.string_input_values .empty ();
802
785
803
- if (is_string_type && has_string_input_values && !skip_classid)
786
+ if (
787
+ is_java_string_type (struct_type) && has_string_input_values &&
788
+ !skip_classid)
804
789
{ // We're dealing with a string and we should set fixed input values.
805
790
// We create a switch statement where each case is an assignment
806
791
// of one of the fixed input strings to the input variable in question
@@ -817,7 +802,7 @@ void java_object_factoryt::gen_nondet_struct_init(
817
802
else if (
818
803
(!is_sub && !skip_classid &&
819
804
update_in_place != update_in_placet::MUST_UPDATE_IN_PLACE) ||
820
- is_string_type )
805
+ is_java_string_type (struct_type) )
821
806
{
822
807
// Add an initial all-zero write. Most of the fields of this will be
823
808
// overwritten, but it helps to have a whole-structure write that analysis
@@ -834,7 +819,7 @@ void java_object_factoryt::gen_nondet_struct_init(
834
819
// If the initialised type is a special-cased String type (one with length
835
820
// and data fields introduced by string-library preprocessing), initialise
836
821
// those fields with nondet values
837
- if (is_string_type )
822
+ if (is_java_string_type (struct_type) )
838
823
{ // We're dealing with a string
839
824
initialize_nondet_string_fields (
840
825
to_struct_expr (*initial_object),
@@ -874,7 +859,8 @@ void java_object_factoryt::gen_nondet_struct_init(
874
859
code.add_source_location () = location;
875
860
assignments.add (code);
876
861
}
877
- else if (is_string_type && (name == " length" || name == " data" ))
862
+ else if (
863
+ is_java_string_type (struct_type) && (name == " length" || name == " data" ))
878
864
{
879
865
// In this case these were set up above.
880
866
continue ;
0 commit comments