OpenVDB  12.0.0
Public Types | Public Member Functions | List of all members
SymbolTable Struct Reference

A symbol table which can be used to represent a single scoped set of a programs variables. This is simply an unordered map of strings to llvm::Values. More...

#include <openvdb_ax/codegen/SymbolTable.h>

Public Types

using MapType = std::unordered_map< std::string, llvm::Value * >
 

Public Member Functions

 SymbolTable ()
 
 ~SymbolTable ()=default
 
llvm::Value * get (const std::string &name) const
 Get a llvm::Value from this symbol table with the given name mapping. It it does not exist, a nullptr is returned. More...
 
bool exists (const std::string &name) const
 Returns true if a variable exists in this symbol table with the given name. More...
 
bool insert (const std::string &name, llvm::Value *value)
 Insert a variable to this symbol table if it does not exist. Returns true if successfully, false if a variable already exists with the given name. More...
 
bool replace (const std::string &name, llvm::Value *value)
 Replace a variable in this symbol table. Returns true if the variable previously existed and false if not. In both cases, the variable is inserted. More...
 
void clear ()
 Clear all symbols in this table. More...
 
const MapTypemap () const
 Access to the underlying map. More...
 

Detailed Description

A symbol table which can be used to represent a single scoped set of a programs variables. This is simply an unordered map of strings to llvm::Values.

Note
Consider using llvm's ValueSymbolTable

Member Typedef Documentation

using MapType = std::unordered_map<std::string, llvm::Value*>

Constructor & Destructor Documentation

SymbolTable ( )
inline
~SymbolTable ( )
default

Member Function Documentation

void clear ( )
inline

Clear all symbols in this table.

bool exists ( const std::string &  name) const
inline

Returns true if a variable exists in this symbol table with the given name.

Parameters
nameThe name of the variable
llvm::Value* get ( const std::string &  name) const
inline

Get a llvm::Value from this symbol table with the given name mapping. It it does not exist, a nullptr is returned.

Parameters
nameThe name of the variable
bool insert ( const std::string &  name,
llvm::Value *  value 
)
inline

Insert a variable to this symbol table if it does not exist. Returns true if successfully, false if a variable already exists with the given name.

Parameters
nameThe name of the variable
valueThe llvm::Value corresponding to this variable
const MapType& map ( ) const
inline

Access to the underlying map.

bool replace ( const std::string &  name,
llvm::Value *  value 
)
inline

Replace a variable in this symbol table. Returns true if the variable previously existed and false if not. In both cases, the variable is inserted.

Parameters
nameThe name of the variable
valueThe llvm::Value corresponding to this variable