-
Notifications
You must be signed in to change notification settings - Fork 2
/
element.cpp
87 lines (74 loc) · 1.93 KB
/
element.cpp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// element.cpp
// Revision 8-jan-2005
#include "element.h"
#include "var.h"
#include "trace.h"
ForElementNumber::ForElementNumber (const std::string & nvar,
ProgramPos pos,
BlNumber initial, BlNumber nmax, BlNumber nstep) :
ForElement (nvar, pos),
max (nmax),
step (nstep)
{
varaddr= addrvarnumber (nvar);
* varaddr= initial;
}
ForElementNumberInc::ForElementNumberInc (const std::string & var,
ProgramPos pos,
BlNumber initial, BlNumber max, BlNumber step) :
ForElementNumber (var, pos, initial, max, step)
{
//TRACEFUNC (tr, "ForElementNumberInc::ForElementNumberInc");
}
bool ForElementNumberInc::next ()
{
* varaddr+= step;
return * varaddr <= max;
}
ForElementNumberDec::ForElementNumberDec (const std::string & var,
ProgramPos pos,
BlNumber initial, BlNumber max, BlNumber step) :
ForElementNumber (var, pos, initial, max, step)
{
//TRACEFUNC (tr, "ForElementNumberDec::ForElementNumberDec");
}
bool ForElementNumberDec::next ()
{
* varaddr+= step;
return * varaddr >= max;
}
ForElementInteger::ForElementInteger (const std::string & nvar,
ProgramPos pos,
BlInteger initial, BlInteger nmax, BlInteger nstep) :
ForElement (nvar, pos),
max (nmax),
step (nstep)
{
varaddr= addrvarinteger (nvar);
* varaddr= initial;
}
ForElementIntegerInc::ForElementIntegerInc (const std::string & var,
ProgramPos pos,
BlInteger initial, BlInteger max, BlInteger step) :
ForElementInteger (var, pos, initial, max, step)
{
//TRACEFUNC (tr, "ForElementIntegerInc::ForElementIntegerInc");
}
bool ForElementIntegerInc::next ()
{
* varaddr+= step;
return * varaddr <= max;
}
ForElementIntegerDec::ForElementIntegerDec (const std::string & var,
ProgramPos pos,
BlInteger initial, BlInteger max, BlInteger step) :
ForElementInteger (var, pos, initial, max, step)
{
//TRACEFUNC (tr, "ForElementIntegerDec::ForElementIntegerDec");
}
bool ForElementIntegerDec::next ()
{
* varaddr+= step;
return * varaddr >= max;
}
// End of element.cpp