| 1 |
package # hide from CPAN indexer |
| 2 |
PreLoad; |
| 3 |
|
| 4 |
use vars qw($VERSION); |
| 5 |
$VERSION = '4.005'; # $Id: //depot/Tkutf8/compile/PreLoad.pm#4 $ |
| 6 |
|
| 7 |
require AutoLoader; |
| 8 |
|
| 9 |
my @todo = (); |
| 10 |
|
| 11 |
*AutoLoader::import = \&queue_load; |
| 12 |
|
| 13 |
INIT |
| 14 |
{ |
| 15 |
while (@todo) |
| 16 |
{ |
| 17 |
my ($pack,$path) = splice(@todo,0,2); |
| 18 |
do_load($pack,$path); |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
END |
| 23 |
{ |
| 24 |
while (@todo) |
| 25 |
{ |
| 26 |
my ($pack,$path) = splice(@todo,0,2); |
| 27 |
do_load($pack,$path); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
sub do_load |
| 34 |
{ |
| 35 |
my ($callpkg,$path) = @_; |
| 36 |
local $_; |
| 37 |
# Try absolute path name. |
| 38 |
local *IX; |
| 39 |
if (open(IX,$path)) |
| 40 |
{ |
| 41 |
while (<IX>) |
| 42 |
{ |
| 43 |
if (/^sub\s+(\S+)\s*;/) |
| 44 |
{ |
| 45 |
my $sub = $1; |
| 46 |
warn "Preload $callpkg\::$sub\n"; |
| 47 |
unless (defined &{$callpkg.'::'.$sub}) |
| 48 |
{ |
| 49 |
(my $al = $path) =~ s#autosplit.ix$#$sub.al#; |
| 50 |
require $al; |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
sub queue_load |
| 58 |
{ |
| 59 |
my $callpkg = caller; |
| 60 |
(my $calldir = $callpkg) =~ s#::#/#g; |
| 61 |
my $path = $INC{$calldir . '.pm'}; |
| 62 |
if (defined($path)) |
| 63 |
{ |
| 64 |
$path =~ s#^(.*)$calldir\.pm$#$1auto/$calldir/autosplit.ix#; |
| 65 |
push(@todo, $callpkg,$path); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
1; |
| 70 |
__END__ |