blib/lib/B/DeparseTree/P518.pm untested

filter: Statementstmt 0.0% 0 / 363 Branchbran 0.0% 0 / 156 Conditioncond 0.0% 0 / 123 MC/DCmcdc 0.0% 0 / 70 Subroutinesub 0.0% 0 / 36 Podpod 0.0% 0 / 23 totaltotal 0.0% 0 / 771 CC 79 SCAR 47.0
CC
79
Cov
0%
check_proto
342.0
pure_string
182.0
re_dq
156.0
CRAP 109.6
1 # B::DeparseTree::P518.pm
2 # Copyright (c) 1998-2000, 2002, 2003, 2004, 2005, 2006 Stephen McCamant.
3 # Copyright (c) 2015, 2018 Rocky Bernstein
4 # All rights reserved.
5 # This module is free software; you can redistribute and/or modify
6 # it under the same terms as Perl itself.
7  
8 # This is based on the module B::Deparse (for perl 5.20) by Stephen McCamant.
9 # It has been extended save tree structure, and is addressible
10 # by opcode address.
11  
12 # B::Parse in turn is based on the module of the same name by Malcolm Beattie,
13 # but essentially none of his code remains.
14  
15 use rlib '../..';
16  
17 package B::DeparseTree::P518;
18 use Carp;
19 use B qw(class opnumber
20 OPf_KIDS OPf_REF OPf_STACKED OPf_SPECIAL OPf_MOD
21 OPpLVAL_INTRO OPpOUR_INTRO OPpENTERSUB_AMPER OPpSLICE OPpCONST_BARE
22 PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE
23 SVpad_OUR SVf_FAKE SVs_RMG SVs_SMG
24 PMf_MULTILINE PMf_SINGLELINE PMf_FOLD PMf_EXTENDED);
25  
26 use B::DeparseTree::PPfns;
27 use B::DeparseTree::SyntaxTree;
28 use B::DeparseTree::PP;
29 use B::Deparse;
30  
31 # Copy unchanged functions from B::Deparse
32 *begin_is_use = *B::Deparse::begin_is_use;
33 *const_sv = *B::Deparse::const_sv;
34 *escape_extended_re = *B::Deparse::escape_extended_re;
35 *find_our_type = *B::Deparse::find_our_type;
36 *find_scope_en = *B::Deparse::find_scope_en;
37 *gv_name = *B::Deparse::gv_name;
38 *padany = *B::Deparse::padany;
39 *padname = *B::Deparse::padname;
40 *padname_sv = *B::Deparse::padname_sv;
41 *padval = *B::Deparse::padval;
42 *populate_curcvlex = *B::Deparse::populate_curcvlex;
43 *re_flags = *B::Deparse::re_flags;
44 *rv2gv_or_string = *B::Deparse::rv2gv_or_string;
45 *stash_variable = *B::Deparse::stash_variable;
46 *tr_chr = *B::Deparse::tr_chr;
47  
48 use strict;
49 use vars qw/$AUTOLOAD/;
50 use warnings ();
51 require feature;
52  
53 our(@EXPORT, @ISA);
54 our $VERSION = '3.2.0';
55  
56 @ISA = qw(Exporter);
57  
58 BEGIN {
59 # List version-specific constants here.
60 # Easiest way to keep this code portable between version looks to
61 # be to fake up a dummy constant that will never actually be true.
62 foreach (qw(OPpSORT_INPLACE OPpSORT_DESCEND OPpITER_REVERSED OPpCONST_NOVER
63 OPpPAD_STATE PMf_SKIPWHITE RXf_SKIPWHITE
64 RXf_PMf_CHARSET RXf_PMf_KEEPCOPY
65 CVf_LOCKED OPpREVERSE_INPLACE OPpSUBSTR_REPL_FIRST
66 PMf_NONDESTRUCT OPpCONST_ARYBASE OPpEVAL_BYTES)) {
67 eval { import B $_ };
68 no strict 'refs';
69 *{$_} = sub () {0} unless *{$_}{CODE};
70 }
71 }
72  
73 BEGIN { for (qw[rv2sv]) {
74 eval "sub OP_\U$_ () { " . opnumber($_) . "}"
75 }}
76  
77 # The following OPs don't have functions:
78  
79 # pp_padany -- does not exist after parsing
80  
81 sub AUTOLOAD {
82 if ($AUTOLOAD =~ s/^.*::pp_//) {
83 warn "unexpected OP_".uc $AUTOLOAD;
84 } else {
85 Carp::confess "Undefined subroutine $AUTOLOAD called";
86 }
87 }
88  
89 sub DESTROY {} # Do not AUTOLOAD
90  
91 # The BEGIN {} is used here because otherwise this code isn't executed
92 # when you run B::Deparse on itself.
93 my %globalnames;
94 BEGIN { map($globalnames{$_}++, "SIG", "STDIN", "STDOUT", "STDERR", "INC",
95 "ENV", "ARGV", "ARGVOUT", "_"); }
96  
97 my %feature_keywords = (
98 # keyword => 'feature',
99 state => 'state',
100 say => 'say',
101 given => 'switch',
102 when => 'switch',
103 default => 'switch',
104 break => 'switch',
105 evalbytes=>'evalbytes',
106 __SUB__ => '__SUB__',
107 fc => 'fc',
108 );
109  
110 # keywords that are strong and also have a prototype
111 #
112 my %strong_proto_keywords = map { $_ => 1 } qw(
113 pos
114 prototype
115 scalar
116 study
117 undef
118 );
119  
120 # stash_variable_name is modified from B::Deparse Perl version 5.18. Perl 5.14 doesn't
121 # have this.
122  
123 # Return just the name, without the prefix. It may be returned as a quoted
124 # string. The second return value is a boolean indicating that.
125 sub stash_variable_name {
126 my($self, $prefix, $gv) = @_;
127 my $name = $self->gv_name($gv, 1);
128 $name = $self->maybe_qualify($prefix,$name);
129 if ($name =~ /^(?:\S|(?!\d)[\ca-\cz]?(?:\w|::)*|\d+)\z/) {
130 $name =~ s/^([\ca-\cz])/'^'.($1|'@')/e;
131 $name =~ /^(\^..|{)/ and $name = "{$name}";
132 return $name, 0; # not quoted
133 }
134 else {
135 $self->single_delim(undef, "q", "'", $name), 1; # quoted
136 }
137 }
138  
139  
140  
141 # FIXME: These we don't seem to be able to put in a table.
142 sub pp_closedir { unop(@_, "closedir") }
143  
144 # NOTE: This is the deparse 5.26 routine which
145 # differs from 5.18 in that adds CORE:: when
146 # appropriate.
147 sub keyword {
148 my $self = shift;
149 my $name = shift;
150 return $name if $name =~ /^CORE::/; # just in case
151 if (exists $feature_keywords{$name}) {
152 my $hh;
153 my $hints = $self->{hints} & $feature::hint_mask;
154 if ($hints && $hints != $feature::hint_mask) {
155 $hh = B::Deparse::_features_from_bundle($hints);
156 }
157 elsif ($hints) { $hh = $self->{'hinthash'} }
158 return "CORE::$name"
159 if !$hh
160 || !$hh->{"feature_$feature_keywords{$name}"}
161 }
162 if ($strong_proto_keywords{$name}
163 || ($name !~ /^(?:chom?p|do|exec|glob|s(?:elect|ystem))\z/
164 && !defined eval{prototype "CORE::$name"})
165 ) { return $name }
166 if (
167 exists $self->{subs_declared}{$name}
168 or
169 exists &{"$self->{curstash}::$name"}
170 ) {
171 return "CORE::$name"
172 }
173 return $name;
174 }
175  
176 { no strict 'refs'; *{"pp_r$_"} = *{"pp_$_"} for qw< keys each values >; }
177  
178 my @threadsv_names = B::threadsv_names;
179 sub pp_threadsv {
180 my $self = shift;
181 my($op, $cx) = @_;
182 return $self->maybe_local_str($op, $cx, "\$" . $threadsv_names[$op->targ]);
183 }
184  
185 sub pp_rv2sv { maybe_local(@_, rv2x(@_, "\$")) }
186 sub pp_rv2hv { maybe_local(@_, rv2x(@_, "%")) }
187 sub pp_rv2gv { maybe_local(@_, rv2x(@_, "*")) }
188  
189 # skip rv2av
190 sub pp_av2arylen {
191 my $self = shift;
192 my($op, $cx) = @_;
193 if ($op->first->name eq "padav") {
194 return $self->maybe_local_str($op, $cx, '$#' . $self->padany($op->first));
195 } else {
196 return $self->maybe_local($op, $cx,
197 $self->rv2x($op->first, $cx, '$#'));
198 }
199 }
200  
201 sub pp_rv2av {
202 my $self = shift;
203 my($op, $cx) = @_;
204 my $kid = $op->first;
205 if ($kid->name eq "const") { # constant list
206 my $av = $self->const_sv($kid);
207 return $self->list_const($kid, $cx, $av->ARRAY);
208 } else {
209 # FIXME?
210 return $self->maybe_local($op, $cx, $self->rv2x($op, $cx, "\@"));
211 }
212 }
213  
214 sub elem_or_slice_array_name
215 {
216 my $self = shift;
217 my ($array, $left, $padname, $allow_arrow) = @_;
218  
219 if ($array->name eq $padname) {
220 return $self->padany($array);
221 } elsif (B::Deparse::is_scope($array)) { # ${expr}[0]
222 return "{" . $self->deparse($array, 0) . "}";
223 } elsif ($array->name eq "gv") {
224 ($array, my $quoted) =
225 $self->stash_variable_name(
226 $left eq '[' ? '@' : '%', $self->gv_or_padgv($array)
227 );
228 if (!$allow_arrow && $quoted) {
229 # This cannot happen.
230 die "Invalid variable name $array for slice";
231 }
232 return $quoted ? "$array->" : $array;
233 } elsif (!$allow_arrow || B::Deparse::is_scalar $array) {
234 # $x[0], $$x[0], ...
235 return $self->deparse($array, 24)->{text};
236 } else {
237 return undef;
238 }
239 }
240  
241 sub elem_or_slice_single_index($$)
242 {
243 my ($self, $idx, $parent) = @_;
244  
245 my $idx_info = $self->deparse($idx, 1, $parent);
246 my $idx_str = $idx_info->{text};
247  
248 # Outer parens in an array index will confuse perl
249 # if we're interpolating in a regular expression, i.e.
250 # /$x$foo[(-1)]/ is *not* the same as /$x$foo[-1]/
251 #
252 # If $self->{parens}, then an initial '(' will
253 # definitely be paired with a final ')'. If
254 # !$self->{parens}, the misleading parens won't
255 # have been added in the first place.
256 #
257 # [You might think that we could get "(...)...(...)"
258 # where the initial and final parens do not match
259 # each other. But we can't, because the above would
260 # only happen if there's an infix binop between the
261 # two pairs of parens, and *that* means that the whole
262 # expression would be parenthesized as well.]
263 #
264 $idx_str =~ s/^\((.*)\)$/$1/ if $self->{'parens'};
265  
266 # Hash-element braces will autoquote a bareword inside themselves.
267 # We need to make sure that C<$hash{warn()}> doesn't come out as
268 # C<$hash{warn}>, which has a quite different meaning. Currently
269 # B::Deparse will always quote strings, even if the string was a
270 # bareword in the original (i.e. the OPpCONST_BARE flag is ignored
271 # for constant strings.) So we can cheat slightly here - if we see
272 # a bareword, we know that it is supposed to be a function call.
273 #
274 $idx_str =~ s/^([A-Za-z_]\w*)$/$1()/;
275  
276 return info_from_text($idx_info->{op}, $self, $idx_str,
277 'elem_or_slice_single_index',
278 {body => [$idx_info]});
279 }
280  
281 sub _method
282 {
283 my($self, $op, $cx) = @_;
284 my @other_ops = ($op->first);
285 my $kid = $op->first->sibling; # skip pushmark
286 my($meth, $obj, @exprs);
287 if ($kid->name eq "list" and B::Deparse::want_list $kid) {
288 # When an indirect object isn't a bareword but the args are in
289 # parens, the parens aren't part of the method syntax (the LLAFR
290 # doesn't apply), but they make a list with OPf_PARENS set that
291 # doesn't get flattened by the append_elem that adds the method,
292 # making a (object, arg1, arg2, ...) list where the object
293 # usually is. This can be distinguished from
294 # '($obj, $arg1, $arg2)->meth()' (which is legal if $arg2 is an
295 # object) because in the later the list is in scalar context
296 # as the left side of -> always is, while in the former
297 # the list is in list context as method arguments always are.
298 # (Good thing there aren't method prototypes!)
299 $meth = $kid->sibling;
300 push @other_ops, $kid->first;
301 $kid = $kid->first->sibling; # skip pushmark
302 $obj = $kid;
303 $kid = $kid->sibling;
304 for (; not B::Deparse::null $kid; $kid = $kid->sibling) {
305 push @exprs, $kid;
306 }
307 } else {
308 $obj = $kid;
309 $kid = $kid->sibling;
310 for (; !B::Deparse::null ($kid->sibling) && $kid->name!~/^method(?:_named)?\z/;
311 $kid = $kid->sibling) {
312 push @exprs, $kid
313 }
314 $meth = $kid;
315 }
316  
317 if ($meth->name eq "method_named") {
318 $meth = $self->const_sv($meth)->PV;
319 } else {
320 $meth = $meth->first;
321 if ($meth->name eq "const") {
322 # As of 5.005_58, this case is probably obsoleted by the
323 # method_named case above
324 $meth = $self->const_sv($meth)->PV; # needs to be bare
325 }
326 }
327  
328 return {
329 method => $meth,
330 variable_method => ref($meth),
331 object => $obj,
332 args => \@exprs,
333 other_ops => \@other_ops
334 }, $cx;
335 }
336  
337 sub e_method {
338 my ($self, $op, $minfo, $cx) = @_;
339 my $obj = $self->deparse($minfo->{object}, 24, $op);
340 my @body = ($obj);
341 my $other_ops = $minfo->{other_ops};
342  
343 my $meth_name = $minfo->{method};
344 my $meth_info;
345 if ($minfo->{variable_method}) {
346 $meth_info = $self->deparse($meth_name, 1, $op);
347 push @body, $meth_info;
348 }
349 my @args = map { $self->deparse($_, 6, $op) } @{$minfo->{args}};
350 push @body, @args;
351 my @args_texts = map $_->{text}, @args;
352 my $args = join(", ", @args_texts);
353  
354 my $opts = {other_ops => $other_ops};
355 my @texts = ();
356 my $type;
357  
358  
359 my $meth_object = $meth_info ? defined($meth_info) : $meth_name;
360 if ($minfo->{object}->name eq 'scope' && B::Deparse::want_list $minfo->{object}) {
361 # method { $object }
362 # This must be deparsed this way to preserve list context
363 # of $object.
364 my $need_paren = $cx >= 6;
365 if ($need_paren) {
366 @texts = ('(', $meth_object, substr($obj,2),
367 $args, ')');
368 $type = 'e_method list ()';
369 } else {
370 @texts = ($meth_object, substr($obj,2), $args);
371 $type = 'e_method list, no ()';
372 }
373 return info_from_list($op, $self, \@texts, '', $type, $opts);
374 }
375  
376 if (length $args) {
377 @texts = ($obj, '->', $meth_object, '(', $args, ')');
378 $type = 'e_method -> ()';
379 } else {
380 @texts = ($obj, '->', $meth_object);
381 $type = 'e_method -> no ()';
382 }
383 return info_from_list($op, $self, \@texts, '', $type, $opts);
384 }
385  
386 # returns "&" and the argument bodies if the prototype doesn't match the args,
387 # or ("", $args_after_prototype_demunging) if it does.
388 sub check_proto {
389 my $self = shift;
390 my $op = shift;
391 return ('&', []) if $self->{'noproto'};
392 my($proto, @args) = @_;
393 my($arg, $real);
394 my $doneok = 0;
395 my @reals;
396 # An unbackslashed @ or % gobbles up the rest of the args
397 1 while $proto =~ s/(?<!\\)([@%])[^\]]+$/$1/;
398 $proto =~ s/^\s*//;
399 while ($proto) {
400 $proto =~ s/^(\\?[\$\@&%*_]|\\\[[\$\@&%*]+\]|;)\s*//;
401 my $chr = $1;
402 if ($chr eq "") {
403 return ('&', []) if @args;
404 } elsif ($chr eq ";") {
405 $doneok = 1;
406 } elsif ($chr eq "@" or $chr eq "%") {
407 push @reals, map($self->deparse($_, 6), @args, $op);
408 @args = ();
409 } else {
410 $arg = shift @args;
411 last unless $arg;
412 if ($chr eq "\$" || $chr eq "_") {
413 if (B::Deparse::want_scalar $arg) {
414 push @reals, $self->deparse($arg, 6, $op);
415 } else {
416 return ('&', []);
417 }
418 } elsif ($chr eq "&") {
419 if ($arg->name =~ /^(s?refgen|undef)$/) {
420 push @reals, $self->deparse($arg, 6, $op);
421 } else {
422 return ('&', []);
423 }
424 } elsif ($chr eq "*") {
425 if ($arg->name =~ /^s?refgen$/
426 and $arg->first->first->name eq "rv2gv")
427 {
428 $real = $arg->first->first; # skip refgen, null
429 if ($real->first->name eq "gv") {
430 push @reals, $self->deparse($real, 6, $op);
431 } else {
432 push @reals, $self->deparse($real->first, 6, $op);
433 }
434 } else {
435 return ('&', []);
436 }
437 } elsif (substr($chr, 0, 1) eq "\\") {
438 $chr =~ tr/\\[]//d;
439 if ($arg->name =~ /^s?refgen$/ and
440 !B::Deparse::null($real = $arg->first) and
441 ($chr =~ /\$/ && B::Deparse::is_scalar($real->first)
442 or ($chr =~ /@/
443 && class($real->first->sibling) ne 'NULL'
444 && $real->first->sibling->name
445 =~ /^(rv2|pad)av$/)
446 or ($chr =~ /%/
447 && class($real->first->sibling) ne 'NULL'
448 && $real->first->sibling->name
449 =~ /^(rv2|pad)hv$/)
450 #or ($chr =~ /&/ # This doesn't work
451 # && $real->first->name eq "rv2cv")
452 or ($chr =~ /\*/
453 && $real->first->name eq "rv2gv")))
454 {
455 push @reals, $self->deparse($real, 6, $op);
456 } else {
457 return ('&', []);
458 }
459 }
460 }
461 }
462 return ('&', []) if $proto and !$doneok; # too few args and no ';'
463 return ('&', []) if @args; # too many args
464 return ('', \@reals);
465 }
466  
467 # Like dq(), but different
468 sub re_dq {
469 my $self = shift;
470 my ($op, $extended) = @_;
471 my ($re_dq_info, $fmt);
472  
473 my $type = $op->name;
474 my ($re, @texts);
475 my $opts = {};
476 if ($type eq "const") {
477 return info_from_text($op, $self, '$[', 're_dq_const', {})
478 if $op->private & OPpCONST_ARYBASE;
479 my $unbacked = B::Deparse::re_unback($self->const_sv($op)->as_string);
480 return B::Deparse::re_uninterp_extended(escape_extended_re($unbacked))
481 if $extended;
482 return B::Deparse::re_uninterp(B::Deparse::escape_str($unbacked));
483 } elsif ($type eq "concat") {
484 my $first = $self->re_dq($op->first, $extended);
485 my $last = $self->re_dq($op->last, $extended);
486 return B::Deparse::re_dq_disambiguate($first, $last);
487 } elsif ($type eq "uc") {
488 $re_dq_info = $self->re_dq($op->first->sibling, $extended);
489 $fmt = '\U%c\E';
490 $type .= ' uc';
491 } elsif ($type eq "lc") {
492 $re_dq_info = $self->re_dq($op->first->sibling, $extended);
493 $fmt = '\L%c\E';
494 $type .= ' lc';
495 } elsif ($type eq "ucfirst") {
496 $re_dq_info = $self->re_dq($op->first->sibling, $extended);
497 $fmt = '\u%c';
498 $type .= ' ucfirst';
499 } elsif ($type eq "lcfirst") {
500 $re_dq_info = $self->re_dq($op->first->sibling, $extended);
501 $fmt = '\u%c';
502 $type .= ' lcfirst';
503 } elsif ($type eq "quotemeta") {
504 $re = $self->re_dq($op->first->sibling, $extended);
505 @texts = ['\Q', $re->{text},'\E'];
506 $type .= ' quotemeta';
507 } elsif ($type eq "fc") {
508 $re = $self->re_dq($op->first->sibling, $extended);
509 @texts = ['\F', $re->{text},'\E'];
510 $type .= ' fc';
511 } elsif ($type eq "join") {
512 return $self->deparse($op->last, 26, $op); # was join($", @ary)
513 } else {
514 my $info = $self->deparse($op, 26, $op);
515 $info->{type} = 're_dq';
516 $info->{text} =~ s/^\$([(|)])\z/\${$1}/; # $( $| $) need braces
517 return $info;
518 }
519 return info_from_list($op, $self, \@texts, '', $type, $opts);
520 }
521  
522 sub pure_string {
523 my ($self, $op) = @_;
524 return 0 if B::Deparse::null $op;
525 my $type = $op->name;
526  
527 if ($type eq 'const' || $type eq 'av2arylen') {
528 return 1;
529 }
530 elsif ($type =~ /^(?:[ul]c(first)?|fc)$/ || $type eq 'quotemeta') {
531 return $self->pure_string($op->first->sibling);
532 }
533 elsif ($type eq 'join') {
534 my $join_op = $op->first->sibling; # Skip pushmark
535 return 0 unless $join_op->name eq 'null' && $join_op->targ == OP_RV2SV;
536  
537 my $gvop = $join_op->first;
538 return 0 unless $gvop->name eq 'gvsv';
539 return 0 unless '"' eq $self->gv_name($self->gv_or_padgv($gvop));
540  
541 return 0 unless ${$join_op->sibling} eq ${$op->last};
542 return 0 unless $op->last->name =~ /^(?:[ah]slice|(?:rv2|pad)av)$/;
543 }
544 elsif ($type eq 'concat') {
545 return $self->pure_string($op->first)
546 && $self->pure_string($op->last);
547 }
548 elsif (B::Deparse::is_scalar($op) || $type =~ /^[ah]elem$/) {
549 return 1;
550 }
551 elsif ($type eq "null" and $op->can('first') and not B::Deparse::null $op->first and
552 ($op->first->name eq "null" and $op->first->can('first')
553 and not B::Deparse::null $op->first->first and
554 $op->first->first->name eq "aelemfast"
555 or
556 $op->first->name =~ /^aelemfast(?:_lex)?\z/
557 )) {
558 return 1;
559 }
560 else {
561 return 0;
562 }
563  
564 return 1;
565 }
566  
567 sub regcomp
568 {
569 my($self, $op, $cx, $extended) = @_;
570 my @other_ops = ();
571 my $kid = $op->first;
572 if ($kid->name eq "regcmaybe") {
573 push @other_ops, $kid;
574 $kid = $kid->first;
575 }
576 if ($kid->name eq "regcreset") {
577 push @other_ops, $kid;
578 $kid = $kid->first;
579 }
580 if ($kid->name eq "null" and !B::Deparse::null($kid->first)
581 and $kid->first->name eq 'pushmark') {
582 my $str = '';
583 push(@other_ops, $kid);
584 $kid = $kid->first->sibling;
585 my @body = ();
586 while (!B::Deparse::null($kid)) {
587 my $first = $str;
588 my $last = $self->re_dq($kid, $extended);
589 push @body, $last;
590 push(@other_ops, $kid);
591 $str = B::Deparse::re_dq_disambiguate($first,
592 $self->info2str($last));
593 $kid = $kid->sibling;
594 }
595 return (info_from_text($op, $self, $str, 'regcomp',
596 {other_ops => \@other_ops,
597 body => \@body}), 1);
598 }
599  
600 if ($self->pure_string($kid)) {
601 my $info = $self->re_dq($kid, $extended);
602 my @kid_ops = $info->{other_ops} ? @{$info->{other_ops}} : ();
603 push @other_ops, @kid_ops;
604 $info->{other_ops} = \@other_ops;
605 return ($info, 1);
606 }
607 return ($self->deparse($kid, $cx, $op), 0, $op);
608 }
609  
610 sub pp_split
611 {
612 my($self, $op, $cx) = @_;
613 my($kid, @exprs, $ary_info, $expr);
614 my $ary = '';
615 my @body = ();
616 my @other_ops = ();
617 $kid = $op->first;
618  
619 # For our kid (an OP_PUSHRE), pmreplroot is never actually the
620 # root of a replacement; it's either empty, or abused to point to
621 # the GV for an array we split into (an optimization to save
622 # assignment overhead). Depending on whether we're using ithreads,
623 # this OP* holds either a GV* or a PADOFFSET. Luckily, B.xs
624 # figures out for us which it is.
625 my $replroot = $kid->pmreplroot;
626 my $gv = 0;
627 if (ref($replroot) eq "B::GV") {
628 $gv = $replroot;
629 } elsif (!ref($replroot) and $replroot > 0) {
630 $gv = $self->padval($replroot);
631 }
632 $ary = $self->stash_variable('@', $self->gv_name($gv), $cx) if $gv;
633  
634 for (; !B::Deparse::null($kid); $kid = $kid->sibling) {
635 push @exprs, $self->deparse($kid, 6, $op);
636 }
637  
638 my $opts = {body => \@exprs};
639  
640 my @args_texts = map $_->{text}, @exprs;
641 # handle special case of split(), and split(' ') that compiles to /\s+/
642 # Under 5.10, the reflags may be undef if the split regexp isn't a constant
643 # Under 5.17.5-5.17.9, the special flag is on split itself.
644 $kid = $op->first;
645 if ( $op->flags & OPf_SPECIAL ) {
646 $exprs[0]->{text} = "' '";
647 }
648  
649 my $sep = '';
650 my $type;
651 my @expr_texts;
652 if ($ary) {
653 @expr_texts = ("$ary", '=', join(', ', @args_texts));
654 $sep = ' ';
655 $type = 'split_array';
656 $opts->{maybe_parens} = [$self, $cx, 7];
657 } else {
658 @expr_texts = ('split', '(', join(', ', @args_texts), ')');
659 $type = 'split';
660  
661 }
662 return info_from_list($op, $self, \@expr_texts, $sep, $type, $opts);
663 }
664  
665 1;