line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
426
|
use 5.008003; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package JavaScript::Any::Context; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
63
|
use Role::Tiny; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
requires 'eval'; |
14
|
|
|
|
|
|
|
requires 'define'; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
162
|
use Ref::Util qw( is_plain_scalarref ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
326
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# convenience methods here |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub implementation { |
21
|
0
|
|
|
0
|
1
|
0
|
ref shift; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub is_true { |
25
|
1
|
|
|
1
|
0
|
2
|
shift; |
26
|
1
|
|
|
|
|
3
|
my ($value) = @_; |
27
|
1
|
50
|
33
|
|
|
4
|
return !!1 if is_plain_scalarref($value) && $$value == 1; |
28
|
1
|
|
|
|
|
663
|
require JSON::PP; |
29
|
1
|
50
|
33
|
|
|
10362
|
return !!1 if JSON::PP::is_bool($value) && $value == JSON::PP::true(); |
30
|
1
|
|
|
|
|
15
|
return !!0; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub is_false { |
34
|
1
|
|
|
1
|
0
|
4
|
shift; |
35
|
1
|
|
|
|
|
4
|
my ($value) = @_; |
36
|
1
|
50
|
33
|
|
|
8
|
return !!1 if is_plain_scalarref($value) && $$value == 0; |
37
|
1
|
|
|
|
|
7
|
require JSON::PP; |
38
|
1
|
50
|
33
|
|
|
3
|
return !!1 if JSON::PP::is_bool($value) && $value == JSON::PP::false(); |
39
|
1
|
|
|
|
|
9
|
return !!0; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub is_null { |
43
|
1
|
|
|
1
|
0
|
4
|
return !defined $_[1]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _throw_if_bad_name { |
47
|
2
|
50
|
|
2
|
|
12
|
return if $_[1] =~ /\A\w+\z/; |
48
|
0
|
|
|
|
|
|
require Carp; |
49
|
0
|
|
|
|
|
|
Carp::croak("Bad name: " . ref($_[1])); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _throw_because_bad_value { |
53
|
0
|
|
|
0
|
|
|
require Carp; |
54
|
0
|
|
|
|
|
|
Carp::croak("Cannot define values of type " . ref($_[1])); |
55
|
|
|
|
|
|
|
# ref should always be defined because non-ref scalars will be good values |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |