line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Sub::Mutate - examination and modification of subroutines |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Sub::Metadata qw( |
8
|
|
|
|
|
|
|
sub_body_type |
9
|
|
|
|
|
|
|
sub_closure_role |
10
|
|
|
|
|
|
|
sub_is_lvalue |
11
|
|
|
|
|
|
|
sub_is_constant |
12
|
|
|
|
|
|
|
sub_is_method mutate_sub_is_method |
13
|
|
|
|
|
|
|
sub_is_debuggable mutate_sub_is_debuggable |
14
|
|
|
|
|
|
|
sub_prototype mutate_sub_prototype |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$type = sub_body_type($sub); |
18
|
|
|
|
|
|
|
$type = sub_closure_role($sub); |
19
|
|
|
|
|
|
|
if(sub_is_lvalue($sub)) { ... |
20
|
|
|
|
|
|
|
if(sub_is_constant($sub)) { ... |
21
|
|
|
|
|
|
|
if(sub_is_method($sub)) { ... |
22
|
|
|
|
|
|
|
mutate_sub_is_method($sub, 1); |
23
|
|
|
|
|
|
|
if(sub_is_debuggable($sub)) { ... |
24
|
|
|
|
|
|
|
mutate_sub_is_debuggable($sub, 0); |
25
|
|
|
|
|
|
|
$proto = sub_prototype($sub); |
26
|
|
|
|
|
|
|
mutate_sub_prototype($sub, $proto); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Sub::WhenBodied qw(when_sub_bodied); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
when_sub_bodied($sub, sub { mutate_sub_foo($_[0], ...) }); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This module is a backward-compatibility wrapper repackaging functions that |
35
|
|
|
|
|
|
|
are now supplied by other modules. It is deprecated to use this module: |
36
|
|
|
|
|
|
|
you should instead get the functions directly from L |
37
|
|
|
|
|
|
|
or L as appropriate. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
package Sub::Mutate; |
42
|
|
|
|
|
|
|
|
43
|
8
|
|
|
8
|
|
109866
|
{ use 5.006; } |
|
8
|
|
|
|
|
22
|
|
|
8
|
|
|
|
|
244
|
|
44
|
8
|
|
|
8
|
|
31
|
use warnings; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
224
|
|
45
|
8
|
|
|
8
|
|
34
|
use strict; |
|
8
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
347
|
|
46
|
|
|
|
|
|
|
|
47
|
8
|
|
|
|
|
732
|
use Sub::Metadata 0.000 qw( |
48
|
|
|
|
|
|
|
sub_body_type |
49
|
|
|
|
|
|
|
sub_closure_role |
50
|
|
|
|
|
|
|
sub_is_lvalue |
51
|
|
|
|
|
|
|
sub_is_constant |
52
|
|
|
|
|
|
|
sub_is_method mutate_sub_is_method |
53
|
|
|
|
|
|
|
sub_is_debuggable mutate_sub_is_debuggable |
54
|
|
|
|
|
|
|
sub_prototype mutate_sub_prototype |
55
|
8
|
|
|
8
|
|
3196
|
); |
|
8
|
|
|
|
|
8655
|
|
56
|
8
|
|
|
8
|
|
2856
|
use Sub::WhenBodied 0.000 qw(when_sub_bodied); |
|
8
|
|
|
|
|
3066
|
|
|
8
|
|
|
|
|
434
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
our $VERSION = "0.007"; |
59
|
|
|
|
|
|
|
|
60
|
8
|
|
|
8
|
|
37
|
use parent "Exporter"; |
|
8
|
|
|
|
|
6
|
|
|
8
|
|
|
|
|
22
|
|
61
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
62
|
|
|
|
|
|
|
sub_body_type |
63
|
|
|
|
|
|
|
sub_closure_role |
64
|
|
|
|
|
|
|
sub_is_lvalue |
65
|
|
|
|
|
|
|
sub_is_constant |
66
|
|
|
|
|
|
|
sub_is_method mutate_sub_is_method |
67
|
|
|
|
|
|
|
sub_is_debuggable mutate_sub_is_debuggable |
68
|
|
|
|
|
|
|
sub_prototype mutate_sub_prototype |
69
|
|
|
|
|
|
|
when_sub_bodied |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 FUNCTIONS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item sub_body_type(SUB) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item sub_closure_role(SUB) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item sub_is_lvalue(SUB) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item sub_is_constant(SUB) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item sub_is_method(SUB) |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item mutate_sub_is_method(SUB, NEW_METHODNESS) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item sub_is_debuggable(SUB) |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item mutate_sub_is_debuggable(SUB, NEW_DEBUGGABILITY) |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item sub_prototype(SUB) |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item mutate_sub_prototype(SUB, NEW_PROTOTYPE) |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
These functions are supplied by L. You should use that |
97
|
|
|
|
|
|
|
module directly. See that module for documentation. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item when_sub_bodied(SUB, ACTION) |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This function is supplied by L. You should use that |
102
|
|
|
|
|
|
|
module directly. See that module for documentation. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L, |
109
|
|
|
|
|
|
|
L |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 AUTHOR |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Andrew Main (Zefram) |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 COPYRIGHT |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Copyright (C) 2009, 2010, 2011, 2013, 2015 |
118
|
|
|
|
|
|
|
Andrew Main (Zefram) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 LICENSE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
123
|
|
|
|
|
|
|
under the same terms as Perl itself. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |