Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
hook I::P5's ModuleLoader to CUR, not P6::ML
  • Loading branch information
FROGGS committed Sep 1, 2015
1 parent 269107e commit ba2ade8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/Perl6/World.nqp
Expand Up @@ -3748,21 +3748,4 @@ class Perl6::World is HLL::World {
}
}

my class Perl5ModuleLoaderStub {
method load_module($module_name, %opts, *@GLOBALish, :$line, :$file) {
{
self.find_symbol(['CompUnitRepo']).load_module('Inline::Perl5', {}, @GLOBALish, :$line, :$file);
CATCH {
$*W.find_symbol(nqp::list('X','NYI','Available')).new(
:available('Inline::Perl5'), :feature('Perl 5')).throw;
}
}

# Inline::Perl5 has overwritten this module loader at this point
return Perl6::ModuleLoader.load_module($module_name, %opts, @GLOBALish, :$line, :$file);
}
}

nqp::gethllsym('perl6', 'ModuleLoader').register_language_module_loader('Perl5', Perl5ModuleLoaderStub);

# vim: ft=perl6 expandtab sw=4
16 changes: 16 additions & 0 deletions src/core/CompUnitRepo.pm
Expand Up @@ -2,6 +2,21 @@ role CompUnitRepo::Locally { ... }
class CompUnitRepo::Local::File { ... }
class CompUnitRepo::Local::Installation { ... }

my class Perl5ModuleLoaderStub {
method load_module($module_name, %opts, *@GLOBALish, :$line, :$file) {
{
CompUnitRepo.load_module('Inline::Perl5', {}, @GLOBALish, :$line, :$file);
CATCH {
$*W.find_symbol(nqp::list('X','NYI','Available')).new(
:available('Inline::Perl5'), :feature('Perl 5')).throw;
}
}

# Inline::Perl5 has overwritten this module loader at this point
return CompUnitRepo.load_module($module_name, %opts, @GLOBALish, :$line, :$file);
}
}

class CompUnitRepo {
my $lock = Lock.new;
my %modules_loaded;
Expand All @@ -10,6 +25,7 @@ class CompUnitRepo {
# We're using Perl6::ModuleLoader instead of NQP's here,
# so it can special-cases NQP wrt GLOBALish correctly.
'NQP' => nqp::gethllsym('perl6', 'ModuleLoader'),
'Perl5' => Perl5ModuleLoaderStub,
;

method register_language_module_loader($lang, $loader, :$force) {
Expand Down

0 comments on commit ba2ade8

Please sign in to comment.