line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
######################################################################## |
2
|
|
|
|
|
|
|
# housekeeping |
3
|
|
|
|
|
|
|
######################################################################## |
4
|
|
|
|
|
|
|
package Keyword::Value v0.1.2; |
5
|
10
|
|
|
10
|
|
643902
|
use v5.22; |
|
10
|
|
|
|
|
94
|
|
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
6832
|
use Keyword::Declare; |
|
10
|
|
|
|
|
912284
|
|
|
10
|
|
|
|
|
84
|
|
8
|
|
|
|
|
|
|
|
9
|
10
|
|
|
10
|
|
5683
|
use Data::Lock qw( dlock ); |
|
10
|
|
|
|
|
49133
|
|
|
10
|
|
|
|
|
494
|
|
10
|
10
|
|
|
10
|
|
62
|
use Carp qw( carp croak ); |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
1399
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
######################################################################## |
13
|
|
|
|
|
|
|
# package variables |
14
|
|
|
|
|
|
|
######################################################################## |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @CARP_NOT = ( __PACKAGE__ ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# variable avoids having to export the sub into every caller's space. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $const |
21
|
|
|
|
|
|
|
= sub : lvalue |
22
|
|
|
|
|
|
|
{ |
23
|
12
|
|
50
|
12
|
|
328
|
state $verbose = $ENV{ VERBOSE_KEYWORD_VALUE } // ''; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# lvalue delays dlock until after state sets its own magic flag. |
26
|
|
|
|
|
|
|
|
27
|
12
|
50
|
|
|
|
27
|
$_[0] = $_[1] if @_ > 1; |
28
|
|
|
|
|
|
|
|
29
|
12
|
50
|
0
|
|
|
26
|
$_[0] // carp "Fixing undefined value" |
30
|
|
|
|
|
|
|
if $verbose; |
31
|
|
|
|
|
|
|
|
32
|
12
|
|
|
|
|
49
|
dlock $_[0]; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# returns ref from stack to allow assignment via lvalue. |
35
|
|
|
|
|
|
|
|
36
|
12
|
|
|
|
|
163
|
$_[0] |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
######################################################################## |
40
|
|
|
|
|
|
|
# exported subs |
41
|
|
|
|
|
|
|
######################################################################## |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub import |
44
|
0
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
# defined inside of "import" this pushes the "value" keyword |
46
|
|
|
|
|
|
|
# into the caller's space. |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# lock a variable (i.e., with a sigil). |
49
|
|
|
|
|
|
|
# lacking a leading variable, constify the entire expression. |
50
|
10
|
|
|
10
|
|
105
|
|
51
|
10
|
50
|
50
|
|
|
153
|
keyword value( Var $var, Expr $expr ) |
52
|
10
|
|
|
|
|
41
|
{ |
53
|
|
|
|
|
|
|
( 0 > index "$var", '::' ) |
54
|
|
|
|
|
|
|
? "\$Keyword::Value::const->( my $var $expr )" |
55
|
|
|
|
|
|
|
: "\$Keyword::Value::const->( $var $expr )" |
56
|
0
|
|
|
0
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
57
|
0
|
0
|
|
|
|
0
|
|
|
10
|
|
|
|
|
286
|
|
58
|
10
|
50
|
50
|
|
|
97
|
keyword value ( Expr $expr ) |
59
|
10
|
|
|
|
|
43
|
{{{ |
60
|
10
|
|
|
|
|
56
|
$Keyword::Value::const->( <{$expr}> ) |
61
|
|
|
|
|
|
|
}}} |
62
|
10
|
|
|
10
|
|
308991
|
} |
63
|
6
|
|
|
6
|
|
558701
|
|
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
10
|
|
64
|
6
|
|
|
|
|
12
|
# keep require happy |
|
6
|
|
|
|
|
26
|
|
65
|
10
|
|
|
|
|
37
|
1 |
66
|
0
|
|
|
|
|
0
|
__END__ |