Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created November 29, 2016 09:26
Show Gist options
  • Save lizmat/0e734516f6a08a5f2a01498d62b38159 to your computer and use it in GitHub Desktop.
Save lizmat/0e734516f6a08a5f2a01498d62b38159 to your computer and use it in GitHub Desktop.
Multi method 'STORE' with signature :(array[int]+{array::shaped2intarray}:D $: Iterable:D \from, *%_) must be resolved by class array[int]+{array::shaped2intarray} because it exists in multiple roles (array::shapedintarray, array::shapedintarray)
diff --git a/src/core/native_array.pm b/src/core/native_array.pm
index f115a37..93dea31 100644
--- a/src/core/native_array.pm
+++ b/src/core/native_array.pm
@@ -944,7 +944,7 @@ my class array does Iterable {
}
#- start of generated part of shapedintarray role -----------------------------
-#- Generated on 2016-11-28T17:47:09+01:00 by tools/build/makeNATIVE_SHAPED_ARRAY.pl6
+#- Generated on 2016-11-28T21:00:16+01:00 by tools/build/makeNATIVE_SHAPED_ARRAY.pl6
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE
role shapedintarray does shapedarray {
@@ -1065,6 +1065,69 @@ my class array does Iterable {
).throw
)
}
+ multi method STORE(::?CLASS:D: Iterable:D \from) {
+ class :: does Rakudo::Internals::ShapeBranchIterator {
+ has $!iterators;
+ method INIT(\to,\from) {
+ nqp::stmts(
+ self.SET-SELF(to),
+ ($!iterators := nqp::setelems(
+ nqp::list(from.iterator),
+ nqp::add_i($!maxdim,1)
+ )),
+ self
+ )
+ }
+ method new(\to,\from) { nqp::create(self).INIT(to,from) }
+ method done(--> Nil) {
+ nqp::unless( # verify lowest
+ nqp::atpos($!iterators,0).is-lazy # finite iterator
+ || nqp::eqaddr( # and something there
+ nqp::atpos($!iterators,0).pull-one,IterationEnd),
+ nqp::atposnd_i($!list,$!indices) # boom!
+ )
+ }
+ method process(--> Nil) {
+ nqp::stmts(
+ (my int $i = $!level),
+ nqp::while(
+ nqp::isle_i(($i = nqp::add_i($i,1)),$!maxdim),
+ nqp::if(
+ nqp::eqaddr((my $item := # exhausted ?
+ nqp::atpos($!iterators,nqp::sub_i($i,1)).pull-one),
+ IterationEnd
+ ),
+ nqp::bindpos($!iterators,$i, # add an empty one
+ Rakudo::Internals.EmptyIterator),
+ nqp::if( # is it an iterator?
+ nqp::istype($item,Iterable) && nqp::isconcrete($item),
+ nqp::bindpos($!iterators,$i,$item.iterator),
+ X::Assignment::ToShaped.new(shape => $!dims).throw
+ )
+ )
+ ),
+ (my $iter := nqp::atpos($!iterators,$!maxdim)),
+ nqp::until( # loop over highest dim
+ nqp::eqaddr((my $pulled := $iter.pull-one),IterationEnd)
+ || nqp::isgt_i(nqp::atpos_i($!indices,$!maxdim),$!maxind),
+ nqp::stmts(
+ nqp::bindposnd_i($!list,$!indices,$pulled),
+ nqp::bindpos_i($!indices,$!maxdim, # increment index
+ nqp::add_i(nqp::atpos_i($!indices,$!maxdim),1))
+ )
+ ),
+ nqp::unless(
+ nqp::eqaddr($pulled,IterationEnd) # if not exhausted
+ || nqp::isle_i( # and index too high
+ nqp::atpos_i($!indices,$!maxdim),$!maxind)
+ || $iter.is-lazy, # and not lazy
+ nqp::atposnd_i($!list,$!indices) # boom!
+ )
+ )
+ }
+ }.new(self,from).sink-all;
+ self
+ }
} # end of shapedintarray role
role shaped1intarray does shapedintarray {
@@ -1214,7 +1277,7 @@ my class array does Iterable {
#- end of generated part of shapedintarray role -------------------------------
#- start of generated part of shapednumarray role -----------------------------
-#- Generated on 2016-11-28T17:47:09+01:00 by tools/build/makeNATIVE_SHAPED_ARRAY.pl6
+#- Generated on 2016-11-28T21:00:16+01:00 by tools/build/makeNATIVE_SHAPED_ARRAY.pl6
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE
role shapednumarray does shapedarray {
@@ -1335,6 +1398,69 @@ my class array does Iterable {
).throw
)
}
+ multi method STORE(::?CLASS:D: Iterable:D \from) {
+ class :: does Rakudo::Internals::ShapeBranchIterator {
+ has $!iterators;
+ method INIT(\to,\from) {
+ nqp::stmts(
+ self.SET-SELF(to),
+ ($!iterators := nqp::setelems(
+ nqp::list(from.iterator),
+ nqp::add_i($!maxdim,1)
+ )),
+ self
+ )
+ }
+ method new(\to,\from) { nqp::create(self).INIT(to,from) }
+ method done(--> Nil) {
+ nqp::unless( # verify lowest
+ nqp::atpos($!iterators,0).is-lazy # finite iterator
+ || nqp::eqaddr( # and something there
+ nqp::atpos($!iterators,0).pull-one,IterationEnd),
+ nqp::atposnd_n($!list,$!indices) # boom!
+ )
+ }
+ method process(--> Nil) {
+ nqp::stmts(
+ (my int $i = $!level),
+ nqp::while(
+ nqp::isle_i(($i = nqp::add_i($i,1)),$!maxdim),
+ nqp::if(
+ nqp::eqaddr((my $item := # exhausted ?
+ nqp::atpos($!iterators,nqp::sub_i($i,1)).pull-one),
+ IterationEnd
+ ),
+ nqp::bindpos($!iterators,$i, # add an empty one
+ Rakudo::Internals.EmptyIterator),
+ nqp::if( # is it an iterator?
+ nqp::istype($item,Iterable) && nqp::isconcrete($item),
+ nqp::bindpos($!iterators,$i,$item.iterator),
+ X::Assignment::ToShaped.new(shape => $!dims).throw
+ )
+ )
+ ),
+ (my $iter := nqp::atpos($!iterators,$!maxdim)),
+ nqp::until( # loop over highest dim
+ nqp::eqaddr((my $pulled := $iter.pull-one),IterationEnd)
+ || nqp::isgt_i(nqp::atpos_i($!indices,$!maxdim),$!maxind),
+ nqp::stmts(
+ nqp::bindposnd_n($!list,$!indices,$pulled),
+ nqp::bindpos_i($!indices,$!maxdim, # increment index
+ nqp::add_i(nqp::atpos_i($!indices,$!maxdim),1))
+ )
+ ),
+ nqp::unless(
+ nqp::eqaddr($pulled,IterationEnd) # if not exhausted
+ || nqp::isle_i( # and index too high
+ nqp::atpos_i($!indices,$!maxdim),$!maxind)
+ || $iter.is-lazy, # and not lazy
+ nqp::atposnd_n($!list,$!indices) # boom!
+ )
+ )
+ }
+ }.new(self,from).sink-all;
+ self
+ }
} # end of shapednumarray role
role shaped1numarray does shapednumarray {
@@ -1484,7 +1610,7 @@ my class array does Iterable {
#- end of generated part of shapednumarray role -------------------------------
#- start of generated part of shapedstrarray role -----------------------------
-#- Generated on 2016-11-28T17:47:09+01:00 by tools/build/makeNATIVE_SHAPED_ARRAY.pl6
+#- Generated on 2016-11-28T21:00:16+01:00 by tools/build/makeNATIVE_SHAPED_ARRAY.pl6
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE
role shapedstrarray does shapedarray {
@@ -1605,6 +1731,69 @@ my class array does Iterable {
).throw
)
}
+ multi method STORE(::?CLASS:D: Iterable:D \from) {
+ class :: does Rakudo::Internals::ShapeBranchIterator {
+ has $!iterators;
+ method INIT(\to,\from) {
+ nqp::stmts(
+ self.SET-SELF(to),
+ ($!iterators := nqp::setelems(
+ nqp::list(from.iterator),
+ nqp::add_i($!maxdim,1)
+ )),
+ self
+ )
+ }
+ method new(\to,\from) { nqp::create(self).INIT(to,from) }
+ method done(--> Nil) {
+ nqp::unless( # verify lowest
+ nqp::atpos($!iterators,0).is-lazy # finite iterator
+ || nqp::eqaddr( # and something there
+ nqp::atpos($!iterators,0).pull-one,IterationEnd),
+ nqp::atposnd_s($!list,$!indices) # boom!
+ )
+ }
+ method process(--> Nil) {
+ nqp::stmts(
+ (my int $i = $!level),
+ nqp::while(
+ nqp::isle_i(($i = nqp::add_i($i,1)),$!maxdim),
+ nqp::if(
+ nqp::eqaddr((my $item := # exhausted ?
+ nqp::atpos($!iterators,nqp::sub_i($i,1)).pull-one),
+ IterationEnd
+ ),
+ nqp::bindpos($!iterators,$i, # add an empty one
+ Rakudo::Internals.EmptyIterator),
+ nqp::if( # is it an iterator?
+ nqp::istype($item,Iterable) && nqp::isconcrete($item),
+ nqp::bindpos($!iterators,$i,$item.iterator),
+ X::Assignment::ToShaped.new(shape => $!dims).throw
+ )
+ )
+ ),
+ (my $iter := nqp::atpos($!iterators,$!maxdim)),
+ nqp::until( # loop over highest dim
+ nqp::eqaddr((my $pulled := $iter.pull-one),IterationEnd)
+ || nqp::isgt_i(nqp::atpos_i($!indices,$!maxdim),$!maxind),
+ nqp::stmts(
+ nqp::bindposnd_s($!list,$!indices,$pulled),
+ nqp::bindpos_i($!indices,$!maxdim, # increment index
+ nqp::add_i(nqp::atpos_i($!indices,$!maxdim),1))
+ )
+ ),
+ nqp::unless(
+ nqp::eqaddr($pulled,IterationEnd) # if not exhausted
+ || nqp::isle_i( # and index too high
+ nqp::atpos_i($!indices,$!maxdim),$!maxind)
+ || $iter.is-lazy, # and not lazy
+ nqp::atposnd_s($!list,$!indices) # boom!
+ )
+ )
+ }
+ }.new(self,from).sink-all;
+ self
+ }
} # end of shapedstrarray role
role shaped1strarray does shapedstrarray {
diff --git a/tools/build/makeNATIVE_SHAPED_ARRAY.pl6 b/tools/build/makeNATIVE_SHAPED_ARRAY.pl6
index 070984d..b83aa0a 100644
--- a/tools/build/makeNATIVE_SHAPED_ARRAY.pl6
+++ b/tools/build/makeNATIVE_SHAPED_ARRAY.pl6
@@ -160,6 +160,69 @@ for $*IN.lines -> $line {
).throw
)
}
+ multi method STORE(::?CLASS:D: Iterable:D \from) {
+ class :: does Rakudo::Internals::ShapeBranchIterator {
+ has $!iterators;
+ method INIT(\to,\from) {
+ nqp::stmts(
+ self.SET-SELF(to),
+ ($!iterators := nqp::setelems(
+ nqp::list(from.iterator),
+ nqp::add_i($!maxdim,1)
+ )),
+ self
+ )
+ }
+ method new(\to,\from) { nqp::create(self).INIT(to,from) }
+ method done(--> Nil) {
+ nqp::unless( # verify lowest
+ nqp::atpos($!iterators,0).is-lazy # finite iterator
+ || nqp::eqaddr( # and something there
+ nqp::atpos($!iterators,0).pull-one,IterationEnd),
+ nqp::atposnd_#postfix#($!list,$!indices) # boom!
+ )
+ }
+ method process(--> Nil) {
+ nqp::stmts(
+ (my int $i = $!level),
+ nqp::while(
+ nqp::isle_i(($i = nqp::add_i($i,1)),$!maxdim),
+ nqp::if(
+ nqp::eqaddr((my $item := # exhausted ?
+ nqp::atpos($!iterators,nqp::sub_i($i,1)).pull-one),
+ IterationEnd
+ ),
+ nqp::bindpos($!iterators,$i, # add an empty one
+ Rakudo::Internals.EmptyIterator),
+ nqp::if( # is it an iterator?
+ nqp::istype($item,Iterable) && nqp::isconcrete($item),
+ nqp::bindpos($!iterators,$i,$item.iterator),
+ X::Assignment::ToShaped.new(shape => $!dims).throw
+ )
+ )
+ ),
+ (my $iter := nqp::atpos($!iterators,$!maxdim)),
+ nqp::until( # loop over highest dim
+ nqp::eqaddr((my $pulled := $iter.pull-one),IterationEnd)
+ || nqp::isgt_i(nqp::atpos_i($!indices,$!maxdim),$!maxind),
+ nqp::stmts(
+ nqp::bindposnd_#postfix#($!list,$!indices,$pulled),
+ nqp::bindpos_i($!indices,$!maxdim, # increment index
+ nqp::add_i(nqp::atpos_i($!indices,$!maxdim),1))
+ )
+ ),
+ nqp::unless(
+ nqp::eqaddr($pulled,IterationEnd) # if not exhausted
+ || nqp::isle_i( # and index too high
+ nqp::atpos_i($!indices,$!maxdim),$!maxind)
+ || $iter.is-lazy, # and not lazy
+ nqp::atposnd_#postfix#($!list,$!indices) # boom!
+ )
+ )
+ }
+ }.new(self,from).sink-all;
+ self
+ }
} # end of shaped#type#array role
role shaped1#type#array does shaped#type#array {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment