Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Assorted fixes to package scoped things. Fixes our subs amongst other…
… things.
  • Loading branch information
jnthn committed Aug 7, 2012
1 parent 90adf5a commit 0143bc0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions src/NQPQ/Actions.pm
Expand Up @@ -881,10 +881,10 @@ class NQP::Actions is HLL::Actions {
# Need to install it at loadinit time but also re-bind
# it per invocation.
$*W.install_package_routine($*PACKAGE, $name, $past);
$BLOCK[0].push(PAST::Op.new(
:pasttype('bind_6model'),
$BLOCK[0].push(QAST::Op.new(
:op('bind'),
lexical_package_lookup([$name], $/),
PAST::Var.new( :name($name), :scope('lexical') )
QAST::Var.new( :name($name), :scope('lexical') )
));
}
}
Expand Down Expand Up @@ -1504,8 +1504,8 @@ class NQP::Actions is HLL::Actions {
# The final lookup will always be just a keyed access to a
# symbol table.
my $final_name := @name.pop();
my $lookup := QAST::Op.new(
:op('atkey'),
my $lookup := QAST::VarWithFallback.new(
:scope('associative'),
QAST::SVal.new( :value(~$final_name) )
);

Expand All @@ -1516,9 +1516,8 @@ class NQP::Actions is HLL::Actions {
:op('who'),
QAST::Var.new( :name('$?PACKAGE'), :scope('lexical') )
));
$lookup := QAST::Op.new(
$lookup.fallback(QAST::Op.new(
:op('ifnull'),
$lookup,
QAST::Op.new(
:op('atkey'),
QAST::Op.new(
Expand All @@ -1527,25 +1526,28 @@ class NQP::Actions is HLL::Actions {
QAST::SVal.new( :value('GLOBAL') ) )
),
QAST::SVal.new( :value(~$final_name) )
));
),
default_for('$')));
}

# Otherwise, see if the first part of the name is lexically
# known. If not, it's in GLOBAL. Also, if first part is GLOBAL
# then strip it off.
else {
my $path := $*W.is_lexical(@name[0]) ??
PAST::Var.new( :name(@name.shift()), :scope('lexical') ) !!
PAST::Var.new( :name('GLOBAL'), :namespace([]), :scope('package') );
QAST::Var.new( :name(@name.shift()), :scope('lexical') ) !!
QAST::VM.new( pirop => 'get_hll_global Ps',
QAST::SVal.new( :value('GLOBAL') ) );
if @name[0] eq 'GLOBAL' {
@name.shift();
}
for @name {
$path := PAST::Op.new(
$path := QAST::VM.new(
:pirop('nqp_get_package_through_who PPs'),
$path, ~$_);
$path, QAST::SVal.new( :value(~$_) ));
}
$lookup.unshift(PAST::Op.new(:pirop('get_who PP'), $path));
$lookup.unshift(QAST::Op.new(:op('who'), $path));
$lookup.fallback(default_for('$'));
}

return $lookup;
Expand Down
2 changes: 1 addition & 1 deletion src/NQPQ/World.pm
Expand Up @@ -181,7 +181,7 @@ class NQP::World is HLL::World {
method install_package_routine($package, $name, $past_block) {
my $fixup := QAST::Op.new(
:op('bindkey'),
QAST::Op.new( :op('getwho'), QAST::WVal.new( :value($package) ) ),
QAST::Op.new( :op('who'), QAST::WVal.new( :value($package) ) ),
QAST::SVal.new( :value(~$name) ),
QAST::BVal.new( :value($past_block) )
);
Expand Down

0 comments on commit 0143bc0

Please sign in to comment.