sencha-lang/Sencha-lang/AST/ProgramNode.cpp

49 lines
887 B
C++

/*
* ProgramNode.cpp
*
* Created on: Nov 5, 2012
* Author: attero
*/
#include "ProgramNode.h"
ProgramNode::ProgramNode() {
//Do nothing
}
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::execute_last()
{
children[children.size() -1]->execute();
}
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);
}