OpenVDB 13.0.0

Loading...
Searching...
No Matches
SymbolTableBlocks Struct Reference

A map of unique ids to symbol tables which can be used to represent local variables within a program. New scopes can be added and erased where necessary and iterated through using find(). Find assumes that tables are added through parented ascending ids. More...

`#include <openvdb_ax/codegen/SymbolTable.h>`

## Public Types
using | MapType = std::map<size_t, SymbolTable<Value>>

## Public Member Functions
| SymbolTableBlocks ()
| ~SymbolTableBlocks ()=default
SymbolTable< llvm::Value * > & | globals ()
| Access to the list of global variables which are always accessible.
const SymbolTable< llvm::Value * > & | globals () const
bool | erase (const size_t index)
| Erase a given scoped indexed SymbolTable from the list of held SymbolTables. Returns true if the table previously existed.
SymbolTable< Value > * | getOrInsert (const size_t index)
| Get or insert and get a SymbolTable with a unique index.
SymbolTable< Value > * | get (const size_t index)
| Get a SymbolTable with a unique index. If it doesn't exist, nullptr is returned.
const Value * | find (const std::string &name, const size_t startIndex) const
| Find a variable within the program starting at a given table index. If the given index does not exist, the next descending index is used.
const Value * | find (const std::string &name) const
| Find a variable within the program starting at the lowest level SymbolTable.
bool | replace (const std::string &name, Value value)
| Replace the first occurrance of a variable with a given name with a replacement value. Returns true if a replacement occurred.

## Detailed Description

A map of unique ids to symbol tables which can be used to represent local variables within a program. New scopes can be added and erased where necessary and iterated through using find(). Find assumes that tables are added through parented ascending ids.

Note
  The zero id is used to represent the top block scope, but globals are stored separately.
  The block symbol table is fairly simple and currently only supports insertion by integer ids. Scopes that exist at the same level are expected to be built in isolation and erase and re-create the desired ids where necessary.

## Member Typedef Documentation

## ◆ MapType

using MapType = std::map<size_t, SymbolTable<Value>>

## Constructor & Destructor Documentation

## ◆ SymbolTableBlocks()

SymbolTableBlocks | ( |  | ) |
| inline

## ◆ ~SymbolTableBlocks()

~SymbolTableBlocks | ( |  | ) |
| default

## Member Function Documentation

## ◆ erase()

bool erase | ( | const size_t | index | ) |
| inline

Erase a given scoped indexed SymbolTable from the list of held SymbolTables. Returns true if the table previously existed.

Parameters

  index | The SymbolTable index to erase

## ◆ find() [1/2]

const Value * find | ( | const std::string & | name | ) | const
| inline

Find a variable within the program starting at the lowest level SymbolTable.

Parameters

  name | The variable name to find

## ◆ find() [2/2]

const Value * find | ( | const std::string & | name,
|  | const size_t | startIndex ) const
| inline

Find a variable within the program starting at a given table index. If the given index does not exist, the next descending index is used.

Note
  This function assumes that tables have been added in ascending order dictating their nested structure.

Parameters

  name | The variable name to find
  startIndex | The start SymbolTable index

## ◆ get()

SymbolTable< Value > * get | ( | const size_t | index | ) |
| inline

Get a SymbolTable with a unique index. If it doesn't exist, nullptr is returned.

Parameters

  index | The SymbolTable index

## ◆ getOrInsert()

SymbolTable< Value > * getOrInsert | ( | const size_t | index | ) |
| inline

Get or insert and get a SymbolTable with a unique index.

Parameters

  index | The SymbolTable index

## ◆ globals() [1/2]

SymbolTable< llvm::Value * > & globals | ( |  | ) |
| inline

Access to the list of global variables which are always accessible.

## ◆ globals() [2/2]

const SymbolTable< llvm::Value * > & globals | ( |  | ) | const
| inline

## ◆ replace()

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

Replace the first occurrance of a variable with a given name with a replacement value. Returns true if a replacement occurred.

Parameters

  name | The variable name to find and replace
  value | The llvm::Value to replace