/* * RepeatStatement.cpp * * Created on: Dec 9, 2012 * Author: attero */ #include "RepeatStatement.h" RepeatStatement::RepeatStatement(ASTExpression * expr, ASTStatement * statement) { body = statement; how_many_times_expr = expr; this->type = "RepeatStatement"; } RepeatStatement::~RepeatStatement() { delete body; delete how_many_times_expr; } SenchaObject RepeatStatement::execute() { auto value = how_many_times_expr->execute(); if(value.type == SenchaObject::integer_number) { int how_many_times = value.integer; for(int i = 0; i < how_many_times; i++) { if(i == how_many_times - 1) return body->execute(); else body->execute(); } } return SenchaObject(); }