Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/TypeConstraint/Parameterized.pm |
Statements | Executed 27 statements in 666µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 653µs | 2.39ms | BEGIN@15 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 11µs | 11µs | BEGIN@14 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 10µs | 10µs | BEGIN@2 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 10µs | 82µs | BEGIN@17 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 9µs | 14µs | BEGIN@9 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 9µs | 46µs | BEGIN@13 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 8µs | 571µs | BEGIN@11 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 8µs | 24µs | BEGIN@10 | Moose::Meta::TypeConstraint::Parameterized::
0 | 0 | 0 | 0s | 0s | _inline_check | Moose::Meta::TypeConstraint::Parameterized::
0 | 0 | 0 | 0s | 0s | can_be_inlined | Moose::Meta::TypeConstraint::Parameterized::
0 | 0 | 0 | 0s | 0s | compile_type_constraint | Moose::Meta::TypeConstraint::Parameterized::
0 | 0 | 0 | 0s | 0s | create_child_type | Moose::Meta::TypeConstraint::Parameterized::
0 | 0 | 0 | 0s | 0s | equals | Moose::Meta::TypeConstraint::Parameterized::
0 | 0 | 0 | 0s | 0s | inline_environment | Moose::Meta::TypeConstraint::Parameterized::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::TypeConstraint::Parameterized; | ||||
2 | # spent 10µs within Moose::Meta::TypeConstraint::Parameterized::BEGIN@2 which was called:
# once (10µs+0s) by Moose::Util::TypeConstraints::BEGIN@34 at line 4 | ||||
3 | 1 | 4µs | $Moose::Meta::TypeConstraint::Parameterized::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 23µs | 1 | 10µs | } # spent 10µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@2 |
5 | { | ||||
6 | 2 | 1µs | $Moose::Meta::TypeConstraint::Parameterized::VERSION = '2.0602'; | ||
7 | } | ||||
8 | |||||
9 | 3 | 19µs | 2 | 19µs | # spent 14µs (9+5) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 which was called:
# once (9µs+5µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 9 # spent 14µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@9
# spent 5µs making 1 call to strict::import |
10 | 3 | 18µs | 2 | 40µs | # spent 24µs (8+16) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 which was called:
# once (8µs+16µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 10 # spent 24µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@10
# spent 16µs making 1 call to warnings::import |
11 | 3 | 29µs | 2 | 1.13ms | # spent 571µs (8+563) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@11 which was called:
# once (8µs+563µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 11 # spent 571µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@11
# spent 563µs making 1 call to metaclass::import |
12 | |||||
13 | 3 | 22µs | 2 | 84µs | # spent 46µs (9+38) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@13 which was called:
# once (9µs+38µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 13 # spent 46µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@13
# spent 38µs making 1 call to Exporter::import |
14 | 3 | 23µs | 1 | 11µs | # spent 11µs within Moose::Meta::TypeConstraint::Parameterized::BEGIN@14 which was called:
# once (11µs+0s) by Moose::Util::TypeConstraints::BEGIN@34 at line 14 # spent 11µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@14 |
15 | 3 | 127µs | 1 | 2.39ms | # spent 2.39ms (653µs+1.74) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 which was called:
# once (653µs+1.74ms) by Moose::Util::TypeConstraints::BEGIN@34 at line 15 # spent 2.39ms making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 |
16 | |||||
17 | 3 | 382µs | 2 | 153µs | # spent 82µs (10+72) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@17 which was called:
# once (10µs+72µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 17 # spent 82µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@17
# spent 72µs making 1 call to base::import |
18 | |||||
19 | 1 | 5µs | 3 | 534µs | __PACKAGE__->meta->add_attribute('type_parameter' => ( # spent 509µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 19µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta
# spent 6µs making 1 call to Class::MOP::_definition_context |
20 | accessor => 'type_parameter', | ||||
21 | predicate => 'has_type_parameter', | ||||
22 | Class::MOP::_definition_context(), | ||||
23 | )); | ||||
24 | |||||
25 | 1 | 4µs | 3 | 437µs | __PACKAGE__->meta->add_attribute('parameterized_from' => ( # spent 421µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 11µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta
# spent 6µs making 1 call to Class::MOP::_definition_context |
26 | accessor => 'parameterized_from', | ||||
27 | predicate => 'has_parameterized_from', | ||||
28 | Class::MOP::_definition_context(), | ||||
29 | )); | ||||
30 | |||||
31 | sub equals { | ||||
32 | my ( $self, $type_or_name ) = @_; | ||||
33 | |||||
34 | my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name); | ||||
35 | |||||
36 | return unless $other->isa(__PACKAGE__); | ||||
37 | |||||
38 | return ( | ||||
39 | $self->type_parameter->equals( $other->type_parameter ) | ||||
40 | and | ||||
41 | $self->parent->equals( $other->parent ) | ||||
42 | ); | ||||
43 | } | ||||
44 | |||||
45 | sub compile_type_constraint { | ||||
46 | my $self = shift; | ||||
47 | |||||
48 | unless ( $self->has_type_parameter ) { | ||||
49 | require Moose; | ||||
50 | Moose->throw_error("You cannot create a Higher Order type without a type parameter"); | ||||
51 | } | ||||
52 | |||||
53 | my $type_parameter = $self->type_parameter; | ||||
54 | |||||
55 | unless ( blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint') ) { | ||||
56 | require Moose; | ||||
57 | Moose->throw_error("The type parameter must be a Moose meta type"); | ||||
58 | } | ||||
59 | |||||
60 | foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) { | ||||
61 | if (my $constraint = $type->generate_constraint_for($self)) { | ||||
62 | $self->_set_constraint($constraint); | ||||
63 | return $self->SUPER::compile_type_constraint; | ||||
64 | } | ||||
65 | } | ||||
66 | |||||
67 | # if we get here, then we couldn't | ||||
68 | # find a way to parameterize this type | ||||
69 | require Moose; | ||||
70 | Moose->throw_error("The " . $self->name . " constraint cannot be used, because " | ||||
71 | . $self->parent->name . " doesn't subtype or coerce from a parameterizable type."); | ||||
72 | } | ||||
73 | |||||
74 | sub can_be_inlined { | ||||
75 | my $self = shift; | ||||
76 | |||||
77 | return | ||||
78 | $self->has_parameterized_from | ||||
79 | && $self->parameterized_from->has_inline_generator | ||||
80 | && $self->type_parameter->can_be_inlined; | ||||
81 | } | ||||
82 | |||||
83 | sub inline_environment { | ||||
84 | my $self = shift; | ||||
85 | |||||
86 | return { | ||||
87 | ($self->has_parameterized_from | ||||
88 | ? (%{ $self->parameterized_from->inline_environment }) | ||||
89 | : ()), | ||||
90 | ($self->has_type_parameter | ||||
91 | ? (%{ $self->type_parameter->inline_environment }) | ||||
92 | : ()), | ||||
93 | }; | ||||
94 | } | ||||
95 | |||||
96 | sub _inline_check { | ||||
97 | my $self = shift; | ||||
98 | |||||
99 | return unless $self->can_be_inlined; | ||||
100 | |||||
101 | return $self->parameterized_from->generate_inline_for( $self->type_parameter, @_ ); | ||||
102 | } | ||||
103 | |||||
104 | sub create_child_type { | ||||
105 | my ($self, %opts) = @_; | ||||
106 | return Moose::Meta::TypeConstraint::Parameterizable->new(%opts, parent=>$self); | ||||
107 | } | ||||
108 | |||||
109 | 1 | 9µs | 1; | ||
110 | |||||
111 | # ABSTRACT: Type constraints with a bound parameter (ArrayRef[Int]) | ||||
112 | |||||
- - | |||||
115 | =pod | ||||
116 | |||||
117 | =head1 NAME | ||||
118 | |||||
119 | Moose::Meta::TypeConstraint::Parameterized - Type constraints with a bound parameter (ArrayRef[Int]) | ||||
120 | |||||
121 | =head1 VERSION | ||||
122 | |||||
123 | version 2.0602 | ||||
124 | |||||
125 | =head1 METHODS | ||||
126 | |||||
127 | This class is intentionally not documented because the API is | ||||
128 | confusing and needs some work. | ||||
129 | |||||
130 | =head1 INHERITANCE | ||||
131 | |||||
132 | C<Moose::Meta::TypeConstraint::Parameterized> is a subclass of | ||||
133 | L<Moose::Meta::TypeConstraint>. | ||||
134 | |||||
135 | =head1 BUGS | ||||
136 | |||||
137 | See L<Moose/BUGS> for details on reporting bugs. | ||||
138 | |||||
139 | =head1 AUTHOR | ||||
140 | |||||
141 | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details. | ||||
142 | |||||
143 | =head1 COPYRIGHT AND LICENSE | ||||
144 | |||||
145 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
146 | |||||
147 | This is free software; you can redistribute it and/or modify it under | ||||
148 | the same terms as the Perl 5 programming language system itself. | ||||
149 | |||||
150 | =cut | ||||
151 | |||||
152 | |||||
153 | __END__ |