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() {
|
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-08 19:59:05 +00:00
|
|
|
void ProgramNode::execute_last()
|
|
|
|
{
|
|
|
|
children[children.size() -1]->execute();
|
2012-12-05 22:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
2012-12-05 22:27:03 +00:00
|
|
|
|