blib/lib/B/Bblock.pm

filter: Statementstmt 15.6% 17 / 109 Branchbran 0.0% 0 / 46 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 15 Subroutinesub 20.0% 4 / 20 Podpod 12.5% 1 / 8 totaltotal 9.7% 22 / 225 CC 36 SCAR 31.3
CC
36
Cov
9%
walk_bblocks
42.0
mark_if_leader
42.0
mark_if_leader
42.0
CRAP 22.9
« blib/lib/B/Stackobj.pm ↑ Summary ByteLoader/hints/522_patched.pl »
1 # Maintained now in B::C by Reini Urban <rurban@cpan.org>
2 package B::Bblock;
3  
4 1 our $VERSION = '1.05';
5  
6 1 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 @ISA = "Exporter";
8 1 our @EXPORT_OK = qw(find_leaders);
9  
10 1 ▶use B qw(peekop walkoptree walkoptree_exec
Subroutine BEGIN: called CC=1 SCAR=0.0
11 main_root main_start svref_2object
12 1 OPf_SPECIAL OPf_STACKED );
13  
14 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 my $bblock;
17 my @bblock_ends;
18 # don't load Config with its dependencies
19 1 ▶use B::C ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 0 ▶sub CPERL56 () { ($B::C::Config::Config{usecperl} and $] >= 5.025003) ? 1 : 0 } #sibparent, xpad_cop_seq
Subroutine CPERL56: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$B::C::Config::Config{'usecperl'} && $] >= 5.025003 ? : 0 0 0
Condition0%0/3
$B::C::Config::Config{"usecperl"} and $] >= "5.025003"
!ll&&!rl&&r
000
MC/DC0%0/2
$B::C::Config::Config{"usecperl"} and $] >= "5.025003"
$B::C::Config::Config{"usecperl"} $] >= "5.025003"
Truth table0%0/3
A and B
A= $B::C::Config::Config{"usecperl"}B= $] >= "5.025003"
ABresult
0X0
100
111
21 0 ▶sub PUSHRE () { ($] >= 5.025006 or CPERL56) ? "split" : "pushre" }
Subroutine PUSHRE: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$] >= 5.025006 || &CPERL56() ? : 0 0 0
Condition0%0/3
$] >= "5.025006" or &CPERL56()
l!l&&r!l&&!r
000
MC/DC0%0/2
$] >= "5.025006" or &CPERL56()
$] >= "5.025006" &CPERL56()
Truth table0%0/3
A or B
A= $] >= "5.025006"B= &CPERL56()
ABresult
1X1
011
000
22  
23 0 ▶sub mark_leader {
Subroutine mark_leader: not called CC=2 SCAR=17.9
Pod undocumented
24 0 my $op = shift;
25 0 ▶ if ($$op) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$op) 0 0 0
26 0 $bblock->{$$op} = $op;
27 }
28 }
29  
30 0 ▶sub remove_sortblock {
Subroutine remove_sortblock: not called CC=3 SCAR=24.8
Pod undocumented
31 0 foreach ( keys %$bblock ) {
32 0 my $leader = $$bblock{$_};
33 0 ▶ delete $$bblock{$_} if ( $leader == 0 );
Branch: 1 branch
BranchTrueFalseTotal
if $leader == 0 0 0 0
34 }
35 }
36  
37 0 ▶sub find_leaders {
Subroutine find_leaders: not called CC=3 SCAR=24.8
Pod documented
38 0 my ( $root, $start ) = @_;
39 0 $bblock = {};
40 0 ▶ mark_leader($start) if ( ref $start ne "B::NULL" );
Branch: 1 branch
BranchTrueFalseTotal
if ref $start ne "B::NULL" 0 0 0
41 0 ▶ walkoptree( $root, "mark_if_leader" ) if ( ( ref $root ) ne "B::NULL" );
Branch: 1 branch
BranchTrueFalseTotal
if ref $root ne "B::NULL" 0 0 0
42 0 remove_sortblock();
43 0 return $bblock;
44 }
45  
46 # Debugging
47 0 ▶sub walk_bblocks {
Subroutine walk_bblocks: not called CC=6 SCAR=37.4
Pod undocumented
48 0 my ( $root, $start ) = @_;
49 0 my ( $op, $lastop, $leader, $bb );
50 0 $bblock = {};
51 0 mark_leader($start);
52 0 walkoptree( $root, "mark_if_leader" );
53 0 my @leaders = values %$bblock;
54 0 ▶ while ( $leader = shift @leaders ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($leader = shift @leaders) 0 0 0
55 0 $lastop = $leader;
56 0 $op = $leader->next;
57 0 ▶ while ( $$op && !exists( $bblock->{$$op} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$op and not exists $$bblock{$$op}) 0 0 0
Condition0%0/3
$$op and not exists $$bblock{$$op}
!ll&&!rl&&r
000
MC/DC0%0/2
$$op and not exists $$bblock{$$op}
$$op not exists $$bblock{$$op}
Truth table0%0/3
A and not(B)
A= $$opB= not exists $$bblock{$$op}
ABresult
0X0
100
111
58 0 $bblock->{$$op} = $leader;
59 0 $lastop = $op;
60 0 $op = $op->next;
61 }
62 0 push( @bblock_ends, [ $leader, $lastop ] );
63 }
64 0 foreach $bb (@bblock_ends) {
65 0 ( $leader, $lastop ) = @$bb;
66 0 printf "%s .. %s\n", peekop($leader), peekop($lastop);
67 0 ▶ for ( $op = $leader ; $$op != $$lastop ; $op = $op->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$op != $$lastop) 0 0 0
68 0 printf " %s\n", peekop($op);
69 }
70 0 printf " %s\n", peekop($lastop);
71 }
72 }
73  
74 0 ▶sub walk_bblocks_obj {
Subroutine walk_bblocks_obj: not called CC=1 SCAR=6.9
Pod undocumented
75 0 my $cvref = shift;
76 0 my $cv = svref_2object($cvref);
77 0 walk_bblocks( $cv->ROOT, $cv->START );
78 }
79  
80 0 ▶sub B::OP::mark_if_leader { }
Subroutine mark_if_leader: not called CC=1 SCAR=0.0
81  
82 0 ▶sub B::COP::mark_if_leader {
Subroutine mark_if_leader: not called CC=2 SCAR=17.9
83 0 my $op = shift;
84 0 ▶ if ( $op->label ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->label) 0 0 0
85 0 mark_leader($op);
86 }
87 }
88  
89 0 ▶sub B::LOOP::mark_if_leader {
Subroutine mark_if_leader: not called CC=1 SCAR=6.9
90 0 my $op = shift;
91 0 mark_leader( $op->next );
92 0 mark_leader( $op->nextop );
93 0 mark_leader( $op->redoop );
94 0 mark_leader( $op->lastop->next );
95 }
96  
97 0 ▶sub B::LOGOP::mark_if_leader {
Subroutine mark_if_leader: not called CC=2 SCAR=17.9
98 0 my $op = shift;
99 0 my $opname = $op->name;
100 0 mark_leader( $op->next );
101 0 ▶ if ( $opname eq "entertry" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opname eq 'entertry') { } 0 0 0
102 0 mark_leader( $op->other->next );
103 }
104 else {
105 0 mark_leader( $op->other );
106 }
107 }
108  
109 0 ▶sub B::LISTOP::mark_if_leader {
Subroutine mark_if_leader: not called CC=6 SCAR=37.4
110 0 my $op = shift;
111 0 my $first = $op->first;
112 0 ▶ $first = $first->next while ( $first->name eq "null" );
Branch: 1 branch
BranchTrueFalseTotal
$first->name eq "null" and do { $first = $first->next } 0 0 0
113 0 ▶ mark_leader( $op->first ) unless ( exists( $bblock->{$$first} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$bblock{$$first} 0 0 0
114 0 mark_leader( $op->next );
115 0 ▶ if ( $op->name eq "sort"
Branch: 1 branch
BranchTrueFalseTotal
if ($op->name eq "sort" and $op->flags & 128 and $op->flags & 64) 0 0 0
Condition0%0/6
$op->name eq "sort" and $op->flags & 128 and $op->flags & 64
!ll&&!rl&&r
000
$op->name eq "sort" and $op->flags & 128
!ll&&!rl&&r
000
MC/DC0%0/3
$op->name eq "sort" and $op->flags & 128 and $op->flags & 64
$op->name eq "sort" $op->flags & 128 $op->flags & 64
Truth table0%0/4
A and B and C
A= $op->name eq "sort"B= $op->flags & 128C= $op->flags & 64
ABCresult
0XX0
10X0
1100
1111
116 and $op->flags & OPf_SPECIAL
117 and $op->flags & OPf_STACKED )
118 {
119 0 my $root = $op->first->sibling->first;
120 0 my $leader = $root->first;
121 0 $bblock->{$$leader} = 0;
122 }
123 }
124  
125 0 ▶sub B::PMOP::mark_if_leader {
Subroutine mark_if_leader: not called CC=6 SCAR=37.4
126 0 my $op = shift;
127 0 ▶ if ( $op->type
Branch: 1 branch
BranchTrueFalseTotal
if ($op->type and $op->name ne &PUSHRE() and $] > "5.008005" || $op->name ne "substcont") 0 0 0
Condition0%0/9
$op->type and $op->name ne &PUSHRE() and $] > "5.008005" || $op->name ne "substcont"
!ll&&!rl&&r
000
$op->type and $op->name ne &PUSHRE()
!ll&&!rl&&r
000
$] > "5.008005" or $op->name ne "substcont"
l!l&&r!l&&!r
000
MC/DC0%0/4
$op->type and $op->name ne &PUSHRE() and $] > "5.008005" || $op->name ne "substcont"
$op->type $op->name ne &PUSHRE() $] > "5.008005" $op->name ne "substcont"
Truth table0%0/5
A and B and C or D
A= $op->typeB= $op->name ne &PUSHRE()C= $] > "5.008005"D= $op->name ne "substcont"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
128 and $op->name ne PUSHRE
129 and ($] > 5.008005 or $op->name ne "substcont") )
130 {
131 #warn $op->name, $op->type if $] == 5.008004;
132 0 my $replroot = $op->pmreplroot;
133 0 ▶ if ($$replroot) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$replroot) 0 0 0
134 0 mark_leader( $replroot );
135 0 mark_leader( $op->next );
136 0 mark_leader( $op->pmreplstart );
137 }
138 }
139 }
140  
141 # PMOP stuff omitted
142  
143 0 ▶sub compile {
Subroutine compile: not called CC=5 SCAR=34.0
Pod undocumented
144 0 my @options = @_;
145 0 my $have_B_Concise;
146 0 B::clearsym();
147  
148 0 ▶ eval { require B::Concise; 1 } and $have_B_Concise = 1;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require B::Concise; 1 } } and $have_B_Concise = 1 0 0 0
149 0 ▶ B::Concise->import(qw(concise_cv concise_main set_style_standard))
Branch: 1 branch
BranchTrueFalseTotal
if $have_B_Concise 0 0 0
150 if $have_B_Concise;
151  
152 0 ▶ if ( @options and $have_B_Concise ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@options and $have_B_Concise) { } 0 0 0
Condition0%0/3
@options and $have_B_Concise
!ll&&!rl&&r
000
MC/DC0%0/2
@options and $have_B_Concise
@options $have_B_Concise
Truth table0%0/3
A and B
A= @optionsB= $have_B_Concise
ABresult
0X0
100
111
153 0 ▶ return sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
154 0 my $objname;
155 0 foreach $objname (@options) {
156 0 ▶ $objname = "main::$objname" unless $objname =~ /::/;
Branch: 1 branch
BranchTrueFalseTotal
unless $objname =~ /::/ 0 0 0
157 0 print "walk_bblocks $objname\n";
158 0 eval "walk_bblocks_obj(\\&$objname)";
159 0 ▶ die "walk_bblocks_obj(\\&$objname) failed: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
160 0 print "-------\n";
161 0 set_style_standard("terse");
162 0 eval "concise_cv('exec', \\&$objname)";
163 0 ▶ die "concise_cv('exec', \\&$objname) failed: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
164 }
165 }
166 0 }
167 else {
168 0 ▶ return sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
169 0 walk_bblocks( main_root, main_start );
170 0 print "-------\n";
171 0 ▶ if ($have_B_Concise) {
Branch: 1 branch
BranchTrueFalseTotal
if ($have_B_Concise) 0 0 0
172 0 set_style_standard("terse");
173 0 concise_main("exec");
174 }
175 0 };
176 }
177 }
178  
179 1 1;
180  
181 __END__
« blib/lib/B/Stackobj.pm ↑ Summary ByteLoader/hints/522_patched.pl »