line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Meta::Library; |
2
|
7
|
|
|
7
|
|
1431
|
use 5.010; |
|
7
|
|
|
|
|
23
|
|
3
|
7
|
|
|
7
|
|
32
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
156
|
|
4
|
7
|
|
|
7
|
|
31
|
use warnings; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
231
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.15"; |
7
|
|
|
|
|
|
|
|
8
|
7
|
|
|
7
|
|
35
|
use Scalar::Util (); |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
97
|
|
9
|
7
|
|
|
7
|
|
742
|
use Sub::Identify; |
|
7
|
|
|
|
|
1932
|
|
|
7
|
|
|
|
|
331
|
|
10
|
7
|
|
|
7
|
|
2996
|
use Types::Standard qw(InstanceOf Str Ref); |
|
7
|
|
|
|
|
493380
|
|
|
7
|
|
|
|
|
84
|
|
11
|
7
|
|
|
7
|
|
10159
|
use Type::Params qw(compile Invocant); |
|
7
|
|
|
|
|
58804
|
|
|
7
|
|
|
|
|
91
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %INFO; |
14
|
|
|
|
|
|
|
our %INDEX; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $SubMeta = InstanceOf['Sub::Meta']; |
17
|
|
|
|
|
|
|
my $Callable = Ref['CODE']; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub register { |
20
|
25
|
|
|
25
|
1
|
9401
|
state $check = compile(Invocant, $Callable, $SubMeta); |
21
|
25
|
|
|
|
|
26464
|
my ($class, $sub, $meta) = $check->(@_); |
22
|
|
|
|
|
|
|
|
23
|
18
|
|
|
|
|
326
|
my $id = Scalar::Util::refaddr $sub; |
24
|
18
|
|
|
|
|
67
|
my ($stash, $subname) = Sub::Identify::get_code_info($sub); |
25
|
18
|
|
|
|
|
44
|
$INDEX{$stash}{$subname} = $id; |
26
|
18
|
|
|
|
|
49
|
$INFO{$id} = $meta; |
27
|
18
|
|
|
|
|
35
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub register_list { |
31
|
7
|
|
|
7
|
1
|
1354
|
my ($class, @list) = @_; |
32
|
|
|
|
|
|
|
|
33
|
7
|
|
|
|
|
11
|
for (@list) { |
34
|
11
|
|
|
|
|
62
|
$class->register(@$_) |
35
|
|
|
|
|
|
|
} |
36
|
3
|
|
|
|
|
7
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub get { |
40
|
30
|
|
|
30
|
1
|
533
|
my ($class, $sub) = @_; |
41
|
30
|
100
|
|
|
|
149
|
return unless $Callable->check($sub); |
42
|
|
|
|
|
|
|
|
43
|
27
|
|
|
|
|
313
|
my $id = Scalar::Util::refaddr $sub; |
44
|
27
|
|
|
|
|
99
|
return $INFO{$id} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_by_stash_subname { |
48
|
4
|
|
|
4
|
1
|
242
|
my ($class, $stash, $subname) = @_; |
49
|
|
|
|
|
|
|
|
50
|
4
|
|
|
|
|
9
|
my $id = $INDEX{$stash}{$subname}; |
51
|
4
|
100
|
|
|
|
15
|
return $INFO{$id} if $id; |
52
|
2
|
|
|
|
|
7
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_all_subnames_by_stash { |
56
|
3
|
|
|
3
|
1
|
237
|
my ($class, $stash) = @_; |
57
|
|
|
|
|
|
|
|
58
|
3
|
|
|
|
|
4
|
my $data = $INDEX{$stash}; |
59
|
3
|
100
|
|
|
|
20
|
return [ sort keys %$data ] if $data; |
60
|
1
|
|
|
|
|
3
|
return [ ] |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub get_all_submeta_by_stash { |
64
|
3
|
|
|
3
|
1
|
8406
|
my ($class, $stash) = @_; |
65
|
|
|
|
|
|
|
|
66
|
3
|
|
|
|
|
6
|
my $data = $INDEX{$stash}; |
67
|
3
|
100
|
|
|
|
12
|
return [ map { $INFO{$data->{$_}} } sort keys %$data ] if $data; |
|
4
|
|
|
|
|
16
|
|
68
|
1
|
|
|
|
|
5
|
return [ ] |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub remove { |
72
|
3
|
|
|
3
|
1
|
5044
|
state $check = compile(Invocant, $Callable); |
73
|
3
|
|
|
|
|
1324
|
my ($class, $sub) = $check->(@_); |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
17
|
my $id = Scalar::Util::refaddr $sub; |
76
|
1
|
|
|
|
|
5
|
my ($stash, $subname) = Sub::Identify::get_code_info($sub); |
77
|
1
|
|
|
|
|
3
|
delete $INDEX{$stash}{$subname}; |
78
|
1
|
|
|
|
|
13
|
return delete $INFO{$id} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
__END__ |