line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Method::Generate::DemolishAll; |
2
|
48
|
|
|
48
|
|
360
|
use strict; |
|
48
|
|
|
|
|
106
|
|
|
48
|
|
|
|
|
1650
|
|
3
|
48
|
|
|
48
|
|
260
|
use warnings; |
|
48
|
|
|
|
|
98
|
|
|
48
|
|
|
|
|
1485
|
|
4
|
|
|
|
|
|
|
|
5
|
48
|
|
|
48
|
|
277
|
use Moo::Object (); |
|
48
|
|
|
|
|
97
|
|
|
48
|
|
|
|
|
1613
|
|
6
|
48
|
|
|
48
|
|
2173
|
BEGIN { our @ISA = qw(Moo::Object) } |
7
|
48
|
|
|
48
|
|
3938
|
use Sub::Quote qw(quote_sub quotify); |
|
48
|
|
|
|
|
38990
|
|
|
48
|
|
|
|
|
3103
|
|
8
|
48
|
|
|
48
|
|
370
|
use Moo::_Utils qw(_getglob _linear_isa _in_global_destruction_code); |
|
48
|
|
|
|
|
101
|
|
|
48
|
|
|
|
|
17955
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub generate_method { |
11
|
24
|
|
|
24
|
0
|
157
|
my ($self, $into) = @_; |
12
|
24
|
|
|
|
|
105
|
quote_sub "${into}::DEMOLISHALL", join '', |
13
|
|
|
|
|
|
|
$self->_handle_subdemolish($into), |
14
|
|
|
|
|
|
|
qq{ my \$self = shift;\n}, |
15
|
|
|
|
|
|
|
$self->demolishall_body_for($into, '$self', '@_'), |
16
|
|
|
|
|
|
|
qq{ return \$self\n}; |
17
|
24
|
|
|
|
|
3782
|
quote_sub "${into}::DESTROY", |
18
|
|
|
|
|
|
|
sprintf <<'END_CODE', $into, _in_global_destruction_code; |
19
|
|
|
|
|
|
|
my $self = shift; |
20
|
|
|
|
|
|
|
my $e; |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
local $?; |
23
|
|
|
|
|
|
|
local $@; |
24
|
|
|
|
|
|
|
package %s; |
25
|
|
|
|
|
|
|
eval { |
26
|
|
|
|
|
|
|
$self->DEMOLISHALL(%s); |
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
} or $e = $@; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# fatal warnings+die in DESTROY = bad times (perl rt#123398) |
32
|
|
|
|
|
|
|
no warnings FATAL => 'all'; |
33
|
|
|
|
|
|
|
use warnings 'all'; |
34
|
|
|
|
|
|
|
die $e if defined $e; # rethrow |
35
|
|
|
|
|
|
|
END_CODE |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub demolishall_body_for { |
39
|
24
|
|
|
24
|
0
|
420
|
my ($self, $into, $me, $args) = @_; |
40
|
|
|
|
|
|
|
my @demolishers = |
41
|
58
|
|
|
|
|
154
|
grep *{_getglob($_)}{CODE}, |
42
|
|
|
|
|
|
|
map "${_}::DEMOLISH", |
43
|
24
|
|
|
|
|
47
|
@{_linear_isa($into)}; |
|
24
|
|
|
|
|
196
|
|
44
|
24
|
|
|
|
|
268
|
join '', |
45
|
|
|
|
|
|
|
qq{ package $into;\n}, |
46
|
|
|
|
|
|
|
map qq{ ${me}->${_}(${args});\n}, @demolishers; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _handle_subdemolish { |
50
|
24
|
|
|
24
|
|
59
|
my ($self, $into) = @_; |
51
|
24
|
|
|
|
|
91
|
' if (ref($_[0]) ne '.quotify($into).') {'."\n". |
52
|
|
|
|
|
|
|
" package $into;\n". |
53
|
|
|
|
|
|
|
' return shift->Moo::Object::DEMOLISHALL(@_)'.";\n". |
54
|
|
|
|
|
|
|
' }'."\n"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |