-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommaList.cpp
More file actions
executable file
·53 lines (38 loc) · 1.03 KB
/
CommaList.cpp
File metadata and controls
executable file
·53 lines (38 loc) · 1.03 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
#include "CommaList.hpp"
CommaList::CommaList(Variable* var1, Variable* var2) : Variable(nullptr, Types::COMMALIST, -2) {
if(var1->getScope() == -1)
internalVariables.add(new Variable(var1));
else
internalVariables.add(var1);
if(var2->getScope() == -1)
internalVariables.add(new Variable(var2));
else
internalVariables.add(var2);
}
CommaList::~CommaList() {
ListIterator<Variable>* it = internalVariables.getIterator();
while(it->hasMore()) {
if(it->getValue()->getScope() == -1) {
delete it->getValue();
it->setValue(nullptr);
}
it->next();
}
delete it;
internalVariables.clearWithoutDeletingContents();
}
void CommaList::add(Variable* var) {
if(var->getScope() == -1)
internalVariables.add(new Variable(var));
else
internalVariables.add(var);
}
void CommaList::print() {
ListIterator<Variable>* it = internalVariables.getIterator();
while(it->hasMore()) {
it->getValue()->print();
it->next();
}
delete it;
std::cout << std::endl;
}