Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/5.18.0/warnings.pm |
Statements | Executed 969 statements in 1.14ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
139 | 112 | 109 | 479µs | 479µs | import | warnings::
3 | 1 | 1 | 153µs | 169µs | register_categories | warnings::
14 | 14 | 9 | 134µs | 134µs | unimport | warnings::
6 | 2 | 1 | 17µs | 17µs | _mkMask | warnings::
1 | 1 | 1 | 12µs | 12µs | CORE:regcomp (opcode) | warnings::
1 | 1 | 1 | 3µs | 3µs | CORE:match (opcode) | warnings::
0 | 0 | 0 | 0s | 0s | Croaker | warnings::
0 | 0 | 0 | 0s | 0s | __chk | warnings::
0 | 0 | 0 | 0s | 0s | _bits | warnings::
0 | 0 | 0 | 0s | 0s | _error_loc | warnings::
0 | 0 | 0 | 0s | 0s | bits | warnings::
0 | 0 | 0 | 0s | 0s | enabled | warnings::
0 | 0 | 0 | 0s | 0s | fatal_enabled | warnings::
0 | 0 | 0 | 0s | 0s | warn | warnings::
0 | 0 | 0 | 0s | 0s | warnif | warnings::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # -*- buffer-read-only: t -*- | ||||
2 | # !!!!!!! DO NOT EDIT THIS FILE !!!!!!! | ||||
3 | # This file is built by regen/warnings.pl. | ||||
4 | # Any changes made here will be lost! | ||||
5 | |||||
6 | package warnings; | ||||
7 | |||||
8 | 1 | 500ns | our $VERSION = '1.18'; | ||
9 | |||||
10 | # Verify that we're called correctly so that warnings will work. | ||||
11 | # see also strict.pm. | ||||
12 | 1 | 24µs | 2 | 14µs | unless ( __FILE__ =~ /(^|[\/\\])\Q${\__PACKAGE__}\E\.pmc?$/ ) { # spent 12µs making 1 call to warnings::CORE:regcomp
# spent 3µs making 1 call to warnings::CORE:match |
13 | my (undef, $f, $l) = caller; | ||||
14 | die("Incorrect use of pragma '${\__PACKAGE__}' at $f line $l.\n"); | ||||
15 | } | ||||
16 | |||||
17 | =head1 NAME | ||||
18 | |||||
19 | warnings - Perl pragma to control optional warnings | ||||
20 | |||||
21 | =head1 SYNOPSIS | ||||
22 | |||||
23 | use warnings; | ||||
24 | no warnings; | ||||
25 | |||||
26 | use warnings "all"; | ||||
27 | no warnings "all"; | ||||
28 | |||||
29 | use warnings::register; | ||||
30 | if (warnings::enabled()) { | ||||
31 | warnings::warn("some warning"); | ||||
32 | } | ||||
33 | |||||
34 | if (warnings::enabled("void")) { | ||||
35 | warnings::warn("void", "some warning"); | ||||
36 | } | ||||
37 | |||||
38 | if (warnings::enabled($object)) { | ||||
39 | warnings::warn($object, "some warning"); | ||||
40 | } | ||||
41 | |||||
42 | warnings::warnif("some warning"); | ||||
43 | warnings::warnif("void", "some warning"); | ||||
44 | warnings::warnif($object, "some warning"); | ||||
45 | |||||
46 | =head1 DESCRIPTION | ||||
47 | |||||
48 | The C<warnings> pragma is a replacement for the command line flag C<-w>, | ||||
49 | but the pragma is limited to the enclosing block, while the flag is global. | ||||
50 | See L<perllexwarn> for more information and the list of built-in warning | ||||
51 | categories. | ||||
52 | |||||
53 | If no import list is supplied, all possible warnings are either enabled | ||||
54 | or disabled. | ||||
55 | |||||
56 | A number of functions are provided to assist module authors. | ||||
57 | |||||
58 | =over 4 | ||||
59 | |||||
60 | =item use warnings::register | ||||
61 | |||||
62 | Creates a new warnings category with the same name as the package where | ||||
63 | the call to the pragma is used. | ||||
64 | |||||
65 | =item warnings::enabled() | ||||
66 | |||||
67 | Use the warnings category with the same name as the current package. | ||||
68 | |||||
69 | Return TRUE if that warnings category is enabled in the calling module. | ||||
70 | Otherwise returns FALSE. | ||||
71 | |||||
72 | =item warnings::enabled($category) | ||||
73 | |||||
74 | Return TRUE if the warnings category, C<$category>, is enabled in the | ||||
75 | calling module. | ||||
76 | Otherwise returns FALSE. | ||||
77 | |||||
78 | =item warnings::enabled($object) | ||||
79 | |||||
80 | Use the name of the class for the object reference, C<$object>, as the | ||||
81 | warnings category. | ||||
82 | |||||
83 | Return TRUE if that warnings category is enabled in the first scope | ||||
84 | where the object is used. | ||||
85 | Otherwise returns FALSE. | ||||
86 | |||||
87 | =item warnings::fatal_enabled() | ||||
88 | |||||
89 | Return TRUE if the warnings category with the same name as the current | ||||
90 | package has been set to FATAL in the calling module. | ||||
91 | Otherwise returns FALSE. | ||||
92 | |||||
93 | =item warnings::fatal_enabled($category) | ||||
94 | |||||
95 | Return TRUE if the warnings category C<$category> has been set to FATAL in | ||||
96 | the calling module. | ||||
97 | Otherwise returns FALSE. | ||||
98 | |||||
99 | =item warnings::fatal_enabled($object) | ||||
100 | |||||
101 | Use the name of the class for the object reference, C<$object>, as the | ||||
102 | warnings category. | ||||
103 | |||||
104 | Return TRUE if that warnings category has been set to FATAL in the first | ||||
105 | scope where the object is used. | ||||
106 | Otherwise returns FALSE. | ||||
107 | |||||
108 | =item warnings::warn($message) | ||||
109 | |||||
110 | Print C<$message> to STDERR. | ||||
111 | |||||
112 | Use the warnings category with the same name as the current package. | ||||
113 | |||||
114 | If that warnings category has been set to "FATAL" in the calling module | ||||
115 | then die. Otherwise return. | ||||
116 | |||||
117 | =item warnings::warn($category, $message) | ||||
118 | |||||
119 | Print C<$message> to STDERR. | ||||
120 | |||||
121 | If the warnings category, C<$category>, has been set to "FATAL" in the | ||||
122 | calling module then die. Otherwise return. | ||||
123 | |||||
124 | =item warnings::warn($object, $message) | ||||
125 | |||||
126 | Print C<$message> to STDERR. | ||||
127 | |||||
128 | Use the name of the class for the object reference, C<$object>, as the | ||||
129 | warnings category. | ||||
130 | |||||
131 | If that warnings category has been set to "FATAL" in the scope where C<$object> | ||||
132 | is first used then die. Otherwise return. | ||||
133 | |||||
134 | |||||
135 | =item warnings::warnif($message) | ||||
136 | |||||
137 | Equivalent to: | ||||
138 | |||||
139 | if (warnings::enabled()) | ||||
140 | { warnings::warn($message) } | ||||
141 | |||||
142 | =item warnings::warnif($category, $message) | ||||
143 | |||||
144 | Equivalent to: | ||||
145 | |||||
146 | if (warnings::enabled($category)) | ||||
147 | { warnings::warn($category, $message) } | ||||
148 | |||||
149 | =item warnings::warnif($object, $message) | ||||
150 | |||||
151 | Equivalent to: | ||||
152 | |||||
153 | if (warnings::enabled($object)) | ||||
154 | { warnings::warn($object, $message) } | ||||
155 | |||||
156 | =item warnings::register_categories(@names) | ||||
157 | |||||
158 | This registers warning categories for the given names and is primarily for | ||||
159 | use by the warnings::register pragma, for which see L<perllexwarn>. | ||||
160 | |||||
161 | =back | ||||
162 | |||||
163 | See L<perlmodlib/Pragmatic Modules> and L<perllexwarn>. | ||||
164 | |||||
165 | =cut | ||||
166 | |||||
167 | 1 | 16µs | our %Offsets = ( | ||
168 | |||||
169 | # Warnings Categories added in Perl 5.008 | ||||
170 | |||||
171 | 'all' => 0, | ||||
172 | 'closure' => 2, | ||||
173 | 'deprecated' => 4, | ||||
174 | 'exiting' => 6, | ||||
175 | 'glob' => 8, | ||||
176 | 'io' => 10, | ||||
177 | 'closed' => 12, | ||||
178 | 'exec' => 14, | ||||
179 | 'layer' => 16, | ||||
180 | 'newline' => 18, | ||||
181 | 'pipe' => 20, | ||||
182 | 'unopened' => 22, | ||||
183 | 'misc' => 24, | ||||
184 | 'numeric' => 26, | ||||
185 | 'once' => 28, | ||||
186 | 'overflow' => 30, | ||||
187 | 'pack' => 32, | ||||
188 | 'portable' => 34, | ||||
189 | 'recursion' => 36, | ||||
190 | 'redefine' => 38, | ||||
191 | 'regexp' => 40, | ||||
192 | 'severe' => 42, | ||||
193 | 'debugging' => 44, | ||||
194 | 'inplace' => 46, | ||||
195 | 'internal' => 48, | ||||
196 | 'malloc' => 50, | ||||
197 | 'signal' => 52, | ||||
198 | 'substr' => 54, | ||||
199 | 'syntax' => 56, | ||||
200 | 'ambiguous' => 58, | ||||
201 | 'bareword' => 60, | ||||
202 | 'digit' => 62, | ||||
203 | 'parenthesis' => 64, | ||||
204 | 'precedence' => 66, | ||||
205 | 'printf' => 68, | ||||
206 | 'prototype' => 70, | ||||
207 | 'qw' => 72, | ||||
208 | 'reserved' => 74, | ||||
209 | 'semicolon' => 76, | ||||
210 | 'taint' => 78, | ||||
211 | 'threads' => 80, | ||||
212 | 'uninitialized' => 82, | ||||
213 | 'unpack' => 84, | ||||
214 | 'untie' => 86, | ||||
215 | 'utf8' => 88, | ||||
216 | 'void' => 90, | ||||
217 | |||||
218 | # Warnings Categories added in Perl 5.011 | ||||
219 | |||||
220 | 'imprecision' => 92, | ||||
221 | 'illegalproto' => 94, | ||||
222 | |||||
223 | # Warnings Categories added in Perl 5.013 | ||||
224 | |||||
225 | 'non_unicode' => 96, | ||||
226 | 'nonchar' => 98, | ||||
227 | 'surrogate' => 100, | ||||
228 | |||||
229 | # Warnings Categories added in Perl 5.017 | ||||
230 | |||||
231 | 'experimental' => 102, | ||||
232 | 'experimental::lexical_subs'=> 104, | ||||
233 | 'experimental::lexical_topic'=> 106, | ||||
234 | 'experimental::regex_sets'=> 108, | ||||
235 | 'experimental::smartmatch'=> 110, | ||||
236 | ); | ||||
237 | |||||
238 | 1 | 14µs | our %Bits = ( | ||
239 | 'all' => "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55", # [0..55] | ||||
240 | 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00", # [29] | ||||
241 | 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00", # [30] | ||||
242 | 'closed' => "\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6] | ||||
243 | 'closure' => "\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1] | ||||
244 | 'debugging' => "\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00", # [22] | ||||
245 | 'deprecated' => "\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [2] | ||||
246 | 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00", # [31] | ||||
247 | 'exec' => "\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] | ||||
248 | 'exiting' => "\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] | ||||
249 | 'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x55", # [51..55] | ||||
250 | 'experimental::lexical_subs'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", # [52] | ||||
251 | 'experimental::lexical_topic'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04", # [53] | ||||
252 | 'experimental::regex_sets'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", # [54] | ||||
253 | 'experimental::smartmatch'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40", # [55] | ||||
254 | 'glob' => "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4] | ||||
255 | 'illegalproto' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00", # [47] | ||||
256 | 'imprecision' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00", # [46] | ||||
257 | 'inplace' => "\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00", # [23] | ||||
258 | 'internal' => "\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00", # [24] | ||||
259 | 'io' => "\x00\x54\x55\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [5..11] | ||||
260 | 'layer' => "\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8] | ||||
261 | 'malloc' => "\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00", # [25] | ||||
262 | 'misc' => "\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [12] | ||||
263 | 'newline' => "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9] | ||||
264 | 'non_unicode' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00", # [48] | ||||
265 | 'nonchar' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00", # [49] | ||||
266 | 'numeric' => "\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [13] | ||||
267 | 'once' => "\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [14] | ||||
268 | 'overflow' => "\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [15] | ||||
269 | 'pack' => "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [16] | ||||
270 | 'parenthesis' => "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00", # [32] | ||||
271 | 'pipe' => "\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [10] | ||||
272 | 'portable' => "\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [17] | ||||
273 | 'precedence' => "\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00", # [33] | ||||
274 | 'printf' => "\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00", # [34] | ||||
275 | 'prototype' => "\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00", # [35] | ||||
276 | 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00", # [36] | ||||
277 | 'recursion' => "\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [18] | ||||
278 | 'redefine' => "\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [19] | ||||
279 | 'regexp' => "\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00", # [20] | ||||
280 | 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00", # [37] | ||||
281 | 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00", # [38] | ||||
282 | 'severe' => "\x00\x00\x00\x00\x00\x54\x05\x00\x00\x00\x00\x00\x00\x00", # [21..25] | ||||
283 | 'signal' => "\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00", # [26] | ||||
284 | 'substr' => "\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00", # [27] | ||||
285 | 'surrogate' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00", # [50] | ||||
286 | 'syntax' => "\x00\x00\x00\x00\x00\x00\x00\x55\x55\x15\x00\x40\x00\x00", # [28..38,47] | ||||
287 | 'taint' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00", # [39] | ||||
288 | 'threads' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00", # [40] | ||||
289 | 'uninitialized' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00", # [41] | ||||
290 | 'unopened' => "\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [11] | ||||
291 | 'unpack' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00", # [42] | ||||
292 | 'untie' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00", # [43] | ||||
293 | 'utf8' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x15\x00", # [44,48..50] | ||||
294 | 'void' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00", # [45] | ||||
295 | ); | ||||
296 | |||||
297 | 1 | 15µs | our %DeadBits = ( | ||
298 | 'all' => "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", # [0..55] | ||||
299 | 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00", # [29] | ||||
300 | 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00", # [30] | ||||
301 | 'closed' => "\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6] | ||||
302 | 'closure' => "\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1] | ||||
303 | 'debugging' => "\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00", # [22] | ||||
304 | 'deprecated' => "\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [2] | ||||
305 | 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00", # [31] | ||||
306 | 'exec' => "\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] | ||||
307 | 'exiting' => "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] | ||||
308 | 'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xaa", # [51..55] | ||||
309 | 'experimental::lexical_subs'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02", # [52] | ||||
310 | 'experimental::lexical_topic'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08", # [53] | ||||
311 | 'experimental::regex_sets'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", # [54] | ||||
312 | 'experimental::smartmatch'=> "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80", # [55] | ||||
313 | 'glob' => "\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4] | ||||
314 | 'illegalproto' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00", # [47] | ||||
315 | 'imprecision' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00", # [46] | ||||
316 | 'inplace' => "\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00", # [23] | ||||
317 | 'internal' => "\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00", # [24] | ||||
318 | 'io' => "\x00\xa8\xaa\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [5..11] | ||||
319 | 'layer' => "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8] | ||||
320 | 'malloc' => "\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00", # [25] | ||||
321 | 'misc' => "\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [12] | ||||
322 | 'newline' => "\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9] | ||||
323 | 'non_unicode' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00", # [48] | ||||
324 | 'nonchar' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00", # [49] | ||||
325 | 'numeric' => "\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [13] | ||||
326 | 'once' => "\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [14] | ||||
327 | 'overflow' => "\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [15] | ||||
328 | 'pack' => "\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [16] | ||||
329 | 'parenthesis' => "\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00", # [32] | ||||
330 | 'pipe' => "\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [10] | ||||
331 | 'portable' => "\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [17] | ||||
332 | 'precedence' => "\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00", # [33] | ||||
333 | 'printf' => "\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00", # [34] | ||||
334 | 'prototype' => "\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00", # [35] | ||||
335 | 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00", # [36] | ||||
336 | 'recursion' => "\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [18] | ||||
337 | 'redefine' => "\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [19] | ||||
338 | 'regexp' => "\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00", # [20] | ||||
339 | 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00", # [37] | ||||
340 | 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00", # [38] | ||||
341 | 'severe' => "\x00\x00\x00\x00\x00\xa8\x0a\x00\x00\x00\x00\x00\x00\x00", # [21..25] | ||||
342 | 'signal' => "\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00", # [26] | ||||
343 | 'substr' => "\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00", # [27] | ||||
344 | 'surrogate' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00", # [50] | ||||
345 | 'syntax' => "\x00\x00\x00\x00\x00\x00\x00\xaa\xaa\x2a\x00\x80\x00\x00", # [28..38,47] | ||||
346 | 'taint' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00", # [39] | ||||
347 | 'threads' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00", # [40] | ||||
348 | 'uninitialized' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00", # [41] | ||||
349 | 'unopened' => "\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [11] | ||||
350 | 'unpack' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00", # [42] | ||||
351 | 'untie' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00", # [43] | ||||
352 | 'utf8' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x2a\x00", # [44,48..50] | ||||
353 | 'void' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00", # [45] | ||||
354 | ); | ||||
355 | |||||
356 | 1 | 200ns | $NONE = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; | ||
357 | 1 | 400ns | $DEFAULT = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x00\x55", # [2,52..55,4,22,23,25] | ||
358 | $LAST_BIT = 112 ; | ||||
359 | 1 | 0s | $BYTES = 14 ; | ||
360 | |||||
361 | 2 | 7µs | $All = "" ; vec($All, $Offsets{'all'}, 2) = 3 ; | ||
362 | |||||
363 | sub Croaker | ||||
364 | { | ||||
365 | require Carp; # this initializes %CarpInternal | ||||
366 | local $Carp::CarpInternal{'warnings'}; | ||||
367 | delete $Carp::CarpInternal{'warnings'}; | ||||
368 | Carp::croak(@_); | ||||
369 | } | ||||
370 | |||||
371 | sub _bits { | ||||
372 | my $mask = shift ; | ||||
373 | my $catmask ; | ||||
374 | my $fatal = 0 ; | ||||
375 | my $no_fatal = 0 ; | ||||
376 | |||||
377 | foreach my $word ( @_ ) { | ||||
378 | if ($word eq 'FATAL') { | ||||
379 | $fatal = 1; | ||||
380 | $no_fatal = 0; | ||||
381 | } | ||||
382 | elsif ($word eq 'NONFATAL') { | ||||
383 | $fatal = 0; | ||||
384 | $no_fatal = 1; | ||||
385 | } | ||||
386 | elsif ($catmask = $Bits{$word}) { | ||||
387 | $mask |= $catmask ; | ||||
388 | $mask |= $DeadBits{$word} if $fatal ; | ||||
389 | $mask &= ~($DeadBits{$word}|$All) if $no_fatal ; | ||||
390 | } | ||||
391 | else | ||||
392 | { Croaker("Unknown warnings category '$word'")} | ||||
393 | } | ||||
394 | |||||
395 | return $mask ; | ||||
396 | } | ||||
397 | |||||
398 | sub bits | ||||
399 | { | ||||
400 | # called from B::Deparse.pm | ||||
401 | push @_, 'all' unless @_ ; | ||||
402 | return _bits(undef, @_) ; | ||||
403 | } | ||||
404 | |||||
405 | sub import | ||||
406 | # spent 479µs within warnings::import which was called 139 times, avg 3µs/call:
# 26 times (100µs+0s) by Moose::Exporter::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Exporter.pm:519] at line 465 of Moose/Exporter.pm, avg 4µs/call
# 3 times (13µs+0s) by Moose::Exporter::import at line 783 of Moose/Exporter.pm, avg 4µs/call
# once (10µs+0s) by Modern::Perl::BEGIN@10 at line 10 of Modern/Perl.pm
# once (8µs+0s) by Class::MOP::Deprecated::BEGIN@10 at line 10 of Class/MOP/Deprecated.pm
# once (6µs+0s) by Moose::Meta::Method::Accessor::Native::Array::clear::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/clear.pm
# once (6µs+0s) by Moose::Meta::Method::Accessor::Native::Array::delete::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/delete.pm
# once (4µs+0s) by Moose::Util::MetaRole::BEGIN@10 at line 10 of Moose/Util/MetaRole.pm
# once (4µs+0s) by Class::MOP::Attribute::BEGIN@11 at line 11 of Class/MOP/Attribute.pm
# once (4µs+0s) by Moose::Meta::Method::Accessor::Native::Array::count::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/count.pm
# once (4µs+0s) by Class::MOP::Class::Immutable::Trait::BEGIN@10 at line 10 of Class/MOP/Class/Immutable/Trait.pm
# once (4µs+0s) by overloading::BEGIN@2 at line 2 of overloading.pm
# once (4µs+0s) by Moose::Util::TypeConstraints::Builtins::BEGIN@10 at line 10 of Moose/Util/TypeConstraints/Builtins.pm
# once (4µs+0s) by Moose::Meta::Instance::BEGIN@11 at line 11 of Moose/Meta/Instance.pm
# once (4µs+0s) by Sub::Install::BEGIN@3 at line 3 of Sub/Install.pm
# once (4µs+0s) by Moose::Meta::Method::Accessor::Native::Array::set::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/set.pm
# once (4µs+0s) by Modern::Perl::import at line 41 of Modern/Perl.pm
# once (4µs+0s) by namespace::clean::BEGIN@3 at line 3 of namespace/clean.pm
# once (3µs+0s) by Moose::Meta::Method::Accessor::Native::Array::Writer::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/Writer.pm
# once (3µs+0s) by Class::MOP::Method::Constructor::BEGIN@11 at line 11 of Class/MOP/Method/Constructor.pm
# once (3µs+0s) by Moose::Meta::Method::Accessor::Native::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native.pm
# once (3µs+0s) by Moose::Error::Util::BEGIN@5 at line 5 of Moose/Error/Util.pm
# once (3µs+0s) by Moose::Meta::Mixin::AttributeCore::BEGIN@10 at line 10 of Moose/Meta/Mixin/AttributeCore.pm
# once (3µs+0s) by Class::MOP::Method::Accessor::BEGIN@11 at line 11 of Class/MOP/Method/Accessor.pm
# once (3µs+0s) by Config::BEGIN@10 at line 10 of Config.pm
# once (3µs+0s) by Class::MOP::MiniTrait::BEGIN@10 at line 10 of Class/MOP/MiniTrait.pm
# once (3µs+0s) by Moose::Meta::Method::Augmented::BEGIN@10 at line 10 of Moose/Meta/Method/Augmented.pm
# once (3µs+0s) by Atom::BEGIN@2.2 at line 2 of namespace/autoclean.pm
# once (3µs+0s) by Moose::Meta::Method::Accessor::Native::Array::elements::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/elements.pm
# once (3µs+0s) by MooseX::Storage::BEGIN@2 at line 2 of String/RewritePrefix.pm
# once (3µs+0s) by Class::MOP::Method::Inlined::BEGIN@10 at line 10 of Class/MOP/Method/Inlined.pm
# once (3µs+0s) by Moose::Meta::Method::Accessor::Native::Writer::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Writer.pm
# once (3µs+0s) by Moose::Meta::Class::Immutable::Trait::BEGIN@10 at line 10 of Moose/Meta/Class/Immutable/Trait.pm
# once (3µs+0s) by Class::MOP::Mixin::HasMethods::BEGIN@10 at line 10 of Class/MOP/Mixin/HasMethods.pm
# once (3µs+0s) by Moose::Meta::Method::BEGIN@10 at line 10 of Moose/Meta/Method.pm
# once (3µs+0s) by Moose::Error::Default::BEGIN@10 at line 10 of Moose/Error/Default.pm
# once (3µs+0s) by Moose::Meta::Role::Composite::BEGIN@10 at line 10 of Moose/Meta/Role/Composite.pm
# once (3µs+0s) by Eval::Closure::BEGIN@9 at line 9 of Eval/Closure.pm
# once (3µs+0s) by Moose::BEGIN@9 at line 9 of Moose.pm
# once (3µs+0s) by Class::Load::XS::BEGIN@7 at line 7 of Class/Load/XS.pm
# once (3µs+0s) by Class::MOP::Class::BEGIN@11 at line 11 of Class/MOP/Class.pm
# once (3µs+0s) by Moose::Meta::Method::Overridden::BEGIN@10 at line 10 of Moose/Meta/Method/Overridden.pm
# once (3µs+0s) by Moose::Exporter::BEGIN@3 at line 3 of Sub/Exporter.pm
# once (3µs+0s) by Moose::Meta::Method::Accessor::Native::Array::get::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/get.pm
# once (3µs+0s) by Moose::Meta::TypeConstraint::BEGIN@11 at line 11 of Moose/Meta/TypeConstraint.pm
# once (3µs+0s) by Moose::Exporter::BEGIN@10 at line 10 of Moose/Exporter.pm
# once (3µs+0s) by Class::MOP::Object::BEGIN@11 at line 11 of Class/MOP/Object.pm
# once (3µs+0s) by Devel::GlobalDestruction::BEGIN@4 at line 4 of Devel/GlobalDestruction.pm
# once (3µs+0s) by Class::Load::BEGIN@2 at line 2 of Data/OptList.pm
# once (3µs+0s) by Carp::BEGIN@5 at line 5 of Carp.pm
# once (3µs+0s) by Class::MOP::Instance::BEGIN@11 at line 11 of Class/MOP/Instance.pm
# once (3µs+0s) by Moose::Meta::Method::Constructor::BEGIN@11 at line 11 of Moose/Meta/Method/Constructor.pm
# once (3µs+0s) by IO::BEGIN@8 at line 8 of IO.pm
# once (3µs+0s) by Moose::Meta::TypeCoercion::BEGIN@11 at line 11 of Moose/Meta/TypeCoercion.pm
# once (3µs+0s) by Class::MOP::Mixin::HasAttributes::BEGIN@10 at line 10 of Class/MOP/Mixin/HasAttributes.pm
# once (3µs+0s) by Moose::Role::BEGIN@9 at line 9 of Moose/Role.pm
# once (3µs+0s) by re::BEGIN@5 at line 5 of re.pm
# once (3µs+0s) by Class::MOP::BEGIN@11 at line 11 of Class/MOP.pm
# once (3µs+0s) by Package::Stash::BEGIN@9 at line 9 of Package/Stash.pm
# once (3µs+0s) by Class::MOP::Method::BEGIN@11 at line 11 of Class/MOP/Method.pm
# once (3µs+0s) by MRO::Compat::BEGIN@3 at line 3 of MRO/Compat.pm
# once (3µs+0s) by Package::Stash::XS::BEGIN@9 at line 9 of Package/Stash/XS.pm
# once (3µs+0s) by Module::Implementation::BEGIN@10 at line 10 of Module/Implementation.pm
# once (3µs+0s) by Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 at line 10 of Moose/Meta/TypeConstraint/Parameterizable.pm
# once (3µs+0s) by Try::Tiny::BEGIN@12 at line 12 of Try/Tiny.pm
# once (3µs+0s) by Class::MOP::Method::Generated::BEGIN@11 at line 11 of Class/MOP/Method/Generated.pm
# once (3µs+0s) by Moose::Meta::Method::Destructor::BEGIN@11 at line 11 of Moose/Meta/Method/Destructor.pm
# once (3µs+0s) by Moose::Meta::Role::BEGIN@10 at line 10 of Moose/Meta/Role.pm
# once (3µs+0s) by Moose::Meta::Role::Method::Conflicting::BEGIN@11 at line 11 of Moose/Meta/Role/Method/Conflicting.pm
# once (3µs+0s) by Moose::Meta::Method::Delegation::BEGIN@11 at line 11 of Moose/Meta/Method/Delegation.pm
# once (3µs+0s) by Moose::Meta::Method::Accessor::Native::Reader::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Reader.pm
# once (3µs+0s) by Moose::Meta::Method::Meta::BEGIN@11 at line 11 of Moose/Meta/Method/Meta.pm
# once (3µs+0s) by Sub::Name::BEGIN@45 at line 45 of Sub/Name.pm
# once (3µs+0s) by Sub::Exporter::Progressive::BEGIN@4 at line 4 of Sub/Exporter/Progressive.pm
# once (3µs+0s) by Moose::Meta::TypeConstraint::Role::BEGIN@10 at line 10 of Moose/Meta/TypeConstraint/Role.pm
# once (3µs+0s) by Moose::Meta::TypeConstraint::DuckType::BEGIN@10 at line 10 of Moose/Meta/TypeConstraint/DuckType.pm
# once (3µs+0s) by Moose::Meta::TypeConstraint::Registry::BEGIN@11 at line 11 of Moose/Meta/TypeConstraint/Registry.pm
# once (3µs+0s) by Moose::Meta::Role::Application::ToInstance::BEGIN@10 at line 10 of Moose/Meta/Role/Application/ToInstance.pm
# once (3µs+0s) by Moose::Meta::Attribute::BEGIN@11 at line 11 of Moose/Meta/Attribute.pm
# once (3µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 10 of Moose/Meta/TypeConstraint/Parameterized.pm
# once (3µs+0s) by Moose::Meta::TypeConstraint::Union::BEGIN@11 at line 11 of Moose/Meta/TypeConstraint/Union.pm
# once (3µs+0s) by Moose::Meta::Role::Attribute::BEGIN@10 at line 10 of Moose/Meta/Role/Attribute.pm
# once (3µs+0s) by Moose::Meta::Role::Application::ToClass::BEGIN@10 at line 10 of Moose/Meta/Role/Application/ToClass.pm
# once (3µs+0s) by Moose::Deprecated::BEGIN@10 at line 10 of Moose/Deprecated.pm
# once (3µs+0s) by Moose::Meta::Method::Accessor::Native::Array::push::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array/push.pm
# once (3µs+0s) by Class::MOP::Mixin::AttributeCore::BEGIN@10 at line 10 of Class/MOP/Mixin/AttributeCore.pm
# once (3µs+0s) by Class::MOP::Module::BEGIN@11 at line 11 of Class/MOP/Module.pm
# once (3µs+0s) by Package::DeprecationManager::BEGIN@7 at line 7 of Package/DeprecationManager.pm
# once (3µs+0s) by Moose::Meta::Method::Accessor::Native::Collection::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Collection.pm
# once (3µs+0s) by Moose::Meta::Method::Accessor::Native::Array::BEGIN@10 at line 10 of Moose/Meta/Method/Accessor/Native/Array.pm
# once (3µs+0s) by Variable::Magic::BEGIN@6 at line 6 of Variable/Magic.pm
# once (3µs+0s) by Class::MOP::Method::Wrapped::BEGIN@11 at line 11 of Class/MOP/Method/Wrapped.pm
# once (3µs+0s) by Moose::Meta::Role::Method::Required::BEGIN@11 at line 11 of Moose/Meta/Role/Method/Required.pm
# once (3µs+0s) by Moose::Meta::Method::Accessor::BEGIN@11 at line 11 of Moose/Meta/Method/Accessor.pm
# once (3µs+0s) by Class::MOP::Package::BEGIN@11 at line 11 of Class/MOP/Package.pm
# once (3µs+0s) by Moose::Meta::Role::Application::BEGIN@10 at line 10 of Moose/Meta/Role/Application.pm
# once (3µs+0s) by Moose::Meta::TypeConstraint::Enum::BEGIN@10 at line 10 of Moose/Meta/TypeConstraint/Enum.pm
# once (3µs+0s) by Class::Load::BEGIN@6 at line 6 of Class/Load.pm
# once (3µs+0s) by Moose::Meta::Role::Application::ToRole::BEGIN@10 at line 10 of Moose/Meta/Role/Application/ToRole.pm
# once (3µs+0s) by B::Hooks::EndOfScope::XS::BEGIN@11 at line 11 of B/Hooks/EndOfScope/XS.pm
# once (3µs+0s) by Moose::Meta::Role::Method::BEGIN@11 at line 11 of Moose/Meta/Role/Method.pm
# once (3µs+0s) by Moose::Object::BEGIN@11 at line 11 of Moose/Object.pm
# once (3µs+0s) by Moose::Util::BEGIN@10 at line 10 of Moose/Util.pm
# once (3µs+0s) by B::Hooks::EndOfScope::BEGIN@11 at line 11 of B/Hooks/EndOfScope.pm
# once (3µs+0s) by Moose::Meta::Role::Application::RoleSummation::BEGIN@10 at line 10 of Moose/Meta/Role/Application/RoleSummation.pm
# once (3µs+0s) by mro::BEGIN@11 at line 11 of mro.pm
# once (3µs+0s) by Moose::Meta::Class::BEGIN@11 at line 11 of Moose/Meta/Class.pm
# once (3µs+0s) by Class::MOP::Method::Overload::BEGIN@11 at line 11 of Class/MOP/Method/Overload.pm
# once (3µs+0s) by metaclass::BEGIN@11 at line 11 of metaclass.pm
# once (3µs+0s) by Moose::Meta::TypeCoercion::Union::BEGIN@11 at line 11 of Moose/Meta/TypeCoercion/Union.pm
# once (3µs+0s) by Moose::Meta::TypeConstraint::Class::BEGIN@10 at line 10 of Moose/Meta/TypeConstraint/Class.pm
# once (3µs+0s) by Class::MOP::Method::Meta::BEGIN@11 at line 11 of Class/MOP/Method/Meta.pm
# once (3µs+0s) by Class::MOP::Mixin::BEGIN@10 at line 10 of Class/MOP/Mixin.pm | ||||
407 | 139 | 11µs | shift; | ||
408 | |||||
409 | 139 | 113µs | my $mask = ${^WARNING_BITS} // ($^W ? $Bits{all} : $DEFAULT) ; | ||
410 | |||||
411 | 139 | 75µs | if (vec($mask, $Offsets{'all'}, 1)) { | ||
412 | 18 | 6µs | $mask |= $Bits{'all'} ; | ||
413 | 18 | 9µs | $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); | ||
414 | } | ||||
415 | |||||
416 | # Empty @_ is equivalent to @_ = 'all' ; | ||||
417 | 139 | 526µs | ${^WARNING_BITS} = @_ ? _bits($mask, @_) : $mask | $Bits{all} ; | ||
418 | } | ||||
419 | |||||
420 | sub unimport | ||||
421 | # spent 134µs within warnings::unimport which was called 14 times, avg 10µs/call:
# once (16µs+0s) by Carp::BEGIN@441 at line 441 of Carp.pm
# once (13µs+0s) by Moose::Util::TypeConstraints::BEGIN@667 at line 667 of Moose/Util/TypeConstraints.pm
# once (12µs+0s) by namespace::clean::BEGIN@445 at line 445 of namespace/clean.pm
# once (12µs+0s) by Moose::Exporter::BEGIN@133 at line 133 of Moose/Exporter.pm
# once (11µs+0s) by Devel::GlobalDestruction::BEGIN@23 at line 23 of Devel/GlobalDestruction.pm
# once (9µs+0s) by Carp::BEGIN@434 at line 434 of Carp.pm
# once (9µs+0s) by Class::MOP::Package::BEGIN@95 at line 95 of Class/MOP/Package.pm
# once (9µs+0s) by Module::Implementation::BEGIN@124 at line 124 of Module/Implementation.pm
# once (8µs+0s) by MRO::Compat::BEGIN@39 at line 39 of MRO/Compat.pm
# once (7µs+0s) by Moose::Util::TypeConstraints::BEGIN@673 at line 673 of Moose/Util/TypeConstraints.pm
# once (7µs+0s) by MRO::Compat::BEGIN@228 at line 228 of MRO/Compat.pm
# once (7µs+0s) by Exporter::Heavy::BEGIN@197 at line 197 of Exporter/Heavy.pm
# once (7µs+0s) by Moose::Util::TypeConstraints::BEGIN@694 at line 694 of Moose/Util/TypeConstraints.pm
# once (7µs+0s) by Moose::Util::TypeConstraints::BEGIN@678 at line 678 of Moose/Util/TypeConstraints.pm | ||||
422 | 14 | 1µs | shift; | ||
423 | |||||
424 | 14 | 1µs | my $catmask ; | ||
425 | 14 | 19µs | my $mask = ${^WARNING_BITS} // ($^W ? $Bits{all} : $DEFAULT) ; | ||
426 | |||||
427 | 14 | 12µs | if (vec($mask, $Offsets{'all'}, 1)) { | ||
428 | 13 | 5µs | $mask |= $Bits{'all'} ; | ||
429 | 13 | 6µs | $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); | ||
430 | } | ||||
431 | |||||
432 | 14 | 3µs | push @_, 'all' unless @_; | ||
433 | |||||
434 | 14 | 9µs | foreach my $word ( @_ ) { | ||
435 | 14 | 40µs | if ($word eq 'FATAL') { | ||
436 | next; | ||||
437 | } | ||||
438 | elsif ($catmask = $Bits{$word}) { | ||||
439 | $mask &= ~($catmask | $DeadBits{$word} | $All); | ||||
440 | } | ||||
441 | else | ||||
442 | { Croaker("Unknown warnings category '$word'")} | ||||
443 | } | ||||
444 | |||||
445 | 14 | 56µs | ${^WARNING_BITS} = $mask ; | ||
446 | } | ||||
447 | |||||
448 | 2 | 2µs | my %builtin_type; @builtin_type{qw(SCALAR ARRAY HASH CODE REF GLOB LVALUE Regexp)} = (); | ||
449 | |||||
450 | sub MESSAGE () { 4 }; | ||||
451 | sub FATAL () { 2 }; | ||||
452 | sub NORMAL () { 1 }; | ||||
453 | |||||
454 | sub __chk | ||||
455 | { | ||||
456 | my $category ; | ||||
457 | my $offset ; | ||||
458 | my $isobj = 0 ; | ||||
459 | my $wanted = shift; | ||||
460 | my $has_message = $wanted & MESSAGE; | ||||
461 | |||||
462 | unless (@_ == 1 || @_ == ($has_message ? 2 : 0)) { | ||||
463 | my $sub = (caller 1)[3]; | ||||
464 | my $syntax = $has_message ? "[category,] 'message'" : '[category]'; | ||||
465 | Croaker("Usage: $sub($syntax)"); | ||||
466 | } | ||||
467 | |||||
468 | my $message = pop if $has_message; | ||||
469 | |||||
470 | if (@_) { | ||||
471 | # check the category supplied. | ||||
472 | $category = shift ; | ||||
473 | if (my $type = ref $category) { | ||||
474 | Croaker("not an object") | ||||
475 | if exists $builtin_type{$type}; | ||||
476 | $category = $type; | ||||
477 | $isobj = 1 ; | ||||
478 | } | ||||
479 | $offset = $Offsets{$category}; | ||||
480 | Croaker("Unknown warnings category '$category'") | ||||
481 | unless defined $offset; | ||||
482 | } | ||||
483 | else { | ||||
484 | $category = (caller(1))[0] ; | ||||
485 | $offset = $Offsets{$category}; | ||||
486 | Croaker("package '$category' not registered for warnings") | ||||
487 | unless defined $offset ; | ||||
488 | } | ||||
489 | |||||
490 | my $i; | ||||
491 | |||||
492 | if ($isobj) { | ||||
493 | my $pkg; | ||||
494 | $i = 2; | ||||
495 | while (do { { package DB; $pkg = (caller($i++))[0] } } ) { | ||||
496 | last unless @DB::args && $DB::args[0] =~ /^$category=/ ; | ||||
497 | } | ||||
498 | $i -= 2 ; | ||||
499 | } | ||||
500 | else { | ||||
501 | $i = _error_loc(); # see where Carp will allocate the error | ||||
502 | } | ||||
503 | |||||
504 | # Default to 0 if caller returns nothing. Default to $DEFAULT if it | ||||
505 | # explicitly returns undef. | ||||
506 | my(@callers_bitmask) = (caller($i))[9] ; | ||||
507 | my $callers_bitmask = | ||||
508 | @callers_bitmask ? $callers_bitmask[0] // $DEFAULT : 0 ; | ||||
509 | |||||
510 | my @results; | ||||
511 | foreach my $type (FATAL, NORMAL) { | ||||
512 | next unless $wanted & $type; | ||||
513 | |||||
514 | push @results, (vec($callers_bitmask, $offset + $type - 1, 1) || | ||||
515 | vec($callers_bitmask, $Offsets{'all'} + $type - 1, 1)); | ||||
516 | } | ||||
517 | |||||
518 | # &enabled and &fatal_enabled | ||||
519 | return $results[0] unless $has_message; | ||||
520 | |||||
521 | # &warnif, and the category is neither enabled as warning nor as fatal | ||||
522 | return if $wanted == (NORMAL | FATAL | MESSAGE) | ||||
523 | && !($results[0] || $results[1]); | ||||
524 | |||||
525 | require Carp; | ||||
526 | Carp::croak($message) if $results[0]; | ||||
527 | # will always get here for &warn. will only get here for &warnif if the | ||||
528 | # category is enabled | ||||
529 | Carp::carp($message); | ||||
530 | } | ||||
531 | |||||
532 | sub _mkMask | ||||
533 | { | ||||
534 | 6 | 1µs | my ($bit) = @_; | ||
535 | 6 | 900ns | my $mask = ""; | ||
536 | |||||
537 | 6 | 6µs | vec($mask, $bit, 1) = 1; | ||
538 | 6 | 15µs | return $mask; | ||
539 | } | ||||
540 | |||||
541 | sub register_categories | ||||
542 | # spent 169µs (153+17) within warnings::register_categories which was called 3 times, avg 56µs/call:
# 3 times (153µs+17µs) by warnings::register::import at line 43 of warnings/register.pm, avg 56µs/call | ||||
543 | 3 | 2µs | my @names = @_; | ||
544 | |||||
545 | 3 | 7µs | for my $name (@names) { | ||
546 | 3 | 4µs | if (! defined $Bits{$name}) { | ||
547 | 3 | 4µs | 3 | 10µs | $Bits{$name} = _mkMask($LAST_BIT); # spent 10µs making 3 calls to warnings::_mkMask, avg 3µs/call |
548 | 3 | 3µs | vec($Bits{'all'}, $LAST_BIT, 1) = 1; | ||
549 | 3 | 1µs | $Offsets{$name} = $LAST_BIT ++; | ||
550 | 3 | 17µs | foreach my $k (keys %Bits) { | ||
551 | 174 | 57µs | vec($Bits{$k}, $LAST_BIT, 1) = 0; | ||
552 | } | ||||
553 | 3 | 3µs | 3 | 6µs | $DeadBits{$name} = _mkMask($LAST_BIT); # spent 6µs making 3 calls to warnings::_mkMask, avg 2µs/call |
554 | 3 | 3µs | vec($DeadBits{'all'}, $LAST_BIT++, 1) = 1; | ||
555 | } | ||||
556 | } | ||||
557 | } | ||||
558 | |||||
559 | sub _error_loc { | ||||
560 | require Carp; | ||||
561 | goto &Carp::short_error_loc; # don't introduce another stack frame | ||||
562 | } | ||||
563 | |||||
564 | sub enabled | ||||
565 | { | ||||
566 | return __chk(NORMAL, @_); | ||||
567 | } | ||||
568 | |||||
569 | sub fatal_enabled | ||||
570 | { | ||||
571 | return __chk(FATAL, @_); | ||||
572 | } | ||||
573 | |||||
574 | sub warn | ||||
575 | { | ||||
576 | return __chk(FATAL | MESSAGE, @_); | ||||
577 | } | ||||
578 | |||||
579 | sub warnif | ||||
580 | { | ||||
581 | return __chk(NORMAL | FATAL | MESSAGE, @_); | ||||
582 | } | ||||
583 | |||||
584 | # These are not part of any public interface, so we can delete them to save | ||||
585 | # space. | ||||
586 | 1 | 6µs | delete @warnings::{qw(NORMAL FATAL MESSAGE)}; | ||
587 | |||||
588 | 1 | 40µs | 1; | ||
589 | |||||
590 | # ex: set ro: | ||||
# spent 3µs within warnings::CORE:match which was called:
# once (3µs+0s) by Modern::Perl::BEGIN@10 at line 12 | |||||
# spent 12µs within warnings::CORE:regcomp which was called:
# once (12µs+0s) by Modern::Perl::BEGIN@10 at line 12 |