line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Method::Generate::DemolishAll; |
2
|
48
|
|
|
48
|
|
328
|
use strict; |
|
48
|
|
|
|
|
401
|
|
|
48
|
|
|
|
|
1516
|
|
3
|
48
|
|
|
48
|
|
244
|
use warnings; |
|
48
|
|
|
|
|
90
|
|
|
48
|
|
|
|
|
1321
|
|
4
|
|
|
|
|
|
|
|
5
|
48
|
|
|
48
|
|
235
|
use Moo::Object (); |
|
48
|
|
|
|
|
91
|
|
|
48
|
|
|
|
|
1540
|
|
6
|
48
|
|
|
48
|
|
2011
|
BEGIN { our @ISA = qw(Moo::Object) } |
7
|
48
|
|
|
48
|
|
3397
|
use Sub::Quote qw(quote_sub quotify); |
|
48
|
|
|
|
|
32965
|
|
|
48
|
|
|
|
|
2830
|
|
8
|
48
|
|
|
48
|
|
313
|
use Moo::_Utils qw(_getglob _linear_isa _in_global_destruction_code); |
|
48
|
|
|
|
|
88
|
|
|
48
|
|
|
|
|
16190
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub generate_method { |
11
|
24
|
|
|
24
|
0
|
66
|
my ($self, $into) = @_; |
12
|
24
|
|
|
|
|
84
|
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
|
|
|
|
|
3059
|
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
|
356
|
my ($self, $into, $me, $args) = @_; |
40
|
|
|
|
|
|
|
my @demolishers = |
41
|
58
|
|
|
|
|
136
|
grep *{_getglob($_)}{CODE}, |
42
|
|
|
|
|
|
|
map "${_}::DEMOLISH", |
43
|
24
|
|
|
|
|
39
|
@{_linear_isa($into)}; |
|
24
|
|
|
|
|
163
|
|
44
|
24
|
|
|
|
|
228
|
join '', |
45
|
|
|
|
|
|
|
qq{ package $into;\n}, |
46
|
|
|
|
|
|
|
map qq{ ${me}->${_}(${args});\n}, @demolishers; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _handle_subdemolish { |
50
|
24
|
|
|
24
|
|
54
|
my ($self, $into) = @_; |
51
|
24
|
|
|
|
|
70
|
' if (ref($_[0]) ne '.quotify($into).') {'."\n". |
52
|
|
|
|
|
|
|
" package $into;\n". |
53
|
|
|
|
|
|
|
' return shift->Moo::Object::DEMOLISHALL(@_)'.";\n". |
54
|
|
|
|
|
|
|
' }'."\n"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |