line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
7
|
use strict; use warnings; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
2
|
|
|
|
|
|
|
package immutable::map; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package immutable::map::tied; |
7
|
1
|
|
|
1
|
|
5
|
use base 'Hash::Ordered'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
535
|
|
8
|
1
|
|
|
1
|
|
3815
|
use immutable::tied; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
111
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import { |
11
|
0
|
|
|
0
|
|
0
|
die "Don't 'use immutable::map' directly"; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Prevent tied changes to immutable::map. |
16
|
|
|
|
|
|
|
# Mutation operations must use method calls which will return a new map. |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
3
|
sub STORE { err 'set a key/value on', '->set($key, $val)' } |
19
|
1
|
|
|
1
|
|
1092
|
sub DELETE { err 'delete a key from', '->del($key)' } |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
0
|
|
0
|
sub CLEAR { err } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package immutable::map; |
26
|
1
|
|
|
1
|
|
400
|
use immutable::base; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
27
|
1
|
|
|
1
|
|
6
|
use base 'immutable::base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
416
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
2
|
|
|
2
|
0
|
3
|
my $class = shift; |
31
|
2
|
|
|
|
|
14
|
tie my %hash, 'immutable::map::tied', @_; |
32
|
2
|
|
|
|
|
41
|
bless \%hash, $class; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub get { |
36
|
2
|
|
|
2
|
0
|
517
|
tied(%{$_[0]})->get($_[1]); |
|
2
|
|
|
|
|
13
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub set { |
40
|
3
|
|
|
3
|
0
|
820
|
my $self = shift; |
41
|
3
|
|
|
|
|
16
|
tie my %hash, 'immutable::map::tied', %$self; |
42
|
3
|
100
|
|
|
|
162
|
if (@_ == 2) { |
43
|
2
|
|
|
|
|
10
|
tied(%hash)->set(@_); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
1
|
|
|
|
|
7
|
tied(%hash)->push(@_); |
47
|
|
|
|
|
|
|
} |
48
|
3
|
|
|
|
|
49
|
bless \%hash, ref($self); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub del { |
52
|
1
|
|
|
1
|
0
|
540
|
my $self = shift; |
53
|
1
|
|
|
|
|
5
|
tie my %hash, 'immutable::map::tied', %$self; |
54
|
1
|
|
|
|
|
52
|
tied(%hash)->delete(@_); |
55
|
1
|
|
|
|
|
25
|
bless \%hash, ref($self); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub size { |
59
|
10
|
|
|
10
|
0
|
16
|
0 + @{tied(%{$_[0]})->[1]}; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
112
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub DESTROY { |
63
|
6
|
|
|
6
|
|
1252
|
untie(%{$_[0]}); |
|
6
|
|
|
|
|
157
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# TODO should not proxy mutating methods. |
67
|
|
|
|
|
|
|
our $AUTOLOAD; |
68
|
|
|
|
|
|
|
sub AUTOLOAD { |
69
|
2
|
|
|
2
|
|
19
|
(my $method = $AUTOLOAD) =~ s/^.*:://; |
70
|
2
|
|
|
|
|
3
|
tied(%{shift()})->$method(@_); |
|
2
|
|
|
|
|
9
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |