Gyoji Compiler
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Gyoji::mir::Symbols Class Reference

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 Symbolget_symbol (std::string name) const
 Look up a symbol by name.
 
void dump (FILE *out) const
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Symbols()

Symbols::Symbols ( )

Creates a new symbol table.

◆ ~Symbols()

Symbols::~Symbols ( )

Move along, nothing to see here.

Move along, nothing to see here.

Member Function Documentation

◆ define_symbol()

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.

◆ dump()

void Symbols::dump ( FILE *  out) const

This is used to dump the content of the global symbol table for debugging purposes.

◆ get_symbol()

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.


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