| 1 | package Dallycot::AST::Invert; | ||||||||||||||||||||
| 2 | 29 | our $AUTHORITY = 'cpan:JSMITH'; | |||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | # ABSTRACT: Invert the truth of an expression or value | ||||||||||||||||||||
| 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 | sub new { | ||||||||||||||||||||
| 13 | 13 | ▶ | my ( $class, $expr ) = @_; | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 13 | ▶ | $class = ref $class || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 16 | 13 | return bless [$expr] => $class; | |||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | sub to_rdf { | ||||||||||||||||||||
| 21 | 0 | ▶ | my($self, $model) = @_; | ||||||||||||||||||
|
Subroutine
to_rdf: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | return $model -> apply( | |||||||||||||||||||
| 24 | $model -> meta_uri('loc:invert'), | ||||||||||||||||||||
| 25 | [ $self->[0] ], | ||||||||||||||||||||
| 26 | {} | ||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | sub execute { | ||||||||||||||||||||
| 31 | 80 | ▶ | my ( $self, $engine ) = @_; | ||||||||||||||||||
|
Subroutine
execute: called CC=1 SCAR=0.1
Pod
undocumented
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | return $engine->execute( $self->[0] )->then( | ||||||||||||||||||||
| 34 | sub { | ||||||||||||||||||||
| 35 | 80 | ▶ | my ($res) = @_; | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
| |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 80 | ▶ | if ( $res->isa('Dallycot::Value::Boolean') ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 38 | 67 | return Dallycot::Value::Boolean->new( !$res->value ); | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | elsif ( $res->isa('Dallycot::Value::Lambda') ) { | ||||||||||||||||||||
| 41 | 13 | return Dallycot::Value::Lambda->new( | |||||||||||||||||||
| 42 | expression => Dallycot::AST::Invert->new( $res->[0] ), | ||||||||||||||||||||
| 43 | bindings => $res->[1], | ||||||||||||||||||||
| 44 | bindings_with_defaults => $res->[2], | ||||||||||||||||||||
| 45 | options => $res->[3], | ||||||||||||||||||||
| 46 | closure_environment => $res->[4], | ||||||||||||||||||||
| 47 | closure_namespaces => $res->[5] | ||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | else { | ||||||||||||||||||||
| 51 | 0 | return Dallycot::Value::Boolean->new( !$res->is_defined ); | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | 80 | ); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 29 | 1; | |||||||||||||||||||