Skip to content

Commit

Permalink
promote last, next and redo to full multi subs
Browse files Browse the repository at this point in the history
at some point it had to be changed into this, but
it seems like it's safe to have it like this now.

the no-arguments version of those will now not only not
allocate a BOOTArray and a Parcel, but also get jitted
properly due to not using param_sp (slurpy positional)
op codes.
  • Loading branch information
timo committed May 26, 2015
1 parent e6f4046 commit abeb0f2
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/core/control.pm
Original file line number Diff line number Diff line change
Expand Up @@ -82,38 +82,53 @@ multi sub take(|) {
}
#?endif

my &last := -> | {
proto sub last(|) { * }
multi sub last() {
THROW(Nil, nqp::const::CONTROL_LAST);
}
multi sub last(*@) {
my Mu $args := nqp::p6argvmarray();

if nqp::islist($args) && nqp::istype(nqp::atpos($args, 0), Label) {
nqp::atpos($args, 0).last()
}
else {
my $parcel := nqp::decont(&RETURN-PARCEL(nqp::p6parcel($args, Nil)));
THROW($parcel, nqp::const::CONTROL_LAST)
}
};
}

my &next := -> | {
proto sub next(|) { * }
multi sub next() {
THROW(Nil, nqp::const::CONTROL_NEXT);
}
multi sub next(*@) {
my Mu $args := nqp::p6argvmarray();

if nqp::islist($args) && nqp::istype(nqp::atpos($args, 0), Label) {
nqp::atpos($args, 0).next()
}
else {
my $parcel := nqp::decont(&RETURN-PARCEL(nqp::p6parcel($args, Nil)));
THROW($parcel, nqp::const::CONTROL_NEXT)
}
};
}

my &redo := -> | {
proto sub redo(|) { * }
multi sub redo() {
THROW(Nil, nqp::const::CONTROL_REDO);
}
multi sub redo(*@) {
my Mu $args := nqp::p6argvmarray();

if nqp::islist($args) && nqp::istype(nqp::atpos($args, 0), Label) {
nqp::atpos($args, 0).redo()
}
else {
my $parcel := nqp::decont(&RETURN-PARCEL(nqp::p6parcel($args, Nil)));
THROW($parcel, nqp::const::CONTROL_REDO)
}
};
}

proto sub succeed(|) { * }
multi sub succeed() {
Expand Down

0 comments on commit abeb0f2

Please sign in to comment.