-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscope.cpp
More file actions
67 lines (59 loc) · 1.24 KB
/
scope.cpp
File metadata and controls
67 lines (59 loc) · 1.24 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
#include "scope.h"
Scope::~Scope()
{
delete this->topASTNode;
for(auto i:this->functionList)
delete i.second;
for(auto i:this->variableList)
delete i.second;
for(Scope* i:this->sonScope)
delete i;
}
void Scope::addVariable(string name)
{
Variable* var=new Variable();
#ifdef READABLEGEN
var->NAME=name;
#endif
this->variableList[name]=var;
}
void Scope::addVariable(string name, Variable *var)
{
#ifdef READABLEGEN
var->NAME=name;
#endif
this->variableList[name]=var;
}
void Scope::addFunction(string name, Function *fun)
{
#ifdef READABLEGEN
fun->NAME=name;
#endif
this->functionList[name]=fun;
}
/*void Scope::deleteFunction(string name)
{
delete this->functionList[name];
this->functionList.erase(name);
}
void Scope::deleteVariable(string name)
{
delete this->variableList[name];
this->variableList.erase(name);
}*/
void Scope::deleteVariable(Variable *var)
{
for(auto p:this->variableList)
{
if(p.second==var)
this->variableList.erase(p.first);
}
}
void Scope::deleteFunction(Function *fun)
{
for(auto p:this->functionList)
{
if(p.second==fun)
this->functionList.erase(p.first);
}
}