#include <symtab.h>
Public Member Functions | |
bool | add (const String *name, Symbol *sym) |
Inserts a symbol in the table with an arbitrary name. | |
bool | add (Symbol *sym) |
Adds a symbol. | |
void | exportUndefined () |
Exports all the undefined symbols. | |
Symbol * | findByName (const String &name) const |
Seek a symbol given its name. | |
bool | load (Module *owner, Stream *in) |
Load the symbol table from a stream. | |
const Map & | map () const |
bool | remove (const String &name) |
Remove a symbol given it's name. | |
bool | save (Stream *out) const |
Save the symbol table on a stream. | |
int | size () const |
Return the number of symbols stored in this table. | |
SymbolTable () | |
Constructs the symbol table. |
Falcon::SymbolTable::SymbolTable | ( | ) |
Constructs the symbol table.
The symbol table is built with owndership of the symbols.
Inserts a symbol in the table with an arbitrary name.
This makes possible to add a symbol in the table with a name different from the one the symbol has. It is used i.e. by classes that must access their symbol using a name that is not the "official" one, by instead a "nickname" which refers to the property.
name | the arbitrary alias of this symbol. | |
sym | the symbol to be added. |
bool Falcon::SymbolTable::add | ( | Symbol * | sym | ) |
Adds a symbol.
The name of the symbol is used as the key in the symbol table.
sym | the symbol to be added. |
void Falcon::SymbolTable::exportUndefined | ( | ) |
Exports all the undefined symbols.
Used by the compiler if the module being compiled asked for complete export.
Seek a symbol given its name.
If the symbol with the given name can't be found in the symbol table, the function returns null.
name | the name of the symbol to be found. |
Load the symbol table from a stream.
If the symbol table owns the symbols, then the symbols are serialized on the stream too; otherwise, only the ID are saved.
The deserialization may return false if the function detects some problem, i.e. an invald format.
owner | the module for which the symbols are created. | |
in | the input stream where the table must be loaded from. |
const Map& Falcon::SymbolTable::map | ( | ) | const [inline] |
bool Falcon::SymbolTable::remove | ( | const String & | name | ) |
Remove a symbol given it's name.
If the SymbolTable has the ownership of the symbols, then the symbol is destroyed. The symbol name is never destroyed though.
name | the name of the symbol to be destroyed. |
bool Falcon::SymbolTable::save | ( | Stream * | out | ) | const |
Save the symbol table on a stream.
The serialization of the table involves only saving the ID of the strings and of the symbols that are in the table.
out | the stream where the table must be saved. |
int Falcon::SymbolTable::size | ( | ) | const [inline] |
Return the number of symbols stored in this table.