cprover
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_SYMBOL_H
11 #define CPROVER_UTIL_SYMBOL_H
12 
20 #include <iosfwd>
21 
22 #include "expr.h"
23 
30 class symbolt
31 {
32 public:
35 
38 
41 
44 
47 
50 
53 
56 
57  const irep_idt &display_name() const
58  {
60  }
61 
62  // global use
65 
66  // ANSI-C
70 
72  {
73  clear();
74  }
75 
76  void clear()
77  {
78  type.make_nil();
79  value.make_nil();
81 
83 
89  }
90 
91  void swap(symbolt &b);
92  void show(std::ostream &out) const;
93 
94  class symbol_exprt symbol_expr() const;
95 
96  bool is_shared() const
97  {
98  return !is_thread_local;
99  }
100 
101  bool is_procedure_local() const
102  {
103  return !is_static_lifetime;
104  }
105 
106  bool is_function() const
107  {
108  return !is_type && !is_macro && type.id()==ID_code;
109  }
110 };
111 
112 std::ostream &operator<<(std::ostream &out, const symbolt &symbol);
113 
119 class type_symbolt:public symbolt
120 {
121 public:
122  explicit type_symbolt(const typet &_type)
123  {
124  type=_type;
125  is_type=true;
126  }
127 };
128 
136 {
137 public:
139  {
140  is_lvalue=true;
141  is_state_var=true;
142  is_thread_local=true;
143  is_file_local=true;
144  is_auxiliary=true;
145  }
146 
149  {
150  this->name=name;
151  this->base_name=name;
152  this->type=type;
153  }
154 };
155 
162 {
163 public:
165  {
166  is_lvalue=true;
167  is_state_var=true;
168  is_thread_local=true;
169  is_file_local=true;
170  is_parameter=true;
171  }
172 };
173 
174 #endif // CPROVER_UTIL_SYMBOL_H
The type of an expression.
Definition: type.h:22
irep_idt name
The unique identifier.
Definition: symbol.h:43
bool is_output
Definition: symbol.h:63
bool is_shared() const
Definition: symbol.h:96
bool is_thread_local
Definition: symbol.h:67
void show(std::ostream &out) const
Definition: symbol.cpp:16
Symbol table entry of function parameterThis is a symbol generated as part of type checking...
Definition: symbol.h:161
irep_idt mode
Language mode.
Definition: symbol.h:52
void clear()
Definition: symbol.h:76
exprt value
Initial value of symbol.
Definition: symbol.h:37
type_symbolt(const typet &_type)
Definition: symbol.h:122
irep_idt module
Name of module the symbol belongs to.
Definition: symbol.h:46
irep_idt pretty_name
Language-specific display name.
Definition: symbol.h:55
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
Definition: symbol.h:30
symbolt()
Definition: symbol.h:71
bool is_static_lifetime
Definition: symbol.h:67
bool is_input
Definition: symbol.h:63
Symbol table entry describing a data typeThis is a symbol generated as part of type checking...
Definition: symbol.h:119
const irep_idt & id() const
Definition: irep.h:259
class symbol_exprt symbol_expr() const
produces a symbol_exprt for a symbol
Definition: symbol.cpp:111
bool is_exported
Definition: symbol.h:63
bool is_parameter
Definition: symbol.h:68
Internally generated symbol table entryThis is a symbol generated as part of translation to or modifi...
Definition: symbol.h:135
void swap(symbolt &b)
Definition: symbol.cpp:76
std::ostream & operator<<(std::ostream &out, const symbolt &symbol)
Definition: symbol.cpp:69
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
Definition: dstring.h:33
auxiliary_symbolt(const irep_idt &name, const typet &type)
Definition: symbol.h:147
bool is_function() const
Definition: symbol.h:106
bool is_volatile
Definition: symbol.h:68
const irep_idt & display_name() const
Definition: symbol.h:57
bool is_extern
Definition: symbol.h:68
typet type
Type of symbol.
Definition: symbol.h:34
source_locationt location
Source code location of definition of symbol.
Definition: symbol.h:40
Base class for all expressions.
Definition: expr.h:42
bool is_state_var
Definition: symbol.h:63
irep_idt base_name
Base (non-scoped) name.
Definition: symbol.h:49
bool is_file_local
Definition: symbol.h:68
void make_nil()
Definition: irep.h:315
bool is_weak
Definition: symbol.h:68
bool is_procedure_local() const
Definition: symbol.h:101
Expression to hold a symbol (variable)
Definition: std_expr.h:90
bool is_auxiliary
Definition: symbol.h:68
dstringt irep_idt
Definition: irep.h:32
bool is_type
Definition: symbol.h:63
bool is_property
Definition: symbol.h:63
bool empty() const
Definition: dstring.h:73
bool is_macro
Definition: symbol.h:63
bool is_lvalue
Definition: symbol.h:68