line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::Declare::MethodInstaller::Simple; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
246302
|
use base 'Devel::Declare::Context::Simple'; |
|
4
|
|
|
|
|
41
|
|
|
4
|
|
|
|
|
1773
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
25
|
use Devel::Declare (); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
105
|
|
6
|
4
|
|
|
4
|
|
2019
|
use Sub::Name; |
|
4
|
|
|
|
|
1866
|
|
|
4
|
|
|
|
|
185
|
|
7
|
4
|
|
|
4
|
|
26
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
70
|
|
8
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
279
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.006_021'; |
11
|
|
|
|
|
|
|
$VERSION =~ tr/_//d; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub install_methodhandler { |
14
|
5
|
|
|
5
|
0
|
228
|
my $class = shift; |
15
|
5
|
|
|
|
|
20
|
my %args = @_; |
16
|
|
|
|
|
|
|
{ |
17
|
4
|
|
|
4
|
|
23
|
no strict 'refs'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1055
|
|
|
5
|
|
|
|
|
11
|
|
18
|
5
|
|
|
0
|
|
22
|
*{$args{into}.'::'.$args{name}} = sub (&) {}; |
|
5
|
|
|
|
|
31
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
|
|
585
|
my $warnings = warnings::enabled("redefine"); |
22
|
5
|
|
|
|
|
42
|
my $ctx = $class->new(%args); |
23
|
|
|
|
|
|
|
Devel::Declare->setup_for( |
24
|
|
|
|
|
|
|
$args{into}, |
25
|
18
|
|
|
18
|
|
60
|
{ $args{name} => { const => sub { $ctx->parser(@_, $warnings) } } } |
26
|
5
|
|
|
|
|
63
|
); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub code_for { |
30
|
18
|
|
|
18
|
0
|
54
|
my ($self, $name) = @_; |
31
|
|
|
|
|
|
|
|
32
|
18
|
100
|
|
|
|
47
|
if (defined $name) { |
33
|
14
|
|
|
|
|
42
|
my $pkg = $self->get_curstash_name; |
34
|
14
|
100
|
|
|
|
62
|
$name = join( '::', $pkg, $name ) |
35
|
|
|
|
|
|
|
unless( $name =~ /::/ ); |
36
|
|
|
|
|
|
|
return sub (&) { |
37
|
11
|
|
|
11
|
|
3415
|
my $code = shift; |
38
|
|
|
|
|
|
|
# So caller() gets the subroutine name |
39
|
4
|
|
|
4
|
|
29
|
no strict 'refs'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
302
|
|
40
|
|
|
|
|
|
|
my $installer = $self->warning_on_redefine |
41
|
10
|
|
|
|
|
58
|
? sub { *{$name} = subname $name => $code; } |
|
10
|
|
|
|
|
52
|
|
42
|
4
|
|
|
4
|
|
25
|
: sub { no warnings 'redefine'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1322
|
|
43
|
11
|
100
|
|
|
|
56
|
*{$name} = subname $name => $code; }; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
8
|
|
44
|
11
|
|
|
|
|
32
|
$installer->(); |
45
|
11
|
|
|
|
|
55
|
return; |
46
|
14
|
|
|
|
|
103
|
}; |
47
|
|
|
|
|
|
|
} else { |
48
|
4
|
|
|
4
|
|
27
|
return sub (&) { shift }; |
|
4
|
|
|
|
|
28
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub install { |
53
|
18
|
|
|
18
|
0
|
34
|
my ($self, $name ) = @_; |
54
|
|
|
|
|
|
|
|
55
|
18
|
|
|
|
|
39
|
$self->shadow( $self->code_for($name) ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub parser { |
59
|
18
|
|
|
18
|
0
|
27
|
my $self = shift; |
60
|
18
|
|
|
|
|
75
|
$self->init(@_); |
61
|
|
|
|
|
|
|
|
62
|
18
|
|
|
|
|
63
|
$self->skip_declarator; |
63
|
18
|
|
|
|
|
44
|
my $name = $self->strip_name; |
64
|
18
|
|
|
|
|
57
|
my $proto = $self->strip_proto; |
65
|
18
|
|
|
|
|
46
|
my $attrs = $self->strip_attrs; |
66
|
18
|
|
|
|
|
50
|
my @decl = $self->parse_proto($proto); |
67
|
18
|
|
|
|
|
110
|
my $inject = $self->inject_parsed_proto(@decl); |
68
|
18
|
100
|
|
|
|
43
|
if (defined $name) { |
69
|
14
|
|
|
|
|
37
|
$inject = $self->scope_injector_call() . $inject; |
70
|
|
|
|
|
|
|
} |
71
|
18
|
100
|
|
|
|
74
|
$self->inject_if_block($inject, $attrs ? "sub ${attrs} " : ''); |
72
|
|
|
|
|
|
|
|
73
|
18
|
|
|
|
|
46
|
$self->install( $name ); |
74
|
|
|
|
|
|
|
|
75
|
18
|
|
|
|
|
120
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
8
|
|
|
8
|
0
|
26
|
sub parse_proto { '' } |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub inject_parsed_proto { |
81
|
18
|
|
|
18
|
0
|
32
|
return $_[1]; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|