Skip to content

Commit

Permalink
Add R:I.BAGGY-CLONE-RAW
Browse files Browse the repository at this point in the history
We need a deep clone of a Baggy to work on for (.)
  • Loading branch information
lizmat committed Apr 29, 2017
1 parent 6641df8 commit d6cf518
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/core/Rakudo/Internals.pm
Expand Up @@ -1095,6 +1095,33 @@ my class Rakudo::Internals {
)
}

method BAGGY-CLONE-RAW(\baggy) {
nqp::if(
(my $raw := baggy.raw_hash) && nqp::elems($raw),
nqp::stmts( # something to coerce
(my $elems := nqp::clone($raw)),
(my $iter := nqp::iterator($elems)),
nqp::while(
$iter,
nqp::bindkey(
$elems,
nqp::iterkey_s(nqp::shift($iter)),
nqp::p6bindattrinvres(
nqp::clone(nqp::iterval($iter)),
Pair,
'$!value',
nqp::decont(
nqp::getattr(nqp::iterval($iter),Pair,'$!value')
)
)
)
),
$elems
),
$raw
)
}

method MULTIPLY-SET-TO-BAG(\elems,\set --> Nil) {
nqp::stmts(
(my $iter := nqp::iterator(elems)),
Expand Down

0 comments on commit d6cf518

Please sign in to comment.