blob: d22de22d10684b1333164078472e879a0bb10a4f (
plain)
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
|
/*
* ProgramNode.cpp
*
* Created on: Nov 5, 2012
* Author: attero
*/
#include "ProgramNode.h"
ProgramNode::ProgramNode() {
//Do nothing
this->type = "ProgramNode";
}
ProgramNode::~ProgramNode() {
for(auto it = children.begin(); it != children.end(); )
{
delete *it;
it = children.erase(it);
}
}
void ProgramNode::execute() {
for (std::vector<ASTNode *>::iterator it = children.begin(); it!=children.end(); ++it) {
(*it)->execute();
}
}
void ProgramNode::accept(Visitor * visitor)
{
visitor->visit(this);
}
void ProgramNode::execute_last()
{
children[children.size() - 1]->execute();
}
SenchaObject ProgramNode::evaluate_last()
{
SenchaObject result = (children[children.size() - 1])->evaluate();
return result;
}
std::string ProgramNode::debug()
{
std::string debug_note = "Program started debugging\n";
for (std::vector<ASTNode *>::iterator it = children.begin(); it!=children.end(); ++it) {
debug_note += (*it)->debug() + "\n";
}
debug_note += "END\n";
return debug_note;
}
void ProgramNode::add_statement(ASTStatement * statement)
{
children.push_back(statement);
}
|