TS_CPP
An efficient & easy to use implementation of a Symbol table used in most compilers
Loading...
Searching...
No Matches
Entry.h
1#ifndef TS_ENTRY_H
2#define TS_ENTRY_H
3
4#include "unordered_map"
5#include "string"
6
7#include "TSConfig.h"
8#include "AttributeValue.h"
9
10namespace TS_CPP{
11
12class SymbolTable;
13
18class Entry
19{
20public:
28 Entry(SymbolTable* parentTable, const std::string& lexeme, int id);
29
34 std::string getLexeme() const;
35
40 int getId() const;
41
48 AttributeValue* getAttribute(const std::string& attributeName);
49
54 long long getDisplacement();
55
62 void setNumericAttribute(const std::string& attributeName, long long value);
63
68 void setSize(int size);
69
74 void _setDisplacement(int displacement);
75
80 void _markAsDeleted();
81
87 bool _isDeleted() const;
88
95 void setStringAttribute(const std::string& attributeName, const char* value);
96
102 bool deleteAttribute(const std::string& attributeName);
103
108 bool getHaveSize() const;
109
115 std::unordered_map<std::string,AttributeValue*>& _getAttributesStorage();
116
117private:
118
120 int id;
121
123 bool haveSize = false;
124
126 bool isDeleted = false;
127
129 std::string lexeme;
130
132 std::unordered_map<std::string,AttributeValue*> attributes;
133
134 SymbolTable* parentTable;
135};
136
137}
138
139#endif //TS_ENTRY_H
Definition Entry.h:19
void _setDisplacement(int displacement)
Definition Entry.cpp:90
bool getHaveSize() const
Definition Entry.cpp:107
AttributeValue * getAttribute(const std::string &attributeName)
Definition Entry.cpp:26
void setStringAttribute(const std::string &attributeName, const char *value)
Definition Entry.cpp:55
int getId() const
Definition Entry.cpp:21
void setNumericAttribute(const std::string &attributeName, long long value)
Definition Entry.cpp:40
bool deleteAttribute(const std::string &attributeName)
Definition Entry.cpp:70
Entry(SymbolTable *parentTable, const std::string &lexeme, int id)
Definition Entry.cpp:7
void _markAsDeleted()
Definition Entry.cpp:112
bool _isDeleted() const
Definition Entry.cpp:117
long long getDisplacement()
Definition Entry.cpp:102
std::string getLexeme() const
Definition Entry.cpp:16
void setSize(int size)
Definition Entry.cpp:95
std::unordered_map< std::string, AttributeValue * > & _getAttributesStorage()
Definition Entry.cpp:85