line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TOML::Dumper::Context::Value; |
2
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
59
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
62
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
9
|
use Class::Accessor::Lite ro => [qw/name type atom/]; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
154
|
use B; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
102
|
|
8
|
2
|
|
|
2
|
|
1430
|
use overload (); |
|
2
|
|
|
|
|
2168
|
|
|
2
|
|
|
|
|
56
|
|
9
|
2
|
|
|
2
|
|
10
|
use Scalar::Util qw/blessed/; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
158
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
10
|
use TOML::Dumper::Name; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
37
|
|
12
|
2
|
|
|
2
|
|
7
|
use TOML::Dumper::String; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
865
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @BOOLEAN_CLASSES = qw/ |
15
|
|
|
|
|
|
|
JSON::PP::Boolean |
16
|
|
|
|
|
|
|
JSON::XS::Boolean |
17
|
|
|
|
|
|
|
/; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
30
|
|
|
30
|
0
|
33
|
my ($class, %args) = @_; |
21
|
30
|
|
|
|
|
27
|
my ($name, $atom) = @args{qw/name atom/}; |
22
|
30
|
|
|
|
|
42
|
my $self = bless { |
23
|
|
|
|
|
|
|
name => $name, |
24
|
|
|
|
|
|
|
type => undef, |
25
|
|
|
|
|
|
|
atom => undef, |
26
|
|
|
|
|
|
|
} => $class; |
27
|
30
|
|
|
|
|
33
|
$self->set($atom); |
28
|
30
|
|
|
|
|
43
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
47
|
|
|
47
|
0
|
26
|
sub depth { scalar @{ shift->{name} } } |
|
47
|
|
|
|
|
80
|
|
32
|
47
|
|
|
47
|
0
|
85
|
sub priority { 3 } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub set { |
35
|
30
|
|
|
30
|
0
|
21
|
my ($self, $atom) = @_; |
36
|
30
|
50
|
|
|
|
41
|
die 'Cannot set undef value' unless defined $atom; |
37
|
30
|
50
|
66
|
|
|
92
|
if (blessed $atom) { |
|
|
100
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
for my $class (@BOOLEAN_CLASSES) { |
39
|
0
|
0
|
|
|
|
0
|
next unless $atom->isa($class); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
$self->{type} = 'bool'; |
42
|
0
|
0
|
|
|
|
0
|
$self->{atom} = !!$atom ? 'true' : 'false'; |
43
|
0
|
|
|
|
|
0
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
0
|
0
|
|
|
|
0
|
if (overload::StrVal($atom)) { |
46
|
0
|
|
|
|
|
0
|
$self->{type} = 'string'; |
47
|
0
|
|
|
|
|
0
|
$self->{atom} = "$atom"; |
48
|
0
|
|
|
|
|
0
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif (ref $atom eq 'SCALAR' && !ref $$atom) { |
52
|
2
|
|
|
|
|
4
|
$self->{type} = 'bool'; |
53
|
2
|
100
|
|
|
|
34
|
$self->{atom} = !!$$atom ? 'true' : 'false'; |
54
|
2
|
|
|
|
|
6
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
28
|
50
|
|
|
|
32
|
die 'Cannot set reference value' if ref $atom; |
57
|
|
|
|
|
|
|
|
58
|
28
|
|
|
|
|
72
|
my $flags = B::svref_2object(\$atom)->FLAGS; |
59
|
28
|
100
|
|
|
|
34
|
if ($flags & (B::SVp_IOK | B::SVp_NOK) & ~B::SVp_POK) { |
60
|
23
|
|
|
|
|
18
|
$self->{type} = 'number'; |
61
|
23
|
|
|
|
|
17
|
$self->{atom} = $atom; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
else { |
64
|
5
|
|
|
|
|
6
|
$self->{type} = 'string'; |
65
|
5
|
|
|
|
|
4
|
$self->{atom} = $atom; |
66
|
|
|
|
|
|
|
} |
67
|
28
|
|
|
|
|
23
|
return $self; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub as_string { |
71
|
17
|
|
|
17
|
0
|
15
|
my $self = shift; |
72
|
17
|
|
|
|
|
25
|
my $name = TOML::Dumper::Name::format($self->{name}->[-1]); |
73
|
17
|
|
|
|
|
27
|
my $body = $self->TOML::Dumper::Context::Value::Inline::as_string(); |
74
|
17
|
|
|
|
|
36
|
return "$name = $body"; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |