Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Unify the %*ENV creating across the jvm and parrot backends.
  • Loading branch information
pmurias committed Aug 28, 2013
1 parent 26a36bf commit 23d310a
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions src/core/terms.pm
Expand Up @@ -7,53 +7,16 @@ sub term:<time>() { nqp::p6box_i(nqp::time_i()) }
nqp::bindkey(nqp::who(PROCESS), '@ARGS', @ARGS);
$PROCESS::ARGFILES = IO::ArgFiles.new(:args(@ARGS));

# Evn iterator on Parrot apparently doesn't behave like a normal
# hash iterator...
my %ENV;
my Mu $env := nqp::getenvhash();
my Mu $enviter := nqp::iterator($env);
#?if parrot
my $key;
while $enviter {
$key = nqp::p6box_s(nqp::shift_s($enviter));
%ENV{$key} = nqp::p6box_s(nqp::atkey($env, nqp::unbox_s($key)));
}
#?endif
#?if !parrot
my $envelem;
my $key;
while $enviter {
$envelem := nqp::shift($enviter);
$key = nqp::p6box_s(nqp::iterkey_s($envelem));
%ENV{$key} = nqp::p6box_s(nqp::iterval($envelem));
}
#?endif
#?if parrot
%ENV does role {
method at_key($k) {
Proxy.new(
FETCH => {
if nqp::p6bool(nqp::existskey(%ENV, nqp::unbox_s($k))) {
nqp::p6box_s(nqp::atkey(%ENV, nqp::unbox_s($k)))
}
else {
Any
}
},
STORE => -> $, $v {
nqp::bindkey(%ENV, nqp::unbox_s($k),
nqp::unbox_s(($v // '').Str))
}
)
}

method delete($k) {
my $ret = self.at_key($k);
nqp::deletekey(%ENV, nqp::unbox_s($k));
return $ret;
}
}
#?endif
nqp::bindkey(nqp::who(PROCESS), '%ENV', %ENV);

#?if parrot
Expand Down

0 comments on commit 23d310a

Please sign in to comment.