| 1 | package Data::Sah::Compiler::js::TH::float; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 1 | our $DATE = '2016-09-14'; # DATE | |||||||||||||
| 4 | 1 | our $VERSION = '0.87'; # VERSION | |||||||||||||
| 5 | |||||||||||||||
| 6 | 1 | ▶ | use 5.010; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | #use Log::Any '$log'; | ||||||||||||||
| 10 | |||||||||||||||
| 11 | 1 | ▶ | use Mo qw(build default); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 1 | ▶ | use Role::Tiny::With; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | |||||||||||||||
| 14 | 1 | extends 'Data::Sah::Compiler::js::TH::num'; | |||||||||||||
| 15 | 1 | with 'Data::Sah::Type::float'; | |||||||||||||
| 16 | |||||||||||||||
| 17 | 0 | ▶ | sub handle_type { | ||||||||||||
|
Subroutine
handle_type: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 18 | 0 | my ($self, $cd) = @_; | |||||||||||||
| 19 | 0 | my $c = $self->compiler; | |||||||||||||
| 20 | 0 | my $dt = $cd->{data_term}; | |||||||||||||
| 21 | |||||||||||||||
| 22 | 0 | $cd->{_ccl_check_type} = "(typeof($dt)=='number' || parseFloat($dt)==$dt)"; | |||||||||||||
| 23 | } | ||||||||||||||
| 24 | |||||||||||||||
| 25 | 0 | ▶ | sub clause_is_nan { | ||||||||||||
|
Subroutine
clause_is_nan: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 26 | 0 | my ($self, $cd) = @_; | |||||||||||||
| 27 | 0 | my $c = $self->compiler; | |||||||||||||
| 28 | 0 | my $ct = $cd->{cl_term}; | |||||||||||||
| 29 | 0 | my $dt = $cd->{data_term}; | |||||||||||||
| 30 | |||||||||||||||
| 31 | 0 | ▶ | if ($cd->{cl_is_expr}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 32 | 0 | $c->add_ccl( | |||||||||||||
| 33 | $cd, | ||||||||||||||
| 34 | join( | ||||||||||||||
| 35 | "", | ||||||||||||||
| 36 | "$ct ? isNaN($dt) : ", | ||||||||||||||
| 37 | $self->expr_defined($ct), " ? !isNaN($dt) : true", | ||||||||||||||
| 38 | ) | ||||||||||||||
| 39 | ); | ||||||||||||||
| 40 | } else { | ||||||||||||||
| 41 | 0 | ▶ | if ($cd->{cl_value}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 42 | 0 | $c->add_ccl($cd, "isNaN($dt)"); | |||||||||||||
| 43 | } elsif (defined $cd->{cl_value}) { | ||||||||||||||
| 44 | 0 | $c->add_ccl($cd, "!isNaN($dt)"); | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | } | ||||||||||||||
| 47 | } | ||||||||||||||
| 48 | |||||||||||||||
| 49 | 0 | ▶ | sub clause_is_pos_inf { | ||||||||||||
|
Subroutine
clause_is_pos_inf: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 50 | 0 | my ($self, $cd) = @_; | |||||||||||||
| 51 | 0 | my $c = $self->compiler; | |||||||||||||
| 52 | 0 | my $ct = $cd->{cl_term}; | |||||||||||||
| 53 | 0 | my $dt = $cd->{data_term}; | |||||||||||||
| 54 | |||||||||||||||
| 55 | 0 | ▶ | if ($cd->{cl_is_expr}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 56 | 0 | $c->add_ccl( | |||||||||||||
| 57 | $cd, | ||||||||||||||
| 58 | join( | ||||||||||||||
| 59 | "", | ||||||||||||||
| 60 | "$ct ? $dt == Infinity : ", | ||||||||||||||
| 61 | $self->expr_defined($ct), " ? $dt != Infinity : true", | ||||||||||||||
| 62 | ) | ||||||||||||||
| 63 | ); | ||||||||||||||
| 64 | } else { | ||||||||||||||
| 65 | 0 | ▶ | if ($cd->{cl_value}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 66 | 0 | $c->add_ccl($cd, "$dt == Infinity"); | |||||||||||||
| 67 | } elsif (defined $cd->{cl_value}) { | ||||||||||||||
| 68 | 0 | $c->add_ccl($cd, "$dt != Infinity"); | |||||||||||||
| 69 | } | ||||||||||||||
| 70 | } | ||||||||||||||
| 71 | } | ||||||||||||||
| 72 | |||||||||||||||
| 73 | 0 | ▶ | sub clause_is_neg_inf { | ||||||||||||
|
Subroutine
clause_is_neg_inf: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 74 | 0 | my ($self, $cd) = @_; | |||||||||||||
| 75 | 0 | my $c = $self->compiler; | |||||||||||||
| 76 | 0 | my $ct = $cd->{cl_term}; | |||||||||||||
| 77 | 0 | my $dt = $cd->{data_term}; | |||||||||||||
| 78 | |||||||||||||||
| 79 | 0 | ▶ | if ($cd->{cl_is_expr}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 80 | 0 | $c->add_ccl( | |||||||||||||
| 81 | $cd, | ||||||||||||||
| 82 | join( | ||||||||||||||
| 83 | "", | ||||||||||||||
| 84 | "$ct ? $dt == -Infinity : ", | ||||||||||||||
| 85 | $self->expr_defined($ct), " ? $dt != -Infinity : true", | ||||||||||||||
| 86 | ) | ||||||||||||||
| 87 | ); | ||||||||||||||
| 88 | } else { | ||||||||||||||
| 89 | 0 | ▶ | if ($cd->{cl_value}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 90 | 0 | $c->add_ccl($cd, "$dt == -Infinity"); | |||||||||||||
| 91 | } elsif (defined $cd->{cl_value}) { | ||||||||||||||
| 92 | 0 | $c->add_ccl($cd, "$dt != -Infinity"); | |||||||||||||
| 93 | } | ||||||||||||||
| 94 | } | ||||||||||||||
| 95 | } | ||||||||||||||
| 96 | |||||||||||||||
| 97 | 0 | ▶ | sub clause_is_inf { | ||||||||||||
|
Subroutine
clause_is_inf: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 98 | 0 | my ($self, $cd) = @_; | |||||||||||||
| 99 | 0 | my $c = $self->compiler; | |||||||||||||
| 100 | 0 | my $ct = $cd->{cl_term}; | |||||||||||||
| 101 | 0 | my $dt = $cd->{data_term}; | |||||||||||||
| 102 | |||||||||||||||
| 103 | 0 | ▶ | if ($cd->{cl_is_expr}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 104 | 0 | $c->add_ccl( | |||||||||||||
| 105 | $cd, | ||||||||||||||
| 106 | join( | ||||||||||||||
| 107 | "", | ||||||||||||||
| 108 | "$ct ? Math.abs($dt) == Infinity : ", | ||||||||||||||
| 109 | $self->expr_defined($ct), " ? Math.abs($dt) != Infinity : true", | ||||||||||||||
| 110 | ) | ||||||||||||||
| 111 | ); | ||||||||||||||
| 112 | } else { | ||||||||||||||
| 113 | 0 | ▶ | if ($cd->{cl_value}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 114 | 0 | $c->add_ccl($cd, "Math.abs($dt) == Infinity"); | |||||||||||||
| 115 | } elsif (defined $cd->{cl_value}) { | ||||||||||||||
| 116 | 0 | $c->add_ccl($cd, "Math.abs($dt) != Infinity"); | |||||||||||||
| 117 | } | ||||||||||||||
| 118 | } | ||||||||||||||
| 119 | } | ||||||||||||||
| 120 | |||||||||||||||
| 121 | 1 | 1; | |||||||||||||
| 122 | # ABSTRACT: js's type handler for type "float" | ||||||||||||||
| 123 | |||||||||||||||
| 124 | __END__ | ||||||||||||||