CBMC
contracts_wrangler.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Parse and annotate contracts from configuration files
4 
5 Author: Qinheping Hu
6 
7 Date: June 2023
8 
9 \*******************************************************************/
10 
13 
14 #ifndef CPROVER_GOTO_INSTRUMENT_CONTRACTS_CONTRACTS_WRANGLER_H
15 #define CPROVER_GOTO_INSTRUMENT_CONTRACTS_CONTRACTS_WRANGLER_H
16 
17 #include <util/message.h>
18 #include <util/namespace.h>
19 #include <util/replace_symbol.h>
20 #include <util/string_utils.h>
21 
24 
25 #include <json/json_parser.h>
26 
27 #include <regex>
28 
30 {
31  std::string identifier;
32  std::string invariants;
33  std::string assigns;
34  std::string decreases;
36 
38  std::string _identifier,
39  std::string _invariants_str,
40  std::string _assigns_str,
41  std::string _decreases_str,
42  unchecked_replace_symbolt _replace_symbol)
43  : identifier(std::move(_identifier)),
44  invariants(std::move(_invariants_str)),
45  assigns(_assigns_str),
46  decreases(_decreases_str),
47  replace_symbol(_replace_symbol)
48  {
49  }
50 };
51 
52 struct functiont
53 {
54  std::vector<loop_contracts_clauset> loop_contracts;
55  std::string regex_str;
56 };
57 
58 using functionst = std::list<std::pair<std::regex, functiont>>;
59 
61 {
62 public:
65  const std::string &file_name,
67 
69 
70 protected:
74 
76 
78 
79  void configure_functions(const jsont &);
80 
84  void mangle(
85  const loop_contracts_clauset &loop_contracts,
86  const irep_idt &function_id);
87 
92  std::string function_name,
93  const std::size_t num_of_args);
94 };
95 
96 #endif // CPROVER_GOTO_INSTRUMENT_CONTRACTS_CONTRACTS_WRANGLER_H
goto_modelt & goto_model
symbol_tablet & symbol_table
message_handlert & message_handler
goto_functionst & goto_functions
void configure_functions(const jsont &)
void add_builtin_pointer_function_symbol(std::string function_name, const std::size_t num_of_args)
Add builtin function symbol with function_name into symbol table.
contracts_wranglert(goto_modelt &goto_model, const std::string &file_name, message_handlert &message_handler)
void mangle(const loop_contracts_clauset &loop_contracts, const irep_idt &function_id)
Mangle loop_contracts in the function with function_id
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
A collection of goto functions.
Definition: json.h:27
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
The symbol table.
Definition: symbol_table.h:14
Goto Programs with Functions.
Symbol Table + CFG.
std::string regex_str
std::vector< loop_contracts_clauset > loop_contracts
loop_contracts_clauset(std::string _identifier, std::string _invariants_str, std::string _assigns_str, std::string _decreases_str, unchecked_replace_symbolt _replace_symbol)
unchecked_replace_symbolt replace_symbol