line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Meta::TypeConstraint::Parameterized; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2205'; |
3
|
|
|
|
|
|
|
|
4
|
390
|
|
|
390
|
|
3011
|
use strict; |
|
390
|
|
|
|
|
969
|
|
|
390
|
|
|
|
|
12675
|
|
5
|
390
|
|
|
390
|
|
2252
|
use warnings; |
|
390
|
|
|
|
|
897
|
|
|
390
|
|
|
|
|
10067
|
|
6
|
390
|
|
|
390
|
|
2201
|
use metaclass; |
|
390
|
|
|
|
|
961
|
|
|
390
|
|
|
|
|
2546
|
|
7
|
|
|
|
|
|
|
|
8
|
390
|
|
|
390
|
|
3192
|
use Scalar::Util 'blessed'; |
|
390
|
|
|
|
|
1142
|
|
|
390
|
|
|
|
|
21799
|
|
9
|
390
|
|
|
390
|
|
2956
|
use Moose::Util::TypeConstraints; |
|
390
|
|
|
|
|
1067
|
|
|
390
|
|
|
|
|
15874
|
|
10
|
390
|
|
|
390
|
|
190010
|
use Moose::Meta::TypeConstraint::Parameterizable; |
|
390
|
|
|
|
|
1352
|
|
|
390
|
|
|
|
|
15549
|
|
11
|
390
|
|
|
390
|
|
3224
|
use Moose::Util 'throw_exception'; |
|
390
|
|
|
|
|
1015
|
|
|
390
|
|
|
|
|
1993
|
|
12
|
|
|
|
|
|
|
|
13
|
390
|
|
|
390
|
|
95044
|
use parent 'Moose::Meta::TypeConstraint'; |
|
390
|
|
|
|
|
1062
|
|
|
390
|
|
|
|
|
1833
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__PACKAGE__->meta->add_attribute('type_parameter' => ( |
16
|
|
|
|
|
|
|
accessor => 'type_parameter', |
17
|
|
|
|
|
|
|
predicate => 'has_type_parameter', |
18
|
|
|
|
|
|
|
Class::MOP::_definition_context(), |
19
|
|
|
|
|
|
|
)); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__PACKAGE__->meta->add_attribute('parameterized_from' => ( |
22
|
|
|
|
|
|
|
accessor => 'parameterized_from', |
23
|
|
|
|
|
|
|
predicate => 'has_parameterized_from', |
24
|
|
|
|
|
|
|
Class::MOP::_definition_context(), |
25
|
|
|
|
|
|
|
)); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub equals { |
28
|
132
|
|
|
132
|
1
|
2347
|
my ( $self, $type_or_name ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
132
|
|
|
|
|
436
|
my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name); |
31
|
|
|
|
|
|
|
|
32
|
132
|
100
|
|
|
|
1839
|
return unless $other->isa(__PACKAGE__); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return ( |
35
|
8
|
|
66
|
|
|
293
|
$self->type_parameter->equals( $other->type_parameter ) |
36
|
|
|
|
|
|
|
and |
37
|
|
|
|
|
|
|
$self->parent->equals( $other->parent ) |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub compile_type_constraint { |
42
|
147
|
|
|
147
|
0
|
401
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
147
|
100
|
|
|
|
6437
|
unless ( $self->has_type_parameter ) { |
45
|
1
|
|
|
|
|
34
|
throw_exception( CannotCreateHigherOrderTypeWithoutATypeParameter => type_name => $self->name ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
146
|
|
|
|
|
5425
|
my $type_parameter = $self->type_parameter; |
49
|
|
|
|
|
|
|
|
50
|
146
|
100
|
66
|
|
|
1618
|
unless ( blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint') ) { |
51
|
1
|
|
|
|
|
28
|
throw_exception( TypeParameterMustBeMooseMetaType => type_name => $self->name ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
145
|
|
|
|
|
768
|
foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) { |
55
|
341
|
100
|
|
|
|
1171
|
if (my $constraint = $type->generate_constraint_for($self)) { |
56
|
142
|
|
|
|
|
5558
|
$self->_set_constraint($constraint); |
57
|
142
|
|
|
|
|
861
|
return $self->SUPER::compile_type_constraint; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# if we get here, then we couldn't |
62
|
|
|
|
|
|
|
# find a way to parameterize this type |
63
|
3
|
|
|
|
|
92
|
throw_exception( TypeConstraintCannotBeUsedForAParameterizableType => type_name => $self->name, |
64
|
|
|
|
|
|
|
parent_type_name => $self->parent->name, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub can_be_inlined { |
69
|
1199
|
|
|
1199
|
1
|
2364
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return |
72
|
1199
|
|
100
|
|
|
49305
|
$self->has_parameterized_from |
73
|
|
|
|
|
|
|
&& $self->parameterized_from->has_inline_generator |
74
|
|
|
|
|
|
|
&& $self->type_parameter->can_be_inlined; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub inline_environment { |
78
|
614
|
|
|
614
|
1
|
1309
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
return { |
81
|
|
|
|
|
|
|
($self->has_parameterized_from |
82
|
613
|
|
|
|
|
20225
|
? (%{ $self->parameterized_from->inline_environment }) |
83
|
|
|
|
|
|
|
: ()), |
84
|
|
|
|
|
|
|
($self->has_type_parameter |
85
|
614
|
100
|
|
|
|
24532
|
? (%{ $self->type_parameter->inline_environment }) |
|
614
|
50
|
|
|
|
20516
|
|
86
|
|
|
|
|
|
|
: ()), |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _inline_check { |
91
|
336
|
|
|
336
|
|
814
|
my $self = shift; |
92
|
|
|
|
|
|
|
|
93
|
336
|
50
|
|
|
|
932
|
return unless $self->can_be_inlined; |
94
|
|
|
|
|
|
|
|
95
|
336
|
|
|
|
|
11596
|
return $self->parameterized_from->generate_inline_for( $self->type_parameter, @_ ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub create_child_type { |
99
|
27
|
|
|
27
|
1
|
128
|
my ($self, %opts) = @_; |
100
|
27
|
|
|
|
|
231
|
return Moose::Meta::TypeConstraint::Parameterizable->new(%opts, parent=>$self); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# ABSTRACT: Type constraints with a bound parameter (ArrayRef[Int]) |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=pod |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=encoding UTF-8 |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 NAME |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Moose::Meta::TypeConstraint::Parameterized - Type constraints with a bound parameter (ArrayRef[Int]) |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 VERSION |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
version 2.2205 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 METHODS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This class is intentionally not documented because the API is |
124
|
|
|
|
|
|
|
confusing and needs some work. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 INHERITANCE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
C<Moose::Meta::TypeConstraint::Parameterized> is a subclass of |
129
|
|
|
|
|
|
|
L<Moose::Meta::TypeConstraint>. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 BUGS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
See L<Moose/BUGS> for details on reporting bugs. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 AUTHORS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=over 4 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Jesse Luehrs <doy@cpan.org> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Shawn M Moore <sartak@cpan.org> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Hans Dieter Pearcey <hdp@cpan.org> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Chris Prather <chris@prather.org> |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Matt S Trout <mstrout@cpan.org> |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=back |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This software is copyright (c) 2006 by Infinity Interactive, Inc. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
186
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |