@@ -365,7 +365,7 @@ string_exprt string_constraint_generatort::add_axioms_for_value_of(
365
365
// / \param radix: the radix
366
366
// / \param max_size: maximum number of characters
367
367
void string_constraint_generatort::add_axioms_for_correct_number_format (
368
- const string_exprt &str, const exprt &radix , std::size_t max_size)
368
+ const string_exprt &str, const exprt &radix_char_type , std::size_t max_size)
369
369
{
370
370
const refined_string_typet &ref_type=to_refined_string_type (str.type ());
371
371
const typet &char_type=ref_type.get_char_type ();
@@ -378,7 +378,7 @@ void string_constraint_generatort::add_axioms_for_correct_number_format(
378
378
exprt chr=str[0 ];
379
379
equal_exprt starts_with_minus (chr, minus_char);
380
380
equal_exprt starts_with_plus (chr, plus_char);
381
- exprt starts_with_digit=is_digit_with_radix (chr, radix );
381
+ exprt starts_with_digit=is_digit_with_radix (chr, radix_char_type );
382
382
383
383
// TODO: we should have implications in the other direction for correct
384
384
// correct => |str| > 0
@@ -408,7 +408,7 @@ void string_constraint_generatort::add_axioms_for_correct_number_format(
408
408
// / index < length && correct => is_digit(str[index])
409
409
implies_exprt character_at_index_is_digit (
410
410
binary_relation_exprt (index_expr, ID_lt, str.length ()),
411
- is_digit_with_radix (str[index ], radix ));
411
+ is_digit_with_radix (str[index ], radix_char_type ));
412
412
axioms.push_back (character_at_index_is_digit);
413
413
}
414
414
}
@@ -443,7 +443,8 @@ exprt string_constraint_generatort::add_axioms_for_parse_int(
443
443
// / TODO: we should throw an exception when this does not hold:
444
444
// / Note that the only thing stopping us from taking longer strings with many
445
445
// / leading zeros is the axioms for correct number format
446
- add_axioms_for_correct_number_format (str, radix, max_string_length);
446
+ add_axioms_for_correct_number_format (
447
+ str, typecast_exprt (radix, char_type), max_string_length);
447
448
448
449
// / TODO(OJones): Fix the below algorithm to make it work for min_int. There
449
450
// / are two problems. (1) Because we build i as positive and then negate it if
@@ -513,21 +514,21 @@ exprt string_constraint_generatort::add_axioms_for_parse_int(
513
514
// / \param chr: the character
514
515
// / \param radix: the radix
515
516
// / \return an expression for the condition
516
- exprt is_digit_with_radix (exprt chr, exprt radix )
517
+ exprt is_digit_with_radix (exprt chr, exprt radix_char_type )
517
518
{
518
519
const typet &char_type=chr.type ();
519
520
exprt zero_char=from_integer (' 0' , char_type);
520
521
exprt nine_char=from_integer (' 9' , char_type);
521
522
exprt a_char=from_integer (' a' , char_type);
522
523
exprt A_char=from_integer (' A' , char_type);
524
+ constant_exprt ten_char_type=from_integer (10 , char_type);
523
525
524
526
and_exprt is_digit_when_radix_le_10 (
525
527
binary_relation_exprt (chr, ID_ge, zero_char),
526
528
binary_relation_exprt (
527
- chr, ID_lt, plus_exprt (zero_char, typecast_exprt (radix, char_type) )));
529
+ chr, ID_lt, plus_exprt (zero_char, radix_char_type )));
528
530
529
- minus_exprt radix_minus_ten (
530
- typecast_exprt (radix, char_type), from_integer (10 , char_type));
531
+ minus_exprt radix_minus_ten (radix_char_type, ten_char_type);
531
532
532
533
or_exprt is_digit_when_radix_gt_10 (
533
534
and_exprt (
@@ -541,7 +542,7 @@ exprt is_digit_with_radix(exprt chr, exprt radix)
541
542
binary_relation_exprt (chr, ID_lt, plus_exprt (A_char, radix_minus_ten))));
542
543
543
544
return if_exprt (
544
- binary_relation_exprt (radix , ID_le, from_integer ( 10 , radix. type ()) ),
545
+ binary_relation_exprt (radix_char_type , ID_le, ten_char_type ),
545
546
is_digit_when_radix_le_10,
546
547
is_digit_when_radix_gt_10);
547
548
}
0 commit comments