line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Keyword::Pluggable; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
236207
|
use v5.14.0; |
|
6
|
|
|
|
|
55
|
|
4
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
251
|
|
5
|
|
|
|
|
|
|
our %kw; |
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
49
|
use Carp qw(croak); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
379
|
|
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
33
|
use XSLoader; |
|
6
|
|
|
|
|
25
|
|
|
6
|
|
|
|
|
333
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
6
|
|
|
6
|
|
20
|
our $VERSION = '1.04'; |
12
|
6
|
|
|
|
|
3294
|
XSLoader::load __PACKAGE__, $VERSION; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub define { |
16
|
8
|
|
|
8
|
1
|
543
|
my %p = @_; |
17
|
8
|
|
|
|
|
30
|
my ($kw, $sub, $expression, $global, $package) = @p{qw(keyword code expression global package)}; |
18
|
6
|
50
|
|
6
|
|
3332
|
$kw =~ /^\p{XIDS}\p{XIDC}*\z/ or croak "'$kw' doesn't look like an identifier"; |
|
6
|
|
|
|
|
76
|
|
|
6
|
|
|
|
|
84
|
|
|
8
|
|
|
|
|
51
|
|
19
|
8
|
50
|
|
|
|
26
|
defined($sub) or croak "'code' is not defined"; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $xsub = (ref($sub) eq 'CODE') ? $sub : |
22
|
8
|
100
|
|
13
|
|
36
|
sub { substr ${$_[0]}, 0, 0, $sub }; |
|
13
|
|
|
|
|
126598
|
|
|
13
|
|
|
|
|
5399
|
|
23
|
|
|
|
|
|
|
|
24
|
8
|
|
|
|
|
22
|
my $entry = [ $xsub, !!$expression ]; |
25
|
|
|
|
|
|
|
|
26
|
8
|
100
|
|
|
|
22
|
if ( defined $package) { |
|
|
100
|
|
|
|
|
|
27
|
6
|
|
|
6
|
|
120885
|
no strict 'refs'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
955
|
|
28
|
2
|
|
|
|
|
3
|
my $keywords = \%{$package . '::/keywords' }; |
|
2
|
|
|
|
|
8
|
|
29
|
2
|
|
|
|
|
36
|
$keywords->{$kw} = $entry; |
30
|
|
|
|
|
|
|
} elsif ( $global ) { |
31
|
2
|
|
|
|
|
38
|
define_global($kw, $entry); |
32
|
|
|
|
|
|
|
} else { |
33
|
4
|
|
100
|
|
|
6
|
my %keywords = %{$^H{+HINTK_KEYWORDS} // {}}; |
|
4
|
|
|
|
|
24
|
|
34
|
4
|
|
|
|
|
11
|
$keywords{$kw} = $entry; |
35
|
4
|
|
|
|
|
80
|
$^H{+HINTK_KEYWORDS} = \%keywords; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub undefine { |
40
|
1
|
|
|
1
|
1
|
1402
|
my %p = @_; |
41
|
1
|
|
|
|
|
5
|
my ($kw, $global, $package) = @p{qw(keyword global package)}; |
42
|
1
|
50
|
|
|
|
8
|
$kw =~ /^\p{XIDS}\p{XIDC}*\z/ or croak "'$kw' doesn't look like an identifier"; |
43
|
|
|
|
|
|
|
|
44
|
1
|
50
|
|
|
|
4
|
if ( defined $package ) { |
|
|
0
|
|
|
|
|
|
45
|
6
|
|
|
6
|
|
1280
|
no strict 'refs'; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
764
|
|
46
|
1
|
|
|
|
|
2
|
my $keywords = \%{$package . '::/keywords' }; |
|
1
|
|
|
|
|
5
|
|
47
|
1
|
|
|
|
|
10
|
delete $keywords->{$kw}; |
48
|
|
|
|
|
|
|
} elsif ( $global ) { |
49
|
0
|
|
|
|
|
|
undefine_global($kw); |
50
|
|
|
|
|
|
|
} else { |
51
|
0
|
|
0
|
|
|
|
my %keywords = %{$^H{+HINTK_KEYWORDS} // {}}; |
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
delete $keywords{$kw}; |
53
|
0
|
|
|
|
|
|
$^H{+HINTK_KEYWORDS} = \%keywords; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
6
|
|
|
6
|
|
9841
|
END { cleanup() } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
'ok' |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |