/usr/local/lib/perl5/5.44.0/feature.pm

filter: Statementstmt 0.0% 0 / 77 Branchbran 0.0% 0 / 46 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 0.0% 0 / 9 Podpod 50.0% 3 / 6 totaltotal 1.8% 3 / 160 CC 33 SCAR 48.6
CC
33
Cov
0%
__common
272.0
feature_enabled
72.0
features_enabled
42.0
CRAP 129.0
« /usr/local/lib/perl5/5.44.0/Carp.pm ↑ Summary /usr/local/lib/perl5/5.44.0/x86_64-linux/IO/Socket.pm »
1 # -*- mode: Perl; buffer-read-only: t -*-
2 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
3 # This file is built by regen/feature.pl.
4 # Any changes made here will be lost!
5  
6 package feature;
7 our $VERSION = '2.02';
8  
9 our %feature = (
10 fc => 'feature_fc',
11 isa => 'feature_isa',
12 say => 'feature_say',
13 try => 'feature_try',
14 class => 'feature_class',
15 defer => 'feature_defer',
16 state => 'feature_state',
17 switch => 'feature_switch',
18 bitwise => 'feature_bitwise',
19 indirect => 'feature_indirect',
20 evalbytes => 'feature_evalbytes',
21 signatures => 'feature_signatures',
22 smartmatch => 'feature_smartmatch',
23 current_sub => 'feature___SUB__',
24 enhanced_xx => 'feature_enhanced_xx',
25 keyword_all => 'feature_keyword_all',
26 keyword_any => 'feature_keyword_any',
27 module_true => 'feature_module_true',
28 refaliasing => 'feature_refaliasing',
29 postderef_qq => 'feature_postderef_qq',
30 unicode_eval => 'feature_unieval',
31 declared_refs => 'feature_myref',
32 unicode_strings => 'feature_unicode',
33 multidimensional => 'feature_multidimensional',
34 bareword_filehandles => 'feature_bareword_filehandles',
35 extra_paired_delimiters => 'feature_more_delims',
36 apostrophe_as_package_separator => 'feature_apos_as_name_sep',
37 );
38  
39 our %feature_bundle = (
40 "5.10" => [qw(apostrophe_as_package_separator bareword_filehandles indirect multidimensional say smartmatch state switch)],
41 "5.11" => [qw(apostrophe_as_package_separator bareword_filehandles indirect multidimensional say smartmatch state switch unicode_strings)],
42 "5.15" => [qw(apostrophe_as_package_separator bareword_filehandles current_sub evalbytes fc indirect multidimensional say smartmatch state switch unicode_eval unicode_strings)],
43 "5.23" => [qw(apostrophe_as_package_separator bareword_filehandles current_sub evalbytes fc indirect multidimensional postderef_qq say smartmatch state switch unicode_eval unicode_strings)],
44 "5.27" => [qw(apostrophe_as_package_separator bareword_filehandles bitwise current_sub evalbytes fc indirect multidimensional postderef_qq say smartmatch state switch unicode_eval unicode_strings)],
45 "5.35" => [qw(apostrophe_as_package_separator bareword_filehandles bitwise current_sub evalbytes fc isa postderef_qq say signatures smartmatch state unicode_eval unicode_strings)],
46 "5.37" => [qw(apostrophe_as_package_separator bitwise current_sub evalbytes fc isa module_true postderef_qq say signatures smartmatch state unicode_eval unicode_strings)],
47 "5.39" => [qw(apostrophe_as_package_separator bitwise current_sub evalbytes fc isa module_true postderef_qq say signatures smartmatch state try unicode_eval unicode_strings)],
48 "5.41" => [qw(bitwise current_sub evalbytes fc isa module_true postderef_qq say signatures state try unicode_eval unicode_strings)],
49 "all" => [qw(apostrophe_as_package_separator bareword_filehandles bitwise class current_sub declared_refs defer enhanced_xx evalbytes extra_paired_delimiters fc indirect isa keyword_all keyword_any module_true multidimensional postderef_qq refaliasing say signatures smartmatch state switch try unicode_eval unicode_strings)],
50 "default" => [qw(apostrophe_as_package_separator bareword_filehandles indirect multidimensional smartmatch)],
51 );
52  
53 $feature_bundle{"5.12"} = $feature_bundle{"5.11"};
54 $feature_bundle{"5.13"} = $feature_bundle{"5.11"};
55 $feature_bundle{"5.14"} = $feature_bundle{"5.11"};
56 $feature_bundle{"5.16"} = $feature_bundle{"5.15"};
57 $feature_bundle{"5.17"} = $feature_bundle{"5.15"};
58 $feature_bundle{"5.18"} = $feature_bundle{"5.15"};
59 $feature_bundle{"5.19"} = $feature_bundle{"5.15"};
60 $feature_bundle{"5.20"} = $feature_bundle{"5.15"};
61 $feature_bundle{"5.21"} = $feature_bundle{"5.15"};
62 $feature_bundle{"5.22"} = $feature_bundle{"5.15"};
63 $feature_bundle{"5.24"} = $feature_bundle{"5.23"};
64 $feature_bundle{"5.25"} = $feature_bundle{"5.23"};
65 $feature_bundle{"5.26"} = $feature_bundle{"5.23"};
66 $feature_bundle{"5.28"} = $feature_bundle{"5.27"};
67 $feature_bundle{"5.29"} = $feature_bundle{"5.27"};
68 $feature_bundle{"5.30"} = $feature_bundle{"5.27"};
69 $feature_bundle{"5.31"} = $feature_bundle{"5.27"};
70 $feature_bundle{"5.32"} = $feature_bundle{"5.27"};
71 $feature_bundle{"5.33"} = $feature_bundle{"5.27"};
72 $feature_bundle{"5.34"} = $feature_bundle{"5.27"};
73 $feature_bundle{"5.36"} = $feature_bundle{"5.35"};
74 $feature_bundle{"5.38"} = $feature_bundle{"5.37"};
75 $feature_bundle{"5.40"} = $feature_bundle{"5.39"};
76 $feature_bundle{"5.42"} = $feature_bundle{"5.41"};
77 $feature_bundle{"5.43"} = $feature_bundle{"5.41"};
78 $feature_bundle{"5.44"} = $feature_bundle{"5.41"};
79 $feature_bundle{"5.9.5"} = $feature_bundle{"5.10"};
80 my %noops = (
81 postderef => 1,
82 lexical_subs => 1,
83 );
84 my %removed = (
85 array_base => 1,
86 );
87  
88 our $hint_shift = 26;
89 our $hint_mask = 0x3c000000;
90 our @hint_bundles = qw( default 5.10 5.11 5.15 5.23 5.27 5.35 5.37 5.39 5.41 );
91  
92 # This gets set (for now) in $^H as well as in %^H,
93 # for runtime speed of the uc/lc/ucfirst/lcfirst functions.
94 # See HINT_UNI_8_BIT in perl.h.
95 our $hint_uni8bit = 0x00000800;
96  
97 sub import {
98 0 ▶ shift;
Subroutine import: not called CC=2 SCAR=17.9
99  
100 0 ▶ if (!@_) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 0 0 0
101 0 croak("No features specified");
102 }
103  
104 0 __common(1, @_);
105 }
106  
107 sub unimport {
108 0 ▶ shift;
Subroutine unimport: not called CC=2 SCAR=17.9
109  
110 # A bare C<no feature> should reset to the default bundle
111 0 ▶ if (!@_) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 0 0 0
112 0 $^H &= ~($hint_uni8bit|$hint_mask);
113 0 return;
114 }
115  
116 0 __common(0, @_);
117 }
118  
119  
120 sub __common {
121 0 ▶ my $import = shift;
Subroutine __common: not called CC=16 SCAR=56.1
122 0 my $bundle_number = $^H & $hint_mask;
123 my $features = $bundle_number != $hint_mask
124 0 ▶ && $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]};
Condition0%0/3
$bundle_number != $hint_mask && $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]}
!ll&&!rl&&r
000
MC/DC0%0/2
$bundle_number != $hint_mask && $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]}
$bundle_number != $hint_mask $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]}
Truth table0%0/3
A && B
A= $bundle_number != $hint_maskB= $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]}
ABresult
0X0
100
111
125 0 ▶ if ($features) {
Branch: 1 branch
BranchTrueFalseTotal
if ($features) 0 0 0
126 # Features are enabled implicitly via bundle hints.
127 # Delete any keys that may be left over from last time.
128 0 delete @^H{ values(%feature) };
129 0 $^H |= $hint_mask;
130 0 for (@$features) {
131 0 $^H{$feature{$_}} = 1;
132 0 ▶ $^H |= $hint_uni8bit if $_ eq 'unicode_strings';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "unicode_strings" 0 0 0
133 }
134 }
135 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
136 0 my $name = shift;
137 0 ▶ if (substr($name, 0, 1) eq ":") {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($name, 0, 1) eq ":") 0 0 0
138 0 my $v = substr($name, 1);
139 0 ▶ if (!exists $feature_bundle{$v}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $feature_bundle{$v}) 0 0 0
140 0 $v =~ s/^([0-9]+)\.([0-9]+).[0-9]+$/$1.$2/;
141 0 ▶ if (!exists $feature_bundle{$v}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $feature_bundle{$v}) 0 0 0
142 0 unknown_feature_bundle(substr($name, 1));
143 }
144 }
145 0 unshift @_, @{$feature_bundle{$v}};
146 0 next;
147 }
148 0 ▶ if (!exists $feature{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $feature{$name}) 0 0 0
149 0 ▶ if (exists $noops{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $noops{$name}) 0 0 0
150 0 next;
151 }
152 0 ▶ if (!$import && exists $removed{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $import and exists $removed{$name}) 0 0 0
Condition0%0/3
not $import and exists $removed{$name}
!ll&&!rl&&r
000
MC/DC0%0/2
not $import and exists $removed{$name}
not $import exists $removed{$name}
Truth table0%0/3
not(A) and B
A= not $importB= exists $removed{$name}
ABresult
0X0
100
111
153 0 next;
154 }
155 0 unknown_feature($name);
156 }
157 0 ▶ if ($import) {
Branch: 1 branch
BranchTrueFalseTotal
if ($import) { } 0 0 0
158 0 $^H{$feature{$name}} = 1;
159 0 ▶ $^H |= $hint_uni8bit if $name eq 'unicode_strings';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "unicode_strings" 0 0 0
160 } else {
161 0 delete $^H{$feature{$name}};
162 0 ▶ $^H &= ~ $hint_uni8bit if $name eq 'unicode_strings';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "unicode_strings" 0 0 0
163 }
164 }
165 }
166  
167 sub unknown_feature {
168 0 ▶ my $feature = shift;
Subroutine unknown_feature: not called CC=1 SCAR=6.9
Pod undocumented
169 0 croak(sprintf('Feature "%s" is not supported by Perl %vd',
170 $feature, $^V));
171 }
172  
173 sub unknown_feature_bundle {
174 0 ▶ my $feature = shift;
Subroutine unknown_feature_bundle: not called CC=1 SCAR=6.9
Pod undocumented
175 0 croak(sprintf('Feature bundle "%s" is not supported by Perl %vd',
176 $feature, $^V));
177 }
178  
179 sub croak {
180 0 ▶ require Carp;
Subroutine croak: not called CC=1 SCAR=6.9
Pod undocumented
181 0 Carp::croak(@_);
182 }
183  
184 sub features_enabled {
185 0 ▶ my ($depth) = @_;
Subroutine features_enabled: not called CC=6 SCAR=37.4
Pod documented
186  
187 0 ▶ $depth //= 1;
Condition0%0/2
$depth //= 1
l!l
00
MC/DC0%0/1
$depth //= 1
$depth
Truth table0%0/2
A
A= $depth
Aresult
11
00
188 0 ▶ my @frame = caller($depth+1)
Branch: 1 branch
BranchTrueFalseTotal
my(@frame) = caller $depth + 1 or return 0 0 0
189 or return;
190 0 my ($hints, $hinthash) = @frame[8, 10];
191  
192 0 my $bundle_number = $hints & $hint_mask;
193 0 ▶ if ($bundle_number != $hint_mask) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bundle_number != $hint_mask) { } 0 0 0
194 0 return $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]}->@*;
195 }
196 else {
197 0 my @features;
198 0 for my $feature (sort keys %feature) {
199 0 ▶ if ($hinthash->{$feature{$feature}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$hinthash{$feature{$feature}}) 0 0 0
200 0 push @features, $feature;
201 }
202 }
203 0 return @features;
204 }
205 }
206  
207 sub feature_enabled {
208 0 ▶ my ($feature, $depth) = @_;
Subroutine feature_enabled: not called CC=8 SCAR=42.8
Pod documented
209  
210 0 ▶ $depth //= 1;
Condition0%0/2
$depth //= 1
l!l
00
MC/DC0%0/1
$depth //= 1
$depth
Truth table0%0/2
A
A= $depth
Aresult
11
00
211 0 ▶ my @frame = caller($depth+1)
Branch: 1 branch
BranchTrueFalseTotal
my(@frame) = caller $depth + 1 or return 0 0 0
212 or return;
213 0 my ($hints, $hinthash) = @frame[8, 10];
214  
215 0 ▶ my $hint_feature = $feature{$feature}
Branch: 1 branch
BranchTrueFalseTotal
my $hint_feature = $feature{$feature} or croak("Unknown feature $feature") 0 0 0
216 or croak "Unknown feature $feature";
217 0 my $bundle_number = $hints & $hint_mask;
218 0 ▶ if ($bundle_number != $hint_mask) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bundle_number != $hint_mask) { } 0 0 0
219 0 my $bundle = $hint_bundles[$bundle_number >> $hint_shift];
220 0 for my $bundle_feature ($feature_bundle{$bundle}->@*) {
221 0 ▶ return 1 if $bundle_feature eq $feature;
Branch: 1 branch
BranchTrueFalseTotal
if $bundle_feature eq $feature 0 0 0
222 }
223 0 return 0;
224 }
225 else {
226 0 ▶ return $hinthash->{$hint_feature} // 0;
Condition0%0/2
$hinthash->{$hint_feature} // 0
l!l
00
MC/DC0%0/1
$hinthash->{$hint_feature} // 0
$hinthash->{$hint_feature}
Truth table0%0/2
A
A= $hinthash->{$hint_feature}
Aresult
11
00
227 }
228 }
229  
230 sub feature_bundle {
231 0 ▶ my $depth = shift;
Subroutine feature_bundle: not called CC=4 SCAR=30.0
Pod documented
232  
233 0 ▶ $depth //= 1;
Condition0%0/2
$depth //= 1
l!l
00
MC/DC0%0/1
$depth //= 1
$depth
Truth table0%0/2
A
A= $depth
Aresult
11
00
234 0 ▶ my @frame = caller($depth+1)
Branch: 1 branch
BranchTrueFalseTotal
my(@frame) = caller $depth + 1 or return 0 0 0
235 or return;
236 0 my $bundle_number = $frame[8] & $hint_mask;
237 0 ▶ if ($bundle_number != $hint_mask) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bundle_number != $hint_mask) { } 0 0 0
238 0 return $hint_bundles[$bundle_number >> $hint_shift];
239 }
240 else {
241 0 return undef;
242 }
243 }
244  
245 1;
246  
247 __END__
« /usr/local/lib/perl5/5.44.0/Carp.pm ↑ Summary /usr/local/lib/perl5/5.44.0/x86_64-linux/IO/Socket.pm »