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

49 lines
887 B
C++
Raw Normal View History

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-03 22:40:47 +00:00
}
ProgramNode::~ProgramNode() {
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() {
for (std::vector<ASTNode *>::iterator it = children.begin(); it!=children.end(); ++it) {
(*it)->execute();
}
2012-12-08 19:59:05 +00:00
}
2012-12-08 19:59:05 +00:00
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);
2012-12-03 22:40:47 +00:00
}