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
|
|
1282
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
196
|
|
5
|
8
|
|
|
8
|
|
34
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
174
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
30
|
use Carp (); |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
130
|
|
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
32
|
use UNIVERSAL::Object::Immutable; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
141
|
|
10
|
|
|
|
|
|
|
|
11
|
8
|
|
|
8
|
|
40
|
use MOP::Internal::Util; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
446
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
14
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
15
|
|
|
|
|
|
|
|
16
|
8
|
|
|
8
|
|
481
|
our @ISA; BEGIN { @ISA = ('UNIVERSAL::Object::Immutable') } |
17
|
|
|
|
|
|
|
our %HAS; BEGIN { |
18
|
|
|
|
|
|
|
%HAS = ( |
19
|
|
|
|
|
|
|
default => sub {}, |
20
|
|
|
|
|
|
|
required => sub {}, |
21
|
|
|
|
|
|
|
) |
22
|
8
|
|
|
8
|
|
1365
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub BUILDARGS { |
25
|
4
|
|
|
4
|
1
|
8005
|
my $class = shift; |
26
|
4
|
|
|
|
|
17
|
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
|
|
|
48
|
if $args->{default} && $args->{required}; |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
9
|
return $args; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub CREATE { |
35
|
4
|
|
|
4
|
1
|
43
|
my ($class, $args) = @_; |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
6
|
my $code; |
38
|
4
|
100
|
|
|
|
10
|
if ( my $message = $args->{required} ) { |
39
|
1
|
|
|
|
|
84
|
$code = eval 'sub { die \''.$message.'\' }'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
3
|
|
66
|
|
|
126
|
$code = $args->{default} || eval 'sub { undef }'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
12
|
return $code; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub BUILD { |
49
|
4
|
|
|
4
|
1
|
149
|
my ($self, $params) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
MOP::Internal::Util::SET_COMP_STASH_FOR_CV( $self, $params->{within_package} ) |
52
|
4
|
100
|
|
|
|
18
|
if $params->{within_package}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |