line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
30
|
|
|
30
|
|
486
|
use warnings; |
|
30
|
|
|
|
|
54
|
|
|
30
|
|
|
|
|
821
|
|
4
|
30
|
|
|
30
|
|
132
|
|
|
30
|
|
|
|
|
47
|
|
|
30
|
|
|
|
|
1026
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.48'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Specio::OO; |
8
|
30
|
|
|
30
|
|
139
|
|
|
30
|
|
|
|
|
47
|
|
|
30
|
|
|
|
|
7381
|
|
9
|
|
|
|
|
|
|
{ |
10
|
|
|
|
|
|
|
my $attrs = { |
11
|
|
|
|
|
|
|
package => { |
12
|
|
|
|
|
|
|
isa => 'Str', |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
}, |
15
|
|
|
|
|
|
|
filename => { |
16
|
|
|
|
|
|
|
isa => 'Str', |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
}, |
19
|
|
|
|
|
|
|
line => { |
20
|
|
|
|
|
|
|
isa => 'Int', |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
subroutine => { |
24
|
|
|
|
|
|
|
isa => 'Str', |
25
|
|
|
|
|
|
|
predicate => 'has_subroutine', |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
30
|
|
|
|
|
|
|
return $attrs; |
31
|
|
|
|
|
|
|
} |
32
|
9421
|
|
|
9421
|
|
12336
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $class = shift; |
35
|
|
|
|
|
|
|
my $depth = shift; |
36
|
|
|
|
|
|
|
|
37
|
947
|
|
|
947
|
1
|
1283
|
my %p; |
38
|
947
|
|
|
|
|
1069
|
@p{qw( package filename line )} = ( caller($depth) )[ 0, 1, 2 ]; |
39
|
|
|
|
|
|
|
|
40
|
947
|
|
|
|
|
1070
|
my $sub = ( caller( $depth + 1 ) )[3]; |
41
|
947
|
|
|
|
|
6621
|
$p{subroutine} = $sub if defined $sub; |
42
|
|
|
|
|
|
|
|
43
|
947
|
|
|
|
|
3603
|
return $class->new(%p); |
44
|
947
|
100
|
|
|
|
2440
|
} |
45
|
|
|
|
|
|
|
|
46
|
947
|
|
|
|
|
2769
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $package = $self->package; |
49
|
|
|
|
|
|
|
my $filename = $self->filename; |
50
|
924
|
|
|
924
|
1
|
2805
|
my $line = $self->line; |
51
|
|
|
|
|
|
|
|
52
|
924
|
|
|
|
|
1805
|
my $desc = "declared in package $package ($filename) at line $line"; |
53
|
924
|
|
|
|
|
2891
|
if ( $self->has_subroutine ) { |
54
|
924
|
|
|
|
|
2742
|
$desc .= ' in sub named ' . $self->subroutine; |
55
|
|
|
|
|
|
|
} |
56
|
924
|
|
|
|
|
2834
|
|
57
|
924
|
100
|
|
|
|
1741
|
return $desc; |
58
|
857
|
|
|
|
|
3216
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__PACKAGE__->_ooify; |
61
|
924
|
|
|
|
|
4686
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# ABSTRACT: A class to represent where a type or coercion was declared |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=pod |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=encoding UTF-8 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Specio::DeclaredAt - A class to represent where a type or coercion was declared |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 VERSION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
version 0.48 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 SYNOPSIS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $declared = Specio::DeclaredAt->new_from_caller(1); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
print $declared->description; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DESCRIPTION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This class provides a thin wrapper around some of the return values from Perl's |
88
|
|
|
|
|
|
|
C<caller> built-in. It's used internally to identify where types and coercions |
89
|
|
|
|
|
|
|
are being declared, which is useful when generating error messages. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 API |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This class provides the following methods. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 Specio::DeclaredAt->new_from_caller($depth) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Given a call stack depth, this method returns a new C<Specio::DeclaredAt> |
98
|
|
|
|
|
|
|
object. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 $declared_at->package, $declared_at->filename, $declared_at->line |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns the call stack information recorded when the object was created. These |
103
|
|
|
|
|
|
|
values are always populated. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 $declared_at->subroutine |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns the subroutine from the call stack. This may be an C<udnef> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 $declared_at->has_subroutine |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns true if there is a subroutine name associated with this object. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 $declared_at->description |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Puts all the information together into a single string like "declared in |
116
|
|
|
|
|
|
|
package Foo::Bar (.../Foo/Bar.pm) at line 42 in sub named blah". |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SUPPORT |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Specio/issues>. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SOURCE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The source code repository for Specio can be found at L<https://github.com/houseabsolute/Specio>. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 AUTHOR |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This software is Copyright (c) 2012 - 2022 by Dave Rolsky. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This is free software, licensed under: |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The full text of the license can be found in the |
139
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |