line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Closure::Loop; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
116269
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
106
|
|
4
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
106
|
|
5
|
3
|
|
|
3
|
|
17
|
use Carp; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
280
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
3482
|
use version; our $VERSION = qv('0.0.3'); |
|
3
|
|
|
|
|
8385
|
|
|
3
|
|
|
|
|
19
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my @SIGS = qw(last next redo); |
10
|
|
|
|
|
|
|
my @EXPORTS = qw(yield); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
3
|
|
|
3
|
|
29
|
my $caller = caller; |
14
|
3
|
|
|
|
|
10
|
my %signals = map { $_ => 1 } ( @SIGS, @_ ); |
|
12
|
|
|
|
|
48
|
|
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
|
448
|
no strict 'refs'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1371
|
|
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
|
|
14
|
for my $sig (keys %signals) { |
19
|
12
|
|
|
|
|
64
|
*{ $caller . '::' . $sig } = sub { |
20
|
10
|
|
|
10
|
|
59
|
my $self = shift; |
21
|
10
|
50
|
33
|
|
|
71
|
croak "$sig must be called as a method" |
22
|
|
|
|
|
|
|
unless ref($self) && $self->isa($caller); |
23
|
10
|
|
|
|
|
49
|
die [ $self, $sig ]; |
24
|
12
|
|
|
|
|
53
|
}; |
25
|
|
|
|
|
|
|
|
26
|
12
|
|
|
|
|
64
|
*{ $caller . '::is_' . $sig } = sub { |
27
|
145
|
|
|
145
|
|
215
|
my $self = shift; |
28
|
145
|
50
|
33
|
|
|
935
|
croak "is_$sig must be called as a method" |
29
|
|
|
|
|
|
|
unless ref($self) && $self->isa($caller); |
30
|
145
|
|
33
|
|
|
324
|
my $excep = shift || $@; |
31
|
145
|
|
100
|
|
|
701
|
return ref($excep) eq 'ARRAY' && |
32
|
|
|
|
|
|
|
$excep->[0] == $self && |
33
|
|
|
|
|
|
|
$excep->[1] eq $sig; |
34
|
12
|
|
|
|
|
47
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
26
|
for my $sub ( @EXPORTS ) { |
38
|
3
|
|
|
|
|
6
|
*{ $caller . '::' . $sub } = \&{ $sub }; |
|
3
|
|
|
|
|
4763
|
|
|
3
|
|
|
|
|
9
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub yield { |
43
|
56
|
|
|
56
|
1
|
25891
|
my $self = shift; |
44
|
56
|
|
|
|
|
62
|
my $cb = shift; |
45
|
|
|
|
|
|
|
|
46
|
56
|
50
|
|
|
|
139
|
croak "yield must be called as a method" |
47
|
|
|
|
|
|
|
unless ref($self); |
48
|
|
|
|
|
|
|
|
49
|
56
|
50
|
|
|
|
115
|
croak "yield must be called with a callback (code ref)" |
50
|
|
|
|
|
|
|
unless ref($cb) eq 'CODE'; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Y: { |
53
|
56
|
|
|
|
|
57
|
eval { |
|
57
|
|
|
|
|
61
|
|
54
|
57
|
|
|
|
|
122
|
$cb->(@_); |
55
|
|
|
|
|
|
|
}; |
56
|
57
|
100
|
|
|
|
398
|
redo Y if $self->is_redo; |
57
|
56
|
100
|
|
|
|
121
|
return if $self->is_next; |
58
|
51
|
100
|
|
|
|
161
|
die $@ if $@; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |