Permalink
Browse files

Implement $?MODULE and ::?MODULE.

Which were in the docs and mysteriously forgotten, while $?CLASS and
$?ROLE have been around for ages.
  • Loading branch information...
1 parent 8dff9df commit 7427d3fe7b4b25493390507720b35cde76f75156 @jnthn jnthn committed Jul 21, 2016
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/Perl6/Grammar.nqp
@@ -2284,7 +2284,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
}
}
- # Install $?PACKAGE, $?ROLE, $?CLASS, and :: variants as needed.
+ # Install $?PACKAGE, $?MODULE, $?ROLE, $?CLASS, and :: variants as needed.
my $curpad := $*W.cur_lexpad();
unless $curpad.symbol('$?PACKAGE') {
$*W.install_lexical_symbol($curpad, '$?PACKAGE', $*PACKAGE);
@@ -2297,7 +2297,11 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
$*W.install_lexical_symbol($curpad, '::?CLASS',
$*W.pkg_create_mo($/, $*W.resolve_mo($/, 'generic'), :name('::?CLASS')));
}
- elsif $*PKGDECL ne 'package' && $*PKGDECL ne 'module' {
+ elsif $*PKGDECL eq 'module' {
+ $*W.install_lexical_symbol($curpad, '$?MODULE', $*PACKAGE);
+ $*W.install_lexical_symbol($curpad, '::?MODULE', $*PACKAGE);
+ }
+ elsif $*PKGDECL ne 'package'{
$*W.install_lexical_symbol($curpad, '$?CLASS', $*PACKAGE);
$*W.install_lexical_symbol($curpad, '::?CLASS', $*PACKAGE);
}

0 comments on commit 7427d3f

Please sign in to comment.