/usr/local/lib/perl5/5.44.0/x86_64-linux/B.pm

filter: Statementstmt 3.1% 3 / 96 Branchbran 0.0% 0 / 40 Conditioncond 0.0% 0 / 25 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 5.8% 1 / 17 Podpod 23.0% 3 / 13 totaltotal 3.4% 7 / 204 CC 31 SCAR 43.6
CC
31
Cov
2%
walkoptree_exec
156.0
walkoptree_slow
132.0
walksymtable
40.9
CRAP 78.0
« lib/Skilletor/ClaudeSettings.pm ↑ Summary /usr/local/lib/perl5/5.44.0/CPAN/Meta/Prereqs.pm »
1 # B.pm
2 #
3 # Copyright (c) 1996, 1997, 1998 Malcolm Beattie
4 #
5 # You may distribute under the terms of either the GNU General Public
6 # License or the Artistic License, as specified in the README file.
7 #
8 package B;
9  
10 @B::ISA = qw(Exporter);
11  
12 # If B is loaded without imports, we do not want to unnecessarily pollute the stash with Exporter.
13 sub import {
14 0 ▶ return unless scalar @_ > 1; # Called as a method call.
Subroutine import: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @_ > 1 0 0 0
15 0 require Exporter;
16 0 B->export_to_level(1, @_);
17 }
18  
19 # walkoptree_slow comes from B.pm (you are there),
20 # walkoptree comes from B.xs
21  
22 BEGIN {
23 $B::VERSION = '1.92';
24 @B::EXPORT_OK = ();
25  
26 # Our BOOT code needs $VERSION set, and will append to @EXPORT_OK.
27 # Want our constants loaded before the compiler meets OPf_KIDS below, as
28 # the combination of having the constant stay a Proxy Constant Subroutine
29 # and its value being inlined saves a little over .5K
30  
31 require XSLoader;
32 XSLoader::load();
33 }
34  
35 push @B::EXPORT_OK, (qw(minus_c ppname save_BEGINs
36 class peekop cast_I32 cstring cchar hash threadsv_names
37 main_root main_start main_cv svref_2object opnumber
38 sub_generation amagic_generation perlstring
39 walkoptree_slow walkoptree walkoptree_exec walksymtable
40 parents comppadlist sv_undef compile_stats timing_info
41 begin_av init_av check_av end_av regex_padav dowarn
42 defstash curstash warnhook diehook inc_gv @optype
43 @specialsv_name unitcheck_av safename));
44  
45 @B::SV::ISA = 'B::OBJECT';
46 @B::NULL::ISA = 'B::SV';
47 @B::PV::ISA = 'B::SV';
48 @B::IV::ISA = 'B::SV';
49 @B::NV::ISA = 'B::SV';
50 # RV is eliminated with 5.11.0, but effectively is a specialisation of IV now.
51 @B::RV::ISA = 'B::IV';
52 @B::PVIV::ISA = qw(B::PV B::IV);
53 @B::PVNV::ISA = qw(B::PVIV B::NV);
54 @B::PVMG::ISA = 'B::PVNV';
55 @B::REGEXP::ISA = 'B::PVMG';
56 @B::INVLIST::ISA = 'B::PV';
57 @B::PVLV::ISA = 'B::GV';
58 @B::BM::ISA = 'B::GV';
59 @B::AV::ISA = 'B::PVMG';
60 @B::GV::ISA = 'B::PVMG';
61 @B::HV::ISA = 'B::PVMG';
62 @B::CV::ISA = 'B::PVMG';
63 @B::IO::ISA = 'B::PVMG';
64 @B::FM::ISA = 'B::CV';
65 @B::OBJ::ISA = 'B::PVMG';
66  
67 @B::OP::ISA = 'B::OBJECT';
68 @B::UNOP::ISA = 'B::OP';
69 @B::UNOP_AUX::ISA = 'B::UNOP';
70 @B::BINOP::ISA = 'B::UNOP';
71 @B::LOGOP::ISA = 'B::UNOP';
72 @B::LISTOP::ISA = 'B::BINOP';
73 @B::SVOP::ISA = 'B::OP';
74 @B::PADOP::ISA = 'B::OP';
75 @B::PVOP::ISA = 'B::OP';
76 @B::LOOP::ISA = 'B::LISTOP';
77 @B::PMOP::ISA = 'B::LISTOP';
78 @B::COP::ISA = 'B::OP';
79 @B::METHOP::ISA = 'B::OP';
80  
81 @B::SPECIAL::ISA = 'B::OBJECT';
82  
83 our @optype = qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP
84 METHOP UNOP_AUX);
85 # bytecode.pl contained the following comment:
86 # Nullsv *must* come first in the following so that the condition
87 # ($$sv == 0) can continue to be used to test (sv == Nullsv).
88 our @specialsv_name = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no
89 (SV*)pWARN_ALL (SV*)pWARN_NONE (SV*)pWARN_STD
90 &PL_sv_zero);
91  
92 # Back-compat
93 {
94 no warnings 'once';
95 *CVf_METHOD = \&CVf_NOWARN_AMBIGUOUS;
96 }
97  
98 {
99 # Stop "-w" from complaining about the lack of a real B::OBJECT class
100 package B::OBJECT;
101 }
102  
103 sub B::GV::SAFENAME {
104 0 ▶ safename(shift()->NAME);
Subroutine SAFENAME: not called CC=1 SCAR=6.9
105 }
106  
107 sub safename {
108 0 ▶ my $name = shift;
Subroutine safename: not called CC=2 SCAR=17.9
Pod documented
109  
110 # The regex below corresponds to the isCONTROLVAR macro
111 # from toke.c
112  
113 0 ▶ $name =~ s/^\c?/^?/
Branch: 1 branch
BranchTrueFalseTotal
$name =~ s/^\c?/^?/ or $name =~ s/^([\cA-\cZ\c\\c[\c]\c_\c^])/'^' . chr(64 ^ ord $1);/e 0 0 0
114 or $name =~ s/^([\cA-\cZ\c\\c[\c]\c_\c^])/
115 0 "^" . chr( utf8::unicode_to_native( 64 ^ ord($1) ))/e;
116  
117 # When we say unicode_to_native we really mean ascii_to_native,
118 # which matters iff this is a non-ASCII platform (EBCDIC). '\c?' would
119 # not have to be special cased, except for non-ASCII.
120  
121 0 return $name;
122 }
123  
124 sub B::IV::int_value {
125 0 ▶ my ($self) = @_;
Subroutine int_value: not called CC=2 SCAR=17.9
126 0 ▶ return (($self->FLAGS() & SVf_IVisUV()) ? $self->UVX : $self->IV);
Branch: 1 branch
BranchTrueFalseTotal
$self->FLAGS & 2147483648 ? : 0 0 0
127 }
128  
129 sub B::NULL::as_string() {""}
130 *B::IV::as_string = *B::IV::as_string = \*B::IV::int_value;
131 *B::PV::as_string = *B::PV::as_string = \*B::PV::PV;
132  
133 # The input typemap checking makes no distinction between different SV types,
134 # so the XS body will generate the same C code, despite the different XS
135 # "types". So there is no change in behaviour from doing "newXS" like this,
136 # compared with the old approach of having a (near) duplicate XS body.
137 # We should fix the typemap checking.
138  
139 # Since perl 5.12.0
140 *B::IV::RV = *B::IV::RV = \*B::PV::RV;
141  
142 my $debug;
143 my $op_count = 0;
144 my @parents = ();
145  
146 sub debug {
147 0 ▶ my ($class, $value) = @_;
Subroutine debug: not called CC=1 SCAR=6.9
Pod undocumented
148 0 $debug = $value;
149 0 walkoptree_debug($value);
150 }
151  
152 sub class {
153 0 ▶ my $obj = shift;
Subroutine class: not called CC=1 SCAR=6.9
Pod documented
154 0 my $name = ref $obj;
155 0 $name =~ s/^.*:://;
156 0 return $name;
157 }
158  
159 0 ▶sub parents { \@parents }
Subroutine parents: not called CC=1 SCAR=6.9
Pod undocumented
160  
161 # For debugging
162 sub peekop {
163 0 ▶ my $op = shift;
Subroutine peekop: not called CC=1 SCAR=6.9
Pod undocumented
164 0 return sprintf("%s (0x%x) %s", class($op), $$op, $op->name);
165 }
166  
167 sub walkoptree_slow {
168 0 ▶ my($op, $method, $level) = @_;
Subroutine walkoptree_slow: not called CC=11 SCAR=48.8
Pod undocumented
169 0 $op_count++; # just for statistics
170 0 ▶ $level ||= 0;
Condition0%0/2
$level ||= 0
l!l
00
MC/DC0%0/1
$level ||= 0
$level
Truth table0%0/2
A
A= $level
Aresult
11
00
171 0 ▶ warn(sprintf("walkoptree: %d. %s\n", $level, peekop($op))) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
172 0 ▶ $op->$method($level) if $op->can($method);
Branch: 1 branch
BranchTrueFalseTotal
if $op->can($method) 0 0 0
173 0 ▶ if ($$op && ($op->flags & OPf_KIDS)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$op and $op->flags & 4) 0 0 0
Condition0%0/3
$$op and $op->flags & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$$op and $op->flags & 4
$$op $op->flags & 4
Truth table0%0/3
A and B
A= $$opB= $op->flags & 4
ABresult
0X0
100
111
174 0 my $kid;
175 0 unshift(@parents, $op);
176 0 ▶ for ($kid = $op->first; $$kid; $kid = $kid->sibling) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$kid) 0 0 0
177 0 walkoptree_slow($kid, $method, $level + 1);
178 }
179 0 shift @parents;
180 }
181 0 ▶ if (class($op) eq 'PMOP'
Branch: 1 branch
BranchTrueFalseTotal
if (B::class($op) eq "PMOP" and ref $op->pmreplroot and ${$op->pmreplroot;} and $op->pmreplroot->isa("B::OP")) 0 0 0
Condition0%0/9
B::class($op) eq "PMOP" and ref $op->pmreplroot and ${$op->pmreplroot;} and $op->pmreplroot->isa("B::OP")
!ll&&!rl&&r
000
B::class($op) eq "PMOP" and ref $op->pmreplroot and ${$op->pmreplroot;}
!ll&&!rl&&r
000
B::class($op) eq "PMOP" and ref $op->pmreplroot
!ll&&!rl&&r
000
MC/DC0%0/4
B::class($op) eq "PMOP" and ref $op->pmreplroot and ${$op->pmreplroot;} and $op->pmreplroot->isa("B::OP")
B::class($op) eq "PMOP" ref $op->pmreplroot ${$op->pmreplroot;} $op->pmreplroot->isa("B::OP")
Truth table0%0/5
A and B and C and D
A= B::class($op) eq "PMOP"B= ref $op->pmreplrootC= ${$op->pmreplroot;}D= $op->pmreplroot->isa("B::OP")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
182 && ref($op->pmreplroot)
183 0 && ${$op->pmreplroot}
184 && $op->pmreplroot->isa( 'B::OP' ))
185 {
186 0 unshift(@parents, $op);
187 0 walkoptree_slow($op->pmreplroot, $method, $level + 1);
188 0 shift @parents;
189 }
190 }
191  
192 sub compile_stats {
193 0 ▶ return "Total number of OPs processed: $op_count\n";
Subroutine compile_stats: not called CC=1 SCAR=6.9
Pod undocumented
194 }
195  
196 sub timing_info {
197 0 ▶ my ($sec, $min, $hr) = localtime;
Subroutine timing_info: not called CC=1 SCAR=6.9
Pod undocumented
198 0 my ($user, $sys) = times;
199 0 sprintf("%02d:%02d:%02d user=$user sys=$sys",
200 $hr, $min, $sec, $user, $sys);
201 }
202  
203 my %symtable;
204  
205 sub clearsym {
206 0 ▶ %symtable = ();
Subroutine clearsym: not called CC=1 SCAR=6.9
Pod undocumented
207 }
208  
209 sub savesym {
210 0 ▶ my ($obj, $value) = @_;
Subroutine savesym: not called CC=1 SCAR=6.9
Pod undocumented
211 # warn(sprintf("savesym: sym_%x => %s\n", $$obj, $value)); # debug
212 0 $symtable{sprintf("sym_%x", $$obj)} = $value;
213 }
214  
215 sub objsym {
216 0 ▶ my $obj = shift;
Subroutine objsym: not called CC=1 SCAR=6.9
Pod undocumented
217 0 return $symtable{sprintf("sym_%x", $$obj)};
218 }
219  
220 sub walkoptree_exec {
221 0 ▶ my ($op, $method, $level) = @_;
Subroutine walkoptree_exec: not called CC=12 SCAR=50.5
Pod undocumented
222 0 ▶ $level ||= 0;
Condition0%0/2
$level ||= 0
l!l
00
MC/DC0%0/1
$level ||= 0
$level
Truth table0%0/2
A
A= $level
Aresult
11
00
223 0 my ($sym, $ppname);
224 0 my $prefix = " " x $level;
225 0 ▶ for (; $$op; $op = $op->next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$op) 0 0 0
226 0 $sym = objsym($op);
227 0 ▶ if (defined($sym)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sym) 0 0 0
228 0 print $prefix, "goto $sym\n";
229 0 return;
230 }
231 0 savesym($op, sprintf("%s (0x%lx)", class($op), $$op));
232 0 $op->$method($level);
233 0 $ppname = $op->name;
234 0 ▶ if ($ppname =~
Branch: 5 branches
BranchTrueFalseTotal
if ($ppname =~ /^(d?or(assign)?|and(assign)?|mapwhile|grepwhile|entertry|range|cond_expr)$/) { } 0 0 0
elsif ($ppname eq 'match' or $ppname eq 'subst') { } 0 0 0
elsif ($ppname eq 'substcont') { } 0 0 0
elsif ($ppname eq 'enterloop') { } 0 0 0
elsif ($ppname eq 'subst') { } 0 0 0
235 /^(d?or(assign)?|and(assign)?|mapwhile|grepwhile|entertry|range|cond_expr)$/)
236 {
237 0 print $prefix, uc($1), " => {\n";
238 0 walkoptree_exec($op->other, $method, $level + 1);
239 0 print $prefix, "}\n";
240 ▶ } elsif ($ppname eq "match" || $ppname eq "subst") {
Condition0%0/3
$ppname eq "match" or $ppname eq "subst"
l!l&&r!l&&!r
000
MC/DC0%0/2
$ppname eq "match" or $ppname eq "subst"
$ppname eq "match" $ppname eq "subst"
Truth table0%0/3
A or B
A= $ppname eq "match"B= $ppname eq "subst"
ABresult
1X1
011
000
241 0 my $pmreplstart = $op->pmreplstart;
242 0 ▶ if ($$pmreplstart) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$pmreplstart) 0 0 0
243 0 print $prefix, "PMREPLSTART => {\n";
244 0 walkoptree_exec($pmreplstart, $method, $level + 1);
245 0 print $prefix, "}\n";
246 }
247 } elsif ($ppname eq "substcont") {
248 0 print $prefix, "SUBSTCONT => {\n";
249 0 walkoptree_exec($op->other->pmreplstart, $method, $level + 1);
250 0 print $prefix, "}\n";
251 0 $op = $op->other;
252 } elsif ($ppname eq "enterloop") {
253 0 print $prefix, "REDO => {\n";
254 0 walkoptree_exec($op->redoop, $method, $level + 1);
255 0 print $prefix, "}\n", $prefix, "NEXT => {\n";
256 0 walkoptree_exec($op->nextop, $method, $level + 1);
257 0 print $prefix, "}\n", $prefix, "LAST => {\n";
258 0 walkoptree_exec($op->lastop, $method, $level + 1);
259 0 print $prefix, "}\n";
260 } elsif ($ppname eq "subst") {
261 0 my $replstart = $op->pmreplstart;
262 0 ▶ if ($$replstart) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$replstart) 0 0 0
263 0 print $prefix, "SUBST => {\n";
264 0 walkoptree_exec($replstart, $method, $level + 1);
265 0 print $prefix, "}\n";
266 }
267 }
268 }
269 }
270  
271 sub walksymtable {
272 0 ▶ my ($symref, $method, $recurse, $prefix) = @_;
Subroutine walksymtable: not called CC=7 SCAR=37.1
Pod documented
273 0 my $sym;
274 my $fullname;
275 no strict 'refs';
276 0 ▶ $prefix = '' unless defined $prefix;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $prefix 0 0 0
277 0 foreach my $sym ( sort keys %$symref ) {
278 0 my $dummy = $symref->{$sym}; # Copying the glob and incrementing
279 # the GPs refcnt clears cached methods
280 0 $fullname = "*main::".$prefix.$sym;
281 0 ▶ if ($sym =~ /::$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sym =~ /::$/) { } 0 0 0
282 0 $sym = $prefix . $sym;
283 0 ▶ if (svref_2object(\*$sym)->NAME ne "main::" && $sym ne "<none>::" && &$recurse($sym)) {
Branch: 1 branch
BranchTrueFalseTotal
if (svref_2object(\*$sym)->NAME ne "main::" and $sym ne "<none>::" and &$recurse($sym)) 0 0 0
Condition0%0/6
svref_2object(\*$sym)->NAME ne "main::" and $sym ne "<none>::" and &$recurse($sym)
!ll&&!rl&&r
000
svref_2object(\*$sym)->NAME ne "main::" and $sym ne "<none>::"
!ll&&!rl&&r
000
MC/DC0%0/3
svref_2object(\*$sym)->NAME ne "main::" and $sym ne "<none>::" and &$recurse($sym)
svref_2object(\*$sym)->NAME ne "main::" $sym ne "<none>::" &$recurse($sym)
Truth table0%0/4
A and B and C
A= svref_2object(\*$sym)->NAME ne "main::"B= $sym ne "<none>::"C= &$recurse($sym)
ABCresult
0XX0
10X0
1100
1111
284 0 walksymtable(\%$fullname, $method, $recurse, $sym);
285 }
286 } else {
287 0 ▶ svref_2object(\*$fullname)->$method();
Subroutine BEGIN: called CC=1 SCAR=0.2
288 }
289 }
290 }
291  
292 1;
293  
294 __END__
« lib/Skilletor/ClaudeSettings.pm ↑ Summary /usr/local/lib/perl5/5.44.0/CPAN/Meta/Prereqs.pm »