line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Method::Generate::DemolishAll; |
2
|
48
|
|
|
48
|
|
343
|
use strict; |
|
48
|
|
|
|
|
96
|
|
|
48
|
|
|
|
|
1536
|
|
3
|
48
|
|
|
48
|
|
265
|
use warnings; |
|
48
|
|
|
|
|
101
|
|
|
48
|
|
|
|
|
1225
|
|
4
|
|
|
|
|
|
|
|
5
|
48
|
|
|
48
|
|
259
|
use Moo::Object (); |
|
48
|
|
|
|
|
94
|
|
|
48
|
|
|
|
|
1567
|
|
6
|
48
|
|
|
48
|
|
2050
|
BEGIN { our @ISA = qw(Moo::Object) } |
7
|
48
|
|
|
48
|
|
3503
|
use Sub::Quote qw(quote_sub quotify); |
|
48
|
|
|
|
|
38064
|
|
|
48
|
|
|
|
|
2862
|
|
8
|
48
|
|
|
48
|
|
346
|
use Moo::_Utils qw(_getglob _linear_isa _in_global_destruction_code); |
|
48
|
|
|
|
|
121
|
|
|
48
|
|
|
|
|
18030
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub generate_method { |
11
|
24
|
|
|
24
|
0
|
73
|
my ($self, $into) = @_; |
12
|
24
|
|
|
|
|
96
|
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
|
|
|
|
|
3595
|
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
|
399
|
my ($self, $into, $me, $args) = @_; |
40
|
|
|
|
|
|
|
my @demolishers = |
41
|
58
|
|
|
|
|
151
|
grep *{_getglob($_)}{CODE}, |
42
|
|
|
|
|
|
|
map "${_}::DEMOLISH", |
43
|
24
|
|
|
|
|
42
|
@{_linear_isa($into)}; |
|
24
|
|
|
|
|
238
|
|
44
|
24
|
|
|
|
|
340
|
join '', |
45
|
|
|
|
|
|
|
qq{ package $into;\n}, |
46
|
|
|
|
|
|
|
map qq{ ${me}->${_}(${args});\n}, @demolishers; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _handle_subdemolish { |
50
|
24
|
|
|
24
|
|
90
|
my ($self, $into) = @_; |
51
|
24
|
|
|
|
|
78
|
' if (ref($_[0]) ne '.quotify($into).') {'."\n". |
52
|
|
|
|
|
|
|
" package $into;\n". |
53
|
|
|
|
|
|
|
' return shift->Moo::Object::DEMOLISHALL(@_)'.";\n". |
54
|
|
|
|
|
|
|
' }'."\n"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |