summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST/BasicStatement.cpp
blob: abd010c6ffc6222ebc196911c57b16dbae7467d5 (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
/*
 * BasicStatement.cpp
 *
 *  Created on: Dec 5, 2012
 *      Author: attero
 */

#include "BasicStatement.h"

BasicStatement::BasicStatement() {
	this->type = "BasicStatement";
}

BasicStatement::~BasicStatement() {
	for(auto it = children.begin(); it != children.end(); )
	{
		delete *it;
		it = children.erase(it);
	}
}

void BasicStatement::add_expression(ASTExpression * expr)
{
	children.push_back(expr);
}


SenchaObject BasicStatement::execute()
{
	for(auto it = children.begin(); it!=children.end() -1; it++)
	(*it)->execute();
	return children[children.size() -1]->execute();

}

SenchaObject BasicStatement::evaluate()
{
	return children[children.size() - 1]->evaluate();
}

void BasicStatement::accept(Visitor * visitor)
{
	visitor->visit(this);
}