20 typedef std::unordered_map<irep_idt, std::pair<size_t, bool>,
irep_id_hash>
37 if(ns.
lookup(identifier, symbol))
40 assert(symbol && symbol->
is_type);
42 if(symbol->
type.
id()!=ID_struct &&
43 symbol->
type.
id()!=ID_union)
49 std::pair<symbol_numbert::iterator, bool> entry=
50 symbol_number.insert(std::make_pair(
52 std::make_pair(symbol_number.size(),
true)));
57 result=
"SYM#"+std::to_string(entry.first->second.first);
62 entry.first->second.second=
false;
66 else if(entry.first->second.second)
67 result=
"SYM#"+std::to_string(entry.first->second.first);
71 entry.first->second.second=
true;
73 entry.first->second.second=
false;
78 result=
"SYM#"+std::to_string(entry.first->second.first);
102 if(type.
get_bool(ID_C_transparent_union))
114 throw "empty type encountered";
115 else if(type.
id()==ID_empty)
117 else if(type.
id()==ID_signedbv)
119 else if(type.
id()==ID_unsignedbv)
121 else if(type.
id()==ID_bool ||
122 type.
id()==ID_c_bool)
124 else if(type.
id()==ID_integer)
126 else if(type.
id()==ID_real)
128 else if(type.
id()==ID_complex)
130 else if(type.
id()==ID_floatbv)
132 else if(type.
id()==ID_fixedbv)
134 else if(type.
id()==ID_natural)
136 else if(type.
id()==ID_pointer)
138 else if(type.
id()==ID_reference)
140 else if(type.
id()==ID_code)
146 for(code_typet::parameterst::const_iterator
147 it=parameters.begin();
148 it!=parameters.end();
151 if(it!=parameters.begin())
153 result+=
type2name(it->type(), ns, symbol_number);
158 if(!parameters.empty())
166 else if(type.
id()==ID_array)
170 if(t.
size().
id()==ID_symbol)
177 else if(type.
id()==ID_symbol ||
178 type.
id()==ID_c_enum_tag ||
179 type.
id()==ID_struct_tag ||
180 type.
id()==ID_union_tag)
185 else if(type.
id()==ID_struct ||
190 if(type.
id()==ID_struct)
192 if(type.
id()==ID_union)
197 for(struct_union_typet::componentst::const_iterator
198 it=components.begin();
199 it!=components.end();
202 if(it!=components.begin())
204 result+=
type2name(it->type(), ns, symbol_number);
205 result+=
"'"+it->get_string(ID_name)+
"'";
209 else if(type.
id()==ID_incomplete_struct)
211 else if(type.
id()==ID_incomplete_union)
213 else if(type.
id()==ID_c_enum)
219 for(c_enum_typet::memberst::const_iterator
224 if(it!=members.begin())
227 result+=
"'"+
id2string(it->get_identifier())+
"'";
230 else if(type.
id()==ID_incomplete_c_enum)
232 else if(type.
id()==ID_c_bit_field)
234 else if(type.
id()==ID_vector)
237 throw "unknown type '"+type.
id_string()+
"' encountered";
251 result+=
type2name(*it, ns, symbol_number);
254 result[result.size()-1]=
'$';
264 return type2name(type, ns, symbol_number);
static std::string type2name(const typet &type, const namespacet &ns, symbol_numbert &symbol_number)
The type of an expression.
#define forall_subtypes(it, type)
bool has_subtypes() const
virtual bool lookup(const irep_idt &name, const symbolt *&symbol) const
const std::string & id2string(const irep_idt &d)
const std::string integer2string(const mp_integer &n, unsigned base)
bool has_ellipsis() const
const irep_idt & get_function() const
std::vector< componentt > componentst
std::vector< parametert > parameterst
const componentst & components() const
const memberst & members() const
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
std::unordered_map< irep_idt, std::pair< size_t, bool >, irep_id_hash > symbol_numbert
bool get_bool(const irep_namet &name) const
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a generic typet to a struct_union_typet.
const irep_idt & id() const
const array_typet & to_array_type(const typet &type)
Cast a generic typet to an array_typet.
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a generic typet to a c_enum_typet.
const irep_idt & get(const irep_namet &name) const
static bool parent_is_sym_check
const exprt & size() const
const source_locationt & source_location() const
static std::string type2name_symbol(const typet &type, const namespacet &ns, symbol_numbert &symbol_number)
typet type
Type of symbol.
Base type of C structs and unions, and C++ classes.
const parameterst & parameters() const
const std::string & get_string(const irep_namet &name) const
const code_typet & to_code_type(const typet &type)
Cast a generic typet to a code_typet.
const std::string & id_string() const
const typet & subtype() const
std::vector< c_enum_membert > memberst
const typet & return_type() const