line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Memoize::Attrs; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
91880
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
154
|
|
5
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
174
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.00_03'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
131566
|
use Attribute::Handlers; |
|
4
|
|
|
|
|
34107
|
|
|
4
|
|
|
|
|
30
|
|
10
|
4
|
|
|
4
|
|
5440
|
use Memoize; |
|
4
|
|
|
|
|
10508
|
|
|
4
|
|
|
|
|
1302
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# $qualified_name = _qualify_name($name, $package) |
13
|
|
|
|
|
|
|
sub _qualify_name { |
14
|
1
|
|
|
1
|
|
5
|
my $name = shift; |
15
|
1
|
|
|
|
|
2
|
my $package = shift; |
16
|
1
|
50
|
|
|
|
5
|
return undef unless defined $name; |
17
|
1
|
50
|
|
|
|
4
|
if ( $name =~ /::/ ) { |
18
|
|
|
|
|
|
|
# already a fully qualified name |
19
|
0
|
|
|
|
|
0
|
return $name |
20
|
|
|
|
|
|
|
} else { |
21
|
|
|
|
|
|
|
# resolves to the given package |
22
|
1
|
|
|
|
|
5
|
return $package . '::' . $name |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#sub MEMOIZE :ATTR(CODE, CHECK) { |
28
|
|
|
|
|
|
|
sub UNIVERSAL::MEMOIZE :ATTR(CODE, CHECK) { |
29
|
2
|
|
|
2
|
0
|
9236
|
my ($package, $symbol, $code, $attr, $data, $phase) = @_; |
30
|
|
|
|
|
|
|
|
31
|
2
|
50
|
|
|
|
14
|
my %options = ( |
|
|
100
|
|
|
|
|
|
32
|
|
|
|
|
|
|
(ref $data) ? @$data |
33
|
|
|
|
|
|
|
: ( defined($data) ? ($data) : () ) |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# qualify the install name (eg, 'foo' to 'caller::foo') |
37
|
2
|
100
|
|
|
|
8
|
if ( exists $options{INSTALL} ) { |
38
|
|
|
|
|
|
|
# explicit INSTALL => name |
39
|
1
|
|
|
|
|
5
|
$options{INSTALL} = _qualify_name($options{INSTALL}, $package); |
40
|
|
|
|
|
|
|
} else { |
41
|
|
|
|
|
|
|
# No INSTALL option provided: use the original name |
42
|
1
|
|
|
|
|
2
|
$options{INSTALL} = *{$symbol}{PACKAGE} . '::' . *{$symbol}{NAME}; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
# XXX INSTALL => undef makes no sense to this module !!! |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# qualify the normalizer name (if given) |
47
|
2
|
50
|
33
|
|
|
13
|
if ( exists $options{NORMALIZER} && !ref $options{NORMALIZER} ) { |
48
|
0
|
|
|
|
|
0
|
$options{NORMALIZER} = _qualify_name($options{NORMALIZER}, $package); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
19
|
memoize($code, %options ); |
52
|
|
|
|
|
|
|
|
53
|
4
|
|
|
4
|
|
34
|
} |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
34
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# XXX instead of Installing handlers into UNIVERSAL, |
56
|
|
|
|
|
|
|
# install it into the caller of import |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |