Permalink
Browse files

Improve Parcel.Capture.

  • Loading branch information...
1 parent 98c9ddf commit d032415631affcc209ded9b4d058fba13d537459 @jnthn jnthn committed Jan 16, 2012
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/core/Parcel.pm
View
@@ -12,7 +12,19 @@ my class Parcel does Positional {
method Parcel() { self }
method Capture() {
my $cap := nqp::create(Capture);
- nqp::bindattr($cap, Capture, '$!list', $!storage);
+ my Mu $list := nqp::list();
+ my Mu $hash := nqp::hash();
+ my int $c = nqp::elems($!storage);
+ my int $i = 0;
+ while $i < $c {
+ my $v := nqp::atpos($!storage, $i);
+ nqp::istype($v, Pair) ??
+ nqp::bindkey($hash, nqp::unbox_s($v.key), $v.value) !!
+ nqp::push($list, $v);
+ $i = $i + 1;
+ }
+ nqp::bindattr($cap, Capture, '$!list', $list);
+ nqp::bindattr($cap, Capture, '$!hash', $hash);
$cap
}

0 comments on commit d032415

Please sign in to comment.