Skip to content
Permalink
Browse files

Standardize use of proto's on .STORE methods

This should make sure there is no inter-class leakage of .STORE candidates.
And perhaps this opens up a way to allow for a default implementation of
.STORE in the Positional / Associative roles.
  • Loading branch information...
lizmat committed Sep 15, 2018
1 parent f1f6825 commit ed9b48de6a55ee39f4574fbf7f476a0d9e6e389e
@@ -264,7 +264,7 @@ my class Array { # declared in BOOTSTRAP
nqp::create(self).STORE(@values)
}

proto method STORE(|) {*}
proto method STORE(Array:D: |) {*}
multi method STORE(Array:D: Iterable:D \iterable) {
nqp::stmts(
(my \buffer = nqp::create(IterationBuffer)),
@@ -755,7 +755,7 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP

# Store in List targets containers with in the list. This handles list
# assignments, like ($a, $b) = foo().
proto method STORE(|) {*}
proto method STORE(List:D: |) {*}
multi method STORE(List:D: Iterable:D \iterable) {
# First pass -- scan lhs containers and pick out scalar versus list
# assignment. This also reifies the RHS values we need, and deconts
@@ -385,7 +385,7 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP
)
}

proto method STORE(|) {*}
proto method STORE(Map:D: |) {*}
multi method STORE(Map:D: Map:D \map, :$initialize) {
nqp::if(
$initialize,
@@ -461,6 +461,7 @@ my class Rakudo::Internals {
self.DEFINITE ?? self!illegal("prepend") !! self.Any::prepend(|c)
}

proto method STORE(::?CLASS:D: |) {*}
multi method STORE(::?CLASS:D: Slip:D \slip) {
nqp::if(
nqp::eqaddr(slip,Empty),
@@ -92,6 +92,7 @@
nqp::bindpos(nqp::getattr(self,List,'$!reified'),one,value)
}

proto method STORE(::?CLASS:D: |) {*}
multi method STORE(::?CLASS:D: ::?CLASS:D \from-array) {
nqp::stmts(
(my \to := nqp::getattr(self,List,'$!reified')),
@@ -288,7 +288,7 @@
}
sub NUMCPY(Mu \to, Mu \from) { NumCopy.new(to,from).sink-all }

proto method STORE(|) {*}
proto method STORE(::?CLASS:D: |) {*}
multi method STORE(::?CLASS:D: ::?CLASS:D \in) {
nqp::if(
in.shape eqv self.shape,
@@ -27,7 +27,7 @@ my class array does Iterable {
!! nqp::create(self)
}

proto method STORE(|) {*}
proto method STORE(array:D: |) {*}
multi method STORE(array:D: *@values) { self.STORE(@values) }

multi method push(array:D: **@values) { self.append(@values) }

0 comments on commit ed9b48d

Please sign in to comment.
You can’t perform that action at this time.