line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MOP::Slot::Initializer; |
2
|
|
|
|
|
|
|
# ABSTRACT: A representation of a class slot initializer |
3
|
|
|
|
|
|
|
|
4
|
8
|
|
|
8
|
|
1412
|
use strict; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
266
|
|
5
|
8
|
|
|
8
|
|
51
|
use warnings; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
287
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
50
|
use Carp (); |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
162
|
|
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
47
|
use UNIVERSAL::Object::Immutable; |
|
8
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
206
|
|
10
|
|
|
|
|
|
|
|
11
|
8
|
|
|
8
|
|
44
|
use MOP::Internal::Util; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
526
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
14
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
15
|
|
|
|
|
|
|
|
16
|
8
|
|
|
8
|
|
621
|
our @ISA; BEGIN { @ISA = ('UNIVERSAL::Object::Immutable') } |
17
|
|
|
|
|
|
|
our %HAS; BEGIN { |
18
|
|
|
|
|
|
|
%HAS = ( |
19
|
|
|
|
|
|
|
default => sub {}, |
20
|
|
|
|
|
|
|
required => sub {}, |
21
|
|
|
|
|
|
|
) |
22
|
8
|
|
|
8
|
|
1624
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub BUILDARGS { |
25
|
4
|
|
|
4
|
1
|
9458
|
my $class = shift; |
26
|
4
|
|
|
|
|
28
|
my $args = $class->SUPER::BUILDARGS( @_ ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Carp::confess('Cannot have both a default and be required in the same initializer') |
29
|
4
|
50
|
66
|
|
|
51
|
if $args->{default} && $args->{required}; |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
9
|
return $args; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub CREATE { |
35
|
4
|
|
|
4
|
1
|
39
|
my ($class, $args) = @_; |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
8
|
my $code; |
38
|
4
|
100
|
|
|
|
9
|
if ( my $message = $args->{required} ) { |
39
|
1
|
|
|
|
|
70
|
$code = eval 'sub { die \''.$message.'\' }'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
3
|
|
66
|
|
|
138
|
$code = $args->{default} || eval 'sub { undef }'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
14
|
return $code; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub BUILD { |
49
|
4
|
|
|
4
|
1
|
129
|
my ($self, $params) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
MOP::Internal::Util::SET_COMP_STASH_FOR_CV( $self, $params->{within_package} ) |
52
|
4
|
100
|
|
|
|
19
|
if $params->{within_package}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |