1313#ifndef CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_GENERATOR_H
1414#define CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_GENERATOR_H
1515
16- #include < ansi-c/c_types .h>
16+ #include < util/string_expr .h>
1717#include < solvers/refinement/refined_string_type.h>
18- #include < solvers/refinement/string_expr.h>
1918#include < solvers/refinement/string_constraint.h>
2019
2120class string_constraint_generatort
@@ -26,33 +25,18 @@ class string_constraint_generatort
2625 // to the axiom list.
2726
2827 string_constraint_generatort ():
29- mode (ID_unknown), refined_string_type(char_type())
28+ mode (ID_unknown)
3029 { }
3130
3231 void set_mode (irep_idt _mode)
3332 {
3433 // only C and java modes supported
3534 assert ((_mode==ID_java) || (_mode==ID_C));
3635 mode=_mode;
37- refined_string_type=refined_string_typet (get_char_type ());
3836 }
3937
4038 irep_idt &get_mode () { return mode; }
4139
42- typet get_char_type () const ;
43- typet get_index_type () const
44- {
45- if (mode==ID_java)
46- return refined_string_typet::java_index_type ();
47- assert (mode==ID_C);
48- return refined_string_typet::index_type ();
49- }
50-
51- const refined_string_typet &get_refined_string_type () const
52- {
53- return refined_string_type;
54- }
55-
5640 // Axioms are of three kinds: universally quantified string constraint,
5741 // not contains string constraints and simple formulas.
5842 std::list<exprt> axioms;
@@ -73,9 +57,14 @@ class string_constraint_generatort
7357 return index_exprt (witness.at (c), univ_val);
7458 }
7559
76- symbol_exprt fresh_exist_index (const irep_idt &prefix);
77- symbol_exprt fresh_univ_index (const irep_idt &prefix);
60+ static unsigned next_symbol_id;
61+
62+ static symbol_exprt fresh_symbol (
63+ const irep_idt &prefix, const typet &type=bool_typet());
64+ symbol_exprt fresh_exist_index (const irep_idt &prefix, const typet &type);
65+ symbol_exprt fresh_univ_index (const irep_idt &prefix, const typet &type);
7866 symbol_exprt fresh_boolean (const irep_idt &prefix);
67+ string_exprt fresh_string (const refined_string_typet &type);
7968
8069 // We maintain a map from symbols to strings.
8170 std::map<irep_idt, string_exprt> symbol_to_string;
@@ -95,7 +84,7 @@ class string_constraint_generatort
9584 exprt add_axioms_for_function_application (
9685 const function_application_exprt &expr);
9786
98- constant_exprt constant_char (int i) const ;
87+ static constant_exprt constant_char (int i, const typet &char_type) ;
9988
10089private:
10190 // The integer with the longest string is Integer.MIN_VALUE which is -2^31,
@@ -107,7 +96,7 @@ class string_constraint_generatort
10796 const std::size_t MAX_FLOAT_LENGTH=15 ;
10897 const std::size_t MAX_DOUBLE_LENGTH=30 ;
10998
110- irep_idt extract_java_string (const symbol_exprt &s) const ;
99+ static irep_idt extract_java_string (const symbol_exprt &s);
111100
112101 exprt axiom_for_is_positive_index (const exprt &x);
113102
@@ -123,7 +112,6 @@ class string_constraint_generatort
123112 exprt add_axioms_for_contains (const function_application_exprt &f);
124113 exprt add_axioms_for_equals (const function_application_exprt &f);
125114 exprt add_axioms_for_equals_ignore_case (const function_application_exprt &f);
126- exprt add_axioms_for_data (const function_application_exprt &f);
127115
128116 // Add axioms corresponding to the String.hashCode java function
129117 // The specification is partial: the actual value is not actually computed
@@ -153,7 +141,8 @@ class string_constraint_generatort
153141 string_exprt add_axioms_for_concat_float (const function_application_exprt &f);
154142 string_exprt add_axioms_for_concat_code_point (
155143 const function_application_exprt &f);
156- string_exprt add_axioms_for_constant (irep_idt sval);
144+ string_exprt add_axioms_for_constant (
145+ irep_idt sval, const refined_string_typet &ref_type);
157146 string_exprt add_axioms_for_delete (
158147 const string_exprt &str, const exprt &start, const exprt &end);
159148 string_exprt add_axioms_for_delete (const function_application_exprt &expr);
@@ -173,15 +162,19 @@ class string_constraint_generatort
173162 const function_application_exprt &f);
174163 string_exprt add_axioms_from_literal (const function_application_exprt &f);
175164 string_exprt add_axioms_from_int (const function_application_exprt &f);
176- string_exprt add_axioms_from_int (const exprt &i, size_t max_size);
177- string_exprt add_axioms_from_int_hex (const exprt &i);
165+ string_exprt add_axioms_from_int (
166+ const exprt &i, size_t max_size, const refined_string_typet &ref_type);
167+ string_exprt add_axioms_from_int_hex (
168+ const exprt &i, const refined_string_typet &ref_type);
178169 string_exprt add_axioms_from_int_hex (const function_application_exprt &f);
179170 string_exprt add_axioms_from_long (const function_application_exprt &f);
180171 string_exprt add_axioms_from_long (const exprt &i, size_t max_size);
181172 string_exprt add_axioms_from_bool (const function_application_exprt &f);
182- string_exprt add_axioms_from_bool (const exprt &i);
173+ string_exprt add_axioms_from_bool (
174+ const exprt &i, const refined_string_typet &ref_type);
183175 string_exprt add_axioms_from_char (const function_application_exprt &f);
184- string_exprt add_axioms_from_char (const exprt &i);
176+ string_exprt add_axioms_from_char (
177+ const exprt &i, const refined_string_typet &ref_type);
185178 string_exprt add_axioms_from_char_array (const function_application_exprt &f);
186179 string_exprt add_axioms_from_char_array (
187180 const exprt &length,
@@ -257,7 +250,8 @@ class string_constraint_generatort
257250 // TODO: not working correctly at the moment
258251 string_exprt add_axioms_for_value_of (const function_application_exprt &f);
259252
260- string_exprt add_axioms_for_code_point (const exprt &code_point);
253+ string_exprt add_axioms_for_code_point (
254+ const exprt &code_point, const refined_string_typet &ref_type);
261255 string_exprt add_axioms_for_java_char_array (const exprt &char_array);
262256 string_exprt add_axioms_for_if (const if_exprt &expr);
263257 exprt add_axioms_for_char_literal (const function_application_exprt &f);
@@ -287,9 +281,6 @@ class string_constraint_generatort
287281 // Tells which language is used. C and Java are supported
288282 irep_idt mode;
289283
290- // Type of strings used in the refinement
291- refined_string_typet refined_string_type;
292-
293284 // assert that the number of argument is equal to nb and extract them
294285 static const function_application_exprt::argumentst &args (
295286 const function_application_exprt &expr, size_t nb)
@@ -299,7 +290,7 @@ class string_constraint_generatort
299290 return args;
300291 }
301292
302- exprt int_of_hex_char (exprt chr) const ;
293+ exprt int_of_hex_char (const exprt & chr) const ;
303294 exprt is_high_surrogate (const exprt &chr) const ;
304295 exprt is_low_surrogate (const exprt &chr) const ;
305296 static exprt character_equals_ignore_case (
0 commit comments