@@ -174,84 +174,6 @@ string_constraint_generatort::add_axioms_for_string_of_int_with_radix(
174
174
return {from_integer (0 , get_return_code_type ()), std::move (result2)};
175
175
}
176
176
177
- // / Returns the integer value represented by the character.
178
- // / \param chr: a character expression in the following set:
179
- // / 0123456789abcdef
180
- // / \return an integer expression
181
- static exprt int_of_hex_char (const exprt &chr)
182
- {
183
- const exprt zero_char = from_integer (' 0' , chr.type ());
184
- const exprt nine_char = from_integer (' 9' , chr.type ());
185
- const exprt a_char = from_integer (' a' , chr.type ());
186
- return if_exprt (
187
- binary_relation_exprt (chr, ID_gt, nine_char),
188
- plus_exprt (from_integer (10 , chr.type ()), minus_exprt (chr, a_char)),
189
- minus_exprt (chr, zero_char));
190
- }
191
-
192
- // / Add axioms stating that the string `res` corresponds to the integer
193
- // / argument written in hexadecimal.
194
- // / \deprecated use add_axioms_from_int_with_radix instead
195
- // / \param res: string expression for the result
196
- // / \param i: an integer argument
197
- // / \return code 0 on success
198
- DEPRECATED (SINCE(2017 , 10 , 5 , " use add_axioms_for_string_of_int_with_radix" ))
199
- std::pair<exprt, string_constraintst>
200
- string_constraint_generatort::add_axioms_from_int_hex(
201
- const array_string_exprt &res,
202
- const exprt &i)
203
- {
204
- const typet &type = i.type ();
205
- PRECONDITION (type.id () == ID_signedbv);
206
- string_constraintst constraints;
207
- const typet &index_type = res.length_type ();
208
- const typet &char_type = to_type_with_subtype (res.content ().type ()).subtype ();
209
- exprt sixteen = from_integer (16 , index_type);
210
- exprt minus_char = from_integer (' -' , char_type);
211
- exprt zero_char = from_integer (' 0' , char_type);
212
- exprt nine_char = from_integer (' 9' , char_type);
213
- exprt a_char = from_integer (' a' , char_type);
214
- exprt f_char = from_integer (' f' , char_type);
215
-
216
- size_t max_size = 8 ;
217
- constraints.existential .push_back (and_exprt (
218
- greater_than (array_pool.get_or_create_length (res), 0 ),
219
- less_than_or_equal_to (array_pool.get_or_create_length (res), max_size)));
220
-
221
- for (size_t size = 1 ; size <= max_size; size++)
222
- {
223
- exprt sum = from_integer (0 , type);
224
- exprt all_numbers = true_exprt ();
225
- exprt chr = res[0 ];
226
-
227
- for (size_t j = 0 ; j < size; j++)
228
- {
229
- chr = res[j];
230
- exprt chr_int = int_of_hex_char (chr);
231
- sum = plus_exprt (mult_exprt (sum, sixteen), typecast_exprt (chr_int, type));
232
- or_exprt is_number (
233
- and_exprt (
234
- binary_relation_exprt (chr, ID_ge, zero_char),
235
- binary_relation_exprt (chr, ID_le, nine_char)),
236
- and_exprt (
237
- binary_relation_exprt (chr, ID_ge, a_char),
238
- binary_relation_exprt (chr, ID_le, f_char)));
239
- all_numbers = and_exprt (all_numbers, is_number);
240
- }
241
-
242
- const equal_exprt premise =
243
- equal_to (array_pool.get_or_create_length (res), size);
244
- constraints.existential .push_back (
245
- implies_exprt (premise, and_exprt (equal_exprt (i, sum), all_numbers)));
246
-
247
- // disallow 0s at the beginning
248
- if (size > 1 )
249
- constraints.existential .push_back (
250
- implies_exprt (premise, not_exprt (equal_exprt (res[0 ], zero_char))));
251
- }
252
- return {from_integer (0 , get_return_code_type ()), std::move (constraints)};
253
- }
254
-
255
177
// / Add axioms corresponding to the Integer.toHexString(I) java function
256
178
// / \param f: function application with an integer argument
257
179
// / \return code 0 on success
@@ -262,7 +184,7 @@ string_constraint_generatort::add_axioms_from_int_hex(
262
184
PRECONDITION (f.arguments ().size () == 3 );
263
185
const array_string_exprt res =
264
186
array_pool.find (f.arguments ()[1 ], f.arguments ()[0 ]);
265
- return add_axioms_from_int_hex (res, f.arguments ()[2 ]);
187
+ return add_axioms_for_string_of_int_with_radix (res, f.arguments ()[2 ], from_integer ( 16 , unsignedbv_typet{ 8 }) , 0 );
266
188
}
267
189
268
190
// / Add axioms making the return value true if the given string is a correct
0 commit comments