InlinedPrivateMethod.pm

filter: Statementstmt 57.9% 102 / 176 Branchbran 47.5% 39 / 82 Conditioncond 7.6% 1 / 13 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 53.8% 7 / 13 Podpod 0.0% 0 / 11 totaltotal 49.1% 149 / 303 CC 54 SCAR 41.8
CC
54
Cov
52%
find
125.3
new
70.7
load_names
30.3
CRAP 65.6
« ZIO_Tk.pm ↑ Summary ZIO_Win32.pm »
1 package Games::Rezrov::InlinedPrivateMethod;
2 # create array-inlined versions of private method calls.
3 # MNE 5/12/99
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶sub new {
Subroutine new: called CC=21 SCAR=42.6
Pod undocumented
8 3 my ($package, %options) = @_;
9  
10 3 my $caller = scalar caller();
11 3 ▶ my $count = $options{"-start"} || 0;
Condition50%1/2
$options{'-start'} || 0
l!l
03
MC/DC0%0/1
$options{'-start'} || 0
$options{'-start'}
Truth table50%1/2
A
A= $options{'-start'}
Aresult
11
00
12 3 ▶ die "need -names" unless $options{"-names"};
Branch: 1 branch
BranchTrueFalseTotal
unless $options{"-names"} 0 3 3
13 3 my %names;
14 3 foreach (@{$options{"-names"}}) {
15 24 ▶ die "need leading _ for $_ in $caller!" unless /^_/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^_/ 0 24 24
16 24 $names{$_} = 1;
17 }
18  
19 3 my $code = "";
20 3 my $fh;
21 3 do {
22 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 3 ▶ die "eek" unless $caller;
Branch: 1 branch
BranchTrueFalseTotal
unless $caller 0 3 3
24 3 eval '$fh = \*' . $caller . '::DATA';
25 # yech, what's the "clean" syntax for this?
26 3 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 3 3
27  
28 # $fh = \*{$caller::DATA};
29 # fails
30 };
31 3 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 713 3 716
32 713 $code .= $_;
33 }
34
35 3 my %seen;
36 # while ($code =~ /(->([A-Z_\d]+)\((.*?)\))/g) {
37 # while ($code =~ /(->([A-Z_\d]+)\((.*)\))/g) {
38 # .* = BROKEN
39 my $char;
40 3 ▶ while ($code =~ /(->(_\w+)\()/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code =~ /(->(_\w+)\()/g) 87 3 90
41 87 my ($full, $var) = ($1, $2);
42 87 ▶ next unless exists $names{$var};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $names{$var} 0 87 87
43 87 my $start = pos($code);
44 87 my $end = $start;
45 87 my $depth=1;
46 87 while (1) {
47 # find code between the appropriately nested paren
48 # FIX ME: QUOTED ('s
49 391 $char = substr($code, $end, 1);
50 391 ▶ if ($char eq '(') {
Branch: 2 branches
BranchTrueFalseTotal
if ($char eq '(') { } 2 389 391
elsif ($char eq ')') { } 89 300 389
51 2 $depth++;
52 } elsif ($char eq ')') {
53 89 ▶ last if --$depth == 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$depth == 0 87 2 89
54 }
55 304 $end++;
56 }
57 87 my $value = substr($code, $start, $end - $start);
58 87 $full .= $value . ")";
59 # printf STDERR "full: %s ... value: %s\n", $full, $value;
60 87 my $index;
61 87 ▶ if (exists $seen{$var}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $seen{$var}) { } 63 24 87
62 63 $index = $seen{$var};
63 } else {
64 24 $index = $seen{$var} = $count++;
65 }
66 87 ▶ if (length $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $value) { } 28 59 87
67 # setting
68 28 $code =~ s/\Q$full\E/->[$index] = $value/;
69 } else {
70 # referring
71 59 $code =~ s/\Q$full\E/->[$index]/;
72 }
73 87 ▶ die "xxx: $1" unless length $2;
Branch: 1 branch
BranchTrueFalseTotal
unless length $2 0 87 87
74 }
75  
76 3 ▶ if (scalar keys %seen != scalar keys %names) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %seen != scalar keys %names) 0 3 3
77 0 foreach (keys %names) {
78 0 ▶ die "hmm, never saw reference to $_ in $caller..." unless exists $seen{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $seen{$_} 0 0 0
79 }
80 }
81  
82 # print STDERR $code;
83 3 ▶ if ($options{"-manual"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{'-manual'}) { } 2 1 3
84 # user wants to manipulate/eval code themselves
85 2 return \$code;
86 } else {
87 # wrap code in caller's package
88 1 $code = sprintf("\{ package %s;\n", $caller) . $code . "\n\}\n";
89 0 ▶ eval $code;
Subroutine find: not called CC=20 SCAR=48.3
Subroutine get: called CC=2 SCAR=11.2
Subroutine get_items: not called CC=1 SCAR=2.3
Subroutine get_random: not called CC=4 SCAR=21.1
Subroutine get_rooms: not called CC=1 SCAR=2.3
Subroutine is_room: called CC=3 SCAR=16.8
Subroutine last_object: not called CC=1 SCAR=2.3
Subroutine load_names: called CC=9 SCAR=34.1
Subroutine new: called CC=1 SCAR=2.3
Subroutine print: not called CC=1 SCAR=2.3
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 24 branches
BranchTrueFalseTotal
if ($options{'-all'}) { } 0 0 0
elsif ($options{'-room'}) { } 0 0 0
if $desc =~ /^\d/ 0 0 0
if ($desc =~ /$what/i or $desc =~ /$what2/i) 0 0 0
if (exists $hits{$desc}) { } 0 0 0
if ($p and $$desc =~ /^[A-Z]/) { } 0 0 0
if ($preferred) 0 0 0
if (scalar keys %hits > 1) 0 0 0
if ($_->[1] =~ /^$what$/i) 0 0 0
if (lc $word eq lc $what) 0 0 0
if (scalar keys %h2 == 1) { } 0 0 0
elsif (scalar keys %h3 == 1) { } 0 0 0
if (defined $$cache[$_[1]]) { } 437 268 705
$options{'-room'} ? : 0 0 0
if not defined $last_index or $this_index != $last_index 0 0 0
if ($rooms) { } 0 71 71
if (my $zo = $self->get($id)) { } 71 0 71
if $self->[2] 3 1 4
if ($i <= $max_objects) 199 0 199
if ($$desc =~ /\s{5,}/) { } 1 198 199
if (Games::Rezrov::StoryFile::likely_location($desc)) { } 70 128 198
if ($zos->parent_room) { } 1 69 70
unless $self->[0] 0 1 1
if exists $idesc{$_} 0 54 54
Condition0%0/11
$desc =~ /$what/i or $desc =~ /$what2/i
l!l&&r!l&&!r
000
$self->get($_->get_parent_id) || (next)
l!l
00
$p and $$desc =~ /^[A-Z]/
!ll&&!rl&&r
000
not defined $last_index or $this_index != $last_index
l!l&&r!l&&!r
000
MC/DC0%0/2
$desc =~ /$what/i or $desc =~ /$what2/i
$desc =~ /$what/i $desc =~ /$what2/i
MC/DC0%0/1
$self->get($_->get_parent_id) || (next)
$self->get($_->get_parent_id)
MC/DC0%0/2
$p and $$desc =~ /^[A-Z]/
$p $$desc =~ /^[A-Z]/
MC/DC0%0/2
not defined $last_index or $this_index != $last_index
not defined $last_index $this_index != $last_index
Truth table0%0/3
A or B
A= $desc =~ /$what/iB= $desc =~ /$what2/i
ABresult
1X1
011
000
Truth table0%0/2
A
A= $self->get($_->get_parent_id)
Aresult
11
00
Truth table0%0/3
A and B
A= $pB= $$desc =~ /^[A-Z]/
ABresult
0X0
100
111
Truth table0%0/3
not(A) or B
A= not defined $last_indexB= $this_index != $last_index
ABresult
1X1
011
000
90 1 ▶ die "eval error: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
91 }
92 }
93  
94 1 1;
« ZIO_Tk.pm ↑ Summary ZIO_Win32.pm »