Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Parcel no longer autoflattens for .elems or .[]
  • Loading branch information
TimToady committed Sep 2, 2014
1 parent a8df1c9 commit ef380d2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
20 changes: 10 additions & 10 deletions src/core/Any.pm
Expand Up @@ -786,7 +786,7 @@ sub SLICE_MORE ( \SELF, $more, $array, *%adv ) is hidden_from_backtrace {
$de(SELF,$_) if $wasthere = $ex(SELF,$_);
($_, !( $wasthere ?^ $exists ))
if !$kv | $wasthere;
} ).eager.Parcel
} ).flat.eager.Parcel
}
else {
@nogo = <delete exists kv>;
Expand Down Expand Up @@ -815,10 +815,10 @@ sub SLICE_MORE ( \SELF, $more, $array, *%adv ) is hidden_from_backtrace {
$kv
?? $more.list.map( {
( $_, $de(SELF,$_) ) if $ex(SELF,$_);
} ).eager.Parcel
} ).flat.eager.Parcel
!! $more.list.map( {
( $_, $de(SELF,$_) )
} ).eager.Parcel;
} ).flat.eager.Parcel;
}
else {
@nogo = <delete kv>;
Expand Down Expand Up @@ -884,10 +884,10 @@ sub SLICE_MORE ( \SELF, $more, $array, *%adv ) is hidden_from_backtrace {
$kv
?? $more.list.map( {
( $_, $exists ) if $ex(SELF,$_);
} ).eager.Parcel
} ).flat.eager.Parcel
!! $more.list.map( {
( $_, !( $ex(SELF,$_) ?^ $exists ) )
} ).eager.Parcel;
} ).flat.eager.Parcel;
}
else {
@nogo = <exists kv>;
Expand Down Expand Up @@ -917,11 +917,11 @@ sub SLICE_MORE ( \SELF, $more, $array, *%adv ) is hidden_from_backtrace {
if !%a { # :!delete?:kv(0|1)
$kv
?? $more.list.map( {
($_, $at(SELF,$_)) if $ex(SELF,$_);
} ).eager.Parcel
$_, $at(SELF,$_) if $ex(SELF,$_);
} ).flat.eager.Parcel
!! $more.list.map( {
($_, $at(SELF,$_))
} ).eager.Parcel;
$_, $at(SELF,$_)
} ).flat.eager.Parcel;
}
else {
@nogo = <kv>;
Expand All @@ -947,7 +947,7 @@ sub SLICE_MORE ( \SELF, $more, $array, *%adv ) is hidden_from_backtrace {
if !%a { # :!delete?:k(0|1)
$k
?? $more.list.map( { $_ if $ex(SELF,$_) } ).eager.Parcel
!! $more.list.eager.Parcel;
!! $more.list.flat.eager.Parcel;
}
else {
@nogo = <k>;
Expand Down
14 changes: 9 additions & 5 deletions src/core/Parcel.pm
Expand Up @@ -6,9 +6,8 @@ my class Parcel does Positional { # declared in BOOTSTRAP
submethod BUILD() { $!storage := nqp::list() }

multi method Bool(Parcel:D:) { nqp::p6bool($!storage) }
multi method Numeric(Parcel:D:) { self.flat.elems }
multi method Str(Parcel:D:) { self.flat.Str }
# multi method Int(Parcel:D:) { self.flat.elems }
multi method Numeric(Parcel:D:) { nqp::elems($!storage) }
multi method Str(Parcel:D:) { self.list.Str }
multi method ACCEPTS(Parcel:D: $topic) { self.list.ACCEPTS($topic) }

multi method WHICH(Parcel:D:) {
Expand All @@ -34,7 +33,7 @@ my class Parcel does Positional { # declared in BOOTSTRAP
$cap
}

method elems() { self.flat.elems }
method elems() { nqp::elems($!storage) }
method item() { my $v = self; }
method flat() { nqp::p6list(nqp::clone($!storage), List, Bool::True) }
method list() { nqp::p6list(nqp::clone($!storage), List, Mu) }
Expand Down Expand Up @@ -63,7 +62,12 @@ my class Parcel does Positional { # declared in BOOTSTRAP
$parcel;
}

method at_pos(Parcel:D: \x) is rw { self.flat.at_pos(x); }
multi method at_pos(Parcel:D: \x) is rw { self.at_pos(nqp::unbox_i(x.floor)) }
multi method at_pos(Parcel:D: int $x) is rw {
$x > nqp::elems($!storage) || $x < 0
?? Nil
!! nqp::atpos($!storage, $x);
}

multi method gist(Parcel:D:) {
my Mu $gist := nqp::list();
Expand Down

0 comments on commit ef380d2

Please sign in to comment.