CBMC
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_args.h"
21 
22 struct template_parametert;
23 class template_typet;
24 
26 {
27 public:
28  // this maps template parameters to their instantiated value
29  typedef std::map<irep_idt, typet> type_mapt;
30  typedef std::map<irep_idt, exprt> expr_mapt;
33 
34  void apply(exprt &dest) const;
35  void apply(typet &dest) const;
36 
37  void swap(template_mapt &template_map)
38  {
39  type_map.swap(template_map.type_map);
40  expr_map.swap(template_map.expr_map);
41  }
42 
43  exprt lookup(const irep_idt &identifier) const;
44  typet lookup_type(const irep_idt &identifier) const;
45  exprt lookup_expr(const irep_idt &identifier) const;
46 
47  void print(std::ostream &out) const;
48 
49  void clear()
50  {
51  type_map.clear();
52  expr_map.clear();
53  }
54 
55  void set(
56  const template_parametert &parameter,
57  const exprt &value);
58 
59  void build(
60  const template_typet &template_type,
61  const cpp_template_args_tct &template_args);
62 
63  void build_unassigned(
64  const template_typet &template_type);
65 
67  const template_typet &template_type) const;
68 };
69 
71 {
72 public:
74  old_map(map), map(map)
75  {
76  }
77 
79  {
80  #if 0
81  std::cout << "RESTORING TEMPLATE MAP\n";
82  #endif
83  map.swap(old_map);
84  }
85 
86 private:
89 };
90 
91 #endif // CPROVER_CPP_TEMPLATE_MAP_H
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
template_mapt::build_unassigned
void build_unassigned(const template_typet &template_type)
Definition: template_map.cpp:214
template_parametert
Definition: cpp_template_parameter.h:19
typet
The type of an expression, extends irept.
Definition: type.h:28
cpp_saved_template_mapt::cpp_saved_template_mapt
cpp_saved_template_mapt(template_mapt &map)
Definition: template_map.h:73
exprt
Base class for all expressions.
Definition: expr.h:55
template_mapt::build_template_args
cpp_template_args_tct build_template_args(const template_typet &template_type) const
Definition: template_map.cpp:236
cpp_template_args.h
cpp_template_args_tct
Definition: cpp_template_args.h:64
template_mapt::expr_map
expr_mapt expr_map
Definition: template_map.h:32
template_mapt::apply
void apply(exprt &dest) const
Definition: template_map.cpp:73
template_mapt::lookup
exprt lookup(const irep_idt &identifier) const
Definition: template_map.cpp:93
expr.h
cpp_saved_template_mapt::~cpp_saved_template_mapt
~cpp_saved_template_mapt()
Definition: template_map.h:78
template_mapt::swap
void swap(template_mapt &template_map)
Definition: template_map.h:37
template_mapt::lookup_type
typet lookup_type(const irep_idt &identifier) const
Definition: template_map.cpp:114
cpp_saved_template_mapt
Definition: template_map.h:70
template_mapt::print
void print(std::ostream &out) const
Definition: template_map.cpp:136
cpp_saved_template_mapt::old_map
template_mapt old_map
Definition: template_map.h:87
template_mapt::expr_mapt
std::map< irep_idt, exprt > expr_mapt
Definition: template_map.h:30
template_mapt::lookup_expr
exprt lookup_expr(const irep_idt &identifier) const
Definition: template_map.cpp:125
template_mapt::type_map
type_mapt type_map
Definition: template_map.h:31
template_mapt
Definition: template_map.h:25
template_mapt::set
void set(const template_parametert &parameter, const exprt &value)
Definition: template_map.cpp:188
template_typet
Definition: cpp_template_type.h:18
template_mapt::type_mapt
std::map< irep_idt, typet > type_mapt
Definition: template_map.h:29
template_mapt::build
void build(const template_typet &template_type, const cpp_template_args_tct &template_args)
Definition: template_map.cpp:145
cpp_saved_template_mapt::map
template_mapt & map
Definition: template_map.h:88
template_mapt::clear
void clear()
Definition: template_map.h:49