| 1 | package Dallycot::AST::ComparisonBase; | ||||||||||
| 2 | 29 | our $AUTHORITY = 'cpan:JSMITH'; | |||||||||
| 3 | |||||||||||
| 4 | # ABSTRACT: Base class for comparison operations | ||||||||||
| 5 | |||||||||||
| 6 | 29 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 29 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 29 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 29 | ▶ | use parent 'Dallycot::AST'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 29 | ▶ | use Promises qw(deferred); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | sub execute { | ||||||||||
| 15 | 84 | ▶ | my ( $self, $engine ) = @_; | ||||||||
|
Subroutine
execute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 16 | |||||||||||
| 17 | 84 | my $d = deferred; | |||||||||
| 18 | |||||||||||
| 19 | 84 | my @expressions = @$self; | |||||||||
| 20 | |||||||||||
| 21 | $engine->execute( shift @expressions )->done( | ||||||||||
| 22 | sub { | ||||||||||
| 23 | 84 | ▶ | $self->process_loop( $engine, $d, $_[0], @expressions ); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 24 | }, | ||||||||||
| 25 | sub { | ||||||||||
| 26 | 0 | ▶ | $d->reject(@_); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 27 | } | ||||||||||
| 28 | 84 | ); | |||||||||
| 29 | |||||||||||
| 30 | 84 | return $d->promise; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | sub process_loop { | ||||||||||
| 34 | 121 | ▶ | my ( $self, $engine, $d, $left_value, @expressions ) = @_; | ||||||||
|
Subroutine
process_loop: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 35 | |||||||||||
| 36 | 121 | ▶ | if ( !@expressions ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 37 | $d->resolve( $engine->TRUE ); | |||||||||
| 38 | } | ||||||||||
| 39 | else { | ||||||||||
| 40 | $engine->execute( shift @expressions )->done( | ||||||||||
| 41 | sub { | ||||||||||
| 42 | 84 | ▶ | my ($right_value) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
| |||||||||||
| 43 | $engine->coerce( $left_value, $right_value, [ $left_value->type, $right_value->type ] )->done( | ||||||||||
| 44 | sub { | ||||||||||
| 45 | 83 | ▶ | my ( $cleft, $cright ) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 46 | $self->compare( $engine, $cleft, $cright )->done( | ||||||||||
| 47 | sub { | ||||||||||
| 48 | 83 | ▶ | if ( $_[0] ) { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 49 | 37 | $self->process_loop( $engine, $d, $right_value, @expressions ); | |||||||||
| 50 | } | ||||||||||
| 51 | else { | ||||||||||
| 52 | 46 | $d->resolve( $engine->FALSE ); | |||||||||
| 53 | } | ||||||||||
| 54 | }, | ||||||||||
| 55 | sub { | ||||||||||
| 56 | 0 | ▶ | $d->reject(@_); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 57 | } | ||||||||||
| 58 | 83 | ); | |||||||||
| 59 | }, | ||||||||||
| 60 | sub { | ||||||||||
| 61 | 0 | ▶ | $d->reject(@_); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 62 | } | ||||||||||
| 63 | 84 | ); | |||||||||
| 64 | }, | ||||||||||
| 65 | sub { | ||||||||||
| 66 | 0 | ▶ | $d->reject(@_); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 67 | } | ||||||||||
| 68 | 84 | ); | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 121 | return; | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | sub compare { | ||||||||||
| 75 | 0 | ▶ | my ( $engine, $left_value, $right_value ) = @_; | ||||||||
|
Subroutine
compare: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 76 | |||||||||||
| 77 | 0 | my $d = deferred; | |||||||||
| 78 | |||||||||||
| 79 | 0 | $d->reject("Comparison not defined"); | |||||||||
| 80 | |||||||||||
| 81 | 0 | return $d->promise; | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 29 | 1; | |||||||||