Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit dcebcb8

Browse files
committed
B::Xref 1.07_02
Support sub refs, and named anon subs.
1 parent 48a6aa9 commit dcebcb8

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

dist/Module-CoreList/lib/Module/CoreList.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17418,6 +17418,7 @@ our %delta = (
1741817418
'Archive::Tar::Constant'=> '2.30',
1741917419
'Archive::Tar::File' => '2.30',
1742017420
'Attribute::Handlers' => '1.00_01',
17421+
'B::Xref' => '1.07_02',
1742117422
'ExtUtils::Constant' => '0.25_01',
1742217423
'ExtUtils::Constant::Base' => '2.25_01',
1742317424
'ExtUtils::Constant::ProxySubs' => '2.25_01',

ext/B/B/Xref.pm

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package B::Xref;
22

3-
our $VERSION = '1.05';
3+
our $VERSION = '1.07_02';
44

55
=head1 NAME
66
@@ -76,7 +76,7 @@ A line number may be prefixed by a single letter:
7676
7777
=item i
7878
79-
Lexical variable introduced (declared with my()) for the first time.
79+
Lexical variable introduced (declared with my,our,state) for the first time.
8080
8181
=item &
8282
@@ -136,14 +136,14 @@ reported properly.
136136
137137
=head1 AUTHOR
138138
139-
Malcolm Beattie, [email protected].
139+
Malcolm Beattie C<retired>.
140140
141141
=cut
142142

143143
use strict;
144144
use Config;
145-
use B qw(peekop class comppadlist main_start svref_2object walksymtable
146-
OPpLVAL_INTRO SVf_POK OPpOUR_INTRO cstring
145+
use B qw(peekop comppadlist main_start svref_2object walksymtable
146+
OPpLVAL_INTRO SVf_POK SVf_ROK OPpOUR_INTRO cstring
147147
);
148148

149149
sub UNKNOWN { ["?", "?", "?"] }
@@ -192,12 +192,12 @@ sub load_pad {
192192
my $padlist = shift;
193193
my ($namelistav, $vallistav, @namelist, $ix);
194194
@pad = ();
195-
return if class($padlist) =~ '^(?:SPECIAL|NULL)\z';
195+
return if B::class($padlist) =~ '^(?:SPECIAL|NULL)\z';
196196
($namelistav,$vallistav) = $padlist->ARRAY;
197197
@namelist = $namelistav->ARRAY;
198198
for ($ix = 1; $ix < @namelist; $ix++) {
199199
my $namesv = $namelist[$ix];
200-
next if class($namesv) eq "SPECIAL";
200+
next if B::class($namesv) eq "SPECIAL";
201201
my ($type, $name) = $namesv->PV =~ /^(.)([^\0]*)(\0.*)?$/;
202202
$pad[$ix] = ["(lexical)", $type || '?', $name || '?'];
203203
}
@@ -206,8 +206,8 @@ sub load_pad {
206206
@vallist = $vallistav->ARRAY;
207207
for ($ix = 1; $ix < @vallist; $ix++) {
208208
my $valsv = $vallist[$ix];
209-
next unless class($valsv) eq "GV";
210-
next if class($valsv->STASH) eq 'SPECIAL';
209+
next unless B::class($valsv) eq "GV";
210+
next if B::class($valsv->STASH) eq 'SPECIAL';
211211
# these pad GVs don't have corresponding names, so same @pad
212212
# array can be used without collisions
213213
$pad[$ix] = [$valsv->STASH->NAME, "*", $valsv->NAME];
@@ -331,7 +331,13 @@ sub pp_gv {
331331
}
332332
else {
333333
$gv = $op->gv;
334-
$top = [$gv->STASH->NAME, "*", $gv->SAFENAME];
334+
if ($gv->FLAGS & SVf_ROK) { # sub ref
335+
my $cv = $gv->RV;
336+
$top = [$cv->STASH->NAME, '*', B::safename($cv->NAME_HEK)]
337+
}
338+
else {
339+
$top = [$gv->STASH->NAME, '*', $gv->SAFENAME];
340+
}
335341
}
336342
process($top, $op->private & OPpLVAL_INTRO ? "intro" : "used");
337343
}
@@ -342,7 +348,7 @@ sub pp_const {
342348
# constant could be in the pad (under useithreads)
343349
if ($$sv) {
344350
$top = ["?", "",
345-
(class($sv) ne "SPECIAL" && $sv->FLAGS & SVf_POK)
351+
(B::class($sv) ne "SPECIAL" && $sv->FLAGS & SVf_POK)
346352
? cstring($sv->PV) : "?"];
347353
}
348354
else {
@@ -373,7 +379,7 @@ sub pp_entersub {
373379
sub B::GV::xref {
374380
my $gv = shift;
375381
my $cv = $gv->CV;
376-
if ($$cv) {
382+
if ($$cv and ref $cv eq 'B::CV') {
377383
#return if $done{$$cv}++;
378384
$file = $gv->FILE;
379385
$line = $gv->LINE;
@@ -449,7 +455,7 @@ sub compile {
449455
last OPTION;
450456
} elsif ($opt eq "o") {
451457
$arg ||= shift @options;
452-
open(STDOUT, ">$arg") or return "$arg: $!\n";
458+
open(STDOUT, '>', $arg) or return "$arg: $!\n";
453459
} elsif ($opt eq "d") {
454460
$nodefs = 1;
455461
} elsif ($opt eq "r") {

pod/perlcdelta.pod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ Remove deprecated no-op attributes :unique, :locked
7474

7575
Fix autovivification bug with hash slice args to a function.
7676

77+
=item L<B::Xref> 1.07_02
78+
79+
Support sub refs, and named anon subs.
80+
7781
=item L<ExtUtils::Constant> 1.25_01
7882

7983
fix failed to extend arg stack

0 commit comments

Comments
 (0)