← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:05 2021

Filename/usr/local/lib/perl5/site_perl/Specio/Constraint/Parameterizable.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sSpecio::Constraint::Parameterizable::::BEGIN@10Specio::Constraint::Parameterizable::BEGIN@10
0000s0sSpecio::Constraint::Parameterizable::::BEGIN@11Specio::Constraint::Parameterizable::BEGIN@11
0000s0sSpecio::Constraint::Parameterizable::::BEGIN@12Specio::Constraint::Parameterizable::BEGIN@12
0000s0sSpecio::Constraint::Parameterizable::::BEGIN@13Specio::Constraint::Parameterizable::BEGIN@13
0000s0sSpecio::Constraint::Parameterizable::::BEGIN@15Specio::Constraint::Parameterizable::BEGIN@15
0000s0sSpecio::Constraint::Parameterizable::::BEGIN@3Specio::Constraint::Parameterizable::BEGIN@3
0000s0sSpecio::Constraint::Parameterizable::::BEGIN@4Specio::Constraint::Parameterizable::BEGIN@4
0000s0sSpecio::Constraint::Parameterizable::::BEGIN@8Specio::Constraint::Parameterizable::BEGIN@8
0000s0sSpecio::Constraint::Parameterizable::::BEGIN@9Specio::Constraint::Parameterizable::BEGIN@9
0000s0sSpecio::Constraint::Parameterizable::::BUILDSpecio::Constraint::Parameterizable::BUILD
0000s0sSpecio::Constraint::Parameterizable::::__ANON__Specio::Constraint::Parameterizable::__ANON__ (xsub)
0000s0sSpecio::Constraint::Parameterizable::::__ANON__[:95]Specio::Constraint::Parameterizable::__ANON__[:95]
0000s0sSpecio::Constraint::Parameterizable::::_attrsSpecio::Constraint::Parameterizable::_attrs
0000s0sSpecio::Constraint::Parameterizable::::parameterizeSpecio::Constraint::Parameterizable::parameterize
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Specio::Constraint::Parameterizable;
2
3use strict;
4use warnings;
5
6our $VERSION = '0.47';
7
8use Carp qw( confess );
9use Role::Tiny::With;
10use Specio::Constraint::Parameterized;
11use Specio::DeclaredAt;
12use Specio::OO;
13use Specio::TypeChecks qw( does_role isa_class );
14
15use Specio::Constraint::Role::Interface;
16with 'Specio::Constraint::Role::Interface';
17
18{
19 ## no critic (Subroutines::ProtectPrivateSubs)
20 my $role_attrs = Specio::Constraint::Role::Interface::_attrs();
21 ## use critic
22
23 my $attrs = {
24 %{$role_attrs},
25 _parameterized_constraint_generator => {
26 isa => 'CodeRef',
27 init_arg => 'parameterized_constraint_generator',
28 predicate => '_has_parameterized_constraint_generator',
29 },
30 _parameterized_inline_generator => {
31 isa => 'CodeRef',
32 init_arg => 'parameterized_inline_generator',
33 predicate => '_has_parameterized_inline_generator',
34 },
35 };
36
37 ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
38 sub _attrs {
39 return $attrs;
40 }
41}
42
43sub BUILD {
44 my $self = shift;
45
46 if ( $self->_has_constraint ) {
47 die
48 'A parameterizable constraint with a constraint parameter must also have a parameterized_constraint_generator'
49 unless $self->_has_parameterized_constraint_generator;
50 }
51
52 if ( $self->_has_inline_generator ) {
53 die
54 'A parameterizable constraint with an inline_generator parameter must also have a parameterized_inline_generator'
55 unless $self->_has_parameterized_inline_generator;
56 }
57
58 return;
59}
60
61sub parameterize {
62 my $self = shift;
63 my %args = @_;
64
65 my ( $parameter, $declared_at ) = @args{qw( of declared_at )};
66 does_role( $parameter, 'Specio::Constraint::Role::Interface' )
67 or confess
68 'The "of" parameter passed to ->parameterize must be an object which does the Specio::Constraint::Role::Interface role';
69
70 if ($declared_at) {
71 isa_class( $declared_at, 'Specio::DeclaredAt' )
72 or confess
73 'The "declared_at" parameter passed to ->parameterize must be a Specio::DeclaredAt object';
74 }
75
76 $declared_at = Specio::DeclaredAt->new_from_caller(1)
77 unless defined $declared_at;
78
79 my %p = (
80 parent => $self,
81 parameter => $parameter,
82 declared_at => $declared_at,
83 );
84
85 if ( $self->_has_parameterized_constraint_generator ) {
86 $p{constraint}
87 = $self->_parameterized_constraint_generator->($parameter);
88 }
89 else {
90 confess
91 'The "of" parameter passed to ->parameterize must be an inlinable constraint if the parameterizable type has an inline_generator'
92 unless $parameter->can_be_inlined;
93
94 my $ig = $self->_parameterized_inline_generator;
95 $p{inline_generator} = sub { $ig->( shift, $parameter, @_ ) };
96 }
97
98 return Specio::Constraint::Parameterized->new(%p);
99}
100
101__PACKAGE__->_ooify;
102
1031;
104
105# ABSTRACT: A class which represents parameterizable constraints
106
107__END__