line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
### |
3
|
|
|
|
|
|
|
### Copyright 2002-2003 University of Illinois Board of Trustees |
4
|
|
|
|
|
|
|
### Copyright 2002-2003 Mark D. Roth |
5
|
|
|
|
|
|
|
### All rights reserved. |
6
|
|
|
|
|
|
|
### |
7
|
|
|
|
|
|
|
### Config::Objective::Integer - integer data type for Config::Objective |
8
|
|
|
|
|
|
|
### |
9
|
|
|
|
|
|
|
### Mark D. Roth |
10
|
|
|
|
|
|
|
### Campus Information Technologies and Educational Services |
11
|
|
|
|
|
|
|
### University of Illinois at Urbana-Champaign |
12
|
|
|
|
|
|
|
### |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Config::Objective::Integer; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
531
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
18
|
1
|
|
|
1
|
|
5
|
use integer; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#use overload |
21
|
|
|
|
|
|
|
# '""' => 'get', |
22
|
|
|
|
|
|
|
## '0+' => 'get', |
23
|
|
|
|
|
|
|
# '+' => 'numeric_add', |
24
|
|
|
|
|
|
|
# '=' => 'set', |
25
|
|
|
|
|
|
|
# 'eq' => 'equals', |
26
|
|
|
|
|
|
|
## 'fallback' => 1 |
27
|
|
|
|
|
|
|
# ; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
21
|
use Config::Objective::DataType; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
663
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our @ISA = qw(Config::Objective::DataType); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
############################################################################### |
35
|
|
|
|
|
|
|
### equals method (for conditional expressions) |
36
|
|
|
|
|
|
|
############################################################################### |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub equals |
39
|
|
|
|
|
|
|
{ |
40
|
3
|
|
|
3
|
1
|
7
|
my ($self, $value) = @_; |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
9
|
return $self->eq($value); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub eq |
47
|
|
|
|
|
|
|
{ |
48
|
3
|
|
|
3
|
1
|
5
|
my ($self, $value) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# print "==> equals(" . ref($self) . "='$self->{'value'}', '$value')\n"; |
51
|
|
|
|
|
|
|
|
52
|
3
|
|
|
|
|
13
|
return ($self->{'value'} == $value); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
############################################################################### |
57
|
|
|
|
|
|
|
### not-equals method (for conditional expressions) |
58
|
|
|
|
|
|
|
############################################################################### |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub ne |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
0
|
1
|
0
|
my ($self, $value) = @_; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
return ($self->{'value'} != $value); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
############################################################################### |
69
|
|
|
|
|
|
|
### greater-than method (for conditional expressions) |
70
|
|
|
|
|
|
|
############################################################################### |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub gt |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
0
|
1
|
0
|
my ($self, $value) = @_; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
return ($self->{'value'} > $value); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
############################################################################### |
81
|
|
|
|
|
|
|
### less-than method (for conditional expressions) |
82
|
|
|
|
|
|
|
############################################################################### |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub lt |
85
|
|
|
|
|
|
|
{ |
86
|
1
|
|
|
1
|
1
|
3
|
my ($self, $value) = @_; |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
6
|
return ($self->{'value'} < $value); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
############################################################################### |
93
|
|
|
|
|
|
|
### less-than-or-equal-to method (for conditional expressions) |
94
|
|
|
|
|
|
|
############################################################################### |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub le |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
0
|
1
|
0
|
my ($self, $value) = @_; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
0
|
return ($self->{'value'} <= $value); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
############################################################################### |
105
|
|
|
|
|
|
|
### greater-than-or-equal-to method (for conditional expressions) |
106
|
|
|
|
|
|
|
############################################################################### |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub ge |
109
|
|
|
|
|
|
|
{ |
110
|
0
|
|
|
0
|
1
|
0
|
my ($self, $value) = @_; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
0
|
return ($self->{'value'} >= $value); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
############################################################################### |
117
|
|
|
|
|
|
|
### set method |
118
|
|
|
|
|
|
|
############################################################################### |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub set |
121
|
|
|
|
|
|
|
{ |
122
|
6
|
|
|
6
|
1
|
10
|
my ($self, $value) = @_; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# print "==> Integer::set($value)\n"; |
125
|
|
|
|
|
|
|
|
126
|
6
|
50
|
|
|
|
14
|
die "value required\n" |
127
|
|
|
|
|
|
|
if (!defined($value)); |
128
|
|
|
|
|
|
|
|
129
|
6
|
50
|
|
|
|
12
|
die "non-scalar value specified for integer variable\n" |
130
|
|
|
|
|
|
|
if (ref($value)); |
131
|
|
|
|
|
|
|
|
132
|
6
|
50
|
|
|
|
23
|
die "non-numeric value specified for integer variable\n" |
133
|
|
|
|
|
|
|
if ($value !~ m/^-?\d+$/); |
134
|
|
|
|
|
|
|
|
135
|
6
|
|
|
|
|
20
|
$self->{'value'} = $value; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
############################################################################### |
140
|
|
|
|
|
|
|
### add method |
141
|
|
|
|
|
|
|
############################################################################### |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub add |
144
|
|
|
|
|
|
|
{ |
145
|
1
|
|
|
1
|
1
|
15
|
my ($self, $value) = @_; |
146
|
|
|
|
|
|
|
|
147
|
1
|
|
|
|
|
5
|
$self->{'value'} += $value; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
############################################################################### |
152
|
|
|
|
|
|
|
### subtract method |
153
|
|
|
|
|
|
|
############################################################################### |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub sub |
156
|
|
|
|
|
|
|
{ |
157
|
1
|
|
|
1
|
1
|
3
|
my ($self, $value) = @_; |
158
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
4
|
$self->{'value'} -= $value; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
############################################################################### |
164
|
|
|
|
|
|
|
### divide method |
165
|
|
|
|
|
|
|
############################################################################### |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub div |
168
|
|
|
|
|
|
|
{ |
169
|
1
|
|
|
1
|
1
|
2
|
my ($self, $value) = @_; |
170
|
|
|
|
|
|
|
|
171
|
1
|
|
|
|
|
5
|
$self->{'value'} = int($self->{'value'} / $value); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
############################################################################### |
176
|
|
|
|
|
|
|
### multiply method |
177
|
|
|
|
|
|
|
############################################################################### |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub mult |
180
|
|
|
|
|
|
|
{ |
181
|
1
|
|
|
1
|
1
|
3
|
my ($self, $value) = @_; |
182
|
|
|
|
|
|
|
|
183
|
1
|
|
|
|
|
3
|
$self->{'value'} *= $value; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
############################################################################### |
188
|
|
|
|
|
|
|
### increment method |
189
|
|
|
|
|
|
|
############################################################################### |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub incr |
192
|
|
|
|
|
|
|
{ |
193
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
194
|
|
|
|
|
|
|
|
195
|
1
|
|
|
|
|
4
|
$self->{'value'}++; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
############################################################################### |
200
|
|
|
|
|
|
|
### decrement method |
201
|
|
|
|
|
|
|
############################################################################### |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub decr |
204
|
|
|
|
|
|
|
{ |
205
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
206
|
|
|
|
|
|
|
|
207
|
1
|
|
|
|
|
6
|
$self->{'value'}--; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
############################################################################### |
212
|
|
|
|
|
|
|
### cleanup and documentation |
213
|
|
|
|
|
|
|
############################################################################### |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
1; |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
__END__ |