-
Notifications
You must be signed in to change notification settings - Fork 0
/
tempVarTable.h
51 lines (35 loc) · 1.19 KB
/
tempVarTable.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
41
42
43
44
45
46
47
48
49
50
51
#ifndef COMPILER_TEMPVARTABLE_H
#define COMPILER_TEMPVARTABLE_H
#include "stdafx.h"
#include "symbolTable.h"
typedef struct {
std::string var;
std::string addr;
std::string val;
SyntaxType syntaxType;
std::string reg;
int regNumber = -1;
int scope;
bool isGlobal;
}TempVar;
class TempVarTable {
public:
TempVarTable();
~TempVarTable();
void addScope();
void decreaseScope();
void pushConVar(std::string &conVar, std::string &val, SyntaxType syntaxType);
void pushVar(std::string &var, SyntaxType syntaxType);
void pushArray(std::string &array, SyntaxType syntaxType, int arrLen);
void pushFunc(std::string &func, std::vector<std::string> ¶ms, std::vector<SyntaxType> paramsType);
TempVar& getVarAddr(std::string &var, SyntaxType syntaxType=INT);
std::vector<std::string>& getFuncParamAddr(std::string &func);
int getCurAddr();
void updataVarRegUse(const std::string &var);
private:
std::vector<TempVar> tempVarTable;
std::map<std::string, std::vector<std::string>> funcParamAddr;
int scope = 0;
int curAddr = 0;
};
#endif //COMPILER_TEMPVARTABLE_H