line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Mux; |
2
|
3
|
|
|
3
|
|
171252
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
126
|
|
3
|
3
|
|
|
3
|
|
1381
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
102
|
|
4
|
3
|
|
|
3
|
|
16
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
3855
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
2
|
|
|
2
|
1
|
39
|
my $class = shift; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
|
|
3
|
my @subs; |
12
|
2
|
|
|
|
|
15
|
$class->_push(\@subs, \@_); |
13
|
2
|
|
|
|
|
17
|
bless { subs => \@subs }, $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
15
|
|
|
15
|
1
|
72
|
sub subs { $_[0]->{subs} } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub execute_first { |
19
|
2
|
|
|
2
|
1
|
657
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
5
|
for my $code (@{$self->subs}) { |
|
2
|
|
|
|
|
7
|
|
22
|
2
|
|
|
|
|
7
|
my $res = $code->(@_); |
23
|
2
|
50
|
|
|
|
19
|
return $res if defined $res; |
24
|
|
|
|
|
|
|
} |
25
|
0
|
|
|
|
|
0
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub execute { |
29
|
1
|
|
|
1
|
1
|
4
|
execute_first(@_); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub execute_all { |
33
|
2
|
|
|
2
|
1
|
10
|
my $self = shift; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
5
|
my $result; |
36
|
2
|
|
|
|
|
5
|
for my $code (@{$self->subs}) { |
|
2
|
|
|
|
|
8
|
|
37
|
8
|
|
|
|
|
41
|
my $res = $code->(@_); |
38
|
8
|
|
|
|
|
28
|
push @{$result}, $res; |
|
8
|
|
|
|
|
23
|
|
39
|
|
|
|
|
|
|
} |
40
|
2
|
|
|
|
|
24
|
return $result; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub execute_list { |
44
|
2
|
|
|
2
|
1
|
14
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
5
|
my $list = $self->subs; |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
3
|
my $result; |
49
|
2
|
|
|
|
|
6
|
for my $i (@_) { |
50
|
4
|
|
|
|
|
7
|
my $code = $list->[$i]; |
51
|
4
|
|
|
|
|
11
|
my $res = $code->(@_); |
52
|
4
|
|
|
|
|
15
|
push @{$result}, $res; |
|
4
|
|
|
|
|
12
|
|
53
|
|
|
|
|
|
|
} |
54
|
2
|
|
|
|
|
14
|
return $result; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub unshift_subs { |
58
|
2
|
|
|
2
|
1
|
15
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
9
|
$self->_unshift($self->subs, \@_); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _unshift { |
64
|
2
|
|
|
2
|
|
6
|
my ($self, $list, $append) = @_; |
65
|
|
|
|
|
|
|
|
66
|
2
|
|
|
|
|
4
|
for my $arg (reverse @{$append}) { |
|
2
|
|
|
|
|
8
|
|
67
|
4
|
50
|
|
|
|
12
|
if (ref $arg eq 'CODE') { |
68
|
4
|
|
|
|
|
5
|
unshift @{$list}, $arg; |
|
4
|
|
|
|
|
14
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
0
|
|
|
|
|
0
|
croak 'wrong subs'; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
1
|
1
|
2
|
sub shift_subs { shift @{$_[0]->subs}; } |
|
1
|
|
|
|
|
4
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub push_subs { |
79
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
4
|
$self->_push($self->subs, \@_); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _push { |
85
|
3
|
|
|
3
|
|
8
|
my ($self, $list, $append) = @_; |
86
|
|
|
|
|
|
|
|
87
|
3
|
|
|
|
|
7
|
for my $arg (@{$append}) { |
|
3
|
|
|
|
|
8
|
|
88
|
4
|
50
|
|
|
|
18
|
if (ref $arg eq 'CODE') { |
89
|
4
|
|
|
|
|
959
|
push @{$list}, $arg; |
|
4
|
|
|
|
|
17
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else { |
92
|
0
|
|
|
|
|
0
|
croak 'wrong subs'; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
1
|
1
|
2
|
sub pop_subs { pop @{$_[0]->subs}; } |
|
1
|
|
|
|
|
4
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |