line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.010; |
3
|
3
|
|
|
3
|
|
59
|
use strict; |
|
3
|
|
|
|
|
10
|
|
4
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
68
|
|
5
|
3
|
|
|
3
|
|
16
|
#use Log::Any '$log'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
73
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Mo qw(build default); |
8
|
3
|
|
|
3
|
|
13
|
use Role::Tiny::With; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
15
|
|
9
|
3
|
|
|
3
|
|
748
|
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1843
|
|
10
|
|
|
|
|
|
|
extends 'Data::Sah::Compiler::perl::TH'; |
11
|
|
|
|
|
|
|
with 'Data::Sah::Type::bool'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
14
|
|
|
|
|
|
|
our $DATE = '2022-09-30'; # DATE |
15
|
|
|
|
|
|
|
our $DIST = 'Data-Sah'; # DIST |
16
|
|
|
|
|
|
|
our $VERSION = '0.913'; # VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ($self, $cd) = @_; |
19
|
|
|
|
|
|
|
my $c = $self->compiler; |
20
|
355
|
|
|
355
|
0
|
698
|
|
21
|
355
|
|
|
|
|
1186
|
my $dt = $cd->{data_term}; |
22
|
|
|
|
|
|
|
$cd->{_ccl_check_type} = "!ref($dt)"; |
23
|
355
|
|
|
|
|
1507
|
} |
24
|
355
|
|
|
|
|
1077
|
|
25
|
|
|
|
|
|
|
my ($self, $which, $cd) = @_; |
26
|
|
|
|
|
|
|
my $c = $self->compiler; |
27
|
|
|
|
|
|
|
my $ct = $cd->{cl_term}; |
28
|
289
|
|
|
289
|
0
|
531
|
my $dt = $cd->{data_term}; |
29
|
289
|
|
|
|
|
821
|
|
30
|
289
|
|
|
|
|
1168
|
if ($which eq 'is') { |
31
|
289
|
|
|
|
|
523
|
$c->add_ccl($cd, "($dt ? 1:0) == ($ct ? 1:0)"); |
32
|
|
|
|
|
|
|
} elsif ($which eq 'in') { |
33
|
289
|
100
|
|
|
|
869
|
if ($dt =~ /\$_\b/) { |
|
|
50
|
|
|
|
|
|
34
|
150
|
|
|
|
|
574
|
$c->add_ccl($cd, "do { my \$_sahv_dt = $dt; (grep { (\$_ ? 1:0) == (\$_sahv_dt ? 1:0) } \@{ $ct }) ? 1:0 }"); |
35
|
|
|
|
|
|
|
} else { |
36
|
139
|
100
|
|
|
|
327
|
$c->add_ccl($cd, "(grep { (\$_ ? 1:0) == ($dt ? 1:0) } \@{ $ct }) ? 1:0"); |
37
|
1
|
|
|
|
|
5
|
} |
38
|
|
|
|
|
|
|
} |
39
|
138
|
|
|
|
|
549
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my ($self, $which, $cd) = @_; |
42
|
|
|
|
|
|
|
my $c = $self->compiler; |
43
|
|
|
|
|
|
|
my $cv = $cd->{cl_value}; |
44
|
|
|
|
|
|
|
my $ct = $cd->{cl_term}; |
45
|
60
|
|
|
60
|
0
|
108
|
my $dt = $cd->{data_term}; |
46
|
60
|
|
|
|
|
156
|
|
47
|
60
|
|
|
|
|
239
|
if ($which eq 'min') { |
48
|
60
|
|
|
|
|
92
|
$c->add_ccl($cd, "($dt ? 1:0) >= ($ct ? 1:0)"); |
49
|
60
|
|
|
|
|
94
|
} elsif ($which eq 'xmin') { |
50
|
|
|
|
|
|
|
$c->add_ccl($cd, "($dt ? 1:0) > ($ct ? 1:0)"); |
51
|
60
|
100
|
|
|
|
245
|
} elsif ($which eq 'max') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
52
|
9
|
|
|
|
|
31
|
$c->add_ccl($cd, "($dt ? 1:0) <= ($ct ? 1:0)"); |
53
|
|
|
|
|
|
|
} elsif ($which eq 'xmax') { |
54
|
9
|
|
|
|
|
32
|
$c->add_ccl($cd, "($dt ? 1:0) < ($ct ? 1:0)"); |
55
|
|
|
|
|
|
|
} elsif ($which eq 'between') { |
56
|
9
|
|
|
|
|
32
|
if ($cd->{cl_is_expr}) { |
57
|
|
|
|
|
|
|
$c->add_ccl($cd, "($dt ? 1:0) >= ($ct\->[0] ? 1:0) && ". |
58
|
9
|
|
|
|
|
34
|
"($dt ? 1:0) <= ($ct\->[1] ? 1:0)"); |
59
|
|
|
|
|
|
|
} else { |
60
|
12
|
50
|
|
|
|
24
|
# simplify code |
61
|
0
|
|
|
|
|
0
|
$c->add_ccl($cd, "($dt ? 1:0) >= ($cv->[0] ? 1:0) && ". |
62
|
|
|
|
|
|
|
"($dt ? 1:0) <= ($cv->[1] ? 1:0)"); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} elsif ($which eq 'xbetween') { |
65
|
12
|
|
|
|
|
63
|
if ($cd->{cl_is_expr}) { |
66
|
|
|
|
|
|
|
$c->add_ccl($cd, "($dt ? 1:0) > ($ct\->[0] ? 1:0) && ". |
67
|
|
|
|
|
|
|
"($dt ? 1:0) < ($ct\->[1] ? 1:0)"); |
68
|
|
|
|
|
|
|
} else { |
69
|
12
|
50
|
|
|
|
24
|
# simplify code |
70
|
0
|
|
|
|
|
0
|
$c->add_ccl($cd, "($dt ? 1:0) > ($cv->[0] ? 1:0) && ". |
71
|
|
|
|
|
|
|
"($dt ? 1:0) < ($cv->[1] ? 1:0)"); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
12
|
|
|
|
|
59
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my ($self, $cd) = @_; |
77
|
|
|
|
|
|
|
my $c = $self->compiler; |
78
|
|
|
|
|
|
|
my $ct = $cd->{cl_term}; |
79
|
|
|
|
|
|
|
my $dt = $cd->{data_term}; |
80
|
|
|
|
|
|
|
|
81
|
21
|
|
|
21
|
0
|
39
|
$c->add_ccl($cd, "($ct) ? $dt : !defined($ct) ? 1 : !$dt"); |
82
|
21
|
|
|
|
|
65
|
} |
83
|
21
|
|
|
|
|
85
|
|
84
|
21
|
|
|
|
|
38
|
1; |
85
|
|
|
|
|
|
|
# ABSTRACT: perl's type handler for type "bool" |
86
|
21
|
|
|
|
|
74
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=pod |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=encoding UTF-8 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Data::Sah::Compiler::perl::TH::bool - perl's type handler for type "bool" |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 VERSION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This document describes version 0.913 of Data::Sah::Compiler::perl::TH::bool (from Perl distribution Data-Sah), released on 2022-09-30. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=for Pod::Coverage ^(clause_.+|superclause_.+)$ |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 HOMEPAGE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah>. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SOURCE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Data-Sah>. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 CONTRIBUTING |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
To contribute, you can send patches by email/via RT, or send pull requests on |
118
|
|
|
|
|
|
|
GitHub. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Most of the time, you don't need to build the distribution yourself. You can |
121
|
|
|
|
|
|
|
simply modify the code, then test via: |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
% prove -l |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
If you want to build the distribution (e.g. to try to install it locally on your |
126
|
|
|
|
|
|
|
system), you can install L<Dist::Zilla>, |
127
|
|
|
|
|
|
|
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, |
128
|
|
|
|
|
|
|
L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other |
129
|
|
|
|
|
|
|
Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond |
130
|
|
|
|
|
|
|
that are considered a bug and can be reported to me. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012 by perlancar <perlancar@cpan.org>. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
137
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 BUGS |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
144
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
145
|
|
|
|
|
|
|
feature. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |