| 1 | 117 | ▶ | use 5.010001; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | 117 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 117 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Mite::Trait::HasDestructor; | ||||||||||||||||||||
| 6 | 117 | ▶ | use Mite::Miteception -role, -all; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 117 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||
| 9 | 117 | our $VERSION = '0.013000'; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 117 | requires qw( | |||||||||||||||||||
| 12 | linear_isa | ||||||||||||||||||||
| 13 | _get_parent | ||||||||||||||||||||
| 14 | _compile_meta | ||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 118 | ▶ | around compilation_stages => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 18 | 118 | my ( $next, $self ) = ( shift, shift ); | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | # Check if we are inheriting from a Mite class in this project | ||||||||||||||||||||
| 21 | 118 | my $inherit_from_mite = do { | |||||||||||||||||||
| 22 | # First parent | ||||||||||||||||||||
| 23 | 118 | my $first_isa = do { | |||||||||||||||||||
| 24 | 118 | my @isa = $self->linear_isa; | |||||||||||||||||||
| 25 | 118 | shift @isa; | |||||||||||||||||||
| 26 | 118 | shift @isa; | |||||||||||||||||||
| 27 | }; | ||||||||||||||||||||
| 28 | 118 | ▶ | !! ( $first_isa and $self->_get_parent( $first_isa ) ); | ||||||||||||||||||
|
Condition100%3/3
$first_isa && $self->_get_parent($first_isa)
MC/DC100%2/2
$first_isa && $self->_get_parent($first_isa)
$first_isa
$self->_get_parent($first_isa)
Truth table100%3/3
A && B
A= $first_isaB= $self->_get_parent($first_isa)
| |||||||||||||||||||||
| 29 | }; | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 118 | my @stages = $self->$next( @_ ); | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | # Only need these stages if not already inheriting from Mite | ||||||||||||||||||||
| 34 | 118 | ▶ | push @stages, qw( | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | _compile_destroy | ||||||||||||||||||||
| 36 | ) unless $inherit_from_mite; | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 118 | return @stages; | |||||||||||||||||||
| 39 | 117 | }; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 94 | ▶ | sub _compile_destroy { | ||||||||||||||||||
|
Subroutine
_compile_destroy: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 42 | 94 | my $self = shift; | |||||||||||||||||||
| 43 | 94 | sprintf <<'CODE', $self->_compile_meta( '$class', '$self' ); | |||||||||||||||||||
| 44 | # Destructor should call DEMOLISH methods | ||||||||||||||||||||
| 45 | sub DESTROY { | ||||||||||||||||||||
| 46 | my $self = shift; | ||||||||||||||||||||
| 47 | my $class = ref( $self ) || $self; | ||||||||||||||||||||
| 48 | my $meta = %s; | ||||||||||||||||||||
| 49 | my $in_global_destruction = defined ${^GLOBAL_PHASE} | ||||||||||||||||||||
| 50 | ? ${^GLOBAL_PHASE} eq 'DESTRUCT' | ||||||||||||||||||||
| 51 | : Devel::GlobalDestruction::in_global_destruction(); | ||||||||||||||||||||
| 52 | for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) { | ||||||||||||||||||||
| 53 | my $e = do { | ||||||||||||||||||||
| 54 | local ( $?, $@ ); | ||||||||||||||||||||
| 55 | eval { $demolisher->( $self, $in_global_destruction ) }; | ||||||||||||||||||||
| 56 | $@; | ||||||||||||||||||||
| 57 | }; | ||||||||||||||||||||
| 58 | no warnings 'misc'; # avoid (in cleanup) warnings | ||||||||||||||||||||
| 59 | die $e if $e; # rethrow | ||||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | return; | ||||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | CODE | ||||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 117 | 1; | |||||||||||||||||||