cprover
template_map.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: C++ Language Type Checking
4 
5 Author: Daniel Kroening, kroening@cs.cmu.edu
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_CPP_TEMPLATE_MAP_H
13 #define CPROVER_CPP_TEMPLATE_MAP_H
14 
15 #include <map>
16 #include <iosfwd>
17 
18 #include <util/expr.h>
19 
20 #include "cpp_template_type.h"
21 #include "cpp_template_args.h"
22 
24 {
25 public:
26  // this maps template parameters to their instantiated value
27  typedef std::map<irep_idt, typet> type_mapt;
28  typedef std::map<irep_idt, exprt> expr_mapt;
31 
32  void apply(exprt &dest) const;
33  void apply(typet &dest) const;
34 
35  void swap(template_mapt &template_map)
36  {
37  type_map.swap(template_map.type_map);
38  expr_map.swap(template_map.expr_map);
39  }
40 
41  exprt lookup(const irep_idt &identifier) const;
42  typet lookup_type(const irep_idt &identifier) const;
43  exprt lookup_expr(const irep_idt &identifier) const;
44 
45  void print(std::ostream &out) const;
46 
47  void clear()
48  {
49  type_map.clear();
50  expr_map.clear();
51  }
52 
53  void set(
54  const template_parametert &parameter,
55  const exprt &value);
56 
57  void build(
58  const template_typet &template_type,
59  const cpp_template_args_tct &template_args);
60 
61  void build_unassigned(
62  const template_typet &template_type);
63 
65  const template_typet &template_type) const;
66 };
67 
69 {
70 public:
72  old_map(map), map(map)
73  {
74  }
75 
77  {
78  #if 0
79  std::cout << "RESTORING TEMPLATE MAP\n";
80  #endif
81  map.swap(old_map);
82  }
83 
84 private:
87 };
88 
89 #endif // CPROVER_CPP_TEMPLATE_MAP_H
The type of an expression, extends irept.
Definition: type.h:27
void set(const template_parametert &parameter, const exprt &value)
void apply(exprt &dest) const
cpp_saved_template_mapt(template_mapt &map)
Definition: template_map.h:71
expr_mapt expr_map
Definition: template_map.h:30
std::map< irep_idt, exprt > expr_mapt
Definition: template_map.h:28
void build(const template_typet &template_type, const cpp_template_args_tct &template_args)
exprt lookup(const irep_idt &identifier) const
void swap(template_mapt &template_map)
Definition: template_map.h:35
std::map< irep_idt, typet > type_mapt
Definition: template_map.h:27
exprt lookup_expr(const irep_idt &identifier) const
type_mapt type_map
Definition: template_map.h:29
cpp_template_args_tct build_template_args(const template_typet &template_type) const
typet lookup_type(const irep_idt &identifier) const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:35
C++ Language Type Checking.
template_mapt old_map
Definition: template_map.h:85
Base class for all expressions.
Definition: expr.h:54
template_mapt & map
Definition: template_map.h:86
void build_unassigned(const template_typet &template_type)
void print(std::ostream &out) const