"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tools/build/makeNATIVE_ARRAY.raku" between
rakudo-2020.09.tar.gz and rakudo-2020.10.tar.gz

About: Rakudo is a compiler for the Raku Pogramming Language (formerly known as Perl 6).

makeNATIVE_ARRAY.raku  (rakudo-2020.09):makeNATIVE_ARRAY.raku  (rakudo-2020.10)
skipping to change at line 53 skipping to change at line 53
my %mapper = my %mapper =
postfix => $type.substr(0,1), postfix => $type.substr(0,1),
type => $type, type => $type,
Type => $type.tclc, Type => $type.tclc,
nullval => $type eq 'str' ?? '""' !! $type eq 'num' ?? '0e0' !! '0' nullval => $type eq 'str' ?? '""' !! $type eq 'num' ?? '0e0' !! '0'
; ;
# spurt the role # spurt the role
say Q:to/SOURCE/.subst(/ '#' (\w+) '#' /, -> $/ { %mapper{$0} }, :g).chomp; say Q:to/SOURCE/.subst(/ '#' (\w+) '#' /, -> $/ { %mapper{$0} }, :g).chomp;
multi method grep(#type#array:D: #Type#:D $needle, :$k, :$kv, :$p, :$v -
-> Seq:D) {
my int $i = -1;
my int $elems = nqp::elems(self);
my $result := nqp::create(IterationBuffer);
if $k {
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::if(
nqp::iseq_#postfix#(nqp::atpos_#postfix#(self,$i),$needle),
nqp::push($result,nqp::clone($i))
)
);
}
elsif $kv {
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::if(
nqp::iseq_#postfix#(nqp::atpos_#postfix#(self,$i),$needle),
nqp::stmts(
nqp::push($result,nqp::clone($i)),
nqp::push($result,$needle)
)
)
);
}
elsif $p {
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::if(
nqp::iseq_#postfix#(nqp::atpos_#postfix#(self,$i),$needle),
nqp::push($result,Pair.new($i,$needle))
)
);
}
else {
my int $found;
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::if(
nqp::iseq_#postfix#(nqp::atpos_#postfix#(self,$i),$needle),
nqp::push($result,$needle)
)
);
}
$result.Seq
}
multi method first(#type#array:D: #Type#:D $needle, :$k, :$kv, :$p, :$v)
{
my int $i = -1;
my int $elems = nqp::elems(self);
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems)
&& nqp::isne_#postfix#(nqp::atpos_#postfix#(self,$i),$needle),
nqp::null()
);
nqp::iseq_i($i,nqp::elems(self))
?? Nil
!! $k
?? $i
!! $kv
?? ($i,$needle)
!! $p
?? Pair.new($i,$needle)
!! $needle
}
multi method unique(#type#array:D: --> Seq:D) {
my int $i = -1;
my int $elems = nqp::elems(self);
my $result := nqp::create(self);
my $seen := nqp::hash;
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::unless(
nqp::existskey($seen,nqp::atpos_#postfix#(self,$i)),
nqp::stmts(
nqp::bindkey($seen,nqp::atpos_#postfix#(self,$i),1),
nqp::push_#postfix#($result,nqp::atpos_#postfix#(self,$i))
)
)
);
$result.Seq
}
multi method repeated(#type#array:D: --> Seq:D) {
my int $i = -1;
my int $elems = nqp::elems(self);
my $result := nqp::create(self);
my $seen := nqp::hash;
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::if(
nqp::existskey($seen,nqp::atpos_#postfix#(self,$i)),
nqp::push_#postfix#($result,nqp::atpos_#postfix#(self,$i)),
nqp::bindkey($seen,nqp::atpos_#postfix#(self,$i),1)
)
);
$result.Seq
}
multi method squish(#type#array:D: --> Seq:D) {
if nqp::elems(self) -> int $elems {
my $result := nqp::create(self);
my #type# $last = nqp::push_#postfix#($result,nqp::atpos_#postfi
x#(self,0));
my int $i;
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::if(
nqp::isne_#postfix#(nqp::atpos_#postfix#(self,$i),$last),
nqp::push_#postfix#($result,$last = nqp::atpos_#postfix#(sel
f,$i))
)
);
$result.Seq
}
else {
self.Seq
}
}
multi method AT-POS(#type#array:D: int $idx --> #type#) is raw { multi method AT-POS(#type#array:D: int $idx --> #type#) is raw {
nqp::islt_i($idx,0) nqp::islt_i($idx,0)
?? INDEX_OUT_OF_RANGE($idx) ?? INDEX_OUT_OF_RANGE($idx)
!! nqp::atposref_#postfix#(self,$idx) !! nqp::atposref_#postfix#(self,$idx)
} }
multi method AT-POS(#type#array:D: Int:D $idx --> #type#) is raw { multi method AT-POS(#type#array:D: Int:D $idx --> #type#) is raw {
$idx < 0 $idx < 0
?? INDEX_OUT_OF_RANGE($idx) ?? INDEX_OUT_OF_RANGE($idx)
!! nqp::atposref_#postfix#(self,$idx) !! nqp::atposref_#postfix#(self,$idx)
} }
skipping to change at line 374 skipping to change at line 501
) )
), ),
Range.new($min,$max) Range.new($min,$max)
), ),
Range.new(Inf,-Inf) Range.new(Inf,-Inf)
) )
} }
method iterator(#type#array:D: --> PredictiveIterator:D) { method iterator(#type#array:D: --> PredictiveIterator:D) {
Rakudo::Iterator.native_#postfix#(self) Rakudo::Iterator.native_#postfix#(self)
} }
method Seq(#type#array:D: --> Seq:D) {
Seq.new(Rakudo::Iterator.native_#postfix#(self))
}
method reverse(#type#array:D: --> #type#array:D) is nodal { method reverse(#type#array:D: --> #type#array:D) is nodal {
nqp::stmts( nqp::stmts(
(my int $elems = nqp::elems(self)), (my int $elems = nqp::elems(self)),
(my int $last = nqp::sub_i($elems,1)), (my int $last = nqp::sub_i($elems,1)),
(my int $i = -1), (my int $i = -1),
(my $to := nqp::clone(self)), (my $to := nqp::clone(self)),
nqp::while( nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems), nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::bindpos_#postfix#($to,nqp::sub_i($last,$i), nqp::bindpos_#postfix#($to,nqp::sub_i($last,$i),
 End of changes. 2 change blocks. 
0 lines changed or deleted 134 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)