line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Rezrov::InlinedPrivateMethod; |
2
|
|
|
|
|
|
|
# create array-inlined versions of private method calls. |
3
|
|
|
|
|
|
|
# MNE 5/12/99 |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
188
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
3
|
|
|
3
|
0
|
10
|
my ($package, %options) = @_; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
|
|
9
|
my $caller = scalar caller(); |
11
|
3
|
|
50
|
|
|
26
|
my $count = $options{"-start"} || 0; |
12
|
3
|
50
|
|
|
|
12
|
die "need -names" unless $options{"-names"}; |
13
|
3
|
|
|
|
|
5
|
my %names; |
14
|
3
|
|
|
|
|
4
|
foreach (@{$options{"-names"}}) { |
|
3
|
|
|
|
|
10
|
|
15
|
24
|
50
|
|
|
|
79
|
die "need leading _ for $_ in $caller!" unless /^_/; |
16
|
24
|
|
|
|
|
59
|
$names{$_} = 1; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
8
|
my $code = ""; |
20
|
3
|
|
|
|
|
6
|
my $fh; |
21
|
3
|
|
|
|
|
6
|
do { |
22
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
541
|
|
23
|
3
|
50
|
|
|
|
10
|
die "eek" unless $caller; |
24
|
3
|
|
|
|
|
227
|
eval '$fh = \*' . $caller . '::DATA'; |
25
|
|
|
|
|
|
|
# yech, what's the "clean" syntax for this? |
26
|
3
|
50
|
|
|
|
18
|
die $@ if $@; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# $fh = \*{$caller::DATA}; |
29
|
|
|
|
|
|
|
# fails |
30
|
|
|
|
|
|
|
}; |
31
|
3
|
|
|
|
|
18
|
while (<$fh>) { |
32
|
713
|
|
|
|
|
1462
|
$code .= $_; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
6
|
my %seen; |
36
|
|
|
|
|
|
|
# while ($code =~ /(->([A-Z_\d]+)\((.*?)\))/g) { |
37
|
|
|
|
|
|
|
# while ($code =~ /(->([A-Z_\d]+)\((.*)\))/g) { |
38
|
|
|
|
|
|
|
# .* = BROKEN |
39
|
|
|
|
|
|
|
my $char; |
40
|
3
|
|
|
|
|
24
|
while ($code =~ /(->(_\w+)\()/g) { |
41
|
87
|
|
|
|
|
206
|
my ($full, $var) = ($1, $2); |
42
|
87
|
50
|
|
|
|
180
|
next unless exists $names{$var}; |
43
|
87
|
|
|
|
|
103
|
my $start = pos($code); |
44
|
87
|
|
|
|
|
88
|
my $end = $start; |
45
|
87
|
|
|
|
|
248
|
my $depth=1; |
46
|
87
|
|
|
|
|
84
|
while (1) { |
47
|
|
|
|
|
|
|
# find code between the appropriately nested paren |
48
|
|
|
|
|
|
|
# FIX ME: QUOTED ('s |
49
|
391
|
|
|
|
|
644
|
$char = substr($code, $end, 1); |
50
|
391
|
100
|
|
|
|
988
|
if ($char eq '(') { |
|
|
100
|
|
|
|
|
|
51
|
2
|
|
|
|
|
4
|
$depth++; |
52
|
|
|
|
|
|
|
} elsif ($char eq ')') { |
53
|
89
|
100
|
|
|
|
182
|
last if --$depth == 0; |
54
|
|
|
|
|
|
|
} |
55
|
304
|
|
|
|
|
264
|
$end++; |
56
|
|
|
|
|
|
|
} |
57
|
87
|
|
|
|
|
124
|
my $value = substr($code, $start, $end - $start); |
58
|
87
|
|
|
|
|
115
|
$full .= $value . ")"; |
59
|
|
|
|
|
|
|
# printf STDERR "full: %s ... value: %s\n", $full, $value; |
60
|
87
|
|
|
|
|
74
|
my $index; |
61
|
87
|
100
|
|
|
|
149
|
if (exists $seen{$var}) { |
62
|
63
|
|
|
|
|
90
|
$index = $seen{$var}; |
63
|
|
|
|
|
|
|
} else { |
64
|
24
|
|
|
|
|
54
|
$index = $seen{$var} = $count++; |
65
|
|
|
|
|
|
|
} |
66
|
87
|
100
|
|
|
|
137
|
if (length $value) { |
67
|
|
|
|
|
|
|
# setting |
68
|
28
|
|
|
|
|
482
|
$code =~ s/\Q$full\E/->[$index] = $value/; |
69
|
|
|
|
|
|
|
} else { |
70
|
|
|
|
|
|
|
# referring |
71
|
59
|
|
|
|
|
1107
|
$code =~ s/\Q$full\E/->[$index]/; |
72
|
|
|
|
|
|
|
} |
73
|
87
|
50
|
|
|
|
1097
|
die "xxx: $1" unless length $2; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
3
|
50
|
|
|
|
12
|
if (scalar keys %seen != scalar keys %names) { |
77
|
0
|
|
|
|
|
0
|
foreach (keys %names) { |
78
|
0
|
0
|
|
|
|
0
|
die "hmm, never saw reference to $_ in $caller..." unless exists $seen{$_}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# print STDERR $code; |
83
|
3
|
100
|
|
|
|
10
|
if ($options{"-manual"}) { |
84
|
|
|
|
|
|
|
# user wants to manipulate/eval code themselves |
85
|
2
|
|
|
|
|
18
|
return \$code; |
86
|
|
|
|
|
|
|
} else { |
87
|
|
|
|
|
|
|
# wrap code in caller's package |
88
|
1
|
|
|
|
|
9
|
$code = sprintf("\{ package %s;\n", $caller) . $code . "\n\}\n"; |
89
|
1
|
0
|
0
|
0
|
0
|
1532
|
eval $code; |
|
0
|
0
|
0
|
705
|
0
|
0
|
|
|
0
|
0
|
0
|
0
|
0
|
0
|
|
|
0
|
0
|
0
|
0
|
0
|
0
|
|
|
0
|
0
|
|
0
|
0
|
0
|
|
|
0
|
0
|
|
71
|
0
|
0
|
|
|
0
|
0
|
|
0
|
0
|
0
|
|
|
0
|
0
|
|
4
|
0
|
0
|
|
|
0
|
0
|
|
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