line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Binding; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
230991
|
use warnings; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
1050
|
|
4
|
6
|
|
|
6
|
|
36
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
248
|
|
5
|
6
|
|
|
6
|
|
7837
|
use PadWalker qw(peek_my peek_our peek_sub closed_over); |
|
6
|
|
|
|
|
12727
|
|
|
6
|
|
|
|
|
1509
|
|
6
|
6
|
|
|
6
|
|
10673
|
use Devel::Caller qw(caller_cv); |
|
6
|
|
|
|
|
22857
|
|
|
6
|
|
|
|
|
686
|
|
7
|
6
|
|
|
6
|
|
6751
|
use Data::Dump qw(pp); |
|
6
|
|
|
|
|
89250
|
|
|
6
|
|
|
|
|
757
|
|
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
216
|
use 5.008; |
|
6
|
|
|
|
|
25
|
|
|
6
|
|
|
|
|
3478
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub of_caller { |
14
|
9
|
|
|
9
|
1
|
1882
|
my ($class, $level) = @_; |
15
|
9
|
100
|
|
|
|
39
|
$level = 1 unless defined($level); |
16
|
|
|
|
|
|
|
|
17
|
9
|
|
100
|
|
|
73
|
my $self = { |
18
|
|
|
|
|
|
|
'caller_cv' => ( caller_cv( $level + 1) || undef ), |
19
|
|
|
|
|
|
|
'level' => $level + 1, |
20
|
|
|
|
|
|
|
}; |
21
|
9
|
|
|
|
|
170
|
return bless $self, $class; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub eval { |
26
|
5
|
|
|
5
|
1
|
29
|
my ($self, $code_str) = @_; |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
48
|
my $vars = peek_my( $self->{level} ); |
29
|
|
|
|
|
|
|
|
30
|
5
|
|
|
|
|
8
|
my $var_declare = ""; |
31
|
5
|
|
|
|
|
19
|
for my $varname (keys %$vars) { |
32
|
6
|
|
|
|
|
363
|
$var_declare .= "my $varname = " . pp(${$vars->{$varname}}) . ";"; |
|
6
|
|
|
|
|
29
|
|
33
|
|
|
|
|
|
|
} |
34
|
5
|
|
|
|
|
416
|
my $code = "$var_declare; $code_str"; |
35
|
5
|
|
|
|
|
395
|
eval $code; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub var { |
39
|
3
|
|
|
3
|
1
|
12
|
my ($self, $varname) = @_; |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
19
|
for (my $level = $self->{level}; $level < 100; $level++) { |
42
|
3
|
|
|
|
|
698
|
my $vars = peek_my($level); |
43
|
3
|
50
|
|
|
|
12
|
if (exists $vars->{$varname}) { |
44
|
3
|
|
|
|
|
8
|
my $varref = $vars->{$varname}; |
45
|
3
|
50
|
66
|
|
|
19
|
if (ref($varref) eq 'SCALAR' || ref($varref) eq 'REF') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
46
|
3
|
|
|
|
|
17
|
return $$varref; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
elsif (ref($varref) eq 'ARRAY') { |
49
|
0
|
|
|
|
|
0
|
return @$varref; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif (ref($varref) eq 'HASH') { |
52
|
0
|
|
|
|
|
0
|
return %$varref; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
die "Unknown var: $varname"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub my_vars { |
61
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
62
|
1
|
|
|
|
|
13
|
my $vars = peek_my($self->{level}); |
63
|
1
|
|
|
|
|
4
|
return $vars; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub our_vars { |
67
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
68
|
1
|
|
|
|
|
20
|
my $vars = peek_our($self->{level}); |
69
|
1
|
|
|
|
|
3
|
return $vars; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
__END__ |