cprover
namespace_baset Class Referenceabstract

Basic interface for a namespace. More...

#include <namespace.h>

+ Inheritance diagram for namespace_baset:

Public Member Functions

const symboltlookup (const irep_idt &name) const
 Lookup a symbol in the namespace. More...
 
const symboltlookup (const symbol_exprt &) const
 Generic lookup function for a symbol expression in a symbol table. More...
 
const symboltlookup (const symbol_typet &) const
 Generic lookup function for a symbol type in a symbol table. More...
 
const symboltlookup (const tag_typet &) const
 Generic lookup function for a tag type in a symbol table. More...
 
virtual ~namespace_baset ()
 
void follow_macros (exprt &) const
 Follow macros to their values in a given expression. More...
 
const typetfollow (const typet &) const
 Resolve type symbol to the type it points to. More...
 
const typetfollow_tag (const union_tag_typet &) const
 Follow type tag of union type. More...
 
const typetfollow_tag (const struct_tag_typet &) const
 Follow type tag of struct type. More...
 
const typetfollow_tag (const c_enum_tag_typet &) const
 Follow type tag of enum type. More...
 
virtual std::size_t smallest_unused_suffix (const std::string &prefix) const =0
 Returns the minimal integer n such that there is no symbol (in any of the symbol tables) whose name is of the form "An" where A is prefix. More...
 
virtual bool lookup (const irep_idt &name, const symbolt *&symbol) const =0
 Searches for a symbol named name. More...
 

Detailed Description

Basic interface for a namespace.

This is not used in practice, as the one being used is namespacet which uses two symbol tables, and multi_namespacet which can combine more than two.

Definition at line 34 of file namespace.h.

Constructor & Destructor Documentation

◆ ~namespace_baset()

namespace_baset::~namespace_baset ( )
virtual

Definition at line 40 of file namespace.cpp.

Member Function Documentation

◆ follow()

const typet & namespace_baset::follow ( const typet src) const

Resolve type symbol to the type it points to.

Parameters
srcThe type we want to resolve in the symbol table.
Returns
The resolved type.

Definition at line 80 of file namespace.cpp.

◆ follow_macros()

void namespace_baset::follow_macros ( exprt expr) const

Follow macros to their values in a given expression.

Parameters
exprThe expression to follow macros in.

Definition at line 143 of file namespace.cpp.

◆ follow_tag() [1/3]

const typet & namespace_baset::follow_tag ( const union_tag_typet src) const

Follow type tag of union type.

Parameters
srcThe union tag type to dispatch on.
Returns
The type of the union tag in the symbol table.

Definition at line 108 of file namespace.cpp.

◆ follow_tag() [2/3]

const typet & namespace_baset::follow_tag ( const struct_tag_typet src) const

Follow type tag of struct type.

Parameters
srcThe struct tag type to dispatch on.
Returns
The type of the struct tag in the symbol table.

Definition at line 120 of file namespace.cpp.

◆ follow_tag() [3/3]

const typet & namespace_baset::follow_tag ( const c_enum_tag_typet src) const

Follow type tag of enum type.

Parameters
srcThe enum tag type to dispatch on.
Returns
The type of the enum tag in the symbol table.

Definition at line 132 of file namespace.cpp.

◆ 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 44 of file namespace.h.

◆ lookup() [2/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 50 of file namespace.cpp.

◆ lookup() [3/5]

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

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

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

Definition at line 61 of file namespace.cpp.

◆ lookup() [4/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 72 of file namespace.cpp.

◆ lookup() [5/5]

virtual bool namespace_baset::lookup ( const irep_idt name,
const symbolt *&  symbol 
) const
pure 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.

Implemented in multi_namespacet, and namespacet.

◆ smallest_unused_suffix()

virtual std::size_t namespace_baset::smallest_unused_suffix ( const std::string &  prefix) const
pure virtual

Returns the minimal integer n such that there is no symbol (in any of the symbol tables) whose name is of the form "An" where A is prefix.

The intended use case is finding the next available symbol name for a sequence of auto-generated symbols.

Implemented in multi_namespacet, and namespacet.


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