forked from Uyouii/cCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
block.h
49 lines (40 loc) · 796 Bytes
/
block.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
#ifndef _BLOCK_H_
#define _BLOCK_H_
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include "tree.h"
using namespace std;
//变量节点
struct varNode {
string name;
string type;
int num = -1;
bool useAddress = false;
string boolString;
};
//函数节点
struct funcNode {
bool isdefinied = false;
string name; //函数名
string rtype; //函数返回类型
vector<varNode> paralist; //记录形参列表
};
//数组节点
struct arrayNode {
string name;
string type;
int num = -1;
};
//block的内容
class Block {
public:
funcNode func; //如果是函数,记录函数名
bool isfunc = false;//记录是否是函数
map<string, struct varNode> varMap; //变量的map
map<string, struct arrayNode> arrayMap; //数组的map
string breakLabelname;
bool canBreak = false;
};
#endif // !_BLOCK_H_