Falcon::SymbolTable Class Reference

#include <symtab.h>

Inheritance diagram for Falcon::SymbolTable:

Inheritance graph
[legend]

List of all members.

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.
SymbolfindByName (const String &name) const
 Seek a symbol given its name.
bool load (Module *owner, Stream *in)
 Load the symbol table from a stream.
const Mapmap () 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.


Constructor & Destructor Documentation

Falcon::SymbolTable::SymbolTable (  ) 

Constructs the symbol table.

The symbol table is built with owndership of the symbols.


Member Function Documentation

bool Falcon::SymbolTable::add ( const String name,
Symbol sym 
)

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.

Note:
The name will never be deleted by this class. The caller must have a safe way to track the symbol existance and delete the name safely. Usually both official symbol names and alias are stored in the module symbol table, and destroyed with the module (which also destroys the symbol table).
Parameters:
name the arbitrary alias of this symbol.
sym the symbol to be added.
Returns:
true if the symbol can be added, false if it were already present.

bool Falcon::SymbolTable::add ( Symbol sym  ) 

Adds a symbol.

The name of the symbol is used as the key in the symbol table.

Parameters:
sym the symbol to be added.
Returns:
true if the symbol can be added, false if it were already present.

void Falcon::SymbolTable::exportUndefined (  ) 

Exports all the undefined symbols.

Used by the compiler if the module being compiled asked for complete export.

Symbol* Falcon::SymbolTable::findByName ( const String name  )  const [inline]

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.

Note:
it is possible also to call this function with static C strings from code.
Parameters:
name the name of the symbol to be found.
Returns:
a pointer to the symbol if it's found, or 0 otherwise.

bool Falcon::SymbolTable::load ( Module owner,
Stream in 
)

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.

Parameters:
owner the module for which the symbols are created.
in the input stream where the table must be loaded from.
Returns:
true if the operation has success, false otherwise.

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.

Parameters:
name the name of the symbol to be destroyed.
Returns:
true if the name can be found, false otherwise.

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.

Parameters:
out the stream where the table must be saved.
Returns:
true if the operation has success, false otherwise.

int Falcon::SymbolTable::size (  )  const [inline]

Return the number of symbols stored in this table.

Returns:
the number of symbols stored in this table.


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

Generated on Mon Oct 19 10:11:47 2009 for Falcon_Core by  doxygen 1.5.8