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
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
template_mapt::build_unassigned
void build_unassigned(const template_typet &template_type)
Definition: template_map.cpp:211
template_parametert
Definition: cpp_template_parameter.h:20
typet
The type of an expression, extends irept.
Definition: type.h:29
cpp_saved_template_mapt::cpp_saved_template_mapt
cpp_saved_template_mapt(template_mapt &map)
Definition: template_map.h:71
exprt
Base class for all expressions.
Definition: expr.h:53
template_mapt::build_template_args
cpp_template_args_tct build_template_args(const template_typet &template_type) const
Definition: template_map.cpp:233
cpp_template_args.h
C++ Language Type Checking.
cpp_template_args_tct
Definition: cpp_template_args.h:65
template_mapt::expr_map
expr_mapt expr_map
Definition: template_map.h:30
template_mapt::apply
void apply(exprt &dest) const
Definition: template_map.cpp:70
template_mapt::lookup
exprt lookup(const irep_idt &identifier) const
Definition: template_map.cpp:90
expr.h
cpp_saved_template_mapt::~cpp_saved_template_mapt
~cpp_saved_template_mapt()
Definition: template_map.h:76
template_mapt::swap
void swap(template_mapt &template_map)
Definition: template_map.h:35
template_mapt::lookup_type
typet lookup_type(const irep_idt &identifier) const
Definition: template_map.cpp:111
cpp_saved_template_mapt
Definition: template_map.h:69
template_mapt::print
void print(std::ostream &out) const
Definition: template_map.cpp:133
cpp_saved_template_mapt::old_map
template_mapt old_map
Definition: template_map.h:85
template_mapt::expr_mapt
std::map< irep_idt, exprt > expr_mapt
Definition: template_map.h:28
template_mapt::lookup_expr
exprt lookup_expr(const irep_idt &identifier) const
Definition: template_map.cpp:122
template_mapt::type_map
type_mapt type_map
Definition: template_map.h:29
template_mapt
Definition: template_map.h:24
template_mapt::set
void set(const template_parametert &parameter, const exprt &value)
Definition: template_map.cpp:185
template_typet
Definition: cpp_template_type.h:19
template_mapt::type_mapt
std::map< irep_idt, typet > type_mapt
Definition: template_map.h:27
template_mapt::build
void build(const template_typet &template_type, const cpp_template_args_tct &template_args)
Definition: template_map.cpp:142
cpp_saved_template_mapt::map
template_mapt & map
Definition: template_map.h:86
cpp_template_type.h
template_mapt::clear
void clear()
Definition: template_map.h:47