2012-12-03 22:40:47 +00:00
|
|
|
/*
|
|
|
|
* ProgramNode.cpp
|
|
|
|
*
|
|
|
|
* Created on: Nov 5, 2012
|
|
|
|
* Author: attero
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ProgramNode.h"
|
|
|
|
|
|
|
|
ProgramNode::ProgramNode() {
|
2012-12-17 08:37:45 +00:00
|
|
|
//Do nothing
|
2012-12-22 10:06:55 +00:00
|
|
|
this->type = "ProgramNode";
|
2012-12-03 22:40:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ProgramNode::~ProgramNode() {
|
2012-12-17 08:25:58 +00:00
|
|
|
for(auto it = children.begin(); it != children.end(); )
|
|
|
|
{
|
|
|
|
delete *it;
|
|
|
|
it = children.erase(it);
|
|
|
|
}
|
2012-12-03 22:40:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProgramNode::execute() {
|
2012-12-05 22:27:03 +00:00
|
|
|
for (std::vector<ASTNode *>::iterator it = children.begin(); it!=children.end(); ++it) {
|
2012-12-17 08:25:58 +00:00
|
|
|
(*it)->execute();
|
|
|
|
}
|
2012-12-08 19:59:05 +00:00
|
|
|
}
|
2012-12-05 22:27:03 +00:00
|
|
|
|
2012-12-18 21:41:39 +00:00
|
|
|
void ProgramNode::accept(Visitor * visitor)
|
|
|
|
{
|
|
|
|
visitor->visit(this);
|
|
|
|
}
|
|
|
|
|
2012-12-08 19:59:05 +00:00
|
|
|
void ProgramNode::execute_last()
|
|
|
|
{
|
2012-12-18 21:41:39 +00:00
|
|
|
children[children.size() - 1]->execute();
|
2012-12-05 22:27:03 +00:00
|
|
|
}
|
|
|
|
|
2012-12-22 17:52:19 +00:00
|
|
|
SenchaObject ProgramNode::evaluate_last()
|
|
|
|
{
|
2012-12-22 19:15:34 +00:00
|
|
|
|
2012-12-22 18:19:13 +00:00
|
|
|
SenchaObject result = (children[children.size() - 1])->evaluate();
|
|
|
|
return result;
|
2012-12-22 17:52:19 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 22:27:03 +00:00
|
|
|
void ProgramNode::add_statement(ASTStatement * statement)
|
|
|
|
{
|
|
|
|
children.push_back(statement);
|
2012-12-03 22:40:47 +00:00
|
|
|
}
|
2012-12-05 22:27:03 +00:00
|
|
|
|