tipc
A TIP to LLVM compiler
|
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) | |
ASTDeclNode * | getFunction (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... | |
ASTDeclNode * | getLocal (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< SymbolTable > | build (ASTProgram *p) |
Perform symbol analysis and construct symbol table. More... | |
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.
|
inline |
|
static |
Perform symbol analysis and construct symbol table.
Errors are reported by raising a SemanticError exception.
p | The AST for the program. |
std::vector< std::string > SymbolTable::getFields | ( | ) |
Returns the record field names referenced in the program.
ASTDeclNode * SymbolTable::getFunction | ( | std::string | s | ) |
Return the declaration node for a given function name.
s | The Function name |
std::vector< ASTDeclNode * > SymbolTable::getFunctions | ( | ) |
Return the declaration nodes for functions in the program.
ASTDeclNode * SymbolTable::getLocal | ( | std::string | s, |
ASTDeclNode * | f | ||
) |
Return the declaration node for local or a parameter in a function.
s | The local or parameter name |
f | The declaration node of the function |
std::vector< ASTDeclNode * > SymbolTable::getLocals | ( | ASTDeclNode * | f | ) |
Return the declaration nodes for locals and parameters in a function.
f | The declaration node of the function. |
bool SymbolTable::getPoly | ( | std::string | s | ) |
Return an indication of whether the function was declared as polymorphic.
s | The Function name |
void SymbolTable::print | ( | std::ostream & | os | ) |
Print symbol table contents to output stream.