165
|
1 package IMPL::Code::Loader;
|
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
|
5 my %packages;
|
|
6
|
|
7 sub Provide {
|
194
|
8 my ($self,$package) = @_;
|
|
9
|
|
10 my ($declaringPackage,$file) = caller();
|
|
11 $packages{$package} = { declaringPackage => $declaringPackage, file => $file, evidence => 'provide' };
|
165
|
12 }
|
|
13
|
|
14 sub Require {
|
194
|
15 my ($self,$package) = @_;
|
|
16
|
|
17 return 1 if $packages{$package};
|
|
18
|
|
19 if (my $file = $INC{$package}) {
|
|
20 $packages{$package} = { file => $file, evidence => 'inc' };
|
|
21 return 1;
|
|
22 }
|
|
23
|
|
24 undef $@;
|
|
25
|
|
26 if ( eval "require $package; 1;" and not $packages{$package}) {
|
|
27 $packages{$package} = { file => $INC{$package}, evidence => 'inc' };
|
|
28 };
|
|
29
|
|
30 die $@ if $@ and not $!;
|
165
|
31 }
|
|
32
|
|
33 1;
|
|
34
|