line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hook::Scope; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
39484
|
use 5.008; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
87
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
247
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
|
|
|
|
|
|
require DynaLoader; |
8
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
10658
|
|
9
|
|
|
|
|
|
|
@ISA = qw(Exporter |
10
|
|
|
|
|
|
|
DynaLoader); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
13
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
14
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# This allows declaration use Hook::Scope ':all'; |
17
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
18
|
|
|
|
|
|
|
# will save memory. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
@EXPORT_OK = qw( POST PRE ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
@EXPORT = qw(); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$VERSION = '0.04'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
bootstrap Hook::Scope $VERSION; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub PRE (&) { |
29
|
0
|
|
|
0
|
0
|
0
|
$_[0]->(); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
0
|
|
0
|
sub B::NULL::next { return undef } |
33
|
0
|
|
|
0
|
|
0
|
sub B::NULL::name { return undef } |
34
|
2
|
|
|
2
|
|
2355
|
use B::Generate; |
|
2
|
|
|
|
|
7678
|
|
|
2
|
|
|
|
|
1313
|
|
35
|
|
|
|
|
|
|
sub optimizer { |
36
|
474
|
|
|
474
|
0
|
377767
|
my $op = shift; |
37
|
474
|
|
|
|
|
564
|
my $cop; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# print $op->name . "-" . $cop->name . ":" . $cop->file . ":" . $cop->line . "\n"; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my @scope; |
42
|
0
|
|
|
|
|
0
|
my @scope_code; |
43
|
474
|
|
|
|
|
1770
|
my $start = $op->first(); |
44
|
474
|
|
|
|
|
698
|
my $previous; |
45
|
474
|
|
66
|
|
|
4310
|
while($start && ref($start) ne 'B::NULL') { |
46
|
990
|
100
|
100
|
|
|
26673
|
if($start->name =~/^enter/ && $start->name ne 'entersub') { |
|
|
100
|
|
|
|
|
|
47
|
4
|
|
|
|
|
8
|
push @scope, $start; |
48
|
4
|
|
|
|
|
8
|
push @scope_code, []; |
49
|
|
|
|
|
|
|
} elsif($start->name =~/^leave/) { |
50
|
472
|
|
|
|
|
1280
|
pop @scope; |
51
|
472
|
|
|
|
|
827
|
my $entersubs = pop @scope_code; |
52
|
472
|
50
|
|
|
|
1018
|
if($entersubs) { |
53
|
0
|
|
|
|
|
0
|
foreach my $entersub (@$entersubs) { |
54
|
0
|
0
|
|
|
|
0
|
if(ref($start) eq 'B::BINOP') { |
55
|
0
|
|
|
|
|
0
|
my $lineseq = $start->last(); |
56
|
0
|
|
|
|
|
0
|
$entersub->sibling->sibling($lineseq->first()); |
57
|
0
|
|
|
|
|
0
|
$lineseq->first($entersub); |
58
|
0
|
|
|
|
|
0
|
$entersub->sibling->next($start->first->next); |
59
|
0
|
|
|
|
|
0
|
$start->first->next($entersub); |
60
|
|
|
|
|
|
|
} else { |
61
|
0
|
|
|
|
|
0
|
print $start->first . "- $start\n"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
990
|
100
|
66
|
|
|
10787
|
$previous = $start if($start->next && ref($start->next) eq 'B::COP'); |
68
|
|
|
|
|
|
|
|
69
|
990
|
50
|
66
|
|
|
5092
|
if($start->name eq 'refgen' && |
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
70
|
|
|
|
|
|
|
$start->next && $start->next->name eq 'gv' && |
71
|
|
|
|
|
|
|
$start->next->next && $start->next->next->name eq 'entersub') { |
72
|
2
|
|
|
|
|
12
|
my $entersub = $start->next->next(); |
73
|
2
|
|
|
|
|
11
|
my $gvop = $start->next(); |
74
|
2
|
|
|
|
|
11
|
my $gv; |
75
|
2
|
50
|
|
|
|
10
|
if(ref($gvop) eq 'B::PADOP') { |
76
|
|
|
|
|
|
|
#this lives in the threaded |
77
|
0
|
|
|
|
|
0
|
my $cv = $op->find_cv(); |
78
|
0
|
|
|
|
|
0
|
$gv = (($cv->PADLIST->ARRAY)[1]->ARRAY)[$gvop->padix]; |
79
|
|
|
|
|
|
|
} else { |
80
|
2
|
|
|
|
|
1624
|
die "No support for non threaded gvs yet\n"; |
81
|
|
|
|
|
|
|
} |
82
|
0
|
0
|
|
|
|
0
|
if($gv->NAME eq 'PRE') { |
83
|
0
|
|
|
|
|
0
|
my $root_state = $previous->next(); |
84
|
0
|
|
|
|
|
0
|
$previous->sibling($entersub->sibling()); |
85
|
0
|
|
|
|
|
0
|
$previous->next($entersub->next()); |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
push @{$scope_code[-1]}, $root_state; |
|
0
|
|
|
|
|
0
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# print scalar @scope . ": " . ($previous ? $previous->name . " -> " : "") . $start->name . "\n"; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
988
|
|
|
|
|
49969
|
$start = $start->next(); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
walkoptree_filtered( |
105
|
|
|
|
|
|
|
$op, |
106
|
|
|
|
|
|
|
sub { |
107
|
|
|
|
|
|
|
return 1 if(opgrep( |
108
|
|
|
|
|
|
|
{ |
109
|
|
|
|
|
|
|
name => 'refgen', |
110
|
|
|
|
|
|
|
next => { |
111
|
|
|
|
|
|
|
'name' => 'gv', |
112
|
|
|
|
|
|
|
'next' => { |
113
|
|
|
|
|
|
|
'name' => 'entersub' } |
114
|
|
|
|
|
|
|
}, |
115
|
|
|
|
|
|
|
}, @_) |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
print $_[0]->name() . "\n"; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
return 0; |
122
|
|
|
|
|
|
|
}, |
123
|
|
|
|
|
|
|
sub { |
124
|
|
|
|
|
|
|
my $gvop = $_[0]->next(); |
125
|
|
|
|
|
|
|
my $gv; |
126
|
|
|
|
|
|
|
if(ref($gvop) eq 'B::PADOP') { |
127
|
|
|
|
|
|
|
#this lives in the threaded |
128
|
|
|
|
|
|
|
my $cv = $op->find_cv(); |
129
|
|
|
|
|
|
|
$gv = (($cv->PADLIST->ARRAY)[1]->ARRAY)[$gvop->padix]; |
130
|
|
|
|
|
|
|
} else { |
131
|
|
|
|
|
|
|
die "No support for non threaded gvs yet\n"; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
return unless ($gv->NAME eq 'PRE'); |
134
|
|
|
|
|
|
|
my $entersub = $gvop->next(); |
135
|
|
|
|
|
|
|
print "FOUND A PRE\n"; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
}, |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
2
|
|
|
2
|
|
4108
|
use optimizer 'sub-detect' => \&optimizer; |
|
2
|
|
|
|
|
8897
|
|
|
2
|
|
|
|
|
14
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
__END__ |