13
13
#ifndef CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_GENERATOR_H
14
14
#define CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_GENERATOR_H
15
15
16
- #include < ansi-c/c_types .h>
16
+ #include < util/string_expr .h>
17
17
#include < solvers/refinement/refined_string_type.h>
18
- #include < solvers/refinement/string_expr.h>
19
18
#include < solvers/refinement/string_constraint.h>
20
19
21
20
class string_constraint_generatort
@@ -26,33 +25,18 @@ class string_constraint_generatort
26
25
// to the axiom list.
27
26
28
27
string_constraint_generatort ():
29
- mode (ID_unknown), refined_string_type(char_type())
28
+ mode (ID_unknown)
30
29
{ }
31
30
32
31
void set_mode (irep_idt _mode)
33
32
{
34
33
// only C and java modes supported
35
34
assert ((_mode==ID_java) || (_mode==ID_C));
36
35
mode=_mode;
37
- refined_string_type=refined_string_typet (get_char_type ());
38
36
}
39
37
40
38
irep_idt &get_mode () { return mode; }
41
39
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
-
56
40
// Axioms are of three kinds: universally quantified string constraint,
57
41
// not contains string constraints and simple formulas.
58
42
std::list<exprt> axioms;
@@ -73,9 +57,14 @@ class string_constraint_generatort
73
57
return index_exprt (witness.at (c), univ_val);
74
58
}
75
59
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);
78
66
symbol_exprt fresh_boolean (const irep_idt &prefix);
67
+ string_exprt fresh_string (const refined_string_typet &type);
79
68
80
69
// We maintain a map from symbols to strings.
81
70
std::map<irep_idt, string_exprt> symbol_to_string;
@@ -95,7 +84,7 @@ class string_constraint_generatort
95
84
exprt add_axioms_for_function_application (
96
85
const function_application_exprt &expr);
97
86
98
- constant_exprt constant_char (int i) const ;
87
+ static constant_exprt constant_char (int i, const typet &char_type) ;
99
88
100
89
private:
101
90
// The integer with the longest string is Integer.MIN_VALUE which is -2^31,
@@ -107,7 +96,7 @@ class string_constraint_generatort
107
96
const std::size_t MAX_FLOAT_LENGTH=15 ;
108
97
const std::size_t MAX_DOUBLE_LENGTH=30 ;
109
98
110
- irep_idt extract_java_string (const symbol_exprt &s) const ;
99
+ static irep_idt extract_java_string (const symbol_exprt &s);
111
100
112
101
exprt axiom_for_is_positive_index (const exprt &x);
113
102
@@ -123,7 +112,6 @@ class string_constraint_generatort
123
112
exprt add_axioms_for_contains (const function_application_exprt &f);
124
113
exprt add_axioms_for_equals (const function_application_exprt &f);
125
114
exprt add_axioms_for_equals_ignore_case (const function_application_exprt &f);
126
- exprt add_axioms_for_data (const function_application_exprt &f);
127
115
128
116
// Add axioms corresponding to the String.hashCode java function
129
117
// The specification is partial: the actual value is not actually computed
@@ -153,7 +141,8 @@ class string_constraint_generatort
153
141
string_exprt add_axioms_for_concat_float (const function_application_exprt &f);
154
142
string_exprt add_axioms_for_concat_code_point (
155
143
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);
157
146
string_exprt add_axioms_for_delete (
158
147
const string_exprt &str, const exprt &start, const exprt &end);
159
148
string_exprt add_axioms_for_delete (const function_application_exprt &expr);
@@ -173,15 +162,19 @@ class string_constraint_generatort
173
162
const function_application_exprt &f);
174
163
string_exprt add_axioms_from_literal (const function_application_exprt &f);
175
164
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);
178
169
string_exprt add_axioms_from_int_hex (const function_application_exprt &f);
179
170
string_exprt add_axioms_from_long (const function_application_exprt &f);
180
171
string_exprt add_axioms_from_long (const exprt &i, size_t max_size);
181
172
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);
183
175
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);
185
178
string_exprt add_axioms_from_char_array (const function_application_exprt &f);
186
179
string_exprt add_axioms_from_char_array (
187
180
const exprt &length,
@@ -257,7 +250,8 @@ class string_constraint_generatort
257
250
// TODO: not working correctly at the moment
258
251
string_exprt add_axioms_for_value_of (const function_application_exprt &f);
259
252
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);
261
255
string_exprt add_axioms_for_java_char_array (const exprt &char_array);
262
256
string_exprt add_axioms_for_if (const if_exprt &expr);
263
257
exprt add_axioms_for_char_literal (const function_application_exprt &f);
@@ -287,9 +281,6 @@ class string_constraint_generatort
287
281
// Tells which language is used. C and Java are supported
288
282
irep_idt mode;
289
283
290
- // Type of strings used in the refinement
291
- refined_string_typet refined_string_type;
292
-
293
284
// assert that the number of argument is equal to nb and extract them
294
285
static const function_application_exprt::argumentst &args (
295
286
const function_application_exprt &expr, size_t nb)
@@ -299,7 +290,7 @@ class string_constraint_generatort
299
290
return args;
300
291
}
301
292
302
- exprt int_of_hex_char (exprt chr) const ;
293
+ exprt int_of_hex_char (const exprt & chr) const ;
303
294
exprt is_high_surrogate (const exprt &chr) const ;
304
295
exprt is_low_surrogate (const exprt &chr) const ;
305
296
static exprt character_equals_ignore_case (
0 commit comments