|
| 1 | +typedef struct __CPROVER_string { char *s; } __CPROVER_string; |
| 2 | +//typedef struct __CPROVER_char { char c; } __CPROVER_char; |
| 3 | +typedef unsigned char __CPROVER_char; |
| 4 | + |
| 5 | +/****************************************************************************** |
| 6 | + * CPROVER string functions |
| 7 | + ******************************************************************************/ |
| 8 | +/* returns s[p] */ |
| 9 | +#define __CPROVER_char_at(s, p) __CPROVER_uninterpreted_string_char_at_func(s, p) |
| 10 | + |
| 11 | +/* string equality */ |
| 12 | +#define __CPROVER_string_equal(s1, s2) __CPROVER_uninterpreted_string_equal_func(s1, s2) |
| 13 | + |
| 14 | +/* defines a string literal, e.g. __CPROVER_string_literal("foo") */ |
| 15 | +#define __CPROVER_string_literal(s) __CPROVER_uninterpreted_string_literal_func(s) |
| 16 | + |
| 17 | +/* defines a char literal, e.g. __CPROVER_char_literal("c"). NOTE: you |
| 18 | + * *must* use a C string literal as argument (i.e. double quotes "c", not |
| 19 | + * single 'c') */ |
| 20 | +#define __CPROVER_char_literal(c) __CPROVER_uninterpreted_char_literal_func(c) |
| 21 | + |
| 22 | +/* produces the concatenation of s1 and s2 */ |
| 23 | +#define __CPROVER_string_concat(s1, s2) __CPROVER_uninterpreted_string_concat_func(s1, s2) |
| 24 | + |
| 25 | +/* return the length of s */ |
| 26 | +#define __CPROVER_string_length(s) __CPROVER_uninterpreted_string_length_func(s) |
| 27 | + |
| 28 | +/* extracts the substring between positions i and j (j not included) */ |
| 29 | +#define __CPROVER_string_substring(s, i, j) __CPROVER_uninterpreted_string_substring_func(s, i, j) |
| 30 | + |
| 31 | +/* test whether p is a prefix of s */ |
| 32 | +#define __CPROVER_string_isprefix(p, s) __CPROVER_uninterpreted_string_is_prefix_func(p, s) |
| 33 | + |
| 34 | +/* test whether p is a suffix of s */ |
| 35 | +#define __CPROVER_string_issuffix(p, s) __CPROVER_uninterpreted_string_is_suffix_func(p, s) |
| 36 | +/* test whether p contains s */ |
| 37 | +#define __CPROVER_string_contains(p, s) __CPROVER_uninterpreted_string_contains_func(p, s) |
| 38 | + |
| 39 | +/* first index where character c appears, -1 if not found */ |
| 40 | +#define __CPROVER_string_index_of(s, c) __CPROVER_uninterpreted_string_index_of_func(s, c) |
| 41 | + |
| 42 | +/* last index where character c appears */ |
| 43 | +#define __CPROVER_string_last_index_of(s, c) __CPROVER_uninterpreted_string_last_index_of_func(s, c) |
| 44 | + |
| 45 | +/* returns a new string obtained from s by setting s[p] = c */ |
| 46 | +#define __CPROVER_char_set(s, p, c) __CPROVER_uninterpreted_string_char_set_func(s, p, c) |
| 47 | + |
| 48 | + |
| 49 | +#define __CPROVER_string_copy(s) __CPROVER_uninterpreted_string_copy_func(s) |
| 50 | +#define __CPROVER_parse_int(s) __CPROVER_uninterpreted_string_parse_int_func(s) |
| 51 | +#define __CPROVER_string_of_int(i) __CPROVER_uninterpreted_string_of_int_func(i) |
| 52 | + |
| 53 | + |
| 54 | +/****************************************************************************** |
| 55 | + * don't use these directly |
| 56 | + ******************************************************************************/ |
| 57 | +extern __CPROVER_char __CPROVER_uninterpreted_string_char_at_func(__CPROVER_string str, int pos); |
| 58 | +extern __CPROVER_bool __CPROVER_uninterpreted_string_equal_func(__CPROVER_string str1, __CPROVER_string str2); |
| 59 | +extern __CPROVER_string __CPROVER_uninterpreted_string_literal_func(); |
| 60 | +extern __CPROVER_char __CPROVER_uninterpreted_char_literal_func(); |
| 61 | +extern __CPROVER_string __CPROVER_uninterpreted_string_concat_func(__CPROVER_string str1, __CPROVER_string str2); |
| 62 | +extern int __CPROVER_uninterpreted_string_length_func(__CPROVER_string str); |
| 63 | +extern __CPROVER_string __CPROVER_uninterpreted_string_substring_func(__CPROVER_string str, int i, int j); |
| 64 | +extern __CPROVER_bool __CPROVER_uninterpreted_string_is_prefix_func(__CPROVER_string pref, __CPROVER_string str); |
| 65 | +extern __CPROVER_bool __CPROVER_uninterpreted_string_is_suffix_func(__CPROVER_string suff, __CPROVER_string str); |
| 66 | +extern __CPROVER_bool __CPROVER_uninterpreted_string_contains_func(__CPROVER_string str1, __CPROVER_string str2); |
| 67 | +extern int __CPROVER_uninterpreted_string_index_of_func(__CPROVER_string str, __CPROVER_char c); |
| 68 | +extern int __CPROVER_uninterpreted_string_last_index_of_func(__CPROVER_string str, __CPROVER_char c); |
| 69 | +extern __CPROVER_string __CPROVER_uninterpreted_string_char_set_func(__CPROVER_string str, int pos, __CPROVER_char c); |
| 70 | +extern __CPROVER_string __CPROVER_uninterpreted_string_copy_func(__CPROVER_string str); |
| 71 | +extern unsigned __CPROVER_uninterpreted_string_parse_int_func(__CPROVER_string str); |
| 72 | +extern __CPROVER_string __CPROVER_uninterpreted_string_of_int_func(unsigned i); |
| 73 | + |
0 commit comments