TS_CPP
An efficient & easy to use implementation of a Symbol table used in most compilers
Loading...
Searching...
No Matches
TS_CPP::Entry Class Reference

#include <Entry.h>

Public Member Functions

 Entry (SymbolTable *parentTable, const std::string &lexeme, int id)
 
std::string getLexeme () const
 
int getId () const
 
AttributeValue * getAttribute (const std::string &attributeName)
 
long long getDisplacement ()
 
void setNumericAttribute (const std::string &attributeName, long long value)
 
void setSize (int size)
 
void _setDisplacement (int displacement)
 
void _markAsDeleted ()
 
bool _isDeleted () const
 
void setStringAttribute (const std::string &attributeName, const char *value)
 
bool deleteAttribute (const std::string &attributeName)
 
bool getHaveSize () const
 
std::unordered_map< std::string, AttributeValue * > & _getAttributesStorage ()
 

Detailed Description

Entry class provides support for each row inside the symbol table It consists of a lexeme, an id and an undefined amount of pairs consisting of attribute name and value (int/string)

Definition at line 18 of file Entry.h.

Constructor & Destructor Documentation

◆ Entry()

Entry::Entry ( SymbolTable * parentTable,
const std::string & lexeme,
int id )

The constructor of an Entry It should not be used directly, but using the method SymbolTable::createNewEntry

Parameters
parentTableThe parent table of this entry
lexemeThe lexeme of this entry
idThe unique identifier of the entry

Definition at line 7 of file Entry.cpp.

Member Function Documentation

◆ _getAttributesStorage()

std::unordered_map< std::string, AttributeValue * > & Entry::_getAttributesStorage ( )

This function should not be used during normal operation and is intended for advanced users only This function provides access to the Attribute Storage object

Returns
a reference to the Attribute Storage object

Definition at line 85 of file Entry.cpp.

◆ _isDeleted()

bool Entry::_isDeleted ( ) const

This function should not be used during normal operation and is intended for advanced users only This function returns true if the entry has been marked as deleted and false otherwise

Returns
true if the entry has been marked as deleted and false otherwise

Definition at line 117 of file Entry.cpp.

◆ _markAsDeleted()

void Entry::_markAsDeleted ( )

This function should not be used during normal operation and is intended for advanced users only This function marks the entry as deleted

Definition at line 112 of file Entry.cpp.

◆ _setDisplacement()

void Entry::_setDisplacement ( int displacement)

This function stores the displacement of the entry in the attribute TS_DISPLACEMENT_ATTR_NAME

Parameters
displacementThe displacement of the entry

Definition at line 90 of file Entry.cpp.

◆ deleteAttribute()

bool Entry::deleteAttribute ( const std::string & attributeName)

This function deletes the attribute with the specified name from the Entry

Parameters
attributeNameThe name of the attribute to delete
Returns
True if the attribute was successfully deleted or false if the attribute doesn't exist

Definition at line 70 of file Entry.cpp.

◆ getAttribute()

AttributeValue * Entry::getAttribute ( const std::string & attributeName)

This function search for the attribute with the specified name and returns its value If the attribute does not exist, it returns a special attribute with attributeType=Null and data.str = nullptr (or data.num = 0)

Parameters
attributeNameThe name of the attribute to search for
Returns
The value of the attribute if the attribute exist or NoAttribute (a special attribute with attributeType=NOATRIB and data.str = nullptr (or data.num = 0)) if it doesn't exist

Definition at line 26 of file Entry.cpp.

◆ getDisplacement()

long long Entry::getDisplacement ( )

This function retrieves the displacement of the entry.

Returns
The displacement of the entry

Definition at line 102 of file Entry.cpp.

◆ getHaveSize()

bool Entry::getHaveSize ( ) const

This function returns true if the size of the entry has been set and false otherwise

Returns
true if the size of the entry has been set and false otherwise

Definition at line 107 of file Entry.cpp.

◆ getId()

int Entry::getId ( ) const

This function retrieves the unique identifier of the entry

Returns
The id of the entry

Definition at line 21 of file Entry.cpp.

◆ getLexeme()

std::string Entry::getLexeme ( ) const

This function retrieves the lexeme of this entry

Returns
A string which holds the lexeme of the entry

Definition at line 16 of file Entry.cpp.

◆ setNumericAttribute()

void Entry::setNumericAttribute ( const std::string & attributeName,
long long value )

This function stores a new attribute with the desired name and value If the attribute already exist, it overwrites it

Parameters
attributeNameThe name of the attribute to store
valueThe value of the attribute to store

Definition at line 40 of file Entry.cpp.

◆ setSize()

void Entry::setSize ( int size)

This function stores the size of the entry in the parent symbol table

Parameters
sizeThe size of the entry

Definition at line 95 of file Entry.cpp.

◆ setStringAttribute()

void Entry::setStringAttribute ( const std::string & attributeName,
const char * value )

This function stores a new attribute with the desired name and value If the attribute already exist, it overwrites it

Parameters
attributeNameThe name of the attribute to store
valueThe value of the attribute to store

Definition at line 55 of file Entry.cpp.


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