line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::ebug::Backend::Plugin::EvalLevel; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1618
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
585
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub register_commands { |
6
|
0
|
|
|
0
|
0
|
|
return ( eval_level => { sub => \&DB::eval_level, record => 1 }, |
7
|
|
|
|
|
|
|
); |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package DB; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
*_project = \&Devel::ebug::Backend::Plugin::EvalLevel::project; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub eval_level { |
15
|
0
|
|
|
0
|
0
|
|
my( $req, $context ) = @_; |
16
|
0
|
|
|
|
|
|
my $res = DB::eval( $req, $context ); # FIXME breaks encapsulation |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
unless( $res->{exception} ) { |
19
|
0
|
|
|
|
|
|
$res->{eval} = _project( $res->{eval}, $req->{level} ); |
20
|
|
|
|
|
|
|
} |
21
|
0
|
|
|
|
|
|
return $res; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package Devel::ebug::Backend::Plugin::EvalLevel; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _cc { |
27
|
0
|
|
|
0
|
|
|
my( $v ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
return ref( $v ) eq 'ARRAY' ? scalar( @$v ) : |
|
|
0
|
|
|
|
|
|
30
|
|
|
|
|
|
|
ref( $v ) eq 'HASH' ? scalar( keys %$v ) : -1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _ck { |
34
|
0
|
|
|
0
|
|
|
my( $v ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
return ref( $v ) eq 'ARRAY' ? [ 0 .. $#$v ] : |
|
|
0
|
|
|
|
|
|
37
|
|
|
|
|
|
|
ref( $v ) eq 'HASH' ? [ sort keys %$v ] : []; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _cv { |
41
|
0
|
|
|
0
|
|
|
my( $v ) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
return ref( $v ) eq 'ARRAY' ? [ @$v ] : |
|
|
0
|
|
|
|
|
|
44
|
|
|
|
|
|
|
ref( $v ) eq 'HASH' ? [ map $v->{$_}, sort keys %$v ] : $v; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _g { |
48
|
0
|
|
|
0
|
|
|
my( $v, $i ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
return ref( $v ) eq 'ARRAY' ? ( $i < @$v, $v->[$i] ) : |
|
|
0
|
|
|
|
|
|
51
|
|
|
|
|
|
|
ref( $v ) eq 'HASH' ? ( exists $v->{$i}, $v->{$i} ) : die; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _ckv { |
55
|
0
|
|
|
0
|
|
|
my( $c ) = @_; |
56
|
0
|
|
|
|
|
|
my( $k, $v ) = ( _ck( $c ), _cv( $c ) ); |
57
|
0
|
|
|
|
|
|
my $r = []; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
while( @$k ) { |
60
|
0
|
|
|
|
|
|
push @$r, [ shift @$k, shift @$v ]; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $r; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub project { |
67
|
0
|
|
|
0
|
0
|
|
my( $v, $l ) = @_; |
68
|
0
|
|
|
|
|
|
my $r = { type => ref $v, |
69
|
|
|
|
|
|
|
string => "$v", |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
if( _cc( $v ) >= 0 ) { |
73
|
0
|
0
|
|
|
|
|
if( !$l ) { |
74
|
0
|
|
|
|
|
|
$r->{childs} = @{_ckv( $v )}; |
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} else { |
76
|
0
|
|
|
|
|
|
$r->{keys} = []; |
77
|
0
|
|
|
|
|
|
foreach my $kv ( @{_ckv( $v )} ) { |
|
0
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
push @{$r->{keys}}, [ $kv->[0], project( $kv->[1], $l - 1 ) ]; |
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} else { |
82
|
0
|
|
|
|
|
|
$r->{value} = $v; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return $r; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |