Gyoji Compiler
|
Symbol table for the intermediate representation (MIR) More...
#include <symbols.hpp>
Public Member Functions | |
Symbols () | |
~Symbols () | |
Move along, nothing to see here. | |
void | define_symbol (std::string name, const Type *symbol_type) |
Create a new global symbol. | |
const Symbol * | get_symbol (std::string name) const |
Look up a symbol by name. | |
void | dump (FILE *out) const |
Symbol table for the intermediate representation (MIR)
This class represents the table of all globally defined symbols such as global variables and function names. The names must be unique and care should be taken to always check whether a name already exists in the table when defining new symbols. It is the responsibility of the front-end to construct globally unique names.
This class is the owner of all symbols and they will be destroyed when the symbol table goes out of scope.
Symbols::Symbols | ( | ) |
Creates a new symbol table.
Symbols::~Symbols | ( | ) |
Move along, nothing to see here.
Move along, nothing to see here.
void Symbols::define_symbol | ( | std::string | name, |
const Type * | symbol_type | ||
) |
Create a new global symbol.
Defines a new symbol. Any existing symbol will This will be a no-op if the symbol name already exists. The caller is advised to always check that a symbol is defined before defining a new one.
void Symbols::dump | ( | FILE * | out | ) | const |
This is used to dump the content of the global symbol table for debugging purposes.
const Symbol * Symbols::get_symbol | ( | std::string | name | ) | const |
Look up a symbol by name.
This will return the symbol given by name if that symbol exists. If it does not exist, then nullptr will be returned instead.