line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Exporter::Lexical; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
4
|
|
|
4
|
|
123926
|
$Exporter::Lexical::AUTHORITY = 'cpan:DOY'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$Exporter::Lexical::VERSION = '0.02'; |
7
|
|
|
|
|
|
|
} |
8
|
4
|
|
|
4
|
|
41
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
134
|
|
9
|
4
|
|
|
4
|
|
25
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
132
|
|
10
|
4
|
|
|
4
|
|
118
|
use 5.018; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
149
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: exporter for lexical subs |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
21
|
use XSLoader; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
537
|
|
15
|
|
|
|
|
|
|
XSLoader::load( |
16
|
|
|
|
|
|
|
__PACKAGE__, |
17
|
|
|
|
|
|
|
# we need to be careful not to touch $VERSION at compile time, otherwise |
18
|
|
|
|
|
|
|
# DynaLoader will assume it's set and check against it, which will cause |
19
|
|
|
|
|
|
|
# fail when being run in the checkout without dzil having set the actual |
20
|
|
|
|
|
|
|
# $VERSION |
21
|
|
|
|
|
|
|
exists $Exporter::Lexical::{VERSION} |
22
|
|
|
|
|
|
|
? ${ $Exporter::Lexical::{VERSION} } : (), |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub import { |
26
|
2
|
|
|
2
|
|
22
|
my $package = shift; |
27
|
2
|
|
|
|
|
7
|
my %opts = @_; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
7
|
my $caller = caller; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
27
|
my $import = build_exporter(\%opts, $caller); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
{ |
34
|
4
|
|
|
4
|
|
21
|
no strict 'refs'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
363
|
|
|
2
|
|
|
|
|
5
|
|
35
|
2
|
|
|
|
|
4
|
*{ $caller . '::import' } = $import; |
|
2
|
|
|
|
|
92
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub build_exporter { |
41
|
3
|
|
|
3
|
1
|
116
|
my ($opts, $caller) = @_; |
42
|
3
|
|
66
|
|
|
23
|
$caller //= caller; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return sub { |
45
|
3
|
|
|
3
|
|
94
|
my $caller_stash = do { |
46
|
4
|
|
|
4
|
|
22
|
no strict 'refs'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
932
|
|
47
|
3
|
|
|
|
|
6
|
\%{ $caller . '::' }; |
|
3
|
|
|
|
|
9
|
|
48
|
|
|
|
|
|
|
}; |
49
|
3
|
|
|
|
|
7
|
my %exports; |
50
|
3
|
100
|
|
|
|
26
|
if (ref($opts->{'-exports'}) eq 'ARRAY') { |
|
|
50
|
|
|
|
|
|
51
|
2
|
|
|
|
|
4
|
%exports = map { $_ => \&{ $caller_stash->{$_} } } |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
4
|
|
52
|
2
|
|
|
|
|
4
|
@{ $opts->{'-exports'} }; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif (ref($opts->{'-exports'}) eq 'HASH') { |
55
|
1
|
|
|
|
|
2
|
%exports = %{ $opts->{'-exports'} }; |
|
1
|
|
|
|
|
15
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
3
|
|
|
|
|
11
|
for my $export (keys %exports) { |
59
|
3
|
|
|
|
|
33
|
lexical_import($export, $exports{$export}); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# XXX there is a bug with lexical_import where the pad entry sequence |
63
|
|
|
|
|
|
|
# numbers are incorrect when used with 'use', so the first statement |
64
|
|
|
|
|
|
|
# after the 'use' statement doesn't see the lexical. hack around this |
65
|
|
|
|
|
|
|
# for now by injecting a dummy statement right after the 'use'. |
66
|
3
|
|
|
|
|
6897
|
_lex_stuff(";1;"); |
67
|
3
|
|
|
|
|
18
|
}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |