"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/core.c/native_array.pm6" 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).

native_array.pm6  (rakudo-2020.09):native_array.pm6  (rakudo-2020.10)
skipping to change at line 96 skipping to change at line 96
nqp::slice(array,$offset,-1), nqp::slice(array,$offset,-1),
nqp::slice(array,$offset,$end) nqp::slice(array,$offset,$end)
) )
) )
) )
) )
} }
my role strarray[::T] does Positional[T] is array_type(T) { my role strarray[::T] does Positional[T] is array_type(T) {
#- start of generated part of strarray role ----------------------------------- #- start of generated part of strarray role -----------------------------------
#- Generated on 2020-06-02T19:28:53+02:00 by tools/build/makeNATIVE_ARRAY.raku #- Generated on 2020-10-23T20:56:37+02:00 by tools/build/makeNATIVE_ARRAY.raku
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE #- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE
multi method grep(strarray:D: Str: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_s(nqp::atpos_s(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_s(nqp::atpos_s(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_s(nqp::atpos_s(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_s(nqp::atpos_s(self,$i),$needle),
nqp::push($result,$needle)
)
);
}
$result.Seq
}
multi method first(strarray:D: Str: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_s(nqp::atpos_s(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(strarray: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_s(self,$i)),
nqp::stmts(
nqp::bindkey($seen,nqp::atpos_s(self,$i),1),
nqp::push_s($result,nqp::atpos_s(self,$i))
)
)
);
$result.Seq
}
multi method repeated(strarray: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_s(self,$i)),
nqp::push_s($result,nqp::atpos_s(self,$i)),
nqp::bindkey($seen,nqp::atpos_s(self,$i),1)
)
);
$result.Seq
}
multi method squish(strarray:D: --> Seq:D) {
if nqp::elems(self) -> int $elems {
my $result := nqp::create(self);
my str $last = nqp::push_s($result,nqp::atpos_s(self,0));
my int $i;
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::if(
nqp::isne_s(nqp::atpos_s(self,$i),$last),
nqp::push_s($result,$last = nqp::atpos_s(self,$i))
)
);
$result.Seq
}
else {
self.Seq
}
}
multi method AT-POS(strarray:D: int $idx --> str) is raw { multi method AT-POS(strarray:D: int $idx --> str) is raw {
nqp::islt_i($idx,0) nqp::islt_i($idx,0)
?? INDEX_OUT_OF_RANGE($idx) ?? INDEX_OUT_OF_RANGE($idx)
!! nqp::atposref_s(self,$idx) !! nqp::atposref_s(self,$idx)
} }
multi method AT-POS(strarray:D: Int:D $idx --> str) is raw { multi method AT-POS(strarray:D: Int:D $idx --> str) is raw {
$idx < 0 $idx < 0
?? INDEX_OUT_OF_RANGE($idx) ?? INDEX_OUT_OF_RANGE($idx)
!! nqp::atposref_s(self,$idx) !! nqp::atposref_s(self,$idx)
} }
skipping to change at line 420 skipping to change at line 547
) )
), ),
Range.new($min,$max) Range.new($min,$max)
), ),
Range.new(Inf,-Inf) Range.new(Inf,-Inf)
) )
} }
method iterator(strarray:D: --> PredictiveIterator:D) { method iterator(strarray:D: --> PredictiveIterator:D) {
Rakudo::Iterator.native_s(self) Rakudo::Iterator.native_s(self)
} }
method Seq(strarray:D: --> Seq:D) {
Seq.new(Rakudo::Iterator.native_s(self))
}
method reverse(strarray:D: --> strarray:D) is nodal { method reverse(strarray:D: --> strarray: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_s($to,nqp::sub_i($last,$i), nqp::bindpos_s($to,nqp::sub_i($last,$i),
skipping to change at line 560 skipping to change at line 690
nqp::bindpos_s(self,$i,$empty) nqp::bindpos_s(self,$i,$empty)
if nqp::isnull_s(nqp::atposref_s(self,$i)) if nqp::isnull_s(nqp::atposref_s(self,$i))
while nqp::islt_i(++$i,$elems); while nqp::islt_i(++$i,$elems);
nqp::join($delim.Str,self) nqp::join($delim.Str,self)
} }
} }
my role intarray[::T] does Positional[T] is array_type(T) { my role intarray[::T] does Positional[T] is array_type(T) {
#- start of generated part of intarray role ----------------------------------- #- start of generated part of intarray role -----------------------------------
#- Generated on 2020-06-02T19:28:53+02:00 by tools/build/makeNATIVE_ARRAY.raku #- Generated on 2020-10-23T20:56:37+02:00 by tools/build/makeNATIVE_ARRAY.raku
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE #- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE
multi method grep(intarray:D: Int: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_i(nqp::atpos_i(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_i(nqp::atpos_i(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_i(nqp::atpos_i(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_i(nqp::atpos_i(self,$i),$needle),
nqp::push($result,$needle)
)
);
}
$result.Seq
}
multi method first(intarray:D: Int: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_i(nqp::atpos_i(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(intarray: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_i(self,$i)),
nqp::stmts(
nqp::bindkey($seen,nqp::atpos_i(self,$i),1),
nqp::push_i($result,nqp::atpos_i(self,$i))
)
)
);
$result.Seq
}
multi method repeated(intarray: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_i(self,$i)),
nqp::push_i($result,nqp::atpos_i(self,$i)),
nqp::bindkey($seen,nqp::atpos_i(self,$i),1)
)
);
$result.Seq
}
multi method squish(intarray:D: --> Seq:D) {
if nqp::elems(self) -> int $elems {
my $result := nqp::create(self);
my int $last = nqp::push_i($result,nqp::atpos_i(self,0));
my int $i;
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::if(
nqp::isne_i(nqp::atpos_i(self,$i),$last),
nqp::push_i($result,$last = nqp::atpos_i(self,$i))
)
);
$result.Seq
}
else {
self.Seq
}
}
multi method AT-POS(intarray:D: int $idx --> int) is raw { multi method AT-POS(intarray:D: int $idx --> int) is raw {
nqp::islt_i($idx,0) nqp::islt_i($idx,0)
?? INDEX_OUT_OF_RANGE($idx) ?? INDEX_OUT_OF_RANGE($idx)
!! nqp::atposref_i(self,$idx) !! nqp::atposref_i(self,$idx)
} }
multi method AT-POS(intarray:D: Int:D $idx --> int) is raw { multi method AT-POS(intarray:D: Int:D $idx --> int) is raw {
$idx < 0 $idx < 0
?? INDEX_OUT_OF_RANGE($idx) ?? INDEX_OUT_OF_RANGE($idx)
!! nqp::atposref_i(self,$idx) !! nqp::atposref_i(self,$idx)
} }
skipping to change at line 884 skipping to change at line 1141
) )
), ),
Range.new($min,$max) Range.new($min,$max)
), ),
Range.new(Inf,-Inf) Range.new(Inf,-Inf)
) )
} }
method iterator(intarray:D: --> PredictiveIterator:D) { method iterator(intarray:D: --> PredictiveIterator:D) {
Rakudo::Iterator.native_i(self) Rakudo::Iterator.native_i(self)
} }
method Seq(intarray:D: --> Seq:D) {
Seq.new(Rakudo::Iterator.native_i(self))
}
method reverse(intarray:D: --> intarray:D) is nodal { method reverse(intarray:D: --> intarray: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_i($to,nqp::sub_i($last,$i), nqp::bindpos_i($to,nqp::sub_i($last,$i),
skipping to change at line 1076 skipping to change at line 1336
), ),
self self
), ),
X::AdHoc.new( payload => "Can only initialize an int array with an int Range" ).throw X::AdHoc.new( payload => "Can only initialize an int array with an int Range" ).throw
) )
} }
} }
my role numarray[::T] does Positional[T] is array_type(T) { my role numarray[::T] does Positional[T] is array_type(T) {
#- start of generated part of numarray role ----------------------------------- #- start of generated part of numarray role -----------------------------------
#- Generated on 2020-06-02T19:28:53+02:00 by tools/build/makeNATIVE_ARRAY.raku #- Generated on 2020-10-23T20:56:37+02:00 by tools/build/makeNATIVE_ARRAY.raku
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE #- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE
multi method grep(numarray:D: Num: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_n(nqp::atpos_n(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_n(nqp::atpos_n(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_n(nqp::atpos_n(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_n(nqp::atpos_n(self,$i),$needle),
nqp::push($result,$needle)
)
);
}
$result.Seq
}
multi method first(numarray:D: Num: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_n(nqp::atpos_n(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(numarray: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_n(self,$i)),
nqp::stmts(
nqp::bindkey($seen,nqp::atpos_n(self,$i),1),
nqp::push_n($result,nqp::atpos_n(self,$i))
)
)
);
$result.Seq
}
multi method repeated(numarray: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_n(self,$i)),
nqp::push_n($result,nqp::atpos_n(self,$i)),
nqp::bindkey($seen,nqp::atpos_n(self,$i),1)
)
);
$result.Seq
}
multi method squish(numarray:D: --> Seq:D) {
if nqp::elems(self) -> int $elems {
my $result := nqp::create(self);
my num $last = nqp::push_n($result,nqp::atpos_n(self,0));
my int $i;
nqp::while(
nqp::islt_i(($i = nqp::add_i($i,1)),$elems),
nqp::if(
nqp::isne_n(nqp::atpos_n(self,$i),$last),
nqp::push_n($result,$last = nqp::atpos_n(self,$i))
)
);
$result.Seq
}
else {
self.Seq
}
}
multi method AT-POS(numarray:D: int $idx --> num) is raw { multi method AT-POS(numarray:D: int $idx --> num) is raw {
nqp::islt_i($idx,0) nqp::islt_i($idx,0)
?? INDEX_OUT_OF_RANGE($idx) ?? INDEX_OUT_OF_RANGE($idx)
!! nqp::atposref_n(self,$idx) !! nqp::atposref_n(self,$idx)
} }
multi method AT-POS(numarray:D: Int:D $idx --> num) is raw { multi method AT-POS(numarray:D: Int:D $idx --> num) is raw {
$idx < 0 $idx < 0
?? INDEX_OUT_OF_RANGE($idx) ?? INDEX_OUT_OF_RANGE($idx)
!! nqp::atposref_n(self,$idx) !! nqp::atposref_n(self,$idx)
} }
skipping to change at line 1400 skipping to change at line 1787
) )
), ),
Range.new($min,$max) Range.new($min,$max)
), ),
Range.new(Inf,-Inf) Range.new(Inf,-Inf)
) )
} }
method iterator(numarray:D: --> PredictiveIterator:D) { method iterator(numarray:D: --> PredictiveIterator:D) {
Rakudo::Iterator.native_n(self) Rakudo::Iterator.native_n(self)
} }
method Seq(numarray:D: --> Seq:D) {
Seq.new(Rakudo::Iterator.native_n(self))
}
method reverse(numarray:D: --> numarray:D) is nodal { method reverse(numarray:D: --> numarray: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_n($to,nqp::sub_i($last,$i), nqp::bindpos_n($to,nqp::sub_i($last,$i),
 End of changes. 9 change blocks. 
3 lines changed or deleted 396 lines changed or added

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