File tree 3 files changed +56
-0
lines changed
3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,25 @@ exprt string_set_char_builtin_functiont::length_constraint() const
187
187
equal_exprt (return_code, return_value));
188
188
}
189
189
190
+ optionalt<exprt> string_to_lower_case_builtin_functiont::eval (
191
+ const std::function<exprt(const exprt &)> &get_value) const
192
+ {
193
+ auto input_opt = eval_string (input, get_value);
194
+ if (!input_opt)
195
+ return {};
196
+ for (mp_integer &c : input_opt.value ())
197
+ {
198
+ if (
199
+ (' A' <= c && c <= ' Z' ) || (0xc0 <= c && c <= 0xd6 ) ||
200
+ (0xd8 <= c && c <= 0xde ))
201
+ c += 0x20 ;
202
+ }
203
+ const auto length =
204
+ from_integer (input_opt.value ().size (), result.length ().type ());
205
+ const array_typet type (result.type ().subtype (), length);
206
+ return make_string (input_opt.value (), type);
207
+ }
208
+
190
209
std::vector<mp_integer> string_insertion_builtin_functiont::eval (
191
210
const std::vector<mp_integer> &input1_value,
192
211
const std::vector<mp_integer> &input2_value,
Original file line number Diff line number Diff line change @@ -177,6 +177,39 @@ class string_set_char_builtin_functiont
177
177
exprt length_constraint () const override ;
178
178
};
179
179
180
+ // / Converting each uppercase character of Basic Latin and Latin-1 supplement
181
+ // / to the corresponding lowercase character.
182
+ class string_to_lower_case_builtin_functiont
183
+ : public string_transformation_builtin_functiont
184
+ {
185
+ public:
186
+ string_to_lower_case_builtin_functiont (
187
+ const exprt &return_code,
188
+ const std::vector<exprt> &fun_args,
189
+ array_poolt &array_pool)
190
+ : string_transformation_builtin_functiont(return_code, fun_args, array_pool)
191
+ {
192
+ }
193
+
194
+ optionalt<exprt>
195
+ eval (const std::function<exprt(const exprt &)> &get_value) const override ;
196
+
197
+ std::string name () const override
198
+ {
199
+ return " to_lower_case" ;
200
+ }
201
+
202
+ exprt add_constraints (string_constraint_generatort &generator) const override
203
+ {
204
+ return generator.add_axioms_for_to_lower_case (result, input);
205
+ };
206
+
207
+ exprt length_constraint () const override
208
+ {
209
+ return equal_exprt (result.length (), input.length ());
210
+ };
211
+ };
212
+
180
213
// / String inserting a string into another one
181
214
class string_insertion_builtin_functiont : public string_builtin_functiont
182
215
{
Original file line number Diff line number Diff line change @@ -232,6 +232,10 @@ static std::unique_ptr<string_builtin_functiont> to_string_builtin_function(
232
232
return util_make_unique<string_set_char_builtin_functiont>(
233
233
return_code, fun_app.arguments (), array_pool);
234
234
235
+ if (id == ID_cprover_string_to_lower_case_func)
236
+ return util_make_unique<string_to_lower_case_builtin_functiont>(
237
+ return_code, fun_app.arguments (), array_pool);
238
+
235
239
return util_make_unique<string_builtin_function_with_no_evalt>(
236
240
return_code, fun_app, array_pool);
237
241
}
You can’t perform that action at this time.
0 commit comments