blib/lib/B/Generate.pm

filter: Statementstmt 42.3% 33 / 78 Branchbran 12.5% 4 / 32 Conditioncond 4.1% 1 / 24 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 66.6% 8 / 12 Podpod n/a totaltotal 28.7% 46 / 160 CC 25 SCAR 36.3
CC
25
Cov
28%
append_elem
90.0
linklist
42.0
prepend_elem
30.0
CRAP 37.6
↑ Summary Generate.xs »
1 package B::Generate;
2  
3 7 require 5.005_62;
4 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use B ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 require DynaLoader;
9 7 ▶use vars qw( @ISA $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 @ISA = qw(DynaLoader);
11 7 $VERSION = '1.56';
12  
13 {
14 # 'no warnings' does not work.
15 7 ▶ local $SIG{__WARN__} = sub {
Subroutine __ANON__: called CC=2 SCAR=8.1
16 132 ▶ return if $_[0] =~ /Subroutine B(?:::\w+)+ redefined/;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /Subroutine B(?:::\w+)+ redefined/ 132 0 132
17 0 warn $_[0];
18 7 };
19 7 bootstrap B::Generate $VERSION;
20 }
21  
22 package
23 B::OP; # do not index
24 7 ▶use constant OP_LIST => B::opnumber("list");
Subroutine BEGIN: called CC=1 SCAR=0.0
25 7 ▶use B qw(OPf_PARENS OPf_KIDS);
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 # for convenience
28 0 ▶sub B::NULL::type { 0 };
Subroutine type: not called CC=1 SCAR=6.9
29  
30 # This is where we implement op.c in Perl. Sssh.
31 # XXX coverage: 0
32 0 ▶sub linklist {
Subroutine linklist: not called CC=6 SCAR=37.4
33 0 my $o = shift;
34 0 ▶ if ( $o->can("first") and $o->first and ${ $o->first } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->can('first') and $o->first and ${$o->first;}) { } 0 0 0
Condition0%0/6
$o->can("first") and $o->first and ${$o->first;}
!ll&&!rl&&r
000
$o->can("first") and $o->first
!ll&&!rl&&r
000
MC/DC0%0/3
$o->can("first") and $o->first and ${$o->first;}
$o->can("first") $o->first ${$o->first;}
Truth table0%0/4
A and B and C
A= $o->can("first")B= $o->firstC= ${$o->first;}
ABCresult
0XX0
10X0
1100
1111
35 0 $o->next( $o->first->linklist );
36 0 ▶ for ( my $kid = $o->first; $$kid; $kid = $kid->sibling ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$kid) 0 0 0
37 0 ▶ if ( ${ $kid->sibling } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (${$kid->sibling;}) { } 0 0 0
38 0 $kid->next( $kid->sibling->linklist );
39 }
40 else {
41 0 $kid->next($o);
42 }
43 }
44 }
45 else {
46 0 $o->next($o);
47 }
48 0 $o->clean;
49 0 return $o->next;
50 }
51  
52 # coverage: scope.t
53 0 ▶sub append_elem {
Subroutine append_elem: not called CC=9 SCAR=45.0
54 0 my ( $class, $type, $first, $last ) = @_;
55 0 ▶ return $last unless $first and $$first;
Branch: 1 branch
BranchTrueFalseTotal
unless $first and $$first 0 0 0
Condition0%0/3
$first and $$first
!ll&&!rl&&r
000
MC/DC0%0/2
$first and $$first
$first $$first
Truth table0%0/3
A and B
A= $firstB= $$first
ABresult
0X0
100
111
56 0 ▶ return $first unless $last and $$last;
Branch: 1 branch
BranchTrueFalseTotal
unless $last and $$last 0 0 0
Condition0%0/3
$last and $$last
!ll&&!rl&&r
000
MC/DC0%0/2
$last and $$last
$last $$last
Truth table0%0/3
A and B
A= $lastB= $$last
ABresult
0X0
100
111
57  
58 0 ▶ if ( $first->type() != $type
Branch: 1 branch
BranchTrueFalseTotal
if ($first->type != $type or $type == 161 and $first->flags & 8) 0 0 0
Condition0%0/6
$first->type != $type or $type == 161 and $first->flags & 8
l!l&&r!l&&!r
000
$type == 161 and $first->flags & 8
!ll&&!rl&&r
000
MC/DC0%0/3
$first->type != $type or $type == 161 and $first->flags & 8
$first->type != $type $type == 161 $first->flags & 8
Truth table0%0/4
A or B and C
A= $first->type != $typeB= $type == 161C= $first->flags & 8
ABCresult
1XX1
0111
00X0
0100
59 or ( $type == OP_LIST and ( $first->flags & OPf_PARENS ) ) )
60 {
61 0 return B::LISTOP->new( $type, 0, $first, $last );
62 }
63  
64 0 ▶ if ( $first->flags() & OPf_KIDS ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first->flags & 4) { } 0 0 0
65  
66 0 $first->last->sibling($last);
67 }
68 else {
69 0 $first->flags( $first->flags | OPf_KIDS );
70 0 $first->first($last);
71 }
72 0 $first->last($last);
73 0 return $first;
74 }
75  
76 # coverage: scope.t
77 0 ▶sub prepend_elem {
Subroutine prepend_elem: not called CC=5 SCAR=34.0
78 0 my ( $class, $type, $first, $last ) = @_;
79 0 ▶ if ( $last->type() != $type ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last->type != $type) 0 0 0
80 0 return B::LISTOP->new( $type, 0, $first, $last );
81 }
82  
83 0 ▶ if ( $type == OP_LIST ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 161) { } 0 0 0
84 0 $first->sibling( $last->first->sibling );
85 0 $last->first->sibling($first);
86 0 ▶ $last->flags( $last->flags & ~OPf_PARENS )
Branch: 1 branch
BranchTrueFalseTotal
unless $first->flags & 8 0 0 0
87 unless ( $first->flags & OPf_PARENS );
88 }
89 else {
90 0 ▶ unless ( $last->flags & OPf_KIDS ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($last->flags & 4) 0 0 0
91 0 $last->last($first);
92 0 $last->flags( $last->flags | OPf_KIDS );
93 }
94 0 $first->sibling( $last->first );
95 0 $last->first($first);
96 }
97 0 $last->flags( $last->flags | OPf_KIDS );
98 0 return $last; # I cannot believe this works.
99 }
100  
101 # coverage: scope.t
102 1 ▶sub scope {
Subroutine scope: called CC=7 SCAR=29.1
103 1 my $o = shift;
104 1 ▶ return unless $o and $$o;
Branch: 1 branch
BranchTrueFalseTotal
unless $o and $$o 0 1 1
Condition33%1/3
$o and $$o
!ll&&!rl&&r
001
MC/DC0%0/2
$o and $$o
$o $$o
Truth table33%1/3
A and B
A= $oB= $$o
ABresult
0X0
100
111
105 1 ▶ if ( $o->flags & OPf_PARENS ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->flags & 8) { } 0 1 1
106 0 $o = B::OP->prepend_elem( B::opnumber("lineseq"),
107 B::OP->new( "enter", 0 ), $o );
108 0 $o->type( B::opnumber("leave") );
109 }
110 else {
111 1 ▶ if ( $o->type == B::opnumber("lineseq") ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o->type == B::opnumber('lineseq')) { } 0 1 1
112 0 my $kid;
113 0 $o->type( B::opnumber("scope") );
114 0 $kid = $o->first;
115 0 ▶ die "This probably shouldn't happen (\$kid->null)\n"
Branch: 1 branch
BranchTrueFalseTotal
if $kid->type == B::opnumber("nextstate") or $kid->type == B::opnumber("dbstate") 0 0 0
Condition0%0/3
$kid->type == B::opnumber("nextstate") or $kid->type == B::opnumber("dbstate")
l!l&&r!l&&!r
000
MC/DC0%0/2
$kid->type == B::opnumber("nextstate") or $kid->type == B::opnumber("dbstate")
$kid->type == B::opnumber("nextstate") $kid->type == B::opnumber("dbstate")
Truth table0%0/3
A or B
A= $kid->type == B::opnumber("nextstate")B= $kid->type == B::opnumber("dbstate")
ABresult
1X1
011
000
116 if ( $kid->type == B::opnumber("nextstate")
117 or $kid->type == B::opnumber("dbstate") );
118 }
119 else {
120 1 $o = B::LISTOP->new( "scope", 0, $o, undef );
121 }
122 }
123 1 return ($o);
124 }
125  
126 7 1;
127 __END__
↑ Summary Generate.xs »