line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
109
|
|
|
109
|
|
2334
|
use 5.010001; |
|
109
|
|
|
|
|
447
|
|
2
|
109
|
|
|
109
|
|
667
|
use strict; |
|
109
|
|
|
|
|
341
|
|
|
109
|
|
|
|
|
2604
|
|
3
|
109
|
|
|
109
|
|
626
|
use warnings; |
|
109
|
|
|
|
|
363
|
|
|
109
|
|
|
|
|
6064
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Mite::Trait::HasDestructor; |
6
|
109
|
|
|
109
|
|
817
|
use Mite::Miteception -role, -all; |
|
109
|
|
|
|
|
369
|
|
|
109
|
|
|
|
|
1012
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
9
|
|
|
|
|
|
|
our $VERSION = '0.012000'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
requires qw( |
12
|
|
|
|
|
|
|
linear_isa |
13
|
|
|
|
|
|
|
_get_parent |
14
|
|
|
|
|
|
|
_compile_meta |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
around compilation_stages => sub { |
18
|
|
|
|
|
|
|
my ( $next, $self ) = ( shift, shift ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Check if we are inheriting from a Mite class in this project |
21
|
|
|
|
|
|
|
my $inherit_from_mite = do { |
22
|
|
|
|
|
|
|
# First parent |
23
|
|
|
|
|
|
|
my $first_isa = do { |
24
|
|
|
|
|
|
|
my @isa = $self->linear_isa; |
25
|
|
|
|
|
|
|
shift @isa; |
26
|
|
|
|
|
|
|
shift @isa; |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
!! ( $first_isa and $self->_get_parent( $first_isa ) ); |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my @stages = $self->$next( @_ ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Only need these stages if not already inheriting from Mite |
34
|
|
|
|
|
|
|
push @stages, qw( |
35
|
|
|
|
|
|
|
_compile_destroy |
36
|
|
|
|
|
|
|
) unless $inherit_from_mite; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return @stages; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _compile_destroy { |
42
|
90
|
|
|
90
|
|
301
|
my $self = shift; |
43
|
90
|
|
|
|
|
480
|
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
|
|
|
|
|
|
|
1; |