CBMC
ansi_c_scope.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_ANSI_C_ANSI_C_SCOPE_H
11 #define CPROVER_ANSI_C_ANSI_C_SCOPE_H
12 
13 #include <util/irep.h>
14 
15 #include <unordered_map>
16 
17 enum class ansi_c_id_classt
18 {
22  ANSI_C_TAG,
24 };
25 
26 std::ostream &operator<<(std::ostream &os, ansi_c_id_classt c);
27 
29 {
30 public:
33 
35  {
36  }
37 };
38 
40 {
41 public:
42  // This maps "scope names" (tag-X, label-X, X) to
43  // ansi_c_identifiert.
44  typedef std::unordered_map<irep_idt, ansi_c_identifiert> name_mapt;
46 
47  std::string prefix;
48 
49  // We remember the last declarator for the benefit
50  // of function argument scoping.
52 
53  // for(;;) and { } scopes are numbered
54  unsigned compound_counter;
55  unsigned anon_counter;
56 
58 
59  void swap(ansi_c_scopet &scope)
60  {
61  name_map.swap(scope.name_map);
62  prefix.swap(scope.prefix);
64  std::swap(compound_counter, scope.compound_counter);
65  }
66 
67  void print(std::ostream &out) const;
68 };
69 
70 #endif // CPROVER_ANSI_C_ANSI_C_SCOPE_H
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
ansi_c_id_classt::ANSI_C_UNKNOWN
@ ANSI_C_UNKNOWN
ansi_c_scopet::ansi_c_scopet
ansi_c_scopet()
Definition: ansi_c_scope.h:57
ansi_c_scopet::swap
void swap(ansi_c_scopet &scope)
Definition: ansi_c_scope.h:59
ansi_c_id_classt
ansi_c_id_classt
Definition: ansi_c_scope.h:17
ansi_c_id_classt::ANSI_C_TYPEDEF
@ ANSI_C_TYPEDEF
ansi_c_scopet::prefix
std::string prefix
Definition: ansi_c_scope.h:47
ansi_c_scopet::print
void print(std::ostream &out) const
Definition: ansi_c_scope.cpp:13
ansi_c_scopet::last_declarator
irep_idt last_declarator
Definition: ansi_c_scope.h:51
dstringt::swap
void swap(dstringt &b)
Definition: dstring.h:161
ansi_c_scopet
Definition: ansi_c_scope.h:39
ansi_c_identifiert::prefixed_name
irep_idt prefixed_name
Definition: ansi_c_scope.h:32
ansi_c_scopet::compound_counter
unsigned compound_counter
Definition: ansi_c_scope.h:54
ansi_c_identifiert
Definition: ansi_c_scope.h:28
ansi_c_identifiert::ansi_c_identifiert
ansi_c_identifiert()
Definition: ansi_c_scope.h:34
ansi_c_scopet::name_mapt
std::unordered_map< irep_idt, ansi_c_identifiert > name_mapt
Definition: ansi_c_scope.h:44
ansi_c_identifiert::base_name
irep_idt base_name
Definition: ansi_c_scope.h:32
ansi_c_scopet::anon_counter
unsigned anon_counter
Definition: ansi_c_scope.h:55
ansi_c_id_classt::ANSI_C_TAG
@ ANSI_C_TAG
ansi_c_id_classt::ANSI_C_LOCAL_LABEL
@ ANSI_C_LOCAL_LABEL
ansi_c_id_classt::ANSI_C_SYMBOL
@ ANSI_C_SYMBOL
ansi_c_identifiert::id_class
ansi_c_id_classt id_class
Definition: ansi_c_scope.h:31
ansi_c_scopet::name_map
name_mapt name_map
Definition: ansi_c_scope.h:45
operator<<
std::ostream & operator<<(std::ostream &os, ansi_c_id_classt c)
irep.h