tipc
A TIP to LLVM compiler
Public Member Functions | Static Public Member Functions | List of all members
SymbolTable Class Reference

Performs symbol analysis and records results for subsequent phases. More...

#include <SymbolTable.h>

Public Member Functions

 SymbolTable (std::map< std::string, std::pair< ASTDeclNode *, bool >> fMap, std::map< ASTDeclNode *, std::map< std::string, ASTDeclNode * >> lMap, std::vector< std::string > fSet)
 
ASTDeclNodegetFunction (std::string s)
 Return the declaration node for a given function name. More...
 
bool getPoly (std::string s)
 Return an indication of whether the function was declared as polymorphic. More...
 
std::vector< ASTDeclNode * > getFunctions ()
 Return the declaration nodes for functions in the program. More...
 
ASTDeclNodegetLocal (std::string s, ASTDeclNode *f)
 Return the declaration node for local or a parameter in a function. More...
 
std::vector< ASTDeclNode * > getLocals (ASTDeclNode *f)
 Return the declaration nodes for locals and parameters in a function. More...
 
std::vector< std::string > getFields ()
 Returns the record field names referenced in the program. More...
 
void print (std::ostream &os)
 Print symbol table contents to output stream. More...
 

Static Public Member Functions

static std::shared_ptr< SymbolTablebuild (ASTProgram *p)
 Perform symbol analysis and construct symbol table. More...
 

Detailed Description

Performs symbol analysis and records results for subsequent phases.

The symbol table maps names of identifiers to declaration nodes. There is a global map of for function names and a local map for each function. In addition it records the set of field names used in the program. Errors are reported by raising a SemanticError exception.

See also
SemanticError

Constructor & Destructor Documentation

◆ SymbolTable()

SymbolTable::SymbolTable ( std::map< std::string, std::pair< ASTDeclNode *, bool >>  fMap,
std::map< ASTDeclNode *, std::map< std::string, ASTDeclNode * >>  lMap,
std::vector< std::string >  fSet 
)
inline

Member Function Documentation

◆ build()

SymbolTable::build ( ASTProgram p)
static

Perform symbol analysis and construct symbol table.

Errors are reported by raising a SemanticError exception.

Parameters
pThe AST for the program.
Returns
The symbol table.

◆ getFields()

std::vector< std::string > SymbolTable::getFields ( )

Returns the record field names referenced in the program.

◆ getFunction()

ASTDeclNode * SymbolTable::getFunction ( std::string  s)

Return the declaration node for a given function name.

Parameters
sThe Function name
Returns
The declaration node of the function

◆ getFunctions()

std::vector< ASTDeclNode * > SymbolTable::getFunctions ( )

Return the declaration nodes for functions in the program.

◆ getLocal()

ASTDeclNode * SymbolTable::getLocal ( std::string  s,
ASTDeclNode f 
)

Return the declaration node for local or a parameter in a function.

Parameters
sThe local or parameter name
fThe declaration node of the function
Returns
The declaration node of the local or parameter

◆ getLocals()

std::vector< ASTDeclNode * > SymbolTable::getLocals ( ASTDeclNode f)

Return the declaration nodes for locals and parameters in a function.

Parameters
fThe declaration node of the function.

◆ getPoly()

bool SymbolTable::getPoly ( std::string  s)

Return an indication of whether the function was declared as polymorphic.

Parameters
sThe Function name
Returns
True if the function is declared polymorphic

◆ print()

void SymbolTable::print ( std::ostream &  os)

Print symbol table contents to output stream.


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