cprover
replace_symbol.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 #ifndef CPROVER_UTIL_REPLACE_SYMBOL_H
11 #define CPROVER_UTIL_REPLACE_SYMBOL_H
12 
13 //
14 // true: did nothing
15 // false: replaced something
16 //
17 
18 #include "expr.h"
19 
21 {
22 public:
23  typedef std::unordered_map<irep_idt, exprt, irep_id_hash> expr_mapt;
24  typedef std::unordered_map<irep_idt, typet, irep_id_hash> type_mapt;
25 
26  void insert(const irep_idt &identifier,
27  const exprt &expr)
28  {
29  expr_map.insert(std::pair<irep_idt, exprt>(identifier, expr));
30  }
31 
32  void insert(const class symbol_exprt &old_expr,
33  const exprt &new_expr);
34 
35  void insert(const irep_idt &identifier,
36  const typet &type)
37  {
38  type_map.insert(std::pair<irep_idt, typet>(identifier, type));
39  }
40 
41  virtual bool replace(exprt &dest) const;
42  virtual bool replace(typet &dest) const;
43 
44  void operator()(exprt &dest) const
45  {
46  replace(dest);
47  }
48 
49  void operator()(typet &dest) const
50  {
51  replace(dest);
52  }
53 
54  void clear()
55  {
56  expr_map.clear();
57  type_map.clear();
58  }
59 
60  bool empty() const
61  {
62  return expr_map.empty() && type_map.empty();
63  }
64 
66  virtual ~replace_symbolt();
67 
70 
71 protected:
72  bool have_to_replace(const exprt &dest) const;
73  bool have_to_replace(const typet &type) const;
74 };
75 
76 #endif // CPROVER_UTIL_REPLACE_SYMBOL_H
The type of an expression.
Definition: type.h:20
bool empty() const
void operator()(exprt &dest) const
virtual bool replace(exprt &dest) const
std::unordered_map< irep_idt, exprt, irep_id_hash > expr_mapt
bool have_to_replace(const exprt &dest) const
virtual ~replace_symbolt()
Base class for all expressions.
Definition: expr.h:46
void insert(const irep_idt &identifier, const exprt &expr)
type_mapt type_map
Expression to hold a symbol (variable)
Definition: std_expr.h:82
void operator()(typet &dest) const
expr_mapt expr_map
void insert(const irep_idt &identifier, const typet &type)
std::unordered_map< irep_idt, typet, irep_id_hash > type_mapt