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

53 lines
712 B
C++

/*
* RepeatStatement.cpp
*
* Created on: Dec 9, 2012
* Author: attero
*/
#include "RepeatStatement.h"
RepeatStatement::RepeatStatement()
{
how_many_times = 0;
body = NULL;
this->type = "RepeatStatement";
}
RepeatStatement::~RepeatStatement()
{
delete body;
}
void RepeatStatement::execute()
{
execute_quietly();
}
void RepeatStatement::add_body(ASTStatement * statement)
{
body = statement;
}
void RepeatStatement::execute_quietly()
{
for(int i = 0; i < how_many_times; i++)
{
body->execute();
}
}
void RepeatStatement::add_iteration_number(SenchaObject so)
{
if(so.type == SenchaObject::integer_number)
{
how_many_times = so.integer;
}
else
{
how_many_times = 0;
}
}