line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
2
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Petal::CodePerl::Expr::DerefTAL; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use base qw( Code::Perl::Expr::Base ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
183
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Class::MethodMaker ( |
9
|
2
|
|
|
|
|
14
|
get_set => [qw( -java Key Ref Strict )] |
10
|
2
|
|
|
2
|
|
18
|
); |
|
2
|
|
|
|
|
4
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
186241
|
use Scalar::Util qw(blessed reftype ); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1613
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub eval |
15
|
|
|
|
|
|
|
{ |
16
|
1
|
|
|
1
|
0
|
340
|
my $self = shift; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
31
|
my $ref = $self->getRef->eval; |
19
|
1
|
|
|
|
|
95
|
my $key = $self->getKey; |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
|
|
18
|
ref($ref) || die "Not a ref"; |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
27
|
if ($self->getStrict) |
24
|
|
|
|
|
|
|
{ |
25
|
0
|
0
|
|
|
|
0
|
return Scalar::Util::blessed($ref) ? |
|
|
0
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$ref->$key() : |
27
|
|
|
|
|
|
|
reftype($ref) eq 'ARRAY' ? $ref->[$key] : $ref->{$key}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else |
30
|
|
|
|
|
|
|
{ |
31
|
1
|
50
|
33
|
|
|
27
|
return Scalar::Util::blessed(\$ref) && (UNIVERSAL::can($ref, $key) or UNIVERSAL::can($ref, "AUTOLOAD")) ? |
|
|
50
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$ref->$key() : |
33
|
|
|
|
|
|
|
reftype($ref) eq 'ARRAY' ? $ref->[$key] : $ref->{$key}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub perl |
38
|
|
|
|
|
|
|
{ |
39
|
1
|
|
|
1
|
0
|
42
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
68
|
my $ref_perl = "(".$self->getRef->perl.")"; |
42
|
1
|
|
|
|
|
149
|
my $key = $self->getKey; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
20
|
my $method = 0; |
45
|
1
|
|
|
|
|
4
|
my $number = 0; |
46
|
1
|
50
|
|
|
|
9
|
if ($key =~ /^[a-z_][a-z0-9_-]*/i) |
|
|
0
|
|
|
|
|
|
47
|
|
|
|
|
|
|
{ |
48
|
1
|
|
|
|
|
3
|
$method = 1; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
elsif($key =~ /^\d+$/) |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
|
|
|
|
0
|
$number = 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
6
|
my $assign = qq{ref(my \$ref = $ref_perl) || die "Not a ref"}; |
56
|
|
|
|
|
|
|
|
57
|
1
|
50
|
33
|
|
|
3447949
|
if (! $number and ! $method) |
|
|
50
|
|
|
|
|
|
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
# it must be a hash key |
60
|
0
|
|
|
|
|
0
|
return qq{($ref_perl)->{"$key"}}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif($number) |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
# look like a number but could be a hash key |
65
|
0
|
|
|
|
|
0
|
return qq{do{$assign; Scalar::Util::reftype(\$ref) eq 'ARRAY' ? \$ref->[$key] : \$ref->{$key}}}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else |
68
|
|
|
|
|
|
|
{ |
69
|
|
|
|
|
|
|
# looks like a method name but could be a hash key |
70
|
|
|
|
|
|
|
|
71
|
1
|
50
|
|
|
|
107
|
if($self->getStrict) |
72
|
|
|
|
|
|
|
{ |
73
|
|
|
|
|
|
|
# strict mode means NEVER treat a blessed object as just a hash |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
return qq{Scalar::Util::blessed(\$ref) ? \$ref->$key() : \$ref->{"$key"}}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else |
78
|
|
|
|
|
|
|
{ |
79
|
|
|
|
|
|
|
# non-strict means check to see if the method exists, if not then fall |
80
|
|
|
|
|
|
|
# back to using hash |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
40
|
return qq{do{$assign; Scalar::Util::blessed(\$ref) && (UNIVERSAL::can(\$ref, "$key") or UNIVERSAL::can(\$ref, "AUTOLOAD")) ? \$ref->$key() : \$ref->{"$key"}}}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |