Skip to content

Commit

Permalink
.STORE should return self
Browse files Browse the repository at this point in the history
Unfortunately, this doesn't fix the problem of .rotate/.reverse on
1dimmed shaped arrays
  • Loading branch information
lizmat committed Nov 15, 2016
1 parent cd765e6 commit c5d33a2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
17 changes: 11 additions & 6 deletions src/core/Shaped1Array.pm
Expand Up @@ -127,7 +127,8 @@
nqp::atpos($to,$i),
nqp::bindpos($to,$i,nqp::p6scalarfromdesc($desc))
) = nqp::atpos($from,$i)
)
),
self
),
X::Assignment::ArrayShapeMismatch.new(
source-shape => from.shape,
Expand Down Expand Up @@ -159,11 +160,15 @@
)
}
multi method STORE(::?CLASS:D: Mu \item) {
nqp::ifnull(
nqp::atpos(nqp::getattr(self,List,'$!reified'),0),
nqp::bindpos(nqp::getattr(self,List,'$!reified'),0,
nqp::p6scalarfromdesc(nqp::getattr(self,Array,'$!descriptor')))
) = item
nqp::stmts(
(nqp::ifnull(
nqp::atpos(nqp::getattr(self,List,'$!reified'),0),
nqp::bindpos(nqp::getattr(self,List,'$!reified'),0,
nqp::p6scalarfromdesc(
nqp::getattr(self,Array,'$!descriptor')))
) = item),
self
)
}

multi method keys(::?CLASS:D:) {
Expand Down
19 changes: 13 additions & 6 deletions src/core/ShapedArray.pm
Expand Up @@ -322,7 +322,10 @@
multi method STORE(::?CLASS:D: ::?CLASS:D \in) {
nqp::if(
in.shape eqv self.shape && nqp::eqaddr(in.WHAT,self.WHAT),
MEMCPY(self,in), # VM-supported memcpy-like thing?
nqp::stmts(
MEMCPY(self,in), # VM-supported memcpy-like thing?
self
),
X::Assignment::ArrayShapeMismatch.new(
source-shape => in.shape,
target-shape => self.shape
Expand All @@ -332,10 +335,13 @@
multi method STORE(::?CLASS:D: array:D \in) {
nqp::if(
in.shape eqv self.shape,
nqp::if(
nqp::istype(in.of,Int),
INTCPY(self,in), # copy from native int
NUMCPY(self,in) # copy from native num
nqp::stmts(
nqp::if(
nqp::istype(in.of,Int),
INTCPY(self,in), # copy from native int
NUMCPY(self,in) # copy from native num
),
self
),
X::Assignment::ArrayShapeMismatch.new(
source-shape => in.shape,
Expand Down Expand Up @@ -409,7 +415,8 @@
)
)
}
}.new(self,in).sink-all
}.new(self,in).sink-all;
self
}
multi method STORE(::?CLASS:D: Mu \item) {
X::Assignment::ToShaped.new(shape => self.shape).throw
Expand Down

0 comments on commit c5d33a2

Please sign in to comment.