| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package JSON::TypeInference::Type::Maybe; |
|
2
|
4
|
|
|
4
|
|
1750
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
102
|
|
|
3
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
113
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
19
|
use List::Util qw(any); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
1332
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub looks_like_maybe { |
|
9
|
23
|
|
|
23
|
1
|
2125
|
my ($class, $candidate_types) = @_; |
|
10
|
23
|
|
100
|
8
|
|
166
|
return (scalar(@$candidate_types) == 2) && any { $_->isa('JSON::TypeInference::Type::Null') } @$candidate_types; |
|
|
8
|
|
|
|
|
95
|
|
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
|
14
|
2
|
|
|
2
|
0
|
12
|
my ($class, $type) = @_; |
|
15
|
2
|
|
|
|
|
16
|
return bless { type => $type }, $class; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub name { |
|
19
|
0
|
|
|
0
|
0
|
0
|
my ($class) = @_; |
|
20
|
0
|
|
|
|
|
0
|
return 'maybe'; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub type { |
|
24
|
2
|
|
|
2
|
0
|
1996
|
my ($self) = @_; |
|
25
|
2
|
|
|
|
|
14
|
return $self->{type}; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub signature { |
|
29
|
1
|
|
|
1
|
0
|
5
|
my ($self) = @_; |
|
30
|
1
|
|
|
|
|
3
|
return sprintf 'maybe[%s]', $self->type->signature; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub accepts { |
|
34
|
7
|
|
|
7
|
0
|
1623
|
my ($class, $data) = @_; |
|
35
|
7
|
|
|
|
|
27
|
return 0; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
|
39
|
|
|
|
|
|
|
__END__ |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=encoding utf-8 |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
JSON::TypeInference::Type::Maybe - maybe type |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
C< JSON::TypeInference::Type::Maybe > represents a possibility whether a value type exists or not. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The type consists of a value type and C<< JSON::TypeInference::Type::Null >>. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
It is a container type, and has a type parameter. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over 4 |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item C<< looks_like_maybe($candidate_types: ArrayRef[JSON::TypeInference::Type]); # => Bool >> |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Returns whether the given types conform to C< JSON::TypeInference::Type::Maybe > structure. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
aereal E<lt>aereal@aereal.orgE<gt> |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
L<JSON::TypeInference::Type::Null> |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|