| 1 | package Mouse::Meta::Method::Destructor; | ||||||||||
| 2 | 1 | ▶ | use Mouse::Util qw(:meta); # enables strict and warnings | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use constant _MOUSE_DEBUG => $ENV{MOUSE_DEBUG} ? 1 : 0; | ||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||
| 5 | |||||||||||
| 6 | 0 | ▶ | sub _generate_destructor{ | ||||||||
|
Subroutine
_generate_destructor: not called CC=5 SCAR=34.0
| |||||||||||
| 7 | 0 | my (undef, $metaclass) = @_; | |||||||||
| 8 | |||||||||||
| 9 | 0 | my $demolishall = ''; | |||||||||
| 10 | 0 | for my $class ($metaclass->linearized_isa) { | |||||||||
| 11 | 0 | ▶ | if (Mouse::Util::get_code_ref($class, 'DEMOLISH')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 0 | $demolishall .= ' ' . $class | |||||||||
| 13 | . '::DEMOLISH($self, Mouse::Util::in_global_destruction());' | ||||||||||
| 14 | . "\n", | ||||||||||
| 15 | } | ||||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | if($demolishall) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 0 | $demolishall = sprintf <<'EOT', $demolishall; | |||||||||
| 20 | my $e = do{ | ||||||||||
| 21 | local $?; | ||||||||||
| 22 | local $@; | ||||||||||
| 23 | eval{ | ||||||||||
| 24 | %s; | ||||||||||
| 25 | }; | ||||||||||
| 26 | $@; | ||||||||||
| 27 | }; | ||||||||||
| 28 | no warnings 'misc'; | ||||||||||
| 29 | die $e if $e; # rethrow | ||||||||||
| 30 | EOT | ||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | my $name = $metaclass->name; | |||||||||
| 34 | 0 | my $source = sprintf(<<'EOT', __FILE__, $name, $demolishall); | |||||||||
| 35 | #line 1 "%s" | ||||||||||
| 36 | package %s; | ||||||||||
| 37 | sub { | ||||||||||
| 38 | my($self) = @_; | ||||||||||
| 39 | return $self->Mouse::Object::DESTROY() | ||||||||||
| 40 | if ref($self) ne __PACKAGE__; | ||||||||||
| 41 | # DEMOLISHALL | ||||||||||
| 42 | %s; | ||||||||||
| 43 | return; | ||||||||||
| 44 | } | ||||||||||
| 45 | EOT | ||||||||||
| 46 | |||||||||||
| 47 | 0 | warn $source if _MOUSE_DEBUG; | |||||||||
| 48 | |||||||||||
| 49 | 0 | my $code; | |||||||||
| 50 | 0 | my $e = do{ | |||||||||
| 51 | 0 | local $@; | |||||||||
| 52 | 0 | $code = eval $source; | |||||||||
| 53 | 0 | $@; | |||||||||
| 54 | }; | ||||||||||
| 55 | 0 | ▶ | die $e if $e; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 0 | return $code; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 1 | 1; | |||||||||
| 60 | __END__ | ||||||||||