| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Return::Type::Lexical; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Same thing as Return::Type, but lexical |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
154410
|
use 5.008; |
|
|
1
|
|
|
|
|
7
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
23
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
405
|
use parent 'Return::Type'; |
|
|
1
|
|
|
|
|
320
|
|
|
|
1
|
|
|
|
|
8
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
|
13
|
2
|
|
|
2
|
|
171
|
my ($class, %args) = @_; |
|
14
|
2
|
100
|
66
|
|
|
95
|
$^H{'Return::Type::Lexical/in_effect'} = exists $args{check} && !$args{check} ? 0 : 1; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub unimport { |
|
18
|
1
|
|
|
1
|
|
5445
|
$^H{'Return::Type::Lexical/in_effect'} = 0; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _in_effect { |
|
22
|
4
|
|
|
4
|
|
10
|
my ($level) = @_; |
|
23
|
4
|
50
|
|
|
|
14
|
$level = 0 if !defined $level; |
|
24
|
4
|
|
|
|
|
13
|
my $hinthash = (caller($level))[10]; |
|
25
|
4
|
|
|
|
|
82
|
my $in_effect = $hinthash->{'Return::Type::Lexical/in_effect'}; |
|
26
|
4
|
|
100
|
|
|
23
|
return !defined $in_effect || $in_effect; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# XXX This is kind of janky. It relies upon Return::Type using Attribute::Handlers, and it assumes |
|
30
|
|
|
|
|
|
|
# some internal Attribute::Handlers behavior. If it proves to be too fragile, we may need to copy |
|
31
|
|
|
|
|
|
|
# the Return::Type code to here. Or make Return::Type lexical if that can be done without breaking |
|
32
|
|
|
|
|
|
|
# backward-compatibility. |
|
33
|
|
|
|
|
|
|
my $handler; |
|
34
|
|
|
|
|
|
|
BEGIN { |
|
35
|
1
|
|
|
1
|
|
9039
|
$handler = $UNIVERSAL::{ReturnType}; |
|
36
|
1
|
|
|
|
|
3
|
delete $UNIVERSAL::{ReturnType}; |
|
37
|
1
|
|
|
|
|
66
|
delete $UNIVERSAL::{_ATTR_CODE_ReturnType}; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
sub UNIVERSAL::ReturnType :ATTR(CODE,BEGIN) { |
|
40
|
4
|
|
|
4
|
0
|
4996
|
my $in_effect = _in_effect(4); |
|
41
|
4
|
100
|
|
|
|
11
|
return if !$in_effect; |
|
42
|
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
5
|
return $handler->(@_); |
|
44
|
1
|
|
|
1
|
|
8
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
13
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |