line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.010; |
3
|
3
|
|
|
3
|
|
514
|
use strict; |
|
3
|
|
|
|
|
9
|
|
4
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
63
|
|
5
|
3
|
|
|
3
|
|
13
|
#use Log::Any '$log'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
84
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Mo qw(build default); |
8
|
3
|
|
|
3
|
|
15
|
use Role::Tiny::With; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
14
|
|
9
|
3
|
|
|
3
|
|
695
|
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
3624
|
|
10
|
|
|
|
|
|
|
extends 'Data::Sah::Compiler::perl::TH::num'; |
11
|
|
|
|
|
|
|
with 'Data::Sah::Type::float'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
14
|
|
|
|
|
|
|
our $DATE = '2022-08-20'; # DATE |
15
|
|
|
|
|
|
|
our $DIST = 'Data-Sah'; # DIST |
16
|
|
|
|
|
|
|
our $VERSION = '0.912'; # VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ($self, $cd) = @_; |
19
|
|
|
|
|
|
|
my $c = $self->compiler; |
20
|
666
|
|
|
666
|
0
|
1476
|
|
21
|
666
|
|
|
|
|
2321
|
my $dt = $cd->{data_term}; |
22
|
|
|
|
|
|
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
23
|
666
|
|
|
|
|
3515
|
$cd->{_ccl_check_type} = "$dt =~ ".'/\A(?:[+-]?(?:0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?|((?i)\s*nan\s*)|((?i)\s*[+-]?inf(inity)?)\s*)\z/'; |
24
|
666
|
100
|
100
|
|
|
3590
|
} else { |
25
|
60
|
|
|
|
|
195
|
$c->add_sun_module($cd); |
26
|
|
|
|
|
|
|
# we use isnum = isint + isfloat, because isfloat(3) is false |
27
|
606
|
|
|
|
|
2395
|
$cd->{_ccl_check_type} = "$cd->{_sun_module}::isnum($dt)"; |
28
|
|
|
|
|
|
|
} |
29
|
606
|
|
|
|
|
3026
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my ($self, $cd) = @_; |
32
|
|
|
|
|
|
|
my $c = $self->compiler; |
33
|
|
|
|
|
|
|
my $ct = $cd->{cl_term}; |
34
|
19
|
|
|
19
|
0
|
37
|
my $dt = $cd->{data_term}; |
35
|
19
|
|
|
|
|
50
|
|
36
|
19
|
|
|
|
|
78
|
if ($cd->{cl_is_expr}) { |
37
|
19
|
|
|
|
|
31
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
38
|
|
|
|
|
|
|
$c->add_ccl( |
39
|
19
|
50
|
|
|
|
38
|
$cd, |
40
|
0
|
0
|
0
|
|
|
0
|
qq[$ct ? lc($dt+0) eq "nan" : defined($ct) ? lc($dt+0) ne "nan" : 1], |
41
|
0
|
|
|
|
|
0
|
); |
42
|
|
|
|
|
|
|
} else { |
43
|
|
|
|
|
|
|
$c->add_ccl( |
44
|
|
|
|
|
|
|
$cd, |
45
|
|
|
|
|
|
|
join( |
46
|
0
|
|
|
|
|
0
|
"", |
47
|
|
|
|
|
|
|
"$ct ? $cd->{_sun_module}::isnan($dt) : ", |
48
|
|
|
|
|
|
|
"defined($ct) ? !$cd->{_sun_module}::isnan($dt) : 1", |
49
|
|
|
|
|
|
|
) |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} else { |
53
|
|
|
|
|
|
|
if ($cd->{cl_value}) { |
54
|
|
|
|
|
|
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
55
|
|
|
|
|
|
|
$c->add_ccl($cd, qq[lc($dt+0) eq "nan"]); |
56
|
19
|
100
|
|
|
|
41
|
} else { |
|
|
50
|
|
|
|
|
|
57
|
11
|
100
|
100
|
|
|
43
|
$c->add_ccl($cd, "$cd->{_sun_module}::isnan($dt)"); |
58
|
4
|
|
|
|
|
14
|
} |
59
|
|
|
|
|
|
|
} elsif (defined $cd->{cl_value}) { |
60
|
7
|
|
|
|
|
26
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
61
|
|
|
|
|
|
|
$c->add_ccl($cd, qq[lc($dt+0) ne "nan"]); |
62
|
|
|
|
|
|
|
} else { |
63
|
8
|
100
|
100
|
|
|
29
|
$c->add_ccl($cd, "!$cd->{_sun_module}::isnan($dt)"); |
64
|
4
|
|
|
|
|
15
|
} |
65
|
|
|
|
|
|
|
} |
66
|
4
|
|
|
|
|
16
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my ($self, $cd) = @_; |
70
|
|
|
|
|
|
|
my $c = $self->compiler; |
71
|
|
|
|
|
|
|
my $ct = $cd->{cl_term}; |
72
|
|
|
|
|
|
|
my $dt = $cd->{data_term}; |
73
|
28
|
|
|
28
|
0
|
45
|
|
74
|
28
|
|
|
|
|
74
|
if ($cd->{cl_is_expr}) { |
75
|
28
|
|
|
|
|
114
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
76
|
28
|
|
|
|
|
44
|
$c->add_ccl( |
77
|
|
|
|
|
|
|
$cd, join( |
78
|
28
|
50
|
|
|
|
53
|
'', |
79
|
0
|
0
|
0
|
|
|
0
|
qq[$ct ? $dt =~ /\\A\\s*-inf(inity)?\\s*\\z/i : ], |
80
|
0
|
|
|
|
|
0
|
qq[defined($ct) ? $dt !~ /\\A\\s*inf(inity)?\\s*\\z/i : 1] |
81
|
|
|
|
|
|
|
)); |
82
|
|
|
|
|
|
|
} else { |
83
|
|
|
|
|
|
|
$c->add_ccl( |
84
|
|
|
|
|
|
|
$cd, join( |
85
|
|
|
|
|
|
|
'', |
86
|
|
|
|
|
|
|
"$ct ? $cd->{_sun_module}::isinf($dt) && $cd->{_sun_module}::isneg($dt) : ", |
87
|
0
|
|
|
|
|
0
|
"defined($ct) ? !($cd->{_sun_module}::isinf($dt) && $cd->{_sun_module}::isneg($dt)) : 1", |
88
|
|
|
|
|
|
|
)); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} else { |
91
|
|
|
|
|
|
|
if ($cd->{cl_value}) { |
92
|
|
|
|
|
|
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
93
|
|
|
|
|
|
|
$c->add_ccl($cd, qq[$dt =~ /\\A\\s*-inf(inity)?\\s*\\z/i]); |
94
|
|
|
|
|
|
|
} else { |
95
|
28
|
100
|
|
|
|
61
|
$c->add_ccl($cd, "$cd->{_sun_module}::isinf($dt) && $cd->{_sun_module}::isneg($dt)"); |
|
|
50
|
|
|
|
|
|
96
|
16
|
100
|
100
|
|
|
65
|
} |
97
|
6
|
|
|
|
|
18
|
} elsif (defined $cd->{cl_value}) { |
98
|
|
|
|
|
|
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
99
|
10
|
|
|
|
|
42
|
$c->add_ccl($cd, qq[$dt !~ /\\A\\s*-inf(inity)?\\s*\\z/i]); |
100
|
|
|
|
|
|
|
} else { |
101
|
|
|
|
|
|
|
$c->add_ccl($cd, "!($cd->{_sun_module}::isinf($dt) && $cd->{_sun_module}::isneg($dt))"); |
102
|
12
|
100
|
100
|
|
|
43
|
} |
103
|
6
|
|
|
|
|
22
|
} |
104
|
|
|
|
|
|
|
} |
105
|
6
|
|
|
|
|
25
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my ($self, $cd) = @_; |
108
|
|
|
|
|
|
|
my $c = $self->compiler; |
109
|
|
|
|
|
|
|
my $ct = $cd->{cl_term}; |
110
|
|
|
|
|
|
|
my $dt = $cd->{data_term}; |
111
|
|
|
|
|
|
|
|
112
|
28
|
|
|
28
|
0
|
53
|
if ($cd->{cl_is_expr}) { |
113
|
28
|
|
|
|
|
66
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
114
|
28
|
|
|
|
|
114
|
$c->add_ccl( |
115
|
28
|
|
|
|
|
42
|
$cd, join( |
116
|
|
|
|
|
|
|
'', |
117
|
28
|
50
|
|
|
|
58
|
qq[$ct ? $dt =~ /\\A\\s*inf(inity)?\\s*\\z/i : ], |
118
|
0
|
0
|
0
|
|
|
0
|
qq[defined($ct) ? $dt !~ /\\A\\s*inf(inity)?\\s*\\z/i : 1] |
119
|
0
|
|
|
|
|
0
|
)); |
120
|
|
|
|
|
|
|
} else { |
121
|
|
|
|
|
|
|
$c->add_ccl( |
122
|
|
|
|
|
|
|
$cd, join( |
123
|
|
|
|
|
|
|
'', |
124
|
|
|
|
|
|
|
"$ct ? $cd->{_sun_module}::isinf($dt) && !$cd->{_sun_module}::isneg($dt) : ", |
125
|
|
|
|
|
|
|
"defined($ct) ? !($cd->{_sun_module}::isinf($dt) && !$cd->{_sun_module}::isneg($dt)) : 1", |
126
|
0
|
|
|
|
|
0
|
)); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} else { |
129
|
|
|
|
|
|
|
if ($cd->{cl_value}) { |
130
|
|
|
|
|
|
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
131
|
|
|
|
|
|
|
$c->add_ccl($cd, qq[$dt =~ /\\A\\s*inf(inity)?\\s*\\z/i]); |
132
|
|
|
|
|
|
|
} else { |
133
|
|
|
|
|
|
|
$c->add_ccl($cd, "$cd->{_sun_module}::isinf($dt) && !$cd->{_sun_module}::isneg($dt)"); |
134
|
28
|
100
|
|
|
|
58
|
} |
|
|
50
|
|
|
|
|
|
135
|
16
|
100
|
100
|
|
|
60
|
} elsif (defined $cd->{cl_value}) { |
136
|
6
|
|
|
|
|
23
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
137
|
|
|
|
|
|
|
$c->add_ccl($cd, qq[$dt !~ /\\A\\s*inf(inity)?\\s*\\z/i]); |
138
|
10
|
|
|
|
|
42
|
} else { |
139
|
|
|
|
|
|
|
$c->add_ccl($cd, "!($cd->{_sun_module}::isinf($dt) && !$cd->{_sun_module}::isneg($dt))"); |
140
|
|
|
|
|
|
|
} |
141
|
12
|
100
|
100
|
|
|
43
|
} |
142
|
6
|
|
|
|
|
22
|
} |
143
|
|
|
|
|
|
|
} |
144
|
6
|
|
|
|
|
28
|
|
145
|
|
|
|
|
|
|
my ($self, $cd) = @_; |
146
|
|
|
|
|
|
|
my $c = $self->compiler; |
147
|
|
|
|
|
|
|
my $ct = $cd->{cl_term}; |
148
|
|
|
|
|
|
|
my $dt = $cd->{data_term}; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
if ($cd->{cl_is_expr}) { |
151
|
28
|
|
|
28
|
0
|
55
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
152
|
28
|
|
|
|
|
75
|
$c->add_ccl( |
153
|
28
|
|
|
|
|
113
|
$cd, join( |
154
|
28
|
|
|
|
|
42
|
'', |
155
|
|
|
|
|
|
|
qq[$ct ? $dt =~ /\\A\\s*-?inf(inity)?\\s*\\z/i : ], |
156
|
28
|
50
|
|
|
|
70
|
qq[defined($ct) ? $dt+0 !~ /\\A-?inf\\z/ : 1] |
157
|
0
|
0
|
0
|
|
|
0
|
)); |
158
|
0
|
|
|
|
|
0
|
} else { |
159
|
|
|
|
|
|
|
$c->add_ccl($cd, "$ct ? $cd->{_sun_module}::isinf($dt) : ". |
160
|
|
|
|
|
|
|
"defined($ct) ? $cd->{_sun_module}::isinf($dt) : 1"); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
} else { |
163
|
|
|
|
|
|
|
if ($cd->{cl_value}) { |
164
|
|
|
|
|
|
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
165
|
0
|
|
|
|
|
0
|
$c->add_ccl($cd, qq[$dt =~ /\\A\\s*-?inf(inity)?\\s*\\z/i]); |
166
|
|
|
|
|
|
|
} else { |
167
|
|
|
|
|
|
|
$c->add_ccl($cd, "$cd->{_sun_module}::isinf($dt)"); |
168
|
|
|
|
|
|
|
} |
169
|
28
|
100
|
|
|
|
63
|
} elsif (defined $cd->{cl_value}) { |
|
|
50
|
|
|
|
|
|
170
|
16
|
100
|
100
|
|
|
58
|
if ($cd->{args}{core} || $cd->{args}{no_modules}) { |
171
|
6
|
|
|
|
|
18
|
$c->add_ccl($cd, qq[$dt !~ /\\A\\s*-?inf(inity)?\\s*\\z/i]); |
172
|
|
|
|
|
|
|
} else { |
173
|
10
|
|
|
|
|
34
|
$c->add_ccl($cd, "!$cd->{_sun_module}::isinf($dt)"); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
} |
176
|
12
|
100
|
100
|
|
|
41
|
} |
177
|
6
|
|
|
|
|
20
|
} |
178
|
|
|
|
|
|
|
|
179
|
6
|
|
|
|
|
23
|
1; |
180
|
|
|
|
|
|
|
# ABSTRACT: perl's type handler for type "float" |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=pod |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=encoding UTF-8 |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 NAME |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Data::Sah::Compiler::perl::TH::float - perl's type handler for type "float" |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 VERSION |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This document describes version 0.912 of Data::Sah::Compiler::perl::TH::float (from Perl distribution Data-Sah), released on 2022-08-20. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=for Pod::Coverage ^(compiler|clause_.+|handle_.+)$ |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 HOMEPAGE |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah>. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 SOURCE |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Data-Sah>. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 AUTHOR |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 CONTRIBUTING |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
To contribute, you can send patches by email/via RT, or send pull requests on |
213
|
|
|
|
|
|
|
GitHub. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Most of the time, you don't need to build the distribution yourself. You can |
216
|
|
|
|
|
|
|
simply modify the code, then test via: |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
% prove -l |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
If you want to build the distribution (e.g. to try to install it locally on your |
221
|
|
|
|
|
|
|
system), you can install L<Dist::Zilla>, |
222
|
|
|
|
|
|
|
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, |
223
|
|
|
|
|
|
|
L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other |
224
|
|
|
|
|
|
|
Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond |
225
|
|
|
|
|
|
|
that are considered a bug and can be reported to me. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012 by perlancar <perlancar@cpan.org>. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
232
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 BUGS |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah> |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
239
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
240
|
|
|
|
|
|
|
feature. |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=cut |