Repository navigation
Expand file tree
/
Copy pathNode.h
More file actions
92 lines (79 loc) · 1.86 KB
/
Copy pathNode.h
File metadata and controls
92 lines (79 loc) · 1.86 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef TreeNode_H
#define TreeNode_H
#include "syntax_tree.h"
#define GenNode(x) \
class x##TreeNode: public TreeNode{ \
public:\
virtual string Codegen() override; \
}; \
#define SwitchClass(x) \
if(#x == classname) return new x##TreeNode();
#define smartEmit \
if(optimize && !isEmit()){ return "NULL";} \
#define addDep(x,y) \
if(y.size()>0 && y.at(0)!='-' && isdigit(y.at(0)) ){\
cover.dependency[x].insert(y); \
cover.affectedVar.insert(x); \
}
GenNode(PROGRAM);
GenNode(EXTDEFS);
class EXTDEFTreeNode: public TreeNode{
public:
virtual string Codegen() override;
virtual bool isEmit() override ;
};
GenNode(SEXTVARS);
GenNode(EXTVARS);
GenNode(STSPEC);
GenNode(FUNC);
GenNode(PARAS);
GenNode(STMTBLOCK);
GenNode(STMTS);
GenNode(STMT);
GenNode(DEFS);
GenNode(SDEFS);
GenNode(SDECS);
GenNode(DECS);
GenNode(VAR);
GenNode(INIT);
GenNode(EXP);
GenNode(EXPS);
GenNode(ARRS);
GenNode(INT);
class ARGSTreeNode: public TreeNode{
public:
virtual void CodeHelperGen() override;
virtual string Codegen() override;
};
GenNode(UNARYOP);
class ConstValue{
public:
static TreeNode * get(const string classname){
SwitchClass(PROGRAM);
SwitchClass(EXTDEFS);
SwitchClass(EXTDEF);
SwitchClass(SEXTVARS);
SwitchClass(EXTVARS);
SwitchClass(STSPEC);
SwitchClass(FUNC);
SwitchClass(PARAS);
SwitchClass(STMTBLOCK);
SwitchClass(STMTS);
SwitchClass(STMT);
SwitchClass(DEFS);
SwitchClass(SDEFS);
SwitchClass(SDECS);
SwitchClass(DECS);
SwitchClass(VAR);
SwitchClass(INIT);
SwitchClass(EXP);
SwitchClass(EXPS);
SwitchClass(ARRS);
SwitchClass(ARGS);
SwitchClass(UNARYOP);
SwitchClass(INT);
return new TreeNode();
};
};
TreeNode* createNodeIns(int line,string type, string content, int childrenSize, ...);
#endif