line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
49
|
|
|
49
|
|
294
|
use strict; use warnings; |
|
49
|
|
|
49
|
|
239
|
|
|
49
|
|
|
|
|
1290
|
|
|
49
|
|
|
|
|
208
|
|
|
49
|
|
|
|
|
84
|
|
|
49
|
|
|
|
|
1735
|
|
2
|
|
|
|
|
|
|
package YAML::Node; |
3
|
|
|
|
|
|
|
|
4
|
49
|
|
|
49
|
|
17107
|
use YAML::Tag; |
|
49
|
|
|
|
|
128
|
|
|
49
|
|
|
|
|
1572
|
|
5
|
|
|
|
|
|
|
require YAML::Mo; |
6
|
|
|
|
|
|
|
|
7
|
49
|
|
|
49
|
|
267
|
use Exporter; |
|
49
|
|
|
|
|
86
|
|
|
49
|
|
|
|
|
68970
|
|
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter YAML::Mo::Object); |
9
|
|
|
|
|
|
|
our @EXPORT = qw(ynode); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub ynode { |
12
|
1942
|
|
|
1942
|
0
|
2234
|
my $self; |
13
|
1942
|
100
|
|
|
|
4126
|
if (ref($_[0]) eq 'HASH') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
14
|
891
|
|
|
|
|
878
|
$self = tied(%{$_[0]}); |
|
891
|
|
|
|
|
1383
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
elsif (ref($_[0]) eq 'ARRAY') { |
17
|
61
|
|
|
|
|
95
|
$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
|
|
|
|
|
1236
|
$self = tied($_[0]); |
24
|
|
|
|
|
|
|
} |
25
|
1942
|
100
|
|
|
|
5065
|
return (ref($self) =~ /^yaml_/) ? $self : undef; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
99
|
|
|
99
|
0
|
5541
|
my ($class, $node, $tag) = @_; |
30
|
99
|
|
|
|
|
141
|
my $self; |
31
|
99
|
|
|
|
|
211
|
$self->{NODE} = $node; |
32
|
99
|
|
|
|
|
290
|
my (undef, $type) = YAML::Mo::Object->node_info($node); |
33
|
99
|
50
|
|
|
|
437
|
$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
|
|
|
428
|
tag($self, ($tag || '')); |
38
|
99
|
100
|
|
|
|
241
|
if ($self->{KIND} eq 'scalar') { |
39
|
16
|
|
|
|
|
99
|
yaml_scalar->new($self, $_[1]); |
40
|
16
|
|
|
|
|
50
|
return \ $_[1]; |
41
|
|
|
|
|
|
|
} |
42
|
83
|
|
|
|
|
174
|
my $package = "yaml_" . $self->{KIND}; |
43
|
83
|
|
|
|
|
262
|
$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
|
369
|
my ($self, $value) = @_; |
50
|
199
|
100
|
|
|
|
362
|
if (defined $value) { |
51
|
99
|
|
|
|
|
380
|
$self->{TAG} = YAML::Tag->new($value); |
52
|
99
|
|
|
|
|
205
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
100
|
|
|
|
|
329
|
return $self->{TAG}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
sub keys { |
59
|
6
|
|
|
6
|
0
|
14
|
my ($self, $value) = @_; |
60
|
6
|
50
|
|
|
|
20
|
if (defined $value) { |
61
|
6
|
|
|
|
|
20
|
$self->{KEYS} = $value; |
62
|
6
|
|
|
|
|
90
|
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
|
|
40
|
my ($class, $self) = @_; |
76
|
16
|
|
|
|
|
56
|
tie $_[2], $class, $self; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub TIESCALAR { |
80
|
16
|
|
|
16
|
|
36
|
my ($class, $self) = @_; |
81
|
16
|
|
|
|
|
25
|
bless $self, $class; |
82
|
16
|
|
|
|
|
45
|
$self |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub FETCH { |
86
|
78
|
|
|
78
|
|
120
|
my ($self) = @_; |
87
|
|
|
|
|
|
|
$self->{NODE} |
88
|
78
|
|
|
|
|
243
|
} |
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
|
|
24
|
my ($class, $self) = @_; |
102
|
10
|
|
|
|
|
15
|
my $new; |
103
|
10
|
|
|
|
|
39
|
tie @$new, $class, $self; |
104
|
10
|
|
|
|
|
37
|
$new |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub TIEARRAY { |
108
|
10
|
|
|
10
|
|
22
|
my ($class, $self) = @_; |
109
|
10
|
|
|
|
|
38
|
bless $self, $class |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub FETCHSIZE { |
113
|
52
|
|
|
52
|
|
98
|
my ($self) = @_; |
114
|
52
|
|
|
|
|
60
|
scalar @{$self->{NODE}}; |
|
52
|
|
|
|
|
209
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub FETCH { |
118
|
36
|
|
|
36
|
|
64
|
my ($self, $index) = @_; |
119
|
36
|
|
|
|
|
98
|
$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
|
|
129
|
my ($class, $self) = @_; |
142
|
73
|
|
|
|
|
100
|
@{$self->{KEYS}} = sort keys %{$self->{NODE}}; |
|
73
|
|
|
|
|
195
|
|
|
73
|
|
|
|
|
319
|
|
143
|
73
|
|
|
|
|
123
|
my $new; |
144
|
73
|
|
|
|
|
241
|
tie %$new, $class, $self; |
145
|
73
|
|
|
|
|
290
|
$new |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub TIEHASH { |
149
|
73
|
|
|
73
|
|
139
|
my ($class, $self) = @_; |
150
|
73
|
|
|
|
|
188
|
bless $self, $class |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub FETCH { |
154
|
317
|
|
|
317
|
|
613
|
my ($self, $key) = @_; |
155
|
317
|
100
|
|
|
|
665
|
if (exists $self->{NODE}{$key}) { |
156
|
313
|
|
|
|
|
1043
|
return (grep {$_ eq $key} @{$self->{KEYS}}) |
|
161
|
|
|
|
|
317
|
|
157
|
161
|
50
|
|
|
|
226
|
? $self->{NODE}{$key} : undef; |
158
|
|
|
|
|
|
|
} |
159
|
156
|
|
|
|
|
422
|
return $self->{HASH}{$key}; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub STORE { |
163
|
75
|
|
|
75
|
|
160
|
my ($self, $key, $value) = @_; |
164
|
75
|
100
|
|
|
|
199
|
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
|
|
|
|
80
|
if (not grep {$_ eq $key} @{$self->{KEYS}}) { |
|
457
|
|
|
|
|
700
|
|
|
73
|
|
|
|
|
146
|
|
172
|
72
|
|
|
|
|
83
|
push(@{$self->{KEYS}}, $key); |
|
72
|
|
|
|
|
142
|
|
173
|
|
|
|
|
|
|
} |
174
|
73
|
|
|
|
|
152
|
$self->{HASH}{$key} = $value; |
175
|
|
|
|
|
|
|
} |
176
|
75
|
|
|
|
|
276
|
$value |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub DELETE { |
180
|
1
|
|
|
1
|
|
9
|
my ($self, $key) = @_; |
181
|
1
|
|
|
|
|
2
|
my $return; |
182
|
1
|
50
|
|
|
|
4
|
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
|
|
|
|
|
13
|
for (my $i = 0; $i < @{$self->{KEYS}}; $i++) { |
|
4
|
|
|
|
|
12
|
|
189
|
3
|
100
|
|
|
|
8
|
if ($self->{KEYS}[$i] eq $key) { |
190
|
1
|
|
|
|
|
2
|
splice(@{$self->{KEYS}}, $i, 1); |
|
1
|
|
|
|
|
3
|
|
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
} |
193
|
1
|
|
|
|
|
22
|
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
|
|
436
|
my ($self) = @_; |
204
|
197
|
|
|
|
|
341
|
$self->{ITER} = 0; |
205
|
197
|
|
|
|
|
627
|
$self->{KEYS}[0] |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub NEXTKEY { |
209
|
451
|
|
|
451
|
|
642
|
my ($self) = @_; |
210
|
451
|
|
|
|
|
1461
|
$self->{KEYS}[++$self->{ITER}] |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub EXISTS { |
214
|
91
|
|
|
91
|
|
166
|
my ($self, $key) = @_; |
215
|
91
|
|
|
|
|
384
|
exists $self->{NODE}{$key} |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
1; |