Skip to content

Commit

Permalink
Merge pull request #3388 from vrurg/problem-solving-142
Browse files Browse the repository at this point in the history
Export packages by user given names
  • Loading branch information
vrurg committed Jan 2, 2020
2 parents 2a4eb56 + 693411a commit 9e64167
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/Perl6/Grammar.nqp
Expand Up @@ -1917,6 +1917,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
rule package_def {
:my $longname;
:my $outer := $*W.cur_lexpad();
:my $*DECLARATION_NAME;
:my $*IMPLICIT := 0;
:my $*DECLARAND;
:my $*CODE_OBJECT := $*W.stub_code_object($*PKGDECL eq 'role' ?? 'Sub' !! 'Block');
Expand Down Expand Up @@ -1944,7 +1945,8 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<!!{ $/.clone_braid_from(self) }>
[
[ <longname> { $longname := $*W.dissect_longname($<longname>); } ]?
[ <longname> { $longname := $*W.dissect_longname($<longname>);
$*DECLARATION_NAME := nqp::hllizefor($longname.name(), 'perl6'); } ]?
<.newpad>
[ :dba('generic role')
Expand Down Expand Up @@ -2880,6 +2882,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token type_declarator:sym<enum> {
<sym><.kok>
:my $*IN_DECL := 'enum';
:my $*DECLARATION_NAME;
:my $*DOC := $*DECLARATOR_DOCS;
{ $*DECLARATOR_DOCS := '' }
:my $*POD_BLOCK;
Expand All @@ -2902,6 +2905,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
symbol => $longname.name(),
);
}
$*DECLARATION_NAME := nqp::hllizefor($longname.name(), 'perl6');
}
| <variable>
| <?>
Expand All @@ -2916,6 +2920,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
rule type_declarator:sym<subset> {
<sym><.kok> :my $*IN_DECL := 'subset';
:my $*DECLARATION_NAME;
:my $*DOC := $*DECLARATOR_DOCS;
{ $*DECLARATOR_DOCS := '' }
:my $*POD_BLOCK;
Expand All @@ -2940,6 +2945,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
symbol => $longname.name(),
);
}
$*DECLARATION_NAME := nqp::hllizefor($longname.name(), 'perl6');
}
]?
{ $*IN_DECL := '' }
Expand Down
12 changes: 11 additions & 1 deletion src/Perl6/World.nqp
Expand Up @@ -1536,7 +1536,17 @@ class Perl6::World is HLL::World {
if $need-decont && nqp::islt_i(nqp::index('$&', nqp::substr($key,0,1)),0) {
$value := nqp::decont($value);
}
if $target.symbol($key) -> %sym {
my $is-packagy := 0;
if $!unit_ready && !nqp::isconcrete($value) {
my $valueHOW := $value.HOW;
$is-packagy := nqp::istype($valueHOW, self.find_symbol(['Metamodel', 'Naming'], :setting-only))
&& nqp::istype($valueHOW, self.find_symbol(['Metamodel', 'Stashing'], :setting-only));
}
if $is-packagy {
# $pkgdecl parameter will never be used by install_package. 'packagy' is just a stub here.
self.install_package($/, nqp::split('::', $key), 'my', 'packagy', $*PACKAGE, $target, $value);
}
elsif $target.symbol($key) -> %sym {
# There's already a symbol. However, we may be able to merge
# if both are multis and have onlystar dispatchers.
my $installed := %sym<value>;
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/operators.pm6
Expand Up @@ -603,7 +603,7 @@ sub INDIRECT_NAME_LOOKUP($root, *@chunks) is raw {
)
}

sub REQUIRE_IMPORT($compunit, $existing-path,$top-existing-pkg,$stubname, *@syms --> Nil) {
sub REQUIRE_IMPORT($compunit, $existing-path, $top-existing-pkg, $stubname, *@syms --> Nil) {
my $handle := $compunit.handle;
my $DEFAULT := $handle.export-package()<DEFAULT>.WHO;
my $GLOBALish := $handle.globalish-package;
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/traits.pm6
Expand Up @@ -288,7 +288,7 @@ multi sub trait_mod:<is>(Routine:D \r, :$export!, :$SYMBOL = '&' ~ r.name) {
Rakudo::Internals.EXPORT_SYMBOL(nqp::decont($SYMBOL), @tags, $to_export);
}
multi sub trait_mod:<is>(Mu:U \type, :$export!) {
my $exp_name := type.^shortname;
my $exp_name := $*DECLARATION_NAME // type.^shortname;
my @tags = flat 'ALL', (
nqp::istype($export,Pair)
?? $export.key()
Expand Down

0 comments on commit 9e64167

Please sign in to comment.