CBMC
Loading...
Searching...
No Matches
multi_namespacet Class Reference

A multi namespace is essentially a namespace, with a list of namespaces. More...

#include <namespace.h>

+ Inheritance diagram for multi_namespacet:
+ Collaboration diagram for multi_namespacet:

Public Member Functions

 multi_namespacet ()
 
 multi_namespacet (const symbol_table_baset &symbol_table)
 
bool lookup (const irep_idt &name, const symbolt *&symbol) const override
 See documentation for namespace_baset::lookup().
 
std::size_t smallest_unused_suffix (const std::string &prefix) const override
 See documentation for namespace_baset::smallest_unused_suffix().
 
void add (const symbol_table_baset &symbol_table)
 Add symbol table to the list of symbol tables this multi-namespace is working with.
 
const symboltlookup (const irep_idt &name) const
 Lookup a symbol in the namespace.
 
const symboltlookup (const symbol_exprt &) const
 Generic lookup function for a symbol expression in a symbol table.
 
const symboltlookup (const tag_typet &) const
 Generic lookup function for a tag type in a symbol table.
 
virtual bool lookup (const irep_idt &name, const symbolt *&symbol) const=0
 Searches for a symbol named name.
 
- Public Member Functions inherited from namespacet
 namespacet (const symbol_table_baset &_symbol_table)
 
 namespacet (const symbol_table_baset &_symbol_table1, const symbol_table_baset &_symbol_table2)
 
 namespacet (const symbol_table_baset *_symbol_table1, const symbol_table_baset *_symbol_table2)
 
bool lookup (const irep_idt &name, const symbolt *&symbol) const override
 See documentation for namespace_baset::lookup().
 
std::size_t smallest_unused_suffix (const std::string &prefix) const override
 See documentation for namespace_baset::smallest_unused_suffix().
 
const symbol_table_basetget_symbol_table () const
 Return first symbol table registered with the namespace.
 
const symboltlookup (const irep_idt &name) const
 Lookup a symbol in the namespace.
 
const symboltlookup (const symbol_exprt &) const
 Generic lookup function for a symbol expression in a symbol table.
 
const symboltlookup (const tag_typet &) const
 Generic lookup function for a tag type in a symbol table.
 
virtual bool lookup (const irep_idt &name, const symbolt *&symbol) const=0
 Searches for a symbol named name.
 
- Public Member Functions inherited from namespace_baset
const symboltlookup (const irep_idt &name) const
 Lookup a symbol in the namespace.
 
const symboltlookup (const symbol_exprt &) const
 Generic lookup function for a symbol expression in a symbol table.
 
const symboltlookup (const tag_typet &) const
 Generic lookup function for a tag type in a symbol table.
 
virtual ~namespace_baset ()
 
void follow_macros (exprt &) const
 Follow macros to their values in a given expression.
 
const union_typetfollow_tag (const union_tag_typet &) const
 Follow type tag of union type.
 
const struct_typetfollow_tag (const struct_tag_typet &) const
 Follow type tag of struct type.
 
const c_enum_typetfollow_tag (const c_enum_tag_typet &) const
 Follow type tag of enum type.
 
const struct_union_typetfollow_tag (const struct_or_union_tag_typet &) const
 Resolve a struct_tag_typet or union_tag_typet to the complete version.
 

Protected Types

typedef std::vector< const symbol_table_baset * > symbol_table_listt
 

Protected Attributes

symbol_table_listt symbol_table_list
 
- Protected Attributes inherited from namespacet
const symbol_table_basetsymbol_table1
 
const symbol_table_basetsymbol_table2
 

Detailed Description

A multi namespace is essentially a namespace, with a list of namespaces.

It's difference with namespacet is that it can use more than two symbol tables to lookup symbols in.

Definition at line 136 of file namespace.h.

Member Typedef Documentation

◆ symbol_table_listt

Definition at line 168 of file namespace.h.

Constructor & Destructor Documentation

◆ multi_namespacet() [1/2]

multi_namespacet::multi_namespacet ( )
inline

Definition at line 140 of file namespace.h.

◆ multi_namespacet() [2/2]

multi_namespacet::multi_namespacet ( const symbol_table_baset symbol_table)
inlineexplicit

Definition at line 144 of file namespace.h.

Member Function Documentation

◆ add()

void multi_namespacet::add ( const symbol_table_baset symbol_table)
inline

Add symbol table to the list of symbol tables this multi-namespace is working with.

Parameters
symbol_tableReference to the symbol table to be added to this namespace.

Definition at line 162 of file namespace.h.

◆ lookup() [1/5]

const symbolt & namespace_baset::lookup ( const irep_idt name) const
inline

Lookup a symbol in the namespace.

Parameters
nameThe name of the symbol to lookup.
Returns
A reference to the symbol found.
Remarks
: It is a PRECONDITION that the symbol name exists in the namespace.

Definition at line 45 of file namespace.h.

◆ lookup() [2/5]

bool multi_namespacet::lookup ( const irep_idt name,
const symbolt *&  symbol 
) const
overridevirtual

See documentation for namespace_baset::lookup().

Iterate through the symbol tables in the multi-namespace and lookup the symbol.

Parameters
nameThe name of the symbol to be looked up.
symbolThe const pointer to the reference of the symbol if it's found during lookup.
Returns
False if the symbol was found, True otherwise.

Implements namespace_baset.

Definition at line 185 of file namespace.cpp.

◆ lookup() [3/5]

virtual bool namespace_baset::lookup ( const irep_idt name,
const symbolt *&  symbol 
) const
virtual

Searches for a symbol named name.

Iff found, set symbol to point to the symbol and return false; else symbol is unmodified and true is returned. With multiple symbol tables, symbol_table1 is searched first and then symbol_table2.

Returns
False iff the requested symbol is found in at least one of the tables.

Implements namespace_baset.

◆ lookup() [4/5]

const symbolt & namespace_baset::lookup ( const symbol_exprt expr) const

Generic lookup function for a symbol expression in a symbol table.

Parameters
exprThe symbol expression to lookup.
Returns
The symbol found in the namespace.
Remarks
The lookup function called assumes that the symbol we are looking for exists in the symbol table. If it doesn't, it hits an INVARIANT.

Definition at line 57 of file namespace.cpp.

◆ lookup() [5/5]

const symbolt & namespace_baset::lookup ( const tag_typet type) const

Generic lookup function for a tag type in a symbol table.

Parameters
typeThe tag type to lookup.
Returns
The symbol found in the namespace.
Remarks
The lookup function called assumes that the tag symbol we are looking for exists in the symbol table. If it doesn't, it hits an INVARIANT.

Definition at line 58 of file namespace.cpp.

◆ smallest_unused_suffix()

std::size_t multi_namespacet::smallest_unused_suffix ( const std::string &  prefix) const
overridevirtual

See documentation for namespace_baset::smallest_unused_suffix().

Find smallest unused suffix in the all the symbol tables.

Parameters
prefixThe prefix to find smallest unused suffix of.
Returns
The smallest prefix size.

Implements namespace_baset.

Definition at line 169 of file namespace.cpp.

Member Data Documentation

◆ symbol_table_list

symbol_table_listt multi_namespacet::symbol_table_list
protected

Definition at line 169 of file namespace.h.


The documentation for this class was generated from the following files: