Byteloader patching from Enache continues;
[p5sagit/p5-mst-13.2.git] / ext / B / B / Concise.pm
index 755c837..57aa6fd 100644 (file)
@@ -14,7 +14,7 @@ use warnings; # uses #3 and #4, since warnings uses Carp
 
 use Exporter (); # use #5
 
-our $VERSION   = "0.56";
+our $VERSION   = "0.57";
 our @ISA       = qw(Exporter);
 our @EXPORT_OK = qw(set_style set_style_standard add_callback
                    concise_subref concise_cv concise_main);
@@ -275,9 +275,13 @@ sub walk_topdown {
            walk_topdown($kid, $sub, $level + 1);
        }
     }
-    if (class($op) eq "PMOP" and $op->pmreplroot and $ {$op->pmreplroot}
-       and $op->pmreplroot->isa("B::OP")) {
-       walk_topdown($op->pmreplroot, $sub, $level + 1);
+    if (class($op) eq "PMOP") {
+       my $maybe_root = $op->pmreplroot;
+       if (ref($maybe_root) and $maybe_root->isa("B::OP")) {
+           # It really is the root of the replacement, not something
+           # else stored here for lack of space elsewhere
+           walk_topdown($maybe_root, $sub, $level + 1);
+       }
     }
 }
 
@@ -520,10 +524,16 @@ sub concise_op {
        }
        my $pmreplroot = $op->pmreplroot;
        my $pmreplstart;
-       if ($pmreplroot && $$pmreplroot && $pmreplroot->isa("B::GV")) {
+       if (ref($pmreplroot) eq "B::GV") {
            # with C<@stash_array = split(/pat/, str);>,
-           #  *stash_array is stored in pmreplroot.
+           #  *stash_array is stored in /pat/'s pmreplroot.
            $h{arg} = "($precomp => \@" . $pmreplroot->NAME . ")";
+       } elsif (!ref($pmreplroot) and $pmreplroot) {
+           # same as the last case, except the value is actually a
+           # pad offset for where the GV is kept (this happens under
+           # ithreads)
+           my $gv = (($curcv->PADLIST->ARRAY)[1]->ARRAY)[$pmreplroot];
+           $h{arg} = "($precomp => \@" . $gv->NAME . ")";
        } elsif ($ {$op->pmreplstart}) {
            undef $lastnext;
            $pmreplstart = "replstart->" . seq($op->pmreplstart);