Class Symbol

Nested Relationships

Nested Types

Class Documentation

class Symbol

Public Functions

Symbol(const std::string &name, bool is_field)

Initialize a new symbol. The class is set to

Parameters
  • name: Name of the symbol
  • is_field: True if the symbol is a class field.

Symbol(std::string name, bool is_field, Quack::Class *q_class)
Quack::Class *get_type() const

Updates the class of the symbol.

Parameters
  • q_class: New class for the symbol.

Friends

friend Symbol::CodeGen::Gen
friend Symbol::Quack::Class
class Table

Public Functions

~Table()

Deletes all symbols in the table.

void add_new(const std::string &symbol_name, bool is_field, Quack::Class *new_class)

Adds a new symbol the table. The symbol is set to the base class of all classes.

Parameters
  • symbol_name: Name of the symbol
  • is_field: True if the new symbol is a field Updates the class of the specified
  • symbol:
  • new_class:

void update(const std::string &symbol_name, bool is_field, Quack::Class *new_class)

Updates the class of the specified symbol. If the object class has changed, the symbol table is marked as dirty.

Parameters
  • symbol_name: Name of the symbol to update.
  • new_class: True if the corresponding symbol is a class field.

void update(const Symbol *symbol, Quack::Class *new_class)

Updates the class of the specified symbol. If the object class has changed, the symbol table is marked as dirty.

Parameters
  • symbol_name: Name of the symbol to update.
  • new_class: True if the corresponding symbol is a class field.

const bool is_dirty() const

Accessor for whether the symbol table is dirty, i.e., whether it has changed since the last time the dirty was clear.

Return
True if a change has occurred.

void clear_dirty()

Resets the dirty flag for the symbol table.

Symbol *get(const std::string &symbol_name, bool is_field) const

Accessor for a symbol table item.

Return
Corresponding symbol object.
Parameters
  • symbol_name: Name of the symbol
  • is_field: True if the symbol is a field.

std::map<SymbolKey, Symbol *>::iterator begin()

Returns an iterator to the beginning of the objects in the symbol table

Return
Beginning of the symbol table

std::map<SymbolKey, Symbol *>::iterator end()

Returns an iterator the end of the object in the symbol table

Return
End of the symbol table