-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSymTab.hpp
More file actions
37 lines (26 loc) · 915 Bytes
/
SymTab.hpp
File metadata and controls
37 lines (26 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef EXPRINTER_SYMTAB_HPP
#define EXPRINTER_SYMTAB_HPP
#include <string>
#include <map>
#include "TypeDescriptor.hpp"
// This is a flat symbol table. It allows for variables to be
// initialized, determines if a give variable has been defined or not, and if
// a variable has been defined, it returns its value.
class SymTab {
public:
SymTab();
bool isDefined(std::string vName);
void setValueFor(std::string vName, TypeDescriptor* td);
TypeDescriptor* getValueFor(std::string vName);
void openScope(std::map<std::string, TypeDescriptor*> newSymTab);
void storeReturnValue(TypeDescriptor *val);
TypeDescriptor* getReturnValue();
void closeScope();
int getI() { return i; }
void print();
private:
std::vector<std::map<std::string, TypeDescriptor*> > symTabs;
int i; // current SymTab depth
TypeDescriptor* returnVal;
};
#endif //EXPRINTER_SYMTAB_HPP