line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
49
|
|
|
49
|
|
308
|
use strict; use warnings; |
|
49
|
|
|
49
|
|
301
|
|
|
49
|
|
|
|
|
1266
|
|
|
49
|
|
|
|
|
218
|
|
|
49
|
|
|
|
|
81
|
|
|
49
|
|
|
|
|
1667
|
|
2
|
|
|
|
|
|
|
package YAML::Node; |
3
|
|
|
|
|
|
|
|
4
|
49
|
|
|
49
|
|
17318
|
use YAML::Tag; |
|
49
|
|
|
|
|
149
|
|
|
49
|
|
|
|
|
1508
|
|
5
|
|
|
|
|
|
|
require YAML::Mo; |
6
|
|
|
|
|
|
|
|
7
|
49
|
|
|
49
|
|
317
|
use Exporter; |
|
49
|
|
|
|
|
91
|
|
|
49
|
|
|
|
|
68676
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter YAML::Mo::Object); |
9
|
|
|
|
|
|
|
our @EXPORT = qw(ynode); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub ynode { |
12
|
1942
|
|
|
1942
|
0
|
2243
|
my $self; |
13
|
1942
|
100
|
|
|
|
4368
|
if (ref($_[0]) eq 'HASH') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
14
|
891
|
|
|
|
|
936
|
$self = tied(%{$_[0]}); |
|
891
|
|
|
|
|
1391
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
elsif (ref($_[0]) eq 'ARRAY') { |
17
|
61
|
|
|
|
|
96
|
$self = tied(@{$_[0]}); |
|
61
|
|
|
|
|
134
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
elsif (ref(\$_[0]) eq 'GLOB') { |
20
|
0
|
|
|
|
|
0
|
$self = tied(*{$_[0]}); |
|
0
|
|
|
|
|
0
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
else { |
23
|
990
|
|
|
|
|
1217
|
$self = tied($_[0]); |
24
|
|
|
|
|
|
|
} |
25
|
1942
|
100
|
|
|
|
5144
|
return (ref($self) =~ /^yaml_/) ? $self : undef; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
99
|
|
|
99
|
0
|
6365
|
my ($class, $node, $tag) = @_; |
30
|
99
|
|
|
|
|
157
|
my $self; |
31
|
99
|
|
|
|
|
225
|
$self->{NODE} = $node; |
32
|
99
|
|
|
|
|
270
|
my (undef, $type) = YAML::Mo::Object->node_info($node); |
33
|
99
|
50
|
|
|
|
485
|
$self->{KIND} = (not defined $type) ? 'scalar' : |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
34
|
|
|
|
|
|
|
($type eq 'ARRAY') ? 'sequence' : |
35
|
|
|
|
|
|
|
($type eq 'HASH') ? 'mapping' : |
36
|
|
|
|
|
|
|
$class->die("Can't create YAML::Node from '$type'"); |
37
|
99
|
|
100
|
|
|
522
|
tag($self, ($tag || '')); |
38
|
99
|
100
|
|
|
|
252
|
if ($self->{KIND} eq 'scalar') { |
39
|
16
|
|
|
|
|
89
|
yaml_scalar->new($self, $_[1]); |
40
|
16
|
|
|
|
|
49
|
return \ $_[1]; |
41
|
|
|
|
|
|
|
} |
42
|
83
|
|
|
|
|
188
|
my $package = "yaml_" . $self->{KIND}; |
43
|
83
|
|
|
|
|
271
|
$package->new($self) |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
0
|
0
|
0
|
sub node { $_->{NODE} } |
47
|
0
|
|
|
0
|
0
|
0
|
sub kind { $_->{KIND} } |
48
|
|
|
|
|
|
|
sub tag { |
49
|
199
|
|
|
199
|
0
|
411
|
my ($self, $value) = @_; |
50
|
199
|
100
|
|
|
|
418
|
if (defined $value) { |
51
|
99
|
|
|
|
|
377
|
$self->{TAG} = YAML::Tag->new($value); |
52
|
99
|
|
|
|
|
215
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
100
|
|
|
|
|
338
|
return $self->{TAG}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
sub keys { |
59
|
6
|
|
|
6
|
0
|
15
|
my ($self, $value) = @_; |
60
|
6
|
50
|
|
|
|
55
|
if (defined $value) { |
61
|
6
|
|
|
|
|
33
|
$self->{KEYS} = $value; |
62
|
6
|
|
|
|
|
95
|
return $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
0
|
|
|
|
|
0
|
return $self->{KEYS}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#============================================================================== |
70
|
|
|
|
|
|
|
package yaml_scalar; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
@yaml_scalar::ISA = qw(YAML::Node); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub new { |
75
|
16
|
|
|
16
|
|
41
|
my ($class, $self) = @_; |
76
|
16
|
|
|
|
|
59
|
tie $_[2], $class, $self; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub TIESCALAR { |
80
|
16
|
|
|
16
|
|
39
|
my ($class, $self) = @_; |
81
|
16
|
|
|
|
|
29
|
bless $self, $class; |
82
|
16
|
|
|
|
|
46
|
$self |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub FETCH { |
86
|
78
|
|
|
78
|
|
131
|
my ($self) = @_; |
87
|
|
|
|
|
|
|
$self->{NODE} |
88
|
78
|
|
|
|
|
251
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub STORE { |
91
|
0
|
|
|
0
|
|
0
|
my ($self, $value) = @_; |
92
|
0
|
|
|
|
|
0
|
$self->{NODE} = $value |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
#============================================================================== |
96
|
|
|
|
|
|
|
package yaml_sequence; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
@yaml_sequence::ISA = qw(YAML::Node); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub new { |
101
|
10
|
|
|
10
|
|
25
|
my ($class, $self) = @_; |
102
|
10
|
|
|
|
|
15
|
my $new; |
103
|
10
|
|
|
|
|
41
|
tie @$new, $class, $self; |
104
|
10
|
|
|
|
|
43
|
$new |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub TIEARRAY { |
108
|
10
|
|
|
10
|
|
25
|
my ($class, $self) = @_; |
109
|
10
|
|
|
|
|
30
|
bless $self, $class |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub FETCHSIZE { |
113
|
52
|
|
|
52
|
|
106
|
my ($self) = @_; |
114
|
52
|
|
|
|
|
63
|
scalar @{$self->{NODE}}; |
|
52
|
|
|
|
|
206
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub FETCH { |
118
|
36
|
|
|
36
|
|
60
|
my ($self, $index) = @_; |
119
|
36
|
|
|
|
|
102
|
$self->{NODE}[$index] |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub STORE { |
123
|
0
|
|
|
0
|
|
0
|
my ($self, $index, $value) = @_; |
124
|
0
|
|
|
|
|
0
|
$self->{NODE}[$index] = $value |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub undone { |
128
|
0
|
|
|
0
|
|
0
|
die "Not implemented yet"; # XXX |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
*STORESIZE = *POP = *PUSH = *SHIFT = *UNSHIFT = *SPLICE = *DELETE = *EXISTS = |
132
|
|
|
|
|
|
|
*STORESIZE = *POP = *PUSH = *SHIFT = *UNSHIFT = *SPLICE = *DELETE = *EXISTS = |
133
|
|
|
|
|
|
|
*undone; # XXX Must implement before release |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
#============================================================================== |
136
|
|
|
|
|
|
|
package yaml_mapping; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
@yaml_mapping::ISA = qw(YAML::Node); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub new { |
141
|
73
|
|
|
73
|
|
136
|
my ($class, $self) = @_; |
142
|
73
|
|
|
|
|
131
|
@{$self->{KEYS}} = sort keys %{$self->{NODE}}; |
|
73
|
|
|
|
|
218
|
|
|
73
|
|
|
|
|
381
|
|
143
|
73
|
|
|
|
|
129
|
my $new; |
144
|
73
|
|
|
|
|
253
|
tie %$new, $class, $self; |
145
|
73
|
|
|
|
|
292
|
$new |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub TIEHASH { |
149
|
73
|
|
|
73
|
|
138
|
my ($class, $self) = @_; |
150
|
73
|
|
|
|
|
191
|
bless $self, $class |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub FETCH { |
154
|
317
|
|
|
317
|
|
627
|
my ($self, $key) = @_; |
155
|
317
|
100
|
|
|
|
679
|
if (exists $self->{NODE}{$key}) { |
156
|
313
|
|
|
|
|
1051
|
return (grep {$_ eq $key} @{$self->{KEYS}}) |
|
161
|
|
|
|
|
330
|
|
157
|
161
|
50
|
|
|
|
227
|
? $self->{NODE}{$key} : undef; |
158
|
|
|
|
|
|
|
} |
159
|
156
|
|
|
|
|
406
|
return $self->{HASH}{$key}; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub STORE { |
163
|
75
|
|
|
75
|
|
173
|
my ($self, $key, $value) = @_; |
164
|
75
|
100
|
|
|
|
185
|
if (exists $self->{NODE}{$key}) { |
|
|
50
|
|
|
|
|
|
165
|
2
|
|
|
|
|
6
|
$self->{NODE}{$key} = $value; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
elsif (exists $self->{HASH}{$key}) { |
168
|
0
|
|
|
|
|
0
|
$self->{HASH}{$key} = $value; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
else { |
171
|
73
|
100
|
|
|
|
103
|
if (not grep {$_ eq $key} @{$self->{KEYS}}) { |
|
457
|
|
|
|
|
641
|
|
|
73
|
|
|
|
|
153
|
|
172
|
72
|
|
|
|
|
89
|
push(@{$self->{KEYS}}, $key); |
|
72
|
|
|
|
|
143
|
|
173
|
|
|
|
|
|
|
} |
174
|
73
|
|
|
|
|
171
|
$self->{HASH}{$key} = $value; |
175
|
|
|
|
|
|
|
} |
176
|
75
|
|
|
|
|
282
|
$value |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub DELETE { |
180
|
1
|
|
|
1
|
|
10
|
my ($self, $key) = @_; |
181
|
1
|
|
|
|
|
2
|
my $return; |
182
|
1
|
50
|
|
|
|
6
|
if (exists $self->{NODE}{$key}) { |
|
|
0
|
|
|
|
|
|
183
|
1
|
|
|
|
|
3
|
$return = $self->{NODE}{$key}; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
elsif (exists $self->{HASH}{$key}) { |
186
|
0
|
|
|
|
|
0
|
$return = delete $self->{NODE}{$key}; |
187
|
|
|
|
|
|
|
} |
188
|
1
|
|
|
|
|
18
|
for (my $i = 0; $i < @{$self->{KEYS}}; $i++) { |
|
4
|
|
|
|
|
12
|
|
189
|
3
|
100
|
|
|
|
8
|
if ($self->{KEYS}[$i] eq $key) { |
190
|
1
|
|
|
|
|
3
|
splice(@{$self->{KEYS}}, $i, 1); |
|
1
|
|
|
|
|
3
|
|
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
} |
193
|
1
|
|
|
|
|
21
|
return $return; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub CLEAR { |
197
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
198
|
0
|
|
|
|
|
0
|
@{$self->{KEYS}} = (); |
|
0
|
|
|
|
|
0
|
|
199
|
0
|
|
|
|
|
0
|
%{$self->{HASH}} = (); |
|
0
|
|
|
|
|
0
|
|
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub FIRSTKEY { |
203
|
197
|
|
|
197
|
|
463
|
my ($self) = @_; |
204
|
197
|
|
|
|
|
331
|
$self->{ITER} = 0; |
205
|
197
|
|
|
|
|
660
|
$self->{KEYS}[0] |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub NEXTKEY { |
209
|
451
|
|
|
451
|
|
670
|
my ($self) = @_; |
210
|
451
|
|
|
|
|
1450
|
$self->{KEYS}[++$self->{ITER}] |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub EXISTS { |
214
|
91
|
|
|
91
|
|
174
|
my ($self, $key) = @_; |
215
|
91
|
|
|
|
|
404
|
exists $self->{NODE}{$key} |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
1; |