Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Streamline Capture.at_pos + error for Inf/NaN
  • Loading branch information
lizmat committed Jan 12, 2015
1 parent 72228a6 commit e56d60d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/core/Capture.pm
Expand Up @@ -39,16 +39,18 @@ my class Capture { # declared in BOOTSTRAP
nqp::existskey($!hash,$skey) ?? nqp::atkey($!hash, $skey) !! Any;
}

multi method at_pos(Capture:D: $pos is copy) {
$pos = $pos.Int;
nqp::existspos($!list, nqp::unbox_i($pos))
?? nqp::atpos($!list, nqp::unbox_i($pos))
!! Any
}
multi method at_pos(Capture:D: Int $pos) {
nqp::existspos($!list, nqp::unbox_i($pos))
?? nqp::atpos($!list, nqp::unbox_i($pos))
!! Any
multi method at_pos(Capture:D: int \pos) {
nqp::existspos($!list, pos) ?? nqp::atpos($!list, pos) !! Any;
}
multi method at_pos(Capture:D: Int \pos) {
my int $pos = nqp::unbox_i(pos);
nqp::existspos($!list,$pos) ?? nqp::atpos($!list,$pos) !! Any;
}
multi method at_pos(Capture:D: \pos) {
X::Item.new(aggregate => self, index => pos).throw
if nqp::istype(pos,Num) && nqp::isnanorinf(pos);
my int $pos = nqp::unbox_i(pos.Int);
nqp::existspos($!list,$pos) ?? nqp::atpos($!list,$pos) !! Any;
}

method hash(Capture:D:) {
Expand Down

0 comments on commit e56d60d

Please sign in to comment.