line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Ogmios::Annotations::Section; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
6022
|
use Lingua::Ogmios::Annotations::Element; |
|
16
|
|
|
|
|
46
|
|
|
16
|
|
|
|
|
423
|
|
4
|
16
|
|
|
16
|
|
88
|
use strict; |
|
16
|
|
|
|
|
22
|
|
|
16
|
|
|
|
|
421
|
|
5
|
16
|
|
|
16
|
|
153
|
use warnings; |
|
16
|
|
|
|
|
253
|
|
|
16
|
|
|
|
|
17541
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @ISA = qw(Lingua::Ogmios::Annotations::Element); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new |
10
|
|
|
|
|
|
|
{ |
11
|
0
|
|
|
0
|
0
|
|
my ($class, $fields) = @_; |
12
|
0
|
0
|
|
|
|
|
if (!defined $fields->{'id'}) { |
13
|
0
|
|
|
|
|
|
$fields->{'id'} = -1; |
14
|
|
|
|
|
|
|
} |
15
|
0
|
|
|
|
|
|
my $section = $class->SUPER::new({ |
16
|
|
|
|
|
|
|
'id' => $fields->{'id'}, |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
if (!defined $fields->{'from'}) { |
21
|
0
|
|
|
|
|
|
die("from is not defined"); |
22
|
|
|
|
|
|
|
} |
23
|
0
|
0
|
|
|
|
|
if (!defined $fields->{'to'}) { |
24
|
0
|
|
|
|
|
|
die("to is not defined"); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
bless ($section,$class); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$section->setFrom($fields->{'from'}); |
30
|
0
|
|
|
|
|
|
$section->setTo($fields->{'to'}); |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if (defined $fields->{'title'}) { |
33
|
0
|
|
|
|
|
|
$section->title($fields->{'title'}); |
34
|
|
|
|
|
|
|
} |
35
|
0
|
0
|
|
|
|
|
if (defined $fields->{'type'}) { |
36
|
0
|
|
|
|
|
|
$section->type($fields->{'type'}); |
37
|
|
|
|
|
|
|
} |
38
|
0
|
0
|
|
|
|
|
if (defined $fields->{'rank'}) { |
39
|
0
|
|
|
|
|
|
$section->rank($fields->{'rank'}); |
40
|
|
|
|
|
|
|
} |
41
|
0
|
0
|
|
|
|
|
if (defined $fields->{'parent_section'}) { |
42
|
0
|
|
|
|
|
|
$section->parent_section($fields->{'parent_section'}); |
43
|
|
|
|
|
|
|
} |
44
|
0
|
0
|
|
|
|
|
if (defined $fields->{'child_sections'}) { |
45
|
0
|
|
|
|
|
|
$section->child_sections($fields->{'child_sections'}); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return $section; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub rank { |
53
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
$self->{'rank'} = shift if @_; |
56
|
0
|
|
|
|
|
|
return $self->{'rank'}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub type { |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
$self->{'type'} = shift if @_; |
63
|
0
|
|
|
|
|
|
return $self->{'type'}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub title { |
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
$self->{'title'} = shift if @_; |
71
|
0
|
|
|
|
|
|
return $self->{'title'}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub getRank { |
76
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $i = 0; |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
if (defined $self->parent_section) { |
81
|
0
|
|
|
|
|
|
for($i = 0; $i < scalar(@{$self->parent_section->child_sections}); $i++) { |
|
0
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if ($self->getId == $self->parent_section->child_sections->[$i]->getId) { |
83
|
0
|
|
|
|
|
|
return($i); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
|
return(-1); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub isTitle { |
92
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
0
|
|
|
|
if ((defined $self->parent_section) && (defined $self->parent_section->{'title'}) |
|
|
|
0
|
|
|
|
|
95
|
|
|
|
|
|
|
&& ($self->rank == 0)) { |
96
|
0
|
|
|
|
|
|
return(1); |
97
|
|
|
|
|
|
|
} |
98
|
0
|
|
|
|
|
|
return(0); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub parent_section { |
103
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
$self->{'parent_section'} = shift if @_; |
106
|
0
|
|
|
|
|
|
return $self->{'parent_section'}; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub child_sections { |
110
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
111
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
$self->{'child_sections'} = shift if @_; |
113
|
0
|
|
|
|
|
|
return $self->{'child_sections'}; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub has_child_sections { |
117
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
0
|
|
|
|
return((defined $self->child_sections) && (scalar(@{$self->child_sections}) > 0)); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub setFrom { |
123
|
0
|
|
|
0
|
0
|
|
my ($self, $from) = @_; |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
$self->{'from'} = $from; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub setTo { |
130
|
0
|
|
|
0
|
0
|
|
my ($self, $to) = @_; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
$self->{'to'} = $to; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub getFrom { |
136
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
return($self->{'from'}); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub getFromOffset { |
143
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
144
|
|
|
|
|
|
|
|
145
|
0
|
0
|
|
|
|
|
if (ref($self->{'from'}) eq "Lingua::Ogmios::Annotations::Token") { |
146
|
0
|
|
|
|
|
|
return($self->{'from'}->getFrom); |
147
|
|
|
|
|
|
|
} else { |
148
|
0
|
|
|
|
|
|
return($self->{'from'}); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub getToOffset { |
154
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
155
|
|
|
|
|
|
|
|
156
|
0
|
0
|
|
|
|
|
if (ref($self->{'to'}) eq "Lingua::Ogmios::Annotations::Token") { |
157
|
0
|
|
|
|
|
|
return($self->{'to'}->getTo); |
158
|
|
|
|
|
|
|
} else { |
159
|
0
|
|
|
|
|
|
return($self->{'to'}); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub getTo { |
165
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
return($self->{'to'}); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub getForm { |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
0
|
0
|
|
my ($self, $tokenLevel) = @_; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# warn "ref start: " . ref($self->getFrom) . "\n"; |
176
|
|
|
|
|
|
|
# warn "ref to: " . ref($self->getTo) . "\n"; |
177
|
0
|
|
|
|
|
|
my $token; |
178
|
|
|
|
|
|
|
my $start_token; |
179
|
0
|
|
|
|
|
|
my $end_token; |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my $sectionForm; |
182
|
|
|
|
|
|
|
|
183
|
0
|
0
|
|
|
|
|
if (ref($self->getFrom) eq "Lingua::Ogmios::Annotations::Token") { |
184
|
|
|
|
|
|
|
# from is a token |
185
|
0
|
|
|
|
|
|
$start_token = $self->getFrom; |
186
|
|
|
|
|
|
|
} else { |
187
|
|
|
|
|
|
|
# from is a offset |
188
|
0
|
|
|
|
|
|
$start_token = $tokenLevel->getElementByOffset($self->getFrom)->[0]; |
189
|
|
|
|
|
|
|
} |
190
|
0
|
0
|
|
|
|
|
if (ref($self->getTo) eq "Lingua::Ogmios::Annotations::Token") { |
191
|
|
|
|
|
|
|
# To is a token |
192
|
0
|
|
|
|
|
|
$end_token = $self->getTo; |
193
|
|
|
|
|
|
|
} else { |
194
|
|
|
|
|
|
|
# to is a offset |
195
|
0
|
|
|
|
|
|
$end_token = $tokenLevel->getElementByOffset($self->getTo)->[0]; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
$token = $start_token; |
199
|
0
|
|
|
|
|
|
$sectionForm = $token->getContent; |
200
|
0
|
|
|
|
|
|
while(!$token->equals($end_token)) { |
201
|
0
|
|
|
|
|
|
$token = $token->next; |
202
|
0
|
|
|
|
|
|
$sectionForm .= $token->getContent; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
}; |
205
|
|
|
|
|
|
|
# warn "$sectionForm\n"; |
206
|
0
|
|
|
|
|
|
return($start_token, $end_token, $sectionForm); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub firstDefinedTitle { |
211
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
212
|
|
|
|
|
|
|
|
213
|
0
|
0
|
|
|
|
|
if (defined $self->title) { |
214
|
0
|
|
|
|
|
|
return($self->title); |
215
|
|
|
|
|
|
|
} else { |
216
|
0
|
0
|
|
|
|
|
if (defined $self->parent_section) { |
217
|
0
|
|
|
|
|
|
return($self->parent_section->firstDefinedTitle); |
218
|
|
|
|
|
|
|
} else { |
219
|
0
|
|
|
|
|
|
return(undef); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub XMLout { |
226
|
0
|
|
|
0
|
0
|
|
my ($self, $order) = @_; |
227
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
|
return($self->SUPER::XMLout("section", $order)); |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub tokenIsInside { |
233
|
0
|
|
|
0
|
0
|
|
my ($self, $token) = @_; |
234
|
|
|
|
|
|
|
|
235
|
0
|
0
|
0
|
|
|
|
if (($self->getFromOffset < $token->getFrom) && |
236
|
|
|
|
|
|
|
($token->getTo < $self->getToOffset)) { |
237
|
0
|
|
|
|
|
|
return(1); |
238
|
|
|
|
|
|
|
} else { |
239
|
0
|
|
|
|
|
|
return(0) |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub reference { |
244
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
245
|
|
|
|
|
|
|
|
246
|
0
|
|
|
|
|
|
my $start_token; |
247
|
|
|
|
|
|
|
my $end_token; |
248
|
0
|
|
|
|
|
|
my @refs; |
249
|
0
|
|
|
|
|
|
my $token; |
250
|
|
|
|
|
|
|
|
251
|
0
|
0
|
|
|
|
|
if (ref($self->getFrom) eq "Lingua::Ogmios::Annotations::Token") { |
252
|
|
|
|
|
|
|
# from is a token |
253
|
0
|
|
|
|
|
|
$start_token = $self->getFrom; |
254
|
|
|
|
|
|
|
} else { |
255
|
|
|
|
|
|
|
# from is a offset |
256
|
|
|
|
|
|
|
# $start_token = $tokenLevel->getElementByOffset($self->getFrom)->[0]; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
# warn "..\n"; |
259
|
|
|
|
|
|
|
# warn $self->getTo . " : " . ref($self->getTo) . "\n"; |
260
|
0
|
0
|
|
|
|
|
if (ref($self->getTo) eq "Lingua::Ogmios::Annotations::Token") { |
261
|
|
|
|
|
|
|
# To is a token |
262
|
0
|
|
|
|
|
|
$end_token = $self->getTo; |
263
|
|
|
|
|
|
|
} else { |
264
|
|
|
|
|
|
|
# to is a offset |
265
|
|
|
|
|
|
|
# $end_token = $tokenLevel->getElementByOffset($self->getTo)->[0]; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
# warn "...\n"; |
268
|
0
|
0
|
|
|
|
|
if (defined $start_token) { |
269
|
0
|
|
|
|
|
|
$token = $start_token; |
270
|
0
|
|
|
|
|
|
push @refs, $token; |
271
|
0
|
|
|
|
|
|
while(!$token->equals($end_token)) { |
272
|
0
|
|
|
|
|
|
$token = $token->next; |
273
|
0
|
|
|
|
|
|
push @refs, $token; |
274
|
|
|
|
|
|
|
}; |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
# warn "....\n"; |
277
|
0
|
|
|
|
|
|
return(\@refs); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
1; |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
__END__ |