-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSymbolTable.h
40 lines (34 loc) · 943 Bytes
/
SymbolTable.h
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
38
39
40
#pragma once
#include<map>
#include<string>
#include<vector>
#include<iostream>
#include"SubSymbolTable.h"
using namespace std;
class SymbolTable {
public:
int mainSymbolId;
SymbolTable();
~SymbolTable();
SymbolEntry* addSymbol(string currentScope,string name,bool isFunction);
SymbolEntry* getSymbolByName(string currentScope,string name);
SymbolEntry* getSymbolById(int id);
SymbolEntry* addTmpSymbol(string function, int id);
SubSymbolTable* getSubSymbolTableByName(string s);
int addString(string str);
string getString(int id);
map<int, vector<int>> summary();
void debugOn();
void selfTest();
void dumpMipsCodeHeader(ostream& f);
friend ostream& operator<<(ostream& out, SymbolTable& t);
private:
int count;
bool debug=false;
map<string, SubSymbolTable*>scope;
SubSymbolTable globalScope;
vector<SymbolEntry*>symbolId;
map<int,SymbolEntry*>tmpSymbolId;
int stringCount;
vector<string> unnamedStrings;
};