diff --git a/src/core.c/Env.pm6 b/src/core.c/Env.pm6 index 01d14c85675..e7aff58239e 100644 --- a/src/core.c/Env.pm6 +++ b/src/core.c/Env.pm6 @@ -1,3 +1,23 @@ +class Env is Hash { + multi method new(Env:) { + nqp::p6bindattrinvres( + nqp::create(self),Map,'$!storage',nqp::clone(nqp::getenvhash) + ) + } + method AT-KEY(Env:D: Str:D $key) { + nqp::existskey(nqp::getattr(self,Map,'$!storage'),$key) + ?? val(nqp::atkey(nqp::getattr(self,Map,'$!storage'),$key)) + !! nextsame + } + method ASSIGN-KEY(Env:D: Str:D $key, \value) { + nqp::bindkey( + nqp::getattr(self,Map,'$!storage'), + $key, + nqp::unbox_s(value.Str) + ) + } +} + Rakudo::Internals.REGISTER-DYNAMIC: '$*CWD', { # PROCESS::<$CWD> = nqp::p6box_s(nqp::cwd()); my $CWD := nqp::p6box_s(nqp::cwd()); diff --git a/src/core.c/Exception.pm6 b/src/core.c/Exception.pm6 index 52f639f4ef1..1b7b3a3cf5f 100644 --- a/src/core.c/Exception.pm6 +++ b/src/core.c/Exception.pm6 @@ -383,7 +383,8 @@ do { :what("PERL6_EXCEPTIONS_HANDLER env var"); my $class := ::("Exceptions::$handler"); unless nqp::istype($class,Failure) { - temp %*ENV = ""; # prevent looping + temp %*ENV; + %*ENV = ""; # prevent looping unless $class.process($e) { nqp::getcurhllsym('&THE_END')(); return @@ -393,7 +394,8 @@ do { if %*ENV -> $handler { my $class := ::("Exceptions::$handler"); unless nqp::istype($class,Failure) { - temp %*ENV = ""; # prevent looping + temp %*ENV; + %*ENV = ""; # prevent looping unless $class.process($e) { nqp::getcurhllsym('&THE_END')(); return diff --git a/src/core.c/Rakudo/Internals.pm6 b/src/core.c/Rakudo/Internals.pm6 index 6d06625e245..017adc674b9 100644 --- a/src/core.c/Rakudo/Internals.pm6 +++ b/src/core.c/Rakudo/Internals.pm6 @@ -154,25 +154,6 @@ my class Rakudo::Internals { 0; } - method createENV() { - nqp::stmts( - (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::iterval($iter)) - ) - ) - ), - $hash - ) - } - # Helper method for prefix:/prefix:, 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 diff --git a/src/core.c/control.pm6 b/src/core.c/control.pm6 index 213e2ddb03e..0982651afb4 100644 --- a/src/core.c/control.pm6 +++ b/src/core.c/control.pm6 @@ -211,7 +211,11 @@ sub CLONE-HASH-DECONTAINERIZED(\hash) { nqp::iterkey_s(nqp::shift(iter)), nqp::if( nqp::defined(nqp::iterval(iter)), - nqp::decont(nqp::iterval(iter)).Str, + nqp::if( + nqp::iseq_s(nqp::iterval(iter).^name,'BOOTStr'), + nqp::iterval(iter), + nqp::unbox_s(nqp::decont(nqp::iterval(iter)).Str) + ), '' ) ) diff --git a/src/core.c/core_prologue.pm6 b/src/core.c/core_prologue.pm6 index b26418591d2..8cfcadc64ed 100644 --- a/src/core.c/core_prologue.pm6 +++ b/src/core.c/core_prologue.pm6 @@ -56,7 +56,8 @@ my class Rakudo::Internals::IterationSet is repr('VMHash') { } my constant $?NL = "\x0A"; # Make sure we have an environment -PROCESS::<%ENV> := Rakudo::Internals.createENV; +my class Env { ... } +PROCESS::<%ENV> := Env.new; # This thread pool scheduler will be the default one. #?if !js diff --git a/t/02-rakudo/03-corekeys-6c.t b/t/02-rakudo/03-corekeys-6c.t index 76219b79513..a35a1322b77 100644 --- a/t/02-rakudo/03-corekeys-6c.t +++ b/t/02-rakudo/03-corekeys-6c.t @@ -529,6 +529,7 @@ my @expected = ( Q{Encoding}, Q{Endian}, Q{Enumeration}, + Q{Env}, Q{Exception}, Q{Exceptions}, Q{Failure}, diff --git a/t/02-rakudo/03-corekeys-6d.t b/t/02-rakudo/03-corekeys-6d.t index 2136da352b3..ddcbf431f2d 100644 --- a/t/02-rakudo/03-corekeys-6d.t +++ b/t/02-rakudo/03-corekeys-6d.t @@ -529,6 +529,7 @@ my @expected = ( Q{Encoding}, Q{Endian}, Q{Enumeration}, + Q{Env}, Q{Exception}, Q{Exceptions}, Q{Failure}, diff --git a/t/02-rakudo/03-corekeys-6e.t b/t/02-rakudo/03-corekeys-6e.t index f8dba68def7..eb31f391349 100644 --- a/t/02-rakudo/03-corekeys-6e.t +++ b/t/02-rakudo/03-corekeys-6e.t @@ -530,6 +530,7 @@ my @expected = ( Q{Encoding}, Q{Endian}, Q{Enumeration}, + Q{Env}, Q{Exception}, Q{Exceptions}, Q{Failure}, diff --git a/t/02-rakudo/03-corekeys.t b/t/02-rakudo/03-corekeys.t index 78278c749f7..64a152fd9cc 100644 --- a/t/02-rakudo/03-corekeys.t +++ b/t/02-rakudo/03-corekeys.t @@ -531,6 +531,7 @@ my @allowed = Q{Encoding}, Q{Endian}, Q{Enumeration}, + Q{Env}, Q{Exception}, Q{Exceptions}, Q{Failure}, diff --git a/t/02-rakudo/04-settingkeys-6c.t b/t/02-rakudo/04-settingkeys-6c.t index 7b5f4c3580e..2725d7eb2bb 100644 --- a/t/02-rakudo/04-settingkeys-6c.t +++ b/t/02-rakudo/04-settingkeys-6c.t @@ -529,6 +529,7 @@ my %allowed = ( Q{Encoding}, Q{Endian}, Q{Enumeration}, + Q{Env}, Q{Exception}, Q{Exceptions}, Q{Failure}, diff --git a/t/02-rakudo/04-settingkeys-6e.t b/t/02-rakudo/04-settingkeys-6e.t index 15180ca5148..c8ab92ff178 100644 --- a/t/02-rakudo/04-settingkeys-6e.t +++ b/t/02-rakudo/04-settingkeys-6e.t @@ -528,6 +528,7 @@ my %allowed = ( Q{Encoding}, Q{Endian}, Q{Enumeration}, + Q{Env}, Q{Exception}, Q{Exceptions}, Q{Failure},