summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST/ProgramNode.cpp
blob: dd08876779e11bc6776376d473ddcc4ab90d4f97 (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
/*
 * 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;
}

void ProgramNode::add_statement(ASTStatement * statement)
{
	children.push_back(statement);
}