Skip to content

Commit

Permalink
Bring the code for %*ENV initialization to where it's run
Browse files Browse the repository at this point in the history
No particular reason, but this code should only be run in a process
anyway, so why make a R:I method for it?
  • Loading branch information
lizmat committed Mar 29, 2022
1 parent 97ad3f7 commit 04c8bd6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
17 changes: 0 additions & 17 deletions src/core.c/Rakudo/Internals.pm6
Expand Up @@ -194,23 +194,6 @@ my class Rakudo::Internals {
}
}

method createENV() {
my $hash := nqp::hash;
my $iter := nqp::iterator(nqp::getenvhash);
nqp::while(
$iter,
nqp::bindkey(
$hash,
nqp::iterkey_s(nqp::shift($iter)),
nqp::assign(
nqp::p6scalarfromdesc(nqp::null),
val(nqp::box_s(nqp::iterval($iter),Str))
)
)
);
$hash
}

# Helper method for prefix:<let>/prefix:<temp>, which really do the same
# thing apart from where they store data. Takes the IterationBuffer in
# which to save data, the container to be inspected, and the type of op
Expand Down
17 changes: 16 additions & 1 deletion src/core.c/core_prologue.pm6
Expand Up @@ -75,7 +75,22 @@ my class Rakudo::Internals::IterationSet is repr('VMHash') {
my constant $?NL = "\x0A";

# Make sure we have an environment
PROCESS::<%ENV> := Rakudo::Internals.createENV;
PROCESS::<%ENV> := do {
my $env := nqp::hash;
my $iter := nqp::iterator(nqp::getenvhash);
nqp::while(
$iter,
nqp::bindkey(
$env,
nqp::iterkey_s(nqp::shift($iter)),
nqp::assign(
nqp::p6scalarfromdesc(nqp::null),
val(nqp::box_s(nqp::iterval($iter),Str))
)
)
);
nqp::p6bindattrinvres(nqp::create(Hash),Map,'$!storage',$env)
}

# This thread pool scheduler will be the default one.
#?if !js
Expand Down

0 comments on commit 04c8bd6

Please sign in to comment.