/*
 * 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);
}
