blob: 404b13adeeee697e04ecdefece6713ea1ae338d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* RepeatStatement.cpp
*
* Created on: Dec 9, 2012
* Author: attero
*/
#include "RepeatStatement.h"
RepeatStatement::RepeatStatement(ASTNode * parent)
{
this->parent = parent;
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();
}
}
std::string RepeatStatement::debug()
{
return "Repeats!";
}
void RepeatStatement::add_iteration_number(SenchaObject so)
{
if(so.type == SenchaObject::integer_number)
{
how_many_times = so.integer;
}
else
{
how_many_times = 0;
}
}
|