blib/lib/Data/Dump/Streamer.pm

filter: Statementstmt 89.5% 180 / 201 Branchbran 64.7% 44 / 68 Conditioncond 41.3% 12 / 29 MC/DCmcdc 12.5% 2 / 16 Subroutinesub 91.1% 31 / 34 Podpod 0.0% 0 / 5 totaltotal 76.2% 269 / 353 CC 49 SCAR 17.1
CC
49
Cov
79%
__ANON__
12.0
_xs_format_text
11.8
_xs_code_text
10.6
CRAP 5.5
↑ Summary Streamer.xs »
1 package Data::Dump::Streamer;
2 46 ▶use 5.012;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 46 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 46 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 46 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 46 ▶use B ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 46 ▶use B::Deparse ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 46 ▶use Data::Dumper ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 46 ▶use DynaLoader ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 46 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 46 ▶use IO::Handle ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 46 ▶use Symbol ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 46 ▶use Hash::Util qw(lock_keys lock_ref_keys lock_keys_plus lock_ref_keys_plus);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 46 ▶use re ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 46 our ($VERSION, $XS_VERSION, $HasPadWalker, $DEBUG);
17 46 our (@ISA, @EXPORT, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS);
18  
19 46 ▶BEGIN {
Subroutine BEGIN: called CC=4 SCAR=16.9
20 46 $VERSION= '3.002';
21 46 $XS_VERSION= eval $VERSION;
22 46 @ISA= qw(Exporter DynaLoader);
23 46 @EXPORT= qw(Dump DumpLex DumpVars);
24 46 @EXPORT_OK= qw(
25 Dump
26 DumpLex
27 DumpVars
28 Stream
29 alias_av
30 alias_hv
31 alias_ref
32 push_alias
33 dualvar
34  
35 alias_to
36  
37 blessed
38 reftype
39 refaddr
40 refcount
41 sv_refcount
42 looks_like_number
43 regex
44 readonly
45 make_ro
46 _make_ro
47 reftype_or_glob
48 refaddr_or_glob
49 globname
50 is_numeric
51  
52 all_keys
53 legal_keys
54 hidden_keys
55 lock_ref_keys
56 lock_keys
57 lock_ref_keys_plus
58 lock_keys_plus
59 SvREADONLY_ref
60 SvREFCNT_ref
61 isweak
62 weaken
63 weak_refcount
64  
65 readonly_set
66  
67 Dumper
68 DDumper
69  
70 alias
71 sqz
72 usqz
73 );
74  
75 46 %EXPORT_TAGS= (
76 undump => [
77 qw( alias_av alias_hv alias_ref make_ro
78 lock_ref_keys
79 lock_keys
80 lock_ref_keys_plus
81 lock_keys_plus
82 alias_to
83 dualvar
84 weaken
85 usqz
86 )
87 ],
88 special => [qw( readonly_set )],
89 all => [ @EXPORT, @EXPORT_OK ],
90 alias => [qw( alias_av alias_hv alias_ref push_alias )],
91 bin => [@EXPORT_OK],
92 Dumper => [qw( Dumper DDumper )],
93 util => [ qw (
94 dualvar
95 blessed reftype refaddr refcount sv_refcount
96 readonly looks_like_number regex is_numeric
97 make_ro readonly_set reftype_or_glob
98 refaddr_or_glob globname
99 weak_refcount isweak weaken
100 )
101 ],
102  
103 );
104  
105 46 Data::Dump::Streamer->bootstrap($XS_VERSION);
106 46 ▶ if ($] >= 5.013006 && $] < 5.013010) {
Branch: 2 branches
BranchTrueFalseTotal
if ($] >= 5.013006 and $] < 5.01301) { } 0 46 46
elsif ($] >= 5.009004) { } 46 0 46
Condition33%1/3
$] >= "5.013006" and $] < "5.01301"
!ll&&!rl&&r
0460
MC/DC0%0/2
$] >= "5.013006" and $] < "5.01301"
$] >= "5.013006" $] < "5.01301"
Truth table33%1/3
A and B
A= $] >= "5.013006"B= $] < "5.01301"
ABresult
0X0
100
111
107  
108 # These development releases exposed flags that were not yet legal
109 # in regexp literals. Preserve the original compatibility rule.
110 0 ▶ *regex= sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
111 0 ▶ return scalar re::regexp_pattern($_[0]) unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 0 0
112 0 my ($pattern, $modifiers)= re::regexp_pattern($_[0]);
113 0 ▶ $modifiers =~ tr/dlua?//d if defined $modifiers;
Branch: 1 branch
BranchTrueFalseTotal
if defined $modifiers 0 0 0
114 0 return ($pattern, $modifiers);
115 0 };
116 }
117 elsif ($] >= 5.009004) {
118 46 *regex= \&re::regexp_pattern;
119 }
120  
121 # Older interpreters use the regex XSUB installed by bootstrap above.
122 46 $HasPadWalker= eval { require PadWalker; PadWalker->VERSION('0.99'); 1 };
123 }
124 46 $DEBUG= 0;
125 46 *DDumper= \&Data::Dumper::Dumper;
126 46 *_get_lexicals= \&_xs_get_lexicals;
127  
128 # Export the requested API and optionally install a package alias selected by
129 # the caller's "as" argument.
130 47 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
131 47 my ($pkg)= @_;
132 47 my ($idx, $alias);
133  
134 47 ▶ if ($idx= (grep lc($_[$_]) eq 'as', 0 .. $#_)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx = grep((lc $_[$_] eq "as"), 0 .. $#_)) 2 45 47
135  
136 #print "found alias at $idx:\n";
137 2 ($idx, $alias)= splice(@_, $idx, 2);
138  
139 #print "found alias: $idx => $alias\n";
140  
141 46 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
142 2 *{ $alias . '::' }= *{ __PACKAGE__ . '::' };
143 }
144 47 $pkg->export_to_level(1, @_);
145 }
146  
147 # Provide the decompressor import prelude or a compressed reconstruction
148 # expression for one string.
149 18 ▶sub _compressor {
Subroutine _compressor: called CC=2 SCAR=6.9
150 18 ▶ return "use Data::Dump::Streamer qw(usqz);\n"
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 9 9 18
151 if !@_;
152 9 return sqz($_[0], "usqz('", "')");
153 }
154  
155 # Compress a private byte copy and Base64-encode it, tagging Unicode strings
156 # so usqz can restore their UTF-8 flag. Optional text wraps the payload.
157 17 ▶sub sqz {
Subroutine sqz: called CC=4 SCAR=13.9
Pod undocumented
158 17 require Compress::Zlib;
159 17 require MIME::Base64;
160  
161 17 my $value= $_[0];
162 17 my $unicode= utf8::is_utf8($value);
163 17 ▶ utf8::encode($value) if $unicode;
Branch: 1 branch
BranchTrueFalseTotal
if $unicode 8 9 17
164 17 my $res= Compress::Zlib::compress($value, 9);
165 17 my $payload= MIME::Base64::encode($res, '');
166  
167 # A colon cannot occur in legacy Base64 payloads. Keep byte strings
168 # untagged so their existing representation remains unchanged.
169 17 ▶ $payload= 'u:' . $payload if $unicode;
Branch: 1 branch
BranchTrueFalseTotal
if $unicode 8 9 17
170 17 ▶ return $_[1]
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 9 8 17
171 ? $_[1] . $payload . $_[2]
172 : $payload;
173 }
174  
175 # Decode and decompress a string emitted by sqz, loading the optional
176 # compression modules in the reconstruction interpreter as needed.
177 15 ▶sub usqz {
Subroutine usqz: called CC=4 SCAR=13.9
Pod undocumented
178 15 require Compress::Zlib;
179 15 require MIME::Base64;
180  
181 15 my $payload= $_[0];
182 15 my $unicode= $payload =~ s/\Au://;
183 15 my $value= Compress::Zlib::uncompress(MIME::Base64::decode($payload));
184 15 ▶ if ($unicode && defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unicode and defined $value) 8 7 15
Condition66%2/3
$unicode and defined $value
!ll&&!rl&&r
708
MC/DC50%1/2
$unicode and defined $value
$unicode defined $value
Truth table66%2/3
A and B
A= $unicodeB= defined $value
ABresult
0X0
100
111
185 8 ▶ utf8::decode($value)
Branch: 1 branch
BranchTrueFalseTotal
utf8::decode($value) or die "Invalid UTF-8 in compressed Unicode string" 8 0 8
186 or die "Invalid UTF-8 in compressed Unicode string";
187 8 utf8::upgrade($value);
188 }
189 15 return $value;
190 }
191  
192 # Return copied catalogue rows ordered by minimum depth and canonical name for
193 # diagnostic display.
194 2 ▶sub _diag_rows {
Subroutine _diag_rows: called CC=2 SCAR=10.1
195 2 my ($self, $kind)= @_;
196 0 ▶ return [ sort { $a->{depth} <=> $b->{depth} || $a->{name} cmp $b->{name} }
Condition0%0/3
$Data::Dump::Streamer::a->{'depth'} <=> $Data::Dump::Streamer::b->{'depth'} || $Data::Dump::Streamer::a->{'name'} cmp $Data::Dump::Streamer::b->{'name'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Data::Dump::Streamer::a->{'depth'} <=> $Data::Dump::Streamer::b->{'depth'} || $Data::Dump::Streamer::a->{'name'} cmp $Data::Dump::Streamer::b->{'name'}
$Data::Dump::Streamer::a->{'depth'} <=> $Data::Dump::Streamer::b->{'depth'} $Data::Dump::Streamer::a->{'name'} cmp $Data::Dump::Streamer::b->{'name'}
Truth table0%0/3
A || B
A= $Data::Dump::Streamer::a->{'depth'} <=> $Data::Dump::Streamer::b->{'depth'}B= $Data::Dump::Streamer::a->{'name'} cmp $Data::Dump::Streamer::b->{'name'}
ABresult
1X1
011
000
197 2 @{ $self->_xs_catalogue->{$kind} } ];
198 }
199  
200 # Format one catalogue row, including identity, counts, depth, flags and
201 # completion status.
202 1 ▶sub _diag_row {
Subroutine _diag_row: called CC=5 SCAR=18.2
203 1 my ($kind, $idx, $row, $prefix)= @_;
204 1 ▶ return '' unless $row;
Branch: 1 branch
BranchTrueFalseTotal
unless $row 0 1 1
205 return sprintf "%s%s %2d : %#x(c%2d|%2d) Dp:%2d %s %s Du:%d => %s\n",
206 $prefix || '', $kind, $idx, @$row{qw(address count encounters depth)},
207 $row->{readonly} ? 'RO' : 'RW', $row->{weak} ? 'WK' : ' ',
208 1 ▶ $row->{done}, $row->{name};
Branch: 2 branches
BranchTrueFalseTotal
$row->{'readonly'} ? : 0 1 1
$row->{'weak'} ? : 0 1 1
Condition50%1/2
$prefix || ''
l!l
01
MC/DC0%0/1
$prefix || ''
$prefix
Truth table50%1/2
A
A= $prefix
Aresult
11
00
209 }
210  
211 # Print scalar-slot and referent catalogue diagnostics to a handle and return
212 # the dumper for chaining.
213 1 ▶sub diag {
Subroutine diag: called CC=4 SCAR=13.9
Pod undocumented
214 1 my $self= shift;
215 1 ▶ my $handle= shift || \*STDOUT;
Condition50%1/2
shift() || \*STDOUT
l!l
10
MC/DC0%0/1
shift() || \*STDOUT
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
216 1 print $handle "+---+\n";
217 1 for my $kind (qw(slots references)) {
218 2 my $rows= $self->_diag_rows($kind);
219 2 for my $idx (0 .. $#$rows) {
220 1 print $handle _diag_row(substr(uc($kind), 0, 1), $idx + 1,
221 $rows->[$idx]);
222 }
223 }
224 1 print $handle "+---+\n";
225 1 return $self;
226 }
227  
228 # Format the requested one-based scalar-slot diagnostic row with an optional
229 # prefix.
230 0 ▶sub diag_sv_idx {
Subroutine diag_sv_idx: not called CC=1 SCAR=6.9
Pod undocumented
231 0 my ($self, $idx, $prefix)= @_;
232 0 return _diag_row('S', $idx, $self->_diag_rows('slots')->[ $idx - 1 ],
233 $prefix);
234 }
235  
236 # Format the requested one-based referent diagnostic row with an optional
237 # prefix.
238 0 ▶sub diag_ref_idx {
Subroutine diag_ref_idx: not called CC=1 SCAR=6.9
Pod undocumented
239 0 my ($self, $idx, $prefix)= @_;
240 0 return _diag_row('R', $idx, $self->_diag_rows('references')->[ $idx - 1 ],
241 $prefix);
242 }
243  
244 # PadWalker supplies names; the native DumpLex entry point handles capture,
245 # contexts, and dumping. XS frames do not add a Perl caller level here.
246 3 ▶sub _xs_lexical_names {
Subroutine _xs_lexical_names: called CC=7 SCAR=21.5
247 3 my %pad_vars;
248 3 for my $pad (PadWalker::peek_my(1), PadWalker::peek_our(1)) {
249 6 ▶ while (my ($var, $ref)= each %$pad) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$pad) 25 6 31
250 25 ▶ $pad_vars{ refaddr($ref) } ||= $var;
Condition33%1/3
$pad_vars{&refaddr($ref)} ||= $var
l!l&&r!l&&!r
0250
MC/DC0%0/2
$pad_vars{&refaddr($ref)} ||= $var
$pad_vars{&refaddr($ref)} $var
Truth table33%1/3
A ||= B
A= $pad_vars{&refaddr($ref)}B= $var
ABresult
1X1
011
000
251 }
252 }
253 return [
254 map {
255 3 $pad_vars{ refaddr(\$_) }
256 6 ▶ || (ref($_) && $pad_vars{ refaddr($_) })
Condition50%4/8
$pad_vars{&refaddr(\$_)} || ref $_ && $pad_vars{&refaddr($_)} || undef
l!l
60
$pad_vars{&refaddr(\$_)} or ref $_ and $pad_vars{&refaddr($_)}
l!l&&r!l&&!r
420
ref $_ and $pad_vars{&refaddr($_)}
!ll&&!rl&&r
002
MC/DC0%0/3
$pad_vars{&refaddr(\$_)} || ref $_ && $pad_vars{&refaddr($_)} || undef
$pad_vars{&refaddr(\$_)} ref $_ $pad_vars{&refaddr($_)}
Truth table50%2/4
A or B and C
A= $pad_vars{&refaddr(\$_)}B= ref $_C= $pad_vars{&refaddr($_)}
ABCresult
1XX1
0111
00X0
0100
257 || undef
258 } @_
259 ];
260 }
261  
262 # Deparse a code reference with catalogue-selected closure names and output
263 # indentation, falling back to the configured stub on failure.
264 50 ▶sub _xs_code_text {
Subroutine _xs_code_text: called CC=10 SCAR=23.6
265 50 my ($self, $item, $name, $indent, $class)= @_;
266 50 ▶ unless ($self->{style}{deparse}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'style'}{'deparse'}) { } 50 0 50
267 0 return $self->{style}{codestub};
268 }
269 else { #deparseopts
270 50 my $cv= B::svref_2object($item);
271  
272 50 ▶ if (ref($cv->ROOT) =~ /NULL/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($cv->ROOT) =~ /NULL/u) 1 49 50
273 1 my $gv= $cv->GV;
274 1 return "\\&" . $gv->STASH->NAME . "::" . $gv->SAFENAME;
275 }
276  
277 my $deparser= Data::Dump::Streamer::Deparser->new(
278 49 @{ $self->{style}{deparseopts} });
279  
280 49 my $used= _xs_get_lexicals($item);
281 49 my %targ;
282 49 foreach my $targ (keys %$used) {
283 78 ▶ next if $targ =~ /\D/;
Branch: 1 branch
BranchTrueFalseTotal
if $targ =~ /\D/u 39 39 78
284 39 my $addr= refaddr($used->{$targ});
285 $targ{$targ}= $self->{lexicals}{a2n}{$addr}
286 39 ▶ if $self->{lexicals}{a2n}{$addr};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"lexicals"}{"a2n"}{$addr} 39 0 39
287 }
288  
289 # we added this method, its not a normal method. see bottom of file.
290 49 $deparser->dds_usenames(\%targ);
291  
292 49 my $code;
293 49 eval {
294 49 $deparser->init;
295 49 local $deparser->{in_coderef2text}= 1;
296 49 $code= $deparser->indent($deparser->deparse_sub($cv));
297 };
298 49 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 49 49
299 0 warnings::warnif
300 "Using CODE stub for $name as B::Deparse failed: $@";
301 0 return $self->{style}{codestub};
302 }
303  
304 49 $code =~ s/(\%\{)(\s*\{\}\s*)/$1;$2/g;
305  
306 49 ▶ $code= "sub" . ($code =~ /^\s*\(/ ? "" : " ") . $code;
Branch: 1 branch
BranchTrueFalseTotal
$code =~ /^\s*\(/u ? : 0 49 49
307 49 ▶ if ($self->{style}{indent}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"style"}{"indent"}) 49 0 49
308 49 $code =~ s/\n/"\n"." " x $indent/meg;
309 }
310  
311 49 ▶ if ($name =~ s/^\&//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s/^\&//u) 7 42 49
312 7 $code =~ s/sub(\s)?/sub $name$1/;
313 }
314 49 return $code;
315 }
316 0 return;
317 }
318  
319 # Reconstruct a format reference, using formatstub when deparsing is disabled
320 # or no format is found. A deparse exception produces a diagnostic format body.
321 4 ▶sub _xs_format_text {
Subroutine _xs_format_text: called CC=8 SCAR=24.7
322  
323 # from link from [ysth]: http://groups.google.com/groups?selm=laUs8gzkgOlT092yn%40efn.org
324 # translate arg (or reference to it) into a B::* object
325 4 my ($self, $item, $name, $indent)= @_;
326  
327 4 ▶ if ($self->{style}{deparse}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"style"}{"deparse"}) 4 0 4
328 4 my $Bobj= B::svref_2object($item);
329  
330 # if passed a glob or globref, get the format
331 4 ▶ $Bobj= B::GV::FORM($Bobj) if ref $Bobj eq 'B::GV';
Branch: 1 branch
BranchTrueFalseTotal
if ref $Bobj eq "B::GV" 0 4 4
332 4 ▶ if (ref $Bobj eq 'B::FM') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $Bobj eq "B::FM") 4 0 4
333 4 my $format;
334 4 eval {
335 4 my $deparser= Data::Dump::Streamer::Deparser->new();
336 4 $format= $deparser->indent($deparser->deparse_format($Bobj));
337 };
338 4 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 4 4
339 0 warnings::warnif
340 0 "B::Deparse (v$B::Deparse::VERSION on @{[$^V]}) failed FORMAT ref deparse.\n";
341 0 $format=
342 0 "B::Deparse (v$B::Deparse::VERSION on @{[$^V]}) failed FORMAT ref deparse.\n.\n";
343 }
344 4 ▶ my $ind= $self->{style}{indent} ? ' ' x $indent : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'style'}{'indent'} ? : 4 0 4
345 4 $format= "format F =\n$format";
346 4 $format =~ s/^/${ind}# /gm;
347  
348 4 my $end= '_EOF_FORMAT_';
349 0 ▶ $end =~ s/T(\d*)_/sprintf "T%02d_",($1||0)+1/e
Branch: 1 branch
BranchTrueFalseTotal
$format =~ /$end/u and do { $end =~ s/T(\d*)_/sprintf "T%02d_", ($1 || 0) + 1;/eu } 0 4 4
Condition0%0/2
$1 || 0
l!l
00
MC/DC0%0/1
$1 || 0
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
350 while $format =~ /$end/;
351  
352 return (
353 4 "do{ local *F; my \$F=<<'$end'; \$F=~s/^\\s+# //mg; eval \$F; die \$F.\$@ if \$@; *F{FORMAT};\n$format\n$end\n$ind}"
354 );
355 }
356 }
357  
358 0 return $self->{style}{formatstub};
359  
360 }
361  
362 # Deparse a glob's FORMAT slot into a named format declaration, returning an
363 # empty string when no format is available.
364 1 ▶sub _xs_glob_format_text {
Subroutine _xs_glob_format_text: called CC=3 SCAR=11.2
365 1 my ($self, $item, $name)= @_;
366 1 my $obj= B::svref_2object($item);
367 1 ▶ $obj= B::GV::FORM($obj) if ref($obj) eq 'B::GV';
Branch: 1 branch
BranchTrueFalseTotal
if ref $obj eq "B::GV" 1 0 1
368 1 ▶ return '' unless ref($obj) eq 'B::FM';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $obj eq "B::FM" 0 1 1
369 1 $name =~ s/^\*(::)?//;
370 1 my $deparser= Data::Dump::Streamer::Deparser->new;
371 return
372 1 "format $name =\n"
373 . $deparser->indent($deparser->deparse_format($obj)) . "\n";
374 }
375  
376 # Apply the configured eclipse-name template while preserving the captured
377 # variable's sigil.
378 7 ▶sub _xs_eclipse_name {
Subroutine _xs_eclipse_name: called CC=2 SCAR=6.9
379 7 my ($name, $format, $n)= @_;
380 7 ▶ return sprintf "%s" . $format, substr($name, 0, 1),
Branch: 1 branch
BranchTrueFalseTotal
$format =~ /^[^%]*%s/u ? : 5 2 7
381 $format =~ /^[^%]*%s/
382 ? (substr($name, 1), $n)
383 : ($n, substr($name, 1));
384 }
385  
386 package Data::Dump::Streamer::Deparser;
387 46 ▶use B::Deparse;
Subroutine BEGIN: called CC=1 SCAR=0.0
388 46 our @ISA= qw(B::Deparse);
389 46 my %cache;
390  
391 46 our $VERSION= '3.002';
392 46 ▶if ($VERSION ne $Data::Dump::Streamer::VERSION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($VERSION ne $Data::Dump::Streamer::VERSION) 0 46 46
393 0 die
394 "Incompatible Data::Dump::Streamer::Deparser v$VERSION vs Data::Dump::Streamer v$Data::Dump::Streamer::VERSION";
395 }
396  
397 # Associate pad offsets with catalogue-selected lexical names for this
398 # deparser instance.
399 49 ▶sub dds_usenames {
Subroutine dds_usenames: called CC=1 SCAR=0.0
400 49 my $self= shift;
401 49 my $names= shift;
402 49 $cache{ Data::Dump::Streamer::refaddr $self}= $names;
403 }
404  
405 # Return an explicitly assigned closure name, falling back to B::Deparse's
406 # pad-name lookup.
407 45 ▶sub padname {
Subroutine padname: called CC=3 SCAR=11.0
408 45 my $self= shift;
409 45 my $targ= shift;
410 45 ▶ if ( $cache{ Data::Dump::Streamer::refaddr $self}
Branch: 1 branch
BranchTrueFalseTotal
if ($cache{&Data::Dump::Streamer::refaddr($self)} and $cache{&Data::Dump::Streamer::refaddr($self)}{$targ}) 39 6 45
Condition66%2/3
$cache{&Data::Dump::Streamer::refaddr($self)} and $cache{&Data::Dump::Streamer::refaddr($self)}{$targ}
!ll&&!rl&&r
0639
MC/DC50%1/2
$cache{&Data::Dump::Streamer::refaddr($self)} and $cache{&Data::Dump::Streamer::refaddr($self)}{$targ}
$cache{&Data::Dump::Streamer::refaddr($self)} $cache{&Data::Dump::Streamer::refaddr($self)}{$targ}
Truth table66%2/3
A and B
A= $cache{&Data::Dump::Streamer::refaddr($self)}B= $cache{&Data::Dump::Streamer::refaddr($self)}{$targ}
ABresult
0X0
100
111
411 and $cache{ Data::Dump::Streamer::refaddr $self}{$targ})
412 {
413 39 return $cache{ Data::Dump::Streamer::refaddr $self}{$targ};
414 }
415 6 return $self->padname_sv($targ)->PVX;
416 }
417  
418 # Remove this deparser's name overrides from the external cache when the
419 # instance is destroyed.
420 54 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
421 54 my $self= shift;
422 54 delete $cache{ Data::Dump::Streamer::refaddr $self};
423 }
424  
425 46 1;
426 __END__
↑ Summary Streamer.xs »