Created
March 7, 2017 22:10
-
-
Save niner/349fd7432e5c2c68361b3caf5111532c 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/Actions.nqp b/src/Perl6/Actions.nqp | |
index 6b964fdc4..a55270ab5 100644 | |
--- a/src/Perl6/Actions.nqp | |
+++ b/src/Perl6/Actions.nqp | |
@@ -1930,11 +1930,14 @@ class Perl6::Actions is HLL::Actions does STDActions { | |
$compunit_past, | |
),'require'); | |
- my $lexical_stub := $*W.symbol_lookup(['Any'], $/); | |
+ my $existing_path := $*W.symbol_lookup(['Any'], $/); | |
+ #my $lexical_stub := $*W.symbol_lookup(['Any'], $/); | |
+ my $lexical_stub; | |
if $target_package && !$longname.contains_indirect_lookup() { | |
my $current; | |
my @components := nqp::clone($longname.components); | |
my $top := @components.shift; | |
+ $existing_path := QAST::Op.new(:op<call>, :name('&infix:<,>')); | |
my $existing := try $*W.find_symbol([$top]); | |
if $existing =:= NQPMu { | |
@@ -1947,18 +1950,21 @@ class Perl6::Actions is HLL::Actions does STDActions { | |
); | |
$lexpad[0].unshift($stubvar); | |
$lexpad.symbol($top, :scope('lexical'), :value($stub)); | |
- $lexical_stub := QAST::SVal.new(:value($top)); | |
$current := nqp::who($stub); | |
+ $lexical_stub := QAST::SVal.new(:value($top)); | |
} | |
else { | |
$current := nqp::who($existing); | |
+ $existing_path.push: QAST::SVal.new(:value($top)); | |
} | |
for @components -> $component { | |
if nqp::existskey($current,$component) { | |
$current := nqp::who($current{$component}); | |
+ $existing_path.push: QAST::SVal.new(:value($component)); | |
} | |
else { | |
+ $lexical_stub := QAST::SVal.new(:value($component)) unless $lexical_stub; | |
my $stub := $*W.pkg_create_mo($/, %*HOW<package>, :name($component)); | |
$*W.pkg_compose($/, $stub); | |
$current{$component} := $stub; | |
@@ -1967,7 +1973,8 @@ class Perl6::Actions is HLL::Actions does STDActions { | |
} | |
} | |
- $require_past.push($lexical_stub); | |
+ $require_past.push($existing_path); | |
+ $require_past.push($lexical_stub // $*W.symbol_lookup(['Any'], $/)); | |
if $<EXPR> { | |
my $p6_argiter := $*W.compile_time_evaluate($/, $<EXPR>.ast).eager.iterator; | |
diff --git a/src/core/operators.pm b/src/core/operators.pm | |
index f5da866d2..2b29b770e 100644 | |
--- a/src/core/operators.pm | |
+++ b/src/core/operators.pm | |
@@ -604,7 +604,7 @@ sub INDIRECT_NAME_LOOKUP($root, *@chunks) is raw { | |
) | |
} | |
-sub REQUIRE_IMPORT($compunit, $module, *@syms --> Nil) { | |
+sub REQUIRE_IMPORT($compunit, $existing, $stub, *@syms --> Nil) { | |
my $handle := $compunit.handle; | |
my $DEFAULT := $handle.export-package()<DEFAULT>.WHO; | |
my $GLOBALish := $handle.globalish-package; | |
@@ -613,7 +613,29 @@ sub REQUIRE_IMPORT($compunit, $module, *@syms --> Nil) { | |
my $block := CALLER::.EXISTS-KEY('%REQUIRE_SYMBOLS') | |
?? CALLER::MY:: | |
!! CALLER::OUTER::; | |
- $block{$module} := $GLOBALish{$module} if $module; | |
+ | |
+ #$block{$module} := $GLOBALish{$module} if $module; | |
+ note "REQUIRE_IMPORT $existing $stub"; | |
+ if $stub { | |
+ if ($existing) { # nested scope | |
+ my $target := $block.AT-KEY('LEXICAL').WHO; | |
+ my $source := $GLOBALish; | |
+ for $existing.list { | |
+ note "traversing $_"; | |
+ $target := $target.AT-KEY($_).WHO; | |
+ $source := $source.AT-KEY($_).WHO; | |
+ } | |
+ note $target.gist; | |
+ note $stub; | |
+ | |
+note "binding $stub ({$source{$stub}.^name}, {$source{$stub}.HOW.^name})"; | |
+ $target{$stub} := $source{$stub}; | |
+ } | |
+ else { | |
+ $block{$stub} := $GLOBALish{$stub}; | |
+ } | |
+ } | |
+ | |
for @syms { | |
unless $DEFAULT.EXISTS-KEY($_) { | |
@missing.push: $_; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment