line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graph::Attribute; |
2
|
|
|
|
|
|
|
|
3
|
82
|
|
|
82
|
|
140348
|
use strict; |
|
82
|
|
|
|
|
207
|
|
|
82
|
|
|
|
|
2574
|
|
4
|
82
|
|
|
82
|
|
699
|
use warnings; |
|
82
|
|
|
|
|
817
|
|
|
82
|
|
|
|
|
8100
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my @API = qw(get_attribute |
7
|
|
|
|
|
|
|
get_attributes |
8
|
|
|
|
|
|
|
set_attribute |
9
|
|
|
|
|
|
|
set_attributes |
10
|
|
|
|
|
|
|
has_attribute |
11
|
|
|
|
|
|
|
has_attributes |
12
|
|
|
|
|
|
|
delete_attribute |
13
|
|
|
|
|
|
|
delete_attributes |
14
|
|
|
|
|
|
|
get_attribute_names |
15
|
|
|
|
|
|
|
get_attribute_values); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import { |
18
|
82
|
|
|
82
|
|
232
|
my $package = shift; |
19
|
82
|
|
|
|
|
3945
|
my %attr = @_; |
20
|
82
|
|
|
|
|
223
|
my $caller = caller(0); |
21
|
82
|
100
|
|
|
|
304
|
if (exists $attr{array}) { |
|
|
50
|
|
|
|
|
|
22
|
81
|
|
|
|
|
1817
|
my $i = $attr{array}; |
23
|
82
|
|
|
82
|
|
636
|
no strict 'refs'; |
|
82
|
|
|
|
|
208
|
|
|
82
|
|
|
|
|
19698
|
|
24
|
81
|
|
|
16120
|
|
332
|
*{"${caller}::_g_get_attributes"} = sub { $_[0]->[ $i ] }; |
|
81
|
|
|
|
|
459
|
|
|
16120
|
|
|
|
|
24050
|
|
25
|
81
|
|
|
|
|
292
|
*{"${caller}::_g_set_attributes"} = |
26
|
623
|
|
100
|
623
|
|
2585
|
sub { $_[0]->[ $i ] ||= { }; |
27
|
623
|
100
|
|
|
|
1563
|
$_[0]->[ $i ] = $_[1] if @_ == 2; |
28
|
81
|
|
|
|
|
293
|
$_[0]->[ $i ] }; |
|
623
|
|
|
|
|
1175
|
|
29
|
81
|
|
|
5
|
|
248
|
*{"${caller}::_g_has_attributes"} = sub { defined $_[0]->[ $i ] }; |
|
81
|
|
|
2
|
|
301
|
|
|
5
|
|
|
|
|
129
|
|
30
|
81
|
|
|
2
|
|
266
|
*{"${caller}::_g_delete_attributes"} = sub { undef $_[0]->[ $i ]; 1 }; |
|
81
|
|
|
|
|
323
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
7
|
|
31
|
|
|
|
|
|
|
} elsif (exists $attr{hash}) { |
32
|
1
|
|
|
|
|
2
|
my $k = $attr{hash}; |
33
|
82
|
|
|
82
|
|
663
|
no strict 'refs'; |
|
82
|
|
|
|
|
247
|
|
|
82
|
|
|
|
|
29079
|
|
34
|
1
|
|
|
3
|
|
3
|
*{"${caller}::_g_get_attributes"} = sub { $_[0]->{ $k } }; |
|
1
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
16
|
|
35
|
1
|
|
|
|
|
4
|
*{"${caller}::_g_set_attributes"} = |
36
|
1
|
|
50
|
1
|
|
10
|
sub { $_[0]->{ $k } ||= { }; |
37
|
1
|
50
|
|
|
|
5
|
$_[0]->{ $k } = $_[1] if @_ == 2; |
38
|
1
|
|
|
|
|
3
|
$_[0]->{ $k } }; |
|
1
|
|
|
|
|
25
|
|
39
|
1
|
|
|
3
|
|
3
|
*{"${caller}::_g_has_attributes"} = sub { defined $_[0]->{ $k } }; |
|
1
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
123
|
|
40
|
1
|
|
|
1
|
|
3
|
*{"${caller}::_g_delete_attributes"} = sub { delete $_[0]->{ $k } }; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
13
|
|
41
|
|
|
|
|
|
|
} else { |
42
|
|
|
|
|
|
|
# uncoverable statement |
43
|
0
|
|
|
|
|
0
|
die "Graph::Attribute::import($package @_) caller $caller\n"; |
44
|
|
|
|
|
|
|
} |
45
|
82
|
100
|
|
|
|
2063
|
if (exists $attr{map}) { |
46
|
80
|
|
|
|
|
161
|
my $map = $attr{map}; |
47
|
80
|
|
|
|
|
2029
|
for my $api (@API) { |
48
|
800
|
|
|
|
|
3958
|
my ($first, $rest) = ($api =~ /^(\w+?)_(.+)/); |
49
|
82
|
|
|
82
|
|
665
|
no strict 'refs'; |
|
82
|
|
|
|
|
173
|
|
|
82
|
|
|
|
|
44970
|
|
50
|
800
|
|
|
|
|
1688
|
*{"${caller}::${first}_${map}_${rest}"} = \&$api; |
|
800
|
|
|
|
|
29886
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub set_attribute { |
56
|
621
|
|
|
621
|
0
|
2325
|
my $g = shift; |
57
|
621
|
|
|
|
|
978
|
my $v = pop; |
58
|
621
|
|
|
|
|
956
|
my $a = pop; |
59
|
621
|
|
|
|
|
1496
|
my $p = $g->_g_set_attributes; |
60
|
621
|
|
|
|
|
1525
|
$p->{ $a } = $v; |
61
|
621
|
|
|
|
|
1682
|
return 1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub set_attributes { |
65
|
1
|
|
|
1
|
0
|
4
|
my $g = shift; |
66
|
1
|
|
|
|
|
4
|
my $a = pop; |
67
|
1
|
|
|
|
|
3
|
my $p = $g->_g_set_attributes( $a ); |
68
|
1
|
|
|
|
|
6
|
return 1; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub has_attribute { |
72
|
3
|
|
|
3
|
0
|
406
|
my $g = shift; |
73
|
3
|
|
|
|
|
7
|
my $a = pop; |
74
|
3
|
|
|
|
|
7
|
my $p = $g->_g_get_attributes; |
75
|
3
|
50
|
|
|
|
15
|
$p ? exists $p->{ $a } : 0; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub has_attributes { |
79
|
10
|
|
|
10
|
0
|
2044
|
my $g = shift; |
80
|
10
|
100
|
|
|
|
23
|
$g->_g_get_attributes ? 1 : 0; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_attribute { |
84
|
15864
|
|
|
15864
|
0
|
29600
|
my $g = shift; |
85
|
15864
|
|
|
|
|
19524
|
my $a = pop; |
86
|
15864
|
|
|
|
|
24273
|
my $p = $g->_g_get_attributes; |
87
|
15864
|
100
|
|
|
|
46245
|
$p ? $p->{ $a } : undef; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub delete_attribute { |
91
|
230
|
|
|
230
|
0
|
464
|
my $g = shift; |
92
|
230
|
|
|
|
|
363
|
my $a = pop; |
93
|
230
|
100
|
|
|
|
493
|
return 0 unless defined(my $p = $g->_g_get_attributes); |
94
|
229
|
|
|
|
|
13553
|
delete $p->{ $a }; |
95
|
229
|
|
|
|
|
1070
|
return 1; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub delete_attributes { |
99
|
2
|
|
|
2
|
0
|
5
|
my $g = shift; |
100
|
2
|
100
|
|
|
|
5
|
return 0 if !$g->_g_has_attributes; |
101
|
1
|
|
|
|
|
4
|
$g->_g_delete_attributes; |
102
|
1
|
|
|
|
|
7
|
return 1; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub get_attribute_names { |
106
|
3
|
|
|
3
|
0
|
6
|
my $g = shift; |
107
|
3
|
|
|
|
|
9
|
my $p = $g->_g_get_attributes; |
108
|
3
|
100
|
|
|
|
11
|
defined $p ? keys %{ $p } : ( ); |
|
2
|
|
|
|
|
18
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub get_attribute_values { |
112
|
3
|
|
|
3
|
0
|
8
|
my $g = shift; |
113
|
3
|
|
|
|
|
10
|
my $p = $g->_g_get_attributes; |
114
|
3
|
100
|
|
|
|
13
|
defined $p ? values %{ $p } : ( ); |
|
2
|
|
|
|
|
20
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub get_attributes { |
118
|
4
|
|
|
4
|
0
|
654
|
$_[0]->_g_get_attributes; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |