/usr/local/lib/perl5/5.44.0/B/Deparse.pm

filter: Statementstmt 0.0% 0 / 3379 Branchbran 0.0% 0 / 2174 Conditioncond 0.0% 0 / 1368 MC/DCmcdc 0.0% 0 / 733 Subroutinesub 0.0% 0 / 539 Podpod 0.7% 4 / 526 totaltotal 0.0% 4 / 8719 CC 1575 SCAR 64.0
CC
1575
Cov
0%
pp_entersub
3080.0
deparse_argops
2256.0
pp_list
2162.0
CRAP 602.3
« /usr/local/lib/perl5/5.44.0/Exporter.pm ↑ Summary /usr/local/lib/perl5/5.44.0/warnings.pm »
1 # B::Deparse.pm
2 # Copyright (c) 1998-2000, 2002, 2003, 2004, 2005, 2006 Stephen McCamant.
3 # All rights reserved.
4 # This module is free software; you can redistribute and/or modify
5 # it under the same terms as Perl itself.
6  
7 # This is based on the module of the same name by Malcolm Beattie,
8 # but essentially none of his code remains.
9  
10 package B::Deparse 1.89;
11 use strict;
12 use builtin qw( true false );
13 use Carp;
14 use B qw(class main_root main_start main_cv svref_2object opnumber perlstring
15 OPf_WANT OPf_WANT_VOID OPf_WANT_SCALAR OPf_WANT_LIST
16 OPf_KIDS OPf_REF OPf_STACKED OPf_SPECIAL OPf_MOD OPf_PARENS
17 OPpLVAL_INTRO OPpOUR_INTRO OPpENTERSUB_AMPER OPpSLICE OPpKVSLICE
18 OPpCONST_BARE OPpEMPTYAVHV_IS_HV
19 OPpCONST_TOKEN_MASK
20 OPpCONST_TOKEN_LINE OPpCONST_TOKEN_FILE OPpCONST_TOKEN_PACKAGE
21 OPpTRANS_SQUASH OPpTRANS_DELETE OPpTRANS_COMPLEMENT OPpTARGET_MY
22 OPpEXISTS_SUB OPpSORT_NUMERIC OPpSORT_INTEGER OPpREPEAT_DOLIST
23 OPpSORT_REVERSE OPpMULTIDEREF_EXISTS OPpMULTIDEREF_DELETE
24 OPpSPLIT_ASSIGN OPpSPLIT_LEX
25 OPpPADHV_ISKEYS OPpRV2HV_ISKEYS
26 OPpCONCAT_NESTED
27 OPpMULTICONCAT_APPEND OPpMULTICONCAT_STRINGIFY OPpMULTICONCAT_FAKE
28 OPpTRUEBOOL OPpINDEX_BOOLNEG OPpDEFER_FINALLY
29 OPpARG_IF_UNDEF OPpARG_IF_FALSE
30 OPpPARAM_IF_UNDEF OPpPARAM_IF_FALSE
31 SVf_IOK SVf_NOK SVf_ROK SVf_POK SVf_FAKE SVs_RMG SVs_SMG
32 SVs_PADTMP
33 CVf_NOWARN_AMBIGUOUS CVf_LVALUE CVf_IsMETHOD
34 PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE
35 PMf_MULTILINE PMf_SINGLELINE PMf_FOLD PMf_EXTENDED PMf_EXTENDED_MORE
36 PADNAMEf_OUTER PADNAMEf_OUR PADNAMEf_TYPED
37 MDEREF_reload
38 MDEREF_AV_pop_rv2av_aelem
39 MDEREF_AV_gvsv_vivify_rv2av_aelem
40 MDEREF_AV_padsv_vivify_rv2av_aelem
41 MDEREF_AV_vivify_rv2av_aelem
42 MDEREF_AV_padav_aelem
43 MDEREF_AV_gvav_aelem
44 MDEREF_HV_pop_rv2hv_helem
45 MDEREF_HV_gvsv_vivify_rv2hv_helem
46 MDEREF_HV_padsv_vivify_rv2hv_helem
47 MDEREF_HV_vivify_rv2hv_helem
48 MDEREF_HV_padhv_helem
49 MDEREF_HV_gvhv_helem
50 MDEREF_ACTION_MASK
51 MDEREF_INDEX_none
52 MDEREF_INDEX_const
53 MDEREF_INDEX_padsv
54 MDEREF_INDEX_gvsv
55 MDEREF_INDEX_MASK
56 MDEREF_FLAG_last
57 MDEREF_MASK
58 MDEREF_SHIFT
59 OPpSTATEMENT
60 );
61  
62 our $AUTOLOAD;
63 use warnings ();
64 require feature;
65  
66 use Config;
67  
68 BEGIN {
69 # List version-specific constants here.
70 # Easiest way to keep this code portable between version looks to
71 # be to fake up a dummy constant that will never actually be true.
72 foreach (qw(OPpSORT_INPLACE OPpSORT_DESCEND OPpITER_INDEXED
73 OPpITER_REVERSED OPpITER_REFALIAS OPpCONST_NOVER
74 OPpPAD_STATE PMf_SKIPWHITE RXf_SKIPWHITE
75 PMf_CHARSET PMf_KEEPCOPY PMf_NOCAPTURE CVf_ANONCONST
76 CVf_LOCKED OPpREVERSE_INPLACE OPpSUBSTR_REPL_FIRST
77 PMf_NONDESTRUCT OPpEVAL_BYTES
78 OPpLVREF_TYPE OPpLVREF_SV OPpLVREF_AV OPpLVREF_HV
79 OPpLVREF_CV OPpLVREF_ELEM SVpad_STATE)) {
80 eval { B->import($_) };
81 no strict 'refs';
82 *{$_} = sub () {0} unless *{$_}{CODE};
83 }
84 }
85  
86 # Todo:
87 # (See also BUGS section at the end of this file)
88 #
89 # - finish tr/// changes
90 # - add option for even more parens (generalize \&foo change)
91 # - left/right context
92 # - copy comments (look at real text with $^P?)
93 # - avoid semis in one-statement blocks
94 # - associativity of &&=, ||=, ?:
95 # - ',' => '=>' (auto-unquote?)
96 # - break long lines ("\r" as discretionary break?)
97 # - configurable syntax highlighting: ANSI color, HTML, TeX, etc.
98 # - more style options: brace style, hex vs. octal, quotes, ...
99 # - print big ints as hex/octal instead of decimal (heuristic?)
100 # - handle 'my $x if 0'?
101 # - version using op_next instead of op_first/sibling?
102 # - avoid string copies (pass arrays, one big join?)
103 # - here-docs?
104  
105 # Current test.deparse failures
106 # comp/hints 6 - location of BEGIN blocks wrt. block openings
107 # run/switchI 1 - missing -I switches entirely
108 # perl -Ifoo -e 'print @INC'
109 # op/caller 2 - warning mask propagates backwards before warnings::register
110 # 'use warnings; BEGIN {${^WARNING_BITS} eq "U"x12;} use warnings::register'
111 # op/getpid 2 - can't assign to shared my() declaration (threads only)
112 # 'my $x : shared = 5'
113 # op/override 7 - parens on overridden require change v-string interpretation
114 # 'BEGIN{*CORE::GLOBAL::require=sub {}} require v5.6'
115 # c.f. 'BEGIN { *f = sub {0} }; f 2'
116 # op/pat 774 - losing Unicode-ness of Latin1-only strings
117 # 'use charnames ":short"; $x="\N{latin:a with acute}"'
118 # op/recurse 12 - missing parens on recursive call makes it look like method
119 # 'sub f { f($x) }'
120 # op/subst 90 - inconsistent handling of utf8 under "use utf8"
121 # op/taint 29 - "use re 'taint'" deparsed in the wrong place wrt. block open
122 # op/tiehandle compile - "use strict" deparsed in the wrong place
123 # uni/tr_ several
124 # ext/B/t/xref 11 - line numbers when we add newlines to one-line subs
125 # ext/Data/Dumper/t/dumper compile
126 # ext/DB_file/several
127 # ext/Encode/several
128 # ext/Ernno/Errno warnings
129 # ext/IO/lib/IO/t/io_sel 23
130 # ext/PerlIO/t/encoding compile
131 # ext/POSIX/t/posix 6
132 # ext/Socket/Socket 8
133 # ext/Storable/t/croak compile
134 # lib/Attribute/Handlers/t/multi compile
135 # lib/bignum/ several
136 # lib/charnames 35
137 # lib/constant 32
138 # lib/English 40
139 # lib/ExtUtils/t/bytes 4
140 # lib/File/DosGlob compile
141 # lib/Filter/Simple/t/data 1
142 # lib/Math/BigInt/t/constant 1
143 # lib/Net/t/config Deparse-warning
144 # lib/overload compile
145 # lib/Switch/ several
146 # lib/Symbol 4
147 # lib/Test/Simple several
148 # lib/Term/Complete
149 # lib/Tie/File/t/29_downcopy 5
150 # lib/vars 22
151  
152 # Object fields:
153 #
154 # in_coderef2text:
155 # True when deparsing via $deparse->coderef2text; false when deparsing the
156 # main program.
157 #
158 # avoid_local:
159 # (local($a), local($b)) and local($a, $b) have the same internal
160 # representation but the short form looks better. We notice we can
161 # use a large-scale local when checking the list, but need to prevent
162 # individual locals too. This hash holds the addresses of OPs that
163 # have already had their local-ness accounted for. The same thing
164 # is done with my().
165 #
166 # curcv:
167 # CV for current sub (or main program) being deparsed
168 #
169 # curcvlex:
170 # Cached hash of lexical variables for curcv: keys are
171 # names prefixed with "m" or "o" (representing my/our), and
172 # each value is an array with two elements indicating the cop_seq
173 # of scopes in which a var of that name is valid and a third ele-
174 # ment referencing the pad name.
175 #
176 # curcop:
177 # COP for statement being deparsed
178 #
179 # curstash:
180 # name of the current package for deparsed code
181 #
182 # subs_todo:
183 # array of [cop_seq, CV, is_format?, name] for subs and formats we still
184 # want to deparse. The fourth element is a pad name thingy for lexical
185 # subs or a string for special blocks. For other subs, it is undef. For
186 # lexical subs, CV may be undef, indicating a stub declaration.
187 #
188 # protos_todo:
189 # as above, but [name, prototype] for subs that never got a GV
190 #
191 # subs_done, forms_done:
192 # keys are addresses of GVs for subs and formats we've already
193 # deparsed (or at least put into subs_todo)
194 #
195 # subs_declared
196 # keys are names of subs for which we've printed declarations.
197 # That means we can omit parentheses from the arguments. It also means we
198 # need to put CORE:: on core functions of the same name.
199 #
200 # in_subst_repl
201 # True when deparsing the replacement part of a substitution.
202 #
203 # in_refgen
204 # True when deparsing the argument to \.
205 #
206 # parens: -p
207 # linenums: -l
208 # unquote: -q
209 # cuddle: ' ' or '\n', depending on -sC
210 # indent_size: -si
211 # use_tabs: -sT
212 # ex_const: -sv
213  
214 # A little explanation of how precedence contexts and associativity
215 # work:
216 #
217 # deparse() calls each per-op subroutine with an argument $cx (short
218 # for context, but not the same as the cx* in the perl core), which is
219 # a number describing the op's parents in terms of precedence, whether
220 # they're inside an expression or at statement level, etc. (see
221 # chart below). When ops with children call deparse on them, they pass
222 # along their precedence. Fractional values are used to implement
223 # associativity ('($x + $y) + $z' => '$x + $y + $y') and related
224 # parentheses hacks. The major disadvantage of this scheme is that
225 # it doesn't know about right sides and left sides, so say if you
226 # assign a listop to a variable, it can't tell it's allowed to leave
227 # the parens off the listop.
228  
229 # Precedences:
230 # 26 [TODO] inside interpolation context ("")
231 # 25 left terms and list operators (leftward)
232 # 24 left ->
233 # 23 nonassoc ++ --
234 # 22 right **
235 # 21 right ! ~ \ and unary + and -
236 # 20 left =~ !~
237 # 19 left * / % x
238 # 18 left + - .
239 # 17 left << >>
240 # 16 nonassoc named unary operators
241 # 15 nonassoc < > <= >= lt gt le ge
242 # 14 nonassoc == != <=> eq ne cmp
243 # 13 left &
244 # 12 left | ^
245 # 11 left &&
246 # 10 left ||
247 # 9 nonassoc .. ...
248 # 8 right ?:
249 # 7 right = += -= *= etc.
250 # 6 left , =>
251 # 5 nonassoc list operators (rightward)
252 # 4 right not
253 # 3 left and
254 # 2 left or xor
255 # 1 statement modifiers
256 # 0.5 statements, but still print scopes as do { ... }
257 # 0 statement level
258 # -1 format body
259  
260 # Nonprinting characters with special meaning:
261 # \cS - steal parens (see maybe_parens_unop)
262 # \n - newline and indent
263 # \t - increase indent
264 # \b - decrease indent ('outdent')
265 # \f - flush left (no indent)
266 # \cK - kill following semicolon, if any
267  
268 # Semicolon handling:
269 # - Individual statements are not deparsed with trailing semicolons.
270 # (If necessary, \cK is tacked on to the end.)
271 # - Whatever code joins statements together or emits them (lineseq,
272 # scopeop, deparse_root) is responsible for adding semicolons where
273 # necessary.
274 # - use statements are deparsed with trailing semicolons because they are
275 # immediately concatenated with the following statement.
276 # - indent() removes semicolons wherever it sees \cK.
277  
278  
279 BEGIN { for (qw[ const stringify rv2sv list glob pushmark null stub aelem
280 kvaslice kvhslice padsv argcheck
281 nextstate dbstate rv2av rv2hv helem pushdefer leavetrycatch
282 custom ]) {
283 eval "sub OP_\U$_ () { " . opnumber($_) . "}"
284 }}
285  
286 # _pessimise_walk(): recursively walk the optree of a sub,
287 # possibly undoing optimisations along the way.
288  
289 0 ▶sub DEBUG { 0 }
Subroutine DEBUG: not called CC=1 SCAR=6.9
Pod undocumented
290 use if DEBUG, 'Data::Dumper';
291  
292 sub _pessimise_walk {
293 0 ▶ my ($self, $startop) = @_;
Subroutine _pessimise_walk: not called CC=12 SCAR=50.5
294  
295 0 ▶ return unless $$startop;
Branch: 1 branch
BranchTrueFalseTotal
unless $$startop 0 0 0
296 0 my ($op, $prevop);
297 0 ▶ for ($op = $startop; $$op; $prevop = $op, $op = $op->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$op) 0 0 0
298 0 my $ppname = $op->name;
299  
300 # pessimisations start here
301  
302 0 ▶ if ($ppname eq "padrange") {
Branch: 1 branch
BranchTrueFalseTotal
if ($ppname eq "padrange") 0 0 0
303 # remove PADRANGE:
304 # the original optimisation either (1) changed this:
305 # pushmark -> (various pad and list and null ops) -> the_rest
306 # or (2), for the = @_ case, changed this:
307 # pushmark -> gv[_] -> rv2av -> (pad stuff) -> the_rest
308 # into this:
309 # padrange ----------------------------------------> the_rest
310 # so we just need to convert the padrange back into a
311 # pushmark, and in case (1), set its op_next to op_sibling,
312 # which is the head of the original chain of optimised-away
313 # pad ops, or for (2), set it to sibling->first, which is
314 # the original gv[_].
315  
316 0 $B::overlay->{$$op} = {
317 type => OP_PUSHMARK,
318 name => 'pushmark',
319 private => ($op->private & OPpLVAL_INTRO),
320 };
321 }
322  
323 # pessimisations end here
324  
325 0 ▶ if (class($op) eq 'PMOP') {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($op) eq "PMOP") 0 0 0
326 0 ▶ if (ref($op->pmreplroot)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $op->pmreplroot and ${$op->pmreplroot;} and $op->pmreplroot->isa("B::OP")) 0 0 0
Condition0%0/6
ref $op->pmreplroot and ${$op->pmreplroot;} and $op->pmreplroot->isa("B::OP")
!ll&&!rl&&r
000
ref $op->pmreplroot and ${$op->pmreplroot;}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $op->pmreplroot and ${$op->pmreplroot;} and $op->pmreplroot->isa("B::OP")
ref $op->pmreplroot ${$op->pmreplroot;} $op->pmreplroot->isa("B::OP")
Truth table0%0/4
A and B and C
A= ref $op->pmreplrootB= ${$op->pmreplroot;}C= $op->pmreplroot->isa("B::OP")
ABCresult
0XX0
10X0
1100
1111
327 0 && ${$op->pmreplroot}
328 && $op->pmreplroot->isa( 'B::OP' ))
329 {
330 0 $self-> _pessimise_walk($op->pmreplroot);
331 }
332  
333 # pessimise any /(?{...})/ code blocks
334 0 my ($re, $cv);
335 0 my $code_list = $op->code_list;
336 0 ▶ if ($$code_list) {
Branch: 2 branches
BranchTrueFalseTotal
if ($$code_list) { } 0 0 0
elsif (${$re = $op->pmregexp;} and ${$cv = $re->qr_anoncv;}) { } 0 0 0
337 0 $self->_pessimise_walk($code_list);
338 }
339 0 ▶ elsif (${$re = $op->pmregexp} && ${$cv = $re->qr_anoncv}) {
Condition0%0/3
${$re = $op->pmregexp;} and ${$cv = $re->qr_anoncv;}
!ll&&!rl&&r
000
MC/DC0%0/2
${$re = $op->pmregexp;} and ${$cv = $re->qr_anoncv;}
${$re = $op->pmregexp;} ${$cv = $re->qr_anoncv;}
Truth table0%0/3
A and B
A= ${$re = $op->pmregexp;}B= ${$cv = $re->qr_anoncv;}
ABresult
0X0
100
111
340 0 $code_list = $cv->ROOT # leavesub
341 ->first # qr
342 ->code_list; # list
343 0 $self->_pessimise_walk($code_list);
344 }
345 }
346  
347 0 ▶ if ($op->flags & OPf_KIDS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 4) 0 0 0
348 0 $self-> _pessimise_walk($op->first);
349 }
350  
351 }
352 }
353  
354  
355 # _pessimise_walk_exe(): recursively walk the op_next chain of a sub,
356 # possibly undoing optimisations along the way.
357  
358 sub _pessimise_walk_exe {
359 0 ▶ my ($self, $startop, $visited) = @_;
Subroutine _pessimise_walk_exe: not called CC=8 SCAR=42.8
360  
361 no warnings 'recursion';
362  
363 0 ▶ return unless $$startop;
Branch: 1 branch
BranchTrueFalseTotal
unless $$startop 0 0 0
364 0 ▶ return if $visited->{$$startop};
Branch: 1 branch
BranchTrueFalseTotal
if $$visited{$$startop} 0 0 0
365 0 my ($op, $prevop);
366 0 ▶ for ($op = $startop; $$op; $prevop = $op, $op = $op->next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$op) 0 0 0
367 0 ▶ last if $visited->{$$op};
Branch: 1 branch
BranchTrueFalseTotal
if $$visited{$$op} 0 0 0
368 0 $visited->{$$op} = 1;
369 0 my $ppname = $op->name;
370 0 ▶ if ($ppname =~
Branch: 3 branches
BranchTrueFalseTotal
if ($ppname =~ /^((and|d?or)(assign)?|(map|grep)while|range|cond_expr|once)$/) { } 0 0 0
elsif ($ppname eq 'subst') { } 0 0 0
elsif ($ppname =~ /^(enter(loop|iter))$/) { } 0 0 0
371 /^((and|d?or)(assign)?|(map|grep)while|range|cond_expr|once)$/
372 # entertry is also a logop, but its op_other invariably points
373 # into the same chain as the main execution path, so we skip it
374 ) {
375 0 $self->_pessimise_walk_exe($op->other, $visited);
376 }
377 elsif ($ppname eq "subst") {
378 0 $self->_pessimise_walk_exe($op->pmreplstart, $visited);
379 }
380 elsif ($ppname =~ /^(enter(loop|iter))$/) {
381 # redoop and nextop will already be covered by the main block
382 # of the loop
383 0 $self->_pessimise_walk_exe($op->lastop, $visited);
384 }
385  
386 # pessimisations start here
387 }
388 }
389  
390 # Go through an optree and "remove" some optimisations by using an
391 # overlay to selectively modify or un-null some ops. Deparsing in the
392 # absence of those optimisations is then easier.
393 #
394 # Note that older optimisations are not removed, as Deparse was already
395 # written to recognise them before the pessimise/overlay system was added.
396  
397 sub pessimise {
398 0 ▶ my ($self, $root, $start) = @_;
Subroutine pessimise: not called CC=1 SCAR=6.9
Pod undocumented
399  
400 no warnings 'recursion';
401 # walk tree in root-to-branch order
402 0 $self->_pessimise_walk($root);
403  
404 0 my %visited;
405 # walk tree in execution order
406 0 $self->_pessimise_walk_exe($start, \%visited);
407 }
408  
409  
410 sub null {
411 0 ▶ my $op = shift;
Subroutine null: not called CC=1 SCAR=6.9
Pod undocumented
412 0 return class($op) eq "NULL";
413 }
414  
415  
416 # Add a CV to the list of subs that still need deparsing.
417  
418 sub todo {
419 0 ▶ my $self = shift;
Subroutine todo: not called CC=8 SCAR=42.8
Pod undocumented
420 0 my($cv, $is_form, $name) = @_;
421 0 ▶ my $cvfile = $cv->FILE//'';
Condition0%0/2
$cv->FILE // ""
l!l
00
MC/DC0%0/1
$cv->FILE // ""
$cv->FILE
Truth table0%0/2
A
A= $cv->FILE
Aresult
11
00
422 0 ▶ return unless ($cvfile eq $0 || exists $self->{files}{$cvfile});
Branch: 1 branch
BranchTrueFalseTotal
unless $cvfile eq $0 or exists $self->{"files"}{$cvfile} 0 0 0
Condition0%0/3
$cvfile eq $0 or exists $self->{"files"}{$cvfile}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cvfile eq $0 or exists $self->{"files"}{$cvfile}
$cvfile eq $0 exists $self->{"files"}{$cvfile}
Truth table0%0/3
A or B
A= $cvfile eq $0B= exists $self->{"files"}{$cvfile}
ABresult
1X1
011
000
423 0 my $seq;
424 0 ▶ if ($cv->OUTSIDE_SEQ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cv->OUTSIDE_SEQ) { } 0 0 0
elsif (not null($cv->START) and is_state($cv->START)) { } 0 0 0
425 0 $seq = $cv->OUTSIDE_SEQ;
426 ▶ } elsif (!null($cv->START) and is_state($cv->START)) {
Condition0%0/3
not null($cv->START) and is_state($cv->START)
!ll&&!rl&&r
000
MC/DC0%0/2
not null($cv->START) and is_state($cv->START)
not null($cv->START) is_state($cv->START)
Truth table0%0/3
not(A) and B
A= not null($cv->START)B= is_state($cv->START)
ABresult
0X0
100
111
427 0 $seq = $cv->START->cop_seq;
428 } else {
429 0 $seq = 0;
430 }
431 0 my $stash = $cv->STASH;
432 0 ▶ if (class($stash) eq 'HV') {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($stash) eq "HV") 0 0 0
433 0 $self->{packs}{$stash->NAME}++;
434 }
435 0 push @{$self->{'subs_todo'}}, [$seq, $cv, $is_form, $name];
436 }
437  
438  
439 # Pop the next sub from the todo list and deparse it
440  
441 sub next_todo {
442 0 ▶ my $self = shift;
Subroutine next_todo: not called CC=33 SCAR=70.2
Pod undocumented
443 0 my $ent = shift @{$self->{'subs_todo'}};
444 0 my ($seq, $cv, $is_form, $name) = @$ent;
445  
446 # any 'use strict; package foo' that should come before the sub
447 # declaration to sync with the first COP of the sub
448 0 my $pragmata = '';
449 0 ▶ if ($cv and !null($cv->START) and is_state($cv->START)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv and not null($cv->START) and is_state($cv->START)) 0 0 0
Condition0%0/6
$cv and not null($cv->START) and is_state($cv->START)
!ll&&!rl&&r
000
$cv and not null($cv->START)
!ll&&!rl&&r
000
MC/DC0%0/3
$cv and not null($cv->START) and is_state($cv->START)
$cv not null($cv->START) is_state($cv->START)
Truth table0%0/4
A and not(B) and C
A= $cvB= not null($cv->START)C= is_state($cv->START)
ABCresult
0XX0
10X0
1100
1111
450 0 $pragmata = $self->pragmata($cv->START);
451 }
452  
453 0 ▶ if (ref $name) { # lexical sub
Branch: 1 branch
BranchTrueFalseTotal
if (ref $name) 0 0 0
454 # emit the sub.
455 0 my @text;
456 0 my $flags = $name->FLAGS;
457 0 ▶ my $category =
Branch: 3 branches
BranchTrueFalseTotal
!$cv || $seq <= $name->COP_SEQ_RANGE_LOW ? : 0 0 0
$flags & 16 ? : 0 0 0
$flags & 2 ? : 0 0 0
Condition0%0/3
not $cv or $seq <= $name->COP_SEQ_RANGE_LOW
l!l&&r!l&&!r
000
MC/DC0%0/2
not $cv or $seq <= $name->COP_SEQ_RANGE_LOW
not $cv $seq <= $name->COP_SEQ_RANGE_LOW
Truth table0%0/3
not(A) or B
A= not $cvB= $seq <= $name->COP_SEQ_RANGE_LOW
ABresult
1X1
011
000
458 !$cv || $seq <= $name->COP_SEQ_RANGE_LOW
459 ? $self->keyword($flags & PADNAMEf_OUR
460 ? "our"
461 : $flags & SVpad_STATE
462 ? "state"
463 : "my") . " "
464 : "";
465  
466 # Skip lexical 'state' subs imported from the builtin::
467 # package, since they are created automatically by
468 # use builtin "foo"
469 0 ▶ if ($cv && $category =~ /\bstate\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv and $category =~ /\bstate\b/) 0 0 0
Condition0%0/3
$cv and $category =~ /\bstate\b/
!ll&&!rl&&r
000
MC/DC0%0/2
$cv and $category =~ /\bstate\b/
$cv $category =~ /\bstate\b/
Truth table0%0/3
A and B
A= $cvB= $category =~ /\bstate\b/
ABresult
0X0
100
111
470 0 my $globname;
471 0 my $gv = $cv->GV;
472 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($gv and $gv->isa("B::GV") and defined($globname = $gv->object_2svref) and $$globname =~ /^\*builtin::/) 0 0 0
Condition0%0/9
$gv and $gv->isa("B::GV") and defined($globname = $gv->object_2svref) and $$globname =~ /^\*builtin::/
!ll&&!rl&&r
000
$gv and $gv->isa("B::GV") and defined($globname = $gv->object_2svref)
!ll&&!rl&&r
000
$gv and $gv->isa("B::GV")
!ll&&!rl&&r
000
MC/DC0%0/4
$gv and $gv->isa("B::GV") and defined($globname = $gv->object_2svref) and $$globname =~ /^\*builtin::/
$gv $gv->isa("B::GV") defined($globname = $gv->object_2svref) $$globname =~ /^\*builtin::/
Truth table0%0/5
A and B and C and D
A= $gvB= $gv->isa("B::GV")C= defined($globname = $gv->object_2svref)D= $$globname =~ /^\*builtin::/
ABCDresult
0XXX0
10XX0
110X0
11100
11111
473 $gv && $gv->isa('B::GV')
474 && defined (($globname = $gv->object_2svref))
475 && $$globname =~ /^\*builtin::/
476 ) {
477 0 return '';
478 }
479 }
480  
481 0 push @text, $category;
482  
483 # XXX We would do $self->keyword("sub"), but ‘my CORE::sub’
484 # doesn’t work and ‘my sub’ ignores a &sub in scope. I.e.,
485 # we have a core bug here.
486 0 ▶ my $kw = $cv ? $self->kw_sub_or_method($cv) : "sub";
Branch: 1 branch
BranchTrueFalseTotal
$cv ? : 0 0 0
487 0 push @text, "$kw " . substr $name->PVX, 1;
488 0 ▶ if ($cv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv) { } 0 0 0
489 # my sub foo { }
490 0 push @text, " " . $self->deparse_sub($cv);
491 0 $text[-1] =~ s/ ;$/;/;
492 }
493 else {
494 # my sub foo;
495 0 push @text, ";\n";
496 }
497 0 return $pragmata . join "", @text;
498 }
499  
500 0 my $gv = $cv->GV;
501 0 ▶ $name //= $self->gv_name($gv);
Condition0%0/3
$name //= $self->gv_name($gv)
l!l&&r!l&&!r
000
MC/DC0%0/2
$name //= $self->gv_name($gv)
$name $self->gv_name($gv)
Truth table0%0/3
A //= B
A= $nameB= $self->gv_name($gv)
ABresult
1X1
011
000
502 0 ▶ if ($is_form) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_form) { } 0 0 0
503 0 return $pragmata . $self->keyword("format") . " $name =\n"
504 . $self->deparse_format($cv). "\n";
505 } else {
506 0 my $use_dec;
507 0 ▶ if ($name eq "BEGIN") {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "BEGIN") 0 0 0
508 0 $use_dec = $self->begin_is_use($cv);
509 0 ▶ if (defined ($use_dec) and $self->{'expand'} < 5) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $use_dec and $self->{"expand"} < 5) 0 0 0
Condition0%0/3
defined $use_dec and $self->{"expand"} < 5
!ll&&!rl&&r
000
MC/DC0%0/2
defined $use_dec and $self->{"expand"} < 5
defined $use_dec $self->{"expand"} < 5
Truth table0%0/3
A and B
A= defined $use_decB= $self->{"expand"} < 5
ABresult
0X0
100
111
510 0 ▶ return $pragmata if 0 == length($use_dec);
Branch: 1 branch
BranchTrueFalseTotal
if 0 == length $use_dec 0 0 0
511  
512 # XXX bit of a hack: Test::More's use_ok() method
513 # builds a fake use statement which deparses as, e.g.
514 # use Net::Ping (@{$args[0];});
515 # As well as being superfluous (the use_ok() is deparsed
516 # too) and ugly, it fails under use strict and otherwise
517 # makes use of a lexical var that's not in scope.
518 # So strip it out.
519 0 ▶ return $pragmata
Branch: 1 branch
BranchTrueFalseTotal
if $use_dec =~ / \A use \s \S+ \s \(\@\{ ( \s*\#line\ \d+\ \".*"\s* )? \$args\[0\];\}\); \n \Z /x 0 0 0
520 if $use_dec =~
521 m/
522 \A
523 use \s \S+ \s \(\@\{
524 (
525 \s*\#line\ \d+\ \".*"\s*
526 )?
527 \$args\[0\];\}\);
528 \n
529 \Z
530 /x;
531  
532 0 $use_dec =~ s/^(use|no)\b/$self->keyword($1)/e;
533 }
534 }
535 0 my $l = '';
536 0 ▶ if ($self->{'linenums'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"linenums"}) 0 0 0
537 0 my $line = $gv->LINE;
538 0 my $file = $gv->FILE;
539 0 $l = "\n\f#line $line \"$file\"\n";
540 }
541 0 my $p = '';
542 0 my $stash;
543 0 ▶ if (class($cv->STASH) ne "SPECIAL") {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($cv->STASH) ne "SPECIAL") 0 0 0
544 0 $stash = $cv->STASH->NAME;
545 0 ▶ if ($stash ne $self->{'curstash'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stash ne $self->{"curstash"}) 0 0 0
546 0 $p = $self->keyword("package") . " $stash;\n";
547 0 ▶ $name = "$self->{'curstash'}::$name" unless $name =~ /::/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /::/ 0 0 0
548 0 $self->{'curstash'} = $stash;
549 }
550 }
551 0 ▶ if ($use_dec) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_dec) 0 0 0
552 0 return "$pragmata$p$l$use_dec";
553 }
554 0 ▶ if ( $name !~ /::/ and $self->lex_in_scope("&$name")
Branch: 2 branches
BranchTrueFalseTotal
if (not $name =~ /::/ and $self->lex_in_scope("&$name") || $self->lex_in_scope("&$name", 1)) { } 0 0 0
elsif (defined $stash) { } 0 0 0
Condition0%0/6
not $name =~ /::/ and $self->lex_in_scope("&$name") || $self->lex_in_scope("&$name", 1)
!ll&&!rl&&r
000
$self->lex_in_scope("&$name") or $self->lex_in_scope("&$name", 1)
l!l&&r!l&&!r
000
MC/DC0%0/3
not $name =~ /::/ and $self->lex_in_scope("&$name") || $self->lex_in_scope("&$name", 1)
not $name =~ /::/ $self->lex_in_scope("&$name") $self->lex_in_scope("&$name", 1)
Truth table0%0/4
not(A) and B or C
A= not $name =~ /::/B= $self->lex_in_scope("&$name")C= $self->lex_in_scope("&$name", 1)
ABCresult
0XX0
1000
11X1
1011
555 || $self->lex_in_scope("&$name", 1) )
556 {
557 0 $name = "$self->{'curstash'}::$name";
558 } elsif (defined $stash) {
559 0 $name =~ s/^\Q$stash\E::(?!\z|.*::)//;
560 }
561 0 my $ret = "$pragmata${p}${l}" . $self->keyword($self->kw_sub_or_method($cv)) . " $name "
562 . $self->deparse_sub($cv);
563 0 $self->{'subs_declared'}{$name} = 1;
564 0 return $ret;
565 }
566 }
567  
568  
569 # Return a "use" declaration for this BEGIN block, if appropriate
570 sub begin_is_use {
571 0 ▶ my ($self, $cv) = @_;
Subroutine begin_is_use: not called CC=31 SCAR=69.0
Pod undocumented
572 0 my $root = $cv->ROOT;
573 0 local @$self{qw'curcv curcvlex'} = ($cv);
574 0 local $B::overlay = {};
575 0 $self->pessimise($root, $cv->START);
576 #require B::Debug;
577 #B::walkoptree($cv->ROOT, "debug");
578 0 my $lineseq = $root->first;
579 0 ▶ return if $lineseq->name ne "lineseq";
Branch: 1 branch
BranchTrueFalseTotal
if $lineseq->name ne "lineseq" 0 0 0
580  
581 0 my $req_op = $lineseq->first->sibling;
582 0 ▶ return if $req_op->name ne "require";
Branch: 1 branch
BranchTrueFalseTotal
if $req_op->name ne "require" 0 0 0
583  
584 # maybe it's C<require expr> rather than C<require 'foo'>
585 0 ▶ return if ($req_op->first->name ne 'const');
Branch: 1 branch
BranchTrueFalseTotal
if $req_op->first->name ne "const" 0 0 0
586  
587 0 my $module;
588 0 ▶ if ($req_op->first->private & OPpCONST_BARE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req_op->first->private & 32) { } 0 0 0
589 # Actually it should always be a bareword
590 0 $module = $self->const_sv($req_op->first)->PV;
591 0 $module =~ s[/][::]g;
592 0 $module =~ s/.pm$//;
593 }
594 else {
595 0 $module = $self->const($self->const_sv($req_op->first), 6);
596 }
597  
598 0 my $version;
599 0 my $version_op = $req_op->sibling;
600 0 ▶ return if class($version_op) eq "NULL";
Branch: 1 branch
BranchTrueFalseTotal
if B::Deparse::class($version_op) eq "NULL" 0 0 0
601 0 ▶ if ($version_op->name eq "lineseq") {
Branch: 1 branch
BranchTrueFalseTotal
if ($version_op->name eq "lineseq") 0 0 0
602 # We have a version parameter; skip nextstate & pushmark
603 0 my $constop = $version_op->first->next->next;
604  
605 0 ▶ return unless $self->const_sv($constop)->PV eq $module;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->const_sv($constop)->PV eq $module 0 0 0
606 0 $constop = $constop->sibling;
607 0 $version = $self->const_sv($constop);
608 0 ▶ if (class($version) eq "IV") {
Branch: 3 branches
BranchTrueFalseTotal
if (B::Deparse::class($version) eq 'IV') { } 0 0 0
elsif (B::Deparse::class($version) eq 'NV') { } 0 0 0
elsif (B::Deparse::class($version) ne 'PVMG') { } 0 0 0
609 0 $version = $version->int_value;
610 } elsif (class($version) eq "NV") {
611 0 $version = $version->NV;
612 } elsif (class($version) ne "PVMG") {
613 # Includes PVIV and PVNV
614 0 $version = $version->PV;
615 } else {
616 # version specified as a v-string
617 0 $version = 'v'.join '.', map ord, split //, $version->PV;
618 }
619 0 $constop = $constop->sibling;
620 0 ▶ return if $constop->name ne "method_named";
Branch: 1 branch
BranchTrueFalseTotal
if $constop->name ne "method_named" 0 0 0
621 0 ▶ return if $self->meth_sv($constop)->PV ne "VERSION";
Branch: 1 branch
BranchTrueFalseTotal
if $self->meth_sv($constop)->PV ne "VERSION" 0 0 0
622 }
623  
624 0 $lineseq = $version_op->sibling;
625 0 ▶ return if $lineseq->name ne "lineseq";
Branch: 1 branch
BranchTrueFalseTotal
if $lineseq->name ne "lineseq" 0 0 0
626 0 my $entersub = $lineseq->first->sibling;
627 0 ▶ if ($entersub->name eq "stub") {
Branch: 1 branch
BranchTrueFalseTotal
if ($entersub->name eq "stub") 0 0 0
628 0 ▶ return "use $module $version ();\n" if defined $version;
Branch: 1 branch
BranchTrueFalseTotal
if defined $version 0 0 0
629 0 return "use $module ();\n";
630 }
631 0 ▶ return if $entersub->name ne "entersub";
Branch: 1 branch
BranchTrueFalseTotal
if $entersub->name ne "entersub" 0 0 0
632  
633 # See if there are import arguments
634 0 my $args = '';
635  
636 0 my $svop = $entersub->first->sibling; # Skip over pushmark
637 0 ▶ return unless $self->const_sv($svop)->PV eq $module;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->const_sv($svop)->PV eq $module 0 0 0
638  
639 # Pull out the arguments
640 0 ▶ for ($svop=$svop->sibling; index($svop->name, "method_") != 0;
Branch: 1 branch
BranchTrueFalseTotal
if (index($svop->name, "method_") != 0) 0 0 0
641 $svop = $svop->sibling) {
642 0 ▶ $args .= ", " if length($args);
Branch: 1 branch
BranchTrueFalseTotal
if length $args 0 0 0
643 0 $args .= $self->deparse($svop, 6);
644 }
645  
646 0 my $use = 'use';
647 0 my $method_named = $svop;
648 0 ▶ return if $method_named->name ne "method_named";
Branch: 1 branch
BranchTrueFalseTotal
if $method_named->name ne "method_named" 0 0 0
649 0 my $method_name = $self->meth_sv($method_named)->PV;
650  
651 0 ▶ if ($method_name eq "unimport") {
Branch: 1 branch
BranchTrueFalseTotal
if ($method_name eq "unimport") 0 0 0
652 0 $use = 'no';
653 }
654  
655 # Certain pragmas are dealt with using hint bits,
656 # so we ignore them here
657 0 ▶ if ($module eq 'strict' || $module eq 'integer'
Branch: 1 branch
BranchTrueFalseTotal
if ($module eq "strict" or $module eq "integer" or $module eq "bytes" or $module eq "warnings" or $module eq "feature") 0 0 0
Condition0%0/12
$module eq "strict" or $module eq "integer" or $module eq "bytes" or $module eq "warnings" or $module eq "feature"
l!l&&r!l&&!r
000
$module eq "strict" or $module eq "integer" or $module eq "bytes" or $module eq "warnings"
l!l&&r!l&&!r
000
$module eq "strict" or $module eq "integer" or $module eq "bytes"
l!l&&r!l&&!r
000
$module eq "strict" or $module eq "integer"
l!l&&r!l&&!r
000
MC/DC0%0/5
$module eq "strict" or $module eq "integer" or $module eq "bytes" or $module eq "warnings" or $module eq "feature"
$module eq "strict" $module eq "integer" $module eq "bytes" $module eq "warnings" $module eq "feature"
Truth table0%0/6
A or B or C or D or E
A= $module eq "strict"B= $module eq "integer"C= $module eq "bytes"D= $module eq "warnings"E= $module eq "feature"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
658 || $module eq 'bytes' || $module eq 'warnings'
659 || $module eq 'feature') {
660 0 return "";
661 }
662  
663 0 ▶ if (defined $version && length $args) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $version and length $args) { } 0 0 0
elsif (defined $version) { } 0 0 0
elsif (length $args) { } 0 0 0
Condition0%0/3
defined $version and length $args
!ll&&!rl&&r
000
MC/DC0%0/2
defined $version and length $args
defined $version length $args
Truth table0%0/3
A and B
A= defined $versionB= length $args
ABresult
0X0
100
111
664 0 return "$use $module $version ($args);\n";
665 } elsif (defined $version) {
666 0 return "$use $module $version;\n";
667 } elsif (length $args) {
668 0 return "$use $module ($args);\n";
669 } else {
670 0 return "$use $module;\n";
671 }
672 }
673  
674 sub stash_subs {
675 0 ▶ my ($self, $pack, $seen) = @_;
Subroutine stash_subs: not called CC=30 SCAR=68.4
Pod undocumented
676 0 my (@ret, $stash);
677 0 ▶ if (!defined $pack) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $pack) { } 0 0 0
678 0 $pack = '';
679 0 $stash = \%::;
680 }
681 else {
682 0 $pack =~ s/(::)?$/::/;
683 no strict 'refs';
684 0 $stash = \%{"main::$pack"};
685 }
686 return
687 if ($seen ||= {})->{
688 0 ▶ $INC{"overload.pm"} ? overload::StrVal($stash) : $stash
Branch: 2 branches
BranchTrueFalseTotal
if ($seen ||= {})->{$INC{"overload.pm"} ? overload::StrVal($stash) : $stash}++ 0 0 0
$INC{'overload.pm'} ? : 0 0 0
Condition0%0/2
$seen ||= {}
l!l
00
MC/DC0%0/1
$seen ||= {}
$seen
Truth table0%0/2
A
A= $seen
Aresult
11
00
689 }++;
690 0 my $stashobj = svref_2object($stash);
691 0 my %stash = $stashobj->ARRAY;
692 0 ▶ while (my ($key, $val) = each %stash) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %stash) 0 0 0
693 0 my $flags = $val->FLAGS;
694 0 ▶ if ($flags & SVf_ROK) {
Branch: 3 branches
BranchTrueFalseTotal
if ($flags & 2048) { } 0 0 0
elsif ($flags & 1280) { } 0 0 0
elsif (B::Deparse::class($val) eq 'GV') { } 0 0 0
695 # A reference. Dump this if it is a reference to a CV. If it
696 # is a constant acting as a proxy for a full subroutine, then
697 # we may or may not have to dump it. If some form of perl-
698 # space visible code must have created it, be it a use
699 # statement, or some direct symbol-table manipulation code that
700 # we will deparse, then we don’t want to dump it. If it is the
701 # result of a declaration like sub f () { 42 } then we *do*
702 # want to dump it. The only way to distinguish these seems
703 # to be the SVs_PADTMP flag on the constant, which is admit-
704 # tedly a hack.
705 0 my $class = class(my $referent = $val->RV);
706 0 ▶ if ($class eq "CV") {
Branch: 2 branches
BranchTrueFalseTotal
if ($class eq 'CV') { } 0 0 0
elsif (not $class =~ /^(AV|HV|CV|FM|IO|SPECIAL)\z/ and $referent->FLAGS & 131072) { } 0 0 0
707 0 $self->todo($referent, 0);
708 ▶ } elsif (
Condition0%0/3
not $class =~ /^(AV|HV|CV|FM|IO|SPECIAL)\z/ and $referent->FLAGS & 131072
!ll&&!rl&&r
000
MC/DC0%0/2
not $class =~ /^(AV|HV|CV|FM|IO|SPECIAL)\z/ and $referent->FLAGS & 131072
not $class =~ /^(AV|HV|CV|FM|IO|SPECIAL)\z/ $referent->FLAGS & 131072
Truth table0%0/3
not(A) and B
A= not $class =~ /^(AV|HV|CV|FM|IO|SPECIAL)\z/B= $referent->FLAGS & 131072
ABresult
0X0
100
111
709 $class !~ /^(AV|HV|CV|FM|IO|SPECIAL)\z/
710 # A more robust way to write that would be this, but B does
711 # not provide the SVt_ constants:
712 # ($referent->FLAGS & B::SVTYPEMASK) < B::SVt_PVAV
713 and $referent->FLAGS & SVs_PADTMP
714 ) {
715 0 push @{$self->{'protos_todo'}}, [$pack . $key, $val];
716 }
717 } elsif ($flags & (SVf_POK|SVf_IOK)) {
718 # Just a prototype. As an ugly but fairly effective way
719 # to find out if it belongs here is to see if the AUTOLOAD
720 # (if any) for the stash was defined in one of our files.
721 0 my $A = $stash{"AUTOLOAD"};
722 0 ▶ if (defined ($A) && class($A) eq "GV" && defined($A->CV)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $A and B::Deparse::class($A) eq "GV" and defined $A->CV and B::Deparse::class($A->CV) eq "CV") 0 0 0
Condition0%0/9
defined $A and B::Deparse::class($A) eq "GV" and defined $A->CV and B::Deparse::class($A->CV) eq "CV"
!ll&&!rl&&r
000
defined $A and B::Deparse::class($A) eq "GV" and defined $A->CV
!ll&&!rl&&r
000
defined $A and B::Deparse::class($A) eq "GV"
!ll&&!rl&&r
000
MC/DC0%0/4
defined $A and B::Deparse::class($A) eq "GV" and defined $A->CV and B::Deparse::class($A->CV) eq "CV"
defined $A B::Deparse::class($A) eq "GV" defined $A->CV B::Deparse::class($A->CV) eq "CV"
Truth table0%0/5
A and B and C and D
A= defined $AB= B::Deparse::class($A) eq "GV"C= defined $A->CVD= B::Deparse::class($A->CV) eq "CV"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
723 && class($A->CV) eq "CV") {
724 0 my $AF = $A->FILE;
725 0 ▶ next unless $AF eq $0 || exists $self->{'files'}{$AF};
Branch: 1 branch
BranchTrueFalseTotal
unless $AF eq $0 or exists $self->{"files"}{$AF} 0 0 0
Condition0%0/3
$AF eq $0 or exists $self->{"files"}{$AF}
l!l&&r!l&&!r
000
MC/DC0%0/2
$AF eq $0 or exists $self->{"files"}{$AF}
$AF eq $0 exists $self->{"files"}{$AF}
Truth table0%0/3
A or B
A= $AF eq $0B= exists $self->{"files"}{$AF}
ABresult
1X1
011
000
726 }
727 0 ▶ push @{$self->{'protos_todo'}},
Branch: 1 branch
BranchTrueFalseTotal
$flags & 1024 ? : 0 0 0
728 [$pack . $key, $flags & SVf_POK ? $val->PV: undef];
729 } elsif (class($val) eq "GV") {
730 0 ▶ if (class(my $cv = $val->CV) ne "SPECIAL") {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class(my $cv = $val->CV) ne "SPECIAL") 0 0 0
731 0 ▶ next if $self->{'subs_done'}{$$val}++;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"subs_done"}{$$val}++ 0 0 0
732  
733 # Ignore imposters (aliases etc)
734 0 my $name = $cv->NAME_HEK;
735 0 ▶ if(defined $name) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) { } 0 0 0
736 # avoid using $cv->GV here because if the $val GV is
737 # an alias, CvGV() could upgrade the real stash entry
738 # from an RV to a GV
739 0 ▶ next unless $name eq $key;
Branch: 1 branch
BranchTrueFalseTotal
unless $name eq $key 0 0 0
740 0 ▶ next unless $$stashobj == ${$cv->STASH};
Branch: 1 branch
BranchTrueFalseTotal
unless $$stashobj == ${$cv->STASH;} 0 0 0
741 }
742 else {
743 0 ▶ next if $$val != ${$cv->GV};
Branch: 1 branch
BranchTrueFalseTotal
if $$val != ${$cv->GV;} 0 0 0
744 }
745  
746 0 $self->todo($cv, 0);
747 }
748 0 ▶ if (class(my $cv = $val->FORM) ne "SPECIAL") {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class(my $cv = $val->FORM) ne "SPECIAL") 0 0 0
749 0 ▶ next if $self->{'forms_done'}{$$val}++;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"forms_done"}{$$val}++ 0 0 0
750 0 ▶ next if $$val != ${$cv->GV}; # Ignore imposters
Branch: 1 branch
BranchTrueFalseTotal
if $$val != ${$cv->GV;} 0 0 0
751 0 $self->todo($cv, 1);
752 }
753 0 ▶ if (class($val->HV) ne "SPECIAL" && $key =~ /::$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($val->HV) ne "SPECIAL" and $key =~ /::$/) 0 0 0
Condition0%0/3
B::Deparse::class($val->HV) ne "SPECIAL" and $key =~ /::$/
!ll&&!rl&&r
000
MC/DC0%0/2
B::Deparse::class($val->HV) ne "SPECIAL" and $key =~ /::$/
B::Deparse::class($val->HV) ne "SPECIAL" $key =~ /::$/
Truth table0%0/3
A and B
A= B::Deparse::class($val->HV) ne "SPECIAL"B= $key =~ /::$/
ABresult
0X0
100
111
754 0 $self->stash_subs($pack . $key, $seen);
755 }
756 }
757 }
758 }
759  
760 sub print_protos {
761 0 ▶ my $self = shift;
Subroutine print_protos: not called CC=7 SCAR=40.3
Pod undocumented
762 0 my $ar;
763 my @ret;
764 0 foreach $ar (@{$self->{'protos_todo'}}) {
765 0 ▶ if (ref $ar->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ar->[1]) 0 0 0
766 # Only print a constant if it occurs in the same package as a
767 # dumped sub. This is not perfect, but a heuristic that will
768 # hopefully work most of the time. Ideally we would use
769 # CvFILE, but a constant stub has no CvFILE.
770 0 my $pack = ($ar->[0] =~ /(.*)::/)[0];
771 0 ▶ next if $pack and !$self->{packs}{$pack}
Branch: 1 branch
BranchTrueFalseTotal
if $pack and not $self->{"packs"}{$pack} 0 0 0
Condition0%0/3
$pack and not $self->{"packs"}{$pack}
!ll&&!rl&&r
000
MC/DC0%0/2
$pack and not $self->{"packs"}{$pack}
$pack not $self->{"packs"}{$pack}
Truth table0%0/3
A and not(B)
A= $packB= not $self->{"packs"}{$pack}
ABresult
0X0
100
111
772 }
773 0 ▶ my $body = defined $ar->[1]
Branch: 2 branches
BranchTrueFalseTotal
defined $ar->[1] ? : 0 0 0
ref $ar->[1] ? : 0 0 0
774 ? ref $ar->[1]
775 ? " () {\n " . $self->const($ar->[1]->RV,0) . ";\n}"
776 : " (". $ar->[1] . ");"
777 : ";";
778 0 push @ret, "sub " . $ar->[0] . "$body\n";
779 }
780 0 delete $self->{'protos_todo'};
781 0 return @ret;
782 }
783  
784 sub style_opts {
785 0 ▶ my $self = shift;
Subroutine style_opts: not called CC=6 SCAR=37.4
Pod undocumented
786 0 my $opts = shift;
787 0 my $opt;
788 0 ▶ while (length($opt = substr($opts, 0, 1))) {
Branch: 1 branch
BranchTrueFalseTotal
if (length($opt = substr($opts, 0, 1))) 0 0 0
789 0 ▶ if ($opt eq "C") {
Branch: 4 branches
BranchTrueFalseTotal
if ($opt eq 'C') { } 0 0 0
elsif ($opt eq 'i') { } 0 0 0
elsif ($opt eq 'T') { } 0 0 0
elsif ($opt eq 'v') { } 0 0 0
790 0 $self->{'cuddle'} = " ";
791 0 $opts = substr($opts, 1);
792 } elsif ($opt eq "i") {
793 0 $opts =~ s/^i(\d+)//;
794 0 $self->{'indent_size'} = $1;
795 } elsif ($opt eq "T") {
796 0 $self->{'use_tabs'} = 1;
797 0 $opts = substr($opts, 1);
798 } elsif ($opt eq "v") {
799 0 $opts =~ s/^v([^.]*)(.|$)//;
800 0 $self->{'ex_const'} = $1;
801 }
802 }
803 }
804  
805 sub new {
806 0 ▶ my $class = shift;
Subroutine new: not called CC=10 SCAR=47.0
Pod documented
807 0 my $self = bless {}, $class;
808 0 $self->{'cuddle'} = "\n";
809 0 $self->{'curcop'} = undef;
810 0 $self->{'curstash'} = "main";
811 0 $self->{'ex_const'} = "'???'";
812 0 $self->{'expand'} = 0;
813 0 $self->{'files'} = {};
814 0 $self->{'packs'} = {};
815 0 $self->{'indent_size'} = 4;
816 0 $self->{'linenums'} = 0;
817 0 $self->{'parens'} = 0;
818 0 $self->{'subs_todo'} = [];
819 0 $self->{'unquote'} = 0;
820 0 $self->{'use_dumper'} = 0;
821 0 $self->{'use_tabs'} = 0;
822  
823 0 $self->{'ambient_warnings'} = undef; # Assume no lexical warnings
824 0 $self->{'ambient_hints'} = 0;
825 0 $self->{'ambient_hinthash'} = undef;
826 0 $self->init();
827  
828 0 ▶ while (my $arg = shift @_) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $arg = shift @_) 0 0 0
829 0 ▶ if ($arg eq "-d") {
Branch: 8 branches
BranchTrueFalseTotal
if ($arg eq '-d') { } 0 0 0
elsif ($arg =~ /^-f(.*)/) { } 0 0 0
elsif ($arg eq '-l') { } 0 0 0
elsif ($arg eq '-p') { } 0 0 0
elsif ($arg eq '-P') { } 0 0 0
elsif ($arg eq '-q') { } 0 0 0
elsif (substr($arg, 0, 2) eq '-s') { } 0 0 0
elsif ($arg =~ /^-x(\d)$/) { } 0 0 0
830 0 $self->{'use_dumper'} = 1;
831 0 require Data::Dumper;
832 } elsif ($arg =~ /^-f(.*)/) {
833 0 $self->{'files'}{$1} = 1;
834 } elsif ($arg eq "-l") {
835 0 $self->{'linenums'} = 1;
836 } elsif ($arg eq "-p") {
837 0 $self->{'parens'} = 1;
838 } elsif ($arg eq "-P") {
839 0 $self->{'noproto'} = 1;
840 } elsif ($arg eq "-q") {
841 0 $self->{'unquote'} = 1;
842 } elsif (substr($arg, 0, 2) eq "-s") {
843 0 $self->style_opts(substr $arg, 2);
844 } elsif ($arg =~ /^-x(\d)$/) {
845 0 $self->{'expand'} = $1;
846 }
847 }
848 0 return $self;
849 }
850  
851  
852 # Initialise the contextual information, either from
853 # defaults provided with the ambient_pragmas method,
854 # or from perl's own defaults otherwise.
855 sub init {
856 0 ▶ my $self = shift;
Subroutine init: not called CC=1 SCAR=6.9
Pod undocumented
857  
858 0 $self->{'warnings'} = $self->{'ambient_warnings'};
859 0 $self->{'hints'} = $self->{'ambient_hints'};
860 0 $self->{'hinthash'} = $self->{'ambient_hinthash'};
861  
862 # also a convenient place to clear out subs_declared
863 0 delete $self->{'subs_declared'};
864 }
865  
866 sub compile {
867 0 ▶ my(@args) = @_;
Subroutine compile: not called CC=1 SCAR=6.9
Pod undocumented
868 return sub {
869 0 ▶ my $self = B::Deparse->new(@args);
Subroutine __ANON__: not called CC=30 SCAR=68.4
870 # First deparse command-line args
871 0 ▶ if (defined $^I) { # deparse -i
Branch: 1 branch
BranchTrueFalseTotal
if (defined $^I) 0 0 0
872 0 print q(BEGIN { $^I = ).perlstring($^I).qq(; }\n);
873 }
874 0 ▶ if ($^W) { # deparse -w
Branch: 1 branch
BranchTrueFalseTotal
if ($^W) 0 0 0
875 0 print qq(BEGIN { \$^W = $^W; }\n);
876 }
877 0 ▶ if ($/ ne "\n" or defined $O::savebackslash) { # deparse -l and -0
Branch: 1 branch
BranchTrueFalseTotal
if ($/ ne "\n" or defined $O::savebackslash) 0 0 0
Condition0%0/3
$/ ne "\n" or defined $O::savebackslash
l!l&&r!l&&!r
000
MC/DC0%0/2
$/ ne "\n" or defined $O::savebackslash
$/ ne "\n" defined $O::savebackslash
Truth table0%0/3
A or B
A= $/ ne "\n"B= defined $O::savebackslash
ABresult
1X1
011
000
878 0 ▶ my $fs = perlstring($/) || 'undef';
Condition0%0/2
perlstring($/) || 'undef'
l!l
00
MC/DC0%0/1
perlstring($/) || 'undef'
perlstring($/)
Truth table0%0/2
A
A= perlstring($/)
Aresult
11
00
879 0 ▶ my $bs = perlstring($O::savebackslash) || 'undef';
Condition0%0/2
perlstring($O::savebackslash) || 'undef'
l!l
00
MC/DC0%0/1
perlstring($O::savebackslash) || 'undef'
perlstring($O::savebackslash)
Truth table0%0/2
A
A= perlstring($O::savebackslash)
Aresult
11
00
880 0 print qq(BEGIN { \$/ = $fs; \$\\ = $bs; }\n);
881 }
882 0 ▶ my @BEGINs = B::begin_av->isa("B::AV") ? B::begin_av->ARRAY : ();
Branch: 1 branch
BranchTrueFalseTotal
B::begin_av()->isa('B::AV') ? : 0 0 0
883 0 ▶ my @UNITCHECKs = B::unitcheck_av->isa("B::AV")
Branch: 1 branch
BranchTrueFalseTotal
B::unitcheck_av()->isa('B::AV') ? : 0 0 0
884 ? B::unitcheck_av->ARRAY
885 : ();
886 0 ▶ my @CHECKs = B::check_av->isa("B::AV") ? B::check_av->ARRAY : ();
Branch: 1 branch
BranchTrueFalseTotal
B::check_av()->isa('B::AV') ? : 0 0 0
887 0 ▶ my @INITs = B::init_av->isa("B::AV") ? B::init_av->ARRAY : ();
Branch: 1 branch
BranchTrueFalseTotal
B::init_av()->isa('B::AV') ? : 0 0 0
888 0 ▶ my @ENDs = B::end_av->isa("B::AV") ? B::end_av->ARRAY : ();
Branch: 1 branch
BranchTrueFalseTotal
B::end_av()->isa('B::AV') ? : 0 0 0
889 0 my @names = qw(BEGIN UNITCHECK CHECK INIT END);
890 0 my @blocks = \(@BEGINs, @UNITCHECKs, @CHECKs, @INITs, @ENDs);
891 0 ▶ while (@names) {
Branch: 1 branch
BranchTrueFalseTotal
if (@names) 0 0 0
892 0 my ($name, $blocks) = (shift @names, shift @blocks);
893 0 for my $block (@$blocks) {
894 0 $self->todo($block, 0, $name);
895 }
896 }
897 0 $self->stash_subs();
898 local($SIG{"__DIE__"}) =
899 sub {
900 0 ▶ if ($self->{'curcop'}) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"curcop"}) 0 0 0
901 0 my $cop = $self->{'curcop'};
902 0 my($line, $file) = ($cop->line, $cop->file);
903 0 print STDERR "While deparsing $file near line $line,\n";
904 }
905 0 };
906 0 $self->{'curcv'} = main_cv;
907 0 $self->{'curcvlex'} = undef;
908 0 print $self->print_protos;
909 0 @{$self->{'subs_todo'}} =
910 0 sort {$a->[0] <=> $b->[0]} @{$self->{'subs_todo'}};
911 0 my $root = main_root;
912 0 local $B::overlay = {};
913 0 ▶ unless (null $root) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($root)) 0 0 0
914 0 $self->pad_subs($self->{'curcv'});
915 # Check for a stub-followed-by-ex-cop, resulting from a program
916 # consisting solely of sub declarations. For backward-compati-
917 # bility (and sane output) we don’t want to emit the stub.
918 # leave
919 # enter
920 # stub
921 # ex-nextstate (or ex-dbstate)
922 0 my $kid;
923 0 ▶ if ( $root->name eq 'leave'
Branch: 1 branch
BranchTrueFalseTotal
if ($root->name eq 'leave' and ($kid = $root->first)->name eq 'enter' and not null($kid = $kid->sibling) and $kid->name eq 'stub' || $kid->name eq 'null' && $kid->targ == 1 and not null($kid = $kid->sibling) and $kid->name eq 'null' and B::Deparse::class($kid) eq 'COP' and null($kid->sibling)) { } 0 0 0
Condition0%0/27
$root->name eq "leave" and ($kid = $root->first)->name eq "enter" and not null($kid = $kid->sibling) and $kid->name eq "stub" || $kid->name eq "null" && $kid->targ == 1 and not null($kid = $kid->sibling) and $kid->name eq "null" and B::Deparse::class($kid) eq "COP" and null($kid->sibling)
!ll&&!rl&&r
000
$root->name eq "leave" and ($kid = $root->first)->name eq "enter" and not null($kid = $kid->sibling) and $kid->name eq "stub" || $kid->name eq "null" && $kid->targ == 1 and not null($kid = $kid->sibling) and $kid->name eq "null" and B::Deparse::class($kid) eq "COP"
!ll&&!rl&&r
000
$root->name eq "leave" and ($kid = $root->first)->name eq "enter" and not null($kid = $kid->sibling) and $kid->name eq "stub" || $kid->name eq "null" && $kid->targ == 1 and not null($kid = $kid->sibling) and $kid->name eq "null"
!ll&&!rl&&r
000
$root->name eq "leave" and ($kid = $root->first)->name eq "enter" and not null($kid = $kid->sibling) and $kid->name eq "stub" || $kid->name eq "null" && $kid->targ == 1 and not null($kid = $kid->sibling)
!ll&&!rl&&r
000
$root->name eq "leave" and ($kid = $root->first)->name eq "enter" and not null($kid = $kid->sibling) and $kid->name eq "stub" || $kid->name eq "null" && $kid->targ == 1
!ll&&!rl&&r
000
$root->name eq "leave" and ($kid = $root->first)->name eq "enter" and not null($kid = $kid->sibling)
!ll&&!rl&&r
000
$root->name eq "leave" and ($kid = $root->first)->name eq "enter"
!ll&&!rl&&r
000
$kid->name eq "stub" or $kid->name eq "null" and $kid->targ == 1
l!l&&r!l&&!r
000
$kid->name eq "null" and $kid->targ == 1
!ll&&!rl&&r
000
MC/DC0%0/10
$root->name eq "leave" and ($kid = $root->first)->name eq "enter" and not null($kid = $kid->sibling) and $kid->name eq "stub" || $kid->name eq "null" && $kid->targ == 1 and not null($kid = $kid->sibling) and $kid->name eq "null" and B::Deparse::class($kid) eq "COP" and null($kid->sibling)
$root->name eq "leave" ($kid = $root->first)->name eq "enter" not null($kid = $kid->sibling) $kid->name eq "stub" $kid->name eq "null" $kid->targ == 1 not null($kid = $kid->sibling) $kid->name eq "null" B::Deparse::class($kid) eq "COP" null($kid->sibling)
Truth table0%0/15
A and B and not(C) and D or E and F and not(G) and H and I and J
A= $root->name eq "leave"B= ($kid = $root->first)->name eq "enter"C= not null($kid = $kid->sibling)D= $kid->name eq "stub"E= $kid->name eq "null"F= $kid->targ == 1G= not null($kid = $kid->sibling)H= $kid->name eq "null"I= B::Deparse::class($kid) eq "COP"J= null($kid->sibling)
ABCDEFGHIJresult
0XXXXXXXXX0
10XXXXXXXX0
110XXXXXXX0
11100XXXXX0
111010XXXX0
1111XX0XXX0
1110110XXX0
1111XX10XX0
11101110XX0
1111XX110X0
111011110X0
1111XX11100
11101111100
1111XX11111
11101111111
924 and ($kid = $root->first)->name eq 'enter'
925 and !null($kid = $kid->sibling) and ($kid->name eq 'stub'
926 or $kid->name eq 'null' and $kid->targ == OP_STUB)
927 and !null($kid = $kid->sibling) and $kid->name eq 'null'
928 and class($kid) eq 'COP' and null $kid->sibling )
929 {
930 # ignore
931 } else {
932 0 $self->pessimise($root, main_start);
933 0 print $self->indent($self->deparse_root($root)), "\n";
934 }
935 }
936 0 my @text;
937 0 ▶ while (scalar(@{$self->{'subs_todo'}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"subs_todo"};}) 0 0 0
938 0 push @text, $self->next_todo;
939 }
940 0 ▶ print $self->indent(join("", @text)), "\n" if @text;
Branch: 1 branch
BranchTrueFalseTotal
if @text 0 0 0
941  
942 # Print __DATA__ section, if necessary
943 no strict 'refs';
944 my $laststash = defined $self->{'curcop'}
945 0 ▶ ? $self->{'curcop'}->stash->NAME : $self->{'curstash'};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'curcop'} ? : 0 0 0
946 0 ▶ if (defined *{$laststash."::DATA"}{IO}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined *{$laststash . '::DATA';}{"IO"}) 0 0 0
947 print $self->keyword("package") . " $laststash;\n"
948 0 ▶ unless $laststash eq $self->{'curstash'};
Branch: 1 branch
BranchTrueFalseTotal
unless $laststash eq $self->{"curstash"} 0 0 0
949 0 print $self->keyword("__DATA__") . "\n";
950 0 print readline(*{$laststash."::DATA"});
951 }
952 }
953 0 }
954  
955 sub coderef2text {
956 0 ▶ my $self = shift;
Subroutine coderef2text: not called CC=2 SCAR=17.9
Pod documented
957 0 my $sub = shift;
958 0 ▶ croak "Usage: ->coderef2text(CODEREF)" unless UNIVERSAL::isa($sub, "CODE");
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($sub, "CODE") 0 0 0
959  
960 0 $self->init();
961 0 local $self->{in_coderef2text} = 1;
962 0 return $self->indent($self->deparse_sub(svref_2object($sub)));
963 }
964  
965 my %strict_bits = do {
966 local $^H;
967 map +($_ => strict::bits($_)), qw/refs subs vars/
968 };
969  
970 sub ambient_pragmas {
971 0 ▶ my $self = shift;
Subroutine ambient_pragmas: not called CC=24 SCAR=64.0
Pod documented
972 0 my ($hint_bits, $warning_bits, $hinthash) = (0);
973  
974 0 ▶ while (@_ > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
975 0 my $name = shift();
976 0 my $val = shift();
977  
978 0 ▶ if ($name eq 'strict') {
Branch: 7 branches
BranchTrueFalseTotal
if ($name eq 'strict') { } 0 0 0
elsif ($name eq 'integer' or $name eq 'bytes' or $name eq 'utf8') { } 0 0 0
elsif ($name eq 're') { } 0 0 0
elsif ($name eq 'warnings') { } 0 0 0
elsif ($name eq 'warning_bits') { } 0 0 0
elsif ($name eq 'hint_bits') { } 0 0 0
elsif ($name eq '%^H') { } 0 0 0
979 0 require strict;
980  
981 0 ▶ if ($val eq 'none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($val eq "none") 0 0 0
982 0 $hint_bits &= $strict_bits{$_} for qw/refs subs vars/;
983 0 next();
984 }
985  
986 0 my @names;
987 0 ▶ if ($val eq "all") {
Branch: 2 branches
BranchTrueFalseTotal
if ($val eq 'all') { } 0 0 0
elsif (ref $val) { } 0 0 0
988 0 @names = qw/refs subs vars/;
989 }
990 elsif (ref $val) {
991 0 @names = @$val;
992 }
993 else {
994 0 @names = split' ', $val;
995 }
996 0 $hint_bits |= $strict_bits{$_} for @names;
997 }
998  
999 ▶ elsif ($name eq 'integer'
Condition0%0/6
$name eq "integer" or $name eq "bytes" or $name eq "utf8"
l!l&&r!l&&!r
000
$name eq "integer" or $name eq "bytes"
l!l&&r!l&&!r
000
MC/DC0%0/3
$name eq "integer" or $name eq "bytes" or $name eq "utf8"
$name eq "integer" $name eq "bytes" $name eq "utf8"
Truth table0%0/4
A or B or C
A= $name eq "integer"B= $name eq "bytes"C= $name eq "utf8"
ABCresult
1XX1
01X1
0011
0000
1000 || $name eq 'bytes'
1001 || $name eq 'utf8') {
1002 0 require "$name.pm";
1003 0 ▶ if ($val) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val) { } 0 0 0
1004 0 $hint_bits |= ${$::{"${name}::"}{"hint_bits"}};
1005 }
1006 else {
1007 0 $hint_bits &= ~${$::{"${name}::"}{"hint_bits"}};
1008 }
1009 }
1010  
1011 elsif ($name eq 're') {
1012 0 require re;
1013 0 ▶ if ($val eq 'none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($val eq "none") 0 0 0
1014 0 $hint_bits &= ~re::bits(qw/taint eval/);
1015 0 next();
1016 }
1017  
1018 0 my @names;
1019 0 ▶ if ($val eq 'all') {
Branch: 2 branches
BranchTrueFalseTotal
if ($val eq 'all') { } 0 0 0
elsif (ref $val) { } 0 0 0
1020 0 @names = qw/taint eval/;
1021 }
1022 elsif (ref $val) {
1023 0 @names = @$val;
1024 }
1025 else {
1026 0 @names = split' ',$val;
1027 }
1028 0 $hint_bits |= re::bits(@names);
1029 }
1030  
1031 elsif ($name eq 'warnings') {
1032 0 ▶ if ($val eq 'none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($val eq "none") 0 0 0
1033 0 $warning_bits = $warnings::NONE;
1034 0 next();
1035 }
1036  
1037 0 my @names;
1038 0 ▶ if (ref $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val) { } 0 0 0
1039 0 @names = @$val;
1040 }
1041 else {
1042 0 @names = split/\s+/, $val;
1043 }
1044  
1045 0 ▶ $warning_bits = $warnings::NONE if !defined ($warning_bits);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $warning_bits 0 0 0
1046 0 $warning_bits |= warnings::bits(@names);
1047 }
1048  
1049 elsif ($name eq 'warning_bits') {
1050 0 $warning_bits = $val;
1051 }
1052  
1053 elsif ($name eq 'hint_bits') {
1054 0 $hint_bits = $val;
1055 }
1056  
1057 elsif ($name eq '%^H') {
1058 0 $hinthash = $val;
1059 }
1060  
1061 else {
1062 0 croak "Unknown pragma type: $name";
1063 }
1064 }
1065 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
1066 0 croak "The ambient_pragmas method expects an even number of args";
1067 }
1068  
1069 0 $self->{'ambient_warnings'} = $warning_bits;
1070 0 $self->{'ambient_hints'} = $hint_bits;
1071 0 $self->{'ambient_hinthash'} = $hinthash;
1072 }
1073  
1074 sub ambient_pragmas_from_caller {
1075 0 ▶ my $self = shift;
Subroutine ambient_pragmas_from_caller: not called CC=1 SCAR=6.9
Pod documented
1076 0 my ($hint_bits, $warning_bits, $hinthash) = (caller(0))[8, 9, 10];
1077 0 $self->ambient_pragmas(
1078 hint_bits => $hint_bits,
1079 warning_bits => $warning_bits,
1080 '%^H' => $hinthash,
1081 );
1082 }
1083  
1084 # This method is the inner loop, so try to keep it simple
1085 sub deparse {
1086 0 ▶ my $self = shift;
Subroutine deparse: not called CC=3 SCAR=24.8
Pod undocumented
1087 0 my($op, $cx) = @_;
1088  
1089 0 ▶ Carp::confess("Null op in deparse") if !defined($op)
Branch: 1 branch
BranchTrueFalseTotal
if not defined $op or B::Deparse::class($op) eq "NULL" 0 0 0
Condition0%0/3
not defined $op or B::Deparse::class($op) eq "NULL"
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $op or B::Deparse::class($op) eq "NULL"
not defined $op B::Deparse::class($op) eq "NULL"
Truth table0%0/3
not(A) or B
A= not defined $opB= B::Deparse::class($op) eq "NULL"
ABresult
1X1
011
000
1090 || class($op) eq "NULL";
1091 0 my $meth = "pp_" . $op->name;
1092 0 return $self->$meth($op, $cx);
1093 }
1094  
1095 sub indent {
1096 0 ▶ my $self = shift;
Subroutine indent: not called CC=8 SCAR=42.8
Pod undocumented
1097 0 my $txt = shift;
1098 # \cK also swallows a preceding line break when followed by a
1099 # semicolon.
1100 0 $txt =~ s/\n\cK;//g;
1101 0 my @lines = split(/\n/, $txt);
1102 0 my $leader = "";
1103 0 my $level = 0;
1104 0 my $line;
1105 0 for $line (@lines) {
1106 0 my $cmd = substr($line, 0, 1);
1107 0 ▶ if ($cmd eq "\t" or $cmd eq "\b") {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "\t" or $cmd eq "\b") 0 0 0
Condition0%0/3
$cmd eq "\t" or $cmd eq "\b"
l!l&&r!l&&!r
000
MC/DC0%0/2
$cmd eq "\t" or $cmd eq "\b"
$cmd eq "\t" $cmd eq "\b"
Truth table0%0/3
A or B
A= $cmd eq "\t"B= $cmd eq "\b"
ABresult
1X1
011
000
1108 0 ▶ $level += ($cmd eq "\t" ? 1 : -1) * $self->{'indent_size'};
Branch: 1 branch
BranchTrueFalseTotal
$cmd eq "\t" ? : 0 0 0
1109 0 ▶ if ($self->{'use_tabs'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'use_tabs'}) { } 0 0 0
1110 0 $leader = "\t" x ($level / 8) . " " x ($level % 8);
1111 } else {
1112 0 $leader = " " x $level;
1113 }
1114 0 $line = substr($line, 1);
1115 }
1116 0 ▶ if (index($line, "\f") > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($line, "\f") > 0) 0 0 0
1117 0 $line =~ s/\f/\n/;
1118 }
1119 0 ▶ if (substr($line, 0, 1) eq "\f") {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($line, 0, 1) eq "\f") { } 0 0 0
1120 0 $line = substr($line, 1); # no indent
1121 } else {
1122 0 $line = $leader . $line;
1123 }
1124 0 $line =~ s/\cK;?//g;
1125 }
1126 0 return join("\n", @lines);
1127 }
1128  
1129 sub pad_subs {
1130 0 ▶ my ($self, $cv) = @_;
Subroutine pad_subs: not called CC=20 SCAR=60.4
Pod undocumented
1131 0 my $padlist = $cv->PADLIST;
1132 0 my @names = $padlist->ARRAYelt(0)->ARRAY;
1133 0 my @values = $padlist->ARRAYelt(1)->ARRAY;
1134 0 my @todo;
1135 PADENTRY:
1136 0 for my $ix (0.. $#names) { for $_ ($names[$ix]) {
1137 0 ▶ next if class($_) eq "SPECIAL";
Branch: 1 branch
BranchTrueFalseTotal
if B::Deparse::class($_) eq "SPECIAL" 0 0 0
1138 0 my $name = $_->PVX;
1139 0 ▶ if (defined $name && $name =~ /^&./) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name and $name =~ /^&./) 0 0 0
Condition0%0/3
defined $name and $name =~ /^&./
!ll&&!rl&&r
000
MC/DC0%0/2
defined $name and $name =~ /^&./
defined $name $name =~ /^&./
Truth table0%0/3
A and B
A= defined $nameB= $name =~ /^&./
ABresult
0X0
100
111
1140 0 my $low = $_->COP_SEQ_RANGE_LOW;
1141 0 my $flags = $_->FLAGS;
1142 0 my $outer = $flags & PADNAMEf_OUTER;
1143 0 ▶ if ($flags & PADNAMEf_OUR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flags & 16) 0 0 0
1144 0 ▶ push @todo, [$low, undef, 0, $_]
Branch: 1 branch
BranchTrueFalseTotal
unless $outer 0 0 0
1145 # [seq, no cv, not format, padname]
1146 unless $outer;
1147 0 next;
1148 }
1149 0 ▶ my $protocv = $flags & SVpad_STATE
Branch: 1 branch
BranchTrueFalseTotal
$flags & 2 ? : 0 0 0
1150 ? $values[$ix]
1151 : $_->PROTOCV;
1152 0 ▶ if (class ($protocv) ne 'CV') {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($protocv) ne "CV") 0 0 0
1153 0 my $flags = $flags;
1154 0 my $cv = $cv;
1155 0 my $name = $_;
1156 0 ▶ while ($flags & PADNAMEf_OUTER && class ($protocv) ne 'CV')
Branch: 1 branch
BranchTrueFalseTotal
if ($flags & 1 and B::Deparse::class($protocv) ne "CV") 0 0 0
Condition0%0/3
$flags & 1 and B::Deparse::class($protocv) ne "CV"
!ll&&!rl&&r
000
MC/DC0%0/2
$flags & 1 and B::Deparse::class($protocv) ne "CV"
$flags & 1 B::Deparse::class($protocv) ne "CV"
Truth table0%0/3
A and B
A= $flags & 1B= B::Deparse::class($protocv) ne "CV"
ABresult
0X0
100
111
1157 {
1158 0 $cv = $cv->OUTSIDE;
1159 0 ▶ next PADENTRY if class($cv) eq 'SPECIAL'; # XXX freed?
Branch: 1 branch
BranchTrueFalseTotal
if B::Deparse::class($cv) eq "SPECIAL" 0 0 0
1160 0 my $padlist = $cv->PADLIST;
1161 0 my $ix = $name->PARENT_PAD_INDEX;
1162 0 $name = $padlist->NAMES->ARRAYelt($ix);
1163 0 $flags = $name->FLAGS;
1164 0 ▶ $protocv = $flags & SVpad_STATE
Branch: 1 branch
BranchTrueFalseTotal
$flags & 2 ? : 0 0 0
1165 ? $padlist->ARRAYelt(1)->ARRAYelt($ix)
1166 : $name->PROTOCV;
1167 }
1168 }
1169 0 ▶ my $defined_in_this_sub = ${$protocv->OUTSIDE} == $$cv || do {
Condition0%0/3
${$protocv->OUTSIDE;} == $$cv || do { my $other = $protocv->PADLIST; $$other and $other->outid == $padlist->id }
l!l&&r!l&&!r
000
MC/DC0%0/2
${$protocv->OUTSIDE;} == $$cv || do { my $other = $protocv->PADLIST; $$other and $other->outid == $padlist->id }
${$protocv->OUTSIDE;} == $$cv do { my $other = $protocv->PADLIST; $$other and $other->outid == $padlist->id }
Truth table0%0/3
A || B
A= ${$protocv->OUTSIDE;} == $$cvB= do { my $other = $protocv->PADLIST; $$other and $other->outid == $padlist->id }
ABresult
1X1
011
000
1170 0 my $other = $protocv->PADLIST;
1171 0 ▶ $$other && $other->outid == $padlist->id;
Condition0%0/3
$$other && $other->outid == $padlist->id
!ll&&!rl&&r
000
MC/DC0%0/2
$$other && $other->outid == $padlist->id
$$other $other->outid == $padlist->id
Truth table0%0/3
A && B
A= $$otherB= $other->outid == $padlist->id
ABresult
0X0
100
111
1172 };
1173 0 ▶ if ($flags & PADNAMEf_OUTER) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flags & 1) 0 0 0
1174 0 ▶ next unless $defined_in_this_sub;
Branch: 1 branch
BranchTrueFalseTotal
unless $defined_in_this_sub 0 0 0
1175 0 push @todo, [$protocv->OUTSIDE_SEQ, $protocv, 0, $_];
1176 0 next;
1177 }
1178 0 my $outseq = $protocv->OUTSIDE_SEQ;
1179 0 ▶ if ($outseq <= $low) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outseq <= $low) { } 0 0 0
1180 # defined before its name is visible, so it’s gotta be
1181 # declared and defined at once: my sub foo { ... }
1182 0 push @todo, [$low, $protocv, 0, $_];
1183 }
1184 else {
1185 # declared and defined separately: my sub f; sub f { ... }
1186 0 push @todo, [$low, undef, 0, $_];
1187 0 ▶ push @todo, [$outseq, $protocv, 0, $_]
Branch: 1 branch
BranchTrueFalseTotal
if $defined_in_this_sub 0 0 0
1188 if $defined_in_this_sub;
1189 }
1190 }
1191 }}
1192 0 @{$self->{'subs_todo'}} =
1193 0 sort {$a->[0] <=> $b->[0]} @{$self->{'subs_todo'}}, @todo
1194 }
1195  
1196  
1197 # deparse_multiparam(): deparse, if possible, a sequence of ops into a
1198 # subroutine signature. If possible, returns either:
1199 # (if $use_feature_sig is true): a string representing the signature syntax,
1200 # minus the surrounding parentheses.
1201 # (if $use_feature_sig is false): a string of perl code that approximates
1202 # the behaviour of the signature.
1203  
1204 sub deparse_multiparam {
1205 0 ▶ my ($self, $topop, $cv, $use_feature_sig) = @_;
Subroutine deparse_multiparam: not called CC=44 SCAR=75.9
Pod undocumented
1206  
1207 0 $topop = $topop->first;
1208 0 ▶ return unless $$topop and $topop->name eq 'lineseq';
Branch: 1 branch
BranchTrueFalseTotal
unless $$topop and $topop->name eq "lineseq" 0 0 0
Condition0%0/3
$$topop and $topop->name eq "lineseq"
!ll&&!rl&&r
000
MC/DC0%0/2
$$topop and $topop->name eq "lineseq"
$$topop $topop->name eq "lineseq"
Truth table0%0/3
A and B
A= $$topopB= $topop->name eq "lineseq"
ABresult
0X0
100
111
1209  
1210 # last op should be nextstate
1211 0 my $last = $topop->last;
1212 0 ▶ return unless $$last
Branch: 1 branch
BranchTrueFalseTotal
unless $$last and _op_is_or_was($last, 202) || _op_is_or_was($last, 203) 0 0 0
Condition0%0/6
$$last and _op_is_or_was($last, 202) || _op_is_or_was($last, 203)
!ll&&!rl&&r
000
_op_is_or_was($last, 202) or _op_is_or_was($last, 203)
l!l&&r!l&&!r
000
MC/DC0%0/3
$$last and _op_is_or_was($last, 202) || _op_is_or_was($last, 203)
$$last _op_is_or_was($last, 202) _op_is_or_was($last, 203)
Truth table0%0/4
A and B or C
A= $$lastB= _op_is_or_was($last, 202)C= _op_is_or_was($last, 203)
ABCresult
0XX0
1000
11X1
1011
1213 and ( _op_is_or_was($last, OP_NEXTSTATE)
1214 or _op_is_or_was($last, OP_DBSTATE));
1215  
1216 # first OP_NEXTSTATE
1217  
1218 0 my $o = $topop->first;
1219 0 ▶ return unless $$o;
Branch: 1 branch
BranchTrueFalseTotal
unless $$o 0 0 0
1220 0 ▶ return if $o->label;
Branch: 1 branch
BranchTrueFalseTotal
if $o->label 0 0 0
1221  
1222 # OP_MULTIPARAM
1223  
1224 0 $o = $o->sibling;
1225 0 ▶ return unless $$o and $o->name eq 'multiparam';
Branch: 1 branch
BranchTrueFalseTotal
unless $$o and $o->name eq "multiparam" 0 0 0
Condition0%0/3
$$o and $o->name eq "multiparam"
!ll&&!rl&&r
000
MC/DC0%0/2
$$o and $o->name eq "multiparam"
$$o $o->name eq "multiparam"
Truth table0%0/3
A and B
A= $$oB= $o->name eq "multiparam"
ABresult
0X0
100
111
1226  
1227 0 my ($min_args, $max_args, $slurpy, @rest) = $o->aux_list($cv);
1228 0 my $nparams = $max_args;
1229 0 my @param_padix = splice @rest, 0, $nparams, ();
1230 0 my ($slurpy_padix) = @rest;
1231  
1232 0 ▶ my @param_padname = map { $_ ? $self->padname($_) : '$' } @param_padix;
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 0 0 0
1233 0 ▶ my ($slurpy_padname) = map { $_ ? $self->padname($_) : $slurpy } $slurpy_padix;
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 0 0 0
1234  
1235 0 my %parami_for_padix;
1236  
1237 # Initial scalars
1238 0 foreach my $parami ( 0 .. $max_args-1 ) {
1239 0 my $padix = $param_padix[$parami];
1240 0 $parami_for_padix{$padix} = $parami;
1241 }
1242  
1243 0 my @param_defmode;
1244 my @param_defexpr;
1245  
1246 0 $o = $o->sibling;
1247 0 ▶ for (; $o and !null $o; $o = $o->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o and not null($o)) 0 0 0
Condition0%0/3
$o and not null($o)
!ll&&!rl&&r
000
MC/DC0%0/2
$o and not null($o)
$o not null($o)
Truth table0%0/3
A and not(B)
A= $oB= not null($o)
ABresult
0X0
100
111
1248 # Look for OP_NULL[OP_PARAMTEST[OP_PARAMSTORE]]
1249 0 my $ofirst;
1250 0 ▶ if ($o->name eq 'null' and $o->flags & OPf_KIDS and
Branch: 1 branch
BranchTrueFalseTotal
if ($o->name eq "null" and $o->flags & 4 and ($ofirst = $o->first)->name eq "paramtest" and $ofirst->first->name eq "paramstore") 0 0 0
Condition0%0/9
$o->name eq "null" and $o->flags & 4 and ($ofirst = $o->first)->name eq "paramtest" and $ofirst->first->name eq "paramstore"
!ll&&!rl&&r
000
$o->name eq "null" and $o->flags & 4 and ($ofirst = $o->first)->name eq "paramtest"
!ll&&!rl&&r
000
$o->name eq "null" and $o->flags & 4
!ll&&!rl&&r
000
MC/DC0%0/4
$o->name eq "null" and $o->flags & 4 and ($ofirst = $o->first)->name eq "paramtest" and $ofirst->first->name eq "paramstore"
$o->name eq "null" $o->flags & 4 ($ofirst = $o->first)->name eq "paramtest" $ofirst->first->name eq "paramstore"
Truth table0%0/5
A and B and C and D
A= $o->name eq "null"B= $o->flags & 4C= ($ofirst = $o->first)->name eq "paramtest"D= $ofirst->first->name eq "paramstore"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1251 ($ofirst = $o->first)->name eq 'paramtest' and
1252 $ofirst->first->name eq 'paramstore') {
1253 # A defaulting expression
1254  
1255 0 my $parami = $parami_for_padix{$ofirst->targ};
1256  
1257 0 my $defmode = "=";
1258 0 ▶ $defmode = "//=" if $ofirst->private == OPpPARAM_IF_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if $ofirst->private == 128 0 0 0
1259 0 ▶ $defmode = "||=" if $ofirst->private == OPpPARAM_IF_FALSE;
Branch: 1 branch
BranchTrueFalseTotal
if $ofirst->private == 64 0 0 0
1260 0 $param_defmode[$parami] = $defmode;
1261  
1262 0 my $defop = $ofirst->first->first;
1263 0 ▶ if ($defop->name ne "stub") {
Branch: 1 branch
BranchTrueFalseTotal
if ($defop->name ne "stub") 0 0 0
1264 0 my $expr = $self->deparse($defop, 7);
1265 0 ▶ $expr = "($expr)" if $defop->flags & OPf_PARENS;
Branch: 1 branch
BranchTrueFalseTotal
if $defop->flags & 8 0 0 0
1266  
1267 0 $param_defexpr[$parami] = $expr;
1268 }
1269 }
1270 }
1271  
1272 0 ▶ if ($cv->CvFLAGS & CVf_IsMETHOD) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->CvFLAGS & 1048576) 0 0 0
1273 # Remove the implied `$self` argument
1274 0 ▶ warn "Expected first signature argument to be named \$self"
Branch: 1 branch
BranchTrueFalseTotal
unless @param_padname and $param_padname[0] eq "\$self" 0 0 0
Condition0%0/3
@param_padname and $param_padname[0] eq "\$self"
!ll&&!rl&&r
000
MC/DC0%0/2
@param_padname and $param_padname[0] eq "\$self"
@param_padname $param_padname[0] eq "\$self"
Truth table0%0/3
A and B
A= @param_padnameB= $param_padname[0] eq "\$self"
ABresult
0X0
100
111
1275 unless @param_padname and $param_padname[0] eq '$self';
1276  
1277 0 shift @param_padix;
1278 0 shift @param_padname;
1279 0 shift @param_defmode;
1280 0 shift @param_defexpr;
1281 }
1282  
1283 0 ▶ if ($use_feature_sig) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_feature_sig) 0 0 0
1284 0 my @sig;
1285  
1286 0 foreach my $parami ( 0 .. $#param_padix ) {
1287 0 my $param_sig = $param_padname[$parami];
1288 0 ▶ if ($param_defmode[$parami]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param_defmode[$parami]) 0 0 0
1289 0 ▶ length $param_sig > 1 ?
Branch: 1 branch
BranchTrueFalseTotal
length $param_sig > 1 ? : 0 0 0
1290 ( $param_sig .= ' ' ) :
1291 ( $param_sig = '$' ); # intentionally no trailing space
1292  
1293 0 $param_sig .= $param_defmode[$parami];
1294  
1295 0 my $defexpr = $param_defexpr[$parami];
1296 0 ▶ $param_sig .= " $defexpr" if defined $defexpr;
Branch: 1 branch
BranchTrueFalseTotal
if defined $defexpr 0 0 0
1297 }
1298  
1299 0 push @sig, $param_sig;
1300 }
1301  
1302 0 ▶ push @sig, $slurpy_padname if $slurpy;
Branch: 1 branch
BranchTrueFalseTotal
if $slurpy 0 0 0
1303  
1304 0 return join(", ", @sig);
1305 }
1306  
1307 # Approximate the behaviour using plain perl code
1308 0 my $code = "";
1309  
1310 0 ▶ $code .= <<"EOF" if !$slurpy_padix;
Branch: 1 branch
BranchTrueFalseTotal
unless $slurpy_padix 0 0 0
1311 die sprintf("Too many arguments for subroutine at %s line %d.\\n", (caller)[1, 2]) unless \@_ <= $nparams;
1312 EOF
1313  
1314 0 ▶ $code .= <<"EOF" if $min_args > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $min_args > 0 0 0 0
1315 die sprintf("Too few arguments for subroutine at %s line %d.\\n", (caller)[1, 2]) unless \@_ >= $min_args;
1316 EOF
1317  
1318 0 ▶ $code .= <<EOF if $slurpy and $slurpy eq '%';
Branch: 1 branch
BranchTrueFalseTotal
if $slurpy and $slurpy eq "%" 0 0 0
Condition0%0/3
$slurpy and $slurpy eq "%"
!ll&&!rl&&r
000
MC/DC0%0/2
$slurpy and $slurpy eq "%"
$slurpy $slurpy eq "%"
Truth table0%0/3
A and B
A= $slurpyB= $slurpy eq "%"
ABresult
0X0
100
111
1319 die sprintf("Odd name/value argument for subroutine at %s line %d.\\n", (caller)[1, 2]) if \@_ > $nparams && ((\@_ - $nparams) & 1);
1320 EOF
1321  
1322 0 foreach my $parami ( 0 .. $#param_padix ) {
1323 0 my $argix = $parami;
1324  
1325 0 my $stmt = "my $param_padname[$parami] = ";
1326  
1327 0 ▶ if (my $defmode = $param_defmode[$parami]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $defmode = $param_defmode[$parami]) { } 0 0 0
1328 0 my $defexpr = $param_defexpr[$parami];
1329 # Optional parameter
1330  
1331 0 ▶ if (length $param_padname[$parami] > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $param_padname[$parami] > 1) { } 0 0 0
1332 # Named optional param
1333 0 ▶ if ($defmode eq "=") {
Branch: 1 branch
BranchTrueFalseTotal
if ($defmode eq '=') { } 0 0 0
1334 0 $stmt .= "\@_ > $argix ? \$_[$argix] : $defexpr";
1335 }
1336 else {
1337 0 $defmode =~ s/=\z//;
1338 0 $stmt .= "\$_[$argix] $defmode $defexpr";
1339 }
1340 }
1341 else {
1342 # Anonymous optional param. This does not create or assign a
1343 # variable but we still evaluate the defaulting expression for
1344 # side-effects
1345 0 ▶ my $cond = ( $defmode eq "//=" ) ? "defined \$_[$argix]" :
Branch: 2 branches
BranchTrueFalseTotal
$defmode eq '//=' ? : 0 0 0
$defmode eq '||=' ? : 0 0 0
1346 ( $defmode eq "||=" ) ? "\$_[$argix]" :
1347 "\@_ > $argix";
1348 0 $stmt = "$defexpr unless $cond";
1349 }
1350 }
1351 else {
1352 # Mandatory parameter
1353  
1354 # Anonymous mandatory params can be entirely ignored. Their pad
1355 # index will be zero.
1356 0 ▶ $param_padix[$parami] or next;
Branch: 1 branch
BranchTrueFalseTotal
$param_padix[$parami] or next 0 0 0
1357  
1358 0 $stmt .= "\$_[$argix]";
1359 }
1360  
1361 0 $code .= "$stmt;\n";
1362 }
1363  
1364 0 ▶ if ($slurpy) {
Branch: 1 branch
BranchTrueFalseTotal
if ($slurpy) 0 0 0
1365 0 $code .= "my $slurpy_padname = \@_[$nparams..\$#_];\n";
1366 }
1367  
1368 0 $code =~ s/;\n\z//;
1369 0 return $code;
1370 }
1371  
1372 # deparse_argops(): deparse, if possible, a sequence of argcheck + argelem
1373 # ops into a subroutine signature. If successful, return the first op
1374 # following the signature ops plus the signature string; else return the
1375 # empty list.
1376 #
1377 # Normally a bunch of argelem ops will have been generated by the
1378 # signature parsing, but it's possible that ops have been added manually
1379 # or altered. In this case we return "()" and fall back to general
1380 # deparsing of the individual sigelems as 'my $x = $_[N]' etc.
1381 #
1382 # We're only called if the top is an ex-argcheck, which is a placeholder
1383 # indicating a signature subtree.
1384 #
1385 # Return a signature string, or an empty list if no deparseable as a
1386 # signature
1387  
1388 sub deparse_argops {
1389 0 ▶ my ($self, $topop, $cv) = @_;
Subroutine deparse_argops: not called CC=47 SCAR=77.2
Pod undocumented
1390  
1391 0 my @sig;
1392  
1393  
1394 0 $topop = $topop->first;
1395 0 ▶ return unless $$topop and $topop->name eq 'lineseq';
Branch: 1 branch
BranchTrueFalseTotal
unless $$topop and $topop->name eq "lineseq" 0 0 0
Condition0%0/3
$$topop and $topop->name eq "lineseq"
!ll&&!rl&&r
000
MC/DC0%0/2
$$topop and $topop->name eq "lineseq"
$$topop $topop->name eq "lineseq"
Truth table0%0/3
A and B
A= $$topopB= $topop->name eq "lineseq"
ABresult
0X0
100
111
1396  
1397  
1398 # last op should be nextstate
1399 0 my $last = $topop->last;
1400 0 ▶ return unless $$last
Branch: 1 branch
BranchTrueFalseTotal
unless $$last and _op_is_or_was($last, 202) || _op_is_or_was($last, 203) 0 0 0
Condition0%0/6
$$last and _op_is_or_was($last, 202) || _op_is_or_was($last, 203)
!ll&&!rl&&r
000
_op_is_or_was($last, 202) or _op_is_or_was($last, 203)
l!l&&r!l&&!r
000
MC/DC0%0/3
$$last and _op_is_or_was($last, 202) || _op_is_or_was($last, 203)
$$last _op_is_or_was($last, 202) _op_is_or_was($last, 203)
Truth table0%0/4
A and B or C
A= $$lastB= _op_is_or_was($last, 202)C= _op_is_or_was($last, 203)
ABCresult
0XX0
1000
11X1
1011
1401 and ( _op_is_or_was($last, OP_NEXTSTATE)
1402 or _op_is_or_was($last, OP_DBSTATE));
1403  
1404 # first OP_NEXTSTATE
1405  
1406 0 my $o = $topop->first;
1407 0 ▶ return unless $$o;
Branch: 1 branch
BranchTrueFalseTotal
unless $$o 0 0 0
1408 0 ▶ return if $o->label;
Branch: 1 branch
BranchTrueFalseTotal
if $o->label 0 0 0
1409  
1410 # OP_ARGCHECK
1411  
1412 0 $o = $o->sibling;
1413 0 ▶ return unless $$o and $o->name eq 'argcheck';
Branch: 1 branch
BranchTrueFalseTotal
unless $$o and $o->name eq "argcheck" 0 0 0
Condition0%0/3
$$o and $o->name eq "argcheck"
!ll&&!rl&&r
000
MC/DC0%0/2
$$o and $o->name eq "argcheck"
$$o $o->name eq "argcheck"
Truth table0%0/3
A and B
A= $$oB= $o->name eq "argcheck"
ABresult
0X0
100
111
1414  
1415 0 my ($params, $opt_params, $slurpy) = $o->aux_list($cv);
1416 0 my $mandatory = $params - $opt_params;
1417 0 my $seen_slurpy = 0;
1418 0 my $last_ix = -1;
1419  
1420 # keep looking for valid nextstate + argelem pairs, terminated
1421 # by a final nextstate
1422  
1423 0 while (1) {
1424 0 $o = $o->sibling;
1425 0 ▶ return unless $$o;
Branch: 1 branch
BranchTrueFalseTotal
unless $$o 0 0 0
1426  
1427 # skip trailing nextstate
1428 0 ▶ last if $$o == $$last;
Branch: 1 branch
BranchTrueFalseTotal
if $$o == $$last 0 0 0
1429  
1430 0 ▶ next if $cv->CvFLAGS & CVf_IsMETHOD and $o->name eq "methstart";
Branch: 1 branch
BranchTrueFalseTotal
if $cv->CvFLAGS & 1048576 and $o->name eq "methstart" 0 0 0
Condition0%0/3
$cv->CvFLAGS & 1048576 and $o->name eq "methstart"
!ll&&!rl&&r
000
MC/DC0%0/2
$cv->CvFLAGS & 1048576 and $o->name eq "methstart"
$cv->CvFLAGS & 1048576 $o->name eq "methstart"
Truth table0%0/3
A and B
A= $cv->CvFLAGS & 1048576B= $o->name eq "methstart"
ABresult
0X0
100
111
1431  
1432 # OP_NEXTSTATE
1433 0 ▶ return unless $o->name =~ /^(next|db)state$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $o->name =~ /^(next|db)state$/ 0 0 0
1434 0 ▶ return if $o->label;
Branch: 1 branch
BranchTrueFalseTotal
if $o->label 0 0 0
1435  
1436 # OP_ARGELEM
1437 0 $o = $o->sibling;
1438 0 ▶ last unless $$o;
Branch: 1 branch
BranchTrueFalseTotal
unless $$o 0 0 0
1439  
1440 0 ▶ if ($o->name eq 'argelem') {
Branch: 2 branches
BranchTrueFalseTotal
if ($o->name eq 'argelem') { } 0 0 0
elsif ($o->name eq 'null' and $o->flags & 4 and $o->first->name eq 'argdefelem') { } 0 0 0
1441 0 my $ix = $o->string($cv);
1442 0 ▶ while (++$last_ix < $ix) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$last_ix < $ix) 0 0 0
1443 0 ▶ push @sig, $last_ix < $mandatory ? '$' : '$=';
Branch: 1 branch
BranchTrueFalseTotal
$last_ix < $mandatory ? : 0 0 0
1444 }
1445 0 my $var = $self->padname($o->targ);
1446 0 ▶ if ($var =~ /^[@%]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($var =~ /^[\@%]/) { } 0 0 0
1447 0 ▶ return if $seen_slurpy;
Branch: 1 branch
BranchTrueFalseTotal
if $seen_slurpy 0 0 0
1448 0 $seen_slurpy = 1;
1449 0 ▶ return if $ix != $params or !$slurpy
Branch: 1 branch
BranchTrueFalseTotal
if $ix != $params or not $slurpy or substr($var, 0, 1) ne $slurpy 0 0 0
Condition0%0/6
$ix != $params or not $slurpy or substr($var, 0, 1) ne $slurpy
l!l&&r!l&&!r
000
$ix != $params or not $slurpy
l!l&&r!l&&!r
000
MC/DC0%0/3
$ix != $params or not $slurpy or substr($var, 0, 1) ne $slurpy
$ix != $params not $slurpy substr($var, 0, 1) ne $slurpy
Truth table0%0/4
A or not(B) or C
A= $ix != $paramsB= not $slurpyC= substr($var, 0, 1) ne $slurpy
ABCresult
1XX1
01X1
0011
0000
1450 or substr($var,0,1) ne $slurpy;
1451 }
1452 else {
1453 0 ▶ return if $ix >= $params;
Branch: 1 branch
BranchTrueFalseTotal
if $ix >= $params 0 0 0
1454 }
1455 0 ▶ if ($o->flags & OPf_KIDS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->flags & 4) 0 0 0
1456 0 my $kid = $o->first;
1457 0 ▶ return unless $$kid and $kid->name eq 'argdefelem';
Branch: 1 branch
BranchTrueFalseTotal
unless $$kid and $kid->name eq "argdefelem" 0 0 0
Condition0%0/3
$$kid and $kid->name eq "argdefelem"
!ll&&!rl&&r
000
MC/DC0%0/2
$$kid and $kid->name eq "argdefelem"
$$kid $kid->name eq "argdefelem"
Truth table0%0/3
A and B
A= $$kidB= $kid->name eq "argdefelem"
ABresult
0X0
100
111
1458 0 my $def = $self->deparse($kid->first, 7);
1459 0 ▶ $def = "($def)" if $kid->first->flags & OPf_PARENS;
Branch: 1 branch
BranchTrueFalseTotal
if $kid->first->flags & 8 0 0 0
1460 0 my $assign = "=";
1461 0 ▶ $assign = "//=" if $kid->private & OPpARG_IF_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if $kid->private & 128 0 0 0
1462 0 ▶ $assign = "||=" if $kid->private & OPpARG_IF_FALSE;
Branch: 1 branch
BranchTrueFalseTotal
if $kid->private & 64 0 0 0
1463 0 $var .= " $assign $def";
1464 }
1465 0 push @sig, $var;
1466 }
1467 ▶ elsif ($o->name eq 'null'
Condition0%0/6
$o->name eq "null" and $o->flags & 4 and $o->first->name eq "argdefelem"
!ll&&!rl&&r
000
$o->name eq "null" and $o->flags & 4
!ll&&!rl&&r
000
MC/DC0%0/3
$o->name eq "null" and $o->flags & 4 and $o->first->name eq "argdefelem"
$o->name eq "null" $o->flags & 4 $o->first->name eq "argdefelem"
Truth table0%0/4
A and B and C
A= $o->name eq "null"B= $o->flags & 4C= $o->first->name eq "argdefelem"
ABCresult
0XX0
10X0
1100
1111
1468 and ($o->flags & OPf_KIDS)
1469 and $o->first->name eq 'argdefelem')
1470 {
1471 # special case - a void context default expression: $ = expr
1472  
1473 0 my $defop = $o->first;
1474 0 my $ix = $defop->targ;
1475 0 ▶ while (++$last_ix < $ix) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$last_ix < $ix) 0 0 0
1476 0 ▶ push @sig, $last_ix < $mandatory ? '$' : '$=';
Branch: 1 branch
BranchTrueFalseTotal
$last_ix < $mandatory ? : 0 0 0
1477 }
1478 0 ▶ return if $last_ix >= $params
Branch: 1 branch
BranchTrueFalseTotal
if $last_ix >= $params or $last_ix < $mandatory 0 0 0
Condition0%0/3
$last_ix >= $params or $last_ix < $mandatory
l!l&&r!l&&!r
000
MC/DC0%0/2
$last_ix >= $params or $last_ix < $mandatory
$last_ix >= $params $last_ix < $mandatory
Truth table0%0/3
A or B
A= $last_ix >= $paramsB= $last_ix < $mandatory
ABresult
1X1
011
000
1479 or $last_ix < $mandatory;
1480 0 my $def = $self->deparse($defop->first, 7);
1481 0 ▶ $def = "($def)" if $defop->first->flags & OPf_PARENS;
Branch: 1 branch
BranchTrueFalseTotal
if $defop->first->flags & 8 0 0 0
1482 0 push @sig, '$ = ' . $def;
1483 }
1484 else {
1485 0 return;
1486 }
1487  
1488 }
1489  
1490 0 ▶ if ($cv->CvFLAGS & CVf_IsMETHOD) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->CvFLAGS & 1048576) 0 0 0
1491 # Remove the implied `$self` argument
1492 0 ▶ warn "Expected first signature argument to be named \$self"
Branch: 1 branch
BranchTrueFalseTotal
unless @sig and $sig[0] eq "\$self" 0 0 0
Condition0%0/3
@sig and $sig[0] eq "\$self"
!ll&&!rl&&r
000
MC/DC0%0/2
@sig and $sig[0] eq "\$self"
@sig $sig[0] eq "\$self"
Truth table0%0/3
A and B
A= @sigB= $sig[0] eq "\$self"
ABresult
0X0
100
111
1493 unless @sig and $sig[0] eq '$self';
1494 0 shift @sig;
1495 }
1496  
1497 0 ▶ while (++$last_ix < $params) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$last_ix < $params) 0 0 0
1498 0 ▶ push @sig, $last_ix < $mandatory ? '$' : '$=';
Branch: 1 branch
BranchTrueFalseTotal
$last_ix < $mandatory ? : 0 0 0
1499 }
1500 0 ▶ push @sig, $slurpy if $slurpy and !$seen_slurpy;
Branch: 1 branch
BranchTrueFalseTotal
if $slurpy and not $seen_slurpy 0 0 0
Condition0%0/3
$slurpy and not $seen_slurpy
!ll&&!rl&&r
000
MC/DC0%0/2
$slurpy and not $seen_slurpy
$slurpy not $seen_slurpy
Truth table0%0/3
A and not(B)
A= $slurpyB= not $seen_slurpy
ABresult
0X0
100
111
1501  
1502 0 return (join(', ', @sig));
1503 }
1504  
1505  
1506 sub kw_sub_or_method {
1507 0 ▶ my $self = shift;
Subroutine kw_sub_or_method: not called CC=2 SCAR=17.9
Pod undocumented
1508 0 my $cv = shift;
1509 0 ▶ return ($cv->CvFLAGS & CVf_IsMETHOD) ? "method" : "sub";
Branch: 1 branch
BranchTrueFalseTotal
$cv->CvFLAGS & 1048576 ? : 0 0 0
1510 }
1511  
1512 # Deparse a sub. Returns everything except the 'sub foo',
1513 # e.g. ($$) : method { ...; }
1514 # or : prototype($$) lvalue ($a, $b) { ...; };
1515  
1516 sub deparse_sub {
1517 0 ▶ my $self = shift;
Subroutine deparse_sub: not called CC=35 SCAR=71.4
Pod undocumented
1518 0 my $cv = shift;
1519 0 my @attrs;
1520 my $proto;
1521 0 my $sig;
1522  
1523 0 ▶Carp::confess("NULL in deparse_sub") if !defined($cv) || $cv->isa("B::NULL");
Branch: 1 branch
BranchTrueFalseTotal
if not defined $cv or $cv->isa("B::NULL") 0 0 0
Condition0%0/3
not defined $cv or $cv->isa("B::NULL")
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $cv or $cv->isa("B::NULL")
not defined $cv $cv->isa("B::NULL")
Truth table0%0/3
not(A) or B
A= not defined $cvB= $cv->isa("B::NULL")
ABresult
1X1
011
000
1524 0 ▶Carp::confess("SPECIAL in deparse_sub") if $cv->isa("B::SPECIAL");
Branch: 1 branch
BranchTrueFalseTotal
if $cv->isa("B::SPECIAL") 0 0 0
1525 0 local $self->{'curcop'} = $self->{'curcop'};
1526  
1527 0 my $use_feature_sig = $self->feature_enabled('signatures');
1528 0 ▶ if ($cv->FLAGS & SVf_POK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->FLAGS & 1024) 0 0 0
1529 0 my $myproto = $cv->PV;
1530 0 ▶ if ($use_feature_sig) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_feature_sig) { } 0 0 0
1531 0 push @attrs, "prototype($myproto)";
1532 }
1533 else {
1534 0 $proto = $myproto;
1535 }
1536 }
1537 0 my $cv_flags = $cv->CvFLAGS;
1538 0 my $is_method = $cv_flags & CVf_IsMETHOD;
1539  
1540 0 ▶ if ($cv_flags & (CVf_NOWARN_AMBIGUOUS|CVf_LOCKED|CVf_LVALUE|CVf_ANONCONST)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv_flags & 131075) 0 0 0
1541 0 ▶ push @attrs, "lvalue" if $cv_flags & CVf_LVALUE;
Branch: 1 branch
BranchTrueFalseTotal
if $cv_flags & 2 0 0 0
1542 0 ▶ push @attrs, "method" if $cv_flags & CVf_NOWARN_AMBIGUOUS and !$is_method;
Branch: 1 branch
BranchTrueFalseTotal
if $cv_flags & 1 and not $is_method 0 0 0
Condition0%0/3
$cv_flags & 1 and not $is_method
!ll&&!rl&&r
000
MC/DC0%0/2
$cv_flags & 1 and not $is_method
$cv_flags & 1 not $is_method
Truth table0%0/3
A and not(B)
A= $cv_flags & 1B= not $is_method
ABresult
0X0
100
111
1543 0 ▶ push @attrs, "const" if $cv_flags & CVf_ANONCONST;
Branch: 1 branch
BranchTrueFalseTotal
if $cv_flags & 131072 0 0 0
1544 }
1545  
1546 0 local($self->{'curcv'}) = $cv;
1547 0 local($self->{'curcvlex'});
1548 local(@$self{qw'curstash warnings hints hinthash'})
1549 0 = @$self{qw'curstash warnings hints hinthash'};
1550 0 my $body = "";
1551 0 my $root = $cv->ROOT;
1552 0 local $B::overlay = {};
1553 0 ▶ if (not null $root) {
Branch: 1 branch
BranchTrueFalseTotal
if (not null($root)) { } 0 0 0
1554 0 $self->pad_subs($cv);
1555 0 $self->pessimise($root, $cv->START);
1556 0 my $lineseq = $root->first;
1557  
1558 # stub sub may have single op rather than list of ops
1559 0 my $is_list = ($lineseq->name eq "lineseq");
1560 0 ▶ my $firstop = $is_list ? $lineseq->first : $lineseq;
Branch: 1 branch
BranchTrueFalseTotal
$is_list ? : 0 0 0
1561  
1562 # Try to deparse first subtree as a signature if possible.
1563 # Top of signature subtree has an ex-argcheck as a placeholder
1564 0 ▶ if ($$firstop and $firstop->name eq 'null' and $firstop->targ == OP_ARGCHECK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$firstop and $firstop->name eq "null" and $firstop->targ == 194) 0 0 0
Condition0%0/6
$$firstop and $firstop->name eq "null" and $firstop->targ == 194
!ll&&!rl&&r
000
$$firstop and $firstop->name eq "null"
!ll&&!rl&&r
000
MC/DC0%0/3
$$firstop and $firstop->name eq "null" and $firstop->targ == 194
$$firstop $firstop->name eq "null" $firstop->targ == 194
Truth table0%0/4
A and B and C
A= $$firstopB= $firstop->name eq "null"C= $firstop->targ == 194
ABCresult
0XX0
10X0
1100
1111
1565 0 ▶ if ($use_feature_sig) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_feature_sig) { } 0 0 0
1566 0 ▶ my ($mysig) = $self->deparse_multiparam($firstop, $cv, true) //
Condition0%0/3
// $self->deparse_argops($firstop, $cv)
l!l&&r!l&&!r
000
MC/DC0%0/2
// $self->deparse_argops($firstop, $cv)
$self->deparse_argops($firstop, $cv)
Truth table0%0/3
A // B
A= B= $self->deparse_argops($firstop, $cv)
ABresult
1X1
011
000
1567 $self->deparse_argops($firstop, $cv);
1568 0 ▶ if (defined $mysig) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mysig) 0 0 0
1569 0 $sig = $mysig;
1570 0 ▶ $firstop = $is_list ? $firstop->sibling : undef;
Branch: 1 branch
BranchTrueFalseTotal
$is_list ? : 0 0 0
1571 }
1572 }
1573 else {
1574 0 my $prelude = $self->deparse_multiparam($firstop, $cv, false);
1575 0 ▶ if (defined $prelude) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $prelude) 0 0 0
1576 0 $body .= $prelude;
1577 0 ▶ $firstop = $is_list ? $firstop->sibling : undef;
Branch: 1 branch
BranchTrueFalseTotal
$is_list ? : 0 0 0
1578 }
1579 }
1580 }
1581  
1582 0 ▶ if ($is_list && $firstop) {
Branch: 2 branches
BranchTrueFalseTotal
if ($is_list and $firstop) { } 0 0 0
elsif ($firstop) { } 0 0 0
Condition0%0/3
$is_list and $firstop
!ll&&!rl&&r
000
MC/DC0%0/2
$is_list and $firstop
$is_list $firstop
Truth table0%0/3
A and B
A= $is_listB= $firstop
ABresult
0X0
100
111
1583 0 my @ops;
1584 0 ▶ for (my $o = $firstop; $$o; $o=$o->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$o) 0 0 0
1585 0 push @ops, $o;
1586 }
1587 0 $body .= $self->lineseq(undef, 0, @ops).";";
1588 0 ▶ if (!$use_feature_sig and $ops[-1]->name =~ /^(next|db)state$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $use_feature_sig and $ops[-1]->name =~ /^(next|db)state$/) 0 0 0
Condition0%0/3
not $use_feature_sig and $ops[-1]->name =~ /^(next|db)state$/
!ll&&!rl&&r
000
MC/DC0%0/2
not $use_feature_sig and $ops[-1]->name =~ /^(next|db)state$/
not $use_feature_sig $ops[-1]->name =~ /^(next|db)state$/
Truth table0%0/3
not(A) and B
A= not $use_feature_sigB= $ops[-1]->name =~ /^(next|db)state$/
ABresult
0X0
100
111
1589 # this handles void context in
1590 # use feature signatures; sub ($=1) {}
1591 0 $body .= "\n()";
1592 }
1593 0 my $scope_en = $self->find_scope_en($lineseq);
1594 0 ▶ if (defined $scope_en) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $scope_en) 0 0 0
1595 0 my $subs = join"", $self->seq_subs($scope_en);
1596 0 ▶ $body .= ";\n$subs" if length($subs);
Branch: 1 branch
BranchTrueFalseTotal
if length $subs 0 0 0
1597 }
1598 }
1599 elsif ($firstop) {
1600 0 $body .= $self->deparse($root->first, 0);
1601 }
1602 else {
1603 0 $body .= ';'; # stub sub
1604 }
1605  
1606 0 my $l = '';
1607 0 ▶ if ($self->{'linenums'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"linenums"}) 0 0 0
1608 # a glob's gp_line is set from the line containing a
1609 # sub's closing '}' if the CV is the first use of the GV.
1610 # So make sure the linenum is set correctly for '}'
1611 0 my $gv = $cv->GV;
1612 0 my $line = $gv->LINE;
1613 0 my $file = $gv->FILE;
1614 0 $l = "\f#line $line \"$file\"\n";
1615 }
1616 0 $body = "{\n\t$body\n$l\b}";
1617 }
1618 else {
1619 0 my $sv = $cv->const_sv;
1620 0 ▶ if ($$sv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$sv) { } 0 0 0
1621 # uh-oh. inlinable sub... format it differently
1622 0 $body = "{ " . $self->const($sv, 0) . " }\n";
1623 } else { # XSUB? (or just a declaration)
1624 0 $body = ';'
1625 }
1626 }
1627 0 ▶ $proto = defined $proto ? "($proto) " : "";
Branch: 1 branch
BranchTrueFalseTotal
defined $proto ? : 0 0 0
1628 0 ▶ $sig = defined $sig ? "($sig) " : "";
Branch: 1 branch
BranchTrueFalseTotal
defined $sig ? : 0 0 0
1629 0 my $attrs = '';
1630 0 ▶ $attrs = ': ' . join('', map "$_ ", @attrs) if @attrs;
Branch: 1 branch
BranchTrueFalseTotal
if @attrs 0 0 0
1631 0 return "$proto$attrs$sig$body\n";
1632 }
1633  
1634 sub deparse_format {
1635 0 ▶ my $self = shift;
Subroutine deparse_format: not called CC=6 SCAR=37.4
Pod undocumented
1636 0 my $form = shift;
1637 0 my @text;
1638 0 local($self->{'curcv'}) = $form;
1639 0 local($self->{'curcvlex'});
1640 0 local($self->{'in_format'}) = 1;
1641 local(@$self{qw'curstash warnings hints hinthash'})
1642 0 = @$self{qw'curstash warnings hints hinthash'};
1643 0 my $op = $form->ROOT;
1644 0 local $B::overlay = {};
1645 0 $self->pessimise($op, $form->START);
1646 0 my $kid;
1647 0 ▶ return "\f." if $op->first->name eq 'stub'
Branch: 1 branch
BranchTrueFalseTotal
if $op->first->name eq "stub" or $op->first->name eq "nextstate" 0 0 0
Condition0%0/3
$op->first->name eq "stub" or $op->first->name eq "nextstate"
l!l&&r!l&&!r
000
MC/DC0%0/2
$op->first->name eq "stub" or $op->first->name eq "nextstate"
$op->first->name eq "stub" $op->first->name eq "nextstate"
Truth table0%0/3
A or B
A= $op->first->name eq "stub"B= $op->first->name eq "nextstate"
ABresult
1X1
011
000
1648 || $op->first->name eq 'nextstate';
1649 0 $op = $op->first->first; # skip leavewrite, lineseq
1650 0 ▶ while (not null $op) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($op)) 0 0 0
1651 0 $op = $op->sibling; # skip nextstate
1652 0 my @exprs;
1653 0 $kid = $op->first->sibling; # skip pushmark
1654 0 push @text, "\f".$self->const_sv($kid)->PV;
1655 0 $kid = $kid->sibling;
1656 0 ▶ for (; not null $kid; $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
1657 0 push @exprs, $self->deparse($kid, -1);
1658 0 $exprs[-1] =~ s/;\z//;
1659 }
1660 0 ▶ push @text, "\f".join(", ", @exprs)."\n" if @exprs;
Branch: 1 branch
BranchTrueFalseTotal
if @exprs 0 0 0
1661 0 $op = $op->sibling;
1662 }
1663 0 return join("", @text) . "\f.";
1664 }
1665  
1666 sub is_scope {
1667 0 ▶ my $op = shift;
Subroutine is_scope: not called CC=7 SCAR=40.3
Pod undocumented
1668 0 ▶ return $op->name eq "leave" || $op->name eq "scope"
Condition0%0/18
$op->name eq 'leave' || $op->name eq 'scope' || $op->name eq 'lineseq' || $op->name eq 'null' && B::Deparse::class($op) eq 'UNOP' && (is_scope($op->first) || $op->first->name eq 'enter')
l!l&&r!l&&!r
000
$op->name eq "leave" or $op->name eq "scope" or $op->name eq "lineseq"
l!l&&r!l&&!r
000
$op->name eq "leave" or $op->name eq "scope"
l!l&&r!l&&!r
000
$op->name eq "null" and B::Deparse::class($op) eq "UNOP" and is_scope($op->first) || $op->first->name eq "enter"
!ll&&!rl&&r
000
$op->name eq "null" and B::Deparse::class($op) eq "UNOP"
!ll&&!rl&&r
000
is_scope($op->first) or $op->first->name eq "enter"
l!l&&r!l&&!r
000
MC/DC0%0/7
$op->name eq 'leave' || $op->name eq 'scope' || $op->name eq 'lineseq' || $op->name eq 'null' && B::Deparse::class($op) eq 'UNOP' && (is_scope($op->first) || $op->first->name eq 'enter')
$op->name eq "leave" $op->name eq "scope" $op->name eq "lineseq" $op->name eq "null" B::Deparse::class($op) eq "UNOP" is_scope($op->first) $op->first->name eq "enter"
Truth table0%0/8
A or B or C || D and E and F or G
A= $op->name eq "leave"B= $op->name eq "scope"C= $op->name eq "lineseq"D= $op->name eq "null"E= B::Deparse::class($op) eq "UNOP"F= is_scope($op->first)G= $op->first->name eq "enter"
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
000111X1
00011011
0000XXX0
00010XX0
00011000
1669 || $op->name eq "lineseq"
1670 || ($op->name eq "null" && class($op) eq "UNOP"
1671 && (is_scope($op->first) || $op->first->name eq "enter"));
1672 }
1673  
1674 sub is_state {
1675 0 ▶ my $name = $_[0]->name;
Subroutine is_state: not called CC=3 SCAR=24.8
Pod undocumented
1676 0 ▶ return $name eq "nextstate" || $name eq "dbstate" || $name eq "setstate";
Condition0%0/6
$name eq 'nextstate' || $name eq 'dbstate' || $name eq 'setstate'
l!l&&r!l&&!r
000
$name eq "nextstate" or $name eq "dbstate"
l!l&&r!l&&!r
000
MC/DC0%0/3
$name eq 'nextstate' || $name eq 'dbstate' || $name eq 'setstate'
$name eq "nextstate" $name eq "dbstate" $name eq 'setstate'
Truth table0%0/4
A or B || C
A= $name eq "nextstate"B= $name eq "dbstate"C= $name eq 'setstate'
ABCresult
1XX1
01X1
0011
0000
1677 }
1678  
1679 sub is_miniwhile { # check for one-line loop ('foo() while $y--')
1680 0 ▶ my $op = shift;
Subroutine is_miniwhile: not called CC=9 SCAR=45.0
Pod undocumented
1681 0 ▶ return (!null($op) and null($op->sibling)
Condition0%0/24
!null($op) && null($op->sibling) && $op->name eq 'null' && B::Deparse::class($op) eq 'UNOP' && ($op->first->name =~ /^(and|or)$/ && $op->first->first->sibling->name eq 'lineseq' || $op->first->name eq 'lineseq' && !null($op->first->first->sibling) && $op->first->first->sibling->name eq 'unstack')
!ll&&!rl&&r
000
not null($op) and null($op->sibling) and $op->name eq "null" and B::Deparse::class($op) eq "UNOP"
!ll&&!rl&&r
000
not null($op) and null($op->sibling) and $op->name eq "null"
!ll&&!rl&&r
000
not null($op) and null($op->sibling)
!ll&&!rl&&r
000
$op->first->name =~ /^(and|or)$/ and $op->first->first->sibling->name eq "lineseq" or $op->first->name eq "lineseq" and not null($op->first->first->sibling) and $op->first->first->sibling->name eq "unstack"
l!l&&r!l&&!r
000
$op->first->name =~ /^(and|or)$/ and $op->first->first->sibling->name eq "lineseq"
!ll&&!rl&&r
000
$op->first->name eq "lineseq" and not null($op->first->first->sibling) and $op->first->first->sibling->name eq "unstack"
!ll&&!rl&&r
000
$op->first->name eq "lineseq" and not null($op->first->first->sibling)
!ll&&!rl&&r
000
MC/DC0%0/9
!null($op) && null($op->sibling) && $op->name eq 'null' && B::Deparse::class($op) eq 'UNOP' && ($op->first->name =~ /^(and|or)$/ && $op->first->first->sibling->name eq 'lineseq' || $op->first->name eq 'lineseq' && !null($op->first->first->sibling) && $op->first->first->sibling->name eq 'unstack')
not null($op) null($op->sibling) $op->name eq "null" B::Deparse::class($op) eq "UNOP" $op->first->name =~ /^(and|or)$/ $op->first->first->sibling->name eq "lineseq" $op->first->name eq "lineseq" not null($op->first->first->sibling) $op->first->first->sibling->name eq "unstack"
Truth table0%0/13
not(A) and B and C and D && E and F or G and not(H) and I
A= not null($op)B= null($op->sibling)C= $op->name eq "null"D= B::Deparse::class($op) eq "UNOP"E= $op->first->name =~ /^(and|or)$/F= $op->first->first->sibling->name eq "lineseq"G= $op->first->name eq "lineseq"H= not null($op->first->first->sibling)I= $op->first->first->sibling->name eq "unstack"
ABCDEFGHIresult
0XXXXXXXX0
10XXXXXXX0
110XXXXXX0
1110XXXXX0
11110X0XX0
11110X10X0
11110X1100
1111100XX0
11111010X0
1111101100
111111XXX1
11110X1111
1111101111
1682 and $op->name eq "null" and class($op) eq "UNOP"
1683 and (($op->first->name =~ /^(and|or)$/
1684 and $op->first->first->sibling->name eq "lineseq")
1685 or ($op->first->name eq "lineseq"
1686 and not null $op->first->first->sibling
1687 and $op->first->first->sibling->name eq "unstack")
1688 ));
1689 }
1690  
1691 # Check if the op and its sibling are the initialization and the rest of a
1692 # for (..;..;..) { ... } loop
1693 sub is_for_loop {
1694 0 ▶ my $op = shift;
Subroutine is_for_loop: not called CC=13 SCAR=52.0
Pod undocumented
1695 # This OP might be almost anything, though it won't be a
1696 # nextstate. (It's the initialization, so in the canonical case it
1697 # will be an sassign.) The sibling is (old style) a lineseq whose
1698 # first child is a nextstate and whose second is a leaveloop, or
1699 # (new style) an unstack whose sibling is a leaveloop.
1700 0 my $lseq = $op->sibling;
1701 0 ▶ return 0 unless !is_state($op) and !null($lseq);
Branch: 1 branch
BranchTrueFalseTotal
if is_state($op) or null($lseq) 0 0 0
Condition0%0/3
is_state($op) or null($lseq)
l!l&&r!l&&!r
000
MC/DC0%0/2
is_state($op) or null($lseq)
is_state($op) null($lseq)
Truth table0%0/3
A or B
A= is_state($op)B= null($lseq)
ABresult
1X1
011
000
1702 0 ▶ if ($lseq->name eq "lineseq") {
Branch: 2 branches
BranchTrueFalseTotal
if ($lseq->name eq 'lineseq') { } 0 0 0
elsif ($lseq->name eq 'unstack' and $lseq->flags & 128) { } 0 0 0
1703 0 ▶ if ($lseq->first && !null($lseq->first) && is_state($lseq->first)
Branch: 1 branch
BranchTrueFalseTotal
if ($lseq->first and not null($lseq->first) and is_state($lseq->first) and my $sib = $lseq->first->sibling) 0 0 0
Condition0%0/9
$lseq->first and not null($lseq->first) and is_state($lseq->first) and my $sib = $lseq->first->sibling
!ll&&!rl&&r
000
$lseq->first and not null($lseq->first) and is_state($lseq->first)
!ll&&!rl&&r
000
$lseq->first and not null($lseq->first)
!ll&&!rl&&r
000
MC/DC0%0/4
$lseq->first and not null($lseq->first) and is_state($lseq->first) and my $sib = $lseq->first->sibling
$lseq->first not null($lseq->first) is_state($lseq->first) my $sib = $lseq->first->sibling
Truth table0%0/5
A and not(B) and C and D
A= $lseq->firstB= not null($lseq->first)C= is_state($lseq->first)D= my $sib = $lseq->first->sibling
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1704 && (my $sib = $lseq->first->sibling)) {
1705 0 ▶ return (!null($sib) && $sib->name eq "leaveloop");
Condition0%0/3
!null($sib) && $sib->name eq 'leaveloop'
!ll&&!rl&&r
000
MC/DC0%0/2
!null($sib) && $sib->name eq 'leaveloop'
!null($sib) $sib->name eq 'leaveloop'
Truth table0%0/3
not(A) && B
A= !null($sib)B= $sib->name eq 'leaveloop'
ABresult
0X0
100
111
1706 }
1707 ▶ } elsif ($lseq->name eq "unstack" && ($lseq->flags & OPf_SPECIAL)) {
Condition0%0/3
$lseq->name eq "unstack" and $lseq->flags & 128
!ll&&!rl&&r
000
MC/DC0%0/2
$lseq->name eq "unstack" and $lseq->flags & 128
$lseq->name eq "unstack" $lseq->flags & 128
Truth table0%0/3
A and B
A= $lseq->name eq "unstack"B= $lseq->flags & 128
ABresult
0X0
100
111
1708 0 my $sib = $lseq->sibling;
1709 0 ▶ return $sib && !null($sib) && $sib->name eq "leaveloop";
Condition0%0/6
$sib && !null($sib) && $sib->name eq 'leaveloop'
!ll&&!rl&&r
000
$sib and not null($sib)
!ll&&!rl&&r
000
MC/DC0%0/3
$sib && !null($sib) && $sib->name eq 'leaveloop'
$sib not null($sib) $sib->name eq 'leaveloop'
Truth table0%0/4
A and not(B) && C
A= $sibB= not null($sib)C= $sib->name eq 'leaveloop'
ABCresult
0XX0
10X0
1100
1111
1710 }
1711 0 return 0;
1712 }
1713  
1714 sub is_scalar {
1715 0 ▶ my $op = shift;
Subroutine is_scalar: not called CC=6 SCAR=37.4
Pod undocumented
1716 0 ▶ return ($op->name eq "rv2sv" or
Condition0%0/15
$op->name eq 'rv2sv' || $op->name eq 'padsv' || $op->name eq 'gv' || $op->flags & 4 && !null($op->first) && $op->first->name eq 'gvsv'
l!l&&r!l&&!r
000
$op->name eq "rv2sv" or $op->name eq "padsv" or $op->name eq "gv"
l!l&&r!l&&!r
000
$op->name eq "rv2sv" or $op->name eq "padsv"
l!l&&r!l&&!r
000
$op->flags & 4 and not null($op->first) and $op->first->name eq "gvsv"
!ll&&!rl&&r
000
$op->flags & 4 and not null($op->first)
!ll&&!rl&&r
000
MC/DC0%0/6
$op->name eq 'rv2sv' || $op->name eq 'padsv' || $op->name eq 'gv' || $op->flags & 4 && !null($op->first) && $op->first->name eq 'gvsv'
$op->name eq "rv2sv" $op->name eq "padsv" $op->name eq "gv" $op->flags & 4 not null($op->first) $op->first->name eq "gvsv"
Truth table0%0/7
A or B or C || D and not(E) and F
A= $op->name eq "rv2sv"B= $op->name eq "padsv"C= $op->name eq "gv"D= $op->flags & 4E= not null($op->first)F= $op->first->name eq "gvsv"
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001111
0000XX0
00010X0
0001100
1717 $op->name eq "padsv" or
1718 $op->name eq "gv" or # only in array/hash constructs
1719 $op->flags & OPf_KIDS && !null($op->first)
1720 && $op->first->name eq "gvsv");
1721 }
1722  
1723 sub maybe_parens {
1724 0 ▶ my $self = shift;
Subroutine maybe_parens: not called CC=8 SCAR=42.8
Pod undocumented
1725 0 my($text, $cx, $prec) = @_;
1726 0 ▶ if ($prec < $cx # unary ops nest just fine
Branch: 1 branch
BranchTrueFalseTotal
if ($prec < $cx or $prec == $cx and $cx != 4 and $cx != 16 and $cx != 21 or $self->{'parens'}) { } 0 0 0
Condition0%0/15
$prec < $cx or $prec == $cx and $cx != 4 and $cx != 16 and $cx != 21 or $self->{"parens"}
l!l&&r!l&&!r
000
$prec < $cx or $prec == $cx and $cx != 4 and $cx != 16 and $cx != 21
l!l&&r!l&&!r
000
$prec == $cx and $cx != 4 and $cx != 16 and $cx != 21
!ll&&!rl&&r
000
$prec == $cx and $cx != 4 and $cx != 16
!ll&&!rl&&r
000
$prec == $cx and $cx != 4
!ll&&!rl&&r
000
MC/DC0%0/6
$prec < $cx or $prec == $cx and $cx != 4 and $cx != 16 and $cx != 21 or $self->{"parens"}
$prec < $cx $prec == $cx $cx != 4 $cx != 16 $cx != 21 $self->{"parens"}
Truth table0%0/10
A or B and C and D and E or F
A= $prec < $cxB= $prec == $cxC= $cx != 4D= $cx != 16E= $cx != 21F= $self->{"parens"}
ABCDEFresult
1XXXXX1
01111X1
00XXX11
010XX11
0110X11
0111011
00XXX00
010XX00
0110X00
0111000
1727 or $prec == $cx and $cx != 4 and $cx != 16 and $cx != 21
1728 or $self->{'parens'})
1729 {
1730 0 $text = "($text)";
1731 # In a unop, let parent reuse our parens; see maybe_parens_unop
1732 0 ▶ $text = "\cS" . $text if $cx == 16;
Branch: 1 branch
BranchTrueFalseTotal
if $cx == 16 0 0 0
1733 0 return $text;
1734 } else {
1735 0 return $text;
1736 }
1737 }
1738  
1739 # same as above, but get around the 'if it looks like a function' rule
1740 sub maybe_parens_unop {
1741 0 ▶ my $self = shift;
Subroutine maybe_parens_unop: not called CC=9 SCAR=45.0
Pod undocumented
1742 0 my($name, $kid, $cx) = @_;
1743 0 ▶ if ($cx > 16 or $self->{'parens'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cx > 16 or $self->{'parens'}) { } 0 0 0
Condition0%0/3
$cx > 16 or $self->{"parens"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cx > 16 or $self->{"parens"}
$cx > 16 $self->{"parens"}
Truth table0%0/3
A or B
A= $cx > 16B= $self->{"parens"}
ABresult
1X1
011
000
1744 0 $kid = $self->deparse($kid, 1);
1745 0 ▶ if ($name eq "umask" && $kid =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "umask" and $kid =~ /^\d+$/) 0 0 0
Condition0%0/3
$name eq "umask" and $kid =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "umask" and $kid =~ /^\d+$/
$name eq "umask" $kid =~ /^\d+$/
Truth table0%0/3
A and B
A= $name eq "umask"B= $kid =~ /^\d+$/
ABresult
0X0
100
111
1746 0 $kid = sprintf("%#o", $kid);
1747 }
1748 0 return $self->keyword($name) . "($kid)";
1749 } else {
1750 0 $kid = $self->deparse($kid, 16);
1751 0 ▶ if ($name eq "umask" && $kid =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "umask" and $kid =~ /^\d+$/) 0 0 0
Condition0%0/3
$name eq "umask" and $kid =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "umask" and $kid =~ /^\d+$/
$name eq "umask" $kid =~ /^\d+$/
Truth table0%0/3
A and B
A= $name eq "umask"B= $kid =~ /^\d+$/
ABresult
0X0
100
111
1752 0 $kid = sprintf("%#o", $kid);
1753 }
1754 0 $name = $self->keyword($name);
1755 0 ▶ if (substr($kid, 0, 1) eq "\cS") {
Branch: 2 branches
BranchTrueFalseTotal
if (substr($kid, 0, 1) eq "\cS") { } 0 0 0
elsif (substr($kid, 0, 1) eq '(') { } 0 0 0
1756 # use kid's parens
1757 0 return $name . substr($kid, 1);
1758 } elsif (substr($kid, 0, 1) eq "(") {
1759 # avoid looks-like-a-function trap with extra parens
1760 # ('+' can lead to ambiguities)
1761 0 return "$name(" . $kid . ")";
1762 } else {
1763 0 return "$name $kid";
1764 }
1765 }
1766 }
1767  
1768 sub maybe_parens_func {
1769 0 ▶ my $self = shift;
Subroutine maybe_parens_func: not called CC=5 SCAR=34.0
Pod undocumented
1770 0 my($func, $text, $cx, $prec) = @_;
1771 0 ▶ if ($prec <= $cx or substr($text, 0, 1) eq "(" or $self->{'parens'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prec <= $cx or substr($text, 0, 1) eq '(' or $self->{'parens'}) { } 0 0 0
Condition0%0/6
$prec <= $cx or substr($text, 0, 1) eq "(" or $self->{"parens"}
l!l&&r!l&&!r
000
$prec <= $cx or substr($text, 0, 1) eq "("
l!l&&r!l&&!r
000
MC/DC0%0/3
$prec <= $cx or substr($text, 0, 1) eq "(" or $self->{"parens"}
$prec <= $cx substr($text, 0, 1) eq "(" $self->{"parens"}
Truth table0%0/4
A or B or C
A= $prec <= $cxB= substr($text, 0, 1) eq "("C= $self->{"parens"}
ABCresult
1XX1
01X1
0011
0000
1772 0 return "$func($text)";
1773 } else {
1774 0 ▶ return $func . (length($text) ? " $text" : "");
Branch: 1 branch
BranchTrueFalseTotal
length $text ? : 0 0 0
1775 }
1776 }
1777  
1778 sub find_our_type {
1779 0 ▶ my ($self, $name) = @_;
Subroutine find_our_type: not called CC=6 SCAR=37.4
Pod undocumented
1780 0 ▶ $self->populate_curcvlex() if !defined $self->{'curcvlex'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"curcvlex"} 0 0 0
1781 0 ▶ my $seq = $self->{'curcop'} ? $self->{'curcop'}->cop_seq : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'curcop'} ? : 0 0 0
1782 0 for my $a (@{$self->{'curcvlex'}{"o$name"}}) {
1783 0 my ($st, undef, $padname) = @$a;
1784 0 ▶ if ($st >= $seq && $padname->FLAGS & PADNAMEf_TYPED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($st >= $seq and $padname->FLAGS & 8) 0 0 0
Condition0%0/3
$st >= $seq and $padname->FLAGS & 8
!ll&&!rl&&r
000
MC/DC0%0/2
$st >= $seq and $padname->FLAGS & 8
$st >= $seq $padname->FLAGS & 8
Truth table0%0/3
A and B
A= $st >= $seqB= $padname->FLAGS & 8
ABresult
0X0
100
111
1785 0 return $padname->SvSTASH->NAME;
1786 }
1787 }
1788 0 return '';
1789 }
1790  
1791 sub maybe_local {
1792 0 ▶ my $self = shift;
Subroutine maybe_local: not called CC=19 SCAR=59.4
Pod undocumented
1793 0 my($op, $cx, $text) = @_;
1794 0 my $name = $op->name;
1795 0 ▶ my $our_intro = ($name =~ /^(?:(?:gv|rv2)[ash]v|split|refassign
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /^(?:(?:gv|rv2)[ash]v|split|refassign |lv(?:av)?ref)$/x ? : 0 0 0
1796 |lv(?:av)?ref)$/x)
1797 ? OPpOUR_INTRO
1798 : 0;
1799 0 ▶ my $lval_intro = $name eq 'split' ? 0 : OPpLVAL_INTRO;
Branch: 1 branch
BranchTrueFalseTotal
$name eq 'split' ? : 0 0 0
1800 # The @a in \(@a) isn't in ref context, but only when the
1801 # parens are there.
1802 0 ▶ my $need_parens = $self->{'in_refgen'} && $name =~ /[ah]v\z/
Condition0%0/6
$self->{'in_refgen'} && $name =~ /[ah]v\z/ && ($op->flags & 24) == 8
!ll&&!rl&&r
000
$self->{"in_refgen"} and $name =~ /[ah]v\z/
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{'in_refgen'} && $name =~ /[ah]v\z/ && ($op->flags & 24) == 8
$self->{"in_refgen"} $name =~ /[ah]v\z/ ($op->flags & 24) == 8
Truth table0%0/4
A and B && C
A= $self->{"in_refgen"}B= $name =~ /[ah]v\z/C= ($op->flags & 24) == 8
ABCresult
0XX0
10X0
1100
1111
1803 && ($op->flags & (OPf_PARENS|OPf_REF)) == OPf_PARENS;
1804 0 ▶ if ((my $priv = $op->private) & ($lval_intro|$our_intro)) {
Branch: 1 branch
BranchTrueFalseTotal
if ((my $priv = $op->private) & ($lval_intro | $our_intro)) { } 0 0 0
1805 0 my @our_local;
1806 0 ▶ push @our_local, "local" if $priv & $lval_intro;
Branch: 1 branch
BranchTrueFalseTotal
if $priv & $lval_intro 0 0 0
1807 0 ▶ push @our_local, "our" if $priv & $our_intro;
Branch: 1 branch
BranchTrueFalseTotal
if $priv & $our_intro 0 0 0
1808 0 my $our_local = join " ", map $self->keyword($_), @our_local;
1809 0 ▶ if( $our_local[-1] eq 'our' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($our_local[-1] eq "our") 0 0 0
1810 0 ▶ if ( $text !~ /^\W(\w+::)*\w+\z/
Branch: 1 branch
BranchTrueFalseTotal
unless ($text =~ /^\W(\w+::)*\w+\z/ or utf8::decode($text) and $text =~ /^\W(\w+::)*\w+\z/) 0 0 0
Condition0%0/6
$text =~ /^\W(\w+::)*\w+\z/ or utf8::decode($text) and $text =~ /^\W(\w+::)*\w+\z/
l!l&&r!l&&!r
000
utf8::decode($text) and $text =~ /^\W(\w+::)*\w+\z/
!ll&&!rl&&r
000
MC/DC0%0/3
$text =~ /^\W(\w+::)*\w+\z/ or utf8::decode($text) and $text =~ /^\W(\w+::)*\w+\z/
$text =~ /^\W(\w+::)*\w+\z/ utf8::decode($text) $text =~ /^\W(\w+::)*\w+\z/
Truth table0%0/4
A or B and C
A= $text =~ /^\W(\w+::)*\w+\z/B= utf8::decode($text)C= $text =~ /^\W(\w+::)*\w+\z/
ABCresult
1XX1
0111
00X0
0100
1811 and !utf8::decode($text) || $text !~ /^\W(\w+::)*\w+\z/
1812 ) {
1813 0 die "Unexpected our($text)\n";
1814 }
1815 0 $text =~ s/(\w+::)+//;
1816  
1817 0 ▶ if (my $type = $self->find_our_type($text)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $type = $self->find_our_type($text)) 0 0 0
1818 0 $our_local .= ' ' . $type;
1819 }
1820 }
1821 return $need_parens ? "($text)" : $text
1822 0 ▶ if $self->{'avoid_local'}{$$op};
Branch: 2 branches
BranchTrueFalseTotal
if $self->{"avoid_local"}{$$op} 0 0 0
$need_parens ? : 0 0 0
1823 0 ▶ if ($need_parens) {
Branch: 2 branches
BranchTrueFalseTotal
if ($need_parens) { } 0 0 0
elsif (want_scalar($op) or $our_local eq 'our') { } 0 0 0
1824 0 return "$our_local($text)";
1825 ▶ } elsif (want_scalar($op) || $our_local eq 'our') {
Condition0%0/3
want_scalar($op) or $our_local eq "our"
l!l&&r!l&&!r
000
MC/DC0%0/2
want_scalar($op) or $our_local eq "our"
want_scalar($op) $our_local eq "our"
Truth table0%0/3
A or B
A= want_scalar($op)B= $our_local eq "our"
ABresult
1X1
011
000
1826 0 return "$our_local $text";
1827 } else {
1828 0 return $self->maybe_parens_func("$our_local", $text, $cx, 16);
1829 }
1830 } else {
1831 0 ▶ return $need_parens ? "($text)" : $text;
Branch: 1 branch
BranchTrueFalseTotal
$need_parens ? : 0 0 0
1832 }
1833 }
1834  
1835 sub maybe_targmy {
1836 0 ▶ my $self = shift;
Subroutine maybe_targmy: not called CC=2 SCAR=17.9
Pod undocumented
1837 0 my($op, $cx, $func, @args) = @_;
1838 0 ▶ if ($op->private & OPpTARGET_MY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 16) { } 0 0 0
1839 0 my $var = $self->padname($op->targ);
1840 0 my $val = $func->($self, $op, 7, @args);
1841 0 return $self->maybe_parens("$var = $val", $cx, 7);
1842 } else {
1843 0 return $func->($self, $op, $cx, @args);
1844 }
1845 }
1846  
1847 sub padname_sv {
1848 0 ▶ my $self = shift;
Subroutine padname_sv: not called CC=1 SCAR=6.9
Pod undocumented
1849 0 my $targ = shift;
1850 0 return $self->{'curcv'}->PADLIST->ARRAYelt(0)->ARRAYelt($targ);
1851 }
1852  
1853 sub maybe_my {
1854 0 ▶ my $self = shift;
Subroutine maybe_my: not called CC=14 SCAR=53.5
Pod undocumented
1855 0 my($op, $cx, $text, $padname, $forbid_parens) = @_;
1856 # The @a in \(@a) isn't in ref context, but only when the
1857 # parens are there.
1858 0 ▶ my $need_parens = !$forbid_parens && $self->{'in_refgen'}
Condition0%0/9
!$forbid_parens && $self->{'in_refgen'} && $op->name =~ /[ah]v\z/ && ($op->flags & 24) == 8
!ll&&!rl&&r
000
not $forbid_parens and $self->{"in_refgen"} and $op->name =~ /[ah]v\z/
!ll&&!rl&&r
000
not $forbid_parens and $self->{"in_refgen"}
!ll&&!rl&&r
000
MC/DC0%0/4
!$forbid_parens && $self->{'in_refgen'} && $op->name =~ /[ah]v\z/ && ($op->flags & 24) == 8
not $forbid_parens $self->{"in_refgen"} $op->name =~ /[ah]v\z/ ($op->flags & 24) == 8
Truth table0%0/5
not(A) and B and C && D
A= not $forbid_parensB= $self->{"in_refgen"}C= $op->name =~ /[ah]v\z/D= ($op->flags & 24) == 8
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1859 && $op->name =~ /[ah]v\z/
1860 && ($op->flags & (OPf_PARENS|OPf_REF)) == OPf_PARENS;
1861 # The @a in \my @a must not have parens.
1862 0 ▶ if (!$need_parens && $self->{'in_refgen'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $need_parens and $self->{"in_refgen"}) 0 0 0
Condition0%0/3
not $need_parens and $self->{"in_refgen"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $need_parens and $self->{"in_refgen"}
not $need_parens $self->{"in_refgen"}
Truth table0%0/3
not(A) and B
A= not $need_parensB= $self->{"in_refgen"}
ABresult
0X0
100
111
1863 0 $forbid_parens = 1;
1864 }
1865 0 ▶ if ($op->private & OPpLVAL_INTRO and not $self->{'avoid_local'}{$$op}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 128 and not $self->{'avoid_local'}{$$op}) { } 0 0 0
Condition0%0/3
$op->private & 128 and not $self->{"avoid_local"}{$$op}
!ll&&!rl&&r
000
MC/DC0%0/2
$op->private & 128 and not $self->{"avoid_local"}{$$op}
$op->private & 128 not $self->{"avoid_local"}{$$op}
Truth table0%0/3
A and not(B)
A= $op->private & 128B= not $self->{"avoid_local"}{$$op}
ABresult
0X0
100
111
1866 # Check $padname->FLAGS for statehood, rather than $op->private,
1867 # because enteriter ops do not carry the flag.
1868 0 ▶ my $my =
Branch: 1 branch
BranchTrueFalseTotal
$padname->FLAGS & 2 ? : 0 0 0
1869 $self->keyword($padname->FLAGS & SVpad_STATE ? "state" : "my");
1870 0 ▶ if ($padname->FLAGS & PADNAMEf_TYPED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($padname->FLAGS & 8) 0 0 0
1871 0 $my .= ' ' . $padname->SvSTASH->NAME;
1872 }
1873 0 ▶ if ($need_parens) {
Branch: 2 branches
BranchTrueFalseTotal
if ($need_parens) { } 0 0 0
elsif ($forbid_parens or want_scalar($op)) { } 0 0 0
1874 0 return "$my($text)";
1875 ▶ } elsif ($forbid_parens || want_scalar($op)) {
Condition0%0/3
$forbid_parens or want_scalar($op)
l!l&&r!l&&!r
000
MC/DC0%0/2
$forbid_parens or want_scalar($op)
$forbid_parens want_scalar($op)
Truth table0%0/3
A or B
A= $forbid_parensB= want_scalar($op)
ABresult
1X1
011
000
1876 0 return "$my $text";
1877 } else {
1878 0 return $self->maybe_parens_func($my, $text, $cx, 16);
1879 }
1880 } else {
1881 0 ▶ return $need_parens ? "($text)" : $text;
Branch: 1 branch
BranchTrueFalseTotal
$need_parens ? : 0 0 0
1882 }
1883 }
1884  
1885 # The following OPs don't have functions:
1886  
1887 # pp_padany -- does not exist after parsing
1888  
1889 sub AUTOLOAD {
1890 0 ▶ if ($AUTOLOAD =~ s/^.*::pp_//) {
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
if ($B::Deparse::AUTOLOAD =~ s/^.*::pp_//) { } 0 0 0
1891 0 ▶ warn "unexpected OP_".
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->type == 390 ? : 0 0 0
1892 ($_[1]->type == OP_CUSTOM ? "CUSTOM ($AUTOLOAD)" : uc $AUTOLOAD);
1893 0 return "XXX";
1894 } else {
1895 0 die "Undefined subroutine $AUTOLOAD called";
1896 }
1897 }
1898  
1899 0 ▶sub DESTROY {} # Do not AUTOLOAD
Subroutine DESTROY: not called CC=1 SCAR=0.0
1900  
1901 # $root should be the op which represents the root of whatever
1902 # we're sequencing here. If it's undefined, then we don't append
1903 # any subroutine declarations to the deparsed ops, otherwise we
1904 # append appropriate declarations.
1905 sub lineseq {
1906 0 ▶ my($self, $root, $cx, @ops) = @_;
Subroutine lineseq: not called CC=14 SCAR=53.5
Pod undocumented
1907 0 my($expr, @exprs);
1908  
1909 0 my $out_cop = $self->{'curcop'};
1910 0 ▶ my $out_seq = defined($out_cop) ? $out_cop->cop_seq : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $out_cop ? : 0 0 0
1911 0 my $limit_seq;
1912 0 ▶ if (defined $root) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $root) 0 0 0
1913 0 $limit_seq = $out_seq;
1914 0 my $nseq;
1915 0 ▶ $nseq = $self->find_scope_st($root->sibling) if ${$root->sibling};
Branch: 1 branch
BranchTrueFalseTotal
if ${$root->sibling;} 0 0 0
1916 0 ▶ $limit_seq = $nseq if !defined($limit_seq)
Branch: 1 branch
BranchTrueFalseTotal
if not defined $limit_seq or defined $nseq and $nseq < $limit_seq 0 0 0
Condition0%0/6
not defined $limit_seq or defined $nseq and $nseq < $limit_seq
l!l&&r!l&&!r
000
defined $nseq and $nseq < $limit_seq
!ll&&!rl&&r
000
MC/DC0%0/3
not defined $limit_seq or defined $nseq and $nseq < $limit_seq
not defined $limit_seq defined $nseq $nseq < $limit_seq
Truth table0%0/4
not(A) or B and C
A= not defined $limit_seqB= defined $nseqC= $nseq < $limit_seq
ABCresult
1XX1
0111
00X0
0100
1917 or defined($nseq) && $nseq < $limit_seq;
1918 }
1919 $limit_seq = $self->{'limit_seq'}
1920 if defined($self->{'limit_seq'})
1921 0 ▶ && (!defined($limit_seq) || $self->{'limit_seq'} < $limit_seq);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"limit_seq"} and !defined($limit_seq) || $self->{"limit_seq"} < $limit_seq 0 0 0
Condition0%0/6
defined $self->{"limit_seq"} and !defined($limit_seq) || $self->{"limit_seq"} < $limit_seq
!ll&&!rl&&r
000
not defined $limit_seq or $self->{"limit_seq"} < $limit_seq
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $self->{"limit_seq"} and !defined($limit_seq) || $self->{"limit_seq"} < $limit_seq
defined $self->{"limit_seq"} not defined $limit_seq $self->{"limit_seq"} < $limit_seq
Truth table0%0/4
A and not(B) or C
A= defined $self->{"limit_seq"}B= not defined $limit_seqC= $self->{"limit_seq"} < $limit_seq
ABCresult
0XX0
1000
11X1
1011
1922 0 local $self->{'limit_seq'} = $limit_seq;
1923 $self->walk_lineseq($root, \@ops,
1924 0 ▶ sub { push @exprs, $_[0]} );
Subroutine __ANON__: not called CC=1 SCAR=6.9
1925  
1926 0 ▶ my $sep = $cx ? '; ' : ";\n";
Branch: 1 branch
BranchTrueFalseTotal
$cx ? : 0 0 0
1927 0 my $body = join($sep, grep {length} @exprs);
1928 0 my $subs = "";
1929 0 ▶ if (defined $root && defined $limit_seq && !$self->{'in_format'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $root and defined $limit_seq and not $self->{"in_format"}) 0 0 0
Condition0%0/6
defined $root and defined $limit_seq and not $self->{"in_format"}
!ll&&!rl&&r
000
defined $root and defined $limit_seq
!ll&&!rl&&r
000
MC/DC0%0/3
defined $root and defined $limit_seq and not $self->{"in_format"}
defined $root defined $limit_seq not $self->{"in_format"}
Truth table0%0/4
A and B and not(C)
A= defined $rootB= defined $limit_seqC= not $self->{"in_format"}
ABCresult
0XX0
10X0
1100
1111
1930 0 $subs = join "\n", $self->seq_subs($limit_seq);
1931 }
1932 0 return join($sep, grep {length} $body, $subs);
1933 }
1934  
1935 sub scopeop {
1936 0 ▶ my($real_block, $self, $op, $cx) = @_;
Subroutine scopeop: not called CC=18 SCAR=58.3
Pod undocumented
1937 0 my $kid;
1938 my @kids;
1939 0 my $leadingstub = '';
1940  
1941 local(@$self{qw'curstash warnings hints hinthash'})
1942 0 ▶ = @$self{qw'curstash warnings hints hinthash'} if $real_block;
Branch: 1 branch
BranchTrueFalseTotal
if $real_block 0 0 0
1943 0 ▶ if ($real_block) {
Branch: 1 branch
BranchTrueFalseTotal
if ($real_block) { } 0 0 0
1944 0 $kid = $op->first->sibling; # skip enter
1945 0 ▶ if (is_miniwhile($kid)) {
Branch: 2 branches
BranchTrueFalseTotal
if (is_miniwhile($kid)) { } 0 0 0
elsif ($kid->type == 411 and $kid->private & 128 and $kid->sibling->type == 408 and null($kid->sibling->sibling)) { } 0 0 0
1946 0 my $top = $kid->first;
1947 0 my $name = $top->name;
1948 0 ▶ if ($name eq "and") {
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'and') { } 0 0 0
elsif ($name eq 'or') { } 0 0 0
1949 0 $name = $self->keyword("while");
1950 } elsif ($name eq "or") {
1951 0 $name = $self->keyword("until");
1952 } else { # no conditional -> while 1 or until 0
1953 0 return $self->deparse($top->first, 1) . " "
1954 . $self->keyword("while") . " 1";
1955 }
1956 0 my $cond = $top->first;
1957 0 my $body = $cond->sibling->first; # skip lineseq
1958 0 $cond = $self->deparse($cond, 1);
1959 0 $body = $self->deparse($body, 1);
1960 0 return "$body $name $cond";
1961 }
1962 ▶ elsif($kid->type == OP_PUSHDEFER &&
Condition0%0/9
$kid->type == 411 and $kid->private & 128 and $kid->sibling->type == 408 and null($kid->sibling->sibling)
!ll&&!rl&&r
000
$kid->type == 411 and $kid->private & 128 and $kid->sibling->type == 408
!ll&&!rl&&r
000
$kid->type == 411 and $kid->private & 128
!ll&&!rl&&r
000
MC/DC0%0/4
$kid->type == 411 and $kid->private & 128 and $kid->sibling->type == 408 and null($kid->sibling->sibling)
$kid->type == 411 $kid->private & 128 $kid->sibling->type == 408 null($kid->sibling->sibling)
Truth table0%0/5
A and B and C and D
A= $kid->type == 411B= $kid->private & 128C= $kid->sibling->type == 408D= null($kid->sibling->sibling)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1963 $kid->private & OPpDEFER_FINALLY &&
1964 $kid->sibling->type == OP_LEAVETRYCATCH &&
1965 null($kid->sibling->sibling)) {
1966 0 return $self->pp_leavetrycatch_with_finally($kid->sibling, $kid, $cx);
1967 }
1968 } else {
1969 0 $kid = $op->first;
1970 0 ▶ if ($kid->name eq "null" && $kid->targ == OP_STUB) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->name eq "null" and $kid->targ == 1) 0 0 0
Condition0%0/3
$kid->name eq "null" and $kid->targ == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$kid->name eq "null" and $kid->targ == 1
$kid->name eq "null" $kid->targ == 1
Truth table0%0/3
A and B
A= $kid->name eq "null"B= $kid->targ == 1
ABresult
0X0
100
111
1971 0 $leadingstub = "();";
1972 0 $kid = $kid->sibling;
1973 }
1974 }
1975 0 ▶ for (; !null($kid); $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
1976 0 push @kids, $kid;
1977 }
1978 0 ▶ if ($cx > 0) { # inside an expression, (a do {} while for lineseq)
Branch: 1 branch
BranchTrueFalseTotal
if ($cx > 0) { } 0 0 0
1979 0 my $body = $self->lineseq($op, 0, @kids);
1980 0 ▶ return is_lexical_subs(@kids)
Branch: 2 branches
BranchTrueFalseTotal
is_lexical_subs(@kids) ? : 0 0 0
$self->lex_in_scope('&do') ? : 0 0 0
1981 ? $body
1982 : ($self->lex_in_scope("&do") ? "CORE::do" : "do")
1983 . " {\n\t$body\n\b}";
1984 } else {
1985 0 my $lineseq = $self->lineseq($op, $cx, @kids);
1986 0 ▶ return (length ($lineseq) ? "$lineseq;"
Branch: 2 branches
BranchTrueFalseTotal
length $lineseq ? : 0 0 0
$leadingstub ? : 0 0 0
1987 : $leadingstub
1988 ? $leadingstub
1989 : "");
1990 }
1991 }
1992  
1993 0 ▶sub pp_scope { scopeop(0, @_); }
Subroutine pp_scope: not called CC=1 SCAR=6.9
Pod undocumented
1994 0 ▶sub pp_lineseq { scopeop(0, @_); }
Subroutine pp_lineseq: not called CC=1 SCAR=6.9
Pod undocumented
1995 0 ▶sub pp_leave { scopeop(1, @_); }
Subroutine pp_leave: not called CC=1 SCAR=6.9
Pod undocumented
1996  
1997 # This is a special case of scopeop and lineseq, for the case of the
1998 # main_root. The difference is that we print the output statements as
1999 # soon as we get them, for the sake of impatient users.
2000 sub deparse_root {
2001 0 ▶ my $self = shift;
Subroutine deparse_root: not called CC=3 SCAR=24.8
Pod undocumented
2002 0 my($op) = @_;
2003 local(@$self{qw'curstash warnings hints hinthash'})
2004 0 = @$self{qw'curstash warnings hints hinthash'};
2005 0 my @kids;
2006 0 ▶ return if null $op->first; # Can happen, e.g., for Bytecode without -k
Branch: 1 branch
BranchTrueFalseTotal
if null($op->first) 0 0 0
2007 0 ▶ for (my $kid = $op->first->sibling; !null($kid); $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
2008 0 push @kids, $kid;
2009 }
2010 $self->walk_lineseq($op, \@kids,
2011 0 ▶ sub { return unless length $_[0];
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
unless length $_[0] 0 0 0
2012 0 print $self->indent($_[0].';');
2013 0 ▶ print "\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $_[1] == $#kids 0 0 0
2014 unless $_[1] == $#kids;
2015 0 });
2016 }
2017  
2018 sub walk_lineseq {
2019 0 ▶ my ($self, $op, $kids, $callback) = @_;
Subroutine walk_lineseq: not called CC=6 SCAR=37.4
Pod undocumented
2020 0 my @kids = @$kids;
2021 0 ▶ for (my $i = 0; $i < @kids; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @kids) 0 0 0
2022 0 my $expr = "";
2023 0 ▶ if (is_state $kids[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_state($kids[$i])) 0 0 0
2024 0 $expr = $self->deparse($kids[$i++], 0);
2025 0 ▶ if ($i > $#kids) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i > $#kids) 0 0 0
2026 0 $callback->($expr, $i);
2027 0 last;
2028 }
2029 }
2030 0 ▶ if (is_for_loop($kids[$i])) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_for_loop($kids[$i])) 0 0 0
2031 0 ▶ $callback->($expr . $self->for_loop($kids[$i], 0),
Branch: 1 branch
BranchTrueFalseTotal
$kids[$i]->sibling->name eq 'unstack' ? : 0 0 0
2032 $i += $kids[$i]->sibling->name eq "unstack" ? 2 : 1);
2033 0 next;
2034 }
2035 0 my $expr2 = $self->deparse($kids[$i], (@kids != 1)/2);
2036 0 $expr2 =~ s/^sub :(?!:)/+sub :/; # statement label otherwise
2037 0 $expr .= $expr2;
2038 0 $callback->($expr, $i);
2039 }
2040 }
2041  
2042 # The BEGIN {} is used here because otherwise this code isn't executed
2043 # when you run B::Deparse on itself.
2044 my %globalnames;
2045 BEGIN { map($globalnames{$_}++, "SIG", "STDIN", "STDOUT", "STDERR", "INC",
2046 "ENV", "ARGV", "ARGVOUT", "_"); }
2047  
2048 sub gv_name {
2049 0 ▶ my $self = shift;
Subroutine gv_name: not called CC=19 SCAR=59.4
Pod undocumented
2050 0 my $gv = shift;
2051 0 my $raw = shift;
2052 #Carp::confess() unless ref($gv) eq "B::GV";
2053 0 ▶ my $cv = $gv->FLAGS & SVf_ROK ? $gv->RV : 0;
Branch: 1 branch
BranchTrueFalseTotal
$gv->FLAGS & 2048 ? : 0 0 0
2054 0 ▶ my $stash = ($cv || $gv)->STASH->NAME;
Condition0%0/3
$cv || $gv
l!l&&r!l&&!r
000
MC/DC0%0/2
$cv || $gv
$cv $gv
Truth table0%0/3
A || B
A= $cvB= $gv
ABresult
1X1
011
000
2055 0 ▶ my $name = $raw
Branch: 3 branches
BranchTrueFalseTotal
$raw ? : 0 0 0
$cv ? : 0 0 0
$cv ? : 0 0 0
Condition0%0/6
$cv->NAME_HEK or $cv->GV->NAME
l!l&&r!l&&!r
000
$cv->NAME_HEK || $cv->GV->NAME
l!l&&r!l&&!r
000
MC/DC0%0/2
$cv->NAME_HEK or $cv->GV->NAME
$cv->NAME_HEK $cv->GV->NAME
MC/DC0%0/2
$cv->NAME_HEK || $cv->GV->NAME
$cv->NAME_HEK $cv->GV->NAME
Truth table0%0/3
A or B
A= $cv->NAME_HEKB= $cv->GV->NAME
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $cv->NAME_HEKB= $cv->GV->NAME
ABresult
1X1
011
000
2056 ? $cv ? $cv->NAME_HEK || $cv->GV->NAME : $gv->NAME
2057 : $cv
2058 ? B::safename($cv->NAME_HEK || $cv->GV->NAME)
2059 : $gv->SAFENAME;
2060 0 ▶ if ($stash eq 'main' && $name =~ /^::/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($stash eq 'main' and $name =~ /^::/) { } 0 0 0
elsif ($stash eq 'main' and $globalnames{$name} || $name =~ /^[^A-Za-z_:]/ or $stash eq $self->{'curstash'} and not $globalnames{$name} and $stash eq 'main' || !($name =~ /::/)) { } 0 0 0
Condition0%0/3
$stash eq "main" and $name =~ /^::/
!ll&&!rl&&r
000
MC/DC0%0/2
$stash eq "main" and $name =~ /^::/
$stash eq "main" $name =~ /^::/
Truth table0%0/3
A and B
A= $stash eq "main"B= $name =~ /^::/
ABresult
0X0
100
111
2061 0 $stash = '::';
2062 }
2063 ▶ elsif (($stash eq 'main'
Condition0%0/18
$stash eq "main" and $globalnames{$name} || $name =~ /^[^A-Za-z_:]/ or $stash eq $self->{"curstash"} and not $globalnames{$name} and $stash eq "main" || !($name =~ /::/)
l!l&&r!l&&!r
000
$stash eq "main" and $globalnames{$name} || $name =~ /^[^A-Za-z_:]/
!ll&&!rl&&r
000
$globalnames{$name} or $name =~ /^[^A-Za-z_:]/
l!l&&r!l&&!r
000
$stash eq $self->{"curstash"} and not $globalnames{$name} and $stash eq "main" || !($name =~ /::/)
!ll&&!rl&&r
000
$stash eq $self->{"curstash"} and not $globalnames{$name}
!ll&&!rl&&r
000
$stash eq "main" or not $name =~ /::/
l!l&&r!l&&!r
000
MC/DC0%0/7
$stash eq "main" and $globalnames{$name} || $name =~ /^[^A-Za-z_:]/ or $stash eq $self->{"curstash"} and not $globalnames{$name} and $stash eq "main" || !($name =~ /::/)
$stash eq "main" $globalnames{$name} $name =~ /^[^A-Za-z_:]/ $stash eq $self->{"curstash"} not $globalnames{$name} $stash eq "main" not $name =~ /::/
Truth table0%0/12
A and B or C or D and not(E) and F or not(G)
A= $stash eq "main"B= $globalnames{$name}C= $name =~ /^[^A-Za-z_:]/D= $stash eq $self->{"curstash"}E= not $globalnames{$name}F= $stash eq "main"G= not $name =~ /::/
ABCDEFGresult
11XXXXX1
101XXXX1
0XX111X1
0XX11011
100111X1
10011011
0XX0XXX0
0XX10XX0
0XX11000
1000XXX0
10010XX0
10011000
2064 && ($globalnames{$name} || $name =~ /^[^A-Za-z_:]/))
2065 or ($stash eq $self->{'curstash'} && !$globalnames{$name}
2066 && ($stash eq 'main' || $name !~ /::/))
2067 )
2068 {
2069 0 $stash = "";
2070 } else {
2071 0 $stash = $stash . "::";
2072 }
2073 0 ▶ if (!$raw and $name =~ /^(\^..|{)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $raw and $name =~ /^(\^..|{)/) 0 0 0
Condition0%0/3
not $raw and $name =~ /^(\^..|{)/
!ll&&!rl&&r
000
MC/DC0%0/2
not $raw and $name =~ /^(\^..|{)/
not $raw $name =~ /^(\^..|{)/
Truth table0%0/3
not(A) and B
A= not $rawB= $name =~ /^(\^..|{)/
ABresult
0X0
100
111
2074 0 $name = "{$name}"; # ${^WARNING_BITS}, etc and ${
2075 }
2076 0 return $stash . $name;
2077 }
2078  
2079 # Return the name to use for a stash variable.
2080 # If a lexical with the same name is in scope, or
2081 # if strictures are enabled, it may need to be
2082 # fully-qualified.
2083 sub stash_variable {
2084 0 ▶ my ($self, $prefix, $name, $cx) = @_;
Subroutine stash_variable: not called CC=13 SCAR=52.0
Pod undocumented
2085  
2086 0 ▶ return $prefix.$self->maybe_qualify($prefix, $name) if $name =~ /::/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /::/ 0 0 0
2087  
2088 0 ▶ unless ($prefix eq '$' || $prefix eq '@' || $prefix eq '&' || #'
Branch: 1 branch
BranchTrueFalseTotal
unless ($prefix eq "\$" or $prefix eq "\@" or $prefix eq "&" or $prefix eq "%" or $prefix eq "\$#") 0 0 0
Condition0%0/12
$prefix eq "\$" or $prefix eq "\@" or $prefix eq "&" or $prefix eq "%" or $prefix eq "\$#"
l!l&&r!l&&!r
000
$prefix eq "\$" or $prefix eq "\@" or $prefix eq "&" or $prefix eq "%"
l!l&&r!l&&!r
000
$prefix eq "\$" or $prefix eq "\@" or $prefix eq "&"
l!l&&r!l&&!r
000
$prefix eq "\$" or $prefix eq "\@"
l!l&&r!l&&!r
000
MC/DC0%0/5
$prefix eq "\$" or $prefix eq "\@" or $prefix eq "&" or $prefix eq "%" or $prefix eq "\$#"
$prefix eq "\$" $prefix eq "\@" $prefix eq "&" $prefix eq "%" $prefix eq "\$#"
Truth table0%0/6
A or B or C or D or E
A= $prefix eq "\$"B= $prefix eq "\@"C= $prefix eq "&"D= $prefix eq "%"E= $prefix eq "\$#"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
2089 $prefix eq '%' || $prefix eq '$#') {
2090 0 return "$prefix$name";
2091 }
2092  
2093 0 ▶ if ($name =~ /^[^[:alpha:]_+-]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^[^[:alpha:]_+-]$/) 0 0 0
2094 0 ▶ if (defined $cx && $cx == 26) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cx and $cx == 26) 0 0 0
Condition0%0/3
defined $cx and $cx == 26
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cx and $cx == 26
defined $cx $cx == 26
Truth table0%0/3
A and B
A= defined $cxB= $cx == 26
ABresult
0X0
100
111
2095 0 ▶ if ($prefix eq '@') {
Branch: 2 branches
BranchTrueFalseTotal
if ($prefix eq '@') { } 0 0 0
elsif ($name eq '#') { } 0 0 0
2096 0 return "$prefix\{$name}";
2097 }
2098 0 elsif ($name eq '#') { return '${#}' } # "${#}a" vs "$#a"
2099 }
2100 0 ▶ if ($prefix eq '$#') {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix eq "\$#") 0 0 0
2101 0 return "\$#{$name}";
2102 }
2103 }
2104  
2105 0 return $prefix . $self->maybe_qualify($prefix, $name);
2106 }
2107  
2108 my %unctrl = # portable to EBCDIC
2109 (
2110 "\c@" => '@', # unused
2111 "\cA" => 'A',
2112 "\cB" => 'B',
2113 "\cC" => 'C',
2114 "\cD" => 'D',
2115 "\cE" => 'E',
2116 "\cF" => 'F',
2117 "\cG" => 'G',
2118 "\cH" => 'H',
2119 "\cI" => 'I',
2120 "\cJ" => 'J',
2121 "\cK" => 'K',
2122 "\cL" => 'L',
2123 "\cM" => 'M',
2124 "\cN" => 'N',
2125 "\cO" => 'O',
2126 "\cP" => 'P',
2127 "\cQ" => 'Q',
2128 "\cR" => 'R',
2129 "\cS" => 'S',
2130 "\cT" => 'T',
2131 "\cU" => 'U',
2132 "\cV" => 'V',
2133 "\cW" => 'W',
2134 "\cX" => 'X',
2135 "\cY" => 'Y',
2136 "\cZ" => 'Z',
2137 "\c[" => '[', # unused
2138 "\c\\" => '\\', # unused
2139 "\c]" => ']', # unused
2140 "\c_" => '_', # unused
2141 );
2142  
2143 # Return just the name, without the prefix. It may be returned as a quoted
2144 # string. The second return value is a boolean indicating that.
2145 sub stash_variable_name {
2146 0 ▶ my($self, $prefix, $gv) = @_;
Subroutine stash_variable_name: not called CC=3 SCAR=24.8
Pod undocumented
2147 0 my $name = $self->gv_name($gv, 1);
2148 0 $name = $self->maybe_qualify($prefix,$name);
2149 0 ▶ if ($name =~ /^(?:\S|(?!\d)[\ca-\cz]?(?:\w|::)*|\d+)\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^(?:\S|(?!\d)[\ca-\cz]?(?:\w|::)*|\d+)\z/) { } 0 0 0
2150 0 $name =~ s/^([\ca-\cz])/'^' . $unctrl{$1}/e;
2151 0 ▶ $name =~ /^(\^..|{)/ and $name = "{$name}";
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /^(\^..|{)/ and $name = "{$name}" 0 0 0
2152 0 return $name, 0; # not quoted
2153 }
2154 else {
2155 0 single_delim("q", "'", $name, $self), 1;
2156 }
2157 }
2158  
2159 sub maybe_qualify {
2160 0 ▶ my ($self,$prefix,$name) = @_;
Subroutine maybe_qualify: not called CC=12 SCAR=50.5
Pod undocumented
2161 0 ▶ my $v = ($prefix eq '$#' ? '@' : $prefix) . $name;
Branch: 1 branch
BranchTrueFalseTotal
$prefix eq '$#' ? : 0 0 0
2162 0 ▶ if ($prefix eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix eq "") 0 0 0
2163 0 ▶ $name .= "::" if $name =~ /(?:\ACORE::[^:]*|::)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /(?:\ACORE::[^:]*|::)\z/ 0 0 0
2164 0 return $name;
2165 }
2166 0 ▶ return $name if $name =~ /::/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /::/ 0 0 0
2167 return $self->{'curstash'}.'::'. $name
2168 if
2169 $name =~ /^(?!\d)\w/ # alphabetic
2170 && $v !~ /^\$[ab]\z/ # not $a or $b
2171 && $v =~ /\A[\$\@\%\&]/ # scalar, array, hash, or sub
2172 && !$globalnames{$name} # not a global name
2173 && $self->{hints} & $strict_bits{vars} # strict vars
2174 0 ▶ && !$self->lex_in_scope($v,1) # no "our"
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /^(?!\d)\w/ and not $v =~ /^\$[ab]\z/ and $v =~ /\A[\$\@\%\&]/ and not $globalnames{$name} and $self->{"hints"} & $strict_bits{"vars"} and not $self->lex_in_scope($v, 1) or $self->lex_in_scope($v) 0 0 0
Condition0%0/18
$name =~ /^(?!\d)\w/ and not $v =~ /^\$[ab]\z/ and $v =~ /\A[\$\@\%\&]/ and not $globalnames{$name} and $self->{"hints"} & $strict_bits{"vars"} and not $self->lex_in_scope($v, 1) or $self->lex_in_scope($v)
l!l&&r!l&&!r
000
$name =~ /^(?!\d)\w/ and not $v =~ /^\$[ab]\z/ and $v =~ /\A[\$\@\%\&]/ and not $globalnames{$name} and $self->{"hints"} & $strict_bits{"vars"} and not $self->lex_in_scope($v, 1)
!ll&&!rl&&r
000
$name =~ /^(?!\d)\w/ and not $v =~ /^\$[ab]\z/ and $v =~ /\A[\$\@\%\&]/ and not $globalnames{$name} and $self->{"hints"} & $strict_bits{"vars"}
!ll&&!rl&&r
000
$name =~ /^(?!\d)\w/ and not $v =~ /^\$[ab]\z/ and $v =~ /\A[\$\@\%\&]/ and not $globalnames{$name}
!ll&&!rl&&r
000
$name =~ /^(?!\d)\w/ and not $v =~ /^\$[ab]\z/ and $v =~ /\A[\$\@\%\&]/
!ll&&!rl&&r
000
$name =~ /^(?!\d)\w/ and not $v =~ /^\$[ab]\z/
!ll&&!rl&&r
000
MC/DC0%0/7
$name =~ /^(?!\d)\w/ and not $v =~ /^\$[ab]\z/ and $v =~ /\A[\$\@\%\&]/ and not $globalnames{$name} and $self->{"hints"} & $strict_bits{"vars"} and not $self->lex_in_scope($v, 1) or $self->lex_in_scope($v)
$name =~ /^(?!\d)\w/ not $v =~ /^\$[ab]\z/ $v =~ /\A[\$\@\%\&]/ not $globalnames{$name} $self->{"hints"} & $strict_bits{"vars"} not $self->lex_in_scope($v, 1) $self->lex_in_scope($v)
Truth table0%0/13
A and not(B) and C and not(D) and E and not(F) or G
A= $name =~ /^(?!\d)\w/B= not $v =~ /^\$[ab]\z/C= $v =~ /\A[\$\@\%\&]/D= not $globalnames{$name}E= $self->{"hints"} & $strict_bits{"vars"}F= not $self->lex_in_scope($v, 1)G= $self->lex_in_scope($v)
ABCDEFGresult
111111X1
0XXXXX11
10XXXX11
110XXX11
1110XX11
11110X11
11111011
0XXXXX00
10XXXX00
110XXX00
1110XX00
11110X00
11111000
2175 or $self->lex_in_scope($v); # conflicts with "my" variable
2176 0 return $name;
2177 }
2178  
2179 sub lex_in_scope {
2180 0 ▶ my ($self, $name, $our) = @_;
Subroutine lex_in_scope: not called CC=8 SCAR=42.8
Pod undocumented
2181 0 ▶ substr $name, 0, 0, = $our ? 'o' : 'm'; # our/my
Branch: 1 branch
BranchTrueFalseTotal
$our ? : 0 0 0
2182 0 ▶ $self->populate_curcvlex() if !defined $self->{'curcvlex'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"curcvlex"} 0 0 0
2183  
2184 0 ▶ return 0 if !defined($self->{'curcop'});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"curcop"} 0 0 0
2185 0 my $seq = $self->{'curcop'}->cop_seq;
2186 0 ▶ return 0 if !exists $self->{'curcvlex'}{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"curcvlex"}{$name} 0 0 0
2187 0 for my $a (@{$self->{'curcvlex'}{$name}}) {
2188 0 my ($st, $en) = @$a;
2189 0 ▶ return 1 if $seq > $st && $seq <= $en;
Branch: 1 branch
BranchTrueFalseTotal
if $seq > $st and $seq <= $en 0 0 0
Condition0%0/3
$seq > $st and $seq <= $en
!ll&&!rl&&r
000
MC/DC0%0/2
$seq > $st and $seq <= $en
$seq > $st $seq <= $en
Truth table0%0/3
A and B
A= $seq > $stB= $seq <= $en
ABresult
0X0
100
111
2190 }
2191 0 return 0;
2192 }
2193  
2194 sub populate_curcvlex {
2195 0 ▶ my $self = shift;
Subroutine populate_curcvlex: not called CC=9 SCAR=45.0
Pod undocumented
2196 0 ▶ for (my $cv = $self->{'curcv'}; class($cv) eq "CV"; $cv = $cv->OUTSIDE) {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($cv) eq "CV") 0 0 0
2197 0 my $padlist = $cv->PADLIST;
2198 # an undef CV still in lexical chain
2199 0 ▶ next if class($padlist) eq "SPECIAL";
Branch: 1 branch
BranchTrueFalseTotal
if B::Deparse::class($padlist) eq "SPECIAL" 0 0 0
2200 0 my @padlist = $padlist->ARRAY;
2201 0 my @ns = $padlist[0]->ARRAY;
2202  
2203 0 ▶ for (my $i=0; $i<@ns; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @ns) 0 0 0
2204 0 ▶ next if class($ns[$i]) eq "SPECIAL";
Branch: 1 branch
BranchTrueFalseTotal
if B::Deparse::class($ns[$i]) eq "SPECIAL" 0 0 0
2205 0 ▶ if (class($ns[$i]) eq "PV") {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($ns[$i]) eq "PV") 0 0 0
2206 # Probably that pesky lexical @_
2207 0 next;
2208 }
2209 0 my $name = $ns[$i]->PVX;
2210 0 ▶ next unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 0 0
2211 0 ▶ my ($seq_st, $seq_en) =
Branch: 1 branch
BranchTrueFalseTotal
$ns[$i]->FLAGS & 16777216 ? : 0 0 0
2212 ($ns[$i]->FLAGS & SVf_FAKE)
2213 ? (0, 999999)
2214 : ($ns[$i]->COP_SEQ_RANGE_LOW, $ns[$i]->COP_SEQ_RANGE_HIGH);
2215  
2216 0 push @{$self->{'curcvlex'}{
2217 0 ▶ ($ns[$i]->FLAGS & PADNAMEf_OUR ? 'o' : 'm') . $name
Branch: 1 branch
BranchTrueFalseTotal
$ns[$i]->FLAGS & 16 ? : 0 0 0
2218 }}, [$seq_st, $seq_en, $ns[$i]];
2219 }
2220 }
2221 }
2222  
2223 0 ▶sub find_scope_st { ((find_scope(@_))[0]); }
Subroutine find_scope_st: not called CC=1 SCAR=6.9
Pod undocumented
2224 0 ▶sub find_scope_en { ((find_scope(@_))[1]); }
Subroutine find_scope_en: not called CC=1 SCAR=6.9
Pod undocumented
2225  
2226 # Recurses down the tree, looking for pad variable introductions and COPs
2227 sub find_scope {
2228 0 ▶ my ($self, $op, $scope_st, $scope_en) = @_;
Subroutine find_scope: not called CC=17 SCAR=57.2
Pod undocumented
2229 0 ▶ carp("Undefined op in find_scope") if !defined $op;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $op 0 0 0
2230 0 ▶ return ($scope_st, $scope_en) unless $op->flags & OPf_KIDS;
Branch: 1 branch
BranchTrueFalseTotal
unless $op->flags & 4 0 0 0
2231  
2232 0 my @queue = ($op);
2233 0 ▶ while(my $op = shift @queue ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $op = shift @queue) 0 0 0
2234 0 ▶ for (my $o=$op->first; $$o; $o=$o->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$o) 0 0 0
2235 0 ▶ if ($o->name =~ /^pad.v$/ && $o->private & OPpLVAL_INTRO) {
Branch: 3 branches
BranchTrueFalseTotal
if ($o->name =~ /^pad.v$/ and $o->private & 128) { } 0 0 0
elsif (is_state($o)) { } 0 0 0
elsif ($o->flags & 4) { } 0 0 0
Condition0%0/3
$o->name =~ /^pad.v$/ and $o->private & 128
!ll&&!rl&&r
000
MC/DC0%0/2
$o->name =~ /^pad.v$/ and $o->private & 128
$o->name =~ /^pad.v$/ $o->private & 128
Truth table0%0/3
A and B
A= $o->name =~ /^pad.v$/B= $o->private & 128
ABresult
0X0
100
111
2236 0 my $s = int($self->padname_sv($o->targ)->COP_SEQ_RANGE_LOW);
2237 0 my $e = $self->padname_sv($o->targ)->COP_SEQ_RANGE_HIGH;
2238 0 ▶ $scope_st = $s if !defined($scope_st) || $s < $scope_st;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $scope_st or $s < $scope_st 0 0 0
Condition0%0/3
not defined $scope_st or $s < $scope_st
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $scope_st or $s < $scope_st
not defined $scope_st $s < $scope_st
Truth table0%0/3
not(A) or B
A= not defined $scope_stB= $s < $scope_st
ABresult
1X1
011
000
2239 0 ▶ $scope_en = $e if !defined($scope_en) || $e > $scope_en;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $scope_en or $e > $scope_en 0 0 0
Condition0%0/3
not defined $scope_en or $e > $scope_en
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $scope_en or $e > $scope_en
not defined $scope_en $e > $scope_en
Truth table0%0/3
not(A) or B
A= not defined $scope_enB= $e > $scope_en
ABresult
1X1
011
000
2240 0 return ($scope_st, $scope_en);
2241 }
2242 elsif (is_state($o)) {
2243 0 my $c = $o->cop_seq;
2244 0 ▶ $scope_st = $c if !defined($scope_st) || $c < $scope_st;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $scope_st or $c < $scope_st 0 0 0
Condition0%0/3
not defined $scope_st or $c < $scope_st
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $scope_st or $c < $scope_st
not defined $scope_st $c < $scope_st
Truth table0%0/3
not(A) or B
A= not defined $scope_stB= $c < $scope_st
ABresult
1X1
011
000
2245 0 ▶ $scope_en = $c if !defined($scope_en) || $c > $scope_en;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $scope_en or $c > $scope_en 0 0 0
Condition0%0/3
not defined $scope_en or $c > $scope_en
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $scope_en or $c > $scope_en
not defined $scope_en $c > $scope_en
Truth table0%0/3
not(A) or B
A= not defined $scope_enB= $c > $scope_en
ABresult
1X1
011
000
2246 0 return ($scope_st, $scope_en);
2247 }
2248 elsif ($o->flags & OPf_KIDS) {
2249 0 unshift (@queue, $o);
2250 }
2251 }
2252 }
2253  
2254 0 return ($scope_st, $scope_en);
2255 }
2256  
2257 # Returns a list of subs which should be inserted before the COP
2258 sub cop_subs {
2259 0 ▶ my ($self, $op, $out_seq) = @_;
Subroutine cop_subs: not called CC=3 SCAR=24.8
Pod undocumented
2260 0 my $seq = $op->cop_seq;
2261 0 ▶ $seq = $out_seq if defined($out_seq) && $out_seq < $seq;
Branch: 1 branch
BranchTrueFalseTotal
if defined $out_seq and $out_seq < $seq 0 0 0
Condition0%0/3
defined $out_seq and $out_seq < $seq
!ll&&!rl&&r
000
MC/DC0%0/2
defined $out_seq and $out_seq < $seq
defined $out_seq $out_seq < $seq
Truth table0%0/3
A and B
A= defined $out_seqB= $out_seq < $seq
ABresult
0X0
100
111
2262 0 return $self->seq_subs($seq);
2263 }
2264  
2265 sub seq_subs {
2266 0 ▶ my ($self, $seq) = @_;
Subroutine seq_subs: not called CC=10 SCAR=47.0
Pod undocumented
2267 0 my @text;
2268 #push @text, "# ($seq)\n";
2269  
2270 0 ▶ return "" if !defined $seq;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $seq 0 0 0
2271 0 my @pending;
2272 0 ▶ while (scalar(@{$self->{'subs_todo'}})
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"subs_todo"};} and $seq > $self->{"subs_todo"}[0][0]) 0 0 0
Condition0%0/3
scalar @{$self->{"subs_todo"};} and $seq > $self->{"subs_todo"}[0][0]
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @{$self->{"subs_todo"};} and $seq > $self->{"subs_todo"}[0][0]
scalar @{$self->{"subs_todo"};} $seq > $self->{"subs_todo"}[0][0]
Truth table0%0/3
A and B
A= scalar @{$self->{"subs_todo"};}B= $seq > $self->{"subs_todo"}[0][0]
ABresult
0X0
100
111
2273 and $seq > $self->{'subs_todo'}[0][0]) {
2274 0 my $cv = $self->{'subs_todo'}[0][1];
2275 # Skip the OUTSIDE check for lexical subs. We may be deparsing a
2276 # cloned anon sub with lexical subs declared in it, in which case
2277 # the OUTSIDE pointer points to the anon protosub.
2278 0 my $lexical = ref $self->{'subs_todo'}[0][3];
2279 0 ▶ my $outside = !$lexical && $cv && $cv->OUTSIDE;
Condition0%0/6
!$lexical && $cv && $cv->OUTSIDE
!ll&&!rl&&r
000
not $lexical and $cv
!ll&&!rl&&r
000
MC/DC0%0/3
!$lexical && $cv && $cv->OUTSIDE
not $lexical $cv $cv->OUTSIDE
Truth table0%0/4
not(A) and B && C
A= not $lexicalB= $cvC= $cv->OUTSIDE
ABCresult
0XX0
10X0
1100
1111
2280 0 ▶ if (!$lexical and $cv
Branch: 1 branch
BranchTrueFalseTotal
if (not $lexical and $cv and ${$cv->OUTSIDE or \0;} != ${$self->{"curcv"};}) 0 0 0
Condition0%0/6
not $lexical and $cv and ${$cv->OUTSIDE or \0;} != ${$self->{"curcv"};}
!ll&&!rl&&r
000
not $lexical and $cv
!ll&&!rl&&r
000
MC/DC0%0/3
not $lexical and $cv and ${$cv->OUTSIDE or \0;} != ${$self->{"curcv"};}
not $lexical $cv ${$cv->OUTSIDE or \0;} != ${$self->{"curcv"};}
Truth table0%0/4
not(A) and B and C
A= not $lexicalB= $cvC= ${$cv->OUTSIDE or \0;} != ${$self->{"curcv"};}
ABCresult
0XX0
10X0
1100
1111
2281 0 ▶ and ${$cv->OUTSIDE || \0} != ${$self->{'curcv'}})
Condition0%0/2
$cv->OUTSIDE || \0
l!l
00
MC/DC0%0/1
$cv->OUTSIDE || \0
$cv->OUTSIDE
Truth table0%0/2
A
A= $cv->OUTSIDE
Aresult
11
00
2282 {
2283 0 push @pending, shift @{$self->{'subs_todo'}};
2284 0 next;
2285 }
2286 0 push @text, $self->next_todo;
2287 }
2288 0 unshift @{$self->{'subs_todo'}}, @pending;
2289 0 return @text;
2290 }
2291  
2292 sub _features_from_bundle {
2293 0 ▶ my ($hints, $hh) = @_;
Subroutine _features_from_bundle: not called CC=2 SCAR=17.9
2294 0 foreach (@{$feature::feature_bundle{@feature::hint_bundles[$hints >> $feature::hint_shift]}}) {
2295 0 $hh->{$feature::feature{$_}} = 1;
2296 }
2297 0 return $hh;
2298 }
2299  
2300 # generate any pragmas, 'package foo' etc needed to synchronise
2301 # with the given cop
2302  
2303 sub pragmata {
2304 0 ▶ my $self = shift;
Subroutine pragmata: not called CC=17 SCAR=57.2
Pod undocumented
2305 0 my($op) = @_;
2306  
2307 0 my @text;
2308  
2309 0 my $stash = $op->stashpv;
2310 0 ▶ if ($stash ne $self->{'curstash'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stash ne $self->{"curstash"}) 0 0 0
2311 0 push @text, $self->keyword("package") . " $stash;\n";
2312 0 $self->{'curstash'} = $stash;
2313 }
2314  
2315 0 my $warnings = $op->warnings;
2316 0 my $warning_bits;
2317 0 ▶ if ($warnings->isa("B::SPECIAL") && $$warnings == 4) {
Branch: 3 branches
BranchTrueFalseTotal
if ($warnings->isa('B::SPECIAL') and $$warnings == 4) { } 0 0 0
elsif ($warnings->isa('B::SPECIAL') and $$warnings == 5) { } 0 0 0
elsif ($warnings->isa('B::SPECIAL')) { } 0 0 0
Condition0%0/3
$warnings->isa("B::SPECIAL") and $$warnings == 4
!ll&&!rl&&r
000
MC/DC0%0/2
$warnings->isa("B::SPECIAL") and $$warnings == 4
$warnings->isa("B::SPECIAL") $$warnings == 4
Truth table0%0/3
A and B
A= $warnings->isa("B::SPECIAL")B= $$warnings == 4
ABresult
0X0
100
111
2318 0 $warning_bits = $warnings::Bits{"all"};
2319 }
2320 ▶ elsif ($warnings->isa("B::SPECIAL") && $$warnings == 5) {
Condition0%0/3
$warnings->isa("B::SPECIAL") and $$warnings == 5
!ll&&!rl&&r
000
MC/DC0%0/2
$warnings->isa("B::SPECIAL") and $$warnings == 5
$warnings->isa("B::SPECIAL") $$warnings == 5
Truth table0%0/3
A and B
A= $warnings->isa("B::SPECIAL")B= $$warnings == 5
ABresult
0X0
100
111
2321 0 $warning_bits = $warnings::NONE;
2322 }
2323 elsif ($warnings->isa("B::SPECIAL")) {
2324 0 $warning_bits = undef;
2325 }
2326 else {
2327 0 $warning_bits = $warnings->PV;
2328 }
2329  
2330 0 my ($w1, $w2);
2331 # The number of valid bit positions may have grown (by a byte or
2332 # more) since the last warnings state, by custom warnings
2333 # categories being registered in the meantime. Normalise the
2334 # bitmasks first so they may be fairly compared.
2335 $w1 = defined($self->{warnings})
2336 ? warnings::_expand_bits($self->{warnings})
2337 0 ▶ : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'warnings'} ? : 0 0 0
2338 0 ▶ $w2 = defined($warning_bits)
Branch: 1 branch
BranchTrueFalseTotal
defined $warning_bits ? : 0 0 0
2339 ? warnings::_expand_bits($warning_bits)
2340 : undef;
2341  
2342 0 ▶ if (defined($w2) and !defined($w1) || $w1 ne $w2) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $w2 and !defined($w1) || $w1 ne $w2) 0 0 0
Condition0%0/6
defined $w2 and !defined($w1) || $w1 ne $w2
!ll&&!rl&&r
000
not defined $w1 or $w1 ne $w2
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $w2 and !defined($w1) || $w1 ne $w2
defined $w2 not defined $w1 $w1 ne $w2
Truth table0%0/4
A and not(B) or C
A= defined $w2B= not defined $w1C= $w1 ne $w2
ABCresult
0XX0
1000
11X1
1011
2343 0 push @text, $self->declare_warnings($w1, $w2);
2344 0 $self->{'warnings'} = $w2;
2345 }
2346  
2347 0 my $hints = $op->hints;
2348 0 my $old_hints = $self->{'hints'};
2349 0 ▶ if ($self->{'hints'} != $hints) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"hints"} != $hints) 0 0 0
2350 0 push @text, $self->declare_hints($self->{'hints'}, $hints);
2351 0 $self->{'hints'} = $hints;
2352 }
2353  
2354 0 my $newhh;
2355 0 $newhh = $op->hints_hash->HASH;
2356  
2357 {
2358 # feature bundle hints
2359 0 my $from = $old_hints & $feature::hint_mask;
2360 0 my $to = $ hints & $feature::hint_mask;
2361 0 ▶ if ($from != $to) {
Branch: 1 branch
BranchTrueFalseTotal
if ($from != $to) 0 0 0
2362 0 ▶ if ($to == $feature::hint_mask) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to == $feature::hint_mask) { } 0 0 0
2363 0 ▶ if ($self->{'hinthash'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'hinthash'}) { } 0 0 0
2364 delete $self->{'hinthash'}{$_}
2365 0 for grep /^feature_/, keys %{$self->{'hinthash'}};
2366 }
2367 0 else { $self->{'hinthash'} = {} }
2368 $self->{'hinthash'}
2369 0 = _features_from_bundle($from, $self->{'hinthash'});
2370 }
2371 else {
2372 0 my $bundle =
2373 $feature::hint_bundles[$to >> $feature::hint_shift];
2374 0 $bundle =~ s/(\d[13579])\z/$1+1/e; # 5.11 => 5.12
2375 0 push @text,
2376 $self->keyword("no") . " feature ':all';\n",
2377 $self->keyword("use") . " feature ':$bundle';\n";
2378 }
2379 }
2380 }
2381  
2382 {
2383 0 push @text, $self->declare_hinthash(
2384 $self->{'hinthash'}, $newhh,
2385 $self->{indent_size}, $self->{hints},
2386 0 );
2387 0 $self->{'hinthash'} = $newhh;
2388 }
2389  
2390 0 return join("", @text);
2391 }
2392  
2393  
2394 # Notice how subs and formats are inserted between statements here;
2395 # also $[ assignments and pragmas.
2396 sub pp_nextstate {
2397 0 ▶ my $self = shift;
Subroutine pp_nextstate: not called CC=5 SCAR=34.0
Pod undocumented
2398 0 my($op, $cx) = @_;
2399 0 $self->{'curcop'} = $op;
2400  
2401 0 my @text;
2402  
2403 0 my @subs = $self->cop_subs($op);
2404 0 ▶ if (@subs) {
Branch: 1 branch
BranchTrueFalseTotal
if (@subs) 0 0 0
2405 # Special marker to swallow up the semicolon
2406 0 push @subs, "\cK";
2407 }
2408 0 push @text, @subs;
2409  
2410 0 push @text, $self->pragmata($op);
2411  
2412  
2413 # This should go after of any branches that add statements, to
2414 # increase the chances that it refers to the same line it did in
2415 # the original program.
2416 0 ▶ if ($self->{'linenums'} && $cx != .5) { # $cx == .5 means in a format
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"linenums"} and $cx != "0.5") 0 0 0
Condition0%0/3
$self->{"linenums"} and $cx != "0.5"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"linenums"} and $cx != "0.5"
$self->{"linenums"} $cx != "0.5"
Truth table0%0/3
A and B
A= $self->{"linenums"}B= $cx != "0.5"
ABresult
0X0
100
111
2417 0 push @text, "\f#line " . $op->line .
2418 ' "' . $op->file, qq'"\n';
2419 }
2420  
2421 0 ▶ push @text, $op->label . ": " if $op->label;
Branch: 1 branch
BranchTrueFalseTotal
if $op->label 0 0 0
2422  
2423 0 return join("", @text);
2424 }
2425  
2426 sub declare_warnings {
2427 0 ▶ my ($self, $from, $to) = @_;
Subroutine declare_warnings: not called CC=5 SCAR=34.0
Pod undocumented
2428 0 ▶ $from //= '';
Condition0%0/2
$from //= ""
l!l
00
MC/DC0%0/1
$from //= ""
$from
Truth table0%0/2
A
A= $from
Aresult
11
00
2429 0 my $all = warnings::bits("all");
2430 0 ▶ unless (($from & ~$all) =~ /[^\0]/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (($from & ~$all) =~ /[^\0]/) 0 0 0
2431 # no FATAL bits need turning off
2432 0 ▶ if ( $to eq $all) {
Branch: 2 branches
BranchTrueFalseTotal
if ($to eq $all) { } 0 0 0
elsif ($to eq "\000" x length($to)) { } 0 0 0
2433 0 return $self->keyword("use") . " warnings;\n";
2434 }
2435 elsif ($to eq ("\0"x length($to))) {
2436 0 return $self->keyword("no") . " warnings;\n";
2437 }
2438 }
2439  
2440 return "BEGIN {\${^WARNING_BITS} = \""
2441 0 . join("", map { sprintf("\\x%02x", ord $_) } split "", $to)
2442 . "\"}\n\cK";
2443 }
2444  
2445 sub declare_hints {
2446 0 ▶ my ($self, $from, $to) = @_;
Subroutine declare_hints: not called CC=3 SCAR=24.8
Pod undocumented
2447 0 my $use = $to & ~$from;
2448 0 my $no = $from & ~$to;
2449 0 my $decls = "";
2450 0 for my $pragma (hint_pragmas($use)) {
2451 0 $decls .= $self->keyword("use") . " $pragma;\n";
2452 }
2453 0 for my $pragma (hint_pragmas($no)) {
2454 0 $decls .= $self->keyword("no") . " $pragma;\n";
2455 }
2456 0 return $decls;
2457 }
2458  
2459 # Internal implementation hints that the core sets automatically, so don't need
2460 # (or want) to be passed back to the user
2461 my %ignored_hints = (
2462 'open<' => 1,
2463 'open>' => 1,
2464 ':' => 1,
2465 'strict/refs' => 1,
2466 'strict/subs' => 1,
2467 'strict/vars' => 1,
2468 'feature/bits' => 1,
2469 );
2470  
2471 my %rev_feature;
2472  
2473 sub declare_hinthash {
2474 0 ▶ my ($self, $from, $to, $indent, $hints) = @_;
Subroutine declare_hinthash: not called CC=21 SCAR=61.4
Pod undocumented
2475 0 my $doing_features =
2476 ($hints & $feature::hint_mask) == $feature::hint_mask;
2477 0 my @decls;
2478 my @features;
2479 0 my @unfeatures; # bugs?
2480 0 for my $key (sort keys %$to) {
2481 0 ▶ next if $ignored_hints{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $ignored_hints{$key} 0 0 0
2482 0 my $is_feature = $key =~ /^feature_/;
2483 0 ▶ next if $is_feature and not $doing_features;
Branch: 1 branch
BranchTrueFalseTotal
if $is_feature and not $doing_features 0 0 0
Condition0%0/3
$is_feature and not $doing_features
!ll&&!rl&&r
000
MC/DC0%0/2
$is_feature and not $doing_features
$is_feature not $doing_features
Truth table0%0/3
A and not(B)
A= $is_featureB= not $doing_features
ABresult
0X0
100
111
2484 0 ▶ if (!exists $from->{$key} or $from->{$key} ne $to->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $from->{$key} or $from->{$key} ne $to->{$key}) 0 0 0
Condition0%0/3
not exists $from->{$key} or $from->{$key} ne $to->{$key}
l!l&&r!l&&!r
000
MC/DC0%0/2
not exists $from->{$key} or $from->{$key} ne $to->{$key}
not exists $from->{$key} $from->{$key} ne $to->{$key}
Truth table0%0/3
not(A) or B
A= not exists $from->{$key}B= $from->{$key} ne $to->{$key}
ABresult
1X1
011
000
2485 0 ▶ push(@features, $key), next if $is_feature;
Branch: 1 branch
BranchTrueFalseTotal
if $is_feature 0 0 0
2486 push @decls,
2487 qq(\$^H{) . single_delim("q", "'", $key, $self) . qq(} = )
2488 . (
2489 defined $to->{$key}
2490 0 ▶ ? single_delim("q", "'", $to->{$key}, $self)
Branch: 1 branch
BranchTrueFalseTotal
defined $to->{$key} ? : 0 0 0
2491 : 'undef'
2492 )
2493 . qq(;);
2494 }
2495 }
2496 0 for my $key (sort keys %$from) {
2497 0 ▶ next if $ignored_hints{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $ignored_hints{$key} 0 0 0
2498 0 my $is_feature = $key =~ /^feature_/;
2499 0 ▶ next if $is_feature and not $doing_features;
Branch: 1 branch
BranchTrueFalseTotal
if $is_feature and not $doing_features 0 0 0
Condition0%0/3
$is_feature and not $doing_features
!ll&&!rl&&r
000
MC/DC0%0/2
$is_feature and not $doing_features
$is_feature not $doing_features
Truth table0%0/3
A and not(B)
A= $is_featureB= not $doing_features
ABresult
0X0
100
111
2500 0 ▶ if (!exists $to->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $to->{$key}) 0 0 0
2501 0 ▶ push(@unfeatures, $key), next if $is_feature;
Branch: 1 branch
BranchTrueFalseTotal
if $is_feature 0 0 0
2502 0 push @decls, qq(delete \$^H{'$key'};);
2503 }
2504 }
2505 0 my @ret;
2506 0 ▶ if (@features || @unfeatures) {
Branch: 1 branch
BranchTrueFalseTotal
if (@features or @unfeatures) 0 0 0
Condition0%0/3
@features or @unfeatures
l!l&&r!l&&!r
000
MC/DC0%0/2
@features or @unfeatures
@features @unfeatures
Truth table0%0/3
A or B
A= @featuresB= @unfeatures
ABresult
1X1
011
000
2507 0 ▶ if (!%rev_feature) { %rev_feature = reverse %feature::feature }
Branch: 1 branch
BranchTrueFalseTotal
unless (%rev_feature) 0 0 0
2508 }
2509 0 ▶ if (@features) {
Branch: 1 branch
BranchTrueFalseTotal
if (@features) 0 0 0
2510 0 push @ret, $self->keyword("use") . " feature "
2511 . join(", ", map "'$rev_feature{$_}'", @features) . ";\n";
2512 }
2513 0 ▶ if (@unfeatures) {
Branch: 1 branch
BranchTrueFalseTotal
if (@unfeatures) 0 0 0
2514 0 push @ret, $self->keyword("no") . " feature "
2515 . join(", ", map "'$rev_feature{$_}'", @unfeatures)
2516 . ";\n";
2517 }
2518 @decls and
2519 0 ▶ push @ret,
Branch: 1 branch
BranchTrueFalseTotal
@decls and push @ret, join("\n" . " " x $indent, "BEGIN {", @decls) . "\n}\n\cK" 0 0 0
2520 join("\n" . (" " x $indent), "BEGIN {", @decls) . "\n}\n\cK";
2521 0 return @ret;
2522 }
2523  
2524 sub hint_pragmas {
2525 0 ▶ my ($bits) = @_;
Subroutine hint_pragmas: not called CC=7 SCAR=40.3
Pod undocumented
2526 0 my (@pragmas, @strict);
2527 0 ▶ push @pragmas, "integer" if $bits & 0x1;
Branch: 1 branch
BranchTrueFalseTotal
if $bits & 1 0 0 0
2528 0 for (sort keys %strict_bits) {
2529 0 ▶ push @strict, "'$_'" if $bits & $strict_bits{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $bits & $strict_bits{$_} 0 0 0
2530 }
2531 0 ▶ if (@strict == keys %strict_bits) {
Branch: 2 branches
BranchTrueFalseTotal
if (@strict == keys %strict_bits) { } 0 0 0
elsif (@strict) { } 0 0 0
2532 0 push @pragmas, "strict";
2533 }
2534 elsif (@strict) {
2535 0 push @pragmas, "strict " . join ', ', @strict;
2536 }
2537 0 ▶ push @pragmas, "bytes" if $bits & 0x8;
Branch: 1 branch
BranchTrueFalseTotal
if $bits & 8 0 0 0
2538 0 return @pragmas;
2539 }
2540  
2541 0 ▶sub pp_dbstate { pp_nextstate(@_) }
Subroutine pp_dbstate: not called CC=1 SCAR=6.9
Pod undocumented
2542 0 ▶sub pp_setstate { pp_nextstate(@_) }
Subroutine pp_setstate: not called CC=1 SCAR=6.9
Pod undocumented
2543  
2544 0 ▶sub pp_unstack { return "" } # see also leaveloop
Subroutine pp_unstack: not called CC=1 SCAR=6.9
Pod undocumented
2545  
2546 my %feature_keywords = (
2547 # keyword => 'feature',
2548 state => 'state',
2549 say => 'say',
2550 given => 'switch',
2551 when => 'switch',
2552 default => 'switch',
2553 break => 'switch',
2554 evalbytes=>'evalbytes',
2555 __SUB__ => '__SUB__',
2556 fc => 'fc',
2557 try => 'try',
2558 catch => 'try',
2559 finally => 'try',
2560 defer => 'defer',
2561 signatures => 'signatures',
2562 any => 'any',
2563 all => 'all',
2564 );
2565  
2566 # keywords that are strong and also have a prototype
2567 #
2568 my %strong_proto_keywords = map { $_ => 1 } qw(
2569 pos
2570 prototype
2571 scalar
2572 study
2573 undef
2574 );
2575  
2576 sub feature_enabled {
2577 0 ▶ my($self,$name) = @_;
Subroutine feature_enabled: not called CC=5 SCAR=34.0
Pod undocumented
2578 0 my $hh;
2579 0 my $hints = $self->{hints} & $feature::hint_mask;
2580 0 ▶ if ($hints && $hints != $feature::hint_mask) {
Branch: 2 branches
BranchTrueFalseTotal
if ($hints and $hints != $feature::hint_mask) { } 0 0 0
elsif ($hints) { } 0 0 0
Condition0%0/3
$hints and $hints != $feature::hint_mask
!ll&&!rl&&r
000
MC/DC0%0/2
$hints and $hints != $feature::hint_mask
$hints $hints != $feature::hint_mask
Truth table0%0/3
A and B
A= $hintsB= $hints != $feature::hint_mask
ABresult
0X0
100
111
2581 0 $hh = _features_from_bundle($hints);
2582 }
2583 0 elsif ($hints) { $hh = $self->{'hinthash'} }
2584 0 ▶ return $hh && $hh->{"feature_$feature_keywords{$name}"}
Condition0%0/3
$hh && $$hh{"feature_$feature_keywords{$name}"}
!ll&&!rl&&r
000
MC/DC0%0/2
$hh && $$hh{"feature_$feature_keywords{$name}"}
$hh $$hh{"feature_$feature_keywords{$name}"}
Truth table0%0/3
A && B
A= $hhB= $$hh{"feature_$feature_keywords{$name}"}
ABresult
0X0
100
111
2585 }
2586  
2587 sub keyword {
2588 0 ▶ my $self = shift;
Subroutine keyword: not called CC=15 SCAR=54.8
Pod undocumented
2589 0 my $name = shift;
2590 0 ▶ return $name if $name =~ /^CORE::/; # just in case
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /^CORE::/ 0 0 0
2591 0 ▶ if (exists $feature_keywords{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $feature_keywords{$name}) 0 0 0
2592 0 ▶ return "CORE::$name" if not $self->feature_enabled($name);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->feature_enabled($name) 0 0 0
2593 }
2594 # This sub may be called for a program that has no nextstate ops. In
2595 # that case we may have a lexical sub named no/use/sub in scope but
2596 # $self->lex_in_scope will return false because it depends on the
2597 # current nextstate op. So we need this alternate method if there is
2598 # no current cop.
2599 0 ▶ if (!$self->{'curcop'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->{'curcop'}) { } 0 0 0
elsif ($self->lex_in_scope("&$name") or $self->lex_in_scope("&$name", 1)) { } 0 0 0
2600 0 ▶ $self->populate_curcvlex() if !defined $self->{'curcvlex'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"curcvlex"} 0 0 0
2601 return "CORE::$name" if exists $self->{'curcvlex'}{"m&$name"}
2602 0 ▶ || exists $self->{'curcvlex'}{"o&$name"};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"curcvlex"}{"m&$name"} or exists $self->{"curcvlex"}{"o&$name"} 0 0 0
Condition0%0/3
exists $self->{"curcvlex"}{"m&$name"} or exists $self->{"curcvlex"}{"o&$name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $self->{"curcvlex"}{"m&$name"} or exists $self->{"curcvlex"}{"o&$name"}
exists $self->{"curcvlex"}{"m&$name"} exists $self->{"curcvlex"}{"o&$name"}
Truth table0%0/3
A or B
A= exists $self->{"curcvlex"}{"m&$name"}B= exists $self->{"curcvlex"}{"o&$name"}
ABresult
1X1
011
000
2603 ▶ } elsif ($self->lex_in_scope("&$name")
Condition0%0/3
$self->lex_in_scope("&$name") or $self->lex_in_scope("&$name", 1)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->lex_in_scope("&$name") or $self->lex_in_scope("&$name", 1)
$self->lex_in_scope("&$name") $self->lex_in_scope("&$name", 1)
Truth table0%0/3
A or B
A= $self->lex_in_scope("&$name")B= $self->lex_in_scope("&$name", 1)
ABresult
1X1
011
000
2604 || $self->lex_in_scope("&$name", 1)) {
2605 0 return "CORE::$name";
2606 }
2607 0 ▶ if ($strong_proto_keywords{$name}
Branch: 1 branch
BranchTrueFalseTotal
if ($strong_proto_keywords{$name} or not $name =~ /^(?:chom?p|do|exec|glob|s(?:elect|ystem))\z/ || defined eval { do { prototype "CORE::$name" } }) 0 0 0
Condition0%0/6
$strong_proto_keywords{$name} or not $name =~ /^(?:chom?p|do|exec|glob|s(?:elect|ystem))\z/ || defined eval { do { prototype "CORE::$name" } }
l!l&&r!l&&!r
000
$name =~ /^(?:chom?p|do|exec|glob|s(?:elect|ystem))\z/ || defined eval { do { prototype "CORE::$name" } }
l!l&&r!l&&!r
000
MC/DC0%0/3
$strong_proto_keywords{$name} or not $name =~ /^(?:chom?p|do|exec|glob|s(?:elect|ystem))\z/ || defined eval { do { prototype "CORE::$name" } }
$strong_proto_keywords{$name} $name =~ /^(?:chom?p|do|exec|glob|s(?:elect|ystem))\z/ defined eval { do { prototype "CORE::$name" } }
Truth table0%0/4
A or not(B || C)
A= $strong_proto_keywords{$name}B= $name =~ /^(?:chom?p|do|exec|glob|s(?:elect|ystem))\z/C= defined eval { do { prototype "CORE::$name" } }
ABCresult
1XX1
0001
01X0
0010
2608 || ($name !~ /^(?:chom?p|do|exec|glob|s(?:elect|ystem))\z/
2609 0 && !defined eval{prototype "CORE::$name"})
2610 0 ) { return $name }
2611 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"subs_declared"}{$name} or exists &{qq[$self->{"curstash"}::$name];}) 0 0 0
Condition0%0/3
exists $self->{"subs_declared"}{$name} or exists &{qq[$self->{"curstash"}::$name];}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $self->{"subs_declared"}{$name} or exists &{qq[$self->{"curstash"}::$name];}
exists $self->{"subs_declared"}{$name} exists &{qq[$self->{"curstash"}::$name];}
Truth table0%0/3
A or B
A= exists $self->{"subs_declared"}{$name}B= exists &{qq[$self->{"curstash"}::$name];}
ABresult
1X1
011
000
2612 exists $self->{subs_declared}{$name}
2613 or
2614 0 exists &{"$self->{curstash}::$name"}
2615 ) {
2616 0 return "CORE::$name"
2617 }
2618 0 return $name;
2619 }
2620  
2621 sub baseop {
2622 0 ▶ my $self = shift;
Subroutine baseop: not called CC=1 SCAR=6.9
Pod undocumented
2623 0 my($op, $cx, $name) = @_;
2624 0 return $self->keyword($name);
2625 }
2626  
2627 0 ▶sub pp_stub { "()" }
Subroutine pp_stub: not called CC=1 SCAR=6.9
Pod undocumented
2628 0 ▶sub pp_wantarray { baseop(@_, "wantarray") }
Subroutine pp_wantarray: not called CC=1 SCAR=6.9
Pod undocumented
2629 0 ▶sub pp_fork { baseop(@_, "fork") }
Subroutine pp_fork: not called CC=1 SCAR=6.9
Pod undocumented
2630 0 ▶sub pp_wait { maybe_targmy(@_, \&baseop, "wait") }
Subroutine pp_wait: not called CC=1 SCAR=6.9
Pod undocumented
2631 0 ▶sub pp_getppid { maybe_targmy(@_, \&baseop, "getppid") }
Subroutine pp_getppid: not called CC=1 SCAR=6.9
Pod undocumented
2632 0 ▶sub pp_time { maybe_targmy(@_, \&baseop, "time") }
Subroutine pp_time: not called CC=1 SCAR=6.9
Pod undocumented
2633 0 ▶sub pp_tms { baseop(@_, "times") }
Subroutine pp_tms: not called CC=1 SCAR=6.9
Pod undocumented
2634 0 ▶sub pp_ghostent { baseop(@_, "gethostent") }
Subroutine pp_ghostent: not called CC=1 SCAR=6.9
Pod undocumented
2635 0 ▶sub pp_gnetent { baseop(@_, "getnetent") }
Subroutine pp_gnetent: not called CC=1 SCAR=6.9
Pod undocumented
2636 0 ▶sub pp_gprotoent { baseop(@_, "getprotoent") }
Subroutine pp_gprotoent: not called CC=1 SCAR=6.9
Pod undocumented
2637 0 ▶sub pp_gservent { baseop(@_, "getservent") }
Subroutine pp_gservent: not called CC=1 SCAR=6.9
Pod undocumented
2638 0 ▶sub pp_ehostent { baseop(@_, "endhostent") }
Subroutine pp_ehostent: not called CC=1 SCAR=6.9
Pod undocumented
2639 0 ▶sub pp_enetent { baseop(@_, "endnetent") }
Subroutine pp_enetent: not called CC=1 SCAR=6.9
Pod undocumented
2640 0 ▶sub pp_eprotoent { baseop(@_, "endprotoent") }
Subroutine pp_eprotoent: not called CC=1 SCAR=6.9
Pod undocumented
2641 0 ▶sub pp_eservent { baseop(@_, "endservent") }
Subroutine pp_eservent: not called CC=1 SCAR=6.9
Pod undocumented
2642 0 ▶sub pp_gpwent { baseop(@_, "getpwent") }
Subroutine pp_gpwent: not called CC=1 SCAR=6.9
Pod undocumented
2643 0 ▶sub pp_spwent { baseop(@_, "setpwent") }
Subroutine pp_spwent: not called CC=1 SCAR=6.9
Pod undocumented
2644 0 ▶sub pp_epwent { baseop(@_, "endpwent") }
Subroutine pp_epwent: not called CC=1 SCAR=6.9
Pod undocumented
2645 0 ▶sub pp_ggrent { baseop(@_, "getgrent") }
Subroutine pp_ggrent: not called CC=1 SCAR=6.9
Pod undocumented
2646 0 ▶sub pp_sgrent { baseop(@_, "setgrent") }
Subroutine pp_sgrent: not called CC=1 SCAR=6.9
Pod undocumented
2647 0 ▶sub pp_egrent { baseop(@_, "endgrent") }
Subroutine pp_egrent: not called CC=1 SCAR=6.9
Pod undocumented
2648 0 ▶sub pp_getlogin { baseop(@_, "getlogin") }
Subroutine pp_getlogin: not called CC=1 SCAR=6.9
Pod undocumented
2649  
2650 sub POSTFIX () { 1 }
2651  
2652 # I couldn't think of a good short name, but this is the category of
2653 # symbolic unary operators with interesting precedence
2654  
2655 sub pfixop {
2656 0 ▶ my $self = shift;
Subroutine pfixop: not called CC=4 SCAR=30.0
Pod undocumented
2657 0 my($op, $cx, $name, $prec, $flags) = (@_, 0);
2658 0 my $kid = $op->first;
2659 0 $kid = $self->deparse($kid, $prec);
2660 0 ▶ return $self->maybe_parens(($flags & POSTFIX)
Branch: 2 branches
BranchTrueFalseTotal
$flags & 1 ? : 0 0 0
$name eq '-' && $kid =~ /^[a-zA-Z](?!\w)/ ? : 0 0 0
Condition0%0/3
$name eq "-" and $kid =~ /^[a-zA-Z](?!\w)/
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "-" and $kid =~ /^[a-zA-Z](?!\w)/
$name eq "-" $kid =~ /^[a-zA-Z](?!\w)/
Truth table0%0/3
A and B
A= $name eq "-"B= $kid =~ /^[a-zA-Z](?!\w)/
ABresult
0X0
100
111
2661 ? "$kid$name"
2662 # avoid confusion with filetests
2663 : $name eq '-'
2664 && $kid =~ /^[a-zA-Z](?!\w)/
2665 ? "$name($kid)"
2666 : "$name$kid",
2667 $cx, $prec);
2668 }
2669  
2670 0 ▶sub pp_preinc { pfixop(@_, "++", 23) }
Subroutine pp_preinc: not called CC=1 SCAR=6.9
Pod undocumented
2671 0 ▶sub pp_predec { pfixop(@_, "--", 23) }
Subroutine pp_predec: not called CC=1 SCAR=6.9
Pod undocumented
2672 0 ▶sub pp_postinc { maybe_targmy(@_, \&pfixop, "++", 23, POSTFIX) }
Subroutine pp_postinc: not called CC=1 SCAR=6.9
Pod undocumented
2673 0 ▶sub pp_postdec { maybe_targmy(@_, \&pfixop, "--", 23, POSTFIX) }
Subroutine pp_postdec: not called CC=1 SCAR=6.9
Pod undocumented
2674 0 ▶sub pp_i_preinc { pfixop(@_, "++", 23) }
Subroutine pp_i_preinc: not called CC=1 SCAR=6.9
Pod undocumented
2675 0 ▶sub pp_i_predec { pfixop(@_, "--", 23) }
Subroutine pp_i_predec: not called CC=1 SCAR=6.9
Pod undocumented
2676 0 ▶sub pp_i_postinc { maybe_targmy(@_, \&pfixop, "++", 23, POSTFIX) }
Subroutine pp_i_postinc: not called CC=1 SCAR=6.9
Pod undocumented
2677 0 ▶sub pp_i_postdec { maybe_targmy(@_, \&pfixop, "--", 23, POSTFIX) }
Subroutine pp_i_postdec: not called CC=1 SCAR=6.9
Pod undocumented
2678 0 ▶sub pp_complement { maybe_targmy(@_, \&pfixop, "~", 21) }
Subroutine pp_complement: not called CC=1 SCAR=6.9
Pod undocumented
2679 *pp_ncomplement = *pp_complement;
2680 0 ▶sub pp_scomplement { maybe_targmy(@_, \&pfixop, "~.", 21) }
Subroutine pp_scomplement: not called CC=1 SCAR=6.9
Pod undocumented
2681  
2682 0 ▶sub pp_negate { maybe_targmy(@_, \&real_negate) }
Subroutine pp_negate: not called CC=1 SCAR=6.9
Pod undocumented
2683 sub real_negate {
2684 0 ▶ my $self = shift;
Subroutine real_negate: not called CC=2 SCAR=17.9
Pod undocumented
2685 0 my($op, $cx) = @_;
2686 0 ▶ if ($op->first->name =~ /^(i_)?negate$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->first->name =~ /^(i_)?negate$/) { } 0 0 0
2687 # avoid --$x
2688 0 $self->pfixop($op, $cx, "-", 21.5);
2689 } else {
2690 0 $self->pfixop($op, $cx, "-", 21);
2691 }
2692 }
2693 0 ▶sub pp_i_negate { pp_negate(@_) }
Subroutine pp_i_negate: not called CC=1 SCAR=6.9
Pod undocumented
2694  
2695 sub pp_not {
2696 0 ▶ my $self = shift;
Subroutine pp_not: not called CC=2 SCAR=17.9
Pod undocumented
2697 0 my($op, $cx) = @_;
2698 0 ▶ if ($cx <= 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cx <= 4) { } 0 0 0
2699 0 $self->listop($op, $cx, "not", $op->first);
2700 } else {
2701 0 $self->pfixop($op, $cx, "!", 21);
2702 }
2703 }
2704  
2705 sub unop {
2706 0 ▶ my $self = shift;
Subroutine unop: not called CC=12 SCAR=50.5
Pod undocumented
2707 0 my($op, $cx, $name, $nollafr) = @_;
2708 0 my $kid;
2709 0 ▶ if ($op->flags & OPf_KIDS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 4) { } 0 0 0
2710 0 $kid = $op->first;
2711 0 ▶ if (not $name) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name) 0 0 0
2712 # this deals with 'boolkeys' right now
2713 0 return $self->deparse($kid,$cx);
2714 }
2715 0 my $builtinname = $name;
2716 0 ▶ $builtinname =~ /^CORE::/ or $builtinname = "CORE::$name";
Branch: 1 branch
BranchTrueFalseTotal
$builtinname =~ /^CORE::/ or $builtinname = "CORE::$name" 0 0 0
2717 0 ▶ if (defined prototype($builtinname)
Branch: 1 branch
BranchTrueFalseTotal
if (defined prototype $builtinname and $builtinname ne "CORE::readline" and prototype($builtinname) =~ /^;?\*/ and $kid->name eq "rv2gv") 0 0 0
Condition0%0/9
defined prototype $builtinname and $builtinname ne "CORE::readline" and prototype($builtinname) =~ /^;?\*/ and $kid->name eq "rv2gv"
!ll&&!rl&&r
000
defined prototype $builtinname and $builtinname ne "CORE::readline" and prototype($builtinname) =~ /^;?\*/
!ll&&!rl&&r
000
defined prototype $builtinname and $builtinname ne "CORE::readline"
!ll&&!rl&&r
000
MC/DC0%0/4
defined prototype $builtinname and $builtinname ne "CORE::readline" and prototype($builtinname) =~ /^;?\*/ and $kid->name eq "rv2gv"
defined prototype $builtinname $builtinname ne "CORE::readline" prototype($builtinname) =~ /^;?\*/ $kid->name eq "rv2gv"
Truth table0%0/5
A and B and C and D
A= defined prototype $builtinnameB= $builtinname ne "CORE::readline"C= prototype($builtinname) =~ /^;?\*/D= $kid->name eq "rv2gv"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2718 && $builtinname ne 'CORE::readline'
2719 && prototype($builtinname) =~ /^;?\*/
2720 && $kid->name eq "rv2gv") {
2721 0 $kid = $kid->first;
2722 }
2723  
2724 0 ▶ if ($nollafr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nollafr) 0 0 0
2725 0 ▶ if (($kid = $self->deparse($kid, 16)) !~ s/^\cS//) {
Branch: 1 branch
BranchTrueFalseTotal
unless (($kid = $self->deparse($kid, 16)) =~ s/^\cS//) 0 0 0
2726 # require foo() is a syntax error.
2727 0 ▶ $kid =~ /^(?!\d)\w/ and $kid = "($kid)";
Branch: 1 branch
BranchTrueFalseTotal
$kid =~ /^(?!\d)\w/ and $kid = "($kid)" 0 0 0
2728 }
2729 0 return $self->maybe_parens(
2730 $self->keyword($name) . " $kid", $cx, 16
2731 );
2732 }
2733 0 return $self->maybe_parens_unop($name, $kid, $cx);
2734 } else {
2735 0 ▶ return $self->maybe_parens(
Branch: 1 branch
BranchTrueFalseTotal
$op->flags & 128 ? : 0 0 0
2736 $self->keyword($name) . ($op->flags & OPf_SPECIAL ? "()" : ""),
2737 $cx, 16,
2738 );
2739 }
2740 }
2741  
2742 0 ▶sub pp_chop { maybe_targmy(@_, \&unop, "chop") }
Subroutine pp_chop: not called CC=1 SCAR=6.9
Pod undocumented
2743 0 ▶sub pp_chomp { maybe_targmy(@_, \&unop, "chomp") }
Subroutine pp_chomp: not called CC=1 SCAR=6.9
Pod undocumented
2744 0 ▶sub pp_schop { maybe_targmy(@_, \&unop, "chop") }
Subroutine pp_schop: not called CC=1 SCAR=6.9
Pod undocumented
2745 0 ▶sub pp_schomp { maybe_targmy(@_, \&unop, "chomp") }
Subroutine pp_schomp: not called CC=1 SCAR=6.9
Pod undocumented
2746 0 ▶sub pp_defined { unop(@_, "defined") }
Subroutine pp_defined: not called CC=1 SCAR=6.9
Pod undocumented
2747 sub pp_undef {
2748 0 ▶ if ($_[1]->private & OPpTARGET_MY) {
Subroutine pp_undef: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1]->private & 16) 0 0 0
2749 0 my $targ = $_[1]->targ;
2750 0 my $var = $_[0]->maybe_my($_[1], $_[2], $_[0]->padname($targ),
2751 $_[0]->padname_sv($targ),
2752 1);
2753 0 my $func = unop(@_, "undef");
2754 0 ▶ if ($func =~ /\s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($func =~ /\s/) { } 0 0 0
2755 0 return unop(@_, "undef").$var;
2756 } else {
2757 0 return "$var = undef";
2758 }
2759 }
2760 0 unop(@_, "undef")
2761 }
2762 0 ▶sub pp_study { unop(@_, "study") }
Subroutine pp_study: not called CC=1 SCAR=6.9
Pod undocumented
2763 0 ▶sub pp_ref { unop(@_, "ref") }
Subroutine pp_ref: not called CC=1 SCAR=6.9
Pod undocumented
2764 0 ▶sub pp_pos { maybe_local(@_, unop(@_, "pos")) }
Subroutine pp_pos: not called CC=1 SCAR=6.9
Pod undocumented
2765  
2766 0 ▶sub pp_sin { maybe_targmy(@_, \&unop, "sin") }
Subroutine pp_sin: not called CC=1 SCAR=6.9
Pod undocumented
2767 0 ▶sub pp_cos { maybe_targmy(@_, \&unop, "cos") }
Subroutine pp_cos: not called CC=1 SCAR=6.9
Pod undocumented
2768 0 ▶sub pp_rand { maybe_targmy(@_, \&unop, "rand") }
Subroutine pp_rand: not called CC=1 SCAR=6.9
Pod undocumented
2769 0 ▶sub pp_srand { unop(@_, "srand") }
Subroutine pp_srand: not called CC=1 SCAR=6.9
Pod undocumented
2770 0 ▶sub pp_exp { maybe_targmy(@_, \&unop, "exp") }
Subroutine pp_exp: not called CC=1 SCAR=6.9
Pod undocumented
2771 0 ▶sub pp_log { maybe_targmy(@_, \&unop, "log") }
Subroutine pp_log: not called CC=1 SCAR=6.9
Pod undocumented
2772 0 ▶sub pp_sqrt { maybe_targmy(@_, \&unop, "sqrt") }
Subroutine pp_sqrt: not called CC=1 SCAR=6.9
Pod undocumented
2773 0 ▶sub pp_int { maybe_targmy(@_, \&unop, "int") }
Subroutine pp_int: not called CC=1 SCAR=6.9
Pod undocumented
2774 0 ▶sub pp_hex { maybe_targmy(@_, \&unop, "hex") }
Subroutine pp_hex: not called CC=1 SCAR=6.9
Pod undocumented
2775 0 ▶sub pp_oct { maybe_targmy(@_, \&unop, "oct") }
Subroutine pp_oct: not called CC=1 SCAR=6.9
Pod undocumented
2776 0 ▶sub pp_abs { maybe_targmy(@_, \&unop, "abs") }
Subroutine pp_abs: not called CC=1 SCAR=6.9
Pod undocumented
2777  
2778 0 ▶sub pp_length { maybe_targmy(@_, \&unop, "length") }
Subroutine pp_length: not called CC=1 SCAR=6.9
Pod undocumented
2779 0 ▶sub pp_ord { maybe_targmy(@_, \&unop, "ord") }
Subroutine pp_ord: not called CC=1 SCAR=6.9
Pod undocumented
2780 0 ▶sub pp_chr { maybe_targmy(@_, \&unop, "chr") }
Subroutine pp_chr: not called CC=1 SCAR=6.9
Pod undocumented
2781  
2782 0 ▶sub pp_each { unop(@_, "each") }
Subroutine pp_each: not called CC=1 SCAR=6.9
Pod undocumented
2783 0 ▶sub pp_values { unop(@_, "values") }
Subroutine pp_values: not called CC=1 SCAR=6.9
Pod undocumented
2784 0 ▶sub pp_keys { unop(@_, "keys") }
Subroutine pp_keys: not called CC=1 SCAR=6.9
Pod undocumented
2785 { no strict 'refs'; *{"pp_r$_"} = *{"pp_$_"} for qw< keys each values >; }
2786 sub pp_boolkeys {
2787 # no name because its an optimisation op that has no keyword
2788 0 ▶ unop(@_,"");
Subroutine pp_boolkeys: not called CC=1 SCAR=6.9
Pod undocumented
2789 }
2790 0 ▶sub pp_aeach { unop(@_, "each") }
Subroutine pp_aeach: not called CC=1 SCAR=6.9
Pod undocumented
2791 0 ▶sub pp_avalues { unop(@_, "values") }
Subroutine pp_avalues: not called CC=1 SCAR=6.9
Pod undocumented
2792 0 ▶sub pp_akeys { unop(@_, "keys") }
Subroutine pp_akeys: not called CC=1 SCAR=6.9
Pod undocumented
2793 0 ▶sub pp_pop { unop(@_, "pop") }
Subroutine pp_pop: not called CC=1 SCAR=6.9
Pod undocumented
2794 0 ▶sub pp_shift { unop(@_, "shift") }
Subroutine pp_shift: not called CC=1 SCAR=6.9
Pod undocumented
2795  
2796 0 ▶sub pp_caller { unop(@_, "caller") }
Subroutine pp_caller: not called CC=1 SCAR=6.9
Pod undocumented
2797 0 ▶sub pp_reset { unop(@_, "reset") }
Subroutine pp_reset: not called CC=1 SCAR=6.9
Pod undocumented
2798 0 ▶sub pp_exit { unop(@_, "exit") }
Subroutine pp_exit: not called CC=1 SCAR=6.9
Pod undocumented
2799 0 ▶sub pp_prototype { unop(@_, "prototype") }
Subroutine pp_prototype: not called CC=1 SCAR=6.9
Pod undocumented
2800  
2801 0 ▶sub pp_close { unop(@_, "close") }
Subroutine pp_close: not called CC=1 SCAR=6.9
Pod undocumented
2802 0 ▶sub pp_fileno { unop(@_, "fileno") }
Subroutine pp_fileno: not called CC=1 SCAR=6.9
Pod undocumented
2803 0 ▶sub pp_umask { unop(@_, "umask") }
Subroutine pp_umask: not called CC=1 SCAR=6.9
Pod undocumented
2804 0 ▶sub pp_untie { unop(@_, "untie") }
Subroutine pp_untie: not called CC=1 SCAR=6.9
Pod undocumented
2805 0 ▶sub pp_tied { unop(@_, "tied") }
Subroutine pp_tied: not called CC=1 SCAR=6.9
Pod undocumented
2806 0 ▶sub pp_dbmclose { unop(@_, "dbmclose") }
Subroutine pp_dbmclose: not called CC=1 SCAR=6.9
Pod undocumented
2807 0 ▶sub pp_getc { unop(@_, "getc") }
Subroutine pp_getc: not called CC=1 SCAR=6.9
Pod undocumented
2808 0 ▶sub pp_eof { unop(@_, "eof") }
Subroutine pp_eof: not called CC=1 SCAR=6.9
Pod undocumented
2809 0 ▶sub pp_tell { unop(@_, "tell") }
Subroutine pp_tell: not called CC=1 SCAR=6.9
Pod undocumented
2810 0 ▶sub pp_getsockname { unop(@_, "getsockname") }
Subroutine pp_getsockname: not called CC=1 SCAR=6.9
Pod undocumented
2811 0 ▶sub pp_getpeername { unop(@_, "getpeername") }
Subroutine pp_getpeername: not called CC=1 SCAR=6.9
Pod undocumented
2812  
2813 sub pp_chdir {
2814 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_chdir: not called CC=4 SCAR=30.0
Pod undocumented
2815 0 ▶ if (($op->flags & (OPf_SPECIAL|OPf_KIDS)) == (OPf_SPECIAL|OPf_KIDS)) {
Branch: 1 branch
BranchTrueFalseTotal
if (($op->flags & 132) == 132) { } 0 0 0
2816 0 my $kw = $self->keyword("chdir");
2817 0 my $kid = $self->const_sv($op->first)->PV;
2818 my $code = $kw
2819 0 ▶ . ($cx >= 16 || $self->{'parens'} ? "($kid)" : " $kid");
Branch: 1 branch
BranchTrueFalseTotal
$cx >= 16 || $self->{'parens'} ? : 0 0 0
Condition0%0/3
$cx >= 16 or $self->{"parens"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cx >= 16 or $self->{"parens"}
$cx >= 16 $self->{"parens"}
Truth table0%0/3
A or B
A= $cx >= 16B= $self->{"parens"}
ABresult
1X1
011
000
2820 0 ▶ maybe_targmy(@_, sub { $_[3] }, $code);
Subroutine __ANON__: not called CC=1 SCAR=6.9
2821 } else {
2822 0 maybe_targmy(@_, \&unop, "chdir")
2823 }
2824 }
2825  
2826 0 ▶sub pp_chroot { maybe_targmy(@_, \&unop, "chroot") }
Subroutine pp_chroot: not called CC=1 SCAR=6.9
Pod undocumented
2827 0 ▶sub pp_readlink { unop(@_, "readlink") }
Subroutine pp_readlink: not called CC=1 SCAR=6.9
Pod undocumented
2828 0 ▶sub pp_rmdir { maybe_targmy(@_, \&unop, "rmdir") }
Subroutine pp_rmdir: not called CC=1 SCAR=6.9
Pod undocumented
2829 0 ▶sub pp_readdir { unop(@_, "readdir") }
Subroutine pp_readdir: not called CC=1 SCAR=6.9
Pod undocumented
2830 0 ▶sub pp_telldir { unop(@_, "telldir") }
Subroutine pp_telldir: not called CC=1 SCAR=6.9
Pod undocumented
2831 0 ▶sub pp_rewinddir { unop(@_, "rewinddir") }
Subroutine pp_rewinddir: not called CC=1 SCAR=6.9
Pod undocumented
2832 0 ▶sub pp_closedir { unop(@_, "closedir") }
Subroutine pp_closedir: not called CC=1 SCAR=6.9
Pod undocumented
2833 0 ▶sub pp_getpgrp { maybe_targmy(@_, \&unop, "getpgrp") }
Subroutine pp_getpgrp: not called CC=1 SCAR=6.9
Pod undocumented
2834 0 ▶sub pp_localtime { unop(@_, "localtime") }
Subroutine pp_localtime: not called CC=1 SCAR=6.9
Pod undocumented
2835 0 ▶sub pp_gmtime { unop(@_, "gmtime") }
Subroutine pp_gmtime: not called CC=1 SCAR=6.9
Pod undocumented
2836 0 ▶sub pp_alarm { unop(@_, "alarm") }
Subroutine pp_alarm: not called CC=1 SCAR=6.9
Pod undocumented
2837 0 ▶sub pp_sleep { maybe_targmy(@_, \&unop, "sleep") }
Subroutine pp_sleep: not called CC=1 SCAR=6.9
Pod undocumented
2838  
2839 sub pp_dofile {
2840 0 ▶ my $code = unop(@_, "do", 1); # llafr does not apply
Subroutine pp_dofile: not called CC=2 SCAR=17.9
Pod undocumented
2841 0 ▶ if ($code =~ s/^((?:CORE::)?do) \{/$1({/) { $code .= ')' }
Branch: 1 branch
BranchTrueFalseTotal
if ($code =~ s/^((?:CORE::)?do) \{/$1({/) 0 0 0
2842 0 $code;
2843 }
2844 sub pp_entereval {
2845 0 ▶ unop(
Subroutine pp_entereval: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->private & 8 ? : 0 0 0
2846 @_,
2847 $_[1]->private & OPpEVAL_BYTES ? 'evalbytes' : "eval"
2848 )
2849 }
2850  
2851 0 ▶sub pp_ghbyname { unop(@_, "gethostbyname") }
Subroutine pp_ghbyname: not called CC=1 SCAR=6.9
Pod undocumented
2852 0 ▶sub pp_gnbyname { unop(@_, "getnetbyname") }
Subroutine pp_gnbyname: not called CC=1 SCAR=6.9
Pod undocumented
2853 0 ▶sub pp_gpbyname { unop(@_, "getprotobyname") }
Subroutine pp_gpbyname: not called CC=1 SCAR=6.9
Pod undocumented
2854 0 ▶sub pp_shostent { unop(@_, "sethostent") }
Subroutine pp_shostent: not called CC=1 SCAR=6.9
Pod undocumented
2855 0 ▶sub pp_snetent { unop(@_, "setnetent") }
Subroutine pp_snetent: not called CC=1 SCAR=6.9
Pod undocumented
2856 0 ▶sub pp_sprotoent { unop(@_, "setprotoent") }
Subroutine pp_sprotoent: not called CC=1 SCAR=6.9
Pod undocumented
2857 0 ▶sub pp_sservent { unop(@_, "setservent") }
Subroutine pp_sservent: not called CC=1 SCAR=6.9
Pod undocumented
2858 0 ▶sub pp_gpwnam { unop(@_, "getpwnam") }
Subroutine pp_gpwnam: not called CC=1 SCAR=6.9
Pod undocumented
2859 0 ▶sub pp_gpwuid { unop(@_, "getpwuid") }
Subroutine pp_gpwuid: not called CC=1 SCAR=6.9
Pod undocumented
2860 0 ▶sub pp_ggrnam { unop(@_, "getgrnam") }
Subroutine pp_ggrnam: not called CC=1 SCAR=6.9
Pod undocumented
2861 0 ▶sub pp_ggrgid { unop(@_, "getgrgid") }
Subroutine pp_ggrgid: not called CC=1 SCAR=6.9
Pod undocumented
2862  
2863 0 ▶sub pp_lock { unop(@_, "lock") }
Subroutine pp_lock: not called CC=1 SCAR=6.9
Pod undocumented
2864  
2865 0 ▶sub pp_continue { unop(@_, "continue"); }
Subroutine pp_continue: not called CC=1 SCAR=6.9
Pod undocumented
2866 0 ▶sub pp_break { unop(@_, "break"); }
Subroutine pp_break: not called CC=1 SCAR=6.9
Pod undocumented
2867  
2868 sub givwhen {
2869 0 ▶ my $self = shift;
Subroutine givwhen: not called CC=2 SCAR=17.9
Pod undocumented
2870 0 my($op, $cx, $givwhen) = @_;
2871  
2872 0 my $enterop = $op->first;
2873 0 my ($head, $block);
2874 0 ▶ if ($enterop->flags & OPf_SPECIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enterop->flags & 128) { } 0 0 0
2875 0 $head = $self->keyword("default");
2876 0 $block = $self->deparse($enterop->first, 0);
2877 }
2878 else {
2879 0 my $cond = $enterop->first;
2880 0 my $cond_str = $self->deparse($cond, 1);
2881 0 $head = "$givwhen ($cond_str)";
2882 0 $block = $self->deparse($cond->sibling, 0);
2883 }
2884  
2885 0 return "$head {\n".
2886 "\t$block\n".
2887 "\b}\cK";
2888 }
2889  
2890 0 ▶sub pp_leavegiven { givwhen(@_, $_[0]->keyword("given")); }
Subroutine pp_leavegiven: not called CC=1 SCAR=6.9
Pod undocumented
2891 0 ▶sub pp_leavewhen { givwhen(@_, $_[0]->keyword("when")); }
Subroutine pp_leavewhen: not called CC=1 SCAR=6.9
Pod undocumented
2892  
2893 sub pp_exists {
2894 0 ▶ my $self = shift;
Subroutine pp_exists: not called CC=3 SCAR=24.8
Pod undocumented
2895 0 my($op, $cx) = @_;
2896 0 my $arg;
2897 0 my $name = $self->keyword("exists");
2898 0 ▶ if ($op->private & OPpEXISTS_SUB) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 64) 0 0 0
2899 # Checking for the existence of a subroutine
2900 0 return $self->maybe_parens_func($name,
2901 $self->pp_rv2cv($op->first, 16), $cx, 16);
2902 }
2903 0 ▶ if ($op->flags & OPf_SPECIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 128) 0 0 0
2904 # Array element, not hash element
2905 0 return $self->maybe_parens_func($name,
2906 $self->pp_aelem($op->first, 16), $cx, 16);
2907 }
2908 0 return $self->maybe_parens_func($name, $self->pp_helem($op->first, 16),
2909 $cx, 16);
2910 }
2911  
2912 sub pp_delete {
2913 0 ▶ my $self = shift;
Subroutine pp_delete: not called CC=4 SCAR=30.0
Pod undocumented
2914 0 my($op, $cx) = @_;
2915 0 my $arg;
2916 0 my $name = $self->keyword("delete");
2917 0 ▶ if ($op->private & (OPpSLICE|OPpKVSLICE)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 96) { } 0 0 0
2918 0 ▶ if ($op->flags & OPf_SPECIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 128) 0 0 0
2919 # Deleting from an array, not a hash
2920 0 return $self->maybe_parens_func($name,
2921 $self->pp_aslice($op->first, 16),
2922 $cx, 16);
2923 }
2924 0 return $self->maybe_parens_func($name,
2925 $self->pp_hslice($op->first, 16),
2926 $cx, 16);
2927 } else {
2928 0 ▶ if ($op->flags & OPf_SPECIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 128) 0 0 0
2929 # Deleting from an array, not a hash
2930 0 return $self->maybe_parens_func($name,
2931 $self->pp_aelem($op->first, 16),
2932 $cx, 16);
2933 }
2934 0 return $self->maybe_parens_func($name,
2935 $self->pp_helem($op->first, 16),
2936 $cx, 16);
2937 }
2938 }
2939  
2940 sub pp_require {
2941 0 ▶ my $self = shift;
Subroutine pp_require: not called CC=7 SCAR=40.3
Pod undocumented
2942 0 my($op, $cx) = @_;
2943 0 ▶ my $opname = $op->flags & OPf_SPECIAL ? 'CORE::require' : 'require';
Branch: 1 branch
BranchTrueFalseTotal
$op->flags & 128 ? : 0 0 0
2944 0 my $kid = $op->first;
2945 0 ▶ if ($kid->name eq 'const') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->name eq "const") 0 0 0
2946 0 my $priv = $kid->private;
2947 0 my $sv = $self->const_sv($kid);
2948 0 my $arg;
2949 0 ▶ if ($priv & OPpCONST_BARE) {
Branch: 3 branches
BranchTrueFalseTotal
if ($priv & 32) { } 0 0 0
elsif ($priv & 2) { } 0 0 0
elsif ((my $tmp = $self->const($sv, 16)) =~ /^v/) { } 0 0 0
2950 0 $arg = $sv->PV;
2951 0 $arg =~ s[/][::]g;
2952 0 $arg =~ s/\.pm//g;
2953 } elsif ($priv & OPpCONST_NOVER) {
2954 0 $opname = $self->keyword('no');
2955 0 $arg = $self->const($sv, 16);
2956 } elsif ((my $tmp = $self->const($sv, 16)) =~ /^v/) {
2957 0 $arg = $tmp;
2958 }
2959 0 ▶ if ($arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg) 0 0 0
2960 0 return $self->maybe_parens("$opname $arg", $cx, 16);
2961 }
2962 }
2963 $self->unop(
2964 0 $op, $cx,
2965 $opname,
2966 1, # llafr does not apply
2967 );
2968 }
2969  
2970 sub pp_scalar {
2971 0 ▶ my $self = shift;
Subroutine pp_scalar: not called CC=2 SCAR=17.9
Pod undocumented
2972 0 my($op, $cx) = @_;
2973 0 my $kid = $op->first;
2974 0 ▶ if (not null $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid->sibling)) 0 0 0
2975 # XXX Was a here-doc
2976 0 return $self->dquote($op);
2977 }
2978 0 $self->unop(@_, "scalar");
2979 }
2980  
2981  
2982 sub padval {
2983 0 ▶ my $self = shift;
Subroutine padval: not called CC=1 SCAR=6.9
Pod undocumented
2984 0 my $targ = shift;
2985 0 return $self->{'curcv'}->PADLIST->ARRAYelt(1)->ARRAYelt($targ);
2986 }
2987  
2988 sub anon_hash_or_list {
2989 0 ▶ my $self = shift;
Subroutine anon_hash_or_list: not called CC=4 SCAR=30.0
Pod undocumented
2990 0 my($op, $cx) = @_;
2991  
2992 0 my($pre, $post) = @{{"anonlist" => ["[","]"],
2993 0 "anonhash" => ["{","}"]}->{$op->name}};
2994 0 my($expr, @exprs);
2995 0 $op = $op->first->sibling; # skip pushmark
2996 0 ▶ for (; !null($op); $op = $op->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($op)) 0 0 0
2997 0 $expr = $self->deparse($op, 6);
2998 0 push @exprs, $expr;
2999 }
3000 0 ▶ if ($pre eq "{" and $cx < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pre eq "{" and $cx < 1) 0 0 0
Condition0%0/3
$pre eq "{" and $cx < 1
!ll&&!rl&&r
000
MC/DC0%0/2
$pre eq "{" and $cx < 1
$pre eq "{" $cx < 1
Truth table0%0/3
A and B
A= $pre eq "{"B= $cx < 1
ABresult
0X0
100
111
3001 # Disambiguate that it's not a block
3002 0 $pre = "+{";
3003 }
3004 0 return $pre . join(", ", @exprs) . $post;
3005 }
3006  
3007 sub pp_anonlist {
3008 0 ▶ my $self = shift;
Subroutine pp_anonlist: not called CC=2 SCAR=17.9
Pod undocumented
3009 0 my ($op, $cx) = @_;
3010 0 ▶ if ($op->flags & OPf_SPECIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 128) 0 0 0
3011 0 return $self->anon_hash_or_list($op, $cx);
3012 }
3013 0 warn "Unexpected op pp_" . $op->name() . " without OPf_SPECIAL";
3014 0 return 'XXX';
3015 }
3016  
3017 *pp_anonhash = \&pp_anonlist;
3018  
3019 sub pp_emptyavhv {
3020 0 ▶ my $self = shift;
Subroutine pp_emptyavhv: not called CC=3 SCAR=24.8
Pod undocumented
3021 0 my ($op, $cx, $forbid_parens) = @_;
3022 0 ▶ my $val = ($op->private & OPpEMPTYAVHV_IS_HV) ? '{}' : '[]';
Branch: 1 branch
BranchTrueFalseTotal
$op->private & 32 ? : 0 0 0
3023 0 ▶ if ($op->private & OPpTARGET_MY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 16) { } 0 0 0
3024 0 my $targ = $op->targ;
3025 0 my $var = $self->maybe_my($op, $cx, $self->padname($targ),
3026 $self->padname_sv($targ),
3027 $forbid_parens);
3028 0 return $self->maybe_parens("$var = $val", $cx, 7);
3029 } else {
3030 0 return $val;
3031 }
3032 }
3033  
3034 sub pp_refgen {
3035 0 ▶ my $self = shift;
Subroutine pp_refgen: not called CC=10 SCAR=47.0
Pod undocumented
3036 0 my($op, $cx) = @_;
3037 0 my $kid = $op->first;
3038 0 ▶ if ($kid->name eq "null") {
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->name eq "null") 0 0 0
3039 0 my $anoncode = $kid = $kid->first;
3040  
3041 # Perl no longer generates this, but XS modules might:
3042 0 ▶ if ($anoncode->name eq "anonconst") {
Branch: 1 branch
BranchTrueFalseTotal
if ($anoncode->name eq "anonconst") 0 0 0
3043 0 $anoncode = $anoncode->first->first->sibling;
3044 }
3045  
3046 # Same as with `anonconst`:
3047 0 ▶ if ($anoncode->name eq "anoncode"
Branch: 2 branches
BranchTrueFalseTotal
if ($anoncode->name eq 'anoncode' or not null($anoncode = $kid->sibling) and $anoncode->name eq 'anoncode') { } 0 0 0
elsif ($kid->name eq 'pushmark') { } 0 0 0
Condition0%0/6
$anoncode->name eq "anoncode" or not null($anoncode = $kid->sibling) and $anoncode->name eq "anoncode"
l!l&&r!l&&!r
000
not null($anoncode = $kid->sibling) and $anoncode->name eq "anoncode"
!ll&&!rl&&r
000
MC/DC0%0/3
$anoncode->name eq "anoncode" or not null($anoncode = $kid->sibling) and $anoncode->name eq "anoncode"
$anoncode->name eq "anoncode" not null($anoncode = $kid->sibling) $anoncode->name eq "anoncode"
Truth table0%0/4
A or not(B) and C
A= $anoncode->name eq "anoncode"B= not null($anoncode = $kid->sibling)C= $anoncode->name eq "anoncode"
ABCresult
1XX1
0111
00X0
0100
3048 or !null($anoncode = $kid->sibling) and
3049 $anoncode->name eq "anoncode") {
3050 0 return $self->e_anoncode({ code => $self->padval($anoncode->targ) });
3051  
3052 # Perl still generates this:
3053 } elsif ($kid->name eq "pushmark") {
3054 0 my $sib_name = $kid->sibling->name;
3055 0 ▶ if ($sib_name eq 'entersub') {
Branch: 1 branch
BranchTrueFalseTotal
if ($sib_name eq "entersub") 0 0 0
3056 0 my $text = $self->deparse($kid->sibling, 1);
3057 # Always show parens for \(&func()), but only with -p otherwise
3058 0 ▶ $text = "($text)" if $self->{'parens'}
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"parens"} or $kid->sibling->private & 8 0 0 0
Condition0%0/3
$self->{"parens"} or $kid->sibling->private & 8
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"parens"} or $kid->sibling->private & 8
$self->{"parens"} $kid->sibling->private & 8
Truth table0%0/3
A or B
A= $self->{"parens"}B= $kid->sibling->private & 8
ABresult
1X1
011
000
3059 or $kid->sibling->private & OPpENTERSUB_AMPER;
3060 0 return "\\$text";
3061 }
3062 }
3063 }
3064 0 local $self->{'in_refgen'} = 1;
3065 0 $self->pfixop($op, $cx, "\\", 20);
3066 }
3067  
3068 sub e_anoncode {
3069 0 ▶ my ($self, $info) = @_;
Subroutine e_anoncode: not called CC=1 SCAR=6.9
Pod undocumented
3070 0 my $cv = $info->{code};
3071 0 my $text = $self->deparse_sub($cv);
3072 0 return $self->keyword($self->kw_sub_or_method($cv)) . " $text";
3073 }
3074  
3075 sub pp_anoncode {
3076 0 ▶ my ($self, $anoncode) = @_;
Subroutine pp_anoncode: not called CC=1 SCAR=6.9
Pod undocumented
3077  
3078 0 return $self->e_anoncode( { code => $self->padval($anoncode->targ) } );
3079 }
3080  
3081 sub pp_anonconst {
3082 0 ▶ my ($self, $anonconst) = @_;
Subroutine pp_anonconst: not called CC=1 SCAR=6.9
Pod undocumented
3083  
3084 0 return $self->pp_anoncode( $anonconst->first->first->sibling );
3085 }
3086  
3087 0 ▶sub pp_srefgen { pp_refgen(@_) }
Subroutine pp_srefgen: not called CC=1 SCAR=6.9
Pod undocumented
3088  
3089 sub pp_readline {
3090 0 ▶ my $self = shift;
Subroutine pp_readline: not called CC=4 SCAR=30.0
Pod undocumented
3091 0 my($op, $cx) = @_;
3092 0 my $kid = $op->first;
3093 0 ▶ if (is_scalar($kid)
Branch: 1 branch
BranchTrueFalseTotal
if (is_scalar($kid) and $op->flags & 128 and $self->deparse($kid, 1) eq "ARGV") 0 0 0
Condition0%0/6
is_scalar($kid) and $op->flags & 128 and $self->deparse($kid, 1) eq "ARGV"
!ll&&!rl&&r
000
is_scalar($kid) and $op->flags & 128
!ll&&!rl&&r
000
MC/DC0%0/3
is_scalar($kid) and $op->flags & 128 and $self->deparse($kid, 1) eq "ARGV"
is_scalar($kid) $op->flags & 128 $self->deparse($kid, 1) eq "ARGV"
Truth table0%0/4
A and B and C
A= is_scalar($kid)B= $op->flags & 128C= $self->deparse($kid, 1) eq "ARGV"
ABCresult
0XX0
10X0
1100
1111
3094 and $op->flags & OPf_SPECIAL
3095 and $self->deparse($kid, 1) eq 'ARGV')
3096 {
3097 0 return '<<>>';
3098 }
3099 0 return $self->unop($op, $cx, "readline");
3100 }
3101  
3102 sub pp_rcatline {
3103 0 ▶ my $self = shift;
Subroutine pp_rcatline: not called CC=1 SCAR=6.9
Pod undocumented
3104 0 my($op) = @_;
3105 0 return "<" . $self->gv_name($self->gv_or_padgv($op)) . ">";
3106 }
3107  
3108 # Unary operators that can occur as pseudo-listops inside double quotes
3109 sub dq_unop {
3110 0 ▶ my $self = shift;
Subroutine dq_unop: not called CC=4 SCAR=30.0
Pod undocumented
3111 0 my($op, $cx, $name, $prec, $flags) = (@_, 0, 0);
3112 0 my $kid;
3113 0 ▶ if ($op->flags & OPf_KIDS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 4) { } 0 0 0
3114 0 $kid = $op->first;
3115 # If there's more than one kid, the first is an ex-pushmark.
3116 0 ▶ $kid = $kid->sibling if not null $kid->sibling;
Branch: 1 branch
BranchTrueFalseTotal
unless null($kid->sibling) 0 0 0
3117 0 return $self->maybe_parens_unop($name, $kid, $cx);
3118 } else {
3119 0 ▶ return $name . ($op->flags & OPf_SPECIAL ? "()" : "");
Branch: 1 branch
BranchTrueFalseTotal
$op->flags & 128 ? : 0 0 0
3120 }
3121 }
3122  
3123 0 ▶sub pp_ucfirst { dq_unop(@_, "ucfirst") }
Subroutine pp_ucfirst: not called CC=1 SCAR=6.9
Pod undocumented
3124 0 ▶sub pp_lcfirst { dq_unop(@_, "lcfirst") }
Subroutine pp_lcfirst: not called CC=1 SCAR=6.9
Pod undocumented
3125 0 ▶sub pp_uc { dq_unop(@_, "uc") }
Subroutine pp_uc: not called CC=1 SCAR=6.9
Pod undocumented
3126 0 ▶sub pp_lc { dq_unop(@_, "lc") }
Subroutine pp_lc: not called CC=1 SCAR=6.9
Pod undocumented
3127 0 ▶sub pp_quotemeta { maybe_targmy(@_, \&dq_unop, "quotemeta") }
Subroutine pp_quotemeta: not called CC=1 SCAR=6.9
Pod undocumented
3128 0 ▶sub pp_fc { dq_unop(@_, "fc") }
Subroutine pp_fc: not called CC=1 SCAR=6.9
Pod undocumented
3129  
3130 sub loopex {
3131 0 ▶ my $self = shift;
Subroutine loopex: not called CC=5 SCAR=34.0
Pod undocumented
3132 0 my ($op, $cx, $name) = @_;
3133 0 ▶ if (class($op) eq "PVOP") {
Branch: 3 branches
BranchTrueFalseTotal
if (B::Deparse::class($op) eq 'PVOP') { } 0 0 0
elsif (B::Deparse::class($op) eq 'OP') { } 0 0 0
elsif (B::Deparse::class($op) eq 'UNOP') { } 0 0 0
3134 0 $name .= " " . $op->pv;
3135 } elsif (class($op) eq "OP") {
3136 # no-op
3137 } elsif (class($op) eq "UNOP") {
3138 0 (my $kid = $self->deparse($op->first, 7)) =~ s/^\cS//;
3139 # last foo() is a syntax error.
3140 0 ▶ $kid =~ /^(?!\d)\w/ and $kid = "($kid)";
Branch: 1 branch
BranchTrueFalseTotal
$kid =~ /^(?!\d)\w/ and $kid = "($kid)" 0 0 0
3141 0 $name .= " $kid";
3142 }
3143 0 return $self->maybe_parens($name, $cx, 7);
3144 }
3145  
3146 0 ▶sub pp_last { loopex(@_, "last") }
Subroutine pp_last: not called CC=1 SCAR=6.9
Pod undocumented
3147 0 ▶sub pp_next { loopex(@_, "next") }
Subroutine pp_next: not called CC=1 SCAR=6.9
Pod undocumented
3148 0 ▶sub pp_redo { loopex(@_, "redo") }
Subroutine pp_redo: not called CC=1 SCAR=6.9
Pod undocumented
3149 0 ▶sub pp_goto { loopex(@_, "goto") }
Subroutine pp_goto: not called CC=1 SCAR=6.9
Pod undocumented
3150 0 ▶sub pp_dump { loopex(@_, "CORE::dump") }
Subroutine pp_dump: not called CC=1 SCAR=6.9
Pod undocumented
3151  
3152 sub ftst {
3153 0 ▶ my $self = shift;
Subroutine ftst: not called CC=4 SCAR=30.0
Pod undocumented
3154 0 my($op, $cx, $name) = @_;
3155 0 ▶ if (class($op) eq "UNOP") {
Branch: 2 branches
BranchTrueFalseTotal
if (B::Deparse::class($op) eq 'UNOP') { } 0 0 0
elsif (B::Deparse::class($op) =~ /^(SV|PAD)OP$/) { } 0 0 0
3156 # Genuine '-X' filetests are exempt from the LLAFR, but not
3157 # l?stat()
3158 0 ▶ if ($name =~ /^-/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^-/) 0 0 0
3159 0 (my $kid = $self->deparse($op->first, 16)) =~ s/^\cS//;
3160 0 return $self->maybe_parens("$name $kid", $cx, 16);
3161 }
3162 0 return $self->maybe_parens_unop($name, $op->first, $cx);
3163 } elsif (class($op) =~ /^(SV|PAD)OP$/) {
3164 0 return $self->maybe_parens_func($name, $self->pp_gv($op, 1), $cx, 16);
3165 } else { # I don't think baseop filetests ever survive ck_ftst, but...
3166 0 return $name;
3167 }
3168 }
3169  
3170 0 ▶sub pp_lstat { ftst(@_, "lstat") }
Subroutine pp_lstat: not called CC=1 SCAR=6.9
Pod undocumented
3171 0 ▶sub pp_stat { ftst(@_, "stat") }
Subroutine pp_stat: not called CC=1 SCAR=6.9
Pod undocumented
3172 0 ▶sub pp_ftrread { ftst(@_, "-R") }
Subroutine pp_ftrread: not called CC=1 SCAR=6.9
Pod undocumented
3173 0 ▶sub pp_ftrwrite { ftst(@_, "-W") }
Subroutine pp_ftrwrite: not called CC=1 SCAR=6.9
Pod undocumented
3174 0 ▶sub pp_ftrexec { ftst(@_, "-X") }
Subroutine pp_ftrexec: not called CC=1 SCAR=6.9
Pod undocumented
3175 0 ▶sub pp_fteread { ftst(@_, "-r") }
Subroutine pp_fteread: not called CC=1 SCAR=6.9
Pod undocumented
3176 0 ▶sub pp_ftewrite { ftst(@_, "-w") }
Subroutine pp_ftewrite: not called CC=1 SCAR=6.9
Pod undocumented
3177 0 ▶sub pp_fteexec { ftst(@_, "-x") }
Subroutine pp_fteexec: not called CC=1 SCAR=6.9
Pod undocumented
3178 0 ▶sub pp_ftis { ftst(@_, "-e") }
Subroutine pp_ftis: not called CC=1 SCAR=6.9
Pod undocumented
3179 0 ▶sub pp_fteowned { ftst(@_, "-O") }
Subroutine pp_fteowned: not called CC=1 SCAR=6.9
Pod undocumented
3180 0 ▶sub pp_ftrowned { ftst(@_, "-o") }
Subroutine pp_ftrowned: not called CC=1 SCAR=6.9
Pod undocumented
3181 0 ▶sub pp_ftzero { ftst(@_, "-z") }
Subroutine pp_ftzero: not called CC=1 SCAR=6.9
Pod undocumented
3182 0 ▶sub pp_ftsize { ftst(@_, "-s") }
Subroutine pp_ftsize: not called CC=1 SCAR=6.9
Pod undocumented
3183 0 ▶sub pp_ftmtime { ftst(@_, "-M") }
Subroutine pp_ftmtime: not called CC=1 SCAR=6.9
Pod undocumented
3184 0 ▶sub pp_ftatime { ftst(@_, "-A") }
Subroutine pp_ftatime: not called CC=1 SCAR=6.9
Pod undocumented
3185 0 ▶sub pp_ftctime { ftst(@_, "-C") }
Subroutine pp_ftctime: not called CC=1 SCAR=6.9
Pod undocumented
3186 0 ▶sub pp_ftsock { ftst(@_, "-S") }
Subroutine pp_ftsock: not called CC=1 SCAR=6.9
Pod undocumented
3187 0 ▶sub pp_ftchr { ftst(@_, "-c") }
Subroutine pp_ftchr: not called CC=1 SCAR=6.9
Pod undocumented
3188 0 ▶sub pp_ftblk { ftst(@_, "-b") }
Subroutine pp_ftblk: not called CC=1 SCAR=6.9
Pod undocumented
3189 0 ▶sub pp_ftfile { ftst(@_, "-f") }
Subroutine pp_ftfile: not called CC=1 SCAR=6.9
Pod undocumented
3190 0 ▶sub pp_ftdir { ftst(@_, "-d") }
Subroutine pp_ftdir: not called CC=1 SCAR=6.9
Pod undocumented
3191 0 ▶sub pp_ftpipe { ftst(@_, "-p") }
Subroutine pp_ftpipe: not called CC=1 SCAR=6.9
Pod undocumented
3192 0 ▶sub pp_ftlink { ftst(@_, "-l") }
Subroutine pp_ftlink: not called CC=1 SCAR=6.9
Pod undocumented
3193 0 ▶sub pp_ftsuid { ftst(@_, "-u") }
Subroutine pp_ftsuid: not called CC=1 SCAR=6.9
Pod undocumented
3194 0 ▶sub pp_ftsgid { ftst(@_, "-g") }
Subroutine pp_ftsgid: not called CC=1 SCAR=6.9
Pod undocumented
3195 0 ▶sub pp_ftsvtx { ftst(@_, "-k") }
Subroutine pp_ftsvtx: not called CC=1 SCAR=6.9
Pod undocumented
3196 0 ▶sub pp_fttty { ftst(@_, "-t") }
Subroutine pp_fttty: not called CC=1 SCAR=6.9
Pod undocumented
3197 0 ▶sub pp_fttext { ftst(@_, "-T") }
Subroutine pp_fttext: not called CC=1 SCAR=6.9
Pod undocumented
3198 0 ▶sub pp_ftbinary { ftst(@_, "-B") }
Subroutine pp_ftbinary: not called CC=1 SCAR=6.9
Pod undocumented
3199  
3200 sub SWAP_CHILDREN () { 1 }
3201 sub ASSIGN () { 2 } # has OP= variant
3202 sub LIST_CONTEXT () { 4 } # Assignment is in list context
3203  
3204 my(%left, %right);
3205  
3206 sub assoc_class {
3207 0 ▶ my $op = shift;
Subroutine assoc_class: not called CC=8 SCAR=42.8
Pod undocumented
3208 0 my $name = $op->name;
3209 0 ▶ if ($name eq "concat" and $op->first->name eq "concat") {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "concat" and $op->first->name eq "concat") 0 0 0
Condition0%0/3
$name eq "concat" and $op->first->name eq "concat"
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "concat" and $op->first->name eq "concat"
$name eq "concat" $op->first->name eq "concat"
Truth table0%0/3
A and B
A= $name eq "concat"B= $op->first->name eq "concat"
ABresult
0X0
100
111
3210 # avoid spurious '=' -- see comment in pp_concat
3211 0 return "concat";
3212 }
3213 0 ▶ if ($name eq "null" and class($op) eq "UNOP"
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "null" and B::Deparse::class($op) eq "UNOP" and $op->first->name =~ /^(and|x?or)$/ and null($op->first->sibling)) 0 0 0
Condition0%0/9
$name eq "null" and B::Deparse::class($op) eq "UNOP" and $op->first->name =~ /^(and|x?or)$/ and null($op->first->sibling)
!ll&&!rl&&r
000
$name eq "null" and B::Deparse::class($op) eq "UNOP" and $op->first->name =~ /^(and|x?or)$/
!ll&&!rl&&r
000
$name eq "null" and B::Deparse::class($op) eq "UNOP"
!ll&&!rl&&r
000
MC/DC0%0/4
$name eq "null" and B::Deparse::class($op) eq "UNOP" and $op->first->name =~ /^(and|x?or)$/ and null($op->first->sibling)
$name eq "null" B::Deparse::class($op) eq "UNOP" $op->first->name =~ /^(and|x?or)$/ null($op->first->sibling)
Truth table0%0/5
A and B and C and D
A= $name eq "null"B= B::Deparse::class($op) eq "UNOP"C= $op->first->name =~ /^(and|x?or)$/D= null($op->first->sibling)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
3214 and $op->first->name =~ /^(and|x?or)$/
3215 and null $op->first->sibling)
3216 {
3217 # Like all conditional constructs, OP_ANDs and OP_ORs are topped
3218 # with a null that's used as the common end point of the two
3219 # flows of control. For precedence purposes, ignore it.
3220 # (COND_EXPRs have these too, but we don't bother with
3221 # their associativity).
3222 0 return assoc_class($op->first);
3223 }
3224 0 ▶ return $name . ($op->flags & OPf_STACKED ? "=" : "");
Branch: 1 branch
BranchTrueFalseTotal
$op->flags & 64 ? : 0 0 0
3225 }
3226  
3227 # Left associative operators, like '+', for which
3228 # $a + $b + $c is equivalent to ($a + $b) + $c
3229  
3230 BEGIN {
3231 %left = ('multiply' => 19, 'i_multiply' => 19,
3232 'divide' => 19, 'i_divide' => 19,
3233 'modulo' => 19, 'i_modulo' => 19,
3234 'repeat' => 19,
3235 'add' => 18, 'i_add' => 18,
3236 'subtract' => 18, 'i_subtract' => 18,
3237 'concat' => 18,
3238 'left_shift' => 17, 'right_shift' => 17,
3239 'bit_and' => 13, 'nbit_and' => 13, 'sbit_and' => 13,
3240 'bit_or' => 12, 'bit_xor' => 12,
3241 'sbit_or' => 12, 'sbit_xor' => 12,
3242 'nbit_or' => 12, 'nbit_xor' => 12,
3243 'and' => 3,
3244 'or' => 2, 'xor' => 2,
3245 );
3246 }
3247  
3248 sub deparse_binop_left {
3249 0 ▶ my $self = shift;
Subroutine deparse_binop_left: not called CC=4 SCAR=30.0
Pod undocumented
3250 0 my($op, $left, $prec) = @_;
3251 0 ▶ if ($left{assoc_class($op)} && $left{assoc_class($left)}
Branch: 1 branch
BranchTrueFalseTotal
if ($left{assoc_class($op)} and $left{assoc_class($left)} and $left{assoc_class($op)} == $left{assoc_class($left)}) { } 0 0 0
Condition0%0/6
$left{assoc_class($op)} and $left{assoc_class($left)} and $left{assoc_class($op)} == $left{assoc_class($left)}
!ll&&!rl&&r
000
$left{assoc_class($op)} and $left{assoc_class($left)}
!ll&&!rl&&r
000
MC/DC0%0/3
$left{assoc_class($op)} and $left{assoc_class($left)} and $left{assoc_class($op)} == $left{assoc_class($left)}
$left{assoc_class($op)} $left{assoc_class($left)} $left{assoc_class($op)} == $left{assoc_class($left)}
Truth table0%0/4
A and B and C
A= $left{assoc_class($op)}B= $left{assoc_class($left)}C= $left{assoc_class($op)} == $left{assoc_class($left)}
ABCresult
0XX0
10X0
1100
1111
3252 and $left{assoc_class($op)} == $left{assoc_class($left)})
3253 {
3254 0 return $self->deparse($left, $prec - .00001);
3255 } else {
3256 0 return $self->deparse($left, $prec);
3257 }
3258 }
3259  
3260 # Right associative operators, like '=', for which
3261 # $a = $b = $c is equivalent to $a = ($b = $c)
3262  
3263 BEGIN {
3264 %right = ('pow' => 22,
3265 'sassign=' => 7, 'aassign=' => 7,
3266 'multiply=' => 7, 'i_multiply=' => 7,
3267 'divide=' => 7, 'i_divide=' => 7,
3268 'modulo=' => 7, 'i_modulo=' => 7,
3269 'repeat=' => 7, 'refassign' => 7, 'refassign=' => 7,
3270 'add=' => 7, 'i_add=' => 7,
3271 'subtract=' => 7, 'i_subtract=' => 7,
3272 'concat=' => 7,
3273 'left_shift=' => 7, 'right_shift=' => 7,
3274 'bit_and=' => 7, 'sbit_and=' => 7, 'nbit_and=' => 7,
3275 'nbit_or=' => 7, 'nbit_xor=' => 7,
3276 'sbit_or=' => 7, 'sbit_xor=' => 7,
3277 'andassign' => 7,
3278 'orassign' => 7,
3279 );
3280 }
3281  
3282 sub deparse_binop_right {
3283 0 ▶ my $self = shift;
Subroutine deparse_binop_right: not called CC=4 SCAR=30.0
Pod undocumented
3284 0 my($op, $right, $prec) = @_;
3285 0 ▶ if ($right{assoc_class($op)} && $right{assoc_class($right)}
Branch: 1 branch
BranchTrueFalseTotal
if ($right{assoc_class($op)} and $right{assoc_class($right)} and $right{assoc_class($op)} == $right{assoc_class($right)}) { } 0 0 0
Condition0%0/6
$right{assoc_class($op)} and $right{assoc_class($right)} and $right{assoc_class($op)} == $right{assoc_class($right)}
!ll&&!rl&&r
000
$right{assoc_class($op)} and $right{assoc_class($right)}
!ll&&!rl&&r
000
MC/DC0%0/3
$right{assoc_class($op)} and $right{assoc_class($right)} and $right{assoc_class($op)} == $right{assoc_class($right)}
$right{assoc_class($op)} $right{assoc_class($right)} $right{assoc_class($op)} == $right{assoc_class($right)}
Truth table0%0/4
A and B and C
A= $right{assoc_class($op)}B= $right{assoc_class($right)}C= $right{assoc_class($op)} == $right{assoc_class($right)}
ABCresult
0XX0
10X0
1100
1111
3286 and $right{assoc_class($op)} == $right{assoc_class($right)})
3287 {
3288 0 return $self->deparse($right, $prec - .00001);
3289 } else {
3290 0 return $self->deparse($right, $prec);
3291 }
3292 }
3293  
3294 my %can_warn_about_lhs_not;
3295 BEGIN {
3296 %can_warn_about_lhs_not = map +($_ => 1), qw(
3297 ==
3298 !=
3299 <
3300 <=
3301 >
3302 >=
3303 eq
3304 ne
3305 lt
3306 le
3307 gt
3308 ge
3309 isa
3310 );
3311 }
3312  
3313 sub binop {
3314 0 ▶ my $self = shift;
Subroutine binop: not called CC=12 SCAR=50.5
Pod undocumented
3315 0 my ($op, $cx, $opname, $prec, $flags) = (@_, 0);
3316 0 my $left = $op->first;
3317 0 my $right = $op->last;
3318 0 my $eq = "";
3319 0 ▶ if ($op->flags & OPf_STACKED && $flags & ASSIGN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 64 and $flags & 2) 0 0 0
Condition0%0/3
$op->flags & 64 and $flags & 2
!ll&&!rl&&r
000
MC/DC0%0/2
$op->flags & 64 and $flags & 2
$op->flags & 64 $flags & 2
Truth table0%0/3
A and B
A= $op->flags & 64B= $flags & 2
ABresult
0X0
100
111
3320 0 $eq = "=";
3321 0 $prec = 7;
3322 }
3323 0 ▶ if ($flags & SWAP_CHILDREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flags & 1) 0 0 0
3324 0 ($left, $right) = ($right, $left);
3325 }
3326 0 my $leftop = $left;
3327 0 $left = $self->deparse_binop_left($op, $left, $prec);
3328 $left = "($left)"
3329 if $flags & LIST_CONTEXT
3330 and $left !~ /^(my|our|local|state|)\s*[\@%\(]/
3331 || do {
3332 # Parenthesize if the left argument is a
3333 # lone repeat op.
3334 0 my $left = $leftop->first->sibling;
3335 0 ▶ $left->name eq 'repeat'
Condition0%0/12
$left->name eq 'repeat' && null($left->sibling)
!ll&&!rl&&r
000
$can_warn_about_lhs_not{$opname} and $leftop->name eq "not" and $leftop->flags & 8 and not $left =~ /\(/
!ll&&!rl&&r
000
$can_warn_about_lhs_not{$opname} and $leftop->name eq "not" and $leftop->flags & 8
!ll&&!rl&&r
000
$can_warn_about_lhs_not{$opname} and $leftop->name eq "not"
!ll&&!rl&&r
000
MC/DC0%0/2
$left->name eq 'repeat' && null($left->sibling)
$left->name eq 'repeat' null($left->sibling)
MC/DC0%0/4
$can_warn_about_lhs_not{$opname} and $leftop->name eq "not" and $leftop->flags & 8 and not $left =~ /\(/
$can_warn_about_lhs_not{$opname} $leftop->name eq "not" $leftop->flags & 8 not $left =~ /\(/
Truth table0%0/3
A && B
A= $left->name eq 'repeat'B= null($left->sibling)
ABresult
0X0
100
111
Truth table0%0/5
A and B and C and not(D)
A= $can_warn_about_lhs_not{$opname}B= $leftop->name eq "not"C= $leftop->flags & 8D= not $left =~ /\(/
ABCDresult
0XXX0
10XX0
110X0
11100
11111
3336 && null($left->sibling);
3337 }
3338 or
3339 0 ▶ $can_warn_about_lhs_not{$opname}
Branch: 1 branch
BranchTrueFalseTotal
if $flags & 4 and !($left =~ /^(my|our|local|state|)\s*[\@%\(]/) || do { my $left = $leftop->first->sibling; $left->name eq "repeat" and null($left->sibling) } or $can_warn_about_lhs_not{$opname} and $leftop->name eq "not" and $leftop->flags & 8 and not $left =~ /\(/ 0 0 0
Condition0%0/9
$flags & 4 and !($left =~ /^(my|our|local|state|)\s*[\@%\(]/) || do { my $left = $leftop->first->sibling; $left->name eq "repeat" and null($left->sibling) } or $can_warn_about_lhs_not{$opname} and $leftop->name eq "not" and $leftop->flags & 8 and not $left =~ /\(/
l!l&&r!l&&!r
000
$flags & 4 and !($left =~ /^(my|our|local|state|)\s*[\@%\(]/) || do { my $left = $leftop->first->sibling; $left->name eq "repeat" and null($left->sibling) }
!ll&&!rl&&r
000
not $left =~ /^(my|our|local|state|)\s*[\@%\(]/ or do { my $left = $leftop->first->sibling; $left->name eq "repeat" and null($left->sibling) }
l!l&&r!l&&!r
000
MC/DC0%0/4
$flags & 4 and !($left =~ /^(my|our|local|state|)\s*[\@%\(]/) || do { my $left = $leftop->first->sibling; $left->name eq "repeat" and null($left->sibling) } or $can_warn_about_lhs_not{$opname} and $leftop->name eq "not" and $leftop->flags & 8 and not $left =~ /\(/
$flags & 4 not $left =~ /^(my|our|local|state|)\s*[\@%\(]/ do { my $left = $leftop->first->sibling; $left->name eq "repeat" and null($left->sibling) } $can_warn_about_lhs_not{$opname} and $leftop->name eq "not" and $leftop->flags & 8 and not $left =~ /\(/
Truth table0%0/6
A and not(B) or C or D
A= $flags & 4B= not $left =~ /^(my|our|local|state|)\s*[\@%\(]/C= do { my $left = $leftop->first->sibling; $left->name eq "repeat" and null($left->sibling) }D= $can_warn_about_lhs_not{$opname} and $leftop->name eq "not" and $leftop->flags & 8 and not $left =~ /\(/
ABCDresult
11XX1
101X1
0XX11
10011
0XX00
10000
3340 and $leftop->name eq 'not'
3341 and $leftop->flags & OPf_PARENS
3342 and $left !~ /\(/;
3343 0 $right = $self->deparse_binop_right($op, $right, $prec);
3344 0 return $self->maybe_parens("$left $opname$eq $right", $cx, $prec);
3345 }
3346  
3347 0 ▶sub pp_add { maybe_targmy(@_, \&binop, "+", 18, ASSIGN) }
Subroutine pp_add: not called CC=1 SCAR=6.9
Pod undocumented
3348 0 ▶sub pp_multiply { maybe_targmy(@_, \&binop, "*", 19, ASSIGN) }
Subroutine pp_multiply: not called CC=1 SCAR=6.9
Pod undocumented
3349 0 ▶sub pp_subtract { maybe_targmy(@_, \&binop, "-",18, ASSIGN) }
Subroutine pp_subtract: not called CC=1 SCAR=6.9
Pod undocumented
3350 0 ▶sub pp_divide { maybe_targmy(@_, \&binop, "/", 19, ASSIGN) }
Subroutine pp_divide: not called CC=1 SCAR=6.9
Pod undocumented
3351 0 ▶sub pp_modulo { maybe_targmy(@_, \&binop, "%", 19, ASSIGN) }
Subroutine pp_modulo: not called CC=1 SCAR=6.9
Pod undocumented
3352 0 ▶sub pp_i_add { maybe_targmy(@_, \&binop, "+", 18, ASSIGN) }
Subroutine pp_i_add: not called CC=1 SCAR=6.9
Pod undocumented
3353 0 ▶sub pp_i_multiply { maybe_targmy(@_, \&binop, "*", 19, ASSIGN) }
Subroutine pp_i_multiply: not called CC=1 SCAR=6.9
Pod undocumented
3354 0 ▶sub pp_i_subtract { maybe_targmy(@_, \&binop, "-", 18, ASSIGN) }
Subroutine pp_i_subtract: not called CC=1 SCAR=6.9
Pod undocumented
3355 0 ▶sub pp_i_divide { maybe_targmy(@_, \&binop, "/", 19, ASSIGN) }
Subroutine pp_i_divide: not called CC=1 SCAR=6.9
Pod undocumented
3356 0 ▶sub pp_i_modulo { maybe_targmy(@_, \&binop, "%", 19, ASSIGN) }
Subroutine pp_i_modulo: not called CC=1 SCAR=6.9
Pod undocumented
3357 0 ▶sub pp_pow { maybe_targmy(@_, \&binop, "**", 22, ASSIGN) }
Subroutine pp_pow: not called CC=1 SCAR=6.9
Pod undocumented
3358  
3359 0 ▶sub pp_left_shift { maybe_targmy(@_, \&binop, "<<", 17, ASSIGN) }
Subroutine pp_left_shift: not called CC=1 SCAR=6.9
Pod undocumented
3360 0 ▶sub pp_right_shift { maybe_targmy(@_, \&binop, ">>", 17, ASSIGN) }
Subroutine pp_right_shift: not called CC=1 SCAR=6.9
Pod undocumented
3361 0 ▶sub pp_bit_and { maybe_targmy(@_, \&binop, "&", 13, ASSIGN) }
Subroutine pp_bit_and: not called CC=1 SCAR=6.9
Pod undocumented
3362 0 ▶sub pp_bit_or { maybe_targmy(@_, \&binop, "|", 12, ASSIGN) }
Subroutine pp_bit_or: not called CC=1 SCAR=6.9
Pod undocumented
3363 0 ▶sub pp_bit_xor { maybe_targmy(@_, \&binop, "^", 12, ASSIGN) }
Subroutine pp_bit_xor: not called CC=1 SCAR=6.9
Pod undocumented
3364 *pp_nbit_and = *pp_bit_and;
3365 *pp_nbit_or = *pp_bit_or;
3366 *pp_nbit_xor = *pp_bit_xor;
3367 0 ▶sub pp_sbit_and { maybe_targmy(@_, \&binop, "&.", 13, ASSIGN) }
Subroutine pp_sbit_and: not called CC=1 SCAR=6.9
Pod undocumented
3368 0 ▶sub pp_sbit_or { maybe_targmy(@_, \&binop, "|.", 12, ASSIGN) }
Subroutine pp_sbit_or: not called CC=1 SCAR=6.9
Pod undocumented
3369 0 ▶sub pp_sbit_xor { maybe_targmy(@_, \&binop, "^.", 12, ASSIGN) }
Subroutine pp_sbit_xor: not called CC=1 SCAR=6.9
Pod undocumented
3370  
3371 0 ▶sub pp_eq { binop(@_, "==", 14) }
Subroutine pp_eq: not called CC=1 SCAR=6.9
Pod undocumented
3372 0 ▶sub pp_ne { binop(@_, "!=", 14) }
Subroutine pp_ne: not called CC=1 SCAR=6.9
Pod undocumented
3373 0 ▶sub pp_lt { binop(@_, "<", 15) }
Subroutine pp_lt: not called CC=1 SCAR=6.9
Pod undocumented
3374 0 ▶sub pp_gt { binop(@_, ">", 15) }
Subroutine pp_gt: not called CC=1 SCAR=6.9
Pod undocumented
3375 0 ▶sub pp_ge { binop(@_, ">=", 15) }
Subroutine pp_ge: not called CC=1 SCAR=6.9
Pod undocumented
3376 0 ▶sub pp_le { binop(@_, "<=", 15) }
Subroutine pp_le: not called CC=1 SCAR=6.9
Pod undocumented
3377 0 ▶sub pp_ncmp { binop(@_, "<=>", 14) }
Subroutine pp_ncmp: not called CC=1 SCAR=6.9
Pod undocumented
3378 0 ▶sub pp_i_eq { binop(@_, "==", 14) }
Subroutine pp_i_eq: not called CC=1 SCAR=6.9
Pod undocumented
3379 0 ▶sub pp_i_ne { binop(@_, "!=", 14) }
Subroutine pp_i_ne: not called CC=1 SCAR=6.9
Pod undocumented
3380 0 ▶sub pp_i_lt { binop(@_, "<", 15) }
Subroutine pp_i_lt: not called CC=1 SCAR=6.9
Pod undocumented
3381 0 ▶sub pp_i_gt { binop(@_, ">", 15) }
Subroutine pp_i_gt: not called CC=1 SCAR=6.9
Pod undocumented
3382 0 ▶sub pp_i_ge { binop(@_, ">=", 15) }
Subroutine pp_i_ge: not called CC=1 SCAR=6.9
Pod undocumented
3383 0 ▶sub pp_i_le { binop(@_, "<=", 15) }
Subroutine pp_i_le: not called CC=1 SCAR=6.9
Pod undocumented
3384 0 ▶sub pp_i_ncmp { maybe_targmy(@_, \&binop, "<=>", 14) }
Subroutine pp_i_ncmp: not called CC=1 SCAR=6.9
Pod undocumented
3385  
3386 0 ▶sub pp_seq { binop(@_, "eq", 14) }
Subroutine pp_seq: not called CC=1 SCAR=6.9
Pod undocumented
3387 0 ▶sub pp_sne { binop(@_, "ne", 14) }
Subroutine pp_sne: not called CC=1 SCAR=6.9
Pod undocumented
3388 0 ▶sub pp_slt { binop(@_, "lt", 15) }
Subroutine pp_slt: not called CC=1 SCAR=6.9
Pod undocumented
3389 0 ▶sub pp_sgt { binop(@_, "gt", 15) }
Subroutine pp_sgt: not called CC=1 SCAR=6.9
Pod undocumented
3390 0 ▶sub pp_sge { binop(@_, "ge", 15) }
Subroutine pp_sge: not called CC=1 SCAR=6.9
Pod undocumented
3391 0 ▶sub pp_sle { binop(@_, "le", 15) }
Subroutine pp_sle: not called CC=1 SCAR=6.9
Pod undocumented
3392 0 ▶sub pp_scmp { maybe_targmy(@_, \&binop, "cmp", 14) }
Subroutine pp_scmp: not called CC=1 SCAR=6.9
Pod undocumented
3393  
3394 0 ▶sub pp_isa { binop(@_, "isa", 15) }
Subroutine pp_isa: not called CC=1 SCAR=6.9
Pod undocumented
3395  
3396 0 ▶sub pp_sassign { binop(@_, "=", 7, SWAP_CHILDREN) }
Subroutine pp_sassign: not called CC=1 SCAR=6.9
Pod undocumented
3397 0 ▶sub pp_aassign { binop(@_, "=", 7, SWAP_CHILDREN | LIST_CONTEXT) }
Subroutine pp_aassign: not called CC=1 SCAR=6.9
Pod undocumented
3398  
3399 sub pp_padsv_store {
3400 0 ▶ my $self = shift;
Subroutine pp_padsv_store: not called CC=1 SCAR=6.9
Pod undocumented
3401 0 my ($op, $cx, $forbid_parens, @args) = @_;
3402 0 my $targ = $op->targ;
3403 0 my $var = $self->maybe_my($op, $cx, $self->padname($targ),
3404 $self->padname_sv($targ),
3405 $forbid_parens);
3406  
3407 0 my $val = $self->deparse($op->first, 7);
3408 0 return $self->maybe_parens("$var = $val", $cx, 7);
3409 }
3410  
3411 sub pp_smartmatch {
3412 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_smartmatch: not called CC=3 SCAR=24.8
Pod undocumented
3413 0 ▶ if (($op->flags & OPf_SPECIAL) && $self->{expand} < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 128 and $self->{'expand'} < 2) { } 0 0 0
Condition0%0/3
$op->flags & 128 and $self->{"expand"} < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$op->flags & 128 and $self->{"expand"} < 2
$op->flags & 128 $self->{"expand"} < 2
Truth table0%0/3
A and B
A= $op->flags & 128B= $self->{"expand"} < 2
ABresult
0X0
100
111
3414 0 return $self->deparse($op->last, $cx);
3415 }
3416 else {
3417 0 binop(@_, "~~", 14);
3418 }
3419 }
3420  
3421 # '.' is special because concats-of-concats are optimized to save copying
3422 # by making all but the first concat stacked. The effect is as if the
3423 # programmer had written '($a . $b) .= $c', except legal.
3424 0 ▶sub pp_concat { maybe_targmy(@_, \&real_concat) }
Subroutine pp_concat: not called CC=1 SCAR=6.9
Pod undocumented
3425 sub real_concat {
3426 0 ▶ my $self = shift;
Subroutine real_concat: not called CC=3 SCAR=24.8
Pod undocumented
3427 0 my($op, $cx) = @_;
3428 0 my $left = $op->first;
3429 0 my $right = $op->last;
3430 0 my $eq = "";
3431 0 my $prec = 18;
3432 0 ▶ if (($op->flags & OPf_STACKED) and !($op->private & OPpCONCAT_NESTED)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 64 and not $op->private & 64) 0 0 0
Condition0%0/3
$op->flags & 64 and not $op->private & 64
!ll&&!rl&&r
000
MC/DC0%0/2
$op->flags & 64 and not $op->private & 64
$op->flags & 64 not $op->private & 64
Truth table0%0/3
A and not(B)
A= $op->flags & 64B= not $op->private & 64
ABresult
0X0
100
111
3433 # '.=' rather than optimised '.'
3434 0 $eq = "=";
3435 0 $prec = 7;
3436 }
3437 0 $left = $self->deparse_binop_left($op, $left, $prec);
3438 0 $right = $self->deparse_binop_right($op, $right, $prec);
3439 0 return $self->maybe_parens("$left .$eq $right", $cx, $prec);
3440 }
3441  
3442 0 ▶sub pp_repeat { maybe_targmy(@_, \&repeat) }
Subroutine pp_repeat: not called CC=1 SCAR=6.9
Pod undocumented
3443  
3444 # 'x' is weird when the left arg is a list
3445 sub repeat {
3446 0 ▶ my $self = shift;
Subroutine repeat: not called CC=6 SCAR=37.4
Pod undocumented
3447 0 my($op, $cx) = @_;
3448 0 my $left = $op->first;
3449 0 my $right = $op->last;
3450 0 my $eq = "";
3451 0 my $prec = 19;
3452 0 ▶ if ($op->flags & OPf_STACKED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 64) 0 0 0
3453 0 $eq = "=";
3454 0 $prec = 7;
3455 }
3456 0 ▶ if (null($right)) { # list repeat; count is inside left-side ex-list
Branch: 1 branch
BranchTrueFalseTotal
if (null($right)) { } 0 0 0
3457 # in 5.21.5 and earlier
3458 0 my $kid = $left->first->sibling; # skip pushmark
3459 0 my @exprs;
3460 0 ▶ for (; !null($kid->sibling); $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid->sibling)) 0 0 0
3461 0 push @exprs, $self->deparse($kid, 6);
3462 }
3463 0 $right = $kid;
3464 0 $left = "(" . join(", ", @exprs). ")";
3465 } else {
3466 0 my $dolist = $op->private & OPpREPEAT_DOLIST;
3467 0 ▶ $left = $self->deparse_binop_left($op, $left, $dolist ? 1 : $prec);
Branch: 1 branch
BranchTrueFalseTotal
$dolist ? : 0 0 0
3468 0 ▶ if ($dolist) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dolist) 0 0 0
3469 0 $left = "($left)";
3470 }
3471 }
3472 0 $right = $self->deparse_binop_right($op, $right, $prec);
3473 0 return $self->maybe_parens("$left x$eq $right", $cx, $prec);
3474 }
3475  
3476 sub range {
3477 0 ▶ my $self = shift;
Subroutine range: not called CC=1 SCAR=6.9
Pod undocumented
3478 0 my ($op, $cx, $type) = @_;
3479 0 my $left = $op->first;
3480 0 my $right = $left->sibling;
3481 0 $left = $self->deparse($left, 9);
3482 0 $right = $self->deparse($right, 9);
3483 0 return $self->maybe_parens("$left $type $right", $cx, 9);
3484 }
3485  
3486 sub pp_flop {
3487 0 ▶ my $self = shift;
Subroutine pp_flop: not called CC=2 SCAR=17.9
Pod undocumented
3488 0 my($op, $cx) = @_;
3489 0 my $flip = $op->first;
3490 0 ▶ my $type = ($flip->flags & OPf_SPECIAL) ? "..." : "..";
Branch: 1 branch
BranchTrueFalseTotal
$flip->flags & 128 ? : 0 0 0
3491 0 return $self->range($flip->first, $cx, $type);
3492 }
3493  
3494 # one-line while/until is handled in pp_leave
3495  
3496 sub logop {
3497 0 ▶ my $self = shift;
Subroutine logop: not called CC=6 SCAR=37.4
Pod undocumented
3498 0 my ($op, $cx, $lowop, $lowprec, $highop, $highprec, $blockname) = @_;
3499 0 my $left = $op->first;
3500 0 my $right = $op->first->sibling;
3501 0 ▶ $blockname &&= $self->keyword($blockname);
Condition0%0/3
$blockname &&= $self->keyword($blockname)
!ll&&!rl&&r
000
MC/DC0%0/2
$blockname &&= $self->keyword($blockname)
$blockname $self->keyword($blockname)
Truth table0%0/3
A &&= B
A= $blocknameB= $self->keyword($blockname)
ABresult
0X0
100
111
3502  
3503 0 ▶ if ($op->private & OPpSTATEMENT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 64) { } 0 0 0
3504 0 ▶ if (is_scope($right)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_scope($right)) { } 0 0 0
3505 # if ($a) {$b}
3506 0 $left = $self->deparse($left, 1);
3507 0 $right = $self->deparse($right, 0);
3508 0 return "$blockname ($left) {\n\t$right\n\b}\cK";
3509 }
3510 else {
3511 # $b if $a
3512 0 $right = $self->deparse($right, 1);
3513 0 $left = $self->deparse($left, 1);
3514 0 return "$right $blockname $left";
3515 }
3516 }
3517 else {
3518 0 ▶ if ($cx > $lowprec and $highop) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cx > $lowprec and $highop) { } 0 0 0
Condition0%0/3
$cx > $lowprec and $highop
!ll&&!rl&&r
000
MC/DC0%0/2
$cx > $lowprec and $highop
$cx > $lowprec $highop
Truth table0%0/3
A and B
A= $cx > $lowprecB= $highop
ABresult
0X0
100
111
3519 # $a && $b
3520 0 $left = $self->deparse_binop_left($op, $left, $highprec);
3521 0 $right = $self->deparse_binop_right($op, $right, $highprec);
3522 0 return $self->maybe_parens("$left $highop $right", $cx, $highprec);
3523 } else {
3524 # $a and $b
3525 0 $left = $self->deparse_binop_left($op, $left, $lowprec);
3526 0 $right = $self->deparse_binop_right($op, $right, $lowprec);
3527 0 return $self->maybe_parens("$left $lowop $right", $cx, $lowprec);
3528 }
3529 }
3530 }
3531  
3532 0 ▶sub pp_and { logop(@_, "and", 3, "&&", 11, "if") }
Subroutine pp_and: not called CC=1 SCAR=6.9
Pod undocumented
3533 0 ▶sub pp_or { logop(@_, "or", 2, "||", 10, "unless") }
Subroutine pp_or: not called CC=1 SCAR=6.9
Pod undocumented
3534 0 ▶sub pp_dor { logop(@_, "//", 10) }
Subroutine pp_dor: not called CC=1 SCAR=6.9
Pod undocumented
3535  
3536 sub pp_xor {
3537 0 ▶ my $self = shift;
Subroutine pp_xor: not called CC=3 SCAR=24.8
Pod undocumented
3538 0 my ($op, $cx) = @_;
3539 0 ▶ if ($cx > 2 or $op->flags & OPf_STACKED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cx > 2 or $op->flags & 64) { } 0 0 0
Condition0%0/3
$cx > 2 or $op->flags & 64
l!l&&r!l&&!r
000
MC/DC0%0/2
$cx > 2 or $op->flags & 64
$cx > 2 $op->flags & 64
Truth table0%0/3
A or B
A= $cx > 2B= $op->flags & 64
ABresult
1X1
011
000
3540 0 binop($self, @_, "^^", 10, ASSIGN);
3541 }
3542 else {
3543 0 binop($self, @_, "xor", 2);
3544 }
3545 }
3546  
3547 sub logassignop {
3548 0 ▶ my $self = shift;
Subroutine logassignop: not called CC=1 SCAR=6.9
Pod undocumented
3549 0 my ($op, $cx, $opname) = @_;
3550 0 my $left = $op->first;
3551 0 my $right = $op->first->sibling->first; # skip sassign
3552 0 $left = $self->deparse($left, 7);
3553 0 $right = $self->deparse($right, 7);
3554 0 return $self->maybe_parens("$left $opname $right", $cx, 7);
3555 }
3556  
3557 0 ▶sub pp_andassign { logassignop(@_, "&&=") }
Subroutine pp_andassign: not called CC=1 SCAR=6.9
Pod undocumented
3558 0 ▶sub pp_orassign { logassignop(@_, "||=") }
Subroutine pp_orassign: not called CC=1 SCAR=6.9
Pod undocumented
3559 0 ▶sub pp_dorassign { logassignop(@_, "//=") }
Subroutine pp_dorassign: not called CC=1 SCAR=6.9
Pod undocumented
3560  
3561 my %cmpchain_cmpops = (
3562 eq => ["==", 14],
3563 i_eq => ["==", 14],
3564 ne => ["!=", 14],
3565 i_ne => ["!=", 14],
3566 seq => ["eq", 14],
3567 sne => ["ne", 14],
3568 lt => ["<", 15],
3569 i_lt => ["<", 15],
3570 gt => [">", 15],
3571 i_gt => [">", 15],
3572 le => ["<=", 15],
3573 i_le => ["<=", 15],
3574 ge => [">=", 15],
3575 i_ge => [">=", 15],
3576 slt => ["lt", 15],
3577 sgt => ["gt", 15],
3578 sle => ["le", 15],
3579 sge => ["ge", 15],
3580 );
3581 sub pp_cmpchain_and {
3582 0 ▶ my($self, $op, $cx) = @_;
Subroutine pp_cmpchain_and: not called CC=13 SCAR=52.0
Pod undocumented
3583 0 my($prec, $dep);
3584 0 while(1) {
3585 0 my($thiscmp, $rightcond);
3586 0 ▶ if($op->name eq "cmpchain_and") {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->name eq 'cmpchain_and') { } 0 0 0
3587 0 $thiscmp = $op->first;
3588 0 $rightcond = $thiscmp->sibling;
3589 } else {
3590 0 $thiscmp = $op;
3591 }
3592 0 ▶ my $thiscmptype = $cmpchain_cmpops{$thiscmp->name} // (return "XXX");
Condition0%0/2
$cmpchain_cmpops{$thiscmp->name} // (return "XXX")
l!l
00
MC/DC0%0/1
$cmpchain_cmpops{$thiscmp->name} // (return "XXX")
$cmpchain_cmpops{$thiscmp->name}
Truth table0%0/2
A
A= $cmpchain_cmpops{$thiscmp->name}
Aresult
11
00
3593 0 ▶ if(defined $prec) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $prec) { } 0 0 0
3594 0 ▶ $thiscmptype->[1] == $prec or return "XXX";
Branch: 1 branch
BranchTrueFalseTotal
$thiscmptype->[1] == $prec or return "XXX" 0 0 0
3595 0 ▶ $thiscmp->first->name eq "null" &&
Branch: 1 branch
BranchTrueFalseTotal
$thiscmp->first->name eq "null" and not $thiscmp->first->flags & 4 or return "XXX" 0 0 0
Condition0%0/3
$thiscmp->first->name eq "null" and not $thiscmp->first->flags & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$thiscmp->first->name eq "null" and not $thiscmp->first->flags & 4
$thiscmp->first->name eq "null" not $thiscmp->first->flags & 4
Truth table0%0/3
A and not(B)
A= $thiscmp->first->name eq "null"B= not $thiscmp->first->flags & 4
ABresult
0X0
100
111
3596 !($thiscmp->first->flags & OPf_KIDS)
3597 or return "XXX";
3598 } else {
3599 0 $prec = $thiscmptype->[1];
3600 0 $dep = $self->deparse($thiscmp->first, $prec);
3601 }
3602 0 $dep .= " ".$thiscmptype->[0]." ";
3603 0 my $operand = $thiscmp->last;
3604 0 ▶ if(defined $rightcond) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rightcond) 0 0 0
3605 0 ▶ $operand->name eq "cmpchain_dup" or return "XXX";
Branch: 1 branch
BranchTrueFalseTotal
$operand->name eq "cmpchain_dup" or return "XXX" 0 0 0
3606 0 $operand = $operand->first;
3607 }
3608 0 $dep .= $self->deparse($operand, $prec);
3609 0 ▶ last unless defined $rightcond;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rightcond 0 0 0
3610 0 ▶ if($rightcond->name eq "null" && ($rightcond->flags & OPf_KIDS) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($rightcond->name eq "null" and $rightcond->flags & 4 and $rightcond->first->name eq "cmpchain_and") 0 0 0
Condition0%0/6
$rightcond->name eq "null" and $rightcond->flags & 4 and $rightcond->first->name eq "cmpchain_and"
!ll&&!rl&&r
000
$rightcond->name eq "null" and $rightcond->flags & 4
!ll&&!rl&&r
000
MC/DC0%0/3
$rightcond->name eq "null" and $rightcond->flags & 4 and $rightcond->first->name eq "cmpchain_and"
$rightcond->name eq "null" $rightcond->flags & 4 $rightcond->first->name eq "cmpchain_and"
Truth table0%0/4
A and B and C
A= $rightcond->name eq "null"B= $rightcond->flags & 4C= $rightcond->first->name eq "cmpchain_and"
ABCresult
0XX0
10X0
1100
1111
3611 $rightcond->first->name eq "cmpchain_and") {
3612 0 $rightcond = $rightcond->first;
3613 }
3614 0 $op = $rightcond;
3615 }
3616 0 return $self->maybe_parens($dep, $cx, $prec);
3617 }
3618  
3619 sub rv2gv_or_string {
3620 0 ▶ my($self,$op) = @_;
Subroutine rv2gv_or_string: not called CC=3 SCAR=24.8
Pod undocumented
3621 0 ▶ if ($op->name eq "gv") { # could be open("open") or open("###")
Branch: 1 branch
BranchTrueFalseTotal
if ($op->name eq 'gv') { } 0 0 0
3622 0 my($name,$quoted) =
3623 $self->stash_variable_name("", $self->gv_or_padgv($op));
3624 0 ▶ $quoted ? $name : "*$name";
Branch: 1 branch
BranchTrueFalseTotal
$quoted ? : 0 0 0
3625 }
3626 else {
3627 0 $self->deparse($op, 6);
3628 }
3629 }
3630  
3631 sub listop {
3632 0 ▶ my $self = shift;
Subroutine listop: not called CC=26 SCAR=65.5
Pod undocumented
3633 0 my($op, $cx, $name, $kid, $nollafr) = @_;
3634 0 my(@exprs);
3635 0 ▶ my $parens = ($cx >= 5) || $self->{'parens'};
Condition0%0/3
$cx >= 5 || $self->{'parens'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cx >= 5 || $self->{'parens'}
$cx >= 5 $self->{'parens'}
Truth table0%0/3
A || B
A= $cx >= 5B= $self->{'parens'}
ABresult
1X1
011
000
3636 0 ▶ $kid ||= $op->first->sibling;
Condition0%0/3
$kid ||= $op->first->sibling
l!l&&r!l&&!r
000
MC/DC0%0/2
$kid ||= $op->first->sibling
$kid $op->first->sibling
Truth table0%0/3
A ||= B
A= $kidB= $op->first->sibling
ABresult
1X1
011
000
3637 # If there are no arguments, add final parentheses (or parenthesize the
3638 # whole thing if the llafr does not apply) to account for cases like
3639 # (return)+1 or setpgrp()+1. When the llafr does not apply, we use a
3640 # precedence of 6 (< comma), as "return, 1" does not need parentheses.
3641 0 ▶ if (null $kid) {
Branch: 1 branch
BranchTrueFalseTotal
if (null($kid)) 0 0 0
3642 0 ▶ return $nollafr
Branch: 1 branch
BranchTrueFalseTotal
$nollafr ? : 0 0 0
3643 ? $self->maybe_parens($self->keyword($name), $cx, 7)
3644 : $self->keyword($name) . '()' x (7 < $cx);
3645 }
3646 0 my $first;
3647 0 my $fullname = $self->keyword($name);
3648 0 my $proto = prototype("CORE::$name");
3649 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proto && $proto =~ /^;?\*/ || $name eq 'select' and $kid->name eq 'rv2gv' and not $kid->private & 128) { } 0 0 0
Condition0%0/12
defined $proto && $proto =~ /^;?\*/ || $name eq "select" and $kid->name eq "rv2gv" and not $kid->private & 128
!ll&&!rl&&r
000
defined $proto && $proto =~ /^;?\*/ || $name eq "select" and $kid->name eq "rv2gv"
!ll&&!rl&&r
000
defined $proto and $proto =~ /^;?\*/ or $name eq "select"
l!l&&r!l&&!r
000
defined $proto and $proto =~ /^;?\*/
!ll&&!rl&&r
000
MC/DC0%0/5
defined $proto && $proto =~ /^;?\*/ || $name eq "select" and $kid->name eq "rv2gv" and not $kid->private & 128
defined $proto $proto =~ /^;?\*/ $name eq "select" $kid->name eq "rv2gv" not $kid->private & 128
Truth table0%0/11
A and B or C and D and not(E)
A= defined $protoB= $proto =~ /^;?\*/C= $name eq "select"D= $kid->name eq "rv2gv"E= not $kid->private & 128
ABCDEresult
0X0XX0
100XX0
11X0X0
0X10X0
1010X0
11X100
0X1100
101100
11X111
0X1111
101111
3650 ( (defined $proto && $proto =~ /^;?\*/)
3651 || $name eq 'select' # select(F) doesn't have a proto
3652 )
3653 && $kid->name eq "rv2gv"
3654 && !($kid->private & OPpLVAL_INTRO)
3655 ) {
3656 0 $first = $self->rv2gv_or_string($kid->first);
3657 }
3658 else {
3659 0 $first = $self->deparse($kid, 6);
3660 }
3661 0 ▶ if ($name eq "chmod" && $first =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "chmod" and $first =~ /^\d+$/) 0 0 0
Condition0%0/3
$name eq "chmod" and $first =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "chmod" and $first =~ /^\d+$/
$name eq "chmod" $first =~ /^\d+$/
Truth table0%0/3
A and B
A= $name eq "chmod"B= $first =~ /^\d+$/
ABresult
0X0
100
111
3662 0 $first = sprintf("%#o", $first);
3663 }
3664 0 ▶ $first = "+$first"
Branch: 1 branch
BranchTrueFalseTotal
if not $parens || $nollafr and substr($first, 0, 1) eq "(" 0 0 0
Condition0%0/6
not $parens || $nollafr and substr($first, 0, 1) eq "("
!ll&&!rl&&r
000
$parens || $nollafr
l!l&&r!l&&!r
000
MC/DC0%0/3
not $parens || $nollafr and substr($first, 0, 1) eq "("
$parens $nollafr substr($first, 0, 1) eq "("
Truth table0%0/4
not(A || B) and C
A= $parensB= $nollafrC= substr($first, 0, 1) eq "("
ABCresult
1XX0
01X0
0000
0011
3665 if not $parens and not $nollafr and substr($first, 0, 1) eq "(";
3666 0 push @exprs, $first;
3667 0 $kid = $kid->sibling;
3668 0 ▶ if (defined $proto && $proto =~ /^\*\*/ && $kid->name eq "rv2gv"
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proto and $proto =~ /^\*\*/ and $kid->name eq "rv2gv" and not $kid->private & 128) 0 0 0
Condition0%0/9
defined $proto and $proto =~ /^\*\*/ and $kid->name eq "rv2gv" and not $kid->private & 128
!ll&&!rl&&r
000
defined $proto and $proto =~ /^\*\*/ and $kid->name eq "rv2gv"
!ll&&!rl&&r
000
defined $proto and $proto =~ /^\*\*/
!ll&&!rl&&r
000
MC/DC0%0/4
defined $proto and $proto =~ /^\*\*/ and $kid->name eq "rv2gv" and not $kid->private & 128
defined $proto $proto =~ /^\*\*/ $kid->name eq "rv2gv" not $kid->private & 128
Truth table0%0/5
A and B and C and not(D)
A= defined $protoB= $proto =~ /^\*\*/C= $kid->name eq "rv2gv"D= not $kid->private & 128
ABCDresult
0XXX0
10XX0
110X0
11100
11111
3669 && !($kid->private & OPpLVAL_INTRO)) {
3670 0 push @exprs, $first = $self->rv2gv_or_string($kid->first);
3671 0 $kid = $kid->sibling;
3672 }
3673 0 ▶ for (; !null($kid); $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
3674 0 push @exprs, $self->deparse($kid, 6);
3675 }
3676 0 ▶ if ($name eq "reverse" && ($op->private & OPpREVERSE_INPLACE)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "reverse" and $op->private & 8) 0 0 0
Condition0%0/3
$name eq "reverse" and $op->private & 8
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "reverse" and $op->private & 8
$name eq "reverse" $op->private & 8
Truth table0%0/3
A and B
A= $name eq "reverse"B= $op->private & 8
ABresult
0X0
100
111
3677 0 ▶ return "$exprs[0] = $fullname"
Branch: 1 branch
BranchTrueFalseTotal
$parens ? : 0 0 0
3678 . ($parens ? "($exprs[0])" : " $exprs[0]");
3679 }
3680  
3681 0 ▶ if ($parens && $nollafr) {
Branch: 2 branches
BranchTrueFalseTotal
if ($parens and $nollafr) { } 0 0 0
elsif ($parens) { } 0 0 0
Condition0%0/3
$parens and $nollafr
!ll&&!rl&&r
000
MC/DC0%0/2
$parens and $nollafr
$parens $nollafr
Truth table0%0/3
A and B
A= $parensB= $nollafr
ABresult
0X0
100
111
3682 0 return "($fullname " . join(", ", @exprs) . ")";
3683 } elsif ($parens) {
3684 0 return "$fullname(" . join(", ", @exprs) . ")";
3685 } else {
3686 0 return "$fullname " . join(", ", @exprs);
3687 }
3688 }
3689  
3690 0 ▶sub pp_bless { listop(@_, "bless") }
Subroutine pp_bless: not called CC=1 SCAR=6.9
Pod undocumented
3691 0 ▶sub pp_atan2 { maybe_targmy(@_, \&listop, "atan2") }
Subroutine pp_atan2: not called CC=1 SCAR=6.9
Pod undocumented
3692 sub pp_substr {
3693 0 ▶ my ($self,$op,$cx) = @_;
Subroutine pp_substr: not called CC=2 SCAR=17.9
Pod undocumented
3694 0 ▶ if ($op->private & OPpSUBSTR_REPL_FIRST) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 16) 0 0 0
3695 return
3696 0 listop($self, $op, 7, "substr", $op->first->sibling->sibling)
3697 . " = "
3698 . $self->deparse($op->first->sibling, 7);
3699 }
3700 0 maybe_local(@_, listop(@_, "substr"))
3701 }
3702  
3703 sub pp_substr_left {
3704 0 ▶ my ($self,$op,$cx) = @_;
Subroutine pp_substr_left: not called CC=3 SCAR=24.8
Pod undocumented
3705  
3706 0 my $lex = ($op->private & OPpTARGET_MY);
3707  
3708 0 ▶ my $val = 'substr(' . $self->deparse($op->first->sibling, $cx)
Branch: 1 branch
BranchTrueFalseTotal
($op->private & 7) == 3 ? : 0 0 0
3709 . ', 0, ' . $self->deparse($op->first->sibling->sibling->sibling, $cx)
3710 . ( (($op->private & 7) == 3) ? ')' : ", '')" );
3711  
3712 0 ▶ if ($lex) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lex) 0 0 0
3713 0 my $targ = $op->targ;
3714 0 my $var = $self->maybe_my($op, $cx, $self->padname($op->targ),
3715 $self->padname_sv($targ),
3716 0);
3717 0 $val = $self->maybe_parens("$var = $val", $cx, 7);
3718 }
3719 0 $val;
3720 }
3721  
3722 sub pp_index {
3723 # Also handles pp_rindex.
3724 #
3725 # The body of this function includes an unrolled maybe_targmy(),
3726 # since the two parts of that sub's actions need to have have the
3727 # '== -1' bit in between
3728  
3729 0 ▶ my($self, $op, $cx) = @_;
Subroutine pp_index: not called CC=7 SCAR=40.3
Pod undocumented
3730  
3731 0 my $lex = ($op->private & OPpTARGET_MY);
3732 0 my $bool = ($op->private & OPpTRUEBOOL);
3733  
3734 0 ▶ my $val = $self->listop($op, ($bool ? 14 : $lex ? 7 : $cx), $op->name);
Branch: 2 branches
BranchTrueFalseTotal
$bool ? : 0 0 0
$lex ? : 0 0 0
3735  
3736 # (index() == -1) has op_eq and op_const optimised away
3737 0 ▶ if ($bool) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bool) 0 0 0
3738 0 ▶ $val .= ($op->private & OPpINDEX_BOOLNEG) ? " == -1" : " != -1";
Branch: 1 branch
BranchTrueFalseTotal
$op->private & 64 ? : 0 0 0
3739 0 ▶ $val = "($val)" if ($op->flags & OPf_PARENS);
Branch: 1 branch
BranchTrueFalseTotal
if $op->flags & 8 0 0 0
3740 }
3741 0 ▶ if ($lex) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lex) 0 0 0
3742 0 my $var = $self->padname($op->targ);
3743 0 $val = $self->maybe_parens("$var = $val", $cx, 7);
3744 }
3745 0 $val;
3746 }
3747  
3748 0 ▶sub pp_rindex { pp_index(@_); }
Subroutine pp_rindex: not called CC=1 SCAR=6.9
Pod undocumented
3749 0 ▶sub pp_vec { maybe_targmy(@_, \&maybe_local, listop(@_, "vec")) }
Subroutine pp_vec: not called CC=1 SCAR=6.9
Pod undocumented
3750 0 ▶sub pp_sprintf { maybe_targmy(@_, \&listop, "sprintf") }
Subroutine pp_sprintf: not called CC=1 SCAR=6.9
Pod undocumented
3751 0 ▶sub pp_formline { listop(@_, "formline") } # see also deparse_format
Subroutine pp_formline: not called CC=1 SCAR=6.9
Pod undocumented
3752 0 ▶sub pp_crypt { maybe_targmy(@_, \&listop, "crypt") }
Subroutine pp_crypt: not called CC=1 SCAR=6.9
Pod undocumented
3753 0 ▶sub pp_unpack { listop(@_, "unpack") }
Subroutine pp_unpack: not called CC=1 SCAR=6.9
Pod undocumented
3754 0 ▶sub pp_pack { listop(@_, "pack") }
Subroutine pp_pack: not called CC=1 SCAR=6.9
Pod undocumented
3755 0 ▶sub pp_join { maybe_targmy(@_, \&listop, "join") }
Subroutine pp_join: not called CC=1 SCAR=6.9
Pod undocumented
3756 0 ▶sub pp_splice { listop(@_, "splice") }
Subroutine pp_splice: not called CC=1 SCAR=6.9
Pod undocumented
3757 0 ▶sub pp_push { maybe_targmy(@_, \&listop, "push") }
Subroutine pp_push: not called CC=1 SCAR=6.9
Pod undocumented
3758 0 ▶sub pp_unshift { maybe_targmy(@_, \&listop, "unshift") }
Subroutine pp_unshift: not called CC=1 SCAR=6.9
Pod undocumented
3759 0 ▶sub pp_reverse { listop(@_, "reverse") }
Subroutine pp_reverse: not called CC=1 SCAR=6.9
Pod undocumented
3760 0 ▶sub pp_warn { listop(@_, "warn") }
Subroutine pp_warn: not called CC=1 SCAR=6.9
Pod undocumented
3761 0 ▶sub pp_die { listop(@_, "die") }
Subroutine pp_die: not called CC=1 SCAR=6.9
Pod undocumented
3762 0 ▶sub pp_return { listop(@_, "return", undef, 1) } # llafr does not apply
Subroutine pp_return: not called CC=1 SCAR=6.9
Pod undocumented
3763 0 ▶sub pp_open { listop(@_, "open") }
Subroutine pp_open: not called CC=1 SCAR=6.9
Pod undocumented
3764 0 ▶sub pp_pipe_op { listop(@_, "pipe") }
Subroutine pp_pipe_op: not called CC=1 SCAR=6.9
Pod undocumented
3765 0 ▶sub pp_tie { listop(@_, "tie") }
Subroutine pp_tie: not called CC=1 SCAR=6.9
Pod undocumented
3766 0 ▶sub pp_binmode { listop(@_, "binmode") }
Subroutine pp_binmode: not called CC=1 SCAR=6.9
Pod undocumented
3767 0 ▶sub pp_dbmopen { listop(@_, "dbmopen") }
Subroutine pp_dbmopen: not called CC=1 SCAR=6.9
Pod undocumented
3768 0 ▶sub pp_sselect { listop(@_, "select") }
Subroutine pp_sselect: not called CC=1 SCAR=6.9
Pod undocumented
3769 0 ▶sub pp_select { listop(@_, "select") }
Subroutine pp_select: not called CC=1 SCAR=6.9
Pod undocumented
3770 0 ▶sub pp_read { listop(@_, "read") }
Subroutine pp_read: not called CC=1 SCAR=6.9
Pod undocumented
3771 0 ▶sub pp_sysopen { listop(@_, "sysopen") }
Subroutine pp_sysopen: not called CC=1 SCAR=6.9
Pod undocumented
3772 0 ▶sub pp_sysseek { listop(@_, "sysseek") }
Subroutine pp_sysseek: not called CC=1 SCAR=6.9
Pod undocumented
3773 0 ▶sub pp_sysread { listop(@_, "sysread") }
Subroutine pp_sysread: not called CC=1 SCAR=6.9
Pod undocumented
3774 0 ▶sub pp_syswrite { listop(@_, "syswrite") }
Subroutine pp_syswrite: not called CC=1 SCAR=6.9
Pod undocumented
3775 0 ▶sub pp_send { listop(@_, "send") }
Subroutine pp_send: not called CC=1 SCAR=6.9
Pod undocumented
3776 0 ▶sub pp_recv { listop(@_, "recv") }
Subroutine pp_recv: not called CC=1 SCAR=6.9
Pod undocumented
3777 0 ▶sub pp_seek { listop(@_, "seek") }
Subroutine pp_seek: not called CC=1 SCAR=6.9
Pod undocumented
3778 0 ▶sub pp_fcntl { listop(@_, "fcntl") }
Subroutine pp_fcntl: not called CC=1 SCAR=6.9
Pod undocumented
3779 0 ▶sub pp_ioctl { listop(@_, "ioctl") }
Subroutine pp_ioctl: not called CC=1 SCAR=6.9
Pod undocumented
3780 0 ▶sub pp_flock { maybe_targmy(@_, \&listop, "flock") }
Subroutine pp_flock: not called CC=1 SCAR=6.9
Pod undocumented
3781 0 ▶sub pp_socket { listop(@_, "socket") }
Subroutine pp_socket: not called CC=1 SCAR=6.9
Pod undocumented
3782 0 ▶sub pp_sockpair { listop(@_, "socketpair") }
Subroutine pp_sockpair: not called CC=1 SCAR=6.9
Pod undocumented
3783 0 ▶sub pp_bind { listop(@_, "bind") }
Subroutine pp_bind: not called CC=1 SCAR=6.9
Pod undocumented
3784 0 ▶sub pp_connect { listop(@_, "connect") }
Subroutine pp_connect: not called CC=1 SCAR=6.9
Pod undocumented
3785 0 ▶sub pp_listen { listop(@_, "listen") }
Subroutine pp_listen: not called CC=1 SCAR=6.9
Pod undocumented
3786 0 ▶sub pp_accept { listop(@_, "accept") }
Subroutine pp_accept: not called CC=1 SCAR=6.9
Pod undocumented
3787 0 ▶sub pp_shutdown { listop(@_, "shutdown") }
Subroutine pp_shutdown: not called CC=1 SCAR=6.9
Pod undocumented
3788 0 ▶sub pp_gsockopt { listop(@_, "getsockopt") }
Subroutine pp_gsockopt: not called CC=1 SCAR=6.9
Pod undocumented
3789 0 ▶sub pp_ssockopt { listop(@_, "setsockopt") }
Subroutine pp_ssockopt: not called CC=1 SCAR=6.9
Pod undocumented
3790 0 ▶sub pp_chown { maybe_targmy(@_, \&listop, "chown") }
Subroutine pp_chown: not called CC=1 SCAR=6.9
Pod undocumented
3791 0 ▶sub pp_unlink { maybe_targmy(@_, \&listop, "unlink") }
Subroutine pp_unlink: not called CC=1 SCAR=6.9
Pod undocumented
3792 0 ▶sub pp_chmod { maybe_targmy(@_, \&listop, "chmod") }
Subroutine pp_chmod: not called CC=1 SCAR=6.9
Pod undocumented
3793 0 ▶sub pp_utime { maybe_targmy(@_, \&listop, "utime") }
Subroutine pp_utime: not called CC=1 SCAR=6.9
Pod undocumented
3794 0 ▶sub pp_rename { maybe_targmy(@_, \&listop, "rename") }
Subroutine pp_rename: not called CC=1 SCAR=6.9
Pod undocumented
3795 0 ▶sub pp_link { maybe_targmy(@_, \&listop, "link") }
Subroutine pp_link: not called CC=1 SCAR=6.9
Pod undocumented
3796 0 ▶sub pp_symlink { maybe_targmy(@_, \&listop, "symlink") }
Subroutine pp_symlink: not called CC=1 SCAR=6.9
Pod undocumented
3797 0 ▶sub pp_mkdir { maybe_targmy(@_, \&listop, "mkdir") }
Subroutine pp_mkdir: not called CC=1 SCAR=6.9
Pod undocumented
3798 0 ▶sub pp_open_dir { listop(@_, "opendir") }
Subroutine pp_open_dir: not called CC=1 SCAR=6.9
Pod undocumented
3799 0 ▶sub pp_seekdir { listop(@_, "seekdir") }
Subroutine pp_seekdir: not called CC=1 SCAR=6.9
Pod undocumented
3800 0 ▶sub pp_waitpid { maybe_targmy(@_, \&listop, "waitpid") }
Subroutine pp_waitpid: not called CC=1 SCAR=6.9
Pod undocumented
3801 0 ▶sub pp_system { maybe_targmy(@_, \&indirop, "system") }
Subroutine pp_system: not called CC=1 SCAR=6.9
Pod undocumented
3802 0 ▶sub pp_exec { maybe_targmy(@_, \&indirop, "exec") }
Subroutine pp_exec: not called CC=1 SCAR=6.9
Pod undocumented
3803 0 ▶sub pp_kill { maybe_targmy(@_, \&listop, "kill") }
Subroutine pp_kill: not called CC=1 SCAR=6.9
Pod undocumented
3804 0 ▶sub pp_setpgrp { maybe_targmy(@_, \&listop, "setpgrp") }
Subroutine pp_setpgrp: not called CC=1 SCAR=6.9
Pod undocumented
3805 0 ▶sub pp_getpriority { maybe_targmy(@_, \&listop, "getpriority") }
Subroutine pp_getpriority: not called CC=1 SCAR=6.9
Pod undocumented
3806 0 ▶sub pp_setpriority { maybe_targmy(@_, \&listop, "setpriority") }
Subroutine pp_setpriority: not called CC=1 SCAR=6.9
Pod undocumented
3807 0 ▶sub pp_shmget { listop(@_, "shmget") }
Subroutine pp_shmget: not called CC=1 SCAR=6.9
Pod undocumented
3808 0 ▶sub pp_shmctl { listop(@_, "shmctl") }
Subroutine pp_shmctl: not called CC=1 SCAR=6.9
Pod undocumented
3809 0 ▶sub pp_shmread { listop(@_, "shmread") }
Subroutine pp_shmread: not called CC=1 SCAR=6.9
Pod undocumented
3810 0 ▶sub pp_shmwrite { listop(@_, "shmwrite") }
Subroutine pp_shmwrite: not called CC=1 SCAR=6.9
Pod undocumented
3811 0 ▶sub pp_msgget { listop(@_, "msgget") }
Subroutine pp_msgget: not called CC=1 SCAR=6.9
Pod undocumented
3812 0 ▶sub pp_msgctl { listop(@_, "msgctl") }
Subroutine pp_msgctl: not called CC=1 SCAR=6.9
Pod undocumented
3813 0 ▶sub pp_msgsnd { listop(@_, "msgsnd") }
Subroutine pp_msgsnd: not called CC=1 SCAR=6.9
Pod undocumented
3814 0 ▶sub pp_msgrcv { listop(@_, "msgrcv") }
Subroutine pp_msgrcv: not called CC=1 SCAR=6.9
Pod undocumented
3815 0 ▶sub pp_semget { listop(@_, "semget") }
Subroutine pp_semget: not called CC=1 SCAR=6.9
Pod undocumented
3816 0 ▶sub pp_semctl { listop(@_, "semctl") }
Subroutine pp_semctl: not called CC=1 SCAR=6.9
Pod undocumented
3817 0 ▶sub pp_semop { listop(@_, "semop") }
Subroutine pp_semop: not called CC=1 SCAR=6.9
Pod undocumented
3818 0 ▶sub pp_ghbyaddr { listop(@_, "gethostbyaddr") }
Subroutine pp_ghbyaddr: not called CC=1 SCAR=6.9
Pod undocumented
3819 0 ▶sub pp_gnbyaddr { listop(@_, "getnetbyaddr") }
Subroutine pp_gnbyaddr: not called CC=1 SCAR=6.9
Pod undocumented
3820 0 ▶sub pp_gpbynumber { listop(@_, "getprotobynumber") }
Subroutine pp_gpbynumber: not called CC=1 SCAR=6.9
Pod undocumented
3821 0 ▶sub pp_gsbyname { listop(@_, "getservbyname") }
Subroutine pp_gsbyname: not called CC=1 SCAR=6.9
Pod undocumented
3822 0 ▶sub pp_gsbyport { listop(@_, "getservbyport") }
Subroutine pp_gsbyport: not called CC=1 SCAR=6.9
Pod undocumented
3823 0 ▶sub pp_syscall { listop(@_, "syscall") }
Subroutine pp_syscall: not called CC=1 SCAR=6.9
Pod undocumented
3824  
3825 sub pp_glob {
3826 0 ▶ my $self = shift;
Subroutine pp_glob: not called CC=4 SCAR=30.0
Pod undocumented
3827 0 my($op, $cx) = @_;
3828 0 my $kid = $op->first->sibling; # skip pushmark
3829 0 ▶ my $keyword =
Branch: 1 branch
BranchTrueFalseTotal
$op->flags & 128 ? : 0 0 0
3830 $op->flags & OPf_SPECIAL ? 'glob' : $self->keyword('glob');
3831 0 my $text = $self->deparse($kid, $cx);
3832 0 ▶ return $cx >= 5 || $self->{'parens'}
Branch: 1 branch
BranchTrueFalseTotal
$cx >= 5 || $self->{'parens'} ? : 0 0 0
Condition0%0/3
$cx >= 5 or $self->{"parens"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cx >= 5 or $self->{"parens"}
$cx >= 5 $self->{"parens"}
Truth table0%0/3
A or B
A= $cx >= 5B= $self->{"parens"}
ABresult
1X1
011
000
3833 ? "$keyword($text)"
3834 : "$keyword $text";
3835 }
3836  
3837 # Truncate is special because OPf_SPECIAL makes a bareword first arg
3838 # be a filehandle. This could probably be better fixed in the core
3839 # by moving the GV lookup into ck_truc.
3840  
3841 sub pp_truncate {
3842 0 ▶ my $self = shift;
Subroutine pp_truncate: not called CC=6 SCAR=37.4
Pod undocumented
3843 0 my($op, $cx) = @_;
3844 0 my(@exprs);
3845 0 ▶ my $parens = ($cx >= 5) || $self->{'parens'};
Condition0%0/3
$cx >= 5 || $self->{'parens'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cx >= 5 || $self->{'parens'}
$cx >= 5 $self->{'parens'}
Truth table0%0/3
A || B
A= $cx >= 5B= $self->{'parens'}
ABresult
1X1
011
000
3846 0 my $kid = $op->first->sibling;
3847 0 my $fh;
3848 0 ▶ if ($op->flags & OPf_SPECIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 128) { } 0 0 0
3849 # $kid is an OP_CONST
3850 0 $fh = $self->const_sv($kid)->PV;
3851 } else {
3852 0 $fh = $self->deparse($kid, 6);
3853 0 ▶ $fh = "+$fh" if not $parens and substr($fh, 0, 1) eq "(";
Branch: 1 branch
BranchTrueFalseTotal
if not $parens and substr($fh, 0, 1) eq "(" 0 0 0
Condition0%0/3
not $parens and substr($fh, 0, 1) eq "("
!ll&&!rl&&r
000
MC/DC0%0/2
not $parens and substr($fh, 0, 1) eq "("
not $parens substr($fh, 0, 1) eq "("
Truth table0%0/3
not(A) and B
A= not $parensB= substr($fh, 0, 1) eq "("
ABresult
0X0
100
111
3854 }
3855 0 my $len = $self->deparse($kid->sibling, 6);
3856 0 my $name = $self->keyword('truncate');
3857 0 ▶ if ($parens) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parens) { } 0 0 0
3858 0 return "$name($fh, $len)";
3859 } else {
3860 0 return "$name $fh, $len";
3861 }
3862 }
3863  
3864 sub indirop {
3865 0 ▶ my $self = shift;
Subroutine indirop: not called CC=28 SCAR=67.0
Pod undocumented
3866 0 my($op, $cx, $name) = @_;
3867 0 my($expr, @exprs);
3868 0 my $firstkid = my $kid = $op->first->sibling;
3869 0 my $indir = "";
3870 0 ▶ if ($op->flags & OPf_STACKED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 64) 0 0 0
3871 0 $indir = $kid;
3872 0 $indir = $indir->first; # skip rv2gv
3873 0 ▶ if (is_scope($indir)) {
Branch: 2 branches
BranchTrueFalseTotal
if (is_scope($indir)) { } 0 0 0
elsif ($indir->name eq 'const' and $indir->private & 32) { } 0 0 0
3874 0 $indir = "{" . $self->deparse($indir, 0) . "}";
3875 0 ▶ $indir = "{;}" if $indir eq "{}";
Branch: 1 branch
BranchTrueFalseTotal
if $indir eq "{}" 0 0 0
3876 ▶ } elsif ($indir->name eq "const" && $indir->private & OPpCONST_BARE) {
Condition0%0/3
$indir->name eq "const" and $indir->private & 32
!ll&&!rl&&r
000
MC/DC0%0/2
$indir->name eq "const" and $indir->private & 32
$indir->name eq "const" $indir->private & 32
Truth table0%0/3
A and B
A= $indir->name eq "const"B= $indir->private & 32
ABresult
0X0
100
111
3877 0 $indir = $self->const_sv($indir)->PV;
3878 } else {
3879 0 $indir = $self->deparse($indir, 24);
3880 }
3881 0 $indir = $indir . " ";
3882 0 $kid = $kid->sibling;
3883 }
3884 0 ▶ if ($name eq "sort" && $op->private & (OPpSORT_NUMERIC | OPpSORT_INTEGER)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'sort' and $op->private & 3) { } 0 0 0
elsif ($name eq 'sort' and $op->private & 16) { } 0 0 0
Condition0%0/3
$name eq "sort" and $op->private & 3
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "sort" and $op->private & 3
$name eq "sort" $op->private & 3
Truth table0%0/3
A and B
A= $name eq "sort"B= $op->private & 3
ABresult
0X0
100
111
3885 0 ▶ $indir = ($op->private & OPpSORT_DESCEND) ? '{$b <=> $a} '
Branch: 1 branch
BranchTrueFalseTotal
$op->private & 16 ? : 0 0 0
3886 : '{$a <=> $b} ';
3887 }
3888 ▶ elsif ($name eq "sort" && $op->private & OPpSORT_DESCEND) {
Condition0%0/3
$name eq "sort" and $op->private & 16
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "sort" and $op->private & 16
$name eq "sort" $op->private & 16
Truth table0%0/3
A and B
A= $name eq "sort"B= $op->private & 16
ABresult
0X0
100
111
3889 0 $indir = '{$b cmp $a} ';
3890 }
3891 0 ▶ for (; !null($kid); $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
3892 0 ▶ $expr = $self->deparse($kid, !$indir && $kid == $firstkid && $name eq "sort" && $firstkid->name eq "entersub" ? 16 : 6);
Branch: 1 branch
BranchTrueFalseTotal
!$indir && $kid == $firstkid && $name eq 'sort' && $firstkid->name eq 'entersub' ? : 0 0 0
Condition0%0/9
not $indir and $kid == $firstkid and $name eq "sort" and $firstkid->name eq "entersub"
!ll&&!rl&&r
000
not $indir and $kid == $firstkid and $name eq "sort"
!ll&&!rl&&r
000
not $indir and $kid == $firstkid
!ll&&!rl&&r
000
MC/DC0%0/4
not $indir and $kid == $firstkid and $name eq "sort" and $firstkid->name eq "entersub"
not $indir $kid == $firstkid $name eq "sort" $firstkid->name eq "entersub"
Truth table0%0/5
not(A) and B and C and D
A= not $indirB= $kid == $firstkidC= $name eq "sort"D= $firstkid->name eq "entersub"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
3893 0 push @exprs, $expr;
3894 }
3895 0 my $name2;
3896 0 ▶ if ($name eq "sort" && $op->private & OPpSORT_REVERSE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq 'sort' and $op->private & 4) { } 0 0 0
Condition0%0/3
$name eq "sort" and $op->private & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "sort" and $op->private & 4
$name eq "sort" $op->private & 4
Truth table0%0/3
A and B
A= $name eq "sort"B= $op->private & 4
ABresult
0X0
100
111
3897 0 $name2 = $self->keyword('reverse') . ' ' . $self->keyword('sort');
3898 }
3899 0 else { $name2 = $self->keyword($name) }
3900 0 ▶ if ($name eq "sort" && ($op->private & OPpSORT_INPLACE)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "sort" and $op->private & 8) 0 0 0
Condition0%0/3
$name eq "sort" and $op->private & 8
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "sort" and $op->private & 8
$name eq "sort" $op->private & 8
Truth table0%0/3
A and B
A= $name eq "sort"B= $op->private & 8
ABresult
0X0
100
111
3901 0 return "$exprs[0] = $name2 $indir $exprs[0]";
3902 }
3903  
3904 0 my $args = $indir . join(", ", @exprs);
3905 0 ▶ if ($indir ne "" && $name eq "sort") {
Branch: 2 branches
BranchTrueFalseTotal
if ($indir ne '' and $name eq 'sort') { } 0 0 0
elsif (not $indir and $name eq 'sort' and not null($op->first->sibling) and $op->first->sibling->name eq 'entersub') { } 0 0 0
Condition0%0/3
$indir ne "" and $name eq "sort"
!ll&&!rl&&r
000
MC/DC0%0/2
$indir ne "" and $name eq "sort"
$indir ne "" $name eq "sort"
Truth table0%0/3
A and B
A= $indir ne ""B= $name eq "sort"
ABresult
0X0
100
111
3906 # We don't want to say "sort(f 1, 2, 3)", since perl -w will
3907 # give bareword warnings in that case. Therefore if context
3908 # requires, we'll put parens around the outside "(sort f 1, 2,
3909 # 3)". Unfortunately, we'll currently think the parens are
3910 # necessary more often that they really are, because we don't
3911 # distinguish which side of an assignment we're on.
3912 0 ▶ if ($cx >= 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cx >= 5) { } 0 0 0
3913 0 return "($name2 $args)";
3914 } else {
3915 0 return "$name2 $args";
3916 }
3917 ▶ } elsif (
Condition0%0/9
not $indir and $name eq "sort" and not null($op->first->sibling) and $op->first->sibling->name eq "entersub"
!ll&&!rl&&r
000
not $indir and $name eq "sort" and not null($op->first->sibling)
!ll&&!rl&&r
000
not $indir and $name eq "sort"
!ll&&!rl&&r
000
MC/DC0%0/4
not $indir and $name eq "sort" and not null($op->first->sibling) and $op->first->sibling->name eq "entersub"
not $indir $name eq "sort" not null($op->first->sibling) $op->first->sibling->name eq "entersub"
Truth table0%0/5
not(A) and B and not(C) and D
A= not $indirB= $name eq "sort"C= not null($op->first->sibling)D= $op->first->sibling->name eq "entersub"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
3918 !$indir && $name eq "sort"
3919 && !null($op->first->sibling)
3920 && $op->first->sibling->name eq 'entersub'
3921 ) {
3922 # We cannot say sort foo(bar), as foo will be interpreted as a
3923 # comparison routine. We have to say sort(...) in that case.
3924 0 return "$name2($args)";
3925 } else {
3926 0 ▶ return length $args
Branch: 1 branch
BranchTrueFalseTotal
length $args ? : 0 0 0
3927 ? $self->maybe_parens_func($name2, $args, $cx, 5)
3928 : $name2 . '()' x (7 < $cx);
3929 }
3930  
3931 }
3932  
3933 0 ▶sub pp_prtf { indirop(@_, "printf") }
Subroutine pp_prtf: not called CC=1 SCAR=6.9
Pod undocumented
3934 0 ▶sub pp_print { indirop(@_, "print") }
Subroutine pp_print: not called CC=1 SCAR=6.9
Pod undocumented
3935 0 ▶sub pp_say { indirop(@_, "say") }
Subroutine pp_say: not called CC=1 SCAR=6.9
Pod undocumented
3936 0 ▶sub pp_sort { indirop(@_, "sort") }
Subroutine pp_sort: not called CC=1 SCAR=6.9
Pod undocumented
3937  
3938 sub mapop {
3939 0 ▶ my $self = shift;
Subroutine mapop: not called CC=5 SCAR=34.0
Pod undocumented
3940 0 my($op, $cx) = @_;
3941 0 my($expr, @exprs);
3942 0 my $kid = $op->first; # this is the (map|grep|any|all)start
3943 0 my ( $name ) = $kid->name =~ m/(.*)start/; # anystart and allstart share anywhile
3944 0 $kid = $kid->first->sibling; # skip a pushmark
3945 0 my $code = $kid->first; # skip a null
3946 0 ▶ if (is_scope $code) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_scope($code)) { } 0 0 0
3947 0 $code = "{" . $self->deparse($code, 0) . "} ";
3948 } else {
3949 0 $code = $self->deparse($code, 24);
3950 0 ▶ $code .= ", " if !null($kid->sibling);
Branch: 1 branch
BranchTrueFalseTotal
unless null($kid->sibling) 0 0 0
3951 }
3952 0 $kid = $kid->sibling;
3953 0 ▶ for (; !null($kid); $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
3954 0 $expr = $self->deparse($kid, 6);
3955 0 ▶ push @exprs, $expr if defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
if defined $expr 0 0 0
3956 }
3957 0 return $self->maybe_parens_func($self->keyword($name),
3958 $code . join(", ", @exprs), $cx, 5);
3959 }
3960  
3961 0 ▶sub pp_mapwhile { mapop(@_) }
Subroutine pp_mapwhile: not called CC=1 SCAR=6.9
Pod undocumented
3962 0 ▶sub pp_grepwhile { mapop(@_) }
Subroutine pp_grepwhile: not called CC=1 SCAR=6.9
Pod undocumented
3963 0 ▶sub pp_anywhile { mapop(@_) }
Subroutine pp_anywhile: not called CC=1 SCAR=6.9
Pod undocumented
3964 0 ▶sub pp_mapstart { baseop(@_, "map") }
Subroutine pp_mapstart: not called CC=1 SCAR=6.9
Pod undocumented
3965 0 ▶sub pp_grepstart { baseop(@_, "grep") }
Subroutine pp_grepstart: not called CC=1 SCAR=6.9
Pod undocumented
3966  
3967 my %uses_intro;
3968 BEGIN {
3969 @uses_intro{
3970 eval { require B::Op_private }
3971 ? @{$B::Op_private::ops_using{OPpLVAL_INTRO}}
3972 : qw(gvsv rv2sv rv2hv rv2gv rv2av aelem helem aslice
3973 hslice delete padsv padav padhv enteriter entersub padrange
3974 pushmark cond_expr refassign list)
3975 } = ();
3976 delete @uses_intro{qw( lvref lvrefslice lvavref entersub )};
3977 }
3978  
3979  
3980 # Look for a my/state attribute declaration in a list or ex-list.
3981 # Returns undef if not found, 'my($x, @a) :Foo(bar)' etc otherwise.
3982 #
3983 # There are three basic tree structs that are expected:
3984 #
3985 # my $x :foo;
3986 # <1> ex-list vK/LVINTRO ->c
3987 # <0> ex-pushmark v ->3
3988 # <1> entersub[t2] vKRS*/TARG ->b
3989 # ....
3990 # <0> padsv[$x:64,65] vM/LVINTRO ->c
3991 #
3992 # my @a :foo;
3993 # my %h :foo;
3994 #
3995 # <1> ex-list vK ->c
3996 # <0> ex-pushmark v ->3
3997 # <0> padav[@a:64,65] vM/LVINTRO ->4
3998 # <1> entersub[t2] vKRS*/TARG ->c
3999 # ....
4000 #
4001 # my ($x,@a,%h) :foo;
4002 #
4003 # <;> nextstate(main 64 -e:1) v:{ ->3
4004 # <@> list vKP ->w
4005 # <0> pushmark vM/LVINTRO ->4
4006 # <0> padsv[$x:64,65] vM/LVINTRO ->5
4007 # <0> padav[@a:64,65] vM/LVINTRO ->6
4008 # <0> padhv[%h:64,65] vM/LVINTRO ->7
4009 # <1> entersub[t4] vKRS*/TARG ->f
4010 # ....
4011 # <1> entersub[t5] vKRS*/TARG ->n
4012 # ....
4013 # <1> entersub[t6] vKRS*/TARG ->v
4014 # ....
4015 # where the entersub in all cases looks like
4016 # <1> entersub[t2] vKRS*/TARG ->c
4017 # <0> pushmark s ->5
4018 # <$> const[PV "attributes"] sM ->6
4019 # <$> const[PV "main"] sM ->7
4020 # <1> srefgen sKM/1 ->9
4021 # <1> ex-list lKRM ->8
4022 # <0> padsv[@a:64,65] sRM ->8
4023 # <$> const[PV "foo"] sM ->a
4024 # <.> method_named[PV "import"] ->b
4025  
4026 sub maybe_var_attr {
4027 0 ▶ my ($self, $op, $cx) = @_;
Subroutine maybe_var_attr: not called CC=38 SCAR=73.0
Pod undocumented
4028  
4029 0 my $kid = $op->first->sibling; # skip pushmark
4030 0 ▶ return if class($kid) eq 'NULL';
Branch: 1 branch
BranchTrueFalseTotal
if B::Deparse::class($kid) eq "NULL" 0 0 0
4031  
4032 0 my $lop;
4033 my $type;
4034  
4035 # Extract out all the pad ops and entersub ops into
4036 # @padops and @entersubops. Return if anything else seen.
4037 # Also determine what class (if any) all the pad vars belong to
4038 0 my $class;
4039 0 my $decl; # 'my' or 'state'
4040 0 my (@padops, @entersubops);
4041 0 ▶ for ($lop = $kid; !null($lop); $lop = $lop->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($lop)) 0 0 0
4042 0 my $lopname = $lop->name;
4043 0 my $loppriv = $lop->private;
4044 0 ▶ if ($lopname =~ /^pad[sah]v$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($lopname =~ /^pad[sah]v$/) { } 0 0 0
elsif ($lopname eq 'entersub') { } 0 0 0
4045 0 ▶ return unless $loppriv & OPpLVAL_INTRO;
Branch: 1 branch
BranchTrueFalseTotal
unless $loppriv & 128 0 0 0
4046  
4047 0 my $padname = $self->padname_sv($lop->targ);
4048 0 ▶ my $thisclass = ($padname->FLAGS & PADNAMEf_TYPED)
Branch: 1 branch
BranchTrueFalseTotal
$padname->FLAGS & 8 ? : 0 0 0
4049 ? $padname->SvSTASH->NAME : 'main';
4050  
4051 # all pad vars must be in the same class
4052 0 ▶ $class //= $thisclass;
Condition0%0/3
$class //= $thisclass
l!l&&r!l&&!r
000
MC/DC0%0/2
$class //= $thisclass
$class $thisclass
Truth table0%0/3
A //= B
A= $classB= $thisclass
ABresult
1X1
011
000
4053 0 ▶ return unless $thisclass eq $class;
Branch: 1 branch
BranchTrueFalseTotal
unless $thisclass eq $class 0 0 0
4054  
4055 # all pad vars must be the same sort of declaration
4056 # (all my, all state, etc)
4057 0 ▶ my $this = ($loppriv & OPpPAD_STATE) ? 'state' : 'my';
Branch: 1 branch
BranchTrueFalseTotal
$loppriv & 64 ? : 0 0 0
4058 0 ▶ if (defined $decl) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $decl) 0 0 0
4059 0 ▶ return unless $this eq $decl;
Branch: 1 branch
BranchTrueFalseTotal
unless $this eq $decl 0 0 0
4060 }
4061 0 $decl = $this;
4062  
4063 0 push @padops, $lop;
4064 }
4065 elsif ($lopname eq 'entersub') {
4066 0 push @entersubops, $lop;
4067 }
4068 else {
4069 0 return;
4070 }
4071 }
4072  
4073 0 ▶ return unless @padops && @padops == @entersubops;
Branch: 1 branch
BranchTrueFalseTotal
unless @padops and @padops == @entersubops 0 0 0
Condition0%0/3
@padops and @padops == @entersubops
!ll&&!rl&&r
000
MC/DC0%0/2
@padops and @padops == @entersubops
@padops @padops == @entersubops
Truth table0%0/3
A and B
A= @padopsB= @padops == @entersubops
ABresult
0X0
100
111
4074  
4075 # there should be a balance: each padop has a corresponding
4076 # 'attributes'->import() method call, in the same order.
4077  
4078 0 my @varnames;
4079 my $attr_text;
4080  
4081 0 for my $i (0..$#padops) {
4082 0 my $padop = $padops[$i];
4083 0 my $esop = $entersubops[$i];
4084  
4085 0 push @varnames, $self->padname($padop->targ);
4086  
4087 0 ▶ return unless ($esop->flags & OPf_KIDS);
Branch: 1 branch
BranchTrueFalseTotal
unless $esop->flags & 4 0 0 0
4088  
4089 0 my $kid = $esop->first;
4090 0 ▶ return unless $kid->type == OP_PUSHMARK;
Branch: 1 branch
BranchTrueFalseTotal
unless $kid->type == 3 0 0 0
4091  
4092 0 $kid = $kid->sibling;
4093 0 ▶ return unless $$kid && $kid->type == OP_CONST;
Branch: 1 branch
BranchTrueFalseTotal
unless $$kid and $kid->type == 5 0 0 0
Condition0%0/3
$$kid and $kid->type == 5
!ll&&!rl&&r
000
MC/DC0%0/2
$$kid and $kid->type == 5
$$kid $kid->type == 5
Truth table0%0/3
A and B
A= $$kidB= $kid->type == 5
ABresult
0X0
100
111
4094 0 ▶ return unless $self->const_sv($kid)->PV eq 'attributes';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->const_sv($kid)->PV eq "attributes" 0 0 0
4095  
4096 0 $kid = $kid->sibling;
4097 0 ▶ return unless $$kid && $kid->type == OP_CONST; # __PACKAGE__
Branch: 1 branch
BranchTrueFalseTotal
unless $$kid and $kid->type == 5 0 0 0
Condition0%0/3
$$kid and $kid->type == 5
!ll&&!rl&&r
000
MC/DC0%0/2
$$kid and $kid->type == 5
$$kid $kid->type == 5
Truth table0%0/3
A and B
A= $$kidB= $kid->type == 5
ABresult
0X0
100
111
4098  
4099 0 $kid = $kid->sibling;
4100 0 ▶ return unless $$kid
Branch: 1 branch
BranchTrueFalseTotal
unless $$kid and $kid->name eq "srefgen" and $kid->flags & 4 and $kid->first->flags & 4 and $kid->first->first->name =~ /^pad[sah]v$/ and $kid->first->first->targ == $padop->targ 0 0 0
Condition0%0/15
$$kid and $kid->name eq "srefgen" and $kid->flags & 4 and $kid->first->flags & 4 and $kid->first->first->name =~ /^pad[sah]v$/ and $kid->first->first->targ == $padop->targ
!ll&&!rl&&r
000
$$kid and $kid->name eq "srefgen" and $kid->flags & 4 and $kid->first->flags & 4 and $kid->first->first->name =~ /^pad[sah]v$/
!ll&&!rl&&r
000
$$kid and $kid->name eq "srefgen" and $kid->flags & 4 and $kid->first->flags & 4
!ll&&!rl&&r
000
$$kid and $kid->name eq "srefgen" and $kid->flags & 4
!ll&&!rl&&r
000
$$kid and $kid->name eq "srefgen"
!ll&&!rl&&r
000
MC/DC0%0/6
$$kid and $kid->name eq "srefgen" and $kid->flags & 4 and $kid->first->flags & 4 and $kid->first->first->name =~ /^pad[sah]v$/ and $kid->first->first->targ == $padop->targ
$$kid $kid->name eq "srefgen" $kid->flags & 4 $kid->first->flags & 4 $kid->first->first->name =~ /^pad[sah]v$/ $kid->first->first->targ == $padop->targ
Truth table0%0/7
A and B and C and D and E and F
A= $$kidB= $kid->name eq "srefgen"C= $kid->flags & 4D= $kid->first->flags & 4E= $kid->first->first->name =~ /^pad[sah]v$/F= $kid->first->first->targ == $padop->targ
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
4101 && $kid->name eq "srefgen"
4102 && ($kid->flags & OPf_KIDS)
4103 && ($kid->first->flags & OPf_KIDS)
4104 && $kid->first->first->name =~ /^pad[sah]v$/
4105 && $kid->first->first->targ == $padop->targ;
4106  
4107 0 $kid = $kid->sibling;
4108 0 my @attr;
4109 0 ▶ while ($$kid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$kid) 0 0 0
4110 0 ▶ last if ($kid->type != OP_CONST);
Branch: 1 branch
BranchTrueFalseTotal
if $kid->type != 5 0 0 0
4111 0 push @attr, $self->const_sv($kid)->PV;
4112 0 $kid = $kid->sibling;
4113 }
4114 0 ▶ return unless @attr;
Branch: 1 branch
BranchTrueFalseTotal
unless @attr 0 0 0
4115 0 my $thisattr = ":" . join(' ', @attr);
4116 0 ▶ $attr_text //= $thisattr;
Condition0%0/3
$attr_text //= $thisattr
l!l&&r!l&&!r
000
MC/DC0%0/2
$attr_text //= $thisattr
$attr_text $thisattr
Truth table0%0/3
A //= B
A= $attr_textB= $thisattr
ABresult
1X1
011
000
4117 # all import calls must have the same list of attributes
4118 0 ▶ return unless $attr_text eq $thisattr;
Branch: 1 branch
BranchTrueFalseTotal
unless $attr_text eq $thisattr 0 0 0
4119  
4120 0 ▶ return unless $kid->name eq 'method_named';
Branch: 1 branch
BranchTrueFalseTotal
unless $kid->name eq "method_named" 0 0 0
4121 0 ▶ return unless $self->meth_sv($kid)->PV eq 'import';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->meth_sv($kid)->PV eq "import" 0 0 0
4122  
4123 0 $kid = $kid->sibling;
4124 0 ▶ return if $$kid;
Branch: 1 branch
BranchTrueFalseTotal
if $$kid 0 0 0
4125 }
4126  
4127 0 my $res = $decl;
4128 0 ▶ $res .= " $class " if $class ne 'main';
Branch: 1 branch
BranchTrueFalseTotal
if $class ne "main" 0 0 0
4129 0 ▶ $res .=
Branch: 1 branch
BranchTrueFalseTotal
@varnames > 1 ? : 0 0 0
4130 (@varnames > 1)
4131 ? "(" . join(', ', @varnames) . ')'
4132 : " $varnames[0]";
4133  
4134 0 return "$res $attr_text";
4135 }
4136  
4137  
4138 sub pp_list {
4139 0 ▶ my $self = shift;
Subroutine pp_list: not called CC=46 SCAR=76.8
Pod undocumented
4140 0 my($op, $cx) = @_;
4141  
4142 {
4143 # might be my ($s,@a,%h) :Foo(bar);
4144 0 my $my_attr = maybe_var_attr($self, $op, $cx);
4145 0 ▶ return $my_attr if defined $my_attr;
Branch: 1 branch
BranchTrueFalseTotal
if defined $my_attr 0 0 0
4146 }
4147  
4148 0 my($expr, @exprs);
4149 0 my $kid = $op->first->sibling; # skip pushmark
4150 0 ▶ return '' if class($kid) eq 'NULL';
Branch: 1 branch
BranchTrueFalseTotal
if B::Deparse::class($kid) eq "NULL" 0 0 0
4151 0 my $lop;
4152 0 my $local = "either"; # could be local(...), my(...), state(...) or our(...)
4153 0 my $type;
4154 0 ▶ for ($lop = $kid; !null($lop); $lop = $lop->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($lop)) 0 0 0
4155 0 my $lopname = $lop->name;
4156 0 my $loppriv = $lop->private;
4157 0 my $newtype;
4158 0 ▶ if ($lopname =~ /^pad[ash]v$/ && $loppriv & OPpLVAL_INTRO) {
Branch: 5 branches
BranchTrueFalseTotal
if ($lopname =~ /^pad[ash]v$/ and $loppriv & 128) { } 0 0 0
elsif ($lopname eq 'padsv_store') { } 0 0 0
elsif ($lopname =~ /^(?:gv|rv2)([ash])v$/ and $loppriv & 64 or $lopname eq 'null' and B::Deparse::class($lop) eq 'UNOP' and $lop->first->name eq 'gvsv' and $lop->first->private & 64) { } 0 0 0
elsif ($lopname ne 'undef' and not $loppriv & 128 && exists $uses_intro{$lopname eq 'null' ? substr(B::ppname($lop->targ), 3) : $lopname}) { } 0 0 0
elsif ($lopname ne 'undef') { } 0 0 0
Condition0%0/3
$lopname =~ /^pad[ash]v$/ and $loppriv & 128
!ll&&!rl&&r
000
MC/DC0%0/2
$lopname =~ /^pad[ash]v$/ and $loppriv & 128
$lopname =~ /^pad[ash]v$/ $loppriv & 128
Truth table0%0/3
A and B
A= $lopname =~ /^pad[ash]v$/B= $loppriv & 128
ABresult
0X0
100
111
4159 0 ▶ if ($loppriv & OPpPAD_STATE) { # state()
Branch: 1 branch
BranchTrueFalseTotal
if ($loppriv & 64) { } 0 0 0
4160 0 ▶ ($local = "", last) if $local !~ /^(?:either|state)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $local =~ /^(?:either|state)$/ 0 0 0
4161 0 $local = "state";
4162 } else { # my()
4163 0 ▶ ($local = "", last) if $local !~ /^(?:either|my)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $local =~ /^(?:either|my)$/ 0 0 0
4164 0 $local = "my";
4165 }
4166 0 my $padname = $self->padname_sv($lop->targ);
4167 0 ▶ if ($padname->FLAGS & PADNAMEf_TYPED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($padname->FLAGS & 8) 0 0 0
4168 0 $newtype = $padname->SvSTASH->NAME;
4169 }
4170 } elsif ($lopname eq 'padsv_store') {
4171 # don't interpret as my (list) if it has an implicit assign
4172 0 $local = "";
4173 ▶ } elsif ($lopname =~ /^(?:gv|rv2)([ash])v$/
Condition0%0/15
$lopname =~ /^(?:gv|rv2)([ash])v$/ and $loppriv & 64 or $lopname eq "null" and B::Deparse::class($lop) eq "UNOP" and $lop->first->name eq "gvsv" and $lop->first->private & 64
l!l&&r!l&&!r
000
$lopname =~ /^(?:gv|rv2)([ash])v$/ and $loppriv & 64
!ll&&!rl&&r
000
$lopname eq "null" and B::Deparse::class($lop) eq "UNOP" and $lop->first->name eq "gvsv" and $lop->first->private & 64
!ll&&!rl&&r
000
$lopname eq "null" and B::Deparse::class($lop) eq "UNOP" and $lop->first->name eq "gvsv"
!ll&&!rl&&r
000
$lopname eq "null" and B::Deparse::class($lop) eq "UNOP"
!ll&&!rl&&r
000
MC/DC0%0/6
$lopname =~ /^(?:gv|rv2)([ash])v$/ and $loppriv & 64 or $lopname eq "null" and B::Deparse::class($lop) eq "UNOP" and $lop->first->name eq "gvsv" and $lop->first->private & 64
$lopname =~ /^(?:gv|rv2)([ash])v$/ $loppriv & 64 $lopname eq "null" B::Deparse::class($lop) eq "UNOP" $lop->first->name eq "gvsv" $lop->first->private & 64
Truth table0%0/11
A and B or C and D and E and F
A= $lopname =~ /^(?:gv|rv2)([ash])v$/B= $loppriv & 64C= $lopname eq "null"D= B::Deparse::class($lop) eq "UNOP"E= $lop->first->name eq "gvsv"F= $lop->first->private & 64
ABCDEFresult
11XXXX1
0X11111
1011111
0X0XXX0
0X10XX0
0X110X0
0X11100
100XXX0
1010XX0
10110X0
1011100
4174 && $loppriv & OPpOUR_INTRO
4175 or $lopname eq "null" && class($lop) eq 'UNOP'
4176 && $lop->first->name eq "gvsv"
4177 && $lop->first->private & OPpOUR_INTRO) { # our()
4178 0 my $newlocal = "local " x !!($loppriv & OPpLVAL_INTRO) . "our";
4179 0 ▶ ($local = "", last)
Branch: 1 branch
BranchTrueFalseTotal
if $local ne "either" and $local ne $newlocal 0 0 0
Condition0%0/3
$local ne "either" and $local ne $newlocal
!ll&&!rl&&r
000
MC/DC0%0/2
$local ne "either" and $local ne $newlocal
$local ne "either" $local ne $newlocal
Truth table0%0/3
A and B
A= $local ne "either"B= $local ne $newlocal
ABresult
0X0
100
111
4180 if $local ne 'either' && $local ne $newlocal;
4181 0 $local = $newlocal;
4182 0 ▶ my $funny = !$1 || $1 eq 's' ? '$' : $1 eq 'a' ? '@' : '%';
Branch: 2 branches
BranchTrueFalseTotal
!$1 || $1 eq 's' ? : 0 0 0
$1 eq 'a' ? : 0 0 0
Condition0%0/3
not $1 or $1 eq "s"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $1 or $1 eq "s"
not $1 $1 eq "s"
Truth table0%0/3
not(A) or B
A= not $1B= $1 eq "s"
ABresult
1X1
011
000
4183 0 ▶ if (my $t = $self->find_our_type(
Branch: 1 branch
BranchTrueFalseTotal
if (my $t = $self->find_our_type($funny . $self->gv_or_padgv($lop->first)->NAME)) 0 0 0
4184 $funny . $self->gv_or_padgv($lop->first)->NAME
4185 )) {
4186 0 $newtype = $t;
4187 }
4188 ▶ } elsif ($lopname ne 'undef'
Branch: 1 branch
BranchTrueFalseTotal
$lopname eq 'null' ? : 0 0 0
Condition0%0/6
$lopname ne "undef" and not $loppriv & 128 && exists $uses_intro{$lopname eq "null" ? substr(B::ppname($lop->targ), 3) : $lopname}
!ll&&!rl&&r
000
$loppriv & 128 && exists $uses_intro{$lopname eq 'null' ? substr(B::ppname($lop->targ), 3) : $lopname}
!ll&&!rl&&r
000
MC/DC0%0/3
$lopname ne "undef" and not $loppriv & 128 && exists $uses_intro{$lopname eq "null" ? substr(B::ppname($lop->targ), 3) : $lopname}
$lopname ne "undef" $loppriv & 128 exists $uses_intro{$lopname eq 'null' ? substr(B::ppname($lop->targ), 3) : $lopname}
Truth table0%0/4
A and not(B && C)
A= $lopname ne "undef"B= $loppriv & 128C= exists $uses_intro{$lopname eq 'null' ? substr(B::ppname($lop->targ), 3) : $lopname}
ABCresult
0XX0
1110
10X1
1101
4189 and !($loppriv & OPpLVAL_INTRO)
4190 || !exists $uses_intro{$lopname eq 'null'
4191 ? substr B::ppname($lop->targ), 3
4192 : $lopname})
4193 {
4194 0 $local = ""; # or not
4195 0 last;
4196 } elsif ($lopname ne "undef")
4197 {
4198 # local()
4199 0 ▶ ($local = "", last) if $local !~ /^(?:either|local)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $local =~ /^(?:either|local)$/ 0 0 0
4200 0 $local = "local";
4201 }
4202 0 ▶ if (defined $type && defined $newtype && $newtype ne $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type and defined $newtype and $newtype ne $type) 0 0 0
Condition0%0/6
defined $type and defined $newtype and $newtype ne $type
!ll&&!rl&&r
000
defined $type and defined $newtype
!ll&&!rl&&r
000
MC/DC0%0/3
defined $type and defined $newtype and $newtype ne $type
defined $type defined $newtype $newtype ne $type
Truth table0%0/4
A and B and C
A= defined $typeB= defined $newtypeC= $newtype ne $type
ABCresult
0XX0
10X0
1100
1111
4203 0 $local = '';
4204 0 last;
4205 }
4206 0 $type = $newtype;
4207 }
4208 0 ▶ $local = "" if $local eq "either"; # no point if it's all undefs
Branch: 1 branch
BranchTrueFalseTotal
if $local eq "either" 0 0 0
4209 0 ▶ $local &&= join ' ', map $self->keyword($_), split / /, $local;
Condition0%0/3
$local &&= join(" ", map($self->keyword($_), split(/ /, $local, 0)))
!ll&&!rl&&r
000
MC/DC0%0/2
$local &&= join(" ", map($self->keyword($_), split(/ /, $local, 0)))
$local join(" ", map($self->keyword($_), split(/ /, $local, 0)))
Truth table0%0/3
A &&= B
A= $localB= join(" ", map($self->keyword($_), split(/ /, $local, 0)))
ABresult
0X0
100
111
4210 0 ▶ $local .= " $type " if $local && length $type;
Branch: 1 branch
BranchTrueFalseTotal
if $local and length $type 0 0 0
Condition0%0/3
$local and length $type
!ll&&!rl&&r
000
MC/DC0%0/2
$local and length $type
$local length $type
Truth table0%0/3
A and B
A= $localB= length $type
ABresult
0X0
100
111
4211 0 ▶ return $self->deparse($kid, $cx) if null $kid->sibling and not $local;
Branch: 1 branch
BranchTrueFalseTotal
if null($kid->sibling) and not $local 0 0 0
Condition0%0/3
null($kid->sibling) and not $local
!ll&&!rl&&r
000
MC/DC0%0/2
null($kid->sibling) and not $local
null($kid->sibling) not $local
Truth table0%0/3
A and not(B)
A= null($kid->sibling)B= not $local
ABresult
0X0
100
111
4212 0 ▶ for (; !null($kid); $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
4213 0 ▶ if ($local) {
Branch: 1 branch
BranchTrueFalseTotal
if ($local) { } 0 0 0
4214 0 ▶ if (class($kid) eq "UNOP" and $kid->first->name eq "gvsv") {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($kid) eq 'UNOP' and $kid->first->name eq 'gvsv') { } 0 0 0
Condition0%0/3
B::Deparse::class($kid) eq "UNOP" and $kid->first->name eq "gvsv"
!ll&&!rl&&r
000
MC/DC0%0/2
B::Deparse::class($kid) eq "UNOP" and $kid->first->name eq "gvsv"
B::Deparse::class($kid) eq "UNOP" $kid->first->name eq "gvsv"
Truth table0%0/3
A and B
A= B::Deparse::class($kid) eq "UNOP"B= $kid->first->name eq "gvsv"
ABresult
0X0
100
111
4215 0 $lop = $kid->first;
4216 } else {
4217 0 $lop = $kid;
4218 }
4219 0 $self->{'avoid_local'}{$$lop}++;
4220 0 $expr = $self->deparse($kid, 6);
4221 0 delete $self->{'avoid_local'}{$$lop};
4222 } else {
4223 0 $expr = $self->deparse($kid, 6);
4224 }
4225 0 push @exprs, $expr;
4226 }
4227 0 ▶ if ($local) {
Branch: 1 branch
BranchTrueFalseTotal
if ($local) { } 0 0 0
4228 0 ▶ if (@exprs == 1 && ($local eq 'state' || $local eq 'CORE::state')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@exprs == 1 and $local eq "state" || $local eq "CORE::state") 0 0 0
Condition0%0/6
@exprs == 1 and $local eq "state" || $local eq "CORE::state"
!ll&&!rl&&r
000
$local eq "state" or $local eq "CORE::state"
l!l&&r!l&&!r
000
MC/DC0%0/3
@exprs == 1 and $local eq "state" || $local eq "CORE::state"
@exprs == 1 $local eq "state" $local eq "CORE::state"
Truth table0%0/4
A and B or C
A= @exprs == 1B= $local eq "state"C= $local eq "CORE::state"
ABCresult
0XX0
1000
11X1
1011
4229 # 'state @a = ...' is legal, while 'state(@a) = ...' currently isn't
4230 0 return "$local $exprs[0]";
4231 }
4232 0 return "$local(" . join(", ", @exprs) . ")";
4233 } else {
4234 0 return $self->maybe_parens( join(", ", @exprs), $cx, 6);
4235 }
4236 }
4237  
4238 sub is_ifelse_cont {
4239 0 ▶ my $op = shift;
Subroutine is_ifelse_cont: not called CC=4 SCAR=30.0
Pod undocumented
4240 0 ▶ return ($op->name eq "null" and class($op) eq "UNOP"
Condition0%0/9
$op->name eq 'null' && B::Deparse::class($op) eq 'UNOP' && $op->first->name =~ /^(and|cond_expr)$/ && is_scope($op->first->first->sibling)
!ll&&!rl&&r
000
$op->name eq "null" and B::Deparse::class($op) eq "UNOP" and $op->first->name =~ /^(and|cond_expr)$/
!ll&&!rl&&r
000
$op->name eq "null" and B::Deparse::class($op) eq "UNOP"
!ll&&!rl&&r
000
MC/DC0%0/4
$op->name eq 'null' && B::Deparse::class($op) eq 'UNOP' && $op->first->name =~ /^(and|cond_expr)$/ && is_scope($op->first->first->sibling)
$op->name eq "null" B::Deparse::class($op) eq "UNOP" $op->first->name =~ /^(and|cond_expr)$/ is_scope($op->first->first->sibling)
Truth table0%0/5
A and B and C && D
A= $op->name eq "null"B= B::Deparse::class($op) eq "UNOP"C= $op->first->name =~ /^(and|cond_expr)$/D= is_scope($op->first->first->sibling)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
4241 and $op->first->name =~ /^(and|cond_expr)$/
4242 and is_scope($op->first->first->sibling));
4243 }
4244  
4245 sub pp_cond_expr {
4246 0 ▶ my $self = shift;
Subroutine pp_cond_expr: not called CC=18 SCAR=58.3
Pod undocumented
4247 0 my($op, $cx) = @_;
4248 0 my $cond = $op->first;
4249 0 my $true = $cond->sibling;
4250 0 my $false = $true->sibling;
4251 0 my $cuddle = $self->{'cuddle'};
4252 0 my $no_true = 0;
4253  
4254 # Note that when an empty true or false block is optimised away,
4255 # cond_expr only has two children: a conditional and a single block,
4256 # rather than the usual two. When the false branch is empty and is
4257 # optimised away, OPf_SPECIAL is set.
4258  
4259 0 ▶ if (class($false) eq "NULL" && !($op->flags & OPf_SPECIAL)) {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($false) eq "NULL" and not $op->flags & 128) 0 0 0
Condition0%0/3
B::Deparse::class($false) eq "NULL" and not $op->flags & 128
!ll&&!rl&&r
000
MC/DC0%0/2
B::Deparse::class($false) eq "NULL" and not $op->flags & 128
B::Deparse::class($false) eq "NULL" not $op->flags & 128
Truth table0%0/3
A and not(B)
A= B::Deparse::class($false) eq "NULL"B= not $op->flags & 128
ABresult
0X0
100
111
4260 # It was an empty true block
4261 0 $no_true = 1;
4262 }
4263  
4264 0 ▶ unless ($op->private & OPpSTATEMENT) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($op->private & 64) 0 0 0
4265 # it's a ?: rather than an if/else
4266  
4267 0 $cond = $self->deparse($cond, 8);
4268 0 $true = $self->deparse($true, 6);
4269 # has one of the two branches has been optimised away?
4270 0 ▶ $false = class($false) eq "NULL" ? '()' : $self->deparse($false, 8);
Branch: 1 branch
BranchTrueFalseTotal
B::Deparse::class($false) eq 'NULL' ? : 0 0 0
4271 0 ▶ ($true, $false) = ($false, $true) if $no_true;
Branch: 1 branch
BranchTrueFalseTotal
if $no_true 0 0 0
4272 0 return $self->maybe_parens("$cond ? $true : $false", $cx, 8);
4273 }
4274  
4275 # if/elseif/else etc
4276  
4277 0 ▶ ($true, $false) = ($false, $true) if $no_true;
Branch: 1 branch
BranchTrueFalseTotal
if $no_true 0 0 0
4278  
4279 0 $cond = $self->deparse($cond, 1);
4280 0 ▶ $true = ($no_true) ? "\b" : $self->deparse($true, 0);
Branch: 1 branch
BranchTrueFalseTotal
$no_true ? : 0 0 0
4281 0 ▶ my $head = ($no_true)
Branch: 1 branch
BranchTrueFalseTotal
$no_true ? : 0 0 0
4282 ? $self->keyword("if") . " ($cond) {\n\t();\n\b}"
4283 : $self->keyword("if") . " ($cond) {\n\t$true\n\b}";
4284 0 my @elsifs;
4285 my $elsif;
4286  
4287 # keep processing chained elsif's until final else (if present)
4288 0 ▶ while (!null($false) and is_ifelse_cont($false)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not null($false) and is_ifelse_cont($false)) 0 0 0
Condition0%0/3
not null($false) and is_ifelse_cont($false)
!ll&&!rl&&r
000
MC/DC0%0/2
not null($false) and is_ifelse_cont($false)
not null($false) is_ifelse_cont($false)
Truth table0%0/3
not(A) and B
A= not null($false)B= is_ifelse_cont($false)
ABresult
0X0
100
111
4289 0 my $newop = $false->first;
4290 0 my $newcond = $newop->first;
4291 0 my $newtrue = $newcond->sibling;
4292 0 $false = $newtrue->sibling; # last in chain is OP_AND => no else
4293 0 ▶ if ($newcond->name eq "lineseq")
Branch: 1 branch
BranchTrueFalseTotal
if ($newcond->name eq "lineseq") 0 0 0
4294 {
4295 # lineseq to ensure correct line numbers in elsif()
4296 # Bug #37302 fixed by change #33710.
4297 0 $newcond = $newcond->first->sibling;
4298 }
4299 0 $newcond = $self->deparse($newcond, 1);
4300  
4301 0 ▶ if ( $op->name eq 'cond'
Branch: 1 branch
BranchTrueFalseTotal
if ($op->name eq 'cond' and null($false) and not $newop->flags & 128) { } 0 0 0
Condition0%0/6
$op->name eq "cond" and null($false) and not $newop->flags & 128
!ll&&!rl&&r
000
$op->name eq "cond" and null($false)
!ll&&!rl&&r
000
MC/DC0%0/3
$op->name eq "cond" and null($false) and not $newop->flags & 128
$op->name eq "cond" null($false) not $newop->flags & 128
Truth table0%0/4
A and B and not(C)
A= $op->name eq "cond"B= null($false)C= not $newop->flags & 128
ABCresult
0XX0
10X0
1100
1111
4302 && null($false)
4303 && ! ($newop->flags & OPf_SPECIAL))
4304 {
4305 # An empty elsif "true" block has been optimised away
4306 0 my $temp = $false; $false = $newtrue; $newtrue = $temp;
4307 0 $newtrue = "();";
4308 } else {
4309 0 $newtrue = $self->deparse($newtrue, 0);
4310 }
4311  
4312 0 ▶ $elsif ||= $self->keyword("elsif");
Condition0%0/3
$elsif ||= $self->keyword("elsif")
l!l&&r!l&&!r
000
MC/DC0%0/2
$elsif ||= $self->keyword("elsif")
$elsif $self->keyword("elsif")
Truth table0%0/3
A ||= B
A= $elsifB= $self->keyword("elsif")
ABresult
1X1
011
000
4313 0 push @elsifs, "$elsif ($newcond) {\n\t$newtrue\n\b}";
4314 }
4315  
4316 0 ▶ if (!null($false)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not null($false)) { } 0 0 0
elsif ($op->flags & 128) { } 0 0 0
4317 0 $false = $cuddle . $self->keyword("else") . " {\n\t" .
4318 $self->deparse($false, 0) . "\n\b}\cK";
4319 } elsif ($op->flags & OPf_SPECIAL) {
4320 0 $false = $cuddle . $self->keyword("else") . " {\n\t" .
4321 "();\n\b}\cK";
4322 } else {
4323 0 $false = "\cK";
4324 }
4325  
4326 0 return $head . join($cuddle, "", @elsifs) . $false;
4327 }
4328  
4329 sub pp_once {
4330 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_once: not called CC=1 SCAR=6.9
Pod undocumented
4331 0 my $cond = $op->first;
4332 0 my $true = $cond->sibling;
4333  
4334 0 my $ret = $self->deparse($true, $cx);
4335 0 $ret =~ s/^(\(?)\$/$1 . $self->keyword("state") . ' $'/e;
4336 0 $ret;
4337 }
4338  
4339 sub loop_common {
4340 0 ▶ my $self = shift;
Subroutine loop_common: not called CC=40 SCAR=74.0
Pod undocumented
4341 0 my($op, $cx, $init) = @_;
4342 0 my $enter = $op->first;
4343 0 my $kid = $enter->sibling;
4344 local(@$self{qw'curstash warnings hints hinthash'})
4345 0 = @$self{qw'curstash warnings hints hinthash'};
4346 0 my $head = "";
4347 0 my $bare = 0;
4348 0 my $body;
4349 0 my $cond = undef;
4350 0 my $name;
4351 0 ▶ if ($kid->name eq "lineseq") { # bare or infinite loop
Branch: 4 branches
BranchTrueFalseTotal
if ($kid->name eq 'lineseq') { } 0 0 0
elsif ($enter->name eq 'enteriter') { } 0 0 0
elsif (_op_is_or_was($kid, 1)) { } 0 0 0
elsif ($kid->name eq 'null') { } 0 0 0
4352 0 ▶ if ($kid->last->name eq "unstack") { # infinite
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->last->name eq 'unstack') { } 0 0 0
4353 0 $head = "while (1) "; # Can't use for(;;) if there's a continue
4354 0 $cond = "";
4355 } else {
4356 0 $bare = 1;
4357 }
4358 0 $body = $kid;
4359 } elsif ($enter->name eq "enteriter") { # foreach
4360 0 my $ary = $enter->first->sibling; # first was pushmark
4361 0 my $var = $ary->sibling;
4362 0 my $iter = $kid->first->first;
4363 0 ▶ if ($ary->name eq 'null' and $enter->private & OPpITER_REVERSED) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ary->name eq 'null' and $enter->private & 2) { } 0 0 0
elsif ($enter->flags & 64 and not null($ary->first->sibling->sibling)) { } 0 0 0
Condition0%0/3
$ary->name eq "null" and $enter->private & 2
!ll&&!rl&&r
000
MC/DC0%0/2
$ary->name eq "null" and $enter->private & 2
$ary->name eq "null" $enter->private & 2
Truth table0%0/3
A and B
A= $ary->name eq "null"B= $enter->private & 2
ABresult
0X0
100
111
4364 # "reverse" was optimised away
4365 0 $ary = listop($self, $ary->first->sibling, 1, 'reverse');
4366 ▶ } elsif ($enter->flags & OPf_STACKED
Condition0%0/3
$enter->flags & 64 and not null($ary->first->sibling->sibling)
!ll&&!rl&&r
000
MC/DC0%0/2
$enter->flags & 64 and not null($ary->first->sibling->sibling)
$enter->flags & 64 not null($ary->first->sibling->sibling)
Truth table0%0/3
A and not(B)
A= $enter->flags & 64B= not null($ary->first->sibling->sibling)
ABresult
0X0
100
111
4367 and not null $ary->first->sibling->sibling)
4368 {
4369 0 $ary = $self->deparse($ary->first->sibling, 9) . " .. " .
4370 $self->deparse($ary->first->sibling->sibling, 9);
4371 } else {
4372 0 $ary = $self->deparse($ary, 1);
4373 }
4374  
4375 0 ▶ if ($iter->private & OPpITER_INDEXED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter->private & 4) 0 0 0
4376 0 $ary = "builtin::indexed $ary";
4377 }
4378  
4379 0 ▶ if ($enter->flags & OPf_PARENS) {
Branch: 4 branches
BranchTrueFalseTotal
if ($enter->flags & 8) { } 0 0 0
elsif (null($var)) { } 0 0 0
elsif ($var->name eq 'rv2gv') { } 0 0 0
elsif ($var->name eq 'gv') { } 0 0 0
4380 # for my ($x, $y, ...) ...
4381 # for my ($foo, $bar) () stores the count (less 1) in the targ of
4382 # the ITER op. For the degenerate case of 1 var ($x), the
4383 # TARG is zero, so it works anyway. In the presence of
4384 # OPpITER_REFALIAS, the lower 8 bits is the var count, and the
4385 # upper 24 bits is a mask indicating which of the variables
4386 # have refalias behaviour.
4387 0 my $iter_targ = $kid->first->first->targ;
4388 0 my $mask = 0;
4389 0 ▶ if ($iter->private & OPpITER_REFALIAS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter->private & 8) 0 0 0
4390 0 $mask = $iter_targ >> 8;
4391 0 $iter_targ &= 0xff;
4392 }
4393 0 my @vars;
4394 0 my $targ = $enter->targ;
4395 0 ▶ while ($iter_targ-- >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter_targ-- >= 0) 0 0 0
4396 0 my $v = $self->padname_sv($targ)->PVX;
4397 0 ▶ $v = "\\$v" if $mask & 1;
Branch: 1 branch
BranchTrueFalseTotal
if $mask & 1 0 0 0
4398 0 push @vars, $v;
4399 0 ++$targ;
4400 0 $mask >>= 1;
4401 }
4402 0 $var = 'my (' . join(', ', @vars) . ')';
4403 } elsif (null $var) {
4404 0 $var = $self->pp_padsv($enter, 1, 1);
4405 0 ▶ $var = "\\" . $var if $iter->private & OPpITER_REFALIAS;
Branch: 1 branch
BranchTrueFalseTotal
if $iter->private & 8 0 0 0
4406 } elsif ($var->name eq "rv2gv") {
4407 0 $var = $self->pp_rv2sv($var, 1);
4408 0 ▶ if ($enter->private & OPpOUR_INTRO) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enter->private & 64) 0 0 0
4409 # our declarations don't have package names
4410 0 $var =~ s/^(.).*::/$1/;
4411 0 $var = "our $var";
4412 }
4413 } elsif ($var->name eq "gv") {
4414 0 $var = "\$" . $self->deparse($var, 1);
4415 } else {
4416 0 $var = $self->deparse($var, 1);
4417 }
4418  
4419 0 $body = $iter->sibling;
4420  
4421 0 ▶ if (!( is_state $body->first
Branch: 1 branch
BranchTrueFalseTotal
unless (is_state($body->first) or _op_is_or_was($body->first, 1) or $body->first->name =~ /^(?:leave|scope)$/) 0 0 0
Condition0%0/6
is_state($body->first) or _op_is_or_was($body->first, 1) or $body->first->name =~ /^(?:leave|scope)$/
l!l&&r!l&&!r
000
is_state($body->first) or _op_is_or_was($body->first, 1)
l!l&&r!l&&!r
000
MC/DC0%0/3
is_state($body->first) or _op_is_or_was($body->first, 1) or $body->first->name =~ /^(?:leave|scope)$/
is_state($body->first) _op_is_or_was($body->first, 1) $body->first->name =~ /^(?:leave|scope)$/
Truth table0%0/4
A or B or C
A= is_state($body->first)B= _op_is_or_was($body->first, 1)C= $body->first->name =~ /^(?:leave|scope)$/
ABCresult
1XX1
01X1
0011
0000
4422 or _op_is_or_was($body->first, OP_STUB)
4423 or ($body->first->name =~ /^(?:leave|scope)$/)))
4424 {
4425 # postfix for
4426 0 ▶ die "Unexpected 'for' statement modifier with non-\$_ loop variable '$var'\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $var eq "\$_" 0 0 0
4427 unless $var eq '$_';
4428 0 $body = $body->first;
4429 0 return $self->deparse($body, 2) . " "
4430 . $self->keyword("foreach") . " ($ary)";
4431 }
4432 0 $head = "foreach $var ($ary) ";
4433 }
4434 elsif (_op_is_or_was($kid, OP_STUB)) { # bare and empty
4435 0 return "{;}"; # {} could be a hashref
4436 }
4437 elsif ($kid->name eq "null") { # while/until
4438 0 $kid = $kid->first;
4439 0 $name = {"and" => "while", "or" => "until"}->{$kid->name};
4440 0 $cond = $kid->first;
4441 0 $body = $kid->first->sibling;
4442 }
4443  
4444 # If there isn't a continue block, then the next pointer for the loop
4445 # will point to the unstack, which is kid's last child, except
4446 # in a bare loop, when it will point to the leaveloop. When neither of
4447 # these conditions hold, then the second-to-last child is the continue
4448 # block (or the last in a bare loop).
4449 0 my $cont_start = $enter->nextop;
4450 0 my $cont;
4451 my $precond;
4452 0 my $postcond;
4453 0 ▶ if ($$cont_start != $$op && ${$cont_start} != ${$body->last}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$cont_start != $$op and ${$cont_start;} != ${$body->last;}) { } 0 0 0
Condition0%0/3
$$cont_start != $$op and ${$cont_start;} != ${$body->last;}
!ll&&!rl&&r
000
MC/DC0%0/2
$$cont_start != $$op and ${$cont_start;} != ${$body->last;}
$$cont_start != $$op ${$cont_start;} != ${$body->last;}
Truth table0%0/3
A and B
A= $$cont_start != $$opB= ${$cont_start;} != ${$body->last;}
ABresult
0X0
100
111
4454 0 ▶ if ($bare) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bare) { } 0 0 0
4455 0 $cont = $body->last;
4456 } else {
4457 0 $cont = $body->first;
4458 0 ▶ while (!null($cont->sibling->sibling)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($cont->sibling->sibling)) 0 0 0
4459 0 $cont = $cont->sibling;
4460 }
4461 }
4462 0 my $state = $body->first;
4463 0 my $cuddle = $self->{'cuddle'};
4464 0 my @states;
4465 0 ▶ for (; $$state != $$cont; $state = $state->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$state != $$cont) 0 0 0
4466 0 push @states, $state;
4467 }
4468 0 $body = $self->lineseq(undef, 0, @states);
4469 0 ▶ if (defined $cond and not is_scope $cont and $self->{'expand'} < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cond and not is_scope($cont) and $self->{'expand'} < 3) { } 0 0 0
Condition0%0/6
defined $cond and not is_scope($cont) and $self->{"expand"} < 3
!ll&&!rl&&r
000
defined $cond and not is_scope($cont)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $cond and not is_scope($cont) and $self->{"expand"} < 3
defined $cond not is_scope($cont) $self->{"expand"} < 3
Truth table0%0/4
A and not(B) and C
A= defined $condB= not is_scope($cont)C= $self->{"expand"} < 3
ABCresult
0XX0
10X0
1100
1111
4470 0 $precond = "for ($init; ";
4471 0 $postcond = "; " . $self->deparse($cont, 1) .") ";
4472 0 $cont = "\cK";
4473 } else {
4474 0 $cont = $cuddle . "continue {\n\t" .
4475 $self->deparse($cont, 0) . "\n\b}\cK";
4476 }
4477 } else {
4478 0 ▶ return "" if !defined $body;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $body 0 0 0
4479 0 ▶ if (length $init) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $init) 0 0 0
4480 0 $precond = "for ($init; ";
4481 0 $postcond = ";) ";
4482 }
4483 0 $cont = "\cK";
4484 0 $body = $self->deparse($body, 0);
4485 }
4486 0 ▶ if ($precond) { # for(;;)
Branch: 1 branch
BranchTrueFalseTotal
if ($precond) 0 0 0
4487 0 ▶ $cond &&= $name eq 'until'
Branch: 1 branch
BranchTrueFalseTotal
$name eq 'until' ? : 0 0 0
Condition0%0/3
$cond &&= $name eq "until" ? listop($self, undef, 1, "not", $cond->first) : $self->deparse($cond, 1)
!ll&&!rl&&r
000
MC/DC0%0/2
$cond &&= $name eq "until" ? listop($self, undef, 1, "not", $cond->first) : $self->deparse($cond, 1)
$cond $name eq "until" ? listop($self, undef, 1, "not", $cond->first) : $self->deparse($cond, 1)
Truth table0%0/3
A &&= B
A= $condB= $name eq "until" ? listop($self, undef, 1, "not", $cond->first) : $self->deparse($cond, 1)
ABresult
0X0
100
111
4488 ? listop($self, undef, 1, "not", $cond->first)
4489 : $self->deparse($cond, 1);
4490 0 $head = "$precond$cond$postcond";
4491 }
4492 0 ▶ if ($name && !$head) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and not $head) 0 0 0
Condition0%0/3
$name and not $head
!ll&&!rl&&r
000
MC/DC0%0/2
$name and not $head
$name not $head
Truth table0%0/3
A and not(B)
A= $nameB= not $head
ABresult
0X0
100
111
4493 0 ▶ ref $cond and $cond = $self->deparse($cond, 1);
Branch: 1 branch
BranchTrueFalseTotal
ref $cond and $cond = $self->deparse($cond, 1) 0 0 0
4494 0 $head = "$name ($cond) ";
4495 }
4496 0 $head =~ s/^(for(?:each)?|while|until)/$self->keyword($1)/e;
4497 0 $body =~ s/;?$/;\n/;
4498  
4499 0 return $head . "{\n\t" . $body . "\b}" . $cont;
4500 }
4501  
4502 0 ▶sub pp_leaveloop { shift->loop_common(@_, "") }
Subroutine pp_leaveloop: not called CC=1 SCAR=6.9
Pod undocumented
4503  
4504 sub for_loop {
4505 0 ▶ my $self = shift;
Subroutine for_loop: not called CC=2 SCAR=17.9
Pod undocumented
4506 0 my($op, $cx) = @_;
4507 0 my $init = $self->deparse($op, 1);
4508 0 my $s = $op->sibling;
4509 0 ▶ my $ll = $s->name eq "unstack" ? $s->sibling : $s->first->sibling;
Branch: 1 branch
BranchTrueFalseTotal
$s->name eq 'unstack' ? : 0 0 0
4510 0 return $self->loop_common($ll, $cx, $init);
4511 }
4512  
4513 sub pp_leavetry {
4514 0 ▶ my $self = shift;
Subroutine pp_leavetry: not called CC=1 SCAR=6.9
Pod undocumented
4515 0 return "eval {\n\t" . $self->pp_leave(@_) . "\n\b}";
4516 }
4517  
4518 sub pp_leavetrycatch_with_finally {
4519 0 ▶ my $self = shift;
Subroutine pp_leavetrycatch_with_finally: not called CC=8 SCAR=42.8
Pod undocumented
4520 0 my ($op, $finallyop) = @_;
4521  
4522 # Expect that the first three kids should be (entertrycatch, poptry, catch)
4523 0 my $entertrycatch = $op->first;
4524 0 ▶ $entertrycatch->name eq "entertrycatch" or die "Expected entertrycatch as first child of leavetrycatch";
Branch: 1 branch
BranchTrueFalseTotal
$entertrycatch->name eq "entertrycatch" or die "Expected entertrycatch as first child of leavetrycatch" 0 0 0
4525  
4526 0 my $tryblock = $entertrycatch->sibling;
4527 0 ▶ $tryblock->name eq "poptry" or die "Expected poptry as second child of leavetrycatch";
Branch: 1 branch
BranchTrueFalseTotal
$tryblock->name eq "poptry" or die "Expected poptry as second child of leavetrycatch" 0 0 0
4528  
4529 0 my $catch = $tryblock->sibling;
4530 0 ▶ $catch->name eq "catch" or die "Expected catch as third child of leavetrycatch";
Branch: 1 branch
BranchTrueFalseTotal
$catch->name eq "catch" or die "Expected catch as third child of leavetrycatch" 0 0 0
4531  
4532 0 my $catchblock = $catch->first->sibling;
4533 0 my $name = $catchblock->name;
4534 0 ▶ unless ($name eq "scope" || $name eq "leave") {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name eq "scope" or $name eq "leave") 0 0 0
Condition0%0/3
$name eq "scope" or $name eq "leave"
l!l&&r!l&&!r
000
MC/DC0%0/2
$name eq "scope" or $name eq "leave"
$name eq "scope" $name eq "leave"
Truth table0%0/3
A or B
A= $name eq "scope"B= $name eq "leave"
ABresult
1X1
011
000
4535 0 die "Expected scope or leave as second child of catch, got $name instead";
4536 }
4537  
4538 0 my $trycode = scopeop(0, $self, $tryblock);
4539 0 my $catchvar = $self->padname($catch->targ);
4540 0 ▶ my $catchcode = $name eq 'scope' ? scopeop(0, $self, $catchblock)
Branch: 1 branch
BranchTrueFalseTotal
$name eq 'scope' ? : 0 0 0
4541 : scopeop(1, $self, $catchblock);
4542  
4543 0 my $finallycode = "";
4544 0 ▶ if($finallyop) {
Branch: 1 branch
BranchTrueFalseTotal
if ($finallyop) 0 0 0
4545 0 my $body = $self->deparse($finallyop->first->first);
4546 0 $finallycode = "\nfinally {\n\t$body\n\b}";
4547 }
4548  
4549 0 return "try {\n\t$trycode\n\b}\n" .
4550 "catch($catchvar) {\n\t$catchcode\n\b}$finallycode\cK";
4551 }
4552  
4553 sub pp_leavetrycatch {
4554 0 ▶ my $self = shift;
Subroutine pp_leavetrycatch: not called CC=1 SCAR=6.9
Pod undocumented
4555 0 my ($op, @args) = @_;
4556 0 return $self->pp_leavetrycatch_with_finally($op, undef, @args);
4557 }
4558  
4559 sub _op_is_or_was {
4560 0 ▶ my ($op, $expect_type) = @_;
Subroutine _op_is_or_was: not called CC=3 SCAR=24.8
4561 0 my $type = $op->type;
4562 0 ▶ return($type == $expect_type
Condition0%0/6
$type == $expect_type || $type == 0 && $op->targ == $expect_type
l!l&&r!l&&!r
000
$type == 0 and $op->targ == $expect_type
!ll&&!rl&&r
000
MC/DC0%0/3
$type == $expect_type || $type == 0 && $op->targ == $expect_type
$type == $expect_type $type == 0 $op->targ == $expect_type
Truth table0%0/4
A || B and C
A= $type == $expect_typeB= $type == 0C= $op->targ == $expect_type
ABCresult
1XX1
0111
00X0
0100
4563 || ($type == OP_NULL && $op->targ == $expect_type));
4564 }
4565  
4566 sub pp_null {
4567 0 ▶ my($self, $op, $cx) = @_;
Subroutine pp_null: not called CC=34 SCAR=70.8
Pod undocumented
4568  
4569 # might be 'my $s :Foo(bar);'
4570 0 ▶ if ($op->targ == OP_LIST) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->targ == 161) { } 0 0 0
elsif ($op->targ == 1) { } 0 0 0
4571 0 my $my_attr = maybe_var_attr($self, $op, $cx);
4572 0 ▶ return $my_attr if defined $my_attr;
Branch: 1 branch
BranchTrueFalseTotal
if defined $my_attr 0 0 0
4573 } elsif ($op->targ == OP_STUB) {
4574 0 return "()";
4575 }
4576  
4577 0 ▶ if (class($op) eq "OP") {
Branch: 12 branches
BranchTrueFalseTotal
if (B::Deparse::class($op) eq 'OP') { } 0 0 0
elsif (B::Deparse::class($op) eq 'COP') { } 0 0 0
elsif ($op->first->name eq 'pushmark' or $op->first->name eq 'null' and $op->first->targ == 3 and _op_is_or_was($op, 161)) { } 0 0 0
elsif ($op->first->name eq 'enter') { } 0 0 0
elsif ($op->first->name eq 'leave') { } 0 0 0
elsif ($op->first->name eq 'scope') { } 0 0 0
elsif ($op->targ == 69) { } 0 0 0
elsif ($op->targ == 25) { } 0 0 0
elsif (not null($op->first->sibling) and $op->first->sibling->name eq 'readline' and $op->first->sibling->flags & 64) { } 0 0 0
elsif (not null($op->first->sibling) and $op->first->sibling->name =~ /^transr?\z/ and $op->first->sibling->flags & 64) { } 0 0 0
elsif ($op->flags & 128 and $cx < 1 and not $op->targ) { } 0 0 0
elsif (not null($op->first->sibling) and $op->first->sibling->name eq 'null' and B::Deparse::class($op->first->sibling) eq 'UNOP' and $op->first->sibling->first->flags & 64 and $op->first->sibling->first->name eq 'rcatline') { } 0 0 0
4578 # old value is lost
4579 0 ▶ return $self->{'ex_const'} if $op->targ == OP_CONST;
Branch: 1 branch
BranchTrueFalseTotal
if $op->targ == 5 0 0 0
4580 } elsif (class ($op) eq "COP") {
4581 0 return &pp_nextstate;
4582 ▶ } elsif ($op->first->name eq 'pushmark'
Condition0%0/9
$op->first->name eq "pushmark" or $op->first->name eq "null" and $op->first->targ == 3 and _op_is_or_was($op, 161)
l!l&&r!l&&!r
000
$op->first->name eq "null" and $op->first->targ == 3 and _op_is_or_was($op, 161)
!ll&&!rl&&r
000
$op->first->name eq "null" and $op->first->targ == 3
!ll&&!rl&&r
000
MC/DC0%0/4
$op->first->name eq "pushmark" or $op->first->name eq "null" and $op->first->targ == 3 and _op_is_or_was($op, 161)
$op->first->name eq "pushmark" $op->first->name eq "null" $op->first->targ == 3 _op_is_or_was($op, 161)
Truth table0%0/5
A or B and C and D
A= $op->first->name eq "pushmark"B= $op->first->name eq "null"C= $op->first->targ == 3D= _op_is_or_was($op, 161)
ABCDresult
1XXX1
01111
00XX0
010X0
01100
4583 or $op->first->name eq 'null'
4584 && $op->first->targ == OP_PUSHMARK
4585 && _op_is_or_was($op, OP_LIST)) {
4586 0 return $self->pp_list($op, $cx);
4587 } elsif ($op->first->name eq "enter") {
4588 0 return $self->pp_leave($op, $cx);
4589 } elsif ($op->first->name eq "leave") {
4590 0 return $self->pp_leave($op->first, $cx);
4591 } elsif ($op->first->name eq "scope") {
4592 0 return $self->pp_scope($op->first, $cx);
4593 } elsif ($op->targ == OP_STRINGIFY) {
4594 0 return $self->dquote($op, $cx);
4595 } elsif ($op->targ == OP_GLOB) {
4596 0 return $self->pp_glob(
4597 $op->first # entersub
4598 ->first # ex-list
4599 ->first # pushmark
4600 ->sibling, # glob
4601 $cx
4602 );
4603 ▶ } elsif (!null($op->first->sibling) and
Condition0%0/6
not null($op->first->sibling) and $op->first->sibling->name eq "readline" and $op->first->sibling->flags & 64
!ll&&!rl&&r
000
not null($op->first->sibling) and $op->first->sibling->name eq "readline"
!ll&&!rl&&r
000
MC/DC0%0/3
not null($op->first->sibling) and $op->first->sibling->name eq "readline" and $op->first->sibling->flags & 64
not null($op->first->sibling) $op->first->sibling->name eq "readline" $op->first->sibling->flags & 64
Truth table0%0/4
not(A) and B and C
A= not null($op->first->sibling)B= $op->first->sibling->name eq "readline"C= $op->first->sibling->flags & 64
ABCresult
0XX0
10X0
1100
1111
4604 $op->first->sibling->name eq "readline" and
4605 $op->first->sibling->flags & OPf_STACKED) {
4606 0 return $self->maybe_parens($self->deparse($op->first, 7) . " = "
4607 . $self->deparse($op->first->sibling, 7),
4608 $cx, 7);
4609 ▶ } elsif (!null($op->first->sibling) and
Condition0%0/6
not null($op->first->sibling) and $op->first->sibling->name =~ /^transr?\z/ and $op->first->sibling->flags & 64
!ll&&!rl&&r
000
not null($op->first->sibling) and $op->first->sibling->name =~ /^transr?\z/
!ll&&!rl&&r
000
MC/DC0%0/3
not null($op->first->sibling) and $op->first->sibling->name =~ /^transr?\z/ and $op->first->sibling->flags & 64
not null($op->first->sibling) $op->first->sibling->name =~ /^transr?\z/ $op->first->sibling->flags & 64
Truth table0%0/4
not(A) and B and C
A= not null($op->first->sibling)B= $op->first->sibling->name =~ /^transr?\z/C= $op->first->sibling->flags & 64
ABCresult
0XX0
10X0
1100
1111
4610 $op->first->sibling->name =~ /^transr?\z/ and
4611 $op->first->sibling->flags & OPf_STACKED) {
4612 0 my $lhs = $self->deparse($op->first, 20);
4613 0 ▶ $lhs = "($lhs)"
Branch: 1 branch
BranchTrueFalseTotal
if $op->first->name eq "not" and $op->first->flags & 8 and not $lhs =~ /\(/ 0 0 0
Condition0%0/6
$op->first->name eq "not" and $op->first->flags & 8 and not $lhs =~ /\(/
!ll&&!rl&&r
000
$op->first->name eq "not" and $op->first->flags & 8
!ll&&!rl&&r
000
MC/DC0%0/3
$op->first->name eq "not" and $op->first->flags & 8 and not $lhs =~ /\(/
$op->first->name eq "not" $op->first->flags & 8 not $lhs =~ /\(/
Truth table0%0/4
A and B and not(C)
A= $op->first->name eq "not"B= $op->first->flags & 8C= not $lhs =~ /\(/
ABCresult
0XX0
10X0
1100
1111
4614 if $op->first->name eq 'not'
4615 and $op->first->flags & OPf_PARENS
4616 and $lhs !~ /\(/;
4617 0 return $self->maybe_parens( "$lhs =~ "
4618 . $self->deparse($op->first->sibling, 20),
4619 $cx, 20);
4620 ▶ } elsif ($op->flags & OPf_SPECIAL && $cx < 1 && !$op->targ) {
Condition0%0/6
$op->flags & 128 and $cx < 1 and not $op->targ
!ll&&!rl&&r
000
$op->flags & 128 and $cx < 1
!ll&&!rl&&r
000
MC/DC0%0/3
$op->flags & 128 and $cx < 1 and not $op->targ
$op->flags & 128 $cx < 1 not $op->targ
Truth table0%0/4
A and B and not(C)
A= $op->flags & 128B= $cx < 1C= not $op->targ
ABCresult
0XX0
10X0
1100
1111
4621 0 ▶ return ($self->lex_in_scope("&do") ? "CORE::do" : "do")
Branch: 1 branch
BranchTrueFalseTotal
$self->lex_in_scope('&do') ? : 0 0 0
4622 . " {\n\t". $self->deparse($op->first, $cx) ."\n\b};";
4623 ▶ } elsif (!null($op->first->sibling) and
Condition0%0/12
not null($op->first->sibling) and $op->first->sibling->name eq "null" and B::Deparse::class($op->first->sibling) eq "UNOP" and $op->first->sibling->first->flags & 64 and $op->first->sibling->first->name eq "rcatline"
!ll&&!rl&&r
000
not null($op->first->sibling) and $op->first->sibling->name eq "null" and B::Deparse::class($op->first->sibling) eq "UNOP" and $op->first->sibling->first->flags & 64
!ll&&!rl&&r
000
not null($op->first->sibling) and $op->first->sibling->name eq "null" and B::Deparse::class($op->first->sibling) eq "UNOP"
!ll&&!rl&&r
000
not null($op->first->sibling) and $op->first->sibling->name eq "null"
!ll&&!rl&&r
000
MC/DC0%0/5
not null($op->first->sibling) and $op->first->sibling->name eq "null" and B::Deparse::class($op->first->sibling) eq "UNOP" and $op->first->sibling->first->flags & 64 and $op->first->sibling->first->name eq "rcatline"
not null($op->first->sibling) $op->first->sibling->name eq "null" B::Deparse::class($op->first->sibling) eq "UNOP" $op->first->sibling->first->flags & 64 $op->first->sibling->first->name eq "rcatline"
Truth table0%0/6
not(A) and B and C and D and E
A= not null($op->first->sibling)B= $op->first->sibling->name eq "null"C= B::Deparse::class($op->first->sibling) eq "UNOP"D= $op->first->sibling->first->flags & 64E= $op->first->sibling->first->name eq "rcatline"
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
4624 $op->first->sibling->name eq "null" and
4625 class($op->first->sibling) eq "UNOP" and
4626 $op->first->sibling->first->flags & OPf_STACKED and
4627 $op->first->sibling->first->name eq "rcatline") {
4628 0 return $self->maybe_parens($self->deparse($op->first, 18) . " .= "
4629 . $self->deparse($op->first->sibling, 18),
4630 $cx, 18);
4631 } else {
4632 0 return $self->deparse($op->first, $cx);
4633 }
4634 }
4635  
4636 sub padname {
4637 0 ▶ my $self = shift;
Subroutine padname: not called CC=1 SCAR=6.9
Pod undocumented
4638 0 my $targ = shift;
4639 0 return $self->padname_sv($targ)->PVX;
4640 }
4641  
4642 sub padany {
4643 0 ▶ my $self = shift;
Subroutine padany: not called CC=1 SCAR=6.9
Pod undocumented
4644 0 my $op = shift;
4645 0 return substr($self->padname($op->targ), 1); # skip $/@/%
4646 }
4647  
4648 sub pp_padsv {
4649 0 ▶ my $self = shift;
Subroutine pp_padsv: not called CC=1 SCAR=6.9
Pod undocumented
4650 0 my($op, $cx, $forbid_parens) = @_;
4651 0 my $targ = $op->targ;
4652 0 return $self->maybe_my($op, $cx, $self->padname($targ),
4653 $self->padname_sv($targ),
4654 $forbid_parens);
4655 }
4656  
4657 0 ▶sub pp_padav { pp_padsv(@_) }
Subroutine pp_padav: not called CC=1 SCAR=6.9
Pod undocumented
4658  
4659 # prepend 'keys' where its been optimised away, with suitable handling
4660 # of CORE:: and parens
4661  
4662 sub add_keys_keyword {
4663 0 ▶ my ($self, $str, $cx) = @_;
Subroutine add_keys_keyword: not called CC=2 SCAR=17.9
Pod undocumented
4664 0 $str = $self->maybe_parens($str, $cx, 16);
4665 # 'keys %h' versus 'keys(%h)'
4666 0 ▶ $str = " $str" unless $str =~ /^\(/;
Branch: 1 branch
BranchTrueFalseTotal
unless $str =~ /^\(/ 0 0 0
4667 0 return $self->keyword("keys") . $str;
4668 }
4669  
4670 sub pp_padhv {
4671 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_padhv: not called CC=3 SCAR=24.8
Pod undocumented
4672 0 my $str = pp_padsv(@_);
4673 # with OPpPADHV_ISKEYS the keys op is optimised away, except
4674 # in scalar context the old op is kept (but not executed) so its targ
4675 # can be used.
4676 0 ▶ if ( ($op->private & OPpPADHV_ISKEYS)
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 1 and not +($op->flags & 3) == 2) 0 0 0
Condition0%0/3
$op->private & 1 and not +($op->flags & 3) == 2
!ll&&!rl&&r
000
MC/DC0%0/2
$op->private & 1 and not +($op->flags & 3) == 2
$op->private & 1 not +($op->flags & 3) == 2
Truth table0%0/3
A and not(B)
A= $op->private & 1B= not +($op->flags & 3) == 2
ABresult
0X0
100
111
4677 && !(($op->flags & OPf_WANT) == OPf_WANT_SCALAR))
4678 {
4679 0 $str = $self->add_keys_keyword($str, $cx);
4680 }
4681 0 $str;
4682 }
4683  
4684 sub gv_or_padgv {
4685 0 ▶ my $self = shift;
Subroutine gv_or_padgv: not called CC=2 SCAR=17.9
Pod undocumented
4686 0 my $op = shift;
4687 0 ▶ if (class($op) eq "PADOP") {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($op) eq 'PADOP') { } 0 0 0
4688 0 return $self->padval($op->padix);
4689 } else { # class($op) eq "SVOP"
4690 0 return $op->gv;
4691 }
4692 }
4693  
4694 sub pp_gvsv {
4695 0 ▶ my $self = shift;
Subroutine pp_gvsv: not called CC=1 SCAR=6.9
Pod undocumented
4696 0 my($op, $cx) = @_;
4697 0 my $gv = $self->gv_or_padgv($op);
4698 0 return $self->maybe_local($op, $cx, $self->stash_variable("\$",
4699 $self->gv_name($gv), $cx));
4700 }
4701  
4702 sub pp_gv {
4703 0 ▶ my $self = shift;
Subroutine pp_gv: not called CC=1 SCAR=6.9
Pod undocumented
4704 0 my($op, $cx) = @_;
4705 0 my $gv = $self->gv_or_padgv($op);
4706 0 return $self->maybe_qualify("", $self->gv_name($gv));
4707 }
4708  
4709 sub pp_aelemfastlex_store {
4710 0 ▶ my $self = shift;
Subroutine pp_aelemfastlex_store: not called CC=2 SCAR=17.9
Pod undocumented
4711 0 my($op, $cx) = @_;
4712 0 my $name = $self->padname($op->targ);
4713 0 $name =~ s/^@/\$/;
4714 0 my $i = $op->private;
4715 0 ▶ $i -= 256 if $i > 127;
Branch: 1 branch
BranchTrueFalseTotal
if $i > 127 0 0 0
4716 0 my $val = $self->deparse($op->first, 7);
4717 0 return $self->maybe_parens("${name}[$i] = $val", $cx, 7);
4718 }
4719  
4720 sub pp_aelemfast_lex {
4721 0 ▶ my $self = shift;
Subroutine pp_aelemfast_lex: not called CC=2 SCAR=17.9
Pod undocumented
4722 0 my($op, $cx) = @_;
4723 0 my $name = $self->padname($op->targ);
4724 0 $name =~ s/^@/\$/;
4725 0 my $i = $op->private;
4726 0 ▶ $i -= 256 if $i > 127;
Branch: 1 branch
BranchTrueFalseTotal
if $i > 127 0 0 0
4727 0 return $name . "[$i]";
4728 }
4729  
4730 sub pp_aelemfast {
4731 0 ▶ my $self = shift;
Subroutine pp_aelemfast: not called CC=4 SCAR=30.0
Pod undocumented
4732 0 my($op, $cx) = @_;
4733 # optimised PADAV, pre 5.15
4734 0 ▶ return $self->pp_aelemfast_lex(@_) if ($op->flags & OPf_SPECIAL);
Branch: 1 branch
BranchTrueFalseTotal
if $op->flags & 128 0 0 0
4735  
4736 0 my $gv = $self->gv_or_padgv($op);
4737 0 my($name,$quoted) = $self->stash_variable_name('@',$gv);
4738 0 ▶ $name = $quoted ? "$name->" : '$' . $name;
Branch: 1 branch
BranchTrueFalseTotal
$quoted ? : 0 0 0
4739 0 my $i = $op->private;
4740 0 ▶ $i -= 256 if $i > 127;
Branch: 1 branch
BranchTrueFalseTotal
if $i > 127 0 0 0
4741 0 return $name . "[$i]";
4742 }
4743  
4744 sub rv2x {
4745 0 ▶ my $self = shift;
Subroutine rv2x: not called CC=6 SCAR=37.4
Pod undocumented
4746 0 my($op, $cx, $type) = @_;
4747  
4748 0 ▶ if (class($op) eq 'NULL' || !$op->can("first")) {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($op) eq "NULL" or not $op->can("first")) 0 0 0
Condition0%0/3
B::Deparse::class($op) eq "NULL" or not $op->can("first")
l!l&&r!l&&!r
000
MC/DC0%0/2
B::Deparse::class($op) eq "NULL" or not $op->can("first")
B::Deparse::class($op) eq "NULL" not $op->can("first")
Truth table0%0/3
A or not(B)
A= B::Deparse::class($op) eq "NULL"B= not $op->can("first")
ABresult
1X1
011
000
4749 0 carp("Unexpected op in pp_rv2x");
4750 0 return 'XXX';
4751 }
4752 0 my $kid = $op->first;
4753 0 ▶ if ($kid->name eq "gv") {
Branch: 2 branches
BranchTrueFalseTotal
if ($kid->name eq 'gv') { } 0 0 0
elsif (is_scalar($kid)) { } 0 0 0
4754 0 return $self->stash_variable($type,
4755 $self->gv_name($self->gv_or_padgv($kid)), $cx);
4756 } elsif (is_scalar $kid) {
4757 0 my $str = $self->deparse($kid, 0);
4758 0 ▶ if ($str =~ /^\$([^\w\d])\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /^\$([^\w\d])\z/) 0 0 0
4759 # "$$+" isn't a legal way to write the scalar dereference
4760 # of $+, since the lexer can't tell you aren't trying to
4761 # do something like "$$ + 1" to get one more than your
4762 # PID. Either "${$+}" or "$${+}" are workable
4763 # disambiguations, but if the programmer did the former,
4764 # they'd be in the "else" clause below rather than here.
4765 # It's not clear if this should somehow be unified with
4766 # the code in dq and re_dq that also adds lexer
4767 # disambiguation braces.
4768 0 $str = '$' . "{$1}"; #'
4769 }
4770 0 return $type . $str;
4771 } else {
4772 0 return $type . "{" . $self->deparse($kid, 0) . "}";
4773 }
4774 }
4775  
4776 0 ▶sub pp_rv2sv { maybe_local(@_, rv2x(@_, "\$")) }
Subroutine pp_rv2sv: not called CC=1 SCAR=6.9
Pod undocumented
4777 0 ▶sub pp_rv2gv { maybe_local(@_, rv2x(@_, "*")) }
Subroutine pp_rv2gv: not called CC=1 SCAR=6.9
Pod undocumented
4778  
4779 sub pp_rv2hv {
4780 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_rv2hv: not called CC=2 SCAR=17.9
Pod undocumented
4781 0 my $str = rv2x(@_, "%");
4782 0 ▶ if ($op->private & OPpRV2HV_ISKEYS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 1) 0 0 0
4783 0 $str = $self->add_keys_keyword($str, $cx);
4784 }
4785 0 return maybe_local(@_, $str);
4786 }
4787  
4788 # skip rv2av
4789 sub pp_av2arylen {
4790 0 ▶ my $self = shift;
Subroutine pp_av2arylen: not called CC=5 SCAR=34.0
Pod undocumented
4791 0 my($op, $cx) = @_;
4792 0 my $kid = $op->first;
4793 0 ▶ if ($kid->name eq "padav") {
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->name eq 'padav') { } 0 0 0
4794 0 return $self->maybe_local($op, $cx, '$#' . $self->padany($kid));
4795 } else {
4796 0 my $kkid;
4797 0 ▶ if ( $kid->name eq "rv2av"
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->name eq 'rv2av' and $kkid = $kid->first and not $kkid->name =~ /^(scope|leave|gv)$/) { } 0 0 0
Condition0%0/6
$kid->name eq "rv2av" and $kkid = $kid->first and not $kkid->name =~ /^(scope|leave|gv)$/
!ll&&!rl&&r
000
$kid->name eq "rv2av" and $kkid = $kid->first
!ll&&!rl&&r
000
MC/DC0%0/3
$kid->name eq "rv2av" and $kkid = $kid->first and not $kkid->name =~ /^(scope|leave|gv)$/
$kid->name eq "rv2av" $kkid = $kid->first not $kkid->name =~ /^(scope|leave|gv)$/
Truth table0%0/4
A and B and not(C)
A= $kid->name eq "rv2av"B= $kkid = $kid->firstC= not $kkid->name =~ /^(scope|leave|gv)$/
ABCresult
0XX0
10X0
1100
1111
4798 && ($kkid = $kid->first)
4799 && $kkid->name !~ /^(scope|leave|gv)$/)
4800 {
4801 # handle (expr)->$#* postfix form
4802 0 my $expr;
4803 0 $expr = $self->deparse($kkid, 24); # 24 is '->'
4804 0 $expr = "$expr->\$#*";
4805 # XXX maybe_local is probably wrong here: local($#-expression)
4806 # doesn't "do" local (the is no INTRO flag set)
4807 0 return $self->maybe_local($op, $cx, $expr);
4808 }
4809 else {
4810 # handle $#{expr} form
4811 # XXX see maybe_local comment above
4812 0 return $self->maybe_local($op, $cx, $self->rv2x($kid, $cx, '$#'));
4813 }
4814 }
4815 }
4816  
4817 # skip down to the old, ex-rv2cv
4818 sub pp_rv2cv {
4819 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_rv2cv: not called CC=4 SCAR=30.0
Pod undocumented
4820 0 ▶ if (!null($op->first) && $op->first->name eq 'null' &&
Branch: 1 branch
BranchTrueFalseTotal
if (not null($op->first) and $op->first->name eq 'null' and $op->first->targ == 161) { } 0 0 0
Condition0%0/6
not null($op->first) and $op->first->name eq "null" and $op->first->targ == 161
!ll&&!rl&&r
000
not null($op->first) and $op->first->name eq "null"
!ll&&!rl&&r
000
MC/DC0%0/3
not null($op->first) and $op->first->name eq "null" and $op->first->targ == 161
not null($op->first) $op->first->name eq "null" $op->first->targ == 161
Truth table0%0/4
not(A) and B and C
A= not null($op->first)B= $op->first->name eq "null"C= $op->first->targ == 161
ABCresult
0XX0
10X0
1100
1111
4821 $op->first->targ == OP_LIST)
4822 {
4823 0 return $self->rv2x($op->first->first->sibling, $cx, "&")
4824 }
4825 else {
4826 0 return $self->rv2x($op, $cx, "")
4827 }
4828 }
4829  
4830 sub list_const {
4831 0 ▶ my $self = shift;
Subroutine list_const: not called CC=6 SCAR=37.4
Pod undocumented
4832 0 my($cx, @list) = @_;
4833 0 my @a = map $self->const($_, 6), @list;
4834 0 ▶ if (@a == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if (@a == 0) { } 0 0 0
elsif (@a == 1) { } 0 0 0
elsif (@a > 2 and not grep((!/^-?\d+$/), @a)) { } 0 0 0
4835 0 return "()";
4836 } elsif (@a == 1) {
4837 0 return $a[0];
4838 ▶ } elsif ( @a > 2 and !grep(!/^-?\d+$/, @a)) {
Condition0%0/3
@a > 2 and not grep((!/^-?\d+$/), @a)
!ll&&!rl&&r
000
MC/DC0%0/2
@a > 2 and not grep((!/^-?\d+$/), @a)
@a > 2 not grep((!/^-?\d+$/), @a)
Truth table0%0/3
A and not(B)
A= @a > 2B= not grep((!/^-?\d+$/), @a)
ABresult
0X0
100
111
4839 # collapse (-1,0,1,2) into (-1..2)
4840 0 my ($s, $e) = @a[0,-1];
4841 0 my $i = $s;
4842 0 ▶ return $self->maybe_parens("$s..$e", $cx, 9)
Branch: 1 branch
BranchTrueFalseTotal
unless grep(($i++ != $_), @a) 0 0 0
4843 unless grep $i++ != $_, @a;
4844 }
4845 0 return $self->maybe_parens(join(", ", @a), $cx, 6);
4846 }
4847  
4848 sub pp_rv2av {
4849 0 ▶ my $self = shift;
Subroutine pp_rv2av: not called CC=2 SCAR=17.9
Pod undocumented
4850 0 my($op, $cx) = @_;
4851 0 my $kid = $op->first;
4852 0 ▶ if ($kid->name eq "const") { # constant list
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->name eq 'const') { } 0 0 0
4853 0 my $av = $self->const_sv($kid);
4854 0 return $self->list_const($cx, $av->ARRAY);
4855 } else {
4856 0 return $self->maybe_local($op, $cx, $self->rv2x($op, $cx, "\@"));
4857 }
4858 }
4859  
4860 sub is_subscriptable {
4861 0 ▶ my $op = shift;
Subroutine is_subscriptable: not called CC=9 SCAR=45.0
Pod undocumented
4862 0 ▶ if ($op->name =~ /^([ahg]elem|multideref$)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->name =~ /^([ahg]elem|multideref$)/) { } 0 0 0
elsif ($op->name eq 'entersub') { } 0 0 0
4863 0 return 1;
4864 } elsif ($op->name eq "entersub") {
4865 0 my $kid = $op->first;
4866 0 ▶ return 0 unless null $kid->sibling;
Branch: 1 branch
BranchTrueFalseTotal
unless null($kid->sibling) 0 0 0
4867 0 $kid = $kid->first;
4868 0 ▶ $kid = $kid->sibling until null $kid->sibling;
Branch: 1 branch
BranchTrueFalseTotal
null($kid->sibling) or do { $kid = $kid->sibling } 0 0 0
4869 0 ▶ return 0 if is_scope($kid);
Branch: 1 branch
BranchTrueFalseTotal
if is_scope($kid) 0 0 0
4870 0 $kid = $kid->first;
4871 0 ▶ return 0 if $kid->name eq "gv" || $kid->name eq "padcv";
Branch: 1 branch
BranchTrueFalseTotal
if $kid->name eq "gv" or $kid->name eq "padcv" 0 0 0
Condition0%0/3
$kid->name eq "gv" or $kid->name eq "padcv"
l!l&&r!l&&!r
000
MC/DC0%0/2
$kid->name eq "gv" or $kid->name eq "padcv"
$kid->name eq "gv" $kid->name eq "padcv"
Truth table0%0/3
A or B
A= $kid->name eq "gv"B= $kid->name eq "padcv"
ABresult
1X1
011
000
4872 0 ▶ return 0 if is_scalar($kid);
Branch: 1 branch
BranchTrueFalseTotal
if is_scalar($kid) 0 0 0
4873 0 return is_subscriptable($kid);
4874 } else {
4875 0 return 0;
4876 }
4877 }
4878  
4879 sub elem_or_slice_array_name
4880 {
4881 0 ▶ my $self = shift;
Subroutine elem_or_slice_array_name: not called CC=10 SCAR=47.0
Pod undocumented
4882 0 my ($array, $left, $padname, $allow_arrow) = @_;
4883  
4884 0 ▶ if ($array->name eq $padname) {
Branch: 4 branches
BranchTrueFalseTotal
if ($array->name eq $padname) { } 0 0 0
elsif (is_scope($array)) { } 0 0 0
elsif ($array->name eq 'gv') { } 0 0 0
elsif (not $allow_arrow or is_scalar($array)) { } 0 0 0
4885 0 return $self->padany($array);
4886 } elsif (is_scope($array)) { # ${expr}[0]
4887 0 return "{" . $self->deparse($array, 0) . "}";
4888 } elsif ($array->name eq "gv") {
4889 0 ▶ ($array, my $quoted) =
Branch: 1 branch
BranchTrueFalseTotal
$left eq '[' ? : 0 0 0
4890 $self->stash_variable_name(
4891 $left eq '[' ? '@' : '%', $self->gv_or_padgv($array)
4892 );
4893 0 ▶ if (!$allow_arrow && $quoted) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $allow_arrow and $quoted) 0 0 0
Condition0%0/3
not $allow_arrow and $quoted
!ll&&!rl&&r
000
MC/DC0%0/2
not $allow_arrow and $quoted
not $allow_arrow $quoted
Truth table0%0/3
not(A) and B
A= not $allow_arrowB= $quoted
ABresult
0X0
100
111
4894 # This cannot happen.
4895 0 die "Invalid variable name $array for slice";
4896 }
4897 0 ▶ return $quoted ? "$array->" : $array;
Branch: 1 branch
BranchTrueFalseTotal
$quoted ? : 0 0 0
4898 ▶ } elsif (!$allow_arrow || is_scalar $array) { # $x[0], $$x[0], ...
Condition0%0/3
not $allow_arrow or is_scalar($array)
l!l&&r!l&&!r
000
MC/DC0%0/2
not $allow_arrow or is_scalar($array)
not $allow_arrow is_scalar($array)
Truth table0%0/3
not(A) or B
A= not $allow_arrowB= is_scalar($array)
ABresult
1X1
011
000
4899 0 return $self->deparse($array, 24);
4900 } else {
4901 0 return undef;
4902 }
4903 }
4904  
4905 sub elem_or_slice_single_index
4906 {
4907 0 ▶ my $self = shift;
Subroutine elem_or_slice_single_index: not called CC=2 SCAR=17.9
Pod undocumented
4908 0 my ($idx) = @_;
4909  
4910 0 $idx = $self->deparse($idx, 1);
4911  
4912 # Outer parens in an array index will confuse perl
4913 # if we're interpolating in a regular expression, i.e.
4914 # /$x$foo[(-1)]/ is *not* the same as /$x$foo[-1]/
4915 #
4916 # If $self->{parens}, then an initial '(' will
4917 # definitely be paired with a final ')'. If
4918 # !$self->{parens}, the misleading parens won't
4919 # have been added in the first place.
4920 #
4921 # [You might think that we could get "(...)...(...)"
4922 # where the initial and final parens do not match
4923 # each other. But we can't, because the above would
4924 # only happen if there's an infix binop between the
4925 # two pairs of parens, and *that* means that the whole
4926 # expression would be parenthesized as well.]
4927 #
4928 0 ▶ $idx =~ s/^\((.*)\)$/$1/ if $self->{'parens'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"parens"} 0 0 0
4929  
4930 # Hash-element braces will autoquote a bareword inside themselves.
4931 # We need to make sure that C<$hash{warn()}> doesn't come out as
4932 # C<$hash{warn}>, which has a quite different meaning. Currently
4933 # B::Deparse will always quote strings, even if the string was a
4934 # bareword in the original (i.e. the OPpCONST_BARE flag is ignored
4935 # for constant strings.) So we can cheat slightly here - if we see
4936 # a bareword, we know that it is supposed to be a function call.
4937 #
4938 0 $idx =~ s/^([A-Za-z_]\w*)$/$1()/;
4939  
4940 0 return $idx;
4941 }
4942  
4943 sub elem {
4944 0 ▶ my $self = shift;
Subroutine elem: not called CC=6 SCAR=37.4
Pod undocumented
4945 0 my ($op, $cx, $left, $right, $padname) = @_;
4946 0 my($array, $idx) = ($op->first, $op->first->sibling);
4947  
4948 0 $idx = $self->elem_or_slice_single_index($idx);
4949  
4950 0 ▶ unless ($array->name eq $padname) { # Maybe this has been fixed
Branch: 1 branch
BranchTrueFalseTotal
unless ($array->name eq $padname) 0 0 0
4951 0 $array = $array->first; # skip rv2av (or ex-rv2av in _53+)
4952 }
4953 0 ▶ if (my $array_name=$self->elem_or_slice_array_name
Branch: 1 branch
BranchTrueFalseTotal
if (my $array_name = $self->elem_or_slice_array_name($array, $left, $padname, 1)) { } 0 0 0
4954 ($array, $left, $padname, 1)) {
4955 0 ▶ return ($array_name =~ /->\z/
Branch: 2 branches
BranchTrueFalseTotal
$array_name =~ /->\z/ ? : 0 0 0
$array_name eq '#' ? : 0 0 0
4956 ? $array_name
4957 : $array_name eq '#' ? '${#}' : "\$" . $array_name)
4958 . $left . $idx . $right;
4959 } else {
4960 # $x[20][3]{hi} or expr->[20]
4961 0 ▶ my $arrow = is_subscriptable($array) ? "" : "->";
Branch: 1 branch
BranchTrueFalseTotal
is_subscriptable($array) ? : 0 0 0
4962 0 return $self->deparse($array, 24) . $arrow . $left . $idx . $right;
4963 }
4964  
4965 }
4966  
4967 # a simplified version of elem_or_slice_array_name()
4968 # for the use of pp_multideref
4969  
4970 sub multideref_var_name {
4971 0 ▶ my $self = shift;
Subroutine multideref_var_name: not called CC=4 SCAR=30.0
Pod undocumented
4972 0 my ($gv, $is_hash) = @_;
4973  
4974 0 ▶ my ($name, $quoted) =
Branch: 1 branch
BranchTrueFalseTotal
$is_hash ? : 0 0 0
4975 $self->stash_variable_name( $is_hash ? '%' : '@', $gv);
4976 0 ▶ return $quoted ? "$name->"
Branch: 2 branches
BranchTrueFalseTotal
$quoted ? : 0 0 0
$name eq '#' ? : 0 0 0
4977 : $name eq '#'
4978 ? '${#}' # avoid ${#}[1] => $#[1]
4979 : '$' . $name;
4980 }
4981  
4982  
4983 # deparse an OP_MULTICONCAT. If $in_dq is 1, we're within
4984 # a double-quoted string, so for example.
4985 # "abc\Qdef$x\Ebar"
4986 # might get compiled as
4987 # multiconcat("abc", metaquote(multiconcat("def", $x)), "bar")
4988 # and the inner multiconcat should be deparsed as C<def$x> rather than
4989 # the normal C<def . $x>
4990 # Ditto if $in_dq is 2, handle qr/...\Qdef$x\E.../.
4991  
4992 sub do_multiconcat {
4993 0 ▶ my $self = shift;
Subroutine do_multiconcat: not called CC=34 SCAR=70.8
Pod undocumented
4994 0 my($op, $cx, $in_dq) = @_;
4995  
4996 0 my $kid;
4997 my @kids;
4998 0 my $assign;
4999 0 my $append;
5000 0 my $lhs = "";
5001  
5002 0 ▶ for ($kid = $op->first; !null $kid; $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
5003 # skip the consts and/or padsv we've optimised away
5004 0 ▶ push @kids, $kid
Branch: 1 branch
BranchTrueFalseTotal
unless $kid->type == 0 and $kid->targ == 9 || $kid->targ == 5 || $kid->targ == 3 0 0 0
Condition0%0/9
$kid->type == 0 and $kid->targ == 9 || $kid->targ == 5 || $kid->targ == 3
!ll&&!rl&&r
000
$kid->targ == 9 or $kid->targ == 5 or $kid->targ == 3
l!l&&r!l&&!r
000
$kid->targ == 9 or $kid->targ == 5
l!l&&r!l&&!r
000
MC/DC0%0/4
$kid->type == 0 and $kid->targ == 9 || $kid->targ == 5 || $kid->targ == 3
$kid->type == 0 $kid->targ == 9 $kid->targ == 5 $kid->targ == 3
Truth table0%0/5
A and B or C or D
A= $kid->type == 0B= $kid->targ == 9C= $kid->targ == 5D= $kid->targ == 3
ABCDresult
0XXX0
10000
11XX1
101X1
10011
5005 unless $kid->type == OP_NULL
5006 && ( $kid->targ == OP_PADSV
5007 || $kid->targ == OP_CONST
5008 || $kid->targ == OP_PUSHMARK);
5009 }
5010  
5011 0 $append = ($op->private & OPpMULTICONCAT_APPEND);
5012  
5013 0 ▶ if ($op->private & OPpTARGET_MY) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->private & 16) { } 0 0 0
elsif ($op->flags & 64) { } 0 0 0
5014 # '$lex = ...' or '$lex .= ....' or 'my $lex = '
5015 0 $lhs = $self->padname($op->targ);
5016 0 ▶ $lhs = "my $lhs" if ($op->private & OPpLVAL_INTRO);
Branch: 1 branch
BranchTrueFalseTotal
if $op->private & 128 0 0 0
5017 0 $assign = 1;
5018 }
5019 elsif ($op->flags & OPf_STACKED) {
5020 # 'expr = ...' or 'expr .= ....'
5021 0 ▶ my $expr = $append ? shift(@kids) : pop(@kids);
Branch: 1 branch
BranchTrueFalseTotal
$append ? : 0 0 0
5022 0 $lhs = $self->deparse($expr, 7);
5023 0 $assign = 1;
5024 }
5025  
5026 0 ▶ if ($assign) {
Branch: 1 branch
BranchTrueFalseTotal
if ($assign) 0 0 0
5027 0 ▶ $lhs .= $append ? ' .= ' : ' = ';
Branch: 1 branch
BranchTrueFalseTotal
$append ? : 0 0 0
5028 }
5029  
5030 0 my ($nargs, $const_str, @const_lens) = $op->aux_list($self->{curcv});
5031  
5032 0 my @consts;
5033 0 my $i = 0;
5034 0 for (@const_lens) {
5035 0 ▶ if ($_ == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ == -1) { } 0 0 0
5036 0 push @consts, undef;
5037 }
5038 else {
5039 0 push @consts, substr($const_str, $i, $_);
5040 0 my @args;
5041 0 $i += $_;
5042 }
5043 }
5044  
5045 0 my $rhs = "";
5046  
5047 0 ▶ if ( $in_dq
Branch: 2 branches
BranchTrueFalseTotal
if ($in_dq or $op->private & 8 and not $self->{'unquote'}) { } 0 0 0
elsif ($op->private & 32) { } 0 0 0
Condition0%0/6
$in_dq or $op->private & 8 and not $self->{"unquote"}
l!l&&r!l&&!r
000
$op->private & 8 and not $self->{"unquote"}
!ll&&!rl&&r
000
MC/DC0%0/3
$in_dq or $op->private & 8 and not $self->{"unquote"}
$in_dq $op->private & 8 not $self->{"unquote"}
Truth table0%0/4
A or B and not(C)
A= $in_dqB= $op->private & 8C= not $self->{"unquote"}
ABCresult
1XX1
0111
00X0
0100
5048 || (($op->private & OPpMULTICONCAT_STRINGIFY) && !$self->{'unquote'}))
5049 {
5050 # "foo=$foo bar=$bar "
5051 0 my $not_first;
5052 0 ▶ while (@consts) {
Branch: 1 branch
BranchTrueFalseTotal
if (@consts) 0 0 0
5053 0 ▶ if ($not_first) {
Branch: 1 branch
BranchTrueFalseTotal
if ($not_first) 0 0 0
5054 0 my $s = $self->dq(shift(@kids), 18);
5055 # don't deparse "a${$}b" as "a$$b"
5056 0 ▶ $s = '${$}' if $s eq '$$';
Branch: 1 branch
BranchTrueFalseTotal
if $s eq "\$\$" 0 0 0
5057 0 $rhs = dq_disambiguate($rhs, $s);
5058 }
5059 0 $not_first = 1;
5060 0 my $c = shift @consts;
5061 0 ▶ if (defined $c) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c) 0 0 0
5062 0 ▶ if ($in_dq == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_dq == 2) { } 0 0 0
5063 # in pattern: don't convert newline to '\n' etc etc
5064 0 my $s = re_uninterp(escape_re(re_unback($c)));
5065 0 $rhs = re_dq_disambiguate($rhs, $s)
5066 }
5067 else {
5068 0 my $s = uninterp(escape_str(unback($c)));
5069 0 $rhs = dq_disambiguate($rhs, $s)
5070 }
5071 }
5072 }
5073 0 ▶ return $rhs if $in_dq;
Branch: 1 branch
BranchTrueFalseTotal
if $in_dq 0 0 0
5074 0 $rhs = single_delim("qq", '"', $rhs, $self);
5075 }
5076 elsif ($op->private & OPpMULTICONCAT_FAKE) {
5077 # sprintf("foo=%s bar=%s ", $foo, $bar)
5078  
5079 0 my @all;
5080 0 ▶ @consts = map { $_ //= ''; s/%/%%/g; $_ } @consts;
Condition0%0/2
$_ //= ""
l!l
00
MC/DC0%0/1
$_ //= ""
$_
Truth table0%0/2
A
A= $_
Aresult
11
00
5081 0 my $fmt = join '%s', @consts;
5082 0 push @all, $self->quoted_const_str($fmt);
5083  
5084 # the following is a stripped down copy of sub listop {}
5085 0 ▶ my $parens = $assign || ($cx >= 5) || $self->{'parens'};
Condition0%0/6
$assign || $cx >= 5 || $self->{'parens'}
l!l&&r!l&&!r
000
$assign or $cx >= 5
l!l&&r!l&&!r
000
MC/DC0%0/3
$assign || $cx >= 5 || $self->{'parens'}
$assign $cx >= 5 $self->{'parens'}
Truth table0%0/4
A or B || C
A= $assignB= $cx >= 5C= $self->{'parens'}
ABCresult
1XX1
01X1
0011
0000
5086 0 my $fullname = $self->keyword('sprintf');
5087 0 push @all, map $self->deparse($_, 6), @kids;
5088  
5089 0 ▶ $rhs = $parens
Branch: 1 branch
BranchTrueFalseTotal
$parens ? : 0 0 0
5090 ? "$fullname(" . join(", ", @all) . ")"
5091 : "$fullname " . join(", ", @all);
5092 }
5093 else {
5094 # "foo=" . $foo . " bar=" . $bar
5095 0 my @all;
5096 my $not_first;
5097 0 ▶ while (@consts) {
Branch: 1 branch
BranchTrueFalseTotal
if (@consts) 0 0 0
5098 0 ▶ push @all, $self->deparse(shift(@kids), 18) if $not_first;
Branch: 1 branch
BranchTrueFalseTotal
if $not_first 0 0 0
5099 0 $not_first = 1;
5100 0 my $c = shift @consts;
5101 0 ▶ if (defined $c) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c) 0 0 0
5102 0 push @all, $self->quoted_const_str($c);
5103 }
5104 }
5105 0 $rhs .= join ' . ', @all;
5106 }
5107  
5108 0 my $text = $lhs . $rhs;
5109  
5110 $text = "($text)" if ($cx >= (($assign) ? 7 : 18+1))
5111 0 ▶ || $self->{'parens'};
Branch: 2 branches
BranchTrueFalseTotal
if $cx >= ($assign ? 7 : 19) or $self->{"parens"} 0 0 0
$assign ? : 0 0 0
Condition0%0/3
$cx >= ($assign ? 7 : 19) or $self->{"parens"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cx >= ($assign ? 7 : 19) or $self->{"parens"}
$cx >= ($assign ? 7 : 19) $self->{"parens"}
Truth table0%0/3
A or B
A= $cx >= ($assign ? 7 : 19)B= $self->{"parens"}
ABresult
1X1
011
000
5112  
5113 0 return $text;
5114 }
5115  
5116  
5117 sub pp_multiconcat {
5118 0 ▶ my $self = shift;
Subroutine pp_multiconcat: not called CC=1 SCAR=6.9
Pod undocumented
5119 0 $self->do_multiconcat(@_, 0);
5120 }
5121  
5122  
5123 sub pp_multideref {
5124 0 ▶ my $self = shift;
Subroutine pp_multideref: not called CC=38 SCAR=73.0
Pod undocumented
5125 0 my($op, $cx) = @_;
5126 0 my $text = "";
5127  
5128 0 ▶ if ($op->private & OPpMULTIDEREF_EXISTS) {
Branch: 3 branches
BranchTrueFalseTotal
if ($op->private & 16) { } 0 0 0
elsif ($op->private & 32) { } 0 0 0
elsif ($op->private & 128) { } 0 0 0
5129 0 $text = $self->keyword("exists"). " ";
5130 }
5131 elsif ($op->private & OPpMULTIDEREF_DELETE) {
5132 0 $text = $self->keyword("delete"). " ";
5133 }
5134 elsif ($op->private & OPpLVAL_INTRO) {
5135 0 $text = $self->keyword("local"). " ";
5136 }
5137  
5138 0 ▶ if ($op->first && ($op->first->flags & OPf_KIDS)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->first and $op->first->flags & 4) 0 0 0
Condition0%0/3
$op->first and $op->first->flags & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$op->first and $op->first->flags & 4
$op->first $op->first->flags & 4
Truth table0%0/3
A and B
A= $op->firstB= $op->first->flags & 4
ABresult
0X0
100
111
5139 # arbitrary initial expression, e.g. f(1,2,3)->[...]
5140 0 my $expr = $self->deparse($op->first, 24);
5141 # stop "exists (expr)->{...}" being interpreted as
5142 #"(exists (expr))->{...}"
5143 0 ▶ $expr = "+$expr" if $expr =~ /^\(/;
Branch: 1 branch
BranchTrueFalseTotal
if $expr =~ /^\(/ 0 0 0
5144 0 $text .= $expr;
5145 }
5146  
5147 0 my @items = $op->aux_list($self->{curcv});
5148 0 my $actions = shift @items;
5149  
5150 0 my $is_hash;
5151 0 my $derefs = 0;
5152  
5153 0 while (1) {
5154 0 ▶ if (($actions & MDEREF_ACTION_MASK) == MDEREF_reload) {
Branch: 1 branch
BranchTrueFalseTotal
if (($actions & 15) == 0) 0 0 0
5155 0 $actions = shift @items;
5156 0 next;
5157 }
5158  
5159 $is_hash = (
5160 0 ▶ ($actions & MDEREF_ACTION_MASK) == MDEREF_HV_pop_rv2hv_helem
Condition0%0/15
($actions & 15) == 8 || ($actions & 15) == 9 || ($actions & 15) == 10 || ($actions & 15) == 11 || ($actions & 15) == 12 || ($actions & 15) == 13
l!l&&r!l&&!r
000
($actions & 15) == 8 or ($actions & 15) == 9 or ($actions & 15) == 10 or ($actions & 15) == 11 or ($actions & 15) == 12
l!l&&r!l&&!r
000
($actions & 15) == 8 or ($actions & 15) == 9 or ($actions & 15) == 10 or ($actions & 15) == 11
l!l&&r!l&&!r
000
($actions & 15) == 8 or ($actions & 15) == 9 or ($actions & 15) == 10
l!l&&r!l&&!r
000
($actions & 15) == 8 or ($actions & 15) == 9
l!l&&r!l&&!r
000
MC/DC0%0/6
($actions & 15) == 8 || ($actions & 15) == 9 || ($actions & 15) == 10 || ($actions & 15) == 11 || ($actions & 15) == 12 || ($actions & 15) == 13
($actions & 15) == 8 ($actions & 15) == 9 ($actions & 15) == 10 ($actions & 15) == 11 ($actions & 15) == 12 ($actions & 15) == 13
Truth table0%0/7
A or B or C or D or E || F
A= ($actions & 15) == 8B= ($actions & 15) == 9C= ($actions & 15) == 10D= ($actions & 15) == 11E= ($actions & 15) == 12F= ($actions & 15) == 13
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
5161 || ($actions & MDEREF_ACTION_MASK) == MDEREF_HV_gvsv_vivify_rv2hv_helem
5162 || ($actions & MDEREF_ACTION_MASK) == MDEREF_HV_padsv_vivify_rv2hv_helem
5163 || ($actions & MDEREF_ACTION_MASK) == MDEREF_HV_vivify_rv2hv_helem
5164 || ($actions & MDEREF_ACTION_MASK) == MDEREF_HV_padhv_helem
5165 || ($actions & MDEREF_ACTION_MASK) == MDEREF_HV_gvhv_helem
5166 );
5167  
5168 0 ▶ if ( ($actions & MDEREF_ACTION_MASK) == MDEREF_AV_padav_aelem
Branch: 2 branches
BranchTrueFalseTotal
if (($actions & 15) == 5 or ($actions & 15) == 12) { } 0 0 0
elsif (($actions & 15) == 6 or ($actions & 15) == 13) { } 0 0 0
Condition0%0/3
($actions & 15) == 5 or ($actions & 15) == 12
l!l&&r!l&&!r
000
MC/DC0%0/2
($actions & 15) == 5 or ($actions & 15) == 12
($actions & 15) == 5 ($actions & 15) == 12
Truth table0%0/3
A or B
A= ($actions & 15) == 5B= ($actions & 15) == 12
ABresult
1X1
011
000
5169 || ($actions & MDEREF_ACTION_MASK) == MDEREF_HV_padhv_helem)
5170 {
5171 0 $derefs = 1;
5172 0 $text .= '$' . substr($self->padname(shift @items), 1);
5173 }
5174 ▶ elsif ( ($actions & MDEREF_ACTION_MASK) == MDEREF_AV_gvav_aelem
Condition0%0/3
($actions & 15) == 6 or ($actions & 15) == 13
l!l&&r!l&&!r
000
MC/DC0%0/2
($actions & 15) == 6 or ($actions & 15) == 13
($actions & 15) == 6 ($actions & 15) == 13
Truth table0%0/3
A or B
A= ($actions & 15) == 6B= ($actions & 15) == 13
ABresult
1X1
011
000
5175 || ($actions & MDEREF_ACTION_MASK) == MDEREF_HV_gvhv_helem)
5176 {
5177 0 $derefs = 1;
5178 0 $text .= $self->multideref_var_name(shift @items, $is_hash);
5179 }
5180 else {
5181 0 ▶ if ( ($actions & MDEREF_ACTION_MASK) ==
Branch: 3 branches
BranchTrueFalseTotal
if (($actions & 15) == 3 or ($actions & 15) == 10) { } 0 0 0
elsif (($actions & 15) == 2 or ($actions & 15) == 9) { } 0 0 0
elsif (($actions & 15) == 1 or ($actions & 15) == 8) { } 0 0 0
Condition0%0/3
($actions & 15) == 3 or ($actions & 15) == 10
l!l&&r!l&&!r
000
MC/DC0%0/2
($actions & 15) == 3 or ($actions & 15) == 10
($actions & 15) == 3 ($actions & 15) == 10
Truth table0%0/3
A or B
A= ($actions & 15) == 3B= ($actions & 15) == 10
ABresult
1X1
011
000
5182 MDEREF_AV_padsv_vivify_rv2av_aelem
5183 || ($actions & MDEREF_ACTION_MASK) ==
5184 MDEREF_HV_padsv_vivify_rv2hv_helem)
5185 {
5186 0 $text .= $self->padname(shift @items);
5187 }
5188 ▶ elsif ( ($actions & MDEREF_ACTION_MASK) ==
Condition0%0/3
($actions & 15) == 2 or ($actions & 15) == 9
l!l&&r!l&&!r
000
MC/DC0%0/2
($actions & 15) == 2 or ($actions & 15) == 9
($actions & 15) == 2 ($actions & 15) == 9
Truth table0%0/3
A or B
A= ($actions & 15) == 2B= ($actions & 15) == 9
ABresult
1X1
011
000
5189 MDEREF_AV_gvsv_vivify_rv2av_aelem
5190 || ($actions & MDEREF_ACTION_MASK) ==
5191 MDEREF_HV_gvsv_vivify_rv2hv_helem)
5192 {
5193 0 $text .= $self->multideref_var_name(shift @items, $is_hash);
5194 }
5195 ▶ elsif ( ($actions & MDEREF_ACTION_MASK) ==
Condition0%0/3
($actions & 15) == 1 or ($actions & 15) == 8
l!l&&r!l&&!r
000
MC/DC0%0/2
($actions & 15) == 1 or ($actions & 15) == 8
($actions & 15) == 1 ($actions & 15) == 8
Truth table0%0/3
A or B
A= ($actions & 15) == 1B= ($actions & 15) == 8
ABresult
1X1
011
000
5196 MDEREF_AV_pop_rv2av_aelem
5197 || ($actions & MDEREF_ACTION_MASK) ==
5198 MDEREF_HV_pop_rv2hv_helem)
5199 {
5200 0 ▶ if ( ($op->flags & OPf_KIDS)
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 4 and _op_is_or_was($op->first, 137) || _op_is_or_was($op->first, 152) and $op->first->flags & 4 and _op_is_or_was($op->first->first, 141) || _op_is_or_was($op->first->first, 153)) 0 0 0
Condition0%0/15
$op->flags & 4 and _op_is_or_was($op->first, 137) || _op_is_or_was($op->first, 152) and $op->first->flags & 4 and _op_is_or_was($op->first->first, 141) || _op_is_or_was($op->first->first, 153)
!ll&&!rl&&r
000
$op->flags & 4 and _op_is_or_was($op->first, 137) || _op_is_or_was($op->first, 152) and $op->first->flags & 4
!ll&&!rl&&r
000
$op->flags & 4 and _op_is_or_was($op->first, 137) || _op_is_or_was($op->first, 152)
!ll&&!rl&&r
000
_op_is_or_was($op->first, 137) or _op_is_or_was($op->first, 152)
l!l&&r!l&&!r
000
_op_is_or_was($op->first->first, 141) or _op_is_or_was($op->first->first, 153)
l!l&&r!l&&!r
000
MC/DC0%0/6
$op->flags & 4 and _op_is_or_was($op->first, 137) || _op_is_or_was($op->first, 152) and $op->first->flags & 4 and _op_is_or_was($op->first->first, 141) || _op_is_or_was($op->first->first, 153)
$op->flags & 4 _op_is_or_was($op->first, 137) _op_is_or_was($op->first, 152) $op->first->flags & 4 _op_is_or_was($op->first->first, 141) _op_is_or_was($op->first->first, 153)
Truth table0%0/10
A and B or C and D and E or F
A= $op->flags & 4B= _op_is_or_was($op->first, 137)C= _op_is_or_was($op->first, 152)D= $op->first->flags & 4E= _op_is_or_was($op->first->first, 141)F= _op_is_or_was($op->first->first, 153)
ABCDEFresult
0XXXXX0
100XXX0
11X0XX0
1010XX0
11X1000
1011000
11X11X1
11X1011
10111X1
1011011
5201 && ( _op_is_or_was($op->first, OP_RV2AV)
5202 || _op_is_or_was($op->first, OP_RV2HV))
5203 && ($op->first->flags & OPf_KIDS)
5204 && ( _op_is_or_was($op->first->first, OP_AELEM)
5205 || _op_is_or_was($op->first->first, OP_HELEM))
5206 )
5207 {
5208 0 $derefs++;
5209 }
5210 }
5211  
5212 0 ▶ $text .= '->' if !$derefs++;
Branch: 1 branch
BranchTrueFalseTotal
unless $derefs++ 0 0 0
5213 }
5214  
5215  
5216 0 ▶ if (($actions & MDEREF_INDEX_MASK) == MDEREF_INDEX_none) {
Branch: 1 branch
BranchTrueFalseTotal
if (($actions & 48) == 0) 0 0 0
5217 0 last;
5218 }
5219  
5220 0 ▶ $text .= $is_hash ? '{' : '[';
Branch: 1 branch
BranchTrueFalseTotal
$is_hash ? : 0 0 0
5221  
5222 0 ▶ if (($actions & MDEREF_INDEX_MASK) == MDEREF_INDEX_const) {
Branch: 3 branches
BranchTrueFalseTotal
if (($actions & 48) == 16) { } 0 0 0
elsif (($actions & 48) == 32) { } 0 0 0
elsif (($actions & 48) == 48) { } 0 0 0
5223 0 my $key = shift @items;
5224 0 ▶ if ($is_hash) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_hash) { } 0 0 0
5225 0 $text .= $self->const($key, $cx);
5226 }
5227 else {
5228 0 $text .= $key;
5229 }
5230 }
5231 elsif (($actions & MDEREF_INDEX_MASK) == MDEREF_INDEX_padsv) {
5232 0 $text .= $self->padname(shift @items);
5233 }
5234 elsif (($actions & MDEREF_INDEX_MASK) == MDEREF_INDEX_gvsv) {
5235 0 $text .= '$' . ($self->stash_variable_name('$', shift @items))[0];
5236 }
5237  
5238 0 ▶ $text .= $is_hash ? '}' : ']';
Branch: 1 branch
BranchTrueFalseTotal
$is_hash ? : 0 0 0
5239  
5240 0 ▶ if ($actions & MDEREF_FLAG_last) {
Branch: 1 branch
BranchTrueFalseTotal
if ($actions & 64) 0 0 0
5241 0 last;
5242 }
5243 0 $actions >>= MDEREF_SHIFT;
5244 }
5245  
5246 0 return $text;
5247 }
5248  
5249  
5250 0 ▶sub pp_aelem { maybe_local(@_, elem(@_, "[", "]", "padav")) }
Subroutine pp_aelem: not called CC=1 SCAR=6.9
Pod undocumented
5251 0 ▶sub pp_helem { maybe_local(@_, elem(@_, "{", "}", "padhv")) }
Subroutine pp_helem: not called CC=1 SCAR=6.9
Pod undocumented
5252  
5253 sub pp_gelem {
5254 0 ▶ my $self = shift;
Subroutine pp_gelem: not called CC=4 SCAR=30.0
Pod undocumented
5255 0 my($op, $cx) = @_;
5256 0 my($glob, $part) = ($op->first, $op->last);
5257 0 $glob = $glob->first; # skip rv2gv
5258 0 ▶ $glob = $glob->first if $glob->name eq "rv2gv"; # this one's a bug
Branch: 1 branch
BranchTrueFalseTotal
if $glob->name eq "rv2gv" 0 0 0
5259 0 my $scope = is_scope($glob);
5260 0 $glob = $self->deparse($glob, 0);
5261 0 $part = $self->deparse($part, 1);
5262 0 ▶ $glob =~ s/::\z// unless $scope;
Branch: 1 branch
BranchTrueFalseTotal
unless $scope 0 0 0
5263 0 ▶ return "*" . ($scope ? "{$glob}" : $glob) . "{$part}";
Branch: 1 branch
BranchTrueFalseTotal
$scope ? : 0 0 0
5264 }
5265  
5266 sub slice {
5267 0 ▶ my $self = shift;
Subroutine slice: not called CC=9 SCAR=45.0
Pod undocumented
5268 0 my ($op, $cx, $left, $right, $regname, $padname) = @_;
5269 0 my $last;
5270 0 my(@elems, $kid, $array, $list);
5271 0 ▶ if (class($op) eq "LISTOP") {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($op) eq 'LISTOP') { } 0 0 0
5272 0 $last = $op->last;
5273 } else { # ex-hslice inside delete()
5274 0 ▶ for ($kid = $op->first; !null $kid->sibling; $kid = $kid->sibling) {}
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid->sibling)) 0 0 0
5275 0 $last = $kid;
5276 }
5277 0 $array = $last;
5278 0 ▶ $array = $array->first
Branch: 1 branch
BranchTrueFalseTotal
if $array->name eq $regname or $array->name eq "null" 0 0 0
Condition0%0/3
$array->name eq $regname or $array->name eq "null"
l!l&&r!l&&!r
000
MC/DC0%0/2
$array->name eq $regname or $array->name eq "null"
$array->name eq $regname $array->name eq "null"
Truth table0%0/3
A or B
A= $array->name eq $regnameB= $array->name eq "null"
ABresult
1X1
011
000
5279 if $array->name eq $regname or $array->name eq "null";
5280 0 $array = $self->elem_or_slice_array_name($array,$left,$padname,0);
5281 0 $kid = $op->first->sibling; # skip pushmark
5282 0 ▶ if ($kid->name eq "list") {
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->name eq 'list') { } 0 0 0
5283 0 $kid = $kid->first->sibling; # skip list, pushmark
5284 0 ▶ for (; !null $kid; $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
5285 0 push @elems, $self->deparse($kid, 6);
5286 }
5287 0 $list = join(", ", @elems);
5288 } else {
5289 0 $list = $self->elem_or_slice_single_index($kid);
5290 }
5291 0 ▶ my $lead = ( _op_is_or_was($op, OP_KVHSLICE)
Branch: 1 branch
BranchTrueFalseTotal
_op_is_or_was($op, 155) || _op_is_or_was($op, 143) ? : 0 0 0
Condition0%0/3
_op_is_or_was($op, 155) or _op_is_or_was($op, 143)
l!l&&r!l&&!r
000
MC/DC0%0/2
_op_is_or_was($op, 155) or _op_is_or_was($op, 143)
_op_is_or_was($op, 155) _op_is_or_was($op, 143)
Truth table0%0/3
A or B
A= _op_is_or_was($op, 155)B= _op_is_or_was($op, 143)
ABresult
1X1
011
000
5292 || _op_is_or_was($op, OP_KVASLICE))
5293 ? '%' : '@';
5294 0 return $lead . $array . $left . $list . $right;
5295 }
5296  
5297 0 ▶sub pp_aslice { maybe_local(@_, slice(@_, "[", "]", "rv2av", "padav")) }
Subroutine pp_aslice: not called CC=1 SCAR=6.9
Pod undocumented
5298 0 ▶sub pp_kvaslice { slice(@_, "[", "]", "rv2av", "padav") }
Subroutine pp_kvaslice: not called CC=1 SCAR=6.9
Pod undocumented
5299 0 ▶sub pp_hslice { maybe_local(@_, slice(@_, "{", "}", "rv2hv", "padhv")) }
Subroutine pp_hslice: not called CC=1 SCAR=6.9
Pod undocumented
5300 0 ▶sub pp_kvhslice { slice(@_, "{", "}", "rv2hv", "padhv") }
Subroutine pp_kvhslice: not called CC=1 SCAR=6.9
Pod undocumented
5301  
5302 sub pp_lslice {
5303 0 ▶ my $self = shift;
Subroutine pp_lslice: not called CC=1 SCAR=6.9
Pod undocumented
5304 0 my($op, $cx) = @_;
5305 0 my $idx = $op->first;
5306 0 my $list = $op->last;
5307 0 my(@elems, $kid);
5308 0 $list = $self->deparse($list, 1);
5309 0 $idx = $self->deparse($idx, 1);
5310 0 return "($list)" . "[$idx]";
5311 }
5312  
5313 sub want_scalar {
5314 0 ▶ my $op = shift;
Subroutine want_scalar: not called CC=1 SCAR=6.9
Pod undocumented
5315 0 return ($op->flags & OPf_WANT) == OPf_WANT_SCALAR;
5316 }
5317  
5318 sub want_list {
5319 0 ▶ my $op = shift;
Subroutine want_list: not called CC=1 SCAR=6.9
Pod undocumented
5320 0 return ($op->flags & OPf_WANT) == OPf_WANT_LIST;
5321 }
5322  
5323 sub _method {
5324 0 ▶ my $self = shift;
Subroutine _method: not called CC=11 SCAR=48.8
5325 0 my($op, $cx) = @_;
5326 0 my $kid = $op->first->sibling; # skip pushmark
5327 0 my($meth, $obj, @exprs);
5328 0 ▶ if ($kid->name eq "list" and want_list $kid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->name eq 'list' and want_list($kid)) { } 0 0 0
Condition0%0/3
$kid->name eq "list" and want_list($kid)
!ll&&!rl&&r
000
MC/DC0%0/2
$kid->name eq "list" and want_list($kid)
$kid->name eq "list" want_list($kid)
Truth table0%0/3
A and B
A= $kid->name eq "list"B= want_list($kid)
ABresult
0X0
100
111
5329 # When an indirect object isn't a bareword but the args are in
5330 # parens, the parens aren't part of the method syntax (the LLAFR
5331 # doesn't apply), but they make a list with OPf_PARENS set that
5332 # doesn't get flattened by the append_elem that adds the method,
5333 # making a (object, arg1, arg2, ...) list where the object
5334 # usually is. This can be distinguished from
5335 # '($obj, $arg1, $arg2)->meth()' (which is legal if $arg2 is an
5336 # object) because in the later the list is in scalar context
5337 # as the left side of -> always is, while in the former
5338 # the list is in list context as method arguments always are.
5339 # (Good thing there aren't method prototypes!)
5340 0 $meth = $kid->sibling;
5341 0 $kid = $kid->first->sibling; # skip pushmark
5342 0 $obj = $kid;
5343 0 $kid = $kid->sibling;
5344 0 ▶ for (; not null $kid; $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
5345 0 push @exprs, $kid;
5346 }
5347 } else {
5348 0 $obj = $kid;
5349 0 $kid = $kid->sibling;
5350 0 ▶ for (; !null ($kid->sibling) && $kid->name!~/^method(?:_named)?\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid->sibling) or $kid->name =~ /^method(?:_named)?\z/) 0 0 0
Condition0%0/3
null($kid->sibling) or $kid->name =~ /^method(?:_named)?\z/
l!l&&r!l&&!r
000
MC/DC0%0/2
null($kid->sibling) or $kid->name =~ /^method(?:_named)?\z/
null($kid->sibling) $kid->name =~ /^method(?:_named)?\z/
Truth table0%0/3
A or B
A= null($kid->sibling)B= $kid->name =~ /^method(?:_named)?\z/
ABresult
1X1
011
000
5351 $kid = $kid->sibling) {
5352 0 push @exprs, $kid
5353 }
5354 0 $meth = $kid;
5355 }
5356  
5357 0 ▶ if ($meth->name eq "method_named") {
Branch: 4 branches
BranchTrueFalseTotal
if ($meth->name eq 'method_named') { } 0 0 0
elsif ($meth->name eq 'method_super') { } 0 0 0
elsif ($meth->name eq 'method_redir') { } 0 0 0
elsif ($meth->name eq 'method_redir_super') { } 0 0 0
5358 0 $meth = $self->meth_sv($meth)->PV;
5359 } elsif ($meth->name eq "method_super") {
5360 0 $meth = "SUPER::".$self->meth_sv($meth)->PV;
5361 } elsif ($meth->name eq "method_redir") {
5362 0 $meth = $self->meth_rclass_sv($meth)->PV.'::'.$self->meth_sv($meth)->PV;
5363 } elsif ($meth->name eq "method_redir_super") {
5364 0 $meth = $self->meth_rclass_sv($meth)->PV.'::SUPER::'.
5365 $self->meth_sv($meth)->PV;
5366 } else {
5367 0 $meth = $meth->first;
5368 0 ▶ if ($meth->name eq "const") {
Branch: 1 branch
BranchTrueFalseTotal
if ($meth->name eq "const") 0 0 0
5369 # As of 5.005_58, this case is probably obsoleted by the
5370 # method_named case above
5371 0 $meth = $self->const_sv($meth)->PV; # needs to be bare
5372 }
5373 }
5374  
5375 0 return { method => $meth, variable_method => ref($meth),
5376 object => $obj, args => \@exprs },
5377 $cx;
5378 }
5379  
5380 # compat function only
5381 sub method {
5382 0 ▶ my $self = shift;
Subroutine method: not called CC=1 SCAR=6.9
Pod undocumented
5383 0 my $info = $self->_method(@_);
5384 0 return $self->e_method( $self->_method(@_) );
5385 }
5386  
5387 sub e_method {
5388 0 ▶ my ($self, $info, $cx) = @_;
Subroutine e_method: not called CC=5 SCAR=34.0
Pod undocumented
5389 0 my $obj = $self->deparse($info->{object}, 24);
5390  
5391 0 my $meth = $info->{method};
5392 0 ▶ $meth = $self->deparse($meth, 1) if $info->{variable_method};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"variable_method"} 0 0 0
5393 0 my $args = join(", ", map { $self->deparse($_, 6) } @{$info->{args}} );
5394 0 ▶ if ($info->{object}->name eq 'scope' && want_list $info->{object}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info->{"object"}->name eq "scope" and want_list($info->{"object"})) 0 0 0
Condition0%0/3
$info->{"object"}->name eq "scope" and want_list($info->{"object"})
!ll&&!rl&&r
000
MC/DC0%0/2
$info->{"object"}->name eq "scope" and want_list($info->{"object"})
$info->{"object"}->name eq "scope" want_list($info->{"object"})
Truth table0%0/3
A and B
A= $info->{"object"}->name eq "scope"B= want_list($info->{"object"})
ABresult
0X0
100
111
5395 # method { $object }
5396 # This must be deparsed this way to preserve list context
5397 # of $object.
5398 0 my $need_paren = $cx >= 6;
5399 0 return '(' x $need_paren
5400 . $meth . substr($obj,2) # chop off the "do"
5401 . " $args"
5402 . ')' x $need_paren;
5403 }
5404 0 my $kid = $obj . "->" . $meth;
5405 0 ▶ if (length $args) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $args) { } 0 0 0
5406 0 return $kid . "(" . $args . ")"; # parens mandatory
5407 } else {
5408 0 return $kid;
5409 }
5410 }
5411  
5412 # returns "&" if the prototype doesn't match the args,
5413 # or ("", $args_after_prototype_demunging) if it does.
5414 sub check_proto {
5415 0 ▶ my $self = shift;
Subroutine check_proto: not called CC=38 SCAR=73.0
Pod undocumented
5416 0 ▶ return "&" if $self->{'noproto'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"noproto"} 0 0 0
5417 0 my ($proto, @args) = @_;
5418 0 my $doneok = 0;
5419 0 my @reals;
5420 0 $proto =~ s/^\s+//;
5421 0 ▶ while (length $proto) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $proto) 0 0 0
5422 0 ▶ $proto =~ s/^(\\?[\$\@&%*]|\\\[[\$\@&%*]+\]|[_+;])\s*//
Branch: 1 branch
BranchTrueFalseTotal
$proto =~ s/^(\\?[\$\@&%*]|\\\[[\$\@&%*]+\]|[_+;])\s*// or return "&" 0 0 0
5423 or return "&"; # malformed prototype
5424 0 my $chr = $1;
5425 0 ▶ if ($chr eq ";") {
Branch: 3 branches
BranchTrueFalseTotal
if ($chr eq ';') { } 0 0 0
elsif ($chr eq '@' or $chr eq '%') { } 0 0 0
elsif (not @args) { } 0 0 0
5426 0 $doneok = 1;
5427 ▶ } elsif ($chr eq '@' or $chr eq '%') {
Condition0%0/3
$chr eq "\@" or $chr eq "%"
l!l&&r!l&&!r
000
MC/DC0%0/2
$chr eq "\@" or $chr eq "%"
$chr eq "\@" $chr eq "%"
Truth table0%0/3
A or B
A= $chr eq "\@"B= $chr eq "%"
ABresult
1X1
011
000
5428 # An unbackslashed @ or % gobbles up the rest of the args
5429 0 push @reals, map($self->deparse($_, 6), @args);
5430 0 @args = ();
5431 0 $proto = '';
5432 } elsif (!@args) {
5433 0 ▶ last if $doneok;
Branch: 1 branch
BranchTrueFalseTotal
if $doneok 0 0 0
5434 0 return "&"; # too few args and no ';'
5435 } else {
5436 0 my $arg = shift @args;
5437 0 ▶ if ($chr eq '$' || $chr eq '_') {
Branch: 5 branches
BranchTrueFalseTotal
if ($chr eq '$' or $chr eq '_') { } 0 0 0
elsif ($chr eq '&') { } 0 0 0
elsif ($chr eq '*') { } 0 0 0
elsif ($chr eq '+') { } 0 0 0
elsif (substr($chr, 0, 1) eq '\\') { } 0 0 0
Condition0%0/3
$chr eq "\$" or $chr eq "_"
l!l&&r!l&&!r
000
MC/DC0%0/2
$chr eq "\$" or $chr eq "_"
$chr eq "\$" $chr eq "_"
Truth table0%0/3
A or B
A= $chr eq "\$"B= $chr eq "_"
ABresult
1X1
011
000
5438 0 ▶ if (want_scalar $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (want_scalar($arg)) { } 0 0 0
5439 0 push @reals, $self->deparse($arg, 6);
5440 } else {
5441 0 return "&";
5442 }
5443 } elsif ($chr eq "&") {
5444 0 ▶ if ($arg->name =~ /^(?:s?refgen|undef)\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->name =~ /^(?:s?refgen|undef)\z/) { } 0 0 0
5445 0 push @reals, $self->deparse($arg, 6);
5446 } else {
5447 0 return "&";
5448 }
5449 } elsif ($chr eq "*") {
5450 0 ▶ if ($arg->name =~ /^s?refgen\z/
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->name =~ /^s?refgen\z/ and $arg->first->first->name eq 'rv2gv') { } 0 0 0
Condition0%0/3
$arg->name =~ /^s?refgen\z/ and $arg->first->first->name eq "rv2gv"
!ll&&!rl&&r
000
MC/DC0%0/2
$arg->name =~ /^s?refgen\z/ and $arg->first->first->name eq "rv2gv"
$arg->name =~ /^s?refgen\z/ $arg->first->first->name eq "rv2gv"
Truth table0%0/3
A and B
A= $arg->name =~ /^s?refgen\z/B= $arg->first->first->name eq "rv2gv"
ABresult
0X0
100
111
5451 and $arg->first->first->name eq "rv2gv")
5452 {
5453 0 my $real = $arg->first->first; # skip refgen, null
5454 0 ▶ if ($real->first->name eq "gv") {
Branch: 1 branch
BranchTrueFalseTotal
if ($real->first->name eq 'gv') { } 0 0 0
5455 0 push @reals, $self->deparse($real, 6);
5456 } else {
5457 0 push @reals, $self->deparse($real->first, 6);
5458 }
5459 } else {
5460 0 return "&";
5461 }
5462 } elsif ($chr eq "+") {
5463 0 my $real;
5464 0 ▶ if ($arg->name =~ /^s?refgen\z/ and
Branch: 2 branches
BranchTrueFalseTotal
if ($arg->name =~ /^s?refgen\z/ and not null($real = $arg->first) and not null($real->first) and $real->first->name =~ /^(?:rv2|pad)[ah]v\z/) { } 0 0 0
elsif (want_scalar($arg)) { } 0 0 0
Condition0%0/9
$arg->name =~ /^s?refgen\z/ and not null($real = $arg->first) and not null($real->first) and $real->first->name =~ /^(?:rv2|pad)[ah]v\z/
!ll&&!rl&&r
000
$arg->name =~ /^s?refgen\z/ and not null($real = $arg->first) and not null($real->first)
!ll&&!rl&&r
000
$arg->name =~ /^s?refgen\z/ and not null($real = $arg->first)
!ll&&!rl&&r
000
MC/DC0%0/4
$arg->name =~ /^s?refgen\z/ and not null($real = $arg->first) and not null($real->first) and $real->first->name =~ /^(?:rv2|pad)[ah]v\z/
$arg->name =~ /^s?refgen\z/ not null($real = $arg->first) not null($real->first) $real->first->name =~ /^(?:rv2|pad)[ah]v\z/
Truth table0%0/5
A and not(B) and not(C) and D
A= $arg->name =~ /^s?refgen\z/B= not null($real = $arg->first)C= not null($real->first)D= $real->first->name =~ /^(?:rv2|pad)[ah]v\z/
ABCDresult
0XXX0
10XX0
110X0
11100
11111
5465 !null($real = $arg->first) and
5466 !null($real->first) and
5467 $real->first->name =~ /^(?:rv2|pad)[ah]v\z/)
5468 {
5469 0 push @reals, $self->deparse($real, 6);
5470 } elsif (want_scalar $arg) {
5471 0 push @reals, $self->deparse($arg, 6);
5472 } else {
5473 0 return "&";
5474 }
5475 } elsif (substr($chr, 0, 1) eq "\\") {
5476 0 $chr =~ tr/\\[]//d;
5477 0 my $real;
5478 0 ▶ if ($arg->name =~ /^s?refgen\z/ and
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->name =~ /^s?refgen\z/ and not null($real = $arg->first) and $chr =~ /\$/ && is_scalar($real->first) || $chr =~ /@/ && !null($real->first) && $real->first->name =~ /^(?:rv2|pad)av\z/ || $chr =~ /%/ && !null($real->first) && $real->first->name =~ /^(?:rv2|pad)hv\z/ || $chr =~ /\*/ && $real->first->name eq 'rv2gv') { } 0 0 0
Condition0%0/33
$arg->name =~ /^s?refgen\z/ and not null($real = $arg->first) and $chr =~ /\$/ && is_scalar($real->first) || $chr =~ /@/ && !null($real->first) && $real->first->name =~ /^(?:rv2|pad)av\z/ || $chr =~ /%/ && !null($real->first) && $real->first->name =~ /^(?:rv2|pad)hv\z/ || $chr =~ /\*/ && $real->first->name eq "rv2gv"
!ll&&!rl&&r
000
$arg->name =~ /^s?refgen\z/ and not null($real = $arg->first)
!ll&&!rl&&r
000
$chr =~ /\$/ and is_scalar($real->first) or $chr =~ /@/ and not null($real->first) and $real->first->name =~ /^(?:rv2|pad)av\z/ or $chr =~ /%/ and not null($real->first) and $real->first->name =~ /^(?:rv2|pad)hv\z/ or $chr =~ /\*/ and $real->first->name eq "rv2gv"
l!l&&r!l&&!r
000
$chr =~ /\$/ and is_scalar($real->first) or $chr =~ /@/ and not null($real->first) and $real->first->name =~ /^(?:rv2|pad)av\z/ or $chr =~ /%/ and not null($real->first) and $real->first->name =~ /^(?:rv2|pad)hv\z/
l!l&&r!l&&!r
000
$chr =~ /\$/ and is_scalar($real->first) or $chr =~ /@/ and not null($real->first) and $real->first->name =~ /^(?:rv2|pad)av\z/
l!l&&r!l&&!r
000
$chr =~ /\$/ and is_scalar($real->first)
!ll&&!rl&&r
000
$chr =~ /@/ and not null($real->first) and $real->first->name =~ /^(?:rv2|pad)av\z/
!ll&&!rl&&r
000
$chr =~ /@/ and not null($real->first)
!ll&&!rl&&r
000
$chr =~ /%/ and not null($real->first) and $real->first->name =~ /^(?:rv2|pad)hv\z/
!ll&&!rl&&r
000
$chr =~ /%/ and not null($real->first)
!ll&&!rl&&r
000
$chr =~ /\*/ and $real->first->name eq "rv2gv"
!ll&&!rl&&r
000
MC/DC0%0/12
$arg->name =~ /^s?refgen\z/ and not null($real = $arg->first) and $chr =~ /\$/ && is_scalar($real->first) || $chr =~ /@/ && !null($real->first) && $real->first->name =~ /^(?:rv2|pad)av\z/ || $chr =~ /%/ && !null($real->first) && $real->first->name =~ /^(?:rv2|pad)hv\z/ || $chr =~ /\*/ && $real->first->name eq "rv2gv"
$arg->name =~ /^s?refgen\z/ not null($real = $arg->first) $chr =~ /\$/ is_scalar($real->first) $chr =~ /@/ not null($real->first) $real->first->name =~ /^(?:rv2|pad)av\z/ $chr =~ /%/ not null($real->first) $real->first->name =~ /^(?:rv2|pad)hv\z/ $chr =~ /\*/ $real->first->name eq "rv2gv"
Truth table0%0/65
A and not(B) and C and D or E and not(F) and G or H and not(I) and J or K and L
A= $arg->name =~ /^s?refgen\z/B= not null($real = $arg->first)C= $chr =~ /\$/D= is_scalar($real->first)E= $chr =~ /@/F= not null($real->first)G= $real->first->name =~ /^(?:rv2|pad)av\z/H= $chr =~ /%/I= not null($real->first)J= $real->first->name =~ /^(?:rv2|pad)hv\z/K= $chr =~ /\*/L= $real->first->name eq "rv2gv"
ABCDEFGHIJKLresult
0XXXXXXXXXXX0
10XXXXXXXXXX0
110X0XX0XX0X0
110X0XX0XX100
110X0XX10X0X0
110X0XX10X100
110X0XX1100X0
110X0XX110100
110X10X0XX0X0
110X10X0XX100
110X10X10X0X0
110X10X10X100
110X10X1100X0
110X10X110100
110X1100XX0X0
110X1100XX100
110X11010X0X0
110X11010X100
110X1101100X0
110X110110100
11100XX0XX0X0
11100XX0XX100
11100XX10X0X0
11100XX10X100
11100XX1100X0
11100XX110100
111010X0XX0X0
111010X0XX100
111010X10X0X0
111010X10X100
111010X1100X0
111010X110100
11101100XX0X0
11101100XX100
111011010X0X0
111011010X100
11101101100X0
1110110110100
1111XXXXXXXX1
110X111XXXXX1
1110111XXXXX1
110X0XX111XX1
110X10X111XX1
110X110111XX1
11100XX111XX1
111010X111XX1
1110110111XX1
110X0XX0XX111
110X0XX10X111
110X0XX110111
110X10X0XX111
110X10X10X111
110X10X110111
110X1100XX111
110X11010X111
110X110110111
11100XX0XX111
11100XX10X111
11100XX110111
111010X0XX111
111010X10X111
111010X110111
11101100XX111
111011010X111
1110110110111
5479 !null($real = $arg->first) and
5480 ($chr =~ /\$/ && is_scalar($real->first)
5481 or ($chr =~ /@/
5482 && !null($real->first)
5483 && $real->first->name =~ /^(?:rv2|pad)av\z/)
5484 or ($chr =~ /%/
5485 && !null($real->first)
5486 && $real->first->name =~ /^(?:rv2|pad)hv\z/)
5487 #or ($chr =~ /&/ # This doesn't work
5488 # && $real->first->name eq "rv2cv")
5489 or ($chr =~ /\*/
5490 && $real->first->name eq "rv2gv")))
5491 {
5492 0 push @reals, $self->deparse($real, 6);
5493 } else {
5494 0 return "&";
5495 }
5496 } else {
5497 # should not happen
5498 0 return "&";
5499 }
5500 }
5501 }
5502 0 ▶ return "&" if @args; # too many args
Branch: 1 branch
BranchTrueFalseTotal
if @args 0 0 0
5503 0 return ("", join ", ", @reals);
5504 }
5505  
5506 sub retscalar {
5507 0 ▶ my $name = $_[0]->name;
Subroutine retscalar: not called CC=2 SCAR=17.9
Pod undocumented
5508 # XXX There has to be a better way of doing this scalar-op check.
5509 # Currently PL_opargs is not exposed.
5510 0 ▶ if ($name eq 'null') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "null") 0 0 0
5511 0 $name = substr B::ppname($_[0]->targ), 3
5512 }
5513 0 $name =~ /^(?:scalar|pushmark|wantarray|const|gvsv|gv|padsv|rv2gv
5514 |rv2sv|av2arylen|anoncode|prototype|srefgen|ref|bless
5515 |regcmaybe|regcreset|regcomp|qr|subst|substcont|trans
5516 |transr|sassign|chop|schop|chomp|schomp|defined|undef
5517 |study|pos|preinc|i_preinc|predec|i_predec|postinc
5518 |i_postinc|postdec|i_postdec|pow|multiply|i_multiply
5519 |divide|i_divide|modulo|i_modulo|add|i_add|subtract
5520 |i_subtract|concat|multiconcat|stringify|left_shift|right_shift|lt
5521 |i_lt|gt|i_gt|le|i_le|ge|i_ge|eq|i_eq|ne|i_ne|ncmp|i_ncmp
5522 |slt|sgt|sle|sge|seq|sne|scmp|[sn]?bit_(?:and|x?or)|negate
5523 |i_negate|not|[sn]?complement|smartmatch|atan2|sin|cos
5524 |rand|srand|exp|log|sqrt|int|hex|oct|abs|length|substr
5525 |vec|index|rindex|sprintf|formline|ord|chr|crypt|ucfirst
5526 |lcfirst|uc|lc|quotemeta|aelemfast|aelem|exists|helem
5527 |pack|join|anonlist|anonhash|push|pop|shift|unshift|xor
5528 |andassign|orassign|dorassign|warn|die|reset|nextstate
5529 |dbstate|unstack|last|next|redo|dump|goto|exit|open|close
5530 |pipe_op|fileno|umask|binmode|tie|untie|tied|dbmopen
5531 |dbmclose|select|getc|read|enterwrite|prtf|print|say
5532 |sysopen|sysseek|sysread|syswrite|eof|tell|seek|truncate
5533 |fcntl|ioctl|flock|send|recv|socket|sockpair|bind|connect
5534 |listen|accept|shutdown|gsockopt|ssockopt|getsockname
5535 |getpeername|ftrread|ftrwrite|ftrexec|fteread|ftewrite
5536 |fteexec|ftis|ftsize|ftmtime|ftatime|ftctime|ftrowned
5537 |fteowned|ftzero|ftsock|ftchr|ftblk|ftfile|ftdir|ftpipe
5538 |ftsuid|ftsgid|ftsvtx|ftlink|fttty|fttext|ftbinary|chdir
5539 |chown|chroot|unlink|chmod|utime|rename|link|symlink
5540 |readlink|mkdir|rmdir|open_dir|telldir|seekdir|rewinddir
5541 |closedir|fork|wait|waitpid|system|exec|kill|getppid
5542 |getpgrp|setpgrp|getpriority|setpriority|time|alarm|sleep
5543 |shmget|shmctl|shmread|shmwrite|msgget|msgctl|msgsnd
5544 |msgrcv|semop|semget|semctl|hintseval|shostent|snetent
5545 |sprotoent|sservent|ehostent|enetent|eprotoent|eservent
5546 |spwent|epwent|sgrent|egrent|getlogin|syscall|lock|runcv
5547 |fc|padsv_store)\z/x
5548 }
5549  
5550 sub pp_entersub {
5551 0 ▶ my $self = shift;
Subroutine pp_entersub: not called CC=55 SCAR=80.3
Pod undocumented
5552 0 my($op, $cx) = @_;
5553 0 ▶ return $self->e_method($self->_method($op, $cx))
Branch: 1 branch
BranchTrueFalseTotal
unless null($op->first->sibling) 0 0 0
5554 unless null $op->first->sibling;
5555 0 my $prefix = "";
5556 0 my $amper = "";
5557 0 my($kid, @exprs);
5558 0 ▶ if ($op->private & OPpENTERSUB_AMPER) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 8) 0 0 0
5559 0 $amper = "&";
5560 }
5561 0 $kid = $op->first;
5562 0 $kid = $kid->first->sibling; # skip ex-list, pushmark
5563 0 ▶ for (; not null $kid->sibling; $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid->sibling)) 0 0 0
5564 0 push @exprs, $kid;
5565 }
5566 0 my $simple = 0;
5567 0 my $proto = undef;
5568 0 my $lexical;
5569 0 ▶ if (is_scope($kid)) {
Branch: 3 branches
BranchTrueFalseTotal
if (is_scope($kid)) { } 0 0 0
elsif ($kid->first->name eq 'gv') { } 0 0 0
elsif (is_scalar($kid->first) and $kid->first->name ne 'rv2cv') { } 0 0 0
5570 0 $amper = "&";
5571 0 $kid = "{" . $self->deparse($kid, 0) . "}";
5572 } elsif ($kid->first->name eq "gv") {
5573 0 my $gv = $self->gv_or_padgv($kid->first);
5574 0 my $cv;
5575 0 ▶ if (class($gv) eq 'GV' && class($cv = $gv->CV) ne "SPECIAL"
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($gv) eq "GV" and B::Deparse::class($cv = $gv->CV) ne "SPECIAL" or $gv->FLAGS & 2048 and B::Deparse::class($cv = $gv->RV) eq "CV") 0 0 0
Condition0%0/9
B::Deparse::class($gv) eq "GV" and B::Deparse::class($cv = $gv->CV) ne "SPECIAL" or $gv->FLAGS & 2048 and B::Deparse::class($cv = $gv->RV) eq "CV"
l!l&&r!l&&!r
000
B::Deparse::class($gv) eq "GV" and B::Deparse::class($cv = $gv->CV) ne "SPECIAL"
!ll&&!rl&&r
000
$gv->FLAGS & 2048 and B::Deparse::class($cv = $gv->RV) eq "CV"
!ll&&!rl&&r
000
MC/DC0%0/4
B::Deparse::class($gv) eq "GV" and B::Deparse::class($cv = $gv->CV) ne "SPECIAL" or $gv->FLAGS & 2048 and B::Deparse::class($cv = $gv->RV) eq "CV"
B::Deparse::class($gv) eq "GV" B::Deparse::class($cv = $gv->CV) ne "SPECIAL" $gv->FLAGS & 2048 B::Deparse::class($cv = $gv->RV) eq "CV"
Truth table0%0/7
A and B or C and D
A= B::Deparse::class($gv) eq "GV"B= B::Deparse::class($cv = $gv->CV) ne "SPECIAL"C= $gv->FLAGS & 2048D= B::Deparse::class($cv = $gv->RV) eq "CV"
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
5576 || $gv->FLAGS & SVf_ROK && class($cv = $gv->RV) eq 'CV') {
5577 0 ▶ $proto = $cv->PV if $cv->FLAGS & SVf_POK;
Branch: 1 branch
BranchTrueFalseTotal
if $cv->FLAGS & 1024 0 0 0
5578 }
5579 0 $simple = 1; # only calls of named functions can be prototyped
5580 0 $kid = $self->maybe_qualify("!", $self->gv_name($gv));
5581 0 my $fq;
5582 # Fully qualify any sub name that conflicts with a lexical.
5583 0 ▶ if ($self->lex_in_scope("&$kid")
Branch: 2 branches
BranchTrueFalseTotal
if ($self->lex_in_scope("&$kid") or $self->lex_in_scope("&$kid", 1)) { } 0 0 0
elsif (not $amper) { } 0 0 0
Condition0%0/3
$self->lex_in_scope("&$kid") or $self->lex_in_scope("&$kid", 1)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->lex_in_scope("&$kid") or $self->lex_in_scope("&$kid", 1)
$self->lex_in_scope("&$kid") $self->lex_in_scope("&$kid", 1)
Truth table0%0/3
A or B
A= $self->lex_in_scope("&$kid")B= $self->lex_in_scope("&$kid", 1)
ABresult
1X1
011
000
5584 || $self->lex_in_scope("&$kid", 1))
5585 {
5586 0 $fq++;
5587 } elsif (!$amper) {
5588 0 ▶ if ($kid eq 'main::') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kid eq 'main::') { } 0 0 0
5589 0 $kid = '::';
5590 }
5591 else {
5592 0 ▶ if ($kid !~ /::/ && $kid ne 'x') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $kid =~ /::/ and $kid ne "x") 0 0 0
Condition0%0/3
not $kid =~ /::/ and $kid ne "x"
!ll&&!rl&&r
000
MC/DC0%0/2
not $kid =~ /::/ and $kid ne "x"
not $kid =~ /::/ $kid ne "x"
Truth table0%0/3
not(A) and B
A= not $kid =~ /::/B= $kid ne "x"
ABresult
0X0
100
111
5593 # Fully qualify any sub name that is also a keyword. While
5594 # we could check the import flag, we cannot guarantee that
5595 # the code deparsed so far would set that flag, so we qual-
5596 # ify the names regardless of importation.
5597 0 ▶ if (exists $feature_keywords{$kid}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $feature_keywords{$kid}) { } 0 0 0
elsif (do { local $@; local $SIG{'__DIE__'}; eval { do { () = prototype "CORE::$kid"; 1 } } }) { } 0 0 0
5598 0 ▶ $fq++ if $self->feature_enabled($kid);
Branch: 1 branch
BranchTrueFalseTotal
if $self->feature_enabled($kid) 0 0 0
5599 0 } elsif (do { local $@; local $SIG{__DIE__};
5600 0 eval { () = prototype "CORE::$kid"; 1 } }) {
5601 0 $fq++
5602 }
5603 }
5604 0 ▶ if ($kid !~ /^(?:\w|::)(?:[\w\d]|::(?!\z))*\z/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($kid =~ /^(?:\w|::)(?:[\w\d]|::(?!\z))*\z/) 0 0 0
5605 0 $kid = single_delim("q", "'", $kid, $self) . '->';
5606 }
5607 }
5608 }
5609 0 ▶ $fq and substr $kid, 0, 0, = $self->{'curstash'}.'::';
Branch: 1 branch
BranchTrueFalseTotal
$fq and substr($kid, 0, 0) = $self->{"curstash"} . '::' 0 0 0
5610 ▶ } elsif (is_scalar ($kid->first) && $kid->first->name ne 'rv2cv') {
Condition0%0/3
is_scalar($kid->first) and $kid->first->name ne "rv2cv"
!ll&&!rl&&r
000
MC/DC0%0/2
is_scalar($kid->first) and $kid->first->name ne "rv2cv"
is_scalar($kid->first) $kid->first->name ne "rv2cv"
Truth table0%0/3
A and B
A= is_scalar($kid->first)B= $kid->first->name ne "rv2cv"
ABresult
0X0
100
111
5611 0 $amper = "&";
5612 0 $kid = $self->deparse($kid, 24);
5613 } else {
5614 0 $prefix = "";
5615 0 my $grandkid = $kid->first;
5616 0 ▶ my $arrow = ($lexical = $grandkid->name eq "padcv")
Branch: 1 branch
BranchTrueFalseTotal
($lexical = $grandkid->name eq 'padcv') || is_subscriptable($grandkid) ? : 0 0 0
Condition0%0/3
$lexical = $grandkid->name eq "padcv" or is_subscriptable($grandkid)
l!l&&r!l&&!r
000
MC/DC0%0/2
$lexical = $grandkid->name eq "padcv" or is_subscriptable($grandkid)
$lexical = $grandkid->name eq "padcv" is_subscriptable($grandkid)
Truth table0%0/3
A or B
A= $lexical = $grandkid->name eq "padcv"B= is_subscriptable($grandkid)
ABresult
1X1
011
000
5617 || is_subscriptable($grandkid)
5618 ? ""
5619 : "->";
5620 0 $kid = $self->deparse($kid, 24) . $arrow;
5621 0 ▶ if ($lexical) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lexical) 0 0 0
5622 0 my $padlist = $self->{'curcv'}->PADLIST;
5623 0 my $padoff = $grandkid->targ;
5624 0 my $padname = $padlist->ARRAYelt(0)->ARRAYelt($padoff);
5625 0 ▶ my $protocv = $padname->FLAGS & SVpad_STATE
Branch: 1 branch
BranchTrueFalseTotal
$padname->FLAGS & 2 ? : 0 0 0
5626 ? $padlist->ARRAYelt(1)->ARRAYelt($padoff)
5627 : $padname->PROTOCV;
5628 0 ▶ if ($protocv->FLAGS & SVf_POK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($protocv->FLAGS & 1024) 0 0 0
5629 0 $proto = $protocv->PV
5630 }
5631 0 $simple = 1;
5632 }
5633 }
5634  
5635 # Doesn't matter how many prototypes there are, if
5636 # they haven't happened yet!
5637 0 ▶ my $declared = $lexical || exists $self->{'subs_declared'}{$kid};
Condition0%0/3
$lexical || exists $self->{'subs_declared'}{$kid}
l!l&&r!l&&!r
000
MC/DC0%0/2
$lexical || exists $self->{'subs_declared'}{$kid}
$lexical exists $self->{'subs_declared'}{$kid}
Truth table0%0/3
A || B
A= $lexicalB= exists $self->{'subs_declared'}{$kid}
ABresult
1X1
011
000
5638 0 ▶ if (not $declared and $self->{'in_coderef2text'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $declared and $self->{"in_coderef2text"}) 0 0 0
Condition0%0/3
not $declared and $self->{"in_coderef2text"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $declared and $self->{"in_coderef2text"}
not $declared $self->{"in_coderef2text"}
Truth table0%0/3
not(A) and B
A= not $declaredB= $self->{"in_coderef2text"}
ABresult
0X0
100
111
5639 no strict 'refs';
5640 no warnings 'uninitialized';
5641 $declared =
5642 (
5643 0 defined &{ ${$self->{'curstash'}."::"}{$kid} }
5644 && !exists
5645 $self->{'subs_deparsed'}{$self->{'curstash'}."::".$kid}
5646 0 ▶ && defined prototype $self->{'curstash'}."::".$kid
Condition0%0/6
defined &{do { $self->{'curstash'} . '::' }->{$kid};} && !exists($self->{'subs_deparsed'}{$self->{'curstash'} . '::' . $kid}) && defined prototype $self->{'curstash'} . '::' . $kid
!ll&&!rl&&r
000
defined &{do { $self->{"curstash"} . '::' }->{$kid};} and not exists $self->{"subs_deparsed"}{$self->{"curstash"} . '::' . $kid}
!ll&&!rl&&r
000
MC/DC0%0/3
defined &{do { $self->{'curstash'} . '::' }->{$kid};} && !exists($self->{'subs_deparsed'}{$self->{'curstash'} . '::' . $kid}) && defined prototype $self->{'curstash'} . '::' . $kid
defined &{do { $self->{"curstash"} . '::' }->{$kid};} not exists $self->{"subs_deparsed"}{$self->{"curstash"} . '::' . $kid} defined prototype $self->{'curstash'} . '::' . $kid
Truth table0%0/4
A and not(B) && C
A= defined &{do { $self->{"curstash"} . '::' }->{$kid};}B= not exists $self->{"subs_deparsed"}{$self->{"curstash"} . '::' . $kid}C= defined prototype $self->{'curstash'} . '::' . $kid
ABCresult
0XX0
10X0
1100
1111
5647 );
5648 }
5649 0 ▶ if (!$declared && defined($proto)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $declared and defined $proto) 0 0 0
Condition0%0/3
not $declared and defined $proto
!ll&&!rl&&r
000
MC/DC0%0/2
not $declared and defined $proto
not $declared defined $proto
Truth table0%0/3
not(A) and B
A= not $declaredB= defined $proto
ABresult
0X0
100
111
5650 # Avoid "too early to check prototype" warning
5651 0 ($amper, $proto) = ('&');
5652 }
5653  
5654 0 my $args;
5655 0 my $listargs = 1;
5656 0 ▶ if ($declared and defined $proto and not $amper) {
Branch: 1 branch
BranchTrueFalseTotal
if ($declared and defined $proto and not $amper) 0 0 0
Condition0%0/6
$declared and defined $proto and not $amper
!ll&&!rl&&r
000
$declared and defined $proto
!ll&&!rl&&r
000
MC/DC0%0/3
$declared and defined $proto and not $amper
$declared defined $proto not $amper
Truth table0%0/4
A and B and not(C)
A= $declaredB= defined $protoC= not $amper
ABCresult
0XX0
10X0
1100
1111
5657 0 ($amper, $args) = $self->check_proto($proto, @exprs);
5658 0 $listargs = $amper;
5659 }
5660 0 ▶ if ($listargs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($listargs) 0 0 0
5661 0 ▶ $args = join(", ", map(
Branch: 1 branch
BranchTrueFalseTotal
($_->flags & 3) == 2 && !retscalar($_) ? : 0 0 0
Condition0%0/3
($_->flags & 3) == 2 and not retscalar($_)
!ll&&!rl&&r
000
MC/DC0%0/2
($_->flags & 3) == 2 and not retscalar($_)
($_->flags & 3) == 2 not retscalar($_)
Truth table0%0/3
A and not(B)
A= ($_->flags & 3) == 2B= not retscalar($_)
ABresult
0X0
100
111
5662 ($_->flags & OPf_WANT) == OPf_WANT_SCALAR
5663 && !retscalar($_)
5664 ? $self->maybe_parens_unop('scalar', $_, 6)
5665 : $self->deparse($_, 6),
5666 @exprs
5667 ));
5668 }
5669 0 ▶ if ($prefix or $amper) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix or $amper) { } 0 0 0
Condition0%0/3
$prefix or $amper
l!l&&r!l&&!r
000
MC/DC0%0/2
$prefix or $amper
$prefix $amper
Truth table0%0/3
A or B
A= $prefixB= $amper
ABresult
1X1
011
000
5670 0 ▶ if ($kid eq '&') { $kid = "{$kid}" } # &{&} cannot be written as &&
Branch: 1 branch
BranchTrueFalseTotal
if ($kid eq "&") 0 0 0
5671 0 ▶ if ($op->flags & OPf_STACKED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 64) { } 0 0 0
5672 0 return $prefix . $amper . $kid . "(" . $args . ")";
5673 } else {
5674 0 return $prefix . $amper. $kid;
5675 }
5676 } else {
5677 # It's a syntax error to call CORE::GLOBAL::foo with a prefix,
5678 # so it must have been translated from a keyword call. Translate
5679 # it back.
5680 0 $kid =~ s/^CORE::GLOBAL:://;
5681  
5682 0 ▶ if (!$declared) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($declared) 0 0 0
5683 0 return "$kid(" . $args . ")";
5684 }
5685  
5686 0 ▶ my $dproto = defined($proto) ? $proto : "undefined";
Branch: 1 branch
BranchTrueFalseTotal
defined $proto ? : 0 0 0
5687 0 ▶ if ($dproto =~ /^\s*\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dproto =~ /^\s*\z/) 0 0 0
5688 0 return $kid;
5689 }
5690  
5691 0 my $scalar_proto = $dproto =~ /^ \s* (?: ;\s* )* (?: [\$*_+] |\\ \s* (?: [\$\@%&*] | \[ [^\]]+ \] ) ) \s* \z/x;
5692 0 ▶ if ($scalar_proto and !@exprs || is_scalar($exprs[0])) {
Branch: 2 branches
BranchTrueFalseTotal
if ($scalar_proto and !@exprs || is_scalar($exprs[0])) { } 0 0 0
elsif (not $scalar_proto and defined $proto || $simple) { } 0 0 0
Condition0%0/6
$scalar_proto and !@exprs || is_scalar($exprs[0])
!ll&&!rl&&r
000
not @exprs or is_scalar($exprs[0])
l!l&&r!l&&!r
000
MC/DC0%0/3
$scalar_proto and !@exprs || is_scalar($exprs[0])
$scalar_proto not @exprs is_scalar($exprs[0])
Truth table0%0/4
A and not(B) or C
A= $scalar_protoB= not @exprsC= is_scalar($exprs[0])
ABCresult
0XX0
1000
11X1
1011
5693 # is_scalar is an excessively conservative test here:
5694 # really, we should be comparing to the precedence of the
5695 # top operator of $exprs[0] (ala unop()), but that would
5696 # take some major code restructuring to do right.
5697 0 return $self->maybe_parens_func($kid, $args, $cx, 16);
5698 ▶ } elsif (not $scalar_proto and defined($proto) || $simple) {
Condition0%0/6
not $scalar_proto and defined $proto || $simple
!ll&&!rl&&r
000
defined $proto or $simple
l!l&&r!l&&!r
000
MC/DC0%0/3
not $scalar_proto and defined $proto || $simple
not $scalar_proto defined $proto $simple
Truth table0%0/4
not(A) and B or C
A= not $scalar_protoB= defined $protoC= $simple
ABCresult
0XX0
1000
11X1
1011
5699 0 return $self->maybe_parens_func($kid, $args, $cx, 5);
5700 } else {
5701 0 return "$kid(" . $args . ")";
5702 }
5703 }
5704 }
5705  
5706 0 ▶sub pp_enterwrite { unop(@_, "write") }
Subroutine pp_enterwrite: not called CC=1 SCAR=6.9
Pod undocumented
5707  
5708 # escape things that cause interpolation in double quotes,
5709 # but not character escapes
5710 sub uninterp {
5711 0 ▶ my($str) = @_;
Subroutine uninterp: not called CC=1 SCAR=6.9
Pod undocumented
5712 0 $str =~ s/(^|\G|[^\\])((?:\\\\)*)([\$\@]|\\[uUlLQE])/$1$2\\$3/g;
5713 0 return $str;
5714 }
5715  
5716 {
5717 my $bal;
5718 BEGIN {
5719 use re "eval";
5720 # Matches any string which is balanced with respect to {braces}
5721 $bal = qr(
5722 (?:
5723 [^\\{}]
5724 | \\\\
5725 | \\[{}]
5726 | \{(??{$bal})\}
5727 )*
5728 )x;
5729 }
5730  
5731 # the same, but treat $|, $), $( and $ at the end of the string differently
5732 # and leave comments unmangled for the sake of /x and (?x).
5733 sub re_uninterp {
5734 0 ▶ my($str) = @_;
Subroutine re_uninterp: not called CC=3 SCAR=24.8
Pod undocumented
5735  
5736 0 $str =~ s/
5737 ( ^|\G # $1
5738 | [^\\]
5739 )
5740  
5741 ( # $2
5742 (?:\\\\)*
5743 )
5744  
5745 ( # $3
5746 ( \(\?\??\{$bal\}\) # $4 (skip over (?{}) and (??{}) blocks)
5747 | \#[^\n]* # (skip over comments)
5748 )
5749 | [\$\@]
5750 (?!\||\)|\(|$|\s)
5751 | \\[uUlLQE]
5752 )
5753  
5754 0 ▶ /defined($4) && length($4) ? "$1$2$4" : "$1$2\\$3"/xeg;
Branch: 1 branch
BranchTrueFalseTotal
defined $4 && length $4 ? : 0 0 0
Condition0%0/3
defined $4 and length $4
!ll&&!rl&&r
000
MC/DC0%0/2
defined $4 and length $4
defined $4 length $4
Truth table0%0/3
A and B
A= defined $4B= length $4
ABresult
0X0
100
111
5755  
5756 0 return $str;
5757 }
5758 }
5759  
5760 # character escapes, but not delimiters that might need to be escaped
5761 sub escape_str { # ASCII, UTF8
5762 0 ▶ my($str) = @_;
Subroutine escape_str: not called CC=2 SCAR=17.9
Pod undocumented
5763 0 ▶ $str =~ s/(.)/ord($1) > 255 ? sprintf("\\x{%x}", ord($1)) : $1/eg;
Branch: 1 branch
BranchTrueFalseTotal
ord $1 > 255 ? : 0 0 0
5764 0 $str =~ s/\a/\\a/g;
5765 # $str =~ s/\cH/\\b/g; # \b means something different in a regex; and \cH
5766 # isn't a backspace in EBCDIC
5767 0 $str =~ s/\t/\\t/g;
5768 0 $str =~ s/\n/\\n/g;
5769 0 $str =~ s/\e/\\e/g;
5770 0 $str =~ s/\f/\\f/g;
5771 0 $str =~ s/\r/\\r/g;
5772 0 $str =~ s/([\cA-\cZ])/'\\c' . $unctrl{$1}/ge;
5773 0 $str =~ s/([[:^print:]])/sprintf("\\%03o", ord($1))/age;
5774 0 return $str;
5775 }
5776  
5777 # For regexes. Leave whitespace unmangled in case of /x or (?x).
5778 sub escape_re {
5779 0 ▶ my($str) = @_;
Subroutine escape_re: not called CC=3 SCAR=24.8
Pod undocumented
5780 0 ▶ $str =~ s/(.)/ord($1) > 255 ? sprintf("\\x{%x}", ord($1)) : $1/eg;
Branch: 1 branch
BranchTrueFalseTotal
ord $1 > 255 ? : 0 0 0
5781 0 $str =~ s/([[:^print:]])/
5782 0 ▶ ($1 =~ y! \t\n!!) ? $1 : sprintf("\\%03o", ord($1))/age;
Branch: 1 branch
BranchTrueFalseTotal
$1 =~ tr/\t\n // ? : 0 0 0
5783 0 $str =~ s/\n/\n\f/g;
5784 0 return $str;
5785 }
5786  
5787 # Don't do this for regexen
5788 sub unback {
5789 0 ▶ my($str) = @_;
Subroutine unback: not called CC=1 SCAR=6.9
Pod undocumented
5790 0 $str =~ s/\\/\\\\/g;
5791 0 return $str;
5792 }
5793  
5794 # Remove backslashes which precede literal control characters,
5795 # to avoid creating ambiguity when we escape the latter.
5796 #
5797 # Don't remove a backslash from escaped whitespace: where the T represents
5798 # a literal tab character, /T/x is not equivalent to /\T/x
5799  
5800 sub re_unback {
5801 0 ▶ my($str) = @_;
Subroutine re_unback: not called CC=1 SCAR=6.9
Pod undocumented
5802  
5803 # the insane complexity here is due to the behaviour of "\c\"
5804 0 $str =~ s/
5805 # these two lines ensure that the backslash we're about to
5806 # remove isn't preceded by something which makes it part
5807 # of a \c
5808  
5809 (^ | [^\\] | \\c\\) # $1
5810 (?<!\\c)
5811  
5812 # the backslash to remove
5813 \\
5814  
5815 # keep pairs of backslashes
5816 (\\\\)* # $2
5817  
5818 # only remove if the thing following is a control char
5819 (?=[[:^print:]])
5820 # and not whitespace
5821 (?=\S)
5822 /$1$2/xg;
5823 0 return $str;
5824 }
5825  
5826 sub balanced_delim {
5827 0 ▶ my($str) = @_;
Subroutine balanced_delim: not called CC=10 SCAR=47.0
Pod undocumented
5828 0 my @str = split //, $str;
5829 0 my($ar, $open, $close, $fail, $c, $cnt, $last_bs);
5830 0 for $ar (['[',']'], ['(',')'], ['<','>'], ['{','}']) {
5831 0 ($open, $close) = @$ar;
5832 0 $fail = 0; $cnt = 0; $last_bs = 0;
5833 0 for $c (@str) {
5834 0 ▶ if ($c eq $open) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq $open) { } 0 0 0
elsif ($c eq $close) { } 0 0 0
5835 0 ▶ $fail = 1 if $last_bs;
Branch: 1 branch
BranchTrueFalseTotal
if $last_bs 0 0 0
5836 0 $cnt++;
5837 } elsif ($c eq $close) {
5838 0 ▶ $fail = 1 if $last_bs;
Branch: 1 branch
BranchTrueFalseTotal
if $last_bs 0 0 0
5839 0 $cnt--;
5840 0 ▶ if ($cnt < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cnt < 0) 0 0 0
5841 # qq()() isn't ")("
5842 0 $fail = 1;
5843 0 last;
5844 }
5845 }
5846 0 $last_bs = $c eq '\\';
5847 }
5848 0 ▶ $fail = 1 if $cnt != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $cnt != 0 0 0 0
5849 0 ▶ return ($open, "$open$str$close") if not $fail;
Branch: 1 branch
BranchTrueFalseTotal
unless $fail 0 0 0
5850 }
5851 0 return ("", $str);
5852 }
5853  
5854 sub single_delim {
5855 0 ▶ my($q, $default, $str, $self) = @_;
Subroutine single_delim: not called CC=8 SCAR=42.8
Pod undocumented
5856 0 ▶ return "$default$str$default" if $default and index($str, $default) == -1;
Branch: 1 branch
BranchTrueFalseTotal
if $default and index($str, $default) == -1 0 0 0
Condition0%0/3
$default and index($str, $default) == -1
!ll&&!rl&&r
000
MC/DC0%0/2
$default and index($str, $default) == -1
$default index($str, $default) == -1
Truth table0%0/3
A and B
A= $defaultB= index($str, $default) == -1
ABresult
0X0
100
111
5857 0 my $coreq = $self->keyword($q); # maybe CORE::q
5858 0 ▶ if ($q ne 'qr') {
Branch: 1 branch
BranchTrueFalseTotal
if ($q ne "qr") 0 0 0
5859 0 (my $succeed, $str) = balanced_delim($str);
5860 0 ▶ return "$coreq$str" if $succeed;
Branch: 1 branch
BranchTrueFalseTotal
if $succeed 0 0 0
5861 }
5862 0 for my $delim ('/', '"', '#') {
5863 0 ▶ return "$coreq$delim" . $str . $delim if index($str, $delim) == -1;
Branch: 1 branch
BranchTrueFalseTotal
if index($str, $delim) == -1 0 0 0
5864 }
5865 0 ▶ if ($default) {
Branch: 1 branch
BranchTrueFalseTotal
if ($default) { } 0 0 0
5866 0 $str =~ s/$default/\\$default/g;
5867 0 return "$default$str$default";
5868 } else {
5869 0 $str =~ s[/][\\/]g;
5870 0 return "$coreq/$str/";
5871 }
5872 }
5873  
5874 my $max_prec;
5875 BEGIN { $max_prec = int(0.999 + 8*length(pack("F", 42))*log(2)/log(10)); }
5876  
5877 # Split a floating point number into an integer mantissa and a binary
5878 # exponent. Assumes you've already made sure the number isn't zero or
5879 # some weird infinity or NaN.
5880 sub split_float {
5881 0 ▶ my($f) = @_;
Subroutine split_float: not called CC=4 SCAR=30.0
Pod undocumented
5882 0 my $exponent = 0;
5883 0 ▶ if ($f == int($f)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f == int $f) { } 0 0 0
5884 0 ▶ while ($f % 2 == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f % 2 == 0) 0 0 0
5885 0 $f /= 2;
5886 0 $exponent++;
5887 }
5888 } else {
5889 0 ▶ while ($f != int($f)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f != int $f) 0 0 0
5890 0 $f *= 2;
5891 0 $exponent--;
5892 }
5893 }
5894 0 my $mantissa = sprintf("%.0f", $f);
5895 0 return ($mantissa, $exponent);
5896 }
5897  
5898  
5899 # suitably single- or double-quote a literal constant string
5900  
5901 sub quoted_const_str {
5902 0 ▶ my ($self, $str) =@_;
Subroutine quoted_const_str: not called CC=2 SCAR=17.9
Pod undocumented
5903 0 ▶ if ($str =~ /[[:^print:]]/a) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /[[:^print:]]/a) { } 0 0 0
5904 0 return single_delim("qq", '"',
5905 uninterp(escape_str unback $str), $self);
5906 } else {
5907 0 return single_delim("q", "'", unback($str), $self);
5908 }
5909 }
5910  
5911  
5912 sub const {
5913 0 ▶ my $self = shift;
Subroutine const: not called CC=40 SCAR=74.0
Pod undocumented
5914 0 my($sv, $cx) = @_;
5915 0 ▶ if ($self->{'use_dumper'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"use_dumper"}) 0 0 0
5916 0 return $self->const_dumper($sv, $cx);
5917 }
5918 0 ▶ if (class($sv) eq "SPECIAL") {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($sv) eq "SPECIAL") 0 0 0
5919 # PL_sv_undef etc
5920 # return yes/no as boolean expressions rather than integers to
5921 # preserve their boolean-ness
5922 return
5923 0 ▶ $$sv == 1 ? 'undef' : # PL_sv_undef
Branch: 4 branches
BranchTrueFalseTotal
$$sv == 1 ? : 0 0 0
$$sv == 2 ? : 0 0 0
$$sv == 3 ? : 0 0 0
$$sv == 7 ? : 0 0 0
5924 $$sv == 2 ? $self->maybe_parens("!0", $cx, 21) : # PL_sv_yes
5925 $$sv == 3 ? $self->maybe_parens("!1", $cx, 21) : # PL_sv_no
5926 $$sv == 7 ? '0' : # PL_sv_zero
5927 '"???"';
5928 }
5929 0 ▶ if (class($sv) eq "NULL") {
Branch: 1 branch
BranchTrueFalseTotal
if (B::Deparse::class($sv) eq "NULL") 0 0 0
5930 0 return 'undef';
5931 }
5932 # convert a version object into the "v1.2.3" string in its V magic
5933 0 ▶ if ($sv->FLAGS & SVs_RMG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sv->FLAGS & 8388608) 0 0 0
5934 0 ▶ for (my $mg = $sv->MAGIC; $mg; $mg = $mg->MOREMAGIC) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mg) 0 0 0
5935 0 ▶ return $mg->PTR if $mg->TYPE eq 'V';
Branch: 1 branch
BranchTrueFalseTotal
if $mg->TYPE eq "V" 0 0 0
5936 }
5937 }
5938  
5939 0 ▶ if ($sv->FLAGS & SVf_IOK) {
Branch: 4 branches
BranchTrueFalseTotal
if ($sv->FLAGS & 256) { } 0 0 0
elsif ($sv->FLAGS & 512) { } 0 0 0
elsif ($sv->FLAGS & 2048 and $sv->can('RV')) { } 0 0 0
elsif ($sv->FLAGS & 1024) { } 0 0 0
5940 0 my $str = $sv->int_value;
5941 0 ▶ $str = $self->maybe_parens($str, $cx, 21) if $str < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $str < 0 0 0 0
5942 0 return $str;
5943 } elsif ($sv->FLAGS & SVf_NOK) {
5944 0 my $nv = $sv->NV;
5945 0 ▶ if ($nv == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if ($nv == 0) { } 0 0 0
elsif (1 / $nv == 0) { } 0 0 0
elsif ($nv != $nv) { } 0 0 0
5946 0 ▶ if (pack("F", $nv) eq pack("F", 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (pack('F', $nv) eq "\000\000\000\000\000\000\000\000") { } 0 0 0
5947 # positive zero
5948 0 return "0.0";
5949 } else {
5950 # negative zero
5951 0 return $self->maybe_parens("-0.0", $cx, 21);
5952 }
5953 } elsif (1/$nv == 0) {
5954 0 ▶ if ($nv > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nv > 0) { } 0 0 0
5955 # positive infinity
5956 0 return $self->maybe_parens("9**9**9", $cx, 22);
5957 } else {
5958 # negative infinity
5959 0 return $self->maybe_parens("-9**9**9", $cx, 21);
5960 }
5961 } elsif ($nv != $nv) {
5962 # NaN
5963 0 ▶ if (pack("F", $nv) eq pack("F", sin(9**9**9))) {
Branch: 2 branches
BranchTrueFalseTotal
if (pack('F', $nv) eq "\000\000\000\000\000\000\370\377") { } 0 0 0
elsif (pack('F', $nv) eq "\000\000\000\000\000\000\370\177") { } 0 0 0
5964 # the normal kind
5965 0 return "sin(9**9**9)";
5966 } elsif (pack("F", $nv) eq pack("F", -sin(9**9**9))) {
5967 # the inverted kind
5968 0 return $self->maybe_parens("-sin(9**9**9)", $cx, 21);
5969 } else {
5970 # some other kind
5971 0 my $hex = unpack("h*", pack("F", $nv));
5972 0 return qq'unpack("F", pack("h*", "$hex"))';
5973 }
5974 }
5975 # first, try the default stringification
5976 0 my $str = "$nv";
5977 0 ▶ if ($str != $nv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str != $nv) 0 0 0
5978 # failing that, try using more precision
5979 0 $str = sprintf("%.${max_prec}g", $nv);
5980 # if (pack("F", $str) ne pack("F", $nv)) {
5981 0 ▶ if ($str != $nv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str != $nv) 0 0 0
5982 # not representable in decimal with whatever sprintf()
5983 # and atof() Perl is using here.
5984 0 my($mant, $exp) = split_float($nv);
5985 0 return $self->maybe_parens("$mant * 2**$exp", $cx, 19);
5986 }
5987 }
5988  
5989 # preserve NV-ness: output as NNN.0 rather than NNN
5990 0 ▶ $str .= ".0" if $str =~ /^-?[0-9]+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $str =~ /^-?[0-9]+$/ 0 0 0
5991  
5992 0 ▶ $str = $self->maybe_parens($str, $cx, 21) if $nv < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $nv < 0 0 0 0
5993 0 return $str;
5994 ▶ } elsif ($sv->FLAGS & SVf_ROK && $sv->can("RV")) {
Condition0%0/3
$sv->FLAGS & 2048 and $sv->can("RV")
!ll&&!rl&&r
000
MC/DC0%0/2
$sv->FLAGS & 2048 and $sv->can("RV")
$sv->FLAGS & 2048 $sv->can("RV")
Truth table0%0/3
A and B
A= $sv->FLAGS & 2048B= $sv->can("RV")
ABresult
0X0
100
111
5995 0 my $ref = $sv->RV;
5996 0 my $class = class($ref);
5997 0 ▶ if ($class eq "AV") {
Branch: 3 branches
BranchTrueFalseTotal
if ($class eq 'AV') { } 0 0 0
elsif ($class eq 'HV') { } 0 0 0
elsif ($class eq 'CV') { } 0 0 0
5998 0 return "[" . $self->list_const(2, $ref->ARRAY) . "]";
5999 } elsif ($class eq "HV") {
6000 0 my %hash = $ref->ARRAY;
6001 0 my @elts;
6002 0 for my $k (sort keys %hash) {
6003 0 push @elts, "$k => " . $self->const($hash{$k}, 6);
6004 }
6005 0 return "{" . join(", ", @elts) . "}";
6006 } elsif ($class eq "CV") {
6007 no overloading;
6008 0 ▶ if ($self->{curcv} &&
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"curcv"} and $self->{"curcv"}->object_2svref == $ref->object_2svref) 0 0 0
Condition0%0/3
$self->{"curcv"} and $self->{"curcv"}->object_2svref == $ref->object_2svref
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"curcv"} and $self->{"curcv"}->object_2svref == $ref->object_2svref
$self->{"curcv"} $self->{"curcv"}->object_2svref == $ref->object_2svref
Truth table0%0/3
A and B
A= $self->{"curcv"}B= $self->{"curcv"}->object_2svref == $ref->object_2svref
ABresult
0X0
100
111
6009 $self->{curcv}->object_2svref == $ref->object_2svref) {
6010 0 return $self->keyword("__SUB__");
6011 }
6012 0 return $self->kw_sub_or_method($ref) . " " . $self->deparse_sub($ref);
6013 }
6014 0 ▶ if ($class ne 'SPECIAL' and $ref->FLAGS & SVs_SMG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class ne "SPECIAL" and $ref->FLAGS & 4194304) 0 0 0
Condition0%0/3
$class ne "SPECIAL" and $ref->FLAGS & 4194304
!ll&&!rl&&r
000
MC/DC0%0/2
$class ne "SPECIAL" and $ref->FLAGS & 4194304
$class ne "SPECIAL" $ref->FLAGS & 4194304
Truth table0%0/3
A and B
A= $class ne "SPECIAL"B= $ref->FLAGS & 4194304
ABresult
0X0
100
111
6015 0 ▶ for (my $mg = $ref->MAGIC; $mg; $mg = $mg->MOREMAGIC) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mg) 0 0 0
6016 0 ▶ if ($mg->TYPE eq 'r') {
Branch: 1 branch
BranchTrueFalseTotal
if ($mg->TYPE eq "r") 0 0 0
6017 0 my $re = re_uninterp(escape_re(re_unback($mg->precomp)));
6018 0 return single_delim("qr", "", $re, $self);
6019 }
6020 }
6021 }
6022
6023 0 my $const = $self->const($ref, 20);
6024 0 ▶ if ($self->{in_subst_repl} && $const =~ /^[0-9]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"in_subst_repl"} and $const =~ /^[0-9]/) 0 0 0
Condition0%0/3
$self->{"in_subst_repl"} and $const =~ /^[0-9]/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"in_subst_repl"} and $const =~ /^[0-9]/
$self->{"in_subst_repl"} $const =~ /^[0-9]/
Truth table0%0/3
A and B
A= $self->{"in_subst_repl"}B= $const =~ /^[0-9]/
ABresult
0X0
100
111
6025 0 $const = "($const)";
6026 }
6027 0 return $self->maybe_parens("\\$const", $cx, 20);
6028 } elsif ($sv->FLAGS & SVf_POK) {
6029 0 my $str = $sv->PV;
6030 0 return $self->quoted_const_str($str);
6031 } else {
6032 0 return "undef";
6033 }
6034 }
6035  
6036 sub const_dumper {
6037 0 ▶ my $self = shift;
Subroutine const_dumper: not called CC=2 SCAR=17.9
Pod undocumented
6038 0 my($sv, $cx) = @_;
6039 0 my $ref = $sv->object_2svref();
6040 0 my $dumper = Data::Dumper->new([$$ref], ['$v']);
6041 0 $dumper->Purity(1)->Terse(1)->Deparse(1)->Indent(0)->Useqq(1)->Sortkeys(1);
6042 0 my $str = $dumper->Dump();
6043 0 ▶ if ($str =~ /^\$v/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /^\$v/) { } 0 0 0
6044 0 return '${my ' . $str . ' \$v}';
6045 } else {
6046 0 return $str;
6047 }
6048 }
6049  
6050 sub const_sv {
6051 0 ▶ my $self = shift;
Subroutine const_sv: not called CC=2 SCAR=17.9
Pod undocumented
6052 0 my $op = shift;
6053 0 my $sv = $op->sv;
6054 # the constant could be in the pad (under useithreads)
6055 0 ▶ $sv = $self->padval($op->targ) unless $$sv;
Branch: 1 branch
BranchTrueFalseTotal
unless $$sv 0 0 0
6056 0 return $sv;
6057 }
6058  
6059 sub meth_sv {
6060 0 ▶ my $self = shift;
Subroutine meth_sv: not called CC=2 SCAR=17.9
Pod undocumented
6061 0 my $op = shift;
6062 0 my $sv = $op->meth_sv;
6063 # the constant could be in the pad (under useithreads)
6064 0 ▶ $sv = $self->padval($op->targ) unless $$sv;
Branch: 1 branch
BranchTrueFalseTotal
unless $$sv 0 0 0
6065 0 return $sv;
6066 }
6067  
6068 sub meth_rclass_sv {
6069 0 ▶ my $self = shift;
Subroutine meth_rclass_sv: not called CC=2 SCAR=17.9
Pod undocumented
6070 0 my $op = shift;
6071 0 my $sv = $op->rclass;
6072 # the constant could be in the pad (under useithreads)
6073 0 ▶ $sv = $self->padval($sv) unless ref $sv;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $sv 0 0 0
6074 0 return $sv;
6075 }
6076  
6077 sub pp_const {
6078 0 ▶ my $self = shift;
Subroutine pp_const: not called CC=5 SCAR=34.0
Pod undocumented
6079 0 my($op, $cx) = @_;
6080 # if ($op->private & OPpCONST_BARE) { # trouble with '=>' autoquoting
6081 # return $self->const_sv($op)->PV;
6082 # }
6083 0 my $sv = $self->const_sv($op);
6084  
6085 0 my $token = ($op->private & OPpCONST_TOKEN_MASK);
6086 0 ▶ if ($token) { # handle __LINE__ etc
Branch: 1 branch
BranchTrueFalseTotal
if ($token) 0 0 0
6087 0 ▶ if ($token == OPpCONST_TOKEN_LINE) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token == 64) { } 0 0 0
elsif ($token == 128) { } 0 0 0
elsif ($token == 192) { } 0 0 0
6088 0 return "__LINE__";
6089 }
6090 elsif ($token == OPpCONST_TOKEN_FILE) {
6091 0 return "__FILE__";
6092 }
6093 elsif ($token == OPpCONST_TOKEN_PACKAGE) {
6094 0 return "__PACKAGE__";
6095 }
6096 }
6097  
6098 0 return $self->const($sv, $cx);
6099 }
6100  
6101  
6102 # Join two components of a double-quoted string, disambiguating
6103 # "${foo}bar", "${foo}{bar}", "${foo}[1]", "$foo\::bar"
6104  
6105 sub dq_disambiguate {
6106 0 ▶ my ($first, $last) = @_;
Subroutine dq_disambiguate: not called CC=4 SCAR=30.0
Pod undocumented
6107 0 ▶ ($last =~ /^[A-Z\\\^\[\]_?]/ &&
Branch: 1 branch
BranchTrueFalseTotal
$last =~ /^[A-Z\\\^\[\]_?]/ and $first =~ s/([\$\@])\^$/$1{^}/ or $last =~ /^[:'{\[\w_]/ and $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/ 0 0 0
Condition0%0/9
$last =~ /^[A-Z\\\^\[\]_?]/ && $first =~ s/([\$\@])\^$/$1{^}/ || $last =~ /^[:'{\[\w_]/ && $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/
l!l&&r!l&&!r
000
$last =~ /^[A-Z\\\^\[\]_?]/ and $first =~ s/([\$\@])\^$/$1{^}/
!ll&&!rl&&r
000
$last =~ /^[:'{\[\w_]/ and $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/
!ll&&!rl&&r
000
MC/DC0%0/4
$last =~ /^[A-Z\\\^\[\]_?]/ && $first =~ s/([\$\@])\^$/$1{^}/ || $last =~ /^[:'{\[\w_]/ && $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/
$last =~ /^[A-Z\\\^\[\]_?]/ $first =~ s/([\$\@])\^$/$1{^}/ $last =~ /^[:'{\[\w_]/ $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/
Truth table0%0/7
A and B || C and D
A= $last =~ /^[A-Z\\\^\[\]_?]/B= $first =~ s/([\$\@])\^$/$1{^}/C= $last =~ /^[:'{\[\w_]/D= $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
6108 $first =~ s/([\$@])\^$/${1}{^}/) # "${^}W" etc
6109 || ($last =~ /^[:'{\[\w_]/ && #'
6110 $first =~ s/([\$@])([A-Za-z_]\w*)$/${1}{$2}/);
6111 0 return $first . $last;
6112 }
6113  
6114  
6115 # Deparse a double-quoted optree. For example, "$a[0]\Q$b\Efo\"o" gets
6116 # compiled to concat(concat($[0],quotemeta($b)),const("fo\"o")), and this
6117 # sub deparses it back to $a[0]\Q$b\Efo"o
6118 # (It does not add delimiters)
6119  
6120 sub dq {
6121 0 ▶ my $self = shift;
Subroutine dq: not called CC=11 SCAR=48.8
Pod undocumented
6122 0 my $op = shift;
6123 0 my $type = $op->name;
6124 0 ▶ if ($type eq "const") {
Branch: 10 branches
BranchTrueFalseTotal
if ($type eq 'const') { } 0 0 0
elsif ($type eq 'concat') { } 0 0 0
elsif ($type eq 'multiconcat') { } 0 0 0
elsif ($type eq 'uc') { } 0 0 0
elsif ($type eq 'lc') { } 0 0 0
elsif ($type eq 'ucfirst') { } 0 0 0
elsif ($type eq 'lcfirst') { } 0 0 0
elsif ($type eq 'quotemeta') { } 0 0 0
elsif ($type eq 'fc') { } 0 0 0
elsif ($type eq 'join') { } 0 0 0
6125 0 return uninterp(escape_str(unback($self->const_sv($op)->as_string)));
6126 } elsif ($type eq "concat") {
6127 0 return dq_disambiguate($self->dq($op->first), $self->dq($op->last));
6128 } elsif ($type eq "multiconcat") {
6129 0 return $self->do_multiconcat($op, 26, 1);
6130 } elsif ($type eq "uc") {
6131 0 return '\U' . $self->dq($op->first->sibling) . '\E';
6132 } elsif ($type eq "lc") {
6133 0 return '\L' . $self->dq($op->first->sibling) . '\E';
6134 } elsif ($type eq "ucfirst") {
6135 0 return '\u' . $self->dq($op->first->sibling);
6136 } elsif ($type eq "lcfirst") {
6137 0 return '\l' . $self->dq($op->first->sibling);
6138 } elsif ($type eq "quotemeta") {
6139 0 return '\Q' . $self->dq($op->first->sibling) . '\E';
6140 } elsif ($type eq "fc") {
6141 0 return '\F' . $self->dq($op->first->sibling) . '\E';
6142 } elsif ($type eq "join") {
6143 0 return $self->deparse($op->last, 26); # was join($", @ary)
6144 } else {
6145 0 return $self->deparse($op, 26);
6146 }
6147 }
6148  
6149 sub pp_backtick {
6150 0 ▶ my $self = shift;
Subroutine pp_backtick: not called CC=3 SCAR=24.8
Pod undocumented
6151 0 my($op, $cx) = @_;
6152 # skip pushmark if it exists (readpipe() vs ``)
6153 0 ▶ my $child = $op->first->sibling->isa('B::NULL')
Branch: 1 branch
BranchTrueFalseTotal
$op->first->sibling->isa('B::NULL') ? : 0 0 0
6154 ? $op->first : $op->first->sibling;
6155 0 ▶ if ($self->pure_string($child)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->pure_string($child)) 0 0 0
6156 0 return single_delim("qx", '`', $self->dq($child, 1), $self);
6157 }
6158 0 unop($self, @_, "readpipe");
6159 }
6160  
6161 sub dquote {
6162 0 ▶ my $self = shift;
Subroutine dquote: not called CC=2 SCAR=17.9
Pod undocumented
6163 0 my($op, $cx) = @_;
6164 0 my $kid = $op->first->sibling; # skip ex-stringify, pushmark
6165 0 ▶ return $self->deparse($kid, $cx) if $self->{'unquote'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"unquote"} 0 0 0
6166 $self->maybe_targmy($kid, $cx,
6167 0 ▶ sub {single_delim("qq", '"', $self->dq($_[1]),
Subroutine __ANON__: not called CC=1 SCAR=6.9
6168 0 $self)});
6169 }
6170  
6171 # OP_STRINGIFY is a listop, but it only ever has one arg
6172 sub pp_stringify {
6173 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_stringify: not called CC=4 SCAR=30.0
Pod undocumented
6174 0 my $kid = $op->first->sibling;
6175 0 ▶ while ($kid->name eq 'null' && !null($kid->first)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->name eq "null" and not null($kid->first)) 0 0 0
Condition0%0/3
$kid->name eq "null" and not null($kid->first)
!ll&&!rl&&r
000
MC/DC0%0/2
$kid->name eq "null" and not null($kid->first)
$kid->name eq "null" not null($kid->first)
Truth table0%0/3
A and not(B)
A= $kid->name eq "null"B= not null($kid->first)
ABresult
0X0
100
111
6176 0 $kid = $kid->first;
6177 }
6178 0 ▶ if ($kid->name =~ /^(?:const|padsv|rv2sv|av2arylen|gvsv|multideref
Branch: 1 branch
BranchTrueFalseTotal
if ($kid->name =~ /^(?:const|padsv|rv2sv|av2arylen|gvsv|multideref |aelemfast(?:_lex)?|[ah]elem|join|concat)\z/x) { } 0 0 0
6179 |aelemfast(?:_lex)?|[ah]elem|join|concat)\z/x) {
6180 0 maybe_targmy(@_, \&dquote);
6181 }
6182 else {
6183 # Actually an optimised join.
6184 0 my $result = listop(@_,"join");
6185 0 $result =~ s/join([( ])/join$1$self->{'ex_const'}, /;
6186 0 $result;
6187 }
6188 }
6189  
6190 # tr/// and s/// (and tr[][], tr[]//, tr###, etc)
6191 # note that tr(from)/to/ is OK, but not tr/from/(to)
6192 sub double_delim {
6193 0 ▶ my($from, $to) = @_;
Subroutine double_delim: not called CC=11 SCAR=48.8
Pod undocumented
6194 0 my($succeed, $delim);
6195 0 ▶ if ($from !~ m[/] and $to !~ m[/]) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $from =~ m[/] || $to =~ m[/]) { } 0 0 0
elsif (($succeed, $from) = balanced_delim($from) and $succeed) { } 0 0 0
Condition0%0/3
$from =~ m[/] || $to =~ m[/]
l!l&&r!l&&!r
000
MC/DC0%0/2
$from =~ m[/] || $to =~ m[/]
$from =~ m[/] $to =~ m[/]
Truth table0%0/3
A || B
A= $from =~ m[/]B= $to =~ m[/]
ABresult
1X1
011
000
6196 0 return "/$from/$to/";
6197 ▶ } elsif (($succeed, $from) = balanced_delim($from) and $succeed) {
Condition0%0/3
($succeed, $from) = balanced_delim($from) and $succeed
!ll&&!rl&&r
000
MC/DC0%0/2
($succeed, $from) = balanced_delim($from) and $succeed
($succeed, $from) = balanced_delim($from) $succeed
Truth table0%0/3
A and B
A= ($succeed, $from) = balanced_delim($from)B= $succeed
ABresult
0X0
100
111
6198 0 ▶ if (($succeed, $to) = balanced_delim($to) and $succeed) {
Branch: 1 branch
BranchTrueFalseTotal
if (($succeed, $to) = balanced_delim($to) and $succeed) { } 0 0 0
Condition0%0/3
($succeed, $to) = balanced_delim($to) and $succeed
!ll&&!rl&&r
000
MC/DC0%0/2
($succeed, $to) = balanced_delim($to) and $succeed
($succeed, $to) = balanced_delim($to) $succeed
Truth table0%0/3
A and B
A= ($succeed, $to) = balanced_delim($to)B= $succeed
ABresult
0X0
100
111
6199 0 return "$from$to";
6200 } else {
6201 0 for $delim ('/', '"', '#') { # note no "'" -- s''' is special
6202 0 ▶ return "$from$delim$to$delim" if index($to, $delim) == -1;
Branch: 1 branch
BranchTrueFalseTotal
if index($to, $delim) == -1 0 0 0
6203 }
6204 0 $to =~ s[/][\\/]g;
6205 0 return "$from/$to/";
6206 }
6207 } else {
6208 0 for $delim ('/', '"', '#') { # note no '
6209 0 ▶ return "$delim$from$delim$to$delim"
Branch: 1 branch
BranchTrueFalseTotal
if index($to . $from, $delim) == -1 0 0 0
6210 if index($to . $from, $delim) == -1;
6211 }
6212 0 $from =~ s[/][\\/]g;
6213 0 $to =~ s[/][\\/]g;
6214 0 return "/$from/$to/";
6215 }
6216 }
6217  
6218 # Escape a characrter.
6219 # Only used by tr///, so backslashes hyphens
6220  
6221 sub pchr {
6222 0 ▶ my($n) = @_;
Subroutine pchr: not called CC=9 SCAR=45.0
Pod undocumented
6223 0 ▶ return sprintf("\\x{%X}", $n) if $n > 255;
Branch: 1 branch
BranchTrueFalseTotal
if $n > 255 0 0 0
6224 0 ▶ return '\\\\' if $n == ord '\\';
Branch: 1 branch
BranchTrueFalseTotal
if $n == 92 0 0 0
6225 0 ▶ return "\\-" if $n == ord "-";
Branch: 1 branch
BranchTrueFalseTotal
if $n == 45 0 0 0
6226 # I'm presuming a regex is not ok here, otherwise we could have used
6227 # /[[:print:]]/a to get here
6228 0 ▶ return chr($n) if ( utf8::native_to_unicode($n)
Branch: 1 branch
BranchTrueFalseTotal
if $n >= 32 and $n <= 126 0 0 0
Condition0%0/3
$n >= 32 and $n <= 126
!ll&&!rl&&r
000
MC/DC0%0/2
$n >= 32 and $n <= 126
$n >= 32 $n <= 126
Truth table0%0/3
A and B
A= $n >= 32B= $n <= 126
ABresult
0X0
100
111
6229 >= utf8::native_to_unicode(ord(' '))
6230 and utf8::native_to_unicode($n)
6231 <= utf8::native_to_unicode(ord('~')));
6232  
6233 0 my $mnemonic_pos = index("\a\b\e\f\n\r\t", chr($n));
6234 0 ▶ return "\\" . substr("abefnrt", $mnemonic_pos, 1) if $mnemonic_pos >= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $mnemonic_pos >= 0 0 0 0
6235  
6236 0 ▶ return '\\c' . $unctrl{chr $n} if $n >= ord("\cA") and $n <= ord("\cZ");
Branch: 1 branch
BranchTrueFalseTotal
if $n >= 1 and $n <= 26 0 0 0
Condition0%0/3
$n >= 1 and $n <= 26
!ll&&!rl&&r
000
MC/DC0%0/2
$n >= 1 and $n <= 26
$n >= 1 $n <= 26
Truth table0%0/3
A and B
A= $n >= 1B= $n <= 26
ABresult
0X0
100
111
6237 # return '\x' . sprintf("%02x", $n);
6238 0 return '\\' . sprintf("%03o", $n);
6239 }
6240  
6241 # Convert a list of characters into a string suitable for tr/// search or
6242 # replacement, with suitable escaping and collapsing of ranges
6243  
6244 sub collapse {
6245 0 ▶ my(@chars) = @_;
Subroutine collapse: not called CC=7 SCAR=40.3
Pod undocumented
6246 0 my($str, $c, $tr) = ("");
6247 0 ▶ for ($c = 0; $c < @chars; $c++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c < @chars) 0 0 0
6248 0 $tr = $chars[$c];
6249 0 $str .= pchr($tr);
6250 0 ▶ if ($c <= $#chars - 2 and $chars[$c + 1] == $tr + 1 and
Branch: 1 branch
BranchTrueFalseTotal
if ($c <= $#chars - 2 and $chars[$c + 1] == $tr + 1 and $chars[$c + 2] == $tr + 2) 0 0 0
Condition0%0/6
$c <= $#chars - 2 and $chars[$c + 1] == $tr + 1 and $chars[$c + 2] == $tr + 2
!ll&&!rl&&r
000
$c <= $#chars - 2 and $chars[$c + 1] == $tr + 1
!ll&&!rl&&r
000
MC/DC0%0/3
$c <= $#chars - 2 and $chars[$c + 1] == $tr + 1 and $chars[$c + 2] == $tr + 2
$c <= $#chars - 2 $chars[$c + 1] == $tr + 1 $chars[$c + 2] == $tr + 2
Truth table0%0/4
A and B and C
A= $c <= $#chars - 2B= $chars[$c + 1] == $tr + 1C= $chars[$c + 2] == $tr + 2
ABCresult
0XX0
10X0
1100
1111
6251 $chars[$c + 2] == $tr + 2)
6252 {
6253 0 ▶ for (; $c <= $#chars-1 and $chars[$c + 1] == $chars[$c] + 1; $c++)
Branch: 1 branch
BranchTrueFalseTotal
if ($c <= $#chars - 1 and $chars[$c + 1] == $chars[$c] + 1) 0 0 0
Condition0%0/3
$c <= $#chars - 1 and $chars[$c + 1] == $chars[$c] + 1
!ll&&!rl&&r
000
MC/DC0%0/2
$c <= $#chars - 1 and $chars[$c + 1] == $chars[$c] + 1
$c <= $#chars - 1 $chars[$c + 1] == $chars[$c] + 1
Truth table0%0/3
A and B
A= $c <= $#chars - 1B= $chars[$c + 1] == $chars[$c] + 1
ABresult
0X0
100
111
6254 {}
6255 0 $str .= "-";
6256 0 $str .= pchr($chars[$c]);
6257 }
6258 }
6259 0 return $str;
6260 }
6261  
6262 sub tr_decode_byte {
6263 0 ▶ my($table, $flags) = @_;
Subroutine tr_decode_byte: not called CC=19 SCAR=59.4
Pod undocumented
6264 0 ▶ my $ssize_t = $Config{ptrsize} == 8 ? 'q' : 'l';
Branch: 1 branch
BranchTrueFalseTotal
$B::Deparse::Config{'ptrsize'} == 8 ? : 0 0 0
6265 0 my ($size, @table) = unpack("${ssize_t}s*", $table);
6266 0 pop @table; # remove the wildcard final entry
6267  
6268 0 my($c, $tr, @from, @to, @delfrom, $delhyphen);
6269 0 ▶ if ($table[ord "-"] != -1 and
Branch: 1 branch
BranchTrueFalseTotal
if ($table[45] != -1 and $table[44] == -1 || $table[46] == -1) 0 0 0
Condition0%0/6
$table[45] != -1 and $table[44] == -1 || $table[46] == -1
!ll&&!rl&&r
000
$table[44] == -1 or $table[46] == -1
l!l&&r!l&&!r
000
MC/DC0%0/3
$table[45] != -1 and $table[44] == -1 || $table[46] == -1
$table[45] != -1 $table[44] == -1 $table[46] == -1
Truth table0%0/4
A and B or C
A= $table[45] != -1B= $table[44] == -1C= $table[46] == -1
ABCresult
0XX0
1000
11X1
1011
6270 $table[ord("-") - 1] == -1 || $table[ord("-") + 1] == -1)
6271 {
6272 0 $tr = $table[ord "-"];
6273 0 $table[ord "-"] = -1;
6274 0 ▶ if ($tr >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tr >= 0) { } 0 0 0
6275 0 @from = ord("-");
6276 0 @to = $tr;
6277 } else { # -2 ==> delete
6278 0 $delhyphen = 1;
6279 }
6280 }
6281 0 ▶ for ($c = 0; $c < @table; $c++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c < @table) 0 0 0
6282 0 $tr = $table[$c];
6283 0 ▶ if ($tr >= 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tr >= 0) { } 0 0 0
elsif ($tr == -2) { } 0 0 0
6284 0 push @from, $c; push @to, $tr;
6285 } elsif ($tr == -2) {
6286 0 push @delfrom, $c;
6287 }
6288 }
6289 0 @from = (@from, @delfrom);
6290  
6291 0 ▶ if ($flags & OPpTRANS_COMPLEMENT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flags & 32) 0 0 0
6292 0 ▶ unless ($flags & OPpTRANS_DELETE) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($flags & 128) 0 0 0
6293 0 ▶ @to = () if ("@from" eq "@to");
Branch: 1 branch
BranchTrueFalseTotal
if join($", @from) eq join($", @to) 0 0 0
6294 }
6295  
6296 0 my @newfrom = ();
6297 0 my %from;
6298 0 @from{@from} = (1) x @from;
6299 0 ▶ for ($c = 0; $c < 256; $c++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c < 256) 0 0 0
6300 0 ▶ push @newfrom, $c unless $from{$c};
Branch: 1 branch
BranchTrueFalseTotal
unless $from{$c} 0 0 0
6301 }
6302 0 @from = @newfrom;
6303 }
6304 0 ▶ unless ($flags & OPpTRANS_DELETE || !@to) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($flags & 128 or not @to) 0 0 0
Condition0%0/3
$flags & 128 or not @to
l!l&&r!l&&!r
000
MC/DC0%0/2
$flags & 128 or not @to
$flags & 128 not @to
Truth table0%0/3
A or not(B)
A= $flags & 128B= not @to
ABresult
1X1
011
000
6305 0 ▶ pop @to while $#to and $to[$#to] == $to[$#to -1];
Branch: 1 branch
BranchTrueFalseTotal
$#to and $to[$#to] == $to[$#to - 1] and do { pop @to } 0 0 0
Condition0%0/3
$#to and $to[$#to] == $to[$#to - 1]
!ll&&!rl&&r
000
MC/DC0%0/2
$#to and $to[$#to] == $to[$#to - 1]
$#to $to[$#to] == $to[$#to - 1]
Truth table0%0/3
A and B
A= $#toB= $to[$#to] == $to[$#to - 1]
ABresult
0X0
100
111
6306 }
6307 0 my($from, $to);
6308 0 $from = collapse(@from);
6309 0 $to = collapse(@to);
6310 0 ▶ $from .= "-" if $delhyphen;
Branch: 1 branch
BranchTrueFalseTotal
if $delhyphen 0 0 0
6311 0 return ($from, $to);
6312 }
6313  
6314 my $infinity = ~0 >> 1; # IV_MAX
6315  
6316 sub tr_append_to_invlist {
6317 0 ▶ my ($list_ref, $current, $next) = @_;
Subroutine tr_append_to_invlist: not called CC=7 SCAR=40.3
Pod undocumented
6318  
6319 # Appends the range $current..$next-1 to the inversion list $list_ref
6320  
6321 0 ▶ printf STDERR "%d: %d..%d %s", __LINE__, $current, $next, Dumper $list_ref if DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 0 0
6322  
6323 0 ▶ if (@$list_ref && $list_ref->[-1] == $current) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$list_ref and $list_ref->[-1] == $current) { } 0 0 0
Condition0%0/3
@$list_ref and $list_ref->[-1] == $current
!ll&&!rl&&r
000
MC/DC0%0/2
@$list_ref and $list_ref->[-1] == $current
@$list_ref $list_ref->[-1] == $current
Truth table0%0/3
A and B
A= @$list_refB= $list_ref->[-1] == $current
ABresult
0X0
100
111
6324  
6325 # The new range extends the current final one. If it is a finite
6326 # rane, replace the current final by the new ending.
6327 0 ▶ if (defined $next) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $next) { } 0 0 0
6328 0 $list_ref->[-1] = $next;
6329 }
6330 else {
6331 # The new range extends to infinity, which means the current end
6332 # of the inversion list is dangling. Removing it causes things to
6333 # work.
6334 0 pop @$list_ref;
6335 }
6336 }
6337 else { # The new range starts after the current final one; add it as a
6338 # new range
6339 0 push @$list_ref, $current;
6340 0 ▶ push @$list_ref, $next if defined $next;
Branch: 1 branch
BranchTrueFalseTotal
if defined $next 0 0 0
6341 }
6342  
6343 0 ▶ print STDERR __LINE__, ": ", Dumper $list_ref if DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 0 0
6344 }
6345  
6346 sub tr_invlist_to_string {
6347 0 ▶ my ($list_ref, $to_complement) = @_;
Subroutine tr_invlist_to_string: not called CC=10 SCAR=47.0
Pod undocumented
6348  
6349 # Stringify the inversion list $list_ref, possibly complementing it first.
6350 # CAUTION: this can modify $list_ref.
6351  
6352 0 ▶ print STDERR __LINE__, ": ", Dumper $list_ref if DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 0 0
6353  
6354 0 ▶ if ($to_complement) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to_complement) 0 0 0
6355  
6356 # Complementing an inversion list is done by prepending a 0 if it
6357 # doesn't have one there already; otherwise removing the leading 0.
6358 0 ▶ if ($list_ref->[0] == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_ref->[0] == 0) { } 0 0 0
6359 0 shift @$list_ref;
6360 }
6361 else {
6362 0 unshift @$list_ref, 0;
6363 }
6364  
6365 0 ▶ print STDERR __LINE__, ": ", Dumper $list_ref if DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 0 0
6366 }
6367  
6368 0 my $output = "";
6369  
6370 # Every other element is in the list.
6371 0 ▶ for (my $i = 0; $i < @$list_ref; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$list_ref) 0 0 0
6372 0 my $base = $list_ref->[$i];
6373 0 $output .= pchr($base);
6374 0 ▶ last unless defined $list_ref->[$i+1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$list_ref[$i + 1] 0 0 0
6375  
6376 # The beginning of the next element starts the range of items not in
6377 # the list.
6378 0 my $upper = $list_ref->[$i+1] - 1;
6379 0 my $range = $upper - $base;
6380 0 ▶ $output .= '-' if $range > 1; # Adjacent characters don't have a
Branch: 1 branch
BranchTrueFalseTotal
if $range > 1 0 0 0
6381 # minus, though it would be legal to do
6382 # so
6383 0 ▶ $output .= pchr($upper) if $range > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $range > 0 0 0 0
6384 }
6385  
6386 0 ▶ print STDERR __LINE__, ": tr_invlist_to_string() returning '$output'\n"
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 0 0
6387 if DEBUG;
6388 0 return $output;
6389 }
6390  
6391 my $unmapped = ~0;
6392 my $special_handling = ~0 - 1;
6393  
6394 sub dump_invmap {
6395 0 ▶ my ($invlist_ref, $map_ref) = @_;
Subroutine dump_invmap: not called CC=4 SCAR=30.0
Pod undocumented
6396  
6397 0 for my $i (0 .. @$invlist_ref - 1) {
6398 0 printf STDERR "[%d]\t%x\t", $i, $invlist_ref->[$i];
6399 0 my $map = $map_ref->[$i];
6400 0 ▶ if ($map == $unmapped) {
Branch: 2 branches
BranchTrueFalseTotal
if ($map == $unmapped) { } 0 0 0
elsif ($map == $special_handling) { } 0 0 0
6401 0 print STDERR "TR_UNMAPPED\n";
6402 }
6403 elsif ($map == $special_handling) {
6404 0 print STDERR "TR_SPECIAL\n";
6405 }
6406 else {
6407 0 printf STDERR "%x\n", $map;
6408 }
6409 }
6410 }
6411  
6412 sub tr_decode_utf8 {
6413 0 ▶ my($tr_av, $flags) = @_;
Subroutine tr_decode_utf8: not called CC=15 SCAR=54.8
Pod undocumented
6414  
6415 0 ▶ printf STDERR "\n%s: %d: flags=0x%x\n", __FILE__, __LINE__, $flags if DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 0 0
6416  
6417 0 my $invlist = $tr_av->ARRAYelt(0);
6418 0 my @invlist = unpack("J*", $invlist->PV);
6419 0 my @map = unpack("J*", $tr_av->ARRAYelt(1)->PV);
6420  
6421 0 ▶ dump_invmap(\@invlist, \@map) if DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 0 0
6422  
6423 0 my @from;
6424 my @to;
6425  
6426 # Go through the whole map
6427 0 ▶ for (my $i = 0; $i < @invlist; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @invlist) 0 0 0
6428 0 my $map = $map[$i];
6429 0 ▶ printf STDERR "%d: i=%d, source=%x, map=%x\n",
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 0 0
6430 __LINE__, $i, $invlist[$i], $map if DEBUG;
6431  
6432 # Ignore any lines that are unmapped
6433 0 ▶ next if $map == $unmapped;
Branch: 1 branch
BranchTrueFalseTotal
if $map == $unmapped 0 0 0
6434  
6435 # Calculate this component of the mapping; First the lhs
6436 0 my $this_from = $invlist[$i];
6437 0 ▶ my $next_from = $invlist[$i+1] if $i < @invlist - 1;
Branch: 1 branch
BranchTrueFalseTotal
if $i < @invlist - 1 0 0 0
6438  
6439 # The length of the rhs is the same as the lhs, except when special
6440 0 ▶ my $next_map = $map - $this_from + $next_from
Branch: 1 branch
BranchTrueFalseTotal
if $map != $special_handling and defined $next_from 0 0 0
Condition0%0/3
$map != $special_handling and defined $next_from
!ll&&!rl&&r
000
MC/DC0%0/2
$map != $special_handling and defined $next_from
$map != $special_handling defined $next_from
Truth table0%0/3
A and B
A= $map != $special_handlingB= defined $next_from
ABresult
0X0
100
111
6441 if $map != $special_handling && defined $next_from;
6442  
6443 0 ▶ if (DEBUG) {
Branch: 1 branch
BranchTrueFalseTotal
if (DEBUG()) 0 0 0
6444 0 printf STDERR "%d: i=%d, from=%x, to=%x",
6445 __LINE__, $i, $this_from, $map;
6446 0 ▶ printf STDERR ", next_from=%x,", $next_from if defined $next_from;
Branch: 1 branch
BranchTrueFalseTotal
if defined $next_from 0 0 0
6447 0 ▶ printf STDERR ", next_map=%x", $next_map if defined $next_map;
Branch: 1 branch
BranchTrueFalseTotal
if defined $next_map 0 0 0
6448 0 print STDERR "\n";
6449 }
6450  
6451 # Add the lhs.
6452 0 tr_append_to_invlist(\@from, $this_from, $next_from);
6453  
6454 # And, the rhs; special handling doesn't get output as it really is an
6455 # unmatched rhs
6456 0 ▶ tr_append_to_invlist(\@to, $map, $next_map) if $map != $special_handling;
Branch: 1 branch
BranchTrueFalseTotal
if $map != $special_handling 0 0 0
6457 }
6458  
6459 # Done with the input.
6460  
6461 0 my $to;
6462 0 ▶ if (join("", @from) eq join("", @to)) {
Branch: 1 branch
BranchTrueFalseTotal
if (join('', @from) eq join('', @to)) { } 0 0 0
6463  
6464 # the rhs is suppressed if identical to the left. That's because
6465 # tr/ABC/ABC/ can be written as tr/ABC//. (Do this comparison before
6466 # any complementing)
6467 0 $to = "";
6468 }
6469 else {
6470 0 $to = tr_invlist_to_string(\@to, 0); # rhs not complemented
6471 }
6472  
6473 0 my $from = tr_invlist_to_string(\@from,
6474 ($flags & OPpTRANS_COMPLEMENT) != 0);
6475  
6476 0 ▶ print STDERR "Returning ", escape_str($from), "/",
Branch: 1 branch
BranchTrueFalseTotal
if DEBUG() 0 0 0
6477 escape_str($to), "\n" if DEBUG;
6478 0 return (escape_str($from), escape_str($to));
6479 }
6480  
6481 sub pp_trans {
6482 0 ▶ my $self = shift;
Subroutine pp_trans: not called CC=10 SCAR=47.0
Pod undocumented
6483 0 my($op, $cx, $morflags) = @_;
6484 0 my($from, $to);
6485 0 my $class = class($op);
6486 0 my $priv_flags = $op->private;
6487 0 ▶ if ($class eq "PVOP") {
Branch: 2 branches
BranchTrueFalseTotal
if ($class eq 'PVOP') { } 0 0 0
elsif ($class eq 'PADOP') { } 0 0 0
6488 0 ($from, $to) = tr_decode_byte($op->pv, $priv_flags);
6489 } elsif ($class eq "PADOP") {
6490 0 ($from, $to)
6491 = tr_decode_utf8($self->padval($op->padix), $priv_flags);
6492 } else { # class($op) eq "SVOP"
6493 0 ($from, $to) = tr_decode_utf8($op->sv, $priv_flags);
6494 }
6495 0 my $flags = "";
6496 0 ▶ $flags .= "c" if $priv_flags & OPpTRANS_COMPLEMENT;
Branch: 1 branch
BranchTrueFalseTotal
if $priv_flags & 32 0 0 0
6497 0 ▶ $flags .= "d" if $priv_flags & OPpTRANS_DELETE;
Branch: 1 branch
BranchTrueFalseTotal
if $priv_flags & 128 0 0 0
6498 0 ▶ $to = "" if $from eq $to and $flags eq "";
Branch: 1 branch
BranchTrueFalseTotal
if $from eq $to and $flags eq "" 0 0 0
Condition0%0/3
$from eq $to and $flags eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
$from eq $to and $flags eq ""
$from eq $to $flags eq ""
Truth table0%0/3
A and B
A= $from eq $toB= $flags eq ""
ABresult
0X0
100
111
6499 0 ▶ $flags .= "s" if $priv_flags & OPpTRANS_SQUASH;
Branch: 1 branch
BranchTrueFalseTotal
if $priv_flags & 8 0 0 0
6500 0 ▶ $flags .= $morflags if defined $morflags;
Branch: 1 branch
BranchTrueFalseTotal
if defined $morflags 0 0 0
6501 0 my $ret = $self->keyword("tr") . double_delim($from, $to) . $flags;
6502 0 ▶ if (my $targ = $op->targ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $targ = $op->targ) 0 0 0
6503 0 return $self->maybe_parens($self->padname($targ) . " =~ $ret",
6504 $cx, 20);
6505 }
6506 0 return $ret;
6507 }
6508  
6509 0 ▶sub pp_transr { push @_, 'r'; goto &pp_trans }
Subroutine pp_transr: not called CC=1 SCAR=6.9
Pod undocumented
6510  
6511 # Join two components of a double-quoted re, disambiguating
6512 # "${foo}bar", "${foo}{bar}", "${foo}[1]".
6513  
6514 sub re_dq_disambiguate {
6515 0 ▶ my ($first, $last) = @_;
Subroutine re_dq_disambiguate: not called CC=4 SCAR=30.0
Pod undocumented
6516 0 ▶ ($last =~ /^[A-Z\\\^\[\]_?]/ &&
Branch: 1 branch
BranchTrueFalseTotal
$last =~ /^[A-Z\\\^\[\]_?]/ and $first =~ s/([\$\@])\^$/$1{^}/ or $last =~ /^[{\[\w_]/ and $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/ 0 0 0
Condition0%0/9
$last =~ /^[A-Z\\\^\[\]_?]/ && $first =~ s/([\$\@])\^$/$1{^}/ || $last =~ /^[{\[\w_]/ && $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/
l!l&&r!l&&!r
000
$last =~ /^[A-Z\\\^\[\]_?]/ and $first =~ s/([\$\@])\^$/$1{^}/
!ll&&!rl&&r
000
$last =~ /^[{\[\w_]/ and $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/
!ll&&!rl&&r
000
MC/DC0%0/4
$last =~ /^[A-Z\\\^\[\]_?]/ && $first =~ s/([\$\@])\^$/$1{^}/ || $last =~ /^[{\[\w_]/ && $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/
$last =~ /^[A-Z\\\^\[\]_?]/ $first =~ s/([\$\@])\^$/$1{^}/ $last =~ /^[{\[\w_]/ $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/
Truth table0%0/7
A and B || C and D
A= $last =~ /^[A-Z\\\^\[\]_?]/B= $first =~ s/([\$\@])\^$/$1{^}/C= $last =~ /^[{\[\w_]/D= $first =~ s/([\$\@])([A-Za-z_]\w*)$/$1{$2}/
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
6517 $first =~ s/([\$@])\^$/${1}{^}/) # "${^}W" etc
6518 || ($last =~ /^[{\[\w_]/ &&
6519 $first =~ s/([\$@])([A-Za-z_]\w*)$/${1}{$2}/);
6520 0 return $first . $last;
6521 }
6522  
6523 # Like dq(), but different
6524 sub re_dq {
6525 0 ▶ my $self = shift;
Subroutine re_dq: not called CC=12 SCAR=50.5
Pod undocumented
6526 0 my ($op) = @_;
6527  
6528 0 my $type = $op->name;
6529 0 ▶ if ($type eq "const") {
Branch: 10 branches
BranchTrueFalseTotal
if ($type eq 'const') { } 0 0 0
elsif ($type eq 'concat') { } 0 0 0
elsif ($type eq 'multiconcat') { } 0 0 0
elsif ($type eq 'uc') { } 0 0 0
elsif ($type eq 'lc') { } 0 0 0
elsif ($type eq 'ucfirst') { } 0 0 0
elsif ($type eq 'lcfirst') { } 0 0 0
elsif ($type eq 'quotemeta') { } 0 0 0
elsif ($type eq 'fc') { } 0 0 0
elsif ($type eq 'join') { } 0 0 0
6530 0 my $unbacked = re_unback($self->const_sv($op)->as_string);
6531 0 return re_uninterp(escape_re($unbacked));
6532 } elsif ($type eq "concat") {
6533 0 my $first = $self->re_dq($op->first);
6534 0 my $last = $self->re_dq($op->last);
6535 0 return re_dq_disambiguate($first, $last);
6536 } elsif ($type eq "multiconcat") {
6537 0 return $self->do_multiconcat($op, 26, 2);
6538 } elsif ($type eq "uc") {
6539 0 return '\U' . $self->re_dq($op->first->sibling) . '\E';
6540 } elsif ($type eq "lc") {
6541 0 return '\L' . $self->re_dq($op->first->sibling) . '\E';
6542 } elsif ($type eq "ucfirst") {
6543 0 return '\u' . $self->re_dq($op->first->sibling);
6544 } elsif ($type eq "lcfirst") {
6545 0 return '\l' . $self->re_dq($op->first->sibling);
6546 } elsif ($type eq "quotemeta") {
6547 0 return '\Q' . $self->re_dq($op->first->sibling) . '\E';
6548 } elsif ($type eq "fc") {
6549 0 return '\F' . $self->re_dq($op->first->sibling) . '\E';
6550 } elsif ($type eq "join") {
6551 0 return $self->deparse($op->last, 26); # was join($", @ary)
6552 } else {
6553 0 my $ret = $self->deparse($op, 26);
6554 0 ▶ $ret =~ s/^\$([(|)])\z/\${$1}/ # $( $| $) need braces
Branch: 1 branch
BranchTrueFalseTotal
$ret =~ s/^\$([(|)])\z/\${$1}/ or $ret =~ s/^\@([-+])\z/\@{$1}/ 0 0 0
6555 or $ret =~ s/^\@([-+])\z/\@{$1}/; # @- @+ need braces
6556 0 return $ret;
6557 }
6558 }
6559  
6560 sub pure_string {
6561 0 ▶ my ($self, $op) = @_;
Subroutine pure_string: not called CC=36 SCAR=71.9
Pod undocumented
6562 0 ▶ return 0 if null $op;
Branch: 1 branch
BranchTrueFalseTotal
if null($op) 0 0 0
6563 0 my $type = $op->name;
6564  
6565 0 ▶ if ($type eq 'const' || $type eq 'av2arylen') {
Branch: 7 branches
BranchTrueFalseTotal
if ($type eq 'const' or $type eq 'av2arylen') { } 0 0 0
elsif ($type =~ /^(?:[ul]c(first)?|fc)$/ or $type eq 'quotemeta') { } 0 0 0
elsif ($type eq 'join') { } 0 0 0
elsif ($type eq 'concat') { } 0 0 0
elsif ($type eq 'multiconcat') { } 0 0 0
elsif (is_scalar($op) or $type =~ /^[ah]elem$/) { } 0 0 0
elsif ($type eq 'null' and $op->can('first') and not null($op->first)) { } 0 0 0
Condition0%0/3
$type eq "const" or $type eq "av2arylen"
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "const" or $type eq "av2arylen"
$type eq "const" $type eq "av2arylen"
Truth table0%0/3
A or B
A= $type eq "const"B= $type eq "av2arylen"
ABresult
1X1
011
000
6566 0 return 1;
6567 }
6568 ▶ elsif ($type =~ /^(?:[ul]c(first)?|fc)$/ || $type eq 'quotemeta') {
Condition0%0/3
$type =~ /^(?:[ul]c(first)?|fc)$/ or $type eq "quotemeta"
l!l&&r!l&&!r
000
MC/DC0%0/2
$type =~ /^(?:[ul]c(first)?|fc)$/ or $type eq "quotemeta"
$type =~ /^(?:[ul]c(first)?|fc)$/ $type eq "quotemeta"
Truth table0%0/3
A or B
A= $type =~ /^(?:[ul]c(first)?|fc)$/B= $type eq "quotemeta"
ABresult
1X1
011
000
6569 0 return $self->pure_string($op->first->sibling);
6570 }
6571 elsif ($type eq 'join') {
6572 0 my $join_op = $op->first->sibling; # Skip pushmark
6573 0 ▶ return 0 unless $join_op->name eq 'null' && $join_op->targ == OP_RV2SV;
Branch: 1 branch
BranchTrueFalseTotal
unless $join_op->name eq "null" and $join_op->targ == 15 0 0 0
Condition0%0/3
$join_op->name eq "null" and $join_op->targ == 15
!ll&&!rl&&r
000
MC/DC0%0/2
$join_op->name eq "null" and $join_op->targ == 15
$join_op->name eq "null" $join_op->targ == 15
Truth table0%0/3
A and B
A= $join_op->name eq "null"B= $join_op->targ == 15
ABresult
0X0
100
111
6574  
6575 0 my $gvop = $join_op->first;
6576 0 ▶ return 0 unless $gvop->name eq 'gvsv';
Branch: 1 branch
BranchTrueFalseTotal
unless $gvop->name eq "gvsv" 0 0 0
6577 0 ▶ return 0 unless '"' eq $self->gv_name($self->gv_or_padgv($gvop));
Branch: 1 branch
BranchTrueFalseTotal
unless "\"" eq $self->gv_name($self->gv_or_padgv($gvop)) 0 0 0
6578  
6579 0 ▶ return 0 unless ${$join_op->sibling} eq ${$op->last};
Branch: 1 branch
BranchTrueFalseTotal
unless ${$join_op->sibling;} eq ${$op->last;} 0 0 0
6580 0 ▶ return 0 unless $op->last->name =~ /^(?:[ah]slice|(?:rv2|pad)av)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $op->last->name =~ /^(?:[ah]slice|(?:rv2|pad)av)$/ 0 0 0
6581 }
6582 elsif ($type eq 'concat') {
6583 0 ▶ return $self->pure_string($op->first)
Condition0%0/3
$self->pure_string($op->first) && $self->pure_string($op->last)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->pure_string($op->first) && $self->pure_string($op->last)
$self->pure_string($op->first) $self->pure_string($op->last)
Truth table0%0/3
A && B
A= $self->pure_string($op->first)B= $self->pure_string($op->last)
ABresult
0X0
100
111
6584 && $self->pure_string($op->last);
6585 }
6586 elsif ($type eq 'multiconcat') {
6587 0 my ($kid, @kids);
6588 0 ▶ for ($kid = $op->first; !null $kid; $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
6589 # skip the consts and/or padsv we've optimised away
6590 0 ▶ push @kids, $kid
Branch: 1 branch
BranchTrueFalseTotal
unless $kid->type == 0 and $kid->targ == 9 || $kid->targ == 5 || $kid->targ == 3 0 0 0
Condition0%0/9
$kid->type == 0 and $kid->targ == 9 || $kid->targ == 5 || $kid->targ == 3
!ll&&!rl&&r
000
$kid->targ == 9 or $kid->targ == 5 or $kid->targ == 3
l!l&&r!l&&!r
000
$kid->targ == 9 or $kid->targ == 5
l!l&&r!l&&!r
000
MC/DC0%0/4
$kid->type == 0 and $kid->targ == 9 || $kid->targ == 5 || $kid->targ == 3
$kid->type == 0 $kid->targ == 9 $kid->targ == 5 $kid->targ == 3
Truth table0%0/5
A and B or C or D
A= $kid->type == 0B= $kid->targ == 9C= $kid->targ == 5D= $kid->targ == 3
ABCDresult
0XXX0
10000
11XX1
101X1
10011
6591 unless $kid->type == OP_NULL
6592 && ( $kid->targ == OP_PADSV
6593 || $kid->targ == OP_CONST
6594 || $kid->targ == OP_PUSHMARK);
6595 }
6596  
6597 0 ▶ if ($op->flags & OPf_STACKED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->flags & 64) 0 0 0
6598 # remove expr from @kids where 'expr = ...' or 'expr .= ....'
6599 0 ▶ if ($op->private & OPpMULTICONCAT_APPEND) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 64) { } 0 0 0
6600 0 shift(@kids);
6601 }
6602 else {
6603 0 pop(@kids);
6604 }
6605 }
6606 0 for (@kids) {
6607 0 ▶ return 0 unless $self->pure_string($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->pure_string($_) 0 0 0
6608 }
6609 0 return 1;
6610 }
6611 ▶ elsif (is_scalar($op) || $type =~ /^[ah]elem$/) {
Condition0%0/3
is_scalar($op) or $type =~ /^[ah]elem$/
l!l&&r!l&&!r
000
MC/DC0%0/2
is_scalar($op) or $type =~ /^[ah]elem$/
is_scalar($op) $type =~ /^[ah]elem$/
Truth table0%0/3
A or B
A= is_scalar($op)B= $type =~ /^[ah]elem$/
ABresult
1X1
011
000
6612 0 return 1;
6613 }
6614 ▶ elsif ($type eq "null" and $op->can('first') and not null $op->first) {
Condition0%0/6
$type eq "null" and $op->can("first") and not null($op->first)
!ll&&!rl&&r
000
$type eq "null" and $op->can("first")
!ll&&!rl&&r
000
MC/DC0%0/3
$type eq "null" and $op->can("first") and not null($op->first)
$type eq "null" $op->can("first") not null($op->first)
Truth table0%0/4
A and B and not(C)
A= $type eq "null"B= $op->can("first")C= not null($op->first)
ABCresult
0XX0
10X0
1100
1111
6615 0 my $first = $op->first;
6616  
6617 0 ▶ return 1 if $first->name eq "multideref";
Branch: 1 branch
BranchTrueFalseTotal
if $first->name eq "multideref" 0 0 0
6618 0 ▶ return 1 if $first->name eq "aelemfast_lex";
Branch: 1 branch
BranchTrueFalseTotal
if $first->name eq "aelemfast_lex" 0 0 0
6619  
6620 0 ▶ if ( $first->name eq "null"
Branch: 1 branch
BranchTrueFalseTotal
if ($first->name eq "null" and $first->can("first") and not null($first->first) and $first->first->name eq "aelemfast") 0 0 0
Condition0%0/9
$first->name eq "null" and $first->can("first") and not null($first->first) and $first->first->name eq "aelemfast"
!ll&&!rl&&r
000
$first->name eq "null" and $first->can("first") and not null($first->first)
!ll&&!rl&&r
000
$first->name eq "null" and $first->can("first")
!ll&&!rl&&r
000
MC/DC0%0/4
$first->name eq "null" and $first->can("first") and not null($first->first) and $first->first->name eq "aelemfast"
$first->name eq "null" $first->can("first") not null($first->first) $first->first->name eq "aelemfast"
Truth table0%0/5
A and B and not(C) and D
A= $first->name eq "null"B= $first->can("first")C= not null($first->first)D= $first->first->name eq "aelemfast"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
6621 and $first->can('first')
6622 and not null $first->first
6623 and $first->first->name eq "aelemfast"
6624 )
6625 {
6626 0 return 1;
6627 }
6628 }
6629  
6630 0 return 0;
6631 }
6632  
6633 sub code_list {
6634 0 ▶ my ($self,$op,$cv) = @_;
Subroutine code_list: not called CC=7 SCAR=40.3
Pod undocumented
6635  
6636 # localise stuff relating to the current sub
6637 $cv and
6638 local($self->{'curcv'}) = $cv,
6639 local($self->{'curcvlex'}),
6640 local(@$self{qw'curstash warnings hints hinthash curcop'})
6641 0 ▶ = @$self{qw'curstash warnings hints hinthash curcop'};
Branch: 1 branch
BranchTrueFalseTotal
$cv and local(local $self->{"curcv"}) = $cv, local $self->{"curcvlex"}, local(@$self{"curstash", "warnings", "hints", "hinthash", "curcop"}) = @$self{"curstash", "warnings", "hints", "hinthash", "curcop"} 0 0 0
6642  
6643 0 my $re = "";
6644 0 ▶ for ($op = $op->first->sibling; !null($op); $op = $op->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($op)) 0 0 0
6645 0 ▶ if ($op->name eq 'null' and $op->flags & OPf_SPECIAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->name eq 'null' and $op->flags & 128) { } 0 0 0
Condition0%0/3
$op->name eq "null" and $op->flags & 128
!ll&&!rl&&r
000
MC/DC0%0/2
$op->name eq "null" and $op->flags & 128
$op->name eq "null" $op->flags & 128
Truth table0%0/3
A and B
A= $op->name eq "null"B= $op->flags & 128
ABresult
0X0
100
111
6646 0 my $scope = $op->first;
6647 # 0 context (last arg to scopeop) means statement context, so
6648 # the contents of the block will not be wrapped in do{...}.
6649 0 my $block = scopeop($scope->first->name eq "enter", $self,
6650 $scope, 0);
6651 # next op is the source code of the block
6652 0 $op = $op->sibling;
6653 0 $re .= ($self->const_sv($op)->PV =~ m|^(\(\?\??\{)|)[0];
6654 0 my $multiline = $block =~ /\n/;
6655 0 ▶ $re .= $multiline ? "\n\t" : ' ';
Branch: 1 branch
BranchTrueFalseTotal
$multiline ? : 0 0 0
6656 0 $re .= $block;
6657 0 ▶ $re .= $multiline ? "\n\b})" : " })";
Branch: 1 branch
BranchTrueFalseTotal
$multiline ? : 0 0 0
6658 } else {
6659 0 $re = re_dq_disambiguate($re, $self->re_dq($op));
6660 }
6661 }
6662 0 $re;
6663 }
6664  
6665 sub regcomp {
6666 0 ▶ my $self = shift;
Subroutine regcomp: not called CC=9 SCAR=45.0
Pod undocumented
6667 0 my($op, $cx) = @_;
6668 0 my $kid = $op->first;
6669 0 ▶ $kid = $kid->first if $kid->name eq "regcmaybe";
Branch: 1 branch
BranchTrueFalseTotal
if $kid->name eq "regcmaybe" 0 0 0
6670 0 ▶ $kid = $kid->first if $kid->name eq "regcreset";
Branch: 1 branch
BranchTrueFalseTotal
if $kid->name eq "regcreset" 0 0 0
6671 0 my $kname = $kid->name;
6672 0 ▶ if ($kname eq "null" and !null($kid->first)
Branch: 1 branch
BranchTrueFalseTotal
if ($kname eq "null" and not null($kid->first) and $kid->first->name eq "pushmark") 0 0 0
Condition0%0/6
$kname eq "null" and not null($kid->first) and $kid->first->name eq "pushmark"
!ll&&!rl&&r
000
$kname eq "null" and not null($kid->first)
!ll&&!rl&&r
000
MC/DC0%0/3
$kname eq "null" and not null($kid->first) and $kid->first->name eq "pushmark"
$kname eq "null" not null($kid->first) $kid->first->name eq "pushmark"
Truth table0%0/4
A and not(B) and C
A= $kname eq "null"B= not null($kid->first)C= $kid->first->name eq "pushmark"
ABCresult
0XX0
10X0
1100
1111
6673 and $kid->first->name eq 'pushmark')
6674 {
6675 0 my $str = '';
6676 0 $kid = $kid->first->sibling;
6677 0 ▶ while (!null($kid)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
6678 0 my $first = $str;
6679 0 my $last = $self->re_dq($kid);
6680 0 $str = re_dq_disambiguate($first, $last);
6681 0 $kid = $kid->sibling;
6682 }
6683 0 return $str, 1;
6684 }
6685  
6686 0 ▶ return ($self->re_dq($kid), 1)
Branch: 1 branch
BranchTrueFalseTotal
if $kname =~ /^(?:rv2|pad)av/ or $self->pure_string($kid) 0 0 0
Condition0%0/3
$kname =~ /^(?:rv2|pad)av/ or $self->pure_string($kid)
l!l&&r!l&&!r
000
MC/DC0%0/2
$kname =~ /^(?:rv2|pad)av/ or $self->pure_string($kid)
$kname =~ /^(?:rv2|pad)av/ $self->pure_string($kid)
Truth table0%0/3
A or B
A= $kname =~ /^(?:rv2|pad)av/B= $self->pure_string($kid)
ABresult
1X1
011
000
6687 if $kname =~ /^(?:rv2|pad)av/ or $self->pure_string($kid);
6688 0 return ($self->deparse($kid, $cx), 0);
6689 }
6690  
6691 sub pp_regcomp {
6692 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_regcomp: not called CC=1 SCAR=6.9
Pod undocumented
6693 0 return (($self->regcomp($op, $cx, 0))[0]);
6694 }
6695  
6696 sub re_flags {
6697 0 ▶ my ($self, $op) = @_;
Subroutine re_flags: not called CC=19 SCAR=59.4
Pod undocumented
6698 0 my $flags = '';
6699 0 my $pmflags = $op->pmflags;
6700 0 ▶ if (!$pmflags) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pmflags) 0 0 0
6701 0 my $re = $op->pmregexp;
6702 0 ▶ if ($$re) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$re) 0 0 0
6703 0 $pmflags = $re->compflags;
6704 }
6705 }
6706 0 ▶ $flags .= "g" if $pmflags & PMf_GLOBAL;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 8388608 0 0 0
6707 0 ▶ $flags .= "i" if $pmflags & PMf_FOLD;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 4 0 0 0
6708 0 ▶ $flags .= "m" if $pmflags & PMf_MULTILINE;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 1 0 0 0
6709 0 ▶ $flags .= "o" if $pmflags & PMf_KEEP;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 4194304 0 0 0
6710 0 ▶ $flags .= "s" if $pmflags & PMf_SINGLELINE;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 2 0 0 0
6711 0 ▶ $flags .= "x" if $pmflags & PMf_EXTENDED;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 8 0 0 0
6712 0 ▶ $flags .= "x" if $pmflags & PMf_EXTENDED_MORE;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 16 0 0 0
6713 0 ▶ $flags .= "p" if $pmflags & PMf_KEEPCOPY;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 64 0 0 0
6714 0 ▶ $flags .= "n" if $pmflags & PMf_NOCAPTURE;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 32 0 0 0
6715 0 ▶ if (my $charset = $pmflags & PMf_CHARSET) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $charset = $pmflags & 896) { } 0 0 0
elsif ($self->{'hinthash'} and $self->{'hinthash'}{'reflags_charset'} || $self->{'hinthash'}{'feature_unicode'} or $self->{'hints'} & $feature::hint_mask and ($self->{'hints'} & $feature::hint_mask) != $feature::hint_mask and $self->{'hints'} & $feature::hint_uni8bit) { } 0 0 0
6716 # Hardcoding this is fragile, but B does not yet export the
6717 # constants we need.
6718 0 $flags .= qw(d l u a aa)[$charset >> 7]
6719 }
6720 # The /d flag is indicated by 0; only show it if necessary.
6721 ▶ elsif ($self->{hinthash} and
Condition0%0/15
$self->{"hinthash"} and $self->{"hinthash"}{"reflags_charset"} || $self->{"hinthash"}{"feature_unicode"} or $self->{"hints"} & $feature::hint_mask and ($self->{"hints"} & $feature::hint_mask) != $feature::hint_mask and $self->{"hints"} & $feature::hint_uni8bit
l!l&&r!l&&!r
000
$self->{"hinthash"} and $self->{"hinthash"}{"reflags_charset"} || $self->{"hinthash"}{"feature_unicode"}
!ll&&!rl&&r
000
$self->{"hinthash"}{"reflags_charset"} or $self->{"hinthash"}{"feature_unicode"}
l!l&&r!l&&!r
000
$self->{"hints"} & $feature::hint_mask and ($self->{"hints"} & $feature::hint_mask) != $feature::hint_mask and $self->{"hints"} & $feature::hint_uni8bit
!ll&&!rl&&r
000
$self->{"hints"} & $feature::hint_mask and ($self->{"hints"} & $feature::hint_mask) != $feature::hint_mask
!ll&&!rl&&r
000
MC/DC0%0/6
$self->{"hinthash"} and $self->{"hinthash"}{"reflags_charset"} || $self->{"hinthash"}{"feature_unicode"} or $self->{"hints"} & $feature::hint_mask and ($self->{"hints"} & $feature::hint_mask) != $feature::hint_mask and $self->{"hints"} & $feature::hint_uni8bit
$self->{"hinthash"} $self->{"hinthash"}{"reflags_charset"} $self->{"hinthash"}{"feature_unicode"} $self->{"hints"} & $feature::hint_mask ($self->{"hints"} & $feature::hint_mask) != $feature::hint_mask $self->{"hints"} & $feature::hint_uni8bit
Truth table0%0/10
A and B or C or D and E and F
A= $self->{"hinthash"}B= $self->{"hinthash"}{"reflags_charset"}C= $self->{"hinthash"}{"feature_unicode"}D= $self->{"hints"} & $feature::hint_maskE= ($self->{"hints"} & $feature::hint_mask) != $feature::hint_maskF= $self->{"hints"} & $feature::hint_uni8bit
ABCDEFresult
11XXXX1
101XXX1
0XX1111
1001111
0XX0XX0
0XX10X0
0XX1100
1000XX0
10010X0
1001100
6722 $self->{hinthash}{reflags_charset}
6723 || $self->{hinthash}{feature_unicode}
6724 or $self->{hints} & $feature::hint_mask
6725 && ($self->{hints} & $feature::hint_mask)
6726 != $feature::hint_mask
6727 && $self->{hints} & $feature::hint_uni8bit
6728 ) {
6729 0 $flags .= 'd';
6730 }
6731 0 $flags;
6732 }
6733  
6734 # osmic acid -- see osmium tetroxide
6735  
6736 my %matchwords;
6737 map($matchwords{join "", sort split //, $_} = $_, 'cig', 'cog', 'cos', 'cogs',
6738 'cox', 'go', 'is', 'ism', 'iso', 'mig', 'mix', 'osmic', 'ox', 'sic',
6739 'sig', 'six', 'smog', 'so', 'soc', 'sog', 'xi', 'soup', 'soupmix');
6740  
6741 # When deparsing a regular expression with code blocks, we have to look in
6742 # various places to find the blocks.
6743 #
6744 # For qr/(?{...})/ without interpolation, the CV is under $qr->qr_anoncv
6745 # and the code list (list of blocks and constants, maybe vars) is under
6746 # $cv->ROOT->first->code_list:
6747 # ./perl -Ilib -MB -e 'use O "Concise", B::svref_2object(sub {qr/(?{die})/})->ROOT->first->first->sibling->pmregexp->qr_anoncv->object_2svref'
6748 #
6749 # For qr/$a(?{...})/ with interpolation, the code list is more accessible,
6750 # under $pmop->code_list, but the $cv is something you have to dig for in
6751 # the regcomp op’s kids:
6752 # ./perl -Ilib -mO=Concise -e 'qr/$a(?{die})/'
6753 #
6754 # For m// and split //, things are much simpler. There is no CV. The code
6755 # list is under $pmop->code_list.
6756  
6757 sub matchop {
6758 0 ▶ my $self = shift;
Subroutine matchop: not called CC=27 SCAR=66.3
Pod undocumented
6759 0 my($op, $cx, $name, $delim) = @_;
6760 0 my $kid = $op->first;
6761 0 my ($binop, $var, $re) = ("", "", "");
6762 0 ▶ if ($op->name ne 'split' && $op->flags & OPf_STACKED) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->name ne 'split' and $op->flags & 64) { } 0 0 0
elsif ($op->name eq 'match' and my $targ = $op->targ) { } 0 0 0
Condition0%0/3
$op->name ne "split" and $op->flags & 64
!ll&&!rl&&r
000
MC/DC0%0/2
$op->name ne "split" and $op->flags & 64
$op->name ne "split" $op->flags & 64
Truth table0%0/3
A and B
A= $op->name ne "split"B= $op->flags & 64
ABresult
0X0
100
111
6763 0 $binop = 1;
6764 0 $var = $self->deparse($kid, 20);
6765 0 ▶ $var = "($var)"
Branch: 1 branch
BranchTrueFalseTotal
if $kid->name eq "not" and $kid->flags & 8 and not $var =~ /\(/ 0 0 0
Condition0%0/6
$kid->name eq "not" and $kid->flags & 8 and not $var =~ /\(/
!ll&&!rl&&r
000
$kid->name eq "not" and $kid->flags & 8
!ll&&!rl&&r
000
MC/DC0%0/3
$kid->name eq "not" and $kid->flags & 8 and not $var =~ /\(/
$kid->name eq "not" $kid->flags & 8 not $var =~ /\(/
Truth table0%0/4
A and B and not(C)
A= $kid->name eq "not"B= $kid->flags & 8C= not $var =~ /\(/
ABCresult
0XX0
10X0
1100
1111
6766 if $kid->name eq 'not'
6767 and $kid->flags & OPf_PARENS
6768 and $var !~ /\(/;
6769 0 $kid = $kid->sibling;
6770 }
6771 # not $name; $name will be 'm' for both match and split
6772 ▶ elsif ($op->name eq 'match' and my $targ = $op->targ) {
Condition0%0/3
$op->name eq "match" and my $targ = $op->targ
!ll&&!rl&&r
000
MC/DC0%0/2
$op->name eq "match" and my $targ = $op->targ
$op->name eq "match" my $targ = $op->targ
Truth table0%0/3
A and B
A= $op->name eq "match"B= my $targ = $op->targ
ABresult
0X0
100
111
6773 0 $binop = 1;
6774 0 $var = $self->padname($targ);
6775 }
6776 0 my $quote = 1;
6777 0 my $pmflags = $op->pmflags;
6778 0 my $rhs_bound_to_defsv;
6779 0 my ($cv, $bregexp);
6780 0 my $have_kid = !null $kid;
6781 # Check for code blocks first
6782 0 ▶ if (not null my $code_list = $op->code_list) {
Branch: 4 branches
BranchTrueFalseTotal
if (not null(my $code_list = $op->code_list)) { } 0 0 0
elsif (${$bregexp = $op->pmregexp;} and ${$cv = $bregexp->qr_anoncv;}) { } 0 0 0
elsif (not $have_kid) { } 0 0 0
elsif ($kid->name ne 'regcomp') { } 0 0 0
6783 0 ▶ $re = $self->code_list($code_list,
Branch: 1 branch
BranchTrueFalseTotal
$op->name eq 'qr' ? : 0 0 0
6784 $op->name eq 'qr'
6785 ? $self->padval(
6786 $kid->first # ex-list
6787 ->first # pushmark
6788 ->sibling # entersub
6789 ->first # ex-list
6790 ->first # pushmark
6791 ->sibling # anoncode
6792 ->targ
6793 )
6794 : undef);
6795 0 ▶ } elsif (${$bregexp = $op->pmregexp} && ${$cv = $bregexp->qr_anoncv}) {
Condition0%0/3
${$bregexp = $op->pmregexp;} and ${$cv = $bregexp->qr_anoncv;}
!ll&&!rl&&r
000
MC/DC0%0/2
${$bregexp = $op->pmregexp;} and ${$cv = $bregexp->qr_anoncv;}
${$bregexp = $op->pmregexp;} ${$cv = $bregexp->qr_anoncv;}
Truth table0%0/3
A and B
A= ${$bregexp = $op->pmregexp;}B= ${$cv = $bregexp->qr_anoncv;}
ABresult
0X0
100
111
6796 0 my $patop = $cv->ROOT # leavesub
6797 ->first # qr
6798 ->code_list;# list
6799 0 $re = $self->code_list($patop, $cv);
6800 } elsif (!$have_kid) {
6801 0 $re = re_uninterp(escape_re(re_unback($op->precomp)));
6802 } elsif ($kid->name ne 'regcomp') {
6803 0 ▶ if ($op->name eq 'split') {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->name eq 'split') { } 0 0 0
6804 # split has other kids, not just regcomp
6805 0 $re = re_uninterp(escape_re(re_unback($op->precomp)));
6806 }
6807 else {
6808 0 carp("found ".$kid->name." where regcomp expected");
6809 }
6810 } else {
6811 0 ($re, $quote) = $self->regcomp($kid, 21);
6812 }
6813 0 ▶ if ($have_kid and $kid->name eq 'regcomp') {
Branch: 1 branch
BranchTrueFalseTotal
if ($have_kid and $kid->name eq "regcomp") 0 0 0
Condition0%0/3
$have_kid and $kid->name eq "regcomp"
!ll&&!rl&&r
000
MC/DC0%0/2
$have_kid and $kid->name eq "regcomp"
$have_kid $kid->name eq "regcomp"
Truth table0%0/3
A and B
A= $have_kidB= $kid->name eq "regcomp"
ABresult
0X0
100
111
6814 0 my $matchop = $kid->first;
6815 0 ▶ if ($matchop->name eq 'regcreset') {
Branch: 1 branch
BranchTrueFalseTotal
if ($matchop->name eq "regcreset") 0 0 0
6816 0 $matchop = $matchop->first;
6817 }
6818 0 ▶ if ($matchop->name =~ /^(?:match|transr?|subst)\z/
Branch: 1 branch
BranchTrueFalseTotal
if ($matchop->name =~ /^(?:match|transr?|subst)\z/ and $matchop->flags & 128) 0 0 0
Condition0%0/3
$matchop->name =~ /^(?:match|transr?|subst)\z/ and $matchop->flags & 128
!ll&&!rl&&r
000
MC/DC0%0/2
$matchop->name =~ /^(?:match|transr?|subst)\z/ and $matchop->flags & 128
$matchop->name =~ /^(?:match|transr?|subst)\z/ $matchop->flags & 128
Truth table0%0/3
A and B
A= $matchop->name =~ /^(?:match|transr?|subst)\z/B= $matchop->flags & 128
ABresult
0X0
100
111
6819 && $matchop->flags & OPf_SPECIAL) {
6820 0 $rhs_bound_to_defsv = 1;
6821 }
6822 }
6823 0 my $flags = "";
6824 0 ▶ $flags .= "c" if $pmflags & PMf_CONTINUE;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 16777216 0 0 0
6825 0 $flags .= $self->re_flags($op);
6826 0 $flags = join '', sort split //, $flags;
6827 0 ▶ $flags = $matchwords{$flags} if $matchwords{$flags};
Branch: 1 branch
BranchTrueFalseTotal
if $matchwords{$flags} 0 0 0
6828 0 ▶ if ($pmflags & PMf_ONCE) { # only one kind of delimiter works here
Branch: 2 branches
BranchTrueFalseTotal
if ($pmflags & 524288) { } 0 0 0
elsif ($quote) { } 0 0 0
6829 0 $re =~ s/\?/\\?/g;
6830 0 $re = $self->keyword("m") . "?$re?"; # explicit 'm' is required
6831 } elsif ($quote) {
6832 0 $re = single_delim($name, $delim, $re, $self);
6833 }
6834 0 ▶ $re = $re . $flags if $quote;
Branch: 1 branch
BranchTrueFalseTotal
if $quote 0 0 0
6835 0 ▶ if ($binop) {
Branch: 1 branch
BranchTrueFalseTotal
if ($binop) { } 0 0 0
6836 return
6837 0 ▶ $self->maybe_parens(
Branch: 1 branch
BranchTrueFalseTotal
$rhs_bound_to_defsv ? : 0 0 0
6838 $rhs_bound_to_defsv
6839 ? "$var =~ (\$_ =~ $re)"
6840 : "$var =~ $re",
6841 $cx, 20
6842 );
6843 } else {
6844 0 return $re;
6845 }
6846 }
6847  
6848 0 ▶sub pp_match { matchop(@_, "m", "/") }
Subroutine pp_match: not called CC=1 SCAR=6.9
Pod undocumented
6849 0 ▶sub pp_qr { matchop(@_, "qr", "") }
Subroutine pp_qr: not called CC=1 SCAR=6.9
Pod undocumented
6850  
6851 0 ▶sub pp_runcv { unop(@_, "__SUB__"); }
Subroutine pp_runcv: not called CC=1 SCAR=6.9
Pod undocumented
6852  
6853 sub pp_split {
6854 0 ▶ my $self = shift;
Subroutine pp_split: not called CC=12 SCAR=50.5
Pod undocumented
6855 0 my($op, $cx) = @_;
6856 0 my($kid, @exprs, $ary, $expr);
6857 0 my $stacked = $op->flags & OPf_STACKED;
6858  
6859 0 $kid = $op->first;
6860 0 ▶ $kid = $kid->sibling if $kid->name eq 'regcomp';
Branch: 1 branch
BranchTrueFalseTotal
if $kid->name eq "regcomp" 0 0 0
6861 0 ▶ for (; !null($kid); $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
unless (null($kid)) 0 0 0
6862 0 push @exprs, $self->deparse($kid, 6);
6863 }
6864  
6865 0 unshift @exprs, $self->matchop($op, $cx, "m", "/");
6866  
6867 0 ▶ if ($op->private & OPpSPLIT_ASSIGN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 16) 0 0 0
6868 # With C<@array = split(/pat/, str);>,
6869 # array is stored in split's pmreplroot; either
6870 # as an integer index into the pad (for a lexical array)
6871 # or as GV for a package array (which will be a pad index
6872 # on threaded builds)
6873 # With my/our @array = split(/pat/, str), the array is instead
6874 # accessed via an extra padav/rv2av op at the end of the
6875 # split's kid ops.
6876  
6877 0 ▶ if ($stacked) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stacked) { } 0 0 0
6878 0 $ary = pop @exprs;
6879 }
6880 else {
6881 0 ▶ if ($op->private & OPpSPLIT_LEX) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 8) { } 0 0 0
6882 0 $ary = $self->padname($op->pmreplroot);
6883 }
6884 else {
6885 # union with op_pmtargetoff, op_pmtargetgv
6886 0 my $gv = $op->pmreplroot;
6887 0 ▶ $gv = $self->padval($gv) if !ref($gv);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $gv 0 0 0
6888 0 $ary = $self->maybe_local(@_,
6889 $self->stash_variable('@',
6890 $self->gv_name($gv),
6891 $cx))
6892 }
6893 0 ▶ if ($op->private & OPpLVAL_INTRO) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->private & 128) 0 0 0
6894 0 ▶ $ary = $op->private & OPpSPLIT_LEX ? "my $ary" : "local $ary";
Branch: 1 branch
BranchTrueFalseTotal
$op->private & 8 ? : 0 0 0
6895 }
6896 }
6897 }
6898  
6899 # handle special case of split(), and split(' ') that compiles to /\s+/
6900 0 ▶ $exprs[0] = q{' '} if ($op->reflags // 0) & RXf_SKIPWHITE();
Branch: 1 branch
BranchTrueFalseTotal
if ($op->reflags // 0) & 536870912 0 0 0
Condition0%0/2
$op->reflags // 0
l!l
00
MC/DC0%0/1
$op->reflags // 0
$op->reflags
Truth table0%0/2
A
A= $op->reflags
Aresult
11
00
6901  
6902 0 $expr = "split(" . join(", ", @exprs) . ")";
6903 0 ▶ if ($ary) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ary) { } 0 0 0
6904 0 return $self->maybe_parens("$ary = $expr", $cx, 7);
6905 } else {
6906 0 return $expr;
6907 }
6908 }
6909  
6910 # oxime -- any of various compounds obtained chiefly by the action of
6911 # hydroxylamine on aldehydes and ketones and characterized by the
6912 # bivalent grouping C=NOH [Webster's Tenth]
6913  
6914 my %substwords;
6915 map($substwords{join "", sort split //, $_} = $_, 'ego', 'egoism', 'em',
6916 'es', 'ex', 'exes', 'gee', 'go', 'goes', 'ie', 'ism', 'iso', 'me',
6917 'meese', 'meso', 'mig', 'mix', 'os', 'ox', 'oxime', 'see', 'seem',
6918 'seg', 'sex', 'sig', 'six', 'smog', 'sog', 'some', 'xi', 'rogue',
6919 'sir', 'rise', 'smore', 'more', 'seer', 'rome', 'gore', 'grim', 'grime',
6920 'or', 'rose', 'rosie');
6921  
6922 sub pp_subst {
6923 0 ▶ my $self = shift;
Subroutine pp_subst: not called CC=15 SCAR=54.8
Pod undocumented
6924 0 my($op, $cx) = @_;
6925 0 my $kid = $op->first;
6926 0 my($binop, $var, $re, $repl) = ("", "", "", "");
6927 0 ▶ if ($op->flags & OPf_STACKED) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->flags & 64) { } 0 0 0
elsif (my $targ = $op->targ) { } 0 0 0
6928 0 $binop = 1;
6929 0 $var = $self->deparse($kid, 20);
6930 0 ▶ $var = "($var)"
Branch: 1 branch
BranchTrueFalseTotal
if $kid->name eq "not" and $kid->flags & 8 and not $var =~ /\(/ 0 0 0
Condition0%0/6
$kid->name eq "not" and $kid->flags & 8 and not $var =~ /\(/
!ll&&!rl&&r
000
$kid->name eq "not" and $kid->flags & 8
!ll&&!rl&&r
000
MC/DC0%0/3
$kid->name eq "not" and $kid->flags & 8 and not $var =~ /\(/
$kid->name eq "not" $kid->flags & 8 not $var =~ /\(/
Truth table0%0/4
A and B and not(C)
A= $kid->name eq "not"B= $kid->flags & 8C= not $var =~ /\(/
ABCresult
0XX0
10X0
1100
1111
6931 if $kid->name eq 'not'
6932 and $kid->flags & OPf_PARENS
6933 and $var !~ /\(/;
6934 0 $kid = $kid->sibling;
6935 }
6936 elsif (my $targ = $op->targ) {
6937 0 $binop = 1;
6938 0 $var = $self->padname($targ);
6939 }
6940 0 my $flags = "";
6941 0 my $pmflags = $op->pmflags;
6942 0 ▶ if (null($op->pmreplroot)) {
Branch: 1 branch
BranchTrueFalseTotal
if (null($op->pmreplroot)) { } 0 0 0
6943 0 $repl = $kid;
6944 0 $kid = $kid->sibling;
6945 } else {
6946 0 $repl = $op->pmreplroot->first; # skip substcont
6947 }
6948 0 ▶ while ($repl->name eq "entereval") {
Branch: 1 branch
BranchTrueFalseTotal
if ($repl->name eq "entereval") 0 0 0
6949 0 $repl = $repl->first;
6950 0 $flags .= "e";
6951 }
6952 {
6953 0 local $self->{in_subst_repl} = 1;
6954 0 ▶ if ($pmflags & PMf_EVAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pmflags & 33554432) { } 0 0 0
6955 0 $repl = $self->deparse($repl->first, 0);
6956 } else {
6957 0 $repl = $self->dq($repl);
6958 }
6959 }
6960 0 ▶ if (not null my $code_list = $op->code_list) {
Branch: 2 branches
BranchTrueFalseTotal
if (not null(my $code_list = $op->code_list)) { } 0 0 0
elsif (null($kid)) { } 0 0 0
6961 0 $re = $self->code_list($code_list);
6962 } elsif (null $kid) {
6963 0 $re = re_uninterp(escape_re(re_unback($op->precomp)));
6964 } else {
6965 0 ($re) = $self->regcomp($kid, 1);
6966 }
6967 0 ▶ $flags .= "r" if $pmflags & PMf_NONDESTRUCT;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 67108864 0 0 0
6968 0 ▶ $flags .= "e" if $pmflags & PMf_EVAL;
Branch: 1 branch
BranchTrueFalseTotal
if $pmflags & 33554432 0 0 0
6969 0 $flags .= $self->re_flags($op);
6970 0 $flags = join '', sort split //, $flags;
6971 0 ▶ $flags = $substwords{$flags} if $substwords{$flags};
Branch: 1 branch
BranchTrueFalseTotal
if $substwords{$flags} 0 0 0
6972 0 my $core_s = $self->keyword("s"); # maybe CORE::s
6973 0 ▶ if ($binop) {
Branch: 1 branch
BranchTrueFalseTotal
if ($binop) { } 0 0 0
6974 0 return $self->maybe_parens("$var =~ $core_s"
6975 . double_delim($re, $repl) . $flags,
6976 $cx, 20);
6977 } else {
6978 0 return "$core_s". double_delim($re, $repl) . $flags;
6979 }
6980 }
6981  
6982 sub is_lexical_subs {
6983 0 ▶ my (@ops) = @_;
Subroutine is_lexical_subs: not called CC=3 SCAR=24.8
Pod undocumented
6984 0 for my $op (@ops) {
6985 0 ▶ return 0 if $op->name !~ /\A(?:introcv|clonecv)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $op->name =~ /\A(?:introcv|clonecv)\z/ 0 0 0
6986 }
6987 0 return 1;
6988 }
6989  
6990 # Pretend these two ops do not exist. The perl parser adds them to the
6991 # beginning of any block containing my-sub declarations, whereas we handle
6992 # the subs in pad_subs and next_todo.
6993 *pp_clonecv = *pp_introcv;
6994 sub pp_introcv {
6995 0 ▶ my $self = shift;
Subroutine pp_introcv: not called CC=1 SCAR=6.9
Pod undocumented
6996 0 my($op, $cx) = @_;
6997 # For now, deparsing doesn't worry about the distinction between introcv
6998 # and clonecv, so pretend this op doesn't exist:
6999 0 return '';
7000 }
7001  
7002 sub pp_padcv {
7003 0 ▶ my $self = shift;
Subroutine pp_padcv: not called CC=1 SCAR=6.9
Pod undocumented
7004 0 my($op, $cx) = @_;
7005 0 return $self->padany($op);
7006 }
7007  
7008 my %lvref_funnies = (
7009 OPpLVREF_SV, => '$',
7010 OPpLVREF_AV, => '@',
7011 OPpLVREF_HV, => '%',
7012 OPpLVREF_CV, => '&',
7013 );
7014  
7015 sub pp_refassign {
7016 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_refassign: not called CC=4 SCAR=30.0
Pod undocumented
7017 0 my $left;
7018 0 ▶ if ($op->private & OPpLVREF_ELEM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->private & 4) { } 0 0 0
elsif ($op->flags & 64) { } 0 0 0
7019 0 $left = $op->first->sibling;
7020 0 ▶ $left = maybe_local(@_, elem($self, $left, undef,
Branch: 1 branch
BranchTrueFalseTotal
$left->targ == 141 ? : 0 0 0
7021 $left->targ == OP_AELEM
7022 ? qw([ ] padav)
7023 : qw({ } padhv)));
7024 } elsif ($op->flags & OPf_STACKED) {
7025 $left = maybe_local(@_,
7026 0 $lvref_funnies{$op->private & OPpLVREF_TYPE}
7027 . $self->deparse($op->first->sibling));
7028 } else {
7029 0 $left = &pp_padsv;
7030 }
7031 0 my $right = $self->deparse_binop_right($op, $op->first, 7);
7032 0 return $self->maybe_parens("\\$left = $right", $cx, 7);
7033 }
7034  
7035 sub pp_lvref {
7036 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_lvref: not called CC=4 SCAR=30.0
Pod undocumented
7037 0 my $code;
7038 0 ▶ if ($op->private & OPpLVREF_ELEM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->private & 4) { } 0 0 0
elsif ($op->flags & 64) { } 0 0 0
7039 0 ▶ $code = $op->first->name =~ /av\z/ ? &pp_aelem : &pp_helem;
Branch: 1 branch
BranchTrueFalseTotal
$op->first->name =~ /av\z/ ? : 0 0 0
7040 } elsif ($op->flags & OPf_STACKED) {
7041 $code = maybe_local(@_,
7042 0 $lvref_funnies{$op->private & OPpLVREF_TYPE}
7043 . $self->deparse($op->first));
7044 } else {
7045 0 $code = &pp_padsv;
7046 }
7047 0 "\\$code";
7048 }
7049  
7050 sub pp_lvrefslice {
7051 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_lvrefslice: not called CC=2 SCAR=17.9
Pod undocumented
7052 0 ▶ '\\' . ($op->last->name =~ /av\z/ ? &pp_aslice : &pp_hslice);
Branch: 1 branch
BranchTrueFalseTotal
$op->last->name =~ /av\z/ ? : 0 0 0
7053 }
7054  
7055 sub pp_lvavref {
7056 0 ▶ my ($self, $op, $cx) = @_;
Subroutine pp_lvavref: not called CC=2 SCAR=17.9
Pod undocumented
7057 0 ▶ '\\(' . ($op->flags & OPf_STACKED
Branch: 1 branch
BranchTrueFalseTotal
$op->flags & 64 ? : 0 0 0
7058 ? maybe_local(@_, rv2x(@_, "\@"))
7059 : &pp_padsv) . ')'
7060 }
7061  
7062  
7063 sub pp_argcheck {
7064 0 ▶ my $self = shift;
Subroutine pp_argcheck: not called CC=5 SCAR=34.0
Pod undocumented
7065 0 my($op, $cx) = @_;
7066 0 my ($params, $opt_params, $slurpy) = $op->aux_list($self->{curcv});
7067 0 my $mandatory = $params - $opt_params;
7068 0 my $check = '';
7069  
7070 0 ▶ $check .= <<EOF if !$slurpy;
Branch: 1 branch
BranchTrueFalseTotal
unless $slurpy 0 0 0
7071 die sprintf("Too many arguments for subroutine at %s line %d.\\n", (caller)[1, 2]) unless \@_ <= $params;
7072 EOF
7073  
7074 0 ▶ $check .= <<EOF if $mandatory > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $mandatory > 0 0 0 0
7075 die sprintf("Too few arguments for subroutine at %s line %d.\\n", (caller)[1, 2]) unless \@_ >= $mandatory;
7076 EOF
7077  
7078 0 ▶ my $cond = ($params & 1) ? 'unless' : 'if';
Branch: 1 branch
BranchTrueFalseTotal
$params & 1 ? : 0 0 0
7079 0 ▶ $check .= <<EOF if $slurpy eq '%';
Branch: 1 branch
BranchTrueFalseTotal
if $slurpy eq "%" 0 0 0
7080 die sprintf("Odd name/value argument for subroutine at %s line %d.\\n", (caller)[1, 2]) if \@_ > $params && ((\@_ - $params) & 1);
7081 EOF
7082  
7083 0 $check =~ s/;\n\z//;
7084 0 return $check;
7085 }
7086  
7087  
7088 sub pp_argelem {
7089 0 ▶ my $self = shift;
Subroutine pp_argelem: not called CC=4 SCAR=30.0
Pod undocumented
7090 0 my($op, $cx) = @_;
7091 0 my $var = $self->padname($op->targ);
7092 0 my $ix = $op->string($self->{curcv});
7093 0 my $expr;
7094 0 ▶ if ($op->flags & OPf_KIDS) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->flags & 4) { } 0 0 0
elsif ($var =~ /^[\@%]/) { } 0 0 0
7095 0 $expr = $self->deparse($op->first, 7);
7096 }
7097 elsif ($var =~ /^[@%]/) {
7098 0 ▶ $expr = $ix ? "\@_[$ix .. \$#_]" : '@_';
Branch: 1 branch
BranchTrueFalseTotal
$ix ? : 0 0 0
7099 }
7100 else {
7101 0 $expr = "\$_[$ix]";
7102 }
7103 0 return "my $var = $expr";
7104 }
7105  
7106  
7107 sub pp_argdefelem {
7108 0 ▶ my $self = shift;
Subroutine pp_argdefelem: not called CC=2 SCAR=17.9
Pod undocumented
7109 0 my($op, $cx) = @_;
7110 0 my $ix = $op->targ;
7111 0 my $expr = "\@_ >= " . ($ix+1) . " ? \$_[$ix] : ";
7112 0 my $def = $self->deparse($op->first, 7);
7113 0 ▶ $def = "($def)" if $op->first->flags & OPf_PARENS;
Branch: 1 branch
BranchTrueFalseTotal
if $op->first->flags & 8 0 0 0
7114 0 $expr .= $self->deparse($op->first, $cx);
7115 0 return $expr;
7116 }
7117  
7118  
7119 sub pp_multiparam {
7120 0 ▶ die "Unable to handle PP_MULTIPARAM outside of a regular subroutine signature position";
Subroutine pp_multiparam: not called CC=1 SCAR=6.9
Pod undocumented
7121 }
7122  
7123  
7124 sub pp_pushdefer {
7125 0 ▶ my $self = shift;
Subroutine pp_pushdefer: not called CC=1 SCAR=6.9
Pod undocumented
7126 0 my($op, $cx) = @_;
7127 # defer block body is stored in the ->first of an OP_NULL that is
7128 # ->first of OP_PUSHDEFER
7129 0 my $body = $self->deparse($op->first->first);
7130 0 return "defer {\n\t$body\n\b}\cK";
7131 }
7132  
7133 sub builtin1 {
7134 0 ▶ my $self = shift;
Subroutine builtin1: not called CC=1 SCAR=6.9
Pod undocumented
7135 0 my ($op, $cx, $name) = @_;
7136 0 my $arg = $self->deparse($op->first, 6);
7137 # TODO: work out if lexical alias is present somehow...
7138 0 return "builtin::$name($arg)";
7139 }
7140  
7141 0 ▶sub pp_is_bool { builtin1(@_, "is_bool"); }
Subroutine pp_is_bool: not called CC=1 SCAR=6.9
Pod undocumented
7142 0 ▶sub pp_is_weak { builtin1(@_, "is_weak"); }
Subroutine pp_is_weak: not called CC=1 SCAR=6.9
Pod undocumented
7143 0 ▶sub pp_weaken { builtin1(@_, "weaken"); }
Subroutine pp_weaken: not called CC=1 SCAR=6.9
Pod undocumented
7144 0 ▶sub pp_unweaken { builtin1(@_, "unweaken"); }
Subroutine pp_unweaken: not called CC=1 SCAR=6.9
Pod undocumented
7145 0 ▶sub pp_blessed { builtin1(@_, "blessed"); }
Subroutine pp_blessed: not called CC=1 SCAR=6.9
Pod undocumented
7146 0 ▶sub pp_refaddr { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "refaddr"); }
Subroutine pp_refaddr: not called CC=1 SCAR=6.9
Pod undocumented
7147 0 ▶sub pp_reftype { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "reftype"); }
Subroutine pp_reftype: not called CC=1 SCAR=6.9
Pod undocumented
7148 0 ▶sub pp_ceil { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "ceil"); }
Subroutine pp_ceil: not called CC=1 SCAR=6.9
Pod undocumented
7149 0 ▶sub pp_floor { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "floor"); }
Subroutine pp_floor: not called CC=1 SCAR=6.9
Pod undocumented
7150 0 ▶sub pp_is_tainted { builtin1(@_, "is_tainted"); }
Subroutine pp_is_tainted: not called CC=1 SCAR=6.9
Pod undocumented
7151  
7152 1;
7153 __END__
« /usr/local/lib/perl5/5.44.0/Exporter.pm ↑ Summary /usr/local/lib/perl5/5.44.0/warnings.pm »