Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
s/$*PKGMETA/$*PACKAGE/ - it's the compile time $?PACKAGE, after all. …
…Install $?PACKAGE. Set up a GLOBALish, though nothing is done with it just yet.
  • Loading branch information
jnthn committed Apr 17, 2011
1 parent 06f82a8 commit 9869549
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
21 changes: 17 additions & 4 deletions src/NQP/Actions.pm
Expand Up @@ -186,6 +186,16 @@ class NQP::Actions is HLL::Actions {
}
self.SET_BLOCK_OUTER_CTX(@BLOCK[0]);
}

method GLOBALish($/) {
# Create GLOBALish.
# XXX Uses KnowHOW for now, just for the .WHO.
# Want something lighter really.
our @BLOCK;
$*PACKAGE := $*SC.pkg_create_mo(KnowHOW, :name('GLOBALish'));
$*PACKAGE.HOW.compose($*PACKAGE);
$*SC.install_lexical_symbol(@BLOCK[0], 'GLOBALish', $*PACKAGE);
}

method you_are_here($/) {
make self.CTXSAVE();
Expand Down Expand Up @@ -431,13 +441,13 @@ class NQP::Actions is HLL::Actions {
# Install it in the package or lexpad as needed.
if $*SCOPE eq 'our' || $*SCOPE eq '' {
$past.namespace( $<name><identifier> );
$*SC.install_package_symbol($<name><identifier>, $*PKGMETA);
$*SC.install_package_symbol($<name><identifier>, $*PACKAGE);
}
elsif $*SCOPE eq 'my' {
if +$<name><identifier> != 1 {
$<name>.CURSOR.panic("A my scoped package cannot have a multi-part name yet");
}
$*SC.install_lexical_symbol(@BLOCK[0], $<name><identifier>[0], $*PKGMETA);
$*SC.install_lexical_symbol(@BLOCK[0], $<name><identifier>[0], $*PACKAGE);
}
else {
$/.CURSOR.panic("$*SCOPE scoped packages are not supported");
Expand All @@ -447,7 +457,7 @@ class NQP::Actions is HLL::Actions {
$*PACKAGE-SETUP.unshift(PAST::Stmts.new(
PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name('type_obj'), :scope('register'), :isdecl(1) ),
$*SC.get_slot_past_for_object($*PKGMETA)
$*SC.get_slot_past_for_object($*PACKAGE)
)
));

Expand All @@ -470,10 +480,13 @@ class NQP::Actions is HLL::Actions {
PAST::Var.new( :name('type_obj'), :scope('register') ),
PAST::Val.new( :value($past) )
));
$*SC.install_lexical_symbol($past, '$?PACKAGE', $*PACKAGE);
$*SC.install_lexical_symbol($past, '$?ROLE', $*PACKAGE);
}
else {
$past.blocktype('immediate');
$*SC.install_lexical_symbol($past, '$?CLASS', $*PKGMETA);
$*SC.install_lexical_symbol($past, '$?PACKAGE', $*PACKAGE);
$*SC.install_lexical_symbol($past, '$?CLASS', $*PACKAGE);
}

# Add call to add_parent if we have one.
Expand Down
9 changes: 7 additions & 2 deletions src/NQP/Grammar.pm
Expand Up @@ -111,6 +111,10 @@ grammar NQP::Grammar is HLL::Grammar {
:my $*MAIN_SUB;
<.newpad>
<.outerctx>

:my $*PACKAGE;
<.GLOBALish>

<statementlist>
[ $ || <.panic: 'Confused'> ]
}
Expand Down Expand Up @@ -174,6 +178,7 @@ grammar NQP::Grammar is HLL::Grammar {

token newpad { <?> }
token outerctx { <?> }
token GLOBALish { <?> }
token finishpad { <?> }
token you_are_here { <?> }

Expand Down Expand Up @@ -329,7 +334,7 @@ grammar NQP::Grammar is HLL::Grammar {
}

rule package_def {
:my $*PKGMETA; # The meta-object for this package.
:my $*PACKAGE; # The type object for this package.
:my %*ATTR-CHECK; # Attribute names we must confirm exist.

<name>
Expand All @@ -343,7 +348,7 @@ grammar NQP::Grammar is HLL::Grammar {
if $<repr> {
%args<repr> := ~$<repr>[0]<quote_delimited><quote_atom>[0];
}
$*PKGMETA := $*SC.pkg_create_mo(%*HOW{$*PKGDECL}, |%args);
$*PACKAGE := $*SC.pkg_create_mo(%*HOW{$*PKGDECL}, |%args);
}

[ 'is' <parent=.name> ]?
Expand Down

0 comments on commit 9869549

Please sign in to comment.