| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MOP::Method; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: A representation of a method |
|
3
|
|
|
|
|
|
|
|
|
4
|
33
|
|
|
33
|
|
265558
|
use strict; |
|
|
33
|
|
|
|
|
86
|
|
|
|
33
|
|
|
|
|
708
|
|
|
5
|
33
|
|
|
33
|
|
126
|
use warnings; |
|
|
33
|
|
|
|
|
55
|
|
|
|
33
|
|
|
|
|
572
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
33
|
|
|
33
|
|
13852
|
use attributes (); |
|
|
33
|
|
|
|
|
31520
|
|
|
|
33
|
|
|
|
|
637
|
|
|
8
|
33
|
|
|
33
|
|
158
|
use Carp (); |
|
|
33
|
|
|
|
|
47
|
|
|
|
33
|
|
|
|
|
441
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
33
|
|
|
33
|
|
10370
|
use MOP::Method::Attribute; |
|
|
33
|
|
|
|
|
64
|
|
|
|
33
|
|
|
|
|
758
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
33
|
|
|
33
|
|
11871
|
use MOP::Internal::Util; |
|
|
33
|
|
|
|
|
70
|
|
|
|
33
|
|
|
|
|
1381
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
|
15
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
33
|
|
|
33
|
|
166
|
use parent 'UNIVERSAL::Object::Immutable'; |
|
|
33
|
|
|
|
|
49
|
|
|
|
33
|
|
|
|
|
136
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub BUILDARGS { |
|
20
|
1037
|
|
|
1037
|
1
|
18153
|
my $class = shift; |
|
21
|
1037
|
|
|
|
|
979
|
my %args; |
|
22
|
|
|
|
|
|
|
|
|
23
|
1037
|
100
|
|
|
|
1470
|
if ( scalar( @_ ) == 1 ) { |
|
24
|
2
|
50
|
|
|
|
6
|
if ( ref $_[0] ) { |
|
25
|
2
|
100
|
|
|
|
7
|
if ( ref $_[0] eq 'CODE' ) { |
|
|
|
50
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
4
|
%args = ( body => $_[0] ); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
elsif (ref $_[0] eq 'HASH') { |
|
29
|
1
|
|
|
|
|
2
|
%args = %{ $_[0] }; |
|
|
1
|
|
|
|
|
3
|
|
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
else { |
|
34
|
1035
|
|
|
|
|
1627
|
%args = @_; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Carp::confess('[ARGS] You must specify a method body') |
|
38
|
1037
|
100
|
|
|
|
1809
|
unless $args{body}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Carp::confess('[ARGS] The body specified must be a CODE reference') |
|
41
|
1036
|
100
|
|
|
|
1625
|
unless ref $args{body} eq 'CODE'; |
|
42
|
|
|
|
|
|
|
|
|
43
|
1035
|
|
|
|
|
1603
|
return \%args; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub CREATE { |
|
47
|
1035
|
|
|
1035
|
1
|
7359
|
my ($class, $args) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
1035
|
|
|
|
|
1117
|
my $body = $args->{body}; |
|
50
|
|
|
|
|
|
|
# this will get blessed, so we |
|
51
|
|
|
|
|
|
|
# do not actually want the CV |
|
52
|
|
|
|
|
|
|
# to get touched, so we get a |
|
53
|
|
|
|
|
|
|
# ref of a ref here ... |
|
54
|
1035
|
|
|
|
|
1744
|
return \$body; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub name { |
|
58
|
546
|
|
|
546
|
1
|
20217
|
my ($self) = @_; |
|
59
|
546
|
|
|
|
|
624
|
return MOP::Internal::Util::GET_GLOB_NAME( $self->body ) |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub fully_qualified_name { |
|
63
|
5
|
|
|
5
|
0
|
10
|
my ($self) = @_; |
|
64
|
5
|
|
|
|
|
12
|
join '::' => $self->origin_stash, $self->name; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub body { |
|
68
|
2549
|
|
|
2549
|
1
|
10659
|
my ($self) = @_; |
|
69
|
2549
|
|
|
|
|
4089
|
return $$self; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub is_required { |
|
73
|
929
|
|
|
929
|
1
|
1090
|
my ($self) = @_; |
|
74
|
929
|
|
|
|
|
1039
|
MOP::Internal::Util::IS_CV_NULL( $self->body ); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub origin_stash { |
|
78
|
611
|
|
|
611
|
1
|
1002
|
my ($self) = @_; |
|
79
|
|
|
|
|
|
|
# NOTE: |
|
80
|
|
|
|
|
|
|
# Here we actually want the stash that is |
|
81
|
|
|
|
|
|
|
# associated with the GV (glob) that the |
|
82
|
|
|
|
|
|
|
# method body is associated with. This is |
|
83
|
|
|
|
|
|
|
# sometimes different then the COMP_STASH |
|
84
|
|
|
|
|
|
|
# meaning the stash it was compiled in. It |
|
85
|
|
|
|
|
|
|
# seems to vary most with required subs, |
|
86
|
|
|
|
|
|
|
# which seem to be compiled in main:: even |
|
87
|
|
|
|
|
|
|
# when I am expecting it not to be. |
|
88
|
|
|
|
|
|
|
# - SL |
|
89
|
611
|
|
|
|
|
714
|
return MOP::Internal::Util::GET_GLOB_STASH_NAME( $self->body ) |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub was_aliased_from { |
|
93
|
25
|
|
|
25
|
1
|
69
|
my ($self, @classnames) = @_; |
|
94
|
|
|
|
|
|
|
|
|
95
|
25
|
50
|
|
|
|
64
|
Carp::confess('[ARGS] You must specify at least one classname') |
|
96
|
|
|
|
|
|
|
if scalar( @classnames ) == 0; |
|
97
|
|
|
|
|
|
|
|
|
98
|
25
|
|
|
|
|
50
|
my $class = $self->origin_stash; |
|
99
|
25
|
|
|
|
|
49
|
foreach my $candidate ( @classnames ) { |
|
100
|
25
|
100
|
|
|
|
110
|
return 1 if $candidate eq $class; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
7
|
|
|
|
|
22
|
return 0; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub has_code_attributes { |
|
106
|
0
|
|
|
0
|
1
|
0
|
my ($self, $to_match) = @_; |
|
107
|
0
|
|
0
|
|
|
0
|
$to_match //= '.'; |
|
108
|
0
|
|
|
|
|
0
|
return scalar grep /^$to_match/, attributes::get( $self->body ); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub get_code_attributes { |
|
112
|
2
|
|
|
2
|
1
|
5
|
my ($self, $to_match) = @_; |
|
113
|
2
|
|
50
|
|
|
4
|
$to_match //= '.'; |
|
114
|
2
|
|
|
|
|
5
|
return map MOP::Method::Attribute->new( $_ ), grep /^$to_match/, attributes::get( $self->body ); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |