Created
December 18, 2015 22:01
-
-
Save niner/caa8f988d9c52b169400 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Perl6/World.nqp b/src/Perl6/World.nqp | |
index 8b0e0e6..4b56123 100644 | |
--- a/src/Perl6/World.nqp | |
+++ b/src/Perl6/World.nqp | |
@@ -948,32 +948,31 @@ class Perl6::World is HLL::World { | |
# Immediate loading. | |
my $line := self.current_line($/); | |
- my $comp_unit := self.find_symbol(['CompUnit', 'RepositoryRegistry']).load_module($module_name, %opts, | |
- $cur_GLOBALish, :$line); | |
+ my $true := self.find_symbol(['True']); | |
+ my $spec := self.find_symbol(['CompUnit', 'DependencySpecification']).new( | |
+ :short-name($module_name), | |
+ :from(%opts<from> // 'Perl6'), | |
+ :auth-matcher(%opts<auth> // $true), | |
+ :version-matcher(%opts<ver> // $true), | |
+ ); | |
+ self.add_object($spec); | |
+ my $registry := self.find_symbol(['CompUnit', 'RepositoryRegistry']); | |
+ self.add_object($registry); | |
+ my $comp_unit := $registry.head.need($spec); | |
+ $cur_GLOBALish.WHO.merge-symbols($comp_unit.handle.globalish-package.WHO); | |
# During deserialization, ensure that we get this module loaded. | |
if self.is_precompilation_mode() { | |
$DEBUG(" Pre-compiling '$module_name'") if $DEBUG; | |
my $opt_hash := QAST::Op.new( :op('hash') ); | |
- for %opts { | |
- self.add_object($_.value); | |
- $opt_hash.push(QAST::SVal.new( :value($_.key) )); | |
- my $Str := self.find_symbol(['Str']); | |
- if nqp::isstr($_.value) || nqp::istype($_.value, $Str) { | |
- $opt_hash.push(QAST::SVal.new( :value($_.value) )); | |
- } | |
- else { | |
- $opt_hash.push(QAST::WVal.new( :value($_.value) )); | |
- } | |
- } | |
self.add_load_dependency_task(:deserialize_ast(QAST::Stmts.new( | |
QAST::Op.new( | |
- :op('callmethod'), :name('load_module'), | |
- QAST::WVal.new( :value(self.find_symbol(['CompUnit', 'RepositoryRegistry'])) ), | |
- QAST::SVal.new( :value($module_name) ), | |
- $opt_hash, | |
- QAST::WVal.new( :value(self.find_symbol(['Any'])) ), | |
- QAST::IVal.new(:value($line), :named('line')) | |
+ :op('callmethod'), :name('need'), | |
+ QAST::Op.new( | |
+ :op('callmethod'), :name('head'), | |
+ QAST::WVal.new( :value($registry) ), | |
+ ), | |
+ QAST::WVal.new( :value($spec) ), | |
)))); | |
} | |
diff --git a/src/core/CompUnit/RepositoryRegistry.pm b/src/core/CompUnit/RepositoryRegistry.pm | |
index c576586..9dc1875 100644 | |
--- a/src/core/CompUnit/RepositoryRegistry.pm | |
+++ b/src/core/CompUnit/RepositoryRegistry.pm | |
@@ -166,6 +166,10 @@ class CompUnit::RepositoryRegistry { | |
%custom-lib{$name} | |
} | |
+ method head() { # mostly usefull for access from NQP | |
+ $*REPO | |
+ } | |
+ | |
method load_module($module_name, %opts, \GLOBALish is raw, :$line, :$file) { | |
RAKUDO_MODULE_DEBUG("going to load $module_name: %opts.perl()") if $*RAKUDO_MODULE_DEBUG; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment