CBMC
string_format_builtin_function.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Built-in function for String.format
4 
5 Author: Romain Brenguier, Joel Allred
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_SOLVERS_STRINGS_STRING_FORMAT_BUILTIN_FUNCTION_H
13 #define CPROVER_SOLVERS_STRINGS_STRING_FORMAT_BUILTIN_FUNCTION_H
14 
16 
17 class format_specifiert;
18 
63 {
64 public:
69  std::vector<array_string_exprt> inputs;
70 
77  const exprt &return_code,
78  const std::vector<exprt> &fun_args,
80 
82  {
83  return result;
84  }
85 
86  std::vector<array_string_exprt> string_arguments() const override
87  {
88  return inputs;
89  }
90 
92  eval(const std::function<exprt(const exprt &)> &get_value) const override;
93 
94  std::string name() const override
95  {
96  return "format";
97  }
98 
100  string_constraint_generatort &generator,
101  message_handlert &message_handler) const override;
102 
103  exprt length_constraint() const override;
104 
118  bool maybe_testing_function() const override
119  {
120  return false;
121  }
122 };
123 
125  const exprt &integer,
126  const typet &length_type,
127  const unsigned long base);
128 
130  const format_specifiert &fs,
131  const array_string_exprt &arg,
132  const typet &index_type,
133  array_poolt &array_pool);
134 
135 #endif // CPROVER_SOLVERS_STRINGS_STRING_FORMAT_BUILTIN_FUNCTION_H
string_builtin_function.h
string_format_builtin_functiont::constraints
string_constraintst constraints(string_constraint_generatort &generator, message_handlert &message_handler) const override
Add constraints ensuring that the value of result expression of the builtin function corresponds to t...
Definition: string_format_builtin_function.cpp:588
typet
The type of an expression, extends irept.
Definition: type.h:28
array_poolt
Correspondance between arrays and pointers string representations.
Definition: array_pool.h:41
string_builtin_functiont::return_code
exprt return_code
Definition: string_builtin_function.h:111
string_format_builtin_functiont
Built-in function for String.format().
Definition: string_format_builtin_function.h:62
exprt
Base class for all expressions.
Definition: expr.h:55
string_format_builtin_functiont::string_format_builtin_functiont
string_format_builtin_functiont(const exprt &return_code, const std::vector< exprt > &fun_args, array_poolt &array_pool)
Constructor from arguments of a function application.
Definition: string_format_builtin_function.cpp:29
string_constraintst
Collection of constraints of different types: existential formulas, universal formulas,...
Definition: string_constraint_generator.h:38
index_type
bitvector_typet index_type()
Definition: c_types.cpp:22
string_format_builtin_functiont::result
array_string_exprt result
Definition: string_format_builtin_function.h:65
string_constraint_generatort
Definition: string_constraint_generator.h:47
string_builtin_functiont::array_pool
array_poolt & array_pool
Definition: string_builtin_function.h:122
string_format_builtin_functiont::string_arguments
std::vector< array_string_exprt > string_arguments() const override
Definition: string_format_builtin_function.h:86
string_format_builtin_functiont::inputs
std::vector< array_string_exprt > inputs
Definition: string_format_builtin_function.h:69
string_format_builtin_functiont::string_result
optionalt< array_string_exprt > string_result() const override
Definition: string_format_builtin_function.h:81
message_handlert
Definition: message.h:27
string_format_builtin_functiont::name
std::string name() const override
Definition: string_format_builtin_function.h:94
optionalt
nonstd::optional< T > optionalt
Definition: optional.h:35
string_builtin_functiont
Base class for string functions that are built in the solver.
Definition: string_builtin_function.h:72
string_format_builtin_functiont::maybe_testing_function
bool maybe_testing_function() const override
In principle this function could return true, because the content of the string sometimes needs to be...
Definition: string_format_builtin_function.h:118
length_for_format_specifier
exprt length_for_format_specifier(const format_specifiert &fs, const array_string_exprt &arg, const typet &index_type, array_poolt &array_pool)
Return an expression representing the length of the format specifier Does not assume that arg is cons...
Definition: string_format_builtin_function.cpp:683
format_specifiert
Field names follow the OpenJDK implementation: http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/9b8c96f9...
Definition: format_specifier.h:22
string_format_builtin_functiont::format_string
optionalt< std::string > format_string
Only set when the format string is a constant.
Definition: string_format_builtin_function.h:68
length_of_decimal_int
exprt length_of_decimal_int(const exprt &integer, const typet &length_type, const unsigned long base)
Compute the length of the decimal representation of an integer.
Definition: string_format_builtin_function.cpp:650
string_format_builtin_functiont::eval
optionalt< exprt > eval(const std::function< exprt(const exprt &)> &get_value) const override
Given a function get_value which gives a valuation to expressions, attempt to find the result of the ...
Definition: string_format_builtin_function.cpp:518
array_string_exprt
Definition: string_expr.h:66
string_format_builtin_functiont::length_constraint
exprt length_constraint() const override
Constraint ensuring that the length of the strings are coherent with the function call.
Definition: string_format_builtin_function.cpp:765