line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
49
|
|
|
49
|
|
277
|
use strict; use warnings; |
|
49
|
|
|
49
|
|
250
|
|
|
49
|
|
|
|
|
1185
|
|
|
49
|
|
|
|
|
202
|
|
|
49
|
|
|
|
|
67
|
|
|
49
|
|
|
|
|
1528
|
|
2
|
|
|
|
|
|
|
package YAML::Node; |
3
|
|
|
|
|
|
|
|
4
|
49
|
|
|
49
|
|
15762
|
use YAML::Tag; |
|
49
|
|
|
|
|
118
|
|
|
49
|
|
|
|
|
1453
|
|
5
|
|
|
|
|
|
|
require YAML::Mo; |
6
|
|
|
|
|
|
|
|
7
|
49
|
|
|
49
|
|
262
|
use Exporter; |
|
49
|
|
|
|
|
74
|
|
|
49
|
|
|
|
|
64912
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter YAML::Mo::Object); |
9
|
|
|
|
|
|
|
our @EXPORT = qw(ynode); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub ynode { |
12
|
1942
|
|
|
1942
|
0
|
2058
|
my $self; |
13
|
1942
|
100
|
|
|
|
3831
|
if (ref($_[0]) eq 'HASH') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
14
|
891
|
|
|
|
|
887
|
$self = tied(%{$_[0]}); |
|
891
|
|
|
|
|
1321
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
elsif (ref($_[0]) eq 'ARRAY') { |
17
|
61
|
|
|
|
|
72
|
$self = tied(@{$_[0]}); |
|
61
|
|
|
|
|
110
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
elsif (ref(\$_[0]) eq 'GLOB') { |
20
|
0
|
|
|
|
|
0
|
$self = tied(*{$_[0]}); |
|
0
|
|
|
|
|
0
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
else { |
23
|
990
|
|
|
|
|
1223
|
$self = tied($_[0]); |
24
|
|
|
|
|
|
|
} |
25
|
1942
|
100
|
|
|
|
4615
|
return (ref($self) =~ /^yaml_/) ? $self : undef; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
96
|
|
|
96
|
0
|
4782
|
my ($class, $node, $tag) = @_; |
30
|
96
|
|
|
|
|
117
|
my $self; |
31
|
96
|
|
|
|
|
199
|
$self->{NODE} = $node; |
32
|
96
|
|
|
|
|
238
|
my (undef, $type) = YAML::Mo::Object->node_info($node); |
33
|
96
|
50
|
|
|
|
384
|
$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
|
96
|
|
100
|
|
|
351
|
tag($self, ($tag || '')); |
38
|
96
|
100
|
|
|
|
219
|
if ($self->{KIND} eq 'scalar') { |
39
|
16
|
|
|
|
|
68
|
yaml_scalar->new($self, $_[1]); |
40
|
16
|
|
|
|
|
43
|
return \ $_[1]; |
41
|
|
|
|
|
|
|
} |
42
|
80
|
|
|
|
|
148
|
my $package = "yaml_" . $self->{KIND}; |
43
|
80
|
|
|
|
|
226
|
$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
|
193
|
|
|
193
|
0
|
337
|
my ($self, $value) = @_; |
50
|
193
|
100
|
|
|
|
323
|
if (defined $value) { |
51
|
96
|
|
|
|
|
271
|
$self->{TAG} = YAML::Tag->new($value); |
52
|
96
|
|
|
|
|
187
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
97
|
|
|
|
|
251
|
return $self->{TAG}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
sub keys { |
59
|
6
|
|
|
6
|
0
|
16
|
my ($self, $value) = @_; |
60
|
6
|
50
|
|
|
|
10
|
if (defined $value) { |
61
|
6
|
|
|
|
|
13
|
$self->{KEYS} = $value; |
62
|
6
|
|
|
|
|
71
|
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
|
|
34
|
my ($class, $self) = @_; |
76
|
16
|
|
|
|
|
46
|
tie $_[2], $class, $self; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub TIESCALAR { |
80
|
16
|
|
|
16
|
|
34
|
my ($class, $self) = @_; |
81
|
16
|
|
|
|
|
21
|
bless $self, $class; |
82
|
16
|
|
|
|
|
38
|
$self |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub FETCH { |
86
|
78
|
|
|
78
|
|
104
|
my ($self) = @_; |
87
|
|
|
|
|
|
|
$self->{NODE} |
88
|
78
|
|
|
|
|
205
|
} |
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
|
|
22
|
my ($class, $self) = @_; |
102
|
10
|
|
|
|
|
13
|
my $new; |
103
|
10
|
|
|
|
|
32
|
tie @$new, $class, $self; |
104
|
10
|
|
|
|
|
43
|
$new |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub TIEARRAY { |
108
|
10
|
|
|
10
|
|
21
|
my ($class, $self) = @_; |
109
|
10
|
|
|
|
|
27
|
bless $self, $class |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub FETCHSIZE { |
113
|
52
|
|
|
52
|
|
104
|
my ($self) = @_; |
114
|
52
|
|
|
|
|
54
|
scalar @{$self->{NODE}}; |
|
52
|
|
|
|
|
168
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub FETCH { |
118
|
36
|
|
|
36
|
|
59
|
my ($self, $index) = @_; |
119
|
36
|
|
|
|
|
88
|
$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
|
70
|
|
|
70
|
|
107
|
my ($class, $self) = @_; |
142
|
70
|
|
|
|
|
83
|
@{$self->{KEYS}} = sort keys %{$self->{NODE}}; |
|
70
|
|
|
|
|
159
|
|
|
70
|
|
|
|
|
272
|
|
143
|
70
|
|
|
|
|
112
|
my $new; |
144
|
70
|
|
|
|
|
199
|
tie %$new, $class, $self; |
145
|
70
|
|
|
|
|
257
|
$new |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub TIEHASH { |
149
|
70
|
|
|
70
|
|
124
|
my ($class, $self) = @_; |
150
|
70
|
|
|
|
|
170
|
bless $self, $class |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub FETCH { |
154
|
299
|
|
|
299
|
|
488
|
my ($self, $key) = @_; |
155
|
299
|
100
|
|
|
|
545
|
if (exists $self->{NODE}{$key}) { |
156
|
259
|
|
|
|
|
772
|
return (grep {$_ eq $key} @{$self->{KEYS}}) |
|
143
|
|
|
|
|
244
|
|
157
|
143
|
50
|
|
|
|
165
|
? $self->{NODE}{$key} : undef; |
158
|
|
|
|
|
|
|
} |
159
|
156
|
|
|
|
|
377
|
return $self->{HASH}{$key}; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub STORE { |
163
|
75
|
|
|
75
|
|
154
|
my ($self, $key, $value) = @_; |
164
|
75
|
100
|
|
|
|
178
|
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
|
|
|
|
83
|
if (not grep {$_ eq $key} @{$self->{KEYS}}) { |
|
457
|
|
|
|
|
687
|
|
|
73
|
|
|
|
|
145
|
|
172
|
72
|
|
|
|
|
80
|
push(@{$self->{KEYS}}, $key); |
|
72
|
|
|
|
|
144
|
|
173
|
|
|
|
|
|
|
} |
174
|
73
|
|
|
|
|
186
|
$self->{HASH}{$key} = $value; |
175
|
|
|
|
|
|
|
} |
176
|
75
|
|
|
|
|
260
|
$value |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub DELETE { |
180
|
1
|
|
|
1
|
|
8
|
my ($self, $key) = @_; |
181
|
1
|
|
|
|
|
2
|
my $return; |
182
|
1
|
50
|
|
|
|
10
|
if (exists $self->{NODE}{$key}) { |
|
|
0
|
|
|
|
|
|
183
|
1
|
|
|
|
|
4
|
$return = $self->{NODE}{$key}; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
elsif (exists $self->{HASH}{$key}) { |
186
|
0
|
|
|
|
|
0
|
$return = delete $self->{NODE}{$key}; |
187
|
|
|
|
|
|
|
} |
188
|
1
|
|
|
|
|
3
|
for (my $i = 0; $i < @{$self->{KEYS}}; $i++) { |
|
4
|
|
|
|
|
8
|
|
189
|
3
|
100
|
|
|
|
6
|
if ($self->{KEYS}[$i] eq $key) { |
190
|
1
|
|
|
|
|
2
|
splice(@{$self->{KEYS}}, $i, 1); |
|
1
|
|
|
|
|
2
|
|
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
} |
193
|
1
|
|
|
|
|
17
|
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
|
188
|
|
|
188
|
|
363
|
my ($self) = @_; |
204
|
188
|
|
|
|
|
270
|
$self->{ITER} = 0; |
205
|
188
|
|
|
|
|
539
|
$self->{KEYS}[0] |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub NEXTKEY { |
209
|
424
|
|
|
424
|
|
591
|
my ($self) = @_; |
210
|
424
|
|
|
|
|
1279
|
$self->{KEYS}[++$self->{ITER}] |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub EXISTS { |
214
|
88
|
|
|
88
|
|
173
|
my ($self, $key) = @_; |
215
|
88
|
|
|
|
|
253
|
exists $self->{NODE}{$key} |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
1; |