line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Package::Pkg::Lexicon; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
681
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
892
|
use Mouse; |
|
1
|
|
|
|
|
31329
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
1046
|
use Clone qw/ clone /; |
|
1
|
|
|
|
|
194834
|
|
|
1
|
|
|
|
|
3779
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has lexicon => qw/ is ro lazy_build 1 isa HashRef /; |
11
|
3
|
|
|
3
|
|
25
|
sub _build_lexicon { {} } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has prefix => qw/ accessor _prefix isa Maybe[Str] /; |
14
|
|
|
|
|
|
|
has suffix => qw/ accessor _suffix isa Maybe[Str] /; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub prefix { |
17
|
16
|
|
|
16
|
0
|
23
|
my $self = shift; |
18
|
16
|
100
|
|
|
|
105
|
return $self->_prefix unless @_; |
19
|
6
|
|
|
|
|
26
|
$self->_prefix( $_[0] ); |
20
|
6
|
|
|
|
|
26
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub suffix { |
24
|
10
|
|
|
10
|
0
|
13
|
my $self = shift; |
25
|
10
|
50
|
|
|
|
135
|
return $self->_suffix unless @_; |
26
|
0
|
|
|
|
|
0
|
$self->_suffix( $_[0] ); |
27
|
0
|
|
|
|
|
0
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub copy { |
31
|
6
|
|
|
6
|
0
|
1505
|
my $self = shift; |
32
|
6
|
|
|
|
|
8
|
my $lexicon; |
33
|
6
|
50
|
|
|
|
16
|
if ( @_ ) { $lexicon = { $self->slice( @_ ) } } |
|
0
|
|
|
|
|
0
|
|
34
|
6
|
|
|
|
|
93
|
else { $lexicon = clone( $self->lexicon ) } |
35
|
6
|
|
|
|
|
28
|
return (ref $self)->new( |
36
|
|
|
|
|
|
|
lexicon => $lexicon, |
37
|
|
|
|
|
|
|
prefix => $self->prefix, |
38
|
|
|
|
|
|
|
suffix => $self->suffix, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub add { |
43
|
3
|
|
|
3
|
0
|
1276
|
my $self = shift; |
44
|
|
|
|
|
|
|
|
45
|
3
|
50
|
|
|
|
12
|
die "Missing name & subroutine" unless @_; |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
12
|
while ( @_ ) { |
48
|
8
|
|
|
|
|
15
|
my $name = shift; |
49
|
8
|
|
|
|
|
8
|
my $subroutine = shift; |
50
|
8
|
50
|
33
|
|
|
48
|
next unless defined $name and defined $subroutine; |
51
|
8
|
50
|
|
|
|
38
|
die "Invalid name ($name)" unless $name =~ m/^\w+$/; |
52
|
8
|
50
|
|
|
|
21
|
die "Invalid subroutine ($subroutine)" unless ref $subroutine eq 'CODE'; |
53
|
8
|
|
|
|
|
48
|
$self->lexicon->{$name} = $subroutine; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
|
|
7
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub remove { |
60
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
1
|
50
|
|
|
|
5
|
die "Missing name" unless @_; |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
4
|
for my $name ( @_ ) { |
65
|
2
|
50
|
|
|
|
7
|
next unless defined $name; |
66
|
2
|
|
|
|
|
7
|
delete $self->lexicon->{$name}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
3
|
return $self; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get { |
73
|
2
|
|
|
2
|
0
|
8
|
my $self = shift; |
74
|
2
|
50
|
|
|
|
10
|
my @namelist = @_ ? @_ : keys %{ $self->lexicon }; |
|
2
|
|
|
|
|
12
|
|
75
|
2
|
50
|
|
|
|
7
|
return map { defined $_ ? $self->lexicon->{$_} : undef } @namelist; |
|
6
|
|
|
|
|
37
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub slice { |
79
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
80
|
3
|
50
|
|
|
|
8
|
return %{ $self->lexicon } unless @_; |
|
3
|
|
|
|
|
33
|
|
81
|
0
|
0
|
|
|
|
0
|
my @namelist = @_ ? @_ : keys %{ $self->lexicon }; |
|
0
|
|
|
|
|
0
|
|
82
|
0
|
0
|
|
|
|
0
|
my @valuelist = map { defined $_ ? $self->lexicon->{$_} : undef } @namelist; |
|
0
|
|
|
|
|
0
|
|
83
|
0
|
|
|
|
|
0
|
my %slice; |
84
|
0
|
|
|
|
|
0
|
@slice{ @namelist } = @valuelist; |
85
|
0
|
|
|
|
|
0
|
return %slice; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub export { |
89
|
4
|
|
|
4
|
0
|
89
|
my $self = shift; |
90
|
4
|
50
|
|
|
|
11
|
my @namelist = @_ ? @_ : keys %{ $self->lexicon }; |
|
4
|
|
|
|
|
29
|
|
91
|
4
|
50
|
|
|
|
13
|
my @valuelist = map { defined $_ ? $self->lexicon->{$_} : undef } @namelist; |
|
8
|
|
|
|
|
31
|
|
92
|
4
|
100
|
|
|
|
14
|
if ( defined ( my $prefix = $self->prefix ) ) { |
93
|
2
|
50
|
|
|
|
5
|
@namelist = map { defined $_ ? join '_', $prefix, $_ : undef } @namelist; |
|
4
|
|
|
|
|
16
|
|
94
|
|
|
|
|
|
|
} |
95
|
4
|
50
|
|
|
|
10
|
if ( defined ( my $suffix = $self->suffix ) ) { |
96
|
0
|
0
|
|
|
|
0
|
@namelist = map { defined $_ ? join '_', $_, $suffix : undef } @namelist; |
|
0
|
|
|
|
|
0
|
|
97
|
|
|
|
|
|
|
} |
98
|
4
|
|
|
|
|
8
|
my %export; |
99
|
4
|
|
|
|
|
13
|
@export{ @namelist } = @valuelist; |
100
|
4
|
|
|
|
|
37
|
return %export; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub filter { |
104
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub map { |
108
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub install { |
112
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
113
|
|
|
|
|
|
|
# overwrite => 0|1 |
114
|
|
|
|
|
|
|
# collide => 0|1|2 |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |