Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Refactor package setup to keep up with the latest JnthnNQP changes. G…
Browse files Browse the repository at this point in the history
…ives $?CLASS. Really want that to be lexical at some point, but can't do that in Parrot - yet.
  • Loading branch information
jnthn committed Sep 26, 2010
1 parent 771e2ba commit c51bdac
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/NQP/Actions.pm
Expand Up @@ -383,11 +383,15 @@ sub package($/) {
PAST::Var.new( :name('type_obj'), :scope('register'), :isdecl(1) ),
PAST::Op.new(
:pasttype('callmethod'), :name('new_type'),
PAST::Var.new( :name(%*HOW{~$<sym>}), :scope('package') )
PAST::Var.new( :name(%*HOW{~$<sym>}), :namespace(''), :scope('package') )
)
),
PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name($name) ),
PAST::Var.new( :name($name), :namespace(''), :scope('package') ),
PAST::Var.new( :name('type_obj'), :scope('register') )
),
PAST::Op.new( :pasttype('bind'),
PAST::Var.new( :name('$?CLASS') ),
PAST::Var.new( :name('type_obj'), :scope('register') )
)
# XXX name
Expand All @@ -410,15 +414,19 @@ sub package($/) {
PAST::Var.new( :name('type_obj'), :scope('register') )
));

# Run this at loadinit time.
@BLOCK[0].loadinit.push(PAST::Block.new( :blocktype('immediate'), $*PACKAGE-SETUP ));

# Set up variable for this to live in.
# Set up slot for the type object to live in.
@BLOCK[0][0].unshift(PAST::Var.new( :name($name), :scope('package'), :isdecl(1) ));
@BLOCK[0].symbol($name, :scope('package'));

# Just evaluate anything else in the package in-line.
# Evaluate anything else in the package in-line; also give it a $?CLASS
# lexical. XXX Due to Parrot static lexpad fail, it's currently package scoped.
my $past := $<package_def>.ast;
$past.unshift(PAST::Var.new( :name('$?CLASS'), :scope('package'), :isdecl(1) ));
$past.symbol('$?CLASS', :scope('package'));

# Attach the class code to run at loadinit time.
$past.loadinit.push(PAST::Block.new( :blocktype('immediate'), $*PACKAGE-SETUP ));

return $past;
}

Expand Down

0 comments on commit c51bdac

Please sign in to comment.