line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Heap::Simple::Method; |
2
|
|
|
|
|
|
|
$VERSION = "0.05"; |
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
461
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $method_name = "k0"; |
7
|
|
|
|
|
|
|
my %method_names; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _elements { |
10
|
476
|
|
|
476
|
|
1339
|
my ($class, $heap, $name, $elements) = @_; |
11
|
476
|
100
|
|
|
|
1897
|
if (!defined $elements->[1]) { |
12
|
32
|
100
|
|
|
|
419
|
$class->isa("Heap::Simple::Wrapper") || |
13
|
|
|
|
|
|
|
croak "missing key method for $elements->[0]"; |
14
|
31
|
|
|
|
|
96
|
$heap->[0]{complex} = 1; |
15
|
31
|
|
|
|
|
169
|
return $name, "0"; |
16
|
|
|
|
|
|
|
} |
17
|
444
|
|
|
|
|
1428
|
$heap->[0]{index} = $elements->[1]; |
18
|
444
|
100
|
66
|
|
|
3790
|
return $name, $method_names{$heap->[0]{index}} ||= $method_name++ if |
19
|
|
|
|
|
|
|
$elements->[1] =~ /\A[_A-Za-z][A-Za-z0-9]*\z/; |
20
|
222
|
|
|
|
|
597
|
$heap->[0]{complex} = 1; |
21
|
222
|
|
|
|
|
1111
|
return $name; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _ELEMENTS_PREPARE { |
25
|
370
|
100
|
|
370
|
|
4974
|
return shift->[0]{complex} ? "my \$name = \$heap->[0]{index};" : ""; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _KEY { |
29
|
1585
|
100
|
|
1585
|
|
41353
|
return shift->[0]{complex} ? shift() . "->\$name" : shift() . "->_LITERAL"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _QUICK_KEY { |
33
|
180
|
100
|
|
180
|
|
8320
|
return return shift->[0]{complex} ? "-" : shift() . "->_LITERAL" |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub key_method { |
37
|
20
|
|
|
20
|
0
|
11564
|
my $heap = shift; |
38
|
20
|
100
|
|
|
|
120
|
if ($heap->[0]{complex}) { |
39
|
10
|
|
|
|
|
61
|
$heap->_make(qq(sub key_method { |
40
|
|
|
|
|
|
|
return shift->[0]{index}; |
41
|
|
|
|
|
|
|
})); |
42
|
|
|
|
|
|
|
} else { |
43
|
10
|
|
|
|
|
52
|
$heap->_make(qq(sub key_method() { |
44
|
|
|
|
|
|
|
return _STRING; |
45
|
|
|
|
|
|
|
})); |
46
|
|
|
|
|
|
|
} |
47
|
20
|
|
|
|
|
7756
|
return $heap->key_method(@_); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub elements { |
51
|
244
|
100
|
|
244
|
0
|
29230
|
return wantarray ? (Method => shift->[0]{index}) : "Method"; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |