line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Keyword::Pluggable; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
278776
|
use v5.14.0; |
|
6
|
|
|
|
|
59
|
|
4
|
6
|
|
|
6
|
|
66
|
use warnings; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
296
|
|
5
|
|
|
|
|
|
|
our %kw; |
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
46
|
use Carp qw(croak); |
|
6
|
|
|
|
|
23
|
|
|
6
|
|
|
|
|
363
|
|
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
37
|
use XSLoader; |
|
6
|
|
|
|
|
28
|
|
|
6
|
|
|
|
|
363
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
6
|
|
|
6
|
|
21
|
our $VERSION = '1.03'; |
12
|
6
|
|
|
|
|
3597
|
XSLoader::load __PACKAGE__, $VERSION; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub define { |
16
|
8
|
|
|
8
|
1
|
571
|
my %p = @_; |
17
|
8
|
|
|
|
|
31
|
my ($kw, $sub, $expression, $global, $package) = @p{qw(keyword code expression global package)}; |
18
|
6
|
50
|
|
6
|
|
3745
|
$kw =~ /^\p{XIDS}\p{XIDC}*\z/ or croak "'$kw' doesn't look like an identifier"; |
|
6
|
|
|
|
|
105
|
|
|
6
|
|
|
|
|
98
|
|
|
8
|
|
|
|
|
56
|
|
19
|
8
|
50
|
|
|
|
28
|
defined($sub) or croak "'code' is not defined"; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $xsub = (ref($sub) eq 'CODE') ? |
22
|
2
|
|
|
2
|
|
65080
|
sub { substr ${$_[0]}, 0, 0, $sub->(${$_[0]}) } : |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
22
|
|
23
|
8
|
100
|
|
13
|
|
42
|
sub { substr ${$_[0]}, 0, 0, $sub }; |
|
13
|
|
|
|
|
71929
|
|
|
13
|
|
|
|
|
6101
|
|
24
|
|
|
|
|
|
|
|
25
|
8
|
|
|
|
|
23
|
my $entry = [ $xsub, !!$expression ]; |
26
|
|
|
|
|
|
|
|
27
|
8
|
100
|
|
|
|
23
|
if ( defined $package) { |
|
|
100
|
|
|
|
|
|
28
|
6
|
|
|
6
|
|
136085
|
no strict 'refs'; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
1078
|
|
29
|
2
|
|
|
|
|
4
|
my $keywords = \%{$package . '::/keywords' }; |
|
2
|
|
|
|
|
7
|
|
30
|
2
|
|
|
|
|
37
|
$keywords->{$kw} = $entry; |
31
|
|
|
|
|
|
|
} elsif ( $global ) { |
32
|
2
|
|
|
|
|
44
|
define_global($kw, $entry); |
33
|
|
|
|
|
|
|
} else { |
34
|
4
|
|
100
|
|
|
7
|
my %keywords = %{$^H{+HINTK_KEYWORDS} // {}}; |
|
4
|
|
|
|
|
28
|
|
35
|
4
|
|
|
|
|
12
|
$keywords{$kw} = $entry; |
36
|
4
|
|
|
|
|
93
|
$^H{+HINTK_KEYWORDS} = \%keywords; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub undefine { |
41
|
1
|
|
|
1
|
1
|
2582
|
my %p = @_; |
42
|
1
|
|
|
|
|
6
|
my ($kw, $global, $package) = @p{qw(keyword global package)}; |
43
|
1
|
50
|
|
|
|
8
|
$kw =~ /^\p{XIDS}\p{XIDC}*\z/ or croak "'$kw' doesn't look like an identifier"; |
44
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
5
|
if ( defined $package ) { |
|
|
0
|
|
|
|
|
|
46
|
6
|
|
|
6
|
|
1450
|
no strict 'refs'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
871
|
|
47
|
1
|
|
|
|
|
2
|
my $keywords = \%{$package . '::/keywords' }; |
|
1
|
|
|
|
|
6
|
|
48
|
1
|
|
|
|
|
10
|
delete $keywords->{$kw}; |
49
|
|
|
|
|
|
|
} elsif ( $global ) { |
50
|
0
|
|
|
|
|
|
undefine_global($kw); |
51
|
|
|
|
|
|
|
} else { |
52
|
0
|
|
0
|
|
|
|
my %keywords = %{$^H{+HINTK_KEYWORDS} // {}}; |
|
0
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
delete $keywords{$kw}; |
54
|
0
|
|
|
|
|
|
$^H{+HINTK_KEYWORDS} = \%keywords; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
6
|
|
|
6
|
|
11256
|
END { cleanup() } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
'ok' |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |