line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Phase; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
172562
|
use strict; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
44
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
36
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
26
|
use 5.14.0; # for ${^GLOBAL_PHASE} |
|
2
|
|
|
|
|
9
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub is_compile_time { |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# why not just `return !is_run_time();`? more explicit/accurate && save a `pp_entersub` op |
13
|
0
|
0
|
0
|
0
|
1
|
|
return ${^GLOBAL_PHASE} |
|
|
|
0
|
|
|
|
|
14
|
|
|
|
|
|
|
if ${^GLOBAL_PHASE} eq "CONSTRUCT" |
15
|
|
|
|
|
|
|
|| ${^GLOBAL_PHASE} eq "START" |
16
|
|
|
|
|
|
|
|| ${^GLOBAL_PHASE} eq "CHECK"; |
17
|
0
|
|
|
|
|
|
return; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub is_run_time { |
21
|
0
|
0
|
0
|
0
|
1
|
|
return ${^GLOBAL_PHASE} |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
22
|
|
|
|
|
|
|
if ${^GLOBAL_PHASE} eq "INIT" |
23
|
|
|
|
|
|
|
|| ${^GLOBAL_PHASE} eq "RUN" |
24
|
|
|
|
|
|
|
|| ${^GLOBAL_PHASE} eq "END" |
25
|
|
|
|
|
|
|
|| ${^GLOBAL_PHASE} eq "DESTRUCT"; |
26
|
0
|
|
|
|
|
|
return; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub assert_is_run_time { |
30
|
0
|
0
|
|
0
|
1
|
|
return ${^GLOBAL_PHASE} if is_run_time(); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my @caller = caller(1); |
33
|
0
|
0
|
|
|
|
|
if (@caller) { |
34
|
0
|
|
|
|
|
|
die "$caller[3]() called at compile time at $caller[1] line $caller[2]\n"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
0
|
|
|
|
|
|
die "This code should not be executed at compile time"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return ${^GLOBAL_PHASE}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub assert_is_compile_time { |
44
|
0
|
0
|
|
0
|
1
|
|
return ${^GLOBAL_PHASE} if is_compile_time(); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my @caller = caller(1); |
47
|
0
|
0
|
|
|
|
|
if (@caller) { |
48
|
0
|
|
|
|
|
|
die "$caller[3]() called at run time at $caller[1] line $caller[2]\n"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else { |
51
|
0
|
|
|
|
|
|
die "This code should not be executed at run time"; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |