Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement various cases of binding into pseudo-packages.
  • Loading branch information
jnthn committed Apr 15, 2012
1 parent d6cd1e2 commit 9df76e9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Perl6/Actions.pm
Expand Up @@ -3750,6 +3750,12 @@ class Perl6::Actions is HLL::Actions {
$target[0].push($source);
make $target;
}
elsif $target.isa(PAST::Op) && $target.pasttype eq 'callmethod' &&
($target.name eq 'postcircumfix:<[ ]>' || $target.name eq 'postcircumfix:<{ }>') {
$source.named('BIND');
$target.push($source);
make $target;
}
# XXX Several more cases to do...
else {
$*W.throw($/, ['X', 'Bind', 'WrongLHS']);
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/World.pm
Expand Up @@ -1640,7 +1640,7 @@ class Perl6::World is HLL::World {
);
}
$lookup := PAST::Op.new(
:pasttype('callmethod'), :name('at_key'),
:pasttype('callmethod'), :name('postcircumfix:<{ }>'),
$lookup,
self.add_string_constant($_));
}
Expand Down
17 changes: 17 additions & 0 deletions src/core/PseudoStash.pm
Expand Up @@ -100,6 +100,23 @@ my class PseudoStash is EnumMap {
}
}

method bind_key($key is copy, \$value) {
$key = $key.Str;
if %pseudoers.exists($key) {
die "Cannot bind to pseudo-package $key";
}
elsif $!mode == PRECISE_SCOPE {
my Mu $store := nqp::getattr(self, EnumMap, '$!storage');
nqp::bindkey($store, nqp::unbox_s($key), $value)
}
elsif $!mode == DYNAMIC_CHAIN || $!mode == PICK_CHAIN_BY_NAME && substr($key, 1, 1) eq '*' {
die "Binding to dynamic variables not yet implemented";
}
else {
die "This case of binding is not yet implemented";
}
}

method exists($key is copy) {
$key = $key.Str;
if %pseudoers.exists($key) {
Expand Down

0 comments on commit 9df76e9

Please sign in to comment.