blib/lib/Perlilog.pm

filter: Statementstmt 46.8% 135 / 288 Branchbran 18.8% 20 / 106 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 64.7% 22 / 34 Podpod 0.0% 0 / 15 totaltotal 39.0% 177 / 453 CC 61 SCAR 37.2
CC
61
Cov
39%
do_inheritdir
132.0
interface
90.0
intobjects
72.0
CRAP 41.4
« blib/lib/Perlilog/siteclasses/wbsimple.pl ↑ Summary blib/lib/Perlilog/sysclasses/PLcodegen.pl »
1 #
2 # This file is part of the Perlilog project.
3 #
4 # Copyright (C) 2003, Eli Billauer
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #
20 # A copy of the license can be found in a file named "licence.txt", at the
21 # root directory of this project.
22 #
23  
24 1 require 5.004;
25 1 ▶use Perlilog::PLerror;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 package Perlilog;
27 1 ▶use Perlilog::PLerror;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=2.6
31 1 @Perlilog::warnings = ();
32 1 %Perlilog::classes = ();
33 0 ▶ $SIG{__WARN__} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
34 0 my ($class) = ($_[0] =~ /unquoted string.*?\"(.*?)\".*may clash/i);
35 0 ▶ if (defined $class) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $class) { } 0 0 0
36 0 push @Perlilog::warnings, $_[0];
37 } else {
38 0 warn ($_[0])
39 }
40 1 };
41 }
42  
43 1 ▶END {
Subroutine END: called CC=3 SCAR=18.4
44 0 ▶ $SIG{__WARN__} = sub {warn $_[0]; }; # Prevent an endless recursion
Subroutine __ANON__: not called CC=1 SCAR=1.2
45 1 foreach (@Perlilog::warnings) {
46 0 my ($class) = ($_ =~ /unquoted string.*?\"(.*?)\".*may clash/i);
47 warn ($_)
48 0 ▶ unless (defined $Perlilog::classes{$class});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Perlilog::classes{$class} 0 0 0
49 }
50 }
51  
52 # We use explicit package names rather than Perl 5.6.0's "our", so
53 # perl 5.004 won't yell at us.
54  
55 1 @Perlilog::ISA = (Exporter);
56 1 @Perlilog::EXPORT = qw[&init &override &underride &inherit &inheritdir &interface &interfaceclass
57 &constreset &definedclass &globalobj &execute];
58 1 $Perlilog::VERSION = '1.0';
59 1 $Perlilog::STARTTIME = localtime();
60  
61 1 $Perlilog::perlilogflag = 0;
62 1 $Perlilog::globalobject=();
63 1 $Perlilog::interface_rec = undef;
64 1 @Perlilog::interface_excuses = ();
65  
66 1 ▶unless ($Perlilog::perlilogflag) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Perlilog::perlilogflag) 1 0 1
67 1 $Perlilog::perlilogflag = 1; # Indicate that this clause has been run once
68 1 $Perlilog::errorcrawl='system';
69 1 $Perlilog::callbacksdepth = 0; # This indicates when callbacks are going on.
70 1 undef $Perlilog::wrong_flag;
71  
72 #For unloaded classes: Value is [classfile, parent class, first-given classname].
73 1 %Perlilog::classes = ('PL_hardroot', 1);
74 1 %Perlilog::objects = ();
75 1 @Perlilog::VARS=(undef, undef); # First two variables may be addressed accidentally
76 1 @Perlilog::EQVARS=(undef, undef); # The first two point to themselves.
77 1 @Perlilog::interface_classes = ();
78 1 $Perlilog::objectcounter = 0;
79
80 {
81 1 my $home = $INC{'Perlilog.pm'};
82 1 ($home) = ($home =~ /^(.*)Perlilog\.pm$/);
83 1 ▶ blow("Failed to resolve Perlilog.pm's directory")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $home 0 1 1
84 unless (defined $home);
85 1 $Perlilog::home = $home;
86 }
87  
88 1 $Perlilog::classhome = "${Perlilog::home}Perlilog/sysclasses/";
89 1 inherit('root',"${Perlilog::classhome}PLroot.pl",'PL_hardroot');
90 1 inherit('codegen',"${Perlilog::classhome}PLcodegen.pl",'root');
91 1 inherit('verilog',"${Perlilog::classhome}PLverilog.pl",'codegen');
92 1 inherit('global',"${Perlilog::classhome}PLglobal.pl",'codegen');
93 1 inherit('port',"${Perlilog::classhome}PLport.pl",'root');
94 1 inherit('interface',"${Perlilog::classhome}PLinterface.pl",'verilog');
95 1 inherit('site_init',"${Perlilog::classhome}site_init.pl",'PL_hardroot');
96 }
97  
98 1 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
99 1 site_init -> init;
100 }
101 18 ▶sub inherit {
Subroutine inherit: called CC=3 SCAR=11.1
Pod undocumented
102 18 my $class = shift;
103 18 my $file = shift;
104 18 my $papa = shift;
105  
106 puke("Attempt to create the already existing class \'$class\'\n")
107 18 ▶ if $Perlilog::classes{$class};
Branch: 1 branch
BranchTrueFalseTotal
if $Perlilog::classes{$class} 0 18 18
108  
109 18 ▶ puke("No parent class defined for \'$class\'\n")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $papa 0 18 18
110 unless (defined $papa);
111 18 $Perlilog::classes{$class} = [$file, $papa, $class];
112 # The following two lines are a Perl 5.8.0 bug workaround (early
113 # versions). Google "stash autoload" for why.
114 18 undef ${"${class}::Perlilog_dummy_variable"};
115 18 undef ${"${class}::Perlilog_dummy_variable"}; # No single use warning...
116 18 return 1;
117 }
118  
119 0 ▶sub inheritdir {
Subroutine inheritdir: not called CC=2 SCAR=17.9
Pod undocumented
120 0 my $dir = shift;
121 0 my $papa = shift;
122  
123 0 ($dir) = ($dir =~ /^(.*?)[\/\\]*$/); # Remove trailing slashes
124  
125 0 ▶ blow("Nonexistent directory \'$dir\'\n")
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 0 0
126 unless (-d $dir);
127  
128 0 do_inheritdir($dir, $papa);
129 0 return 1;
130 }
131  
132 0 ▶sub do_inheritdir {
Subroutine do_inheritdir: not called CC=11 SCAR=48.8
Pod undocumented
133 0 my $dir = shift;
134 0 my $papa = shift;
135  
136 0 ($dir) = ($dir =~ /^(.*?)[\/\\]*$/); # Remove trailing slashes
137  
138 0 ▶ return unless (opendir(DIR,$dir));
Branch: 1 branch
BranchTrueFalseTotal
unless opendir DIR, $dir 0 0 0
139 0 my @files=sort readdir(DIR);
140 0 closedir(DIR);
141 0 my @dirs = ();
142 0 my %newclasses = ();
143  
144 0 foreach my $file (@files) {
145 0 ▶ next if (($file eq '.') || ($file eq '..'));
Branch: 1 branch
BranchTrueFalseTotal
if $file eq "." or $file eq ".." 0 0 0
Condition0%0/3
$file eq "." or $file eq ".."
l!l&&r!l&&!r
000
MC/DC0%0/2
$file eq "." or $file eq ".."
$file eq "." $file eq ".."
Truth table0%0/3
A or B
A= $file eq "."B= $file eq ".."
ABresult
1X1
011
000
146 0 my $thefile = $dir.'/'.$file;
147  
148 0 ▶ if (-d $thefile) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $thefile) { } 0 0 0
149 0 ▶ next unless ($file =~ /^[a-zA-Z][a-zA-Z0-9_]*$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ /^[a-zA-Z][a-zA-Z0-9_]*$/ 0 0 0
150 0 push @dirs, $file, $thefile;
151 } else {
152 0 my ($class) = ($file =~ /^([a-zA-Z][a-zA-Z0-9_]*)\.pl$/i);
153 0 ▶ next unless (defined $class);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $class 0 0 0
154 0 $class = lc $class; # Lowercase the class
155 blow("inheritdir: Attempt to create the already existing class \'".$class.
156 "\' with \'$thefile\' (possibly symbolic link loop?)\n")
157 0 ▶ if ($Eobj::classes{$class});
Branch: 1 branch
BranchTrueFalseTotal
if $Eobj::classes{$class} 0 0 0
158 0 inherit($class, $thefile, $papa);
159 0 $newclasses{$class} = 1;
160 }
161 }
162 0 ▶ while ($#dirs > 0) { # At least two entries...
Branch: 1 branch
BranchTrueFalseTotal
if ($#dirs > 0) 0 0 0
163 0 my $newpapa = lc shift @dirs;
164 0 my $descend = shift @dirs;
165
166 blow("inheritdir: Could not descend to directory \'$descend\' because there was no \'".
167 $newpapa.".pl\' file in directory \'$dir\'\n")
168 0 ▶ unless ($newclasses{$newpapa});
Branch: 1 branch
BranchTrueFalseTotal
unless $newclasses{$newpapa} 0 0 0
169 0 do_inheritdir($descend, $newpapa);
170 }
171 }
172  
173 0 ▶sub override {
Subroutine override: not called CC=5 SCAR=34.0
Pod undocumented
174 0 my $class = shift;
175 0 my $file = shift;
176 0 my $papa = shift;
177  
178 0 ▶ unless ($Perlilog::classes{$class}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Perlilog::classes{$class}) 0 0 0
179 0 ▶ return inherit($class, $file, $papa)
Branch: 1 branch
BranchTrueFalseTotal
if defined $papa 0 0 0
180 if defined ($papa);
181 0 puke("Tried to override nonexisting class \'$class\', and no alternative parent given\n");
182 }
183  
184 puke("Attempt to override class \'$class\' after it has been loaded\n")
185 0 ▶ unless ref($Perlilog::classes{$class});
Branch: 1 branch
BranchTrueFalseTotal
unless ref $Perlilog::classes{$class} 0 0 0
186  
187 # Now create a new name for the previous class pointer
188  
189 0 my $newname=$class.'_PL_';
190 0 my $i=1;
191 0 ▶ while (defined $Perlilog::classes{$newname.$i}) {$i++;}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Perlilog::classes{$newname . $i}) 0 0 0
192 0 $newname=$newname.$i;
193
194 # This is the operation of overriding
195  
196 0 $Perlilog::classes{$newname}=$Perlilog::classes{$class};
197 0 $Perlilog::classes{$class}=[$file, $newname, $class];
198  
199 # The following two lines are a Perl 5.8.0 bug workaround (early
200 # versions). Google "stash autoload" for why.
201 0 undef ${"${newname}::Perlilog_dummy_variable"};
202 0 undef ${"${newname}::Perlilog_dummy_variable"}; # No single use warning
203  
204 0 return 1;
205 }
206  
207 0 ▶sub underride {
Subroutine underride: not called CC=5 SCAR=34.0
Pod undocumented
208 0 my $class = shift;
209 0 my $file = shift;
210  
211 0 ▶ unless ($Perlilog::classes{$class}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Perlilog::classes{$class}) 0 0 0
212 0 puke("Tried to underride a nonexisting class \'$class\'\n");
213 }
214  
215 puke("Attempt to underride class \'$class\' after it has been loaded\n")
216 0 ▶ unless ref($Perlilog::classes{$class});
Branch: 1 branch
BranchTrueFalseTotal
unless ref $Perlilog::classes{$class} 0 0 0
217  
218 # Now create a new name for the previous class pointer
219  
220 0 my $newname=$class.'_PL_';
221 0 my $i=1;
222 0 ▶ while (defined $Perlilog::classes{$newname.$i}) {$i++;}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Perlilog::classes{$newname . $i}) 0 0 0
223 0 $newname=$newname.$i;
224
225 0 my $victim = $class;
226  
227 # Now we look for the grandfather
228 0 SEARCH: while (1) {
229 0 my $parent = ${$Perlilog::classes{$victim}}[1];
230 0 ▶ if (${$Perlilog::classes{$parent}}[2] ne $class) { # Same family?
Branch: 1 branch
BranchTrueFalseTotal
if (do { $Perlilog::classes{$parent} }->[2] ne $class) { } 0 0 0
231 0 last SEARCH;
232 } else {
233 0 $victim = $parent; # Climb up the family tree
234 }
235 }
236 # This is the operation of parenting
237  
238 0 $Perlilog::classes{$newname}=[$file, ${$Perlilog::classes{$victim}}[1], $class];
239 0 ${$Perlilog::classes{$victim}}[1]=$newname;
240  
241 # The following two lines are a Perl 5.8.0 bug workaround (early
242 # versions). Google "stash autoload" for why.
243 0 undef ${"${newname}::Perlilog_dummy_variable"};
244 0 undef ${"${newname}::Perlilog_dummy_variable"}; # No single use warning.
245 0 return 1;
246 }
247  
248 #definedclass:
249 #0 - not defined, 1 - defined but not loaded, 2 - defined and loaded
250  
251 4 ▶sub definedclass {
Subroutine definedclass: called CC=3 SCAR=12.0
Pod undocumented
252 4 my $class = shift;
253 4 my $p = $Perlilog::classes{$class};
254 4 ▶ return 0 unless (defined $p);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p 0 4 4
255 4 ▶ return 1 if ref($p);
Branch: 1 branch
BranchTrueFalseTotal
if ref $p 4 0 4
256 0 return 2;
257 }
258  
259 4 ▶sub interfaceclass {
Subroutine interfaceclass: called CC=2 SCAR=7.1
Pod undocumented
260 4 my $class = shift;
261 4 ▶ puke("The class \'$class\' is not defined, and hence cannot be declared as an interface class\n")
Branch: 1 branch
BranchTrueFalseTotal
unless definedclass($class) 0 4 4
262 unless (definedclass($class));
263 4 push @Perlilog::interface_classes, $class;
264 }
265  
266 8 ▶sub classload {
Subroutine classload: called CC=5 SCAR=16.1
Pod undocumented
267 8 my ($class, $schwonz) = @_;
268 8 my $p = $Perlilog::classes{$class};
269 8 my $err;
270  
271 8 ▶ blow($schwonz."Attempt to use undeclared class \'$class\'\n")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p 0 8 8
272 unless (defined $p);
273  
274 # If $p isn't a reference, the class has been loaded.
275 # This trick allows recursive calls.
276 8 ▶ return 1 unless ref($p);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p 3 5 8
277  
278 5 $Perlilog::classes{$class} = 1;
279  
280 5 my ($file, $papa, $original) = @{$p};
281  
282 5 classload($papa, $schwonz); # Make sure parents are loaded
283  
284 # Now we create the package wrapping
285  
286 5 my $d = "package $class; use strict 'vars'; use Perlilog::PLerror;\n";
287 5 $d.='@'.$class."::ISA=qw[$papa];\n";
288  
289 # Registering MUST be the last line before the text itself,
290 # since the line number is recorded. Line count in error
291 # messages begin immediately after the line that registers.
292  
293 5 $d.="&Perlilog::PLerror::register(\'$file\');\n# line 1 \"$file\"\n";
294  
295 5 ▶ open (CLASSFILE, $file) ||
Branch: 1 branch
BranchTrueFalseTotal
open CLASSFILE, $file or blow($schwonz . "Failed to open resource file '${file}' for class '${class}'\n") 5 0 5
296 blow($schwonz."Failed to open resource file \'$file\' for class \'$class\'\n");
297 5 $d.=join("",<CLASSFILE>);
298 5 close CLASSFILE;
299 1 ▶ eval($d);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
300 5 ▶ blow ($schwonz."Failed to load class \'$original\':\n $@")
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 5 5
301 if ($@);
302 }
303  
304 0 ▶sub globalobj {
Subroutine globalobj: not called CC=2 SCAR=17.9
Pod undocumented
305 0 ▶ return $Perlilog::globalobject if (ref $Perlilog::globalobject);
Branch: 1 branch
BranchTrueFalseTotal
if ref $Perlilog::globalobject 0 0 0
306 0 puke("Global object was requested before init() was executed\n");
307 }
308  
309 0 ▶sub constreset {
Subroutine constreset: not called CC=1 SCAR=6.9
Pod undocumented
310 0 return globalobj()->constreset(@_);
311 }
312  
313 0 ▶sub execute {
Subroutine execute: not called CC=1 SCAR=6.9
Pod undocumented
314 0 globalobj()->execute();
315 }
316  
317 0 ▶sub interface {
Subroutine interface: not called CC=9 SCAR=45.0
Pod undocumented
318 0 ▶ puke("Attempt to call 'interface' from within an interface object (use intobjects instead)\n")
Branch: 1 branch
BranchTrueFalseTotal
if defined $Perlilog::interface_rec 0 0 0
319 if (defined $Perlilog::interface_rec);
320  
321 0 my $g=globalobj();
322  
323 puke("interface() called with non-object item\n")
324 0 ▶ if (grep {not ($g->isobject($_))} @_);
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $g->isobject($_);} @_ 0 0 0
325  
326 0 $Perlilog::interface_rec = globalobj->get('MAX_INTERFACE_REC');
327 0 @Perlilog::interface_excuses=();
328  
329 0 my @obj=intobjects(@_);
330  
331 0 undef $Perlilog::interface_rec;
332  
333 0 ▶ if (@obj) {
Branch: 1 branch
BranchTrueFalseTotal
if (@obj) { } 0 0 0
334 0 foreach (@obj) {
335 0 $_->sustain();
336 }
337 0 return $obj[0];
338 } else {
339 0 my $p;
340 0 my @names=();
341  
342 0 foreach $p (@_) {
343 0 ▶ if ($g->isobject($p)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($g->isobject($p)) { } 0 0 0
344 0 push @names, $p->who();
345 } else {
346 0 push @names, "(Non-object item)";
347 }
348 }
349  
350 0 my $excuses = "";
351 0 chomp @Perlilog::interface_excuses;
352 0 foreach (@Perlilog::interface_excuses) {
353 0 $excuses.="$_\n";
354 }
355
356 0 ▶ $excuses = "No adequate interface object found\n"
Branch: 1 branch
BranchTrueFalseTotal
unless length $excuses 0 0 0
357 unless (length($excuses));
358  
359 0 wrong("Failed to interface between ports:\n".
360 join("\n", @names)."\n----------\n$excuses");
361 0 return undef;
362 }
363 }
364  
365 0 ▶sub intobjects {
Subroutine intobjects: not called CC=8 SCAR=42.8
Pod undocumented
366 0 ▶ puke("intobjects should be called only from within interface classes\n")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Perlilog::interface_rec 0 0 0
367 unless (defined $Perlilog::interface_rec);
368 0 ▶ if ($Perlilog::interface_rec<0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Perlilog::interface_rec < 0) 0 0 0
369 0 fishy("Maximal interface object recursion (MAX_INTERFACE_REC) was reached. ".
370 "Are the interface objects registered in the wrong order, or is the design ".
371 "very complex?\n");
372 0 return ();
373 }
374 0 my $c;
375 my @obj;
376 0 $Perlilog::interface_rec--;
377
378 0 foreach $c (@Perlilog::interface_classes) {
379 0 @obj = $c->attempt(@_);
380 0 ▶ if (@obj) {
Branch: 1 branch
BranchTrueFalseTotal
if (@obj) 0 0 0
381 0 ▶ if (globalobj()->isobject($obj[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (globalobj()->isobject($obj[0])) 0 0 0
382 0 $obj[0]->set('perlilog-ports-to-connect', @_);
383 0 last;
384 }
385 0 ▶ push @Perlilog::interface_excuses, "class $c: ".$obj[0]
Branch: 1 branch
BranchTrueFalseTotal
if defined $obj[0] and $obj[0] =~ /[a-z]/i 0 0 0
Condition0%0/3
defined $obj[0] and $obj[0] =~ /[a-z]/i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $obj[0] and $obj[0] =~ /[a-z]/i
defined $obj[0] $obj[0] =~ /[a-z]/i
Truth table0%0/3
A and B
A= defined $obj[0]B= $obj[0] =~ /[a-z]/i
ABresult
0X0
100
111
386 if (defined ($obj[0]) && $obj[0]=~/[a-z]/i);
387 0 @obj=();
388 }
389 }
390 0 $Perlilog::interface_rec++;
391 0 return @obj;
392 }
393  
394 # This routine attempts to keep lines below 80 chrs/lines
395 0 ▶sub linebreak {
Subroutine linebreak: not called CC=8 SCAR=42.8
Pod undocumented
396 0 my $data = shift;
397 0 my $extraindent = shift;
398  
399 0 ▶ $extraindent = '' unless (defined $extraindent);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $extraindent 0 0 0
400  
401 0 my @chunks = split("\n", $data);
402  
403 0 foreach (@chunks) {
404 0 my $realout = '';
405 0 while (1) { # Not forever. We'll break this in proper time
406 0 ▶ if (/^.{0,79}$/) { # The rest fits well...
Branch: 1 branch
BranchTrueFalseTotal
if (/^.{0,79}$/) 0 0 0
407 0 $realout .= $_;
408 0 last;
409 }
410 # We try to break the line after a comma.
411 0 my ($x, $y) = (/^(.{50,78},)\s*(.*)$/);
412 # Didn't work? A whitespace is enough, then.
413 0 ▶ ($x, $y) = (/^(.{50,79})\s+(.*)$/)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 0 0 0
414 unless (defined $x);
415 # Still didn't work? Break at first white space.
416 0 ▶ ($x, $y) = (/^(.{50,}?)\s+(.*)$/)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 0 0 0
417 unless (defined $x);
418
419 # THAT didn't work? Give up. Just dump it all out.
420 0 ▶ unless (defined $x) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $x) { } 0 0 0
421 0 $realout .= $_;
422 0 last;
423 } else { # OK, we have a line split!
424 0 $realout .= $x."\n";
425 0 $_ = $extraindent.$y; # The rest, only indented.
426 }
427 }
428 0 $_ = $realout;
429 }
430 0 my $final = join("\n", @chunks);
431 0 ▶ $final .= "\n" if ($data =~ /\n$/);
Branch: 1 branch
BranchTrueFalseTotal
if $data =~ /\n$/ 0 0 0
432 0 return $final;
433 }
434  
435 # Just empty packages (used by PLroot).
436 package PL_hardroot;
437 package PL_settable;
438 package PL_const;
439  
440 # And now the magic of autoloading.
441 package UNIVERSAL;
442 1 ▶use Perlilog::PLerror;
Subroutine BEGIN: called CC=1 SCAR=0.0
443 1 $UNIVERSAL::errorcrawl='skip';
444 1 %UNIVERSAL::blacklist=();
445  
446 75029 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=7 SCAR=19.8
447 75029 my $class = shift;
448 75029 my $method = $UNIVERSAL::AUTOLOAD;
449 75029 my ($junk,$file,$line)=caller;
450 75029 my $schwonz = "at $file line $line";
451 75029 ▶ return undef if $method =~ /::SUPER::/;
Branch: 1 branch
BranchTrueFalseTotal
if $method =~ /::SUPER::/ 3 75026 75029
452  
453 75026 my ($package) = $method =~ /^(.*?)::/;
454 75026 $method =~ s/.*:://;
455  
456 75026 my $name = ref($class);
457  
458 75026 ▶ return undef if ($method eq 'DESTROY');
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 75023 3 75026
459
460 3 ▶ print "$class, $package\n" unless ($class eq $package);
Branch: 1 branch
BranchTrueFalseTotal
unless $class eq $package 0 3 3
461 3 ▶ puke("Undefined function/method \'$method\' $schwonz\n")
Branch: 1 branch
BranchTrueFalseTotal
unless $class eq $package 0 3 3
462 unless ($class eq $package);
463  
464 3 ▶ if ($name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name) 0 3 3
465 # Forgive. This is not our class anyway...
466 0 return undef;
467 }
468  
469 # Now we protect ourselves against infinite recursion, should
470 # the classload call fail silently. This will happen if the
471 # first attempt to call a method in a class is to a
472 # method that isn't defined.
473 puke("Undefined method \'$method\' in class \'$class\' $schwonz\n")
474 3 ▶ if $UNIVERSAL::blacklist{$class};
Branch: 1 branch
BranchTrueFalseTotal
if $UNIVERSAL::blacklist{$class} 0 3 3
475 3 $UNIVERSAL::blacklist{$class}=1;
476  
477 3 &Perlilog::classload($class,
478 "While trying to load class \'$class\' due to call ".
479 "of method \'$method\' $schwonz:\n");
480
481 #Just loaded the new class? Let's use it!
482 3 return $class->$method(@_);
483 }
484  
485 # Now have the "defineclass" subroutine defined, so we can use it to
486 # generate bareword warnings for anything but a class name.
487  
488  
489  
490 1 1; # Return true
491  
492 __END__
« blib/lib/Perlilog/siteclasses/wbsimple.pl ↑ Summary blib/lib/Perlilog/sysclasses/PLcodegen.pl »