line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Enumerator::Deeply; |
2
|
8
|
|
|
8
|
|
46
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
279
|
|
3
|
8
|
|
|
8
|
|
42
|
use warnings; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
197
|
|
4
|
8
|
|
|
8
|
|
41
|
use Data::Enumerator::Base; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
238
|
|
5
|
8
|
|
|
8
|
|
10907
|
use Data::Visitor::Lite; |
|
8
|
|
|
|
|
61398
|
|
|
8
|
|
|
|
|
1414
|
|
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
package Data::Enumerator::Deeply::_Swap; |
8
|
|
|
|
|
|
|
sub new { |
9
|
11
|
|
|
11
|
|
17
|
my ( $class,$id ) = @_; |
10
|
11
|
|
|
|
|
50
|
return bless \$id , $class; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
sub value { |
13
|
15955
|
|
|
15955
|
|
20431
|
my ( $self,$value ) = @_; |
14
|
15955
|
|
|
|
|
33603
|
return $value->[$self->id]; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
sub id{ |
17
|
15955
|
|
|
15955
|
|
18588
|
my ( $self ) = @_; |
18
|
15955
|
|
|
|
|
57593
|
$$self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
package Data::Enumerator::Deeply::_Fixed; |
23
|
8
|
|
|
8
|
|
86
|
use base qw/Data::Enumerator::Deeply::_Swap/; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
12191
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
1
|
|
|
1
|
|
2
|
my ( $class,$generator ) = @_; |
26
|
1
|
|
|
|
|
11
|
return bless { generator => $generator } , $class; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
sub _generator{ |
29
|
1
|
|
|
1
|
|
7
|
shift->{generator}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
sub value { |
32
|
102
|
|
|
102
|
|
217
|
my $value = shift->_iterator->(); |
33
|
102
|
50
|
|
|
|
308
|
return if Data::Enumerator::Base->is_last($value); |
34
|
102
|
|
|
|
|
473
|
return $value; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
sub _iterator { |
37
|
102
|
|
|
102
|
|
133
|
my ($self ) = @_; |
38
|
102
|
|
66
|
|
|
665
|
return $self->{_iterator} ||= $self->_generator->iterator; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
sub independ { |
42
|
1
|
|
|
1
|
0
|
13
|
return Data::Enumerator::Deeply::_Fixed->new($_[0]); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub __swapper { |
46
|
11
|
|
|
11
|
|
17
|
my ( $id ) = @_; |
47
|
11
|
|
|
|
|
40
|
return Data::Enumerator::Deeply::_Swap->new($id); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub __product_all { |
51
|
3
|
|
|
3
|
|
10
|
my ( @generators ) = @_; |
52
|
3
|
|
|
|
|
6
|
my $result = shift @generators; |
53
|
3
|
|
|
|
|
23
|
while( my $gen = shift @generators ) { |
54
|
8
|
|
|
|
|
50
|
$result = $result->product($gen); |
55
|
|
|
|
|
|
|
} |
56
|
3
|
|
|
|
|
12
|
return $result; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub compose { |
60
|
3
|
|
|
3
|
0
|
7
|
my ( $class, $struct ) = @_; |
61
|
3
|
|
|
|
|
13
|
my ( $template, $object ) = __get_template_and_generator($struct); |
62
|
|
|
|
|
|
|
return $object->select(sub{ |
63
|
3235
|
|
|
3235
|
|
3793
|
my $value = shift; |
64
|
3235
|
|
|
|
|
5516
|
__convert_by_template( $template,$value ); |
65
|
3
|
|
|
|
|
36
|
}); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub __get_template_and_generator{ |
69
|
3
|
|
|
3
|
|
7
|
my ( $struct ) = @_; |
70
|
3
|
|
|
|
|
5
|
my @generators; |
71
|
3
|
|
|
|
|
7
|
my $count = 0; |
72
|
|
|
|
|
|
|
my $v = Data::Visitor::Lite->new( |
73
|
|
|
|
|
|
|
['-instance' => 'Data::Enumerator::Base'=> sub { |
74
|
11
|
|
|
11
|
|
505
|
my ($obj) = @_; |
75
|
11
|
|
|
|
|
17
|
push @generators,$obj; |
76
|
11
|
|
|
|
|
27
|
return __swapper( $count++); |
77
|
3
|
|
|
|
|
43
|
}] |
78
|
|
|
|
|
|
|
); |
79
|
3
|
|
|
|
|
133
|
my $template = $v->visit( $struct ); |
80
|
3
|
|
|
|
|
71
|
my $producted = __product_all(@generators); |
81
|
3
|
|
|
|
|
138
|
return ($template,$producted); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub __convert_by_template { |
85
|
3235
|
|
|
3235
|
|
4093
|
my ( $template, $value ) = @_; |
86
|
|
|
|
|
|
|
my $v = Data::Visitor::Lite->new( |
87
|
|
|
|
|
|
|
[ -instance => 'Data::Enumerator::Deeply::_Swap' => sub { |
88
|
16057
|
|
|
16057
|
|
518027
|
my ($obj ) = @_; |
89
|
16057
|
|
|
|
|
29801
|
return $obj->value($value); |
90
|
|
|
|
|
|
|
} |
91
|
3235
|
|
|
|
|
21667
|
] |
92
|
|
|
|
|
|
|
); |
93
|
3235
|
|
|
|
|
102531
|
return $v->visit($template); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |