line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::Spy; |
2
|
1
|
|
|
1
|
|
71442
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
3
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
699
|
use Devel::Spy::Util; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
5
|
1
|
|
|
1
|
|
891
|
use Sub::Name (); |
|
1
|
|
|
|
|
727
|
|
|
1
|
|
|
|
|
27
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
518
|
use Devel::Spy::_constants; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
482
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
18
|
|
|
18
|
1
|
57
|
my @self; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Store a tied wrapper over the object. This will be used anytime |
15
|
|
|
|
|
|
|
# thing is ever used as a value or reference. |
16
|
18
|
|
|
|
|
70
|
$self[TIED_PAYLOAD] = Devel::Spy::Util->wrap_thing( $_[_thing], $_[_logger] ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Store a plain copy of $thing as well. If $thing is an object the |
19
|
|
|
|
|
|
|
# method calls have to go through this copy instead. tied objects |
20
|
|
|
|
|
|
|
# can't be returned as objects from function calls. |
21
|
18
|
|
|
|
|
39
|
$self[UNTIED_PAYLOAD] = $_[_thing]; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Store the reporting code, whatever that is. |
24
|
18
|
|
|
|
|
24
|
$self[CODE] = $_[_logger]; |
25
|
|
|
|
|
|
|
|
26
|
18
|
|
|
|
|
119
|
return bless \@self, "$_[_class]\::_obj"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $null_eventlog = Devel::Spy::Util->Y( |
30
|
|
|
|
|
|
|
Sub::Name::subname( null_eventlog_curry => sub { |
31
|
|
|
|
|
|
|
my $f = shift @_; |
32
|
|
|
|
|
|
|
return Sub::Name::subname( null_eventlog => sub { |
33
|
|
|
|
|
|
|
return $f; |
34
|
|
|
|
|
|
|
} ); |
35
|
|
|
|
|
|
|
} ) |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub make_null_eventlog { |
39
|
2
|
|
|
2
|
1
|
3095
|
return $null_eventlog; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub make_eventlog { |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# C returns a closure which appends a new element to a |
45
|
|
|
|
|
|
|
# log and returns a closure which appends to the new log entry. |
46
|
|
|
|
|
|
|
# |
47
|
|
|
|
|
|
|
# my ( $log, $logger ) = Devel::Spy->make_eventlog; |
48
|
|
|
|
|
|
|
# |
49
|
|
|
|
|
|
|
# my $foo = $logger->log( 'A' ); # pushes 'A' onto @$log |
50
|
|
|
|
|
|
|
# $foo = $foo->( 'B' ); # Appends 'B' to 'A' |
51
|
|
|
|
|
|
|
# $foo = $foo->( 'C' ); # Appends 'C' to 'AB' |
52
|
|
|
|
|
|
|
# $foo = $foo->( 'D' ); # Appends 'D' to 'ABC' |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
# my $bar = $logger->log( 1 ) # pushes '1' onto @$log |
55
|
|
|
|
|
|
|
# $bar = $bar->( 2 ); # Appends '2' onto '1' |
56
|
|
|
|
|
|
|
# $bar = $bar->( 3 ); # Appends '3' onto '12' |
57
|
|
|
|
|
|
|
# $bar = $bar->( 4 ); # Appends '4' onto '123' |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
1
|
1
|
891
|
my @eventlog; |
60
|
|
|
|
|
|
|
my $logger = Sub::Name::subname( EVENT => sub { |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Add to the event log |
63
|
1
|
|
|
1
|
|
3
|
push @eventlog, "@_"; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Let the caller add more information to this log entry |
66
|
|
|
|
|
|
|
# with more information as needed. |
67
|
1
|
|
|
|
|
3
|
my $followup = \$eventlog[-1]; |
68
|
|
|
|
|
|
|
return Devel::Spy::Util->Y( |
69
|
|
|
|
|
|
|
Sub::Name::subname( eventlog_curry => sub { |
70
|
3
|
|
|
|
|
4
|
my $f = shift @_; |
71
|
|
|
|
|
|
|
Sub::Name::subname( eventlog_followup => sub { |
72
|
3
|
|
|
|
|
14
|
$$followup .= "@_"; |
73
|
3
|
|
|
|
|
7
|
$f; |
74
|
3
|
|
|
|
|
33
|
} ); |
75
|
|
|
|
|
|
|
} |
76
|
1
|
|
|
|
|
13
|
) ); |
77
|
1
|
|
|
|
|
14
|
} ); |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
6
|
return ( \@eventlog, $logger ); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $tattler = Devel::Spy::Util->Y( |
83
|
|
|
|
|
|
|
Sub::Name::subname( tattler_curry => sub { |
84
|
|
|
|
|
|
|
my $f = shift @_; |
85
|
|
|
|
|
|
|
return Sub::Name::subname( tattler => sub { |
86
|
|
|
|
|
|
|
local $\ = "\n"; |
87
|
|
|
|
|
|
|
print for @_; |
88
|
|
|
|
|
|
|
return $f; |
89
|
|
|
|
|
|
|
} ); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
) ); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub make_tattler { |
94
|
1
|
|
|
1
|
1
|
882
|
return $tattler; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Include these *after* _compile is compiled because they'll want it available. |
98
|
1
|
|
|
1
|
|
453
|
use Devel::Spy::_obj; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
99
|
1
|
|
|
1
|
|
726
|
use Devel::Spy::TieScalar; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
100
|
1
|
|
|
1
|
|
600
|
use Devel::Spy::TieArray; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
101
|
1
|
|
|
1
|
|
620
|
use Devel::Spy::TieHash; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
102
|
1
|
|
|
1
|
|
565
|
use Devel::Spy::TieHandle; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
our $DEBUG; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |