line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::Util::FindMethods; |
2
|
2
|
|
|
2
|
|
3215
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
70
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings qw(FATAL all NONFATAL misc); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
70
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use Exporter qw(import); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
6
|
|
|
|
|
|
|
our @EXPORT = qw(FindMethods); |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
14
|
use YATT::Lite::Util qw(symtab); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
423
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub FindMethods { |
11
|
|
|
|
|
|
|
# depth first, pre-order search of 'sub'. |
12
|
|
|
|
|
|
|
# In the real sense, this should be called 'Findsubs'. |
13
|
3
|
|
|
3
|
0
|
646
|
my ($obj, $pattern, $visited, $found) = @_; |
14
|
3
|
|
100
|
|
|
10
|
$visited ||= {}; |
15
|
3
|
|
100
|
|
|
10
|
$found ||= {}; |
16
|
3
|
100
|
|
|
|
7
|
my $class = ref($obj) ? ref($obj) : $obj; |
17
|
3
|
|
|
|
|
7
|
$visited->{$class} = 1; |
18
|
3
|
|
|
|
|
7
|
my $symtab = symtab($class); |
19
|
3
|
|
|
|
|
5
|
local $_; |
20
|
3
|
|
|
|
|
13
|
foreach my $orig (keys %$symtab) { |
21
|
66
|
|
|
|
|
249
|
$_ = $orig; |
22
|
66
|
50
|
|
|
|
124
|
if ($pattern) { |
23
|
66
|
50
|
|
|
|
120
|
if (ref $pattern eq 'CODE') { |
24
|
66
|
100
|
|
|
|
121
|
$pattern->($_) or next; |
25
|
|
|
|
|
|
|
} else { |
26
|
0
|
0
|
|
|
|
0
|
$_ =~ $pattern or next; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
4
|
|
|
|
|
24
|
my $glob = $symtab->{$orig}; |
30
|
4
|
100
|
|
|
|
7
|
next unless *{$glob}{CODE}; |
|
4
|
|
|
|
|
16
|
|
31
|
2
|
|
33
|
|
|
14
|
$found->{$_} //= $class; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
17
|
my $isa = $symtab->{ISA}; |
35
|
3
|
50
|
50
|
|
|
8
|
if (defined $isa and *{$isa}{ARRAY}) { |
|
3
|
|
|
|
|
13
|
|
36
|
3
|
|
|
|
|
6
|
foreach my $super (@{*{$isa}{ARRAY}}) { |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
9
|
|
37
|
|
|
|
|
|
|
FindMethods($super, $pattern, $visited, $found) |
38
|
2
|
50
|
|
|
|
15
|
unless $visited->{$super}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
3
|
100
|
|
|
|
8
|
if (wantarray) { |
43
|
1
|
|
|
|
|
10
|
sort keys %$found |
44
|
|
|
|
|
|
|
} else { |
45
|
2
|
|
|
|
|
5
|
$found; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |