Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleanup of is rw usage on subs/methods.
Most of them wanted to be "is raw".
Some didn't want anything at all.
In some places "rw" stayed.
Commit poem! Oh, LOL! Well played.
  • Loading branch information
jnthn committed Sep 24, 2015
1 parent 0743bf4 commit ab042e1
Show file tree
Hide file tree
Showing 24 changed files with 252 additions and 252 deletions.
34 changes: 17 additions & 17 deletions src/core/Any-iterable-methods.pm
Expand Up @@ -91,7 +91,7 @@ augment class Any {
has $!NEXT;
has $!CAN_FIRE_PHASERS;

method pull-one() is rw {
method pull-one() is raw {
my int $redo = 1;
my $value;
my $result;
Expand Down Expand Up @@ -204,7 +204,7 @@ augment class Any {
has $!NEXT;
has $!CAN_FIRE_PHASERS;

method pull-one() is rw {
method pull-one() is raw {
$!value-buffer.DEFINITE
?? nqp::setelems($!value-buffer, 0)
!! ($!value-buffer := IterationBuffer.new);
Expand Down Expand Up @@ -274,7 +274,7 @@ augment class Any {
}

proto method flatmap (|) is nodal { * }
multi method flatmap(&block, :$label) is rw {
multi method flatmap(&block, :$label) {
self.map(&block, :$label).flat
}

Expand All @@ -290,12 +290,12 @@ augment class Any {
}

proto method grep(|) is nodal { * }
multi method grep(Bool:D $t) is rw {
multi method grep(Bool:D $t) {
fail X::Match::Bool.new( type => '.grep' );
}
multi method grep(Regex:D $test) is rw {
multi method grep(Regex:D $test) {
Seq.new(class :: does Grepper {
method pull-one() is rw {
method pull-one() is raw {
my Mu $value;
until ($value := $!iter.pull-one) =:= IterationEnd {
return-rw $value if $value.match($!test);
Expand All @@ -311,12 +311,12 @@ augment class Any {
}
}.new(self, $test))
}
multi method grep(Callable:D $test) is rw {
multi method grep(Callable:D $test) {
if ($test.count == 1) {
$test.?has-phasers
?? self.map({ next unless $test($_); $_ }) # cannot go fast
!! Seq.new(class :: does Grepper {
method pull-one() is rw {
method pull-one() is raw {
my Mu $value;
until ($value := $!iter.pull-one) =:= IterationEnd {
return-rw $value if $!test($value);
Expand Down Expand Up @@ -356,9 +356,9 @@ augment class Any {
self.map(&tester);
}
}
multi method grep(Mu $test) is rw {
multi method grep(Mu $test) {
Seq.new(class :: does Grepper {
method pull-one() is rw {
method pull-one() is raw {
my Mu $value;
until ($value := $!iter.pull-one) =:= IterationEnd {
return-rw $value if $!test.ACCEPTS($value);
Expand All @@ -376,7 +376,7 @@ augment class Any {
}

proto method grep-index(|) is nodal { * }
multi method grep-index(Bool:D $t) is rw {
multi method grep-index(Bool:D $t) {
fail X::Match::Bool.new( type => '.grep-index' );
}
multi method grep-index(Regex:D $test) {
Expand Down Expand Up @@ -405,24 +405,24 @@ augment class Any {
}

proto method first(|) is nodal { * }
multi method first(Bool:D $t) is rw {
multi method first(Bool:D $t) {
fail X::Match::Bool.new( type => '.first' );
}
multi method first(Regex:D $test) is rw {
multi method first(Regex:D $test) is raw {
self.map({ return-rw $_ if .match($test) });
Nil;
}
multi method first(Callable:D $test) is rw {
multi method first(Callable:D $test) is raw {
self.map({ return-rw $_ if $test($_) });
Nil;
}
multi method first(Mu $test) is rw {
multi method first(Mu $test) is raw {
self.map({ return-rw $_ if $_ ~~ $test });
Nil;
}

proto method first-index(|) is nodal { * }
multi method first-index(Bool:D $t) is rw {
multi method first-index(Bool:D $t) {
fail X::Match::Bool.new( type => '.first-index' );
}
multi method first-index(Regex:D $test) {
Expand Down Expand Up @@ -451,7 +451,7 @@ augment class Any {
}

proto method last-index(|) is nodal { * }
multi method last-index(Bool:D $t) is rw {
multi method last-index(Bool:D $t) {
fail X::Match::Bool.new( type => '.last-index' );
}
multi method last-index(Regex:D $test) {
Expand Down
40 changes: 20 additions & 20 deletions src/core/Any.pm
Expand Up @@ -145,9 +145,9 @@ my class Any { # declared in BOOTSTRAP
method join($separator = '') is nodal { self.list.join($separator) }

# XXX GLR should move these
method nodemap(&block) is rw is nodal { nodemap(&block, self) }
method duckmap(&block) is rw is nodal { duckmap(&block, self) }
method deepmap(&block) is rw is nodal { deepmap(&block, self) }
method nodemap(&block) is nodal { nodemap(&block, self) }
method duckmap(&block) is nodal { duckmap(&block, self) }
method deepmap(&block) is nodal { deepmap(&block, self) }

# XXX GLR Do we need tree post-GLR?
proto method tree(|) is nodal { * }
Expand Down Expand Up @@ -185,7 +185,7 @@ my class Any { # declared in BOOTSTRAP

proto method EXISTS-POS(|) is nodal { * }
multi method EXISTS-POS(Any:U: Any:D $) { False }
multi method EXISTS-POS(Any:U: Any:U $pos) is rw {
multi method EXISTS-POS(Any:U: Any:U $pos) {
die "Cannot use '{$pos.^name}' as an index";
}

Expand Down Expand Up @@ -217,49 +217,49 @@ my class Any { # declared in BOOTSTRAP
}

proto method AT-POS(|) is nodal {*}
multi method AT-POS(Any:U \SELF: int \pos) is rw {
multi method AT-POS(Any:U \SELF: int \pos) is raw {
nqp::bindattr(my $v, Scalar, '$!whence',
-> { SELF.defined || (SELF = Array.new);
SELF.BIND-POS(pos, $v) });
$v
}
multi method AT-POS(Any:U \SELF: Int:D \pos) is rw {
multi method AT-POS(Any:U \SELF: Int:D \pos) is raw {
nqp::bindattr(my $v, Scalar, '$!whence',
-> { SELF.defined || (SELF = Array.new);
SELF.BIND-POS(nqp::unbox_i(pos), $v) });
$v
}
multi method AT-POS(Any:U: Num:D \pos) is rw {
multi method AT-POS(Any:U: Num:D \pos) is raw {
fail X::Item.new(aggregate => self, index => pos)
if nqp::isnanorinf(pos);
self.AT-POS(nqp::unbox_i(pos.Int));
}
multi method AT-POS(Any:U: Any:D \pos) is rw {
multi method AT-POS(Any:U: Any:D \pos) is raw {
self.AT-POS(nqp::unbox_i(pos.Int));
}

multi method AT-POS(Any:D: int \pos) is rw {
multi method AT-POS(Any:D: int \pos) is raw {
fail X::OutOfRange.new(:what<Index>, :got(pos), :range<0..0>)
unless nqp::not_i(pos);
self;
}
multi method AT-POS(Any:D: Int:D \pos) is rw {
multi method AT-POS(Any:D: Int:D \pos) is raw {
fail X::OutOfRange.new(:what<Index>, :got(pos), :range<0..0>)
if pos != 0;
self;
}
multi method AT-POS(Any:D: Num:D \pos) is rw {
multi method AT-POS(Any:D: Num:D \pos) is raw {
fail X::Item.new(aggregate => self, index => pos)
if nqp::isnanorinf(pos);
self.AT-POS(nqp::unbox_i(pos.Int));
}
multi method AT-POS(Any:D: Any:D \pos) is rw {
multi method AT-POS(Any:D: Any:D \pos) is raw {
self.AT-POS(nqp::unbox_i(pos.Int));
}
multi method AT-POS(Any: Any:U \pos) is rw {
multi method AT-POS(Any: Any:U \pos) is raw {
die "Cannot use '{pos.^name}' as an index";
}
multi method AT-POS(**@indices) is rw {
multi method AT-POS(**@indices) is raw {
my $result := self;
for @indices {
$result := $result.AT-POS($_);
Expand Down Expand Up @@ -300,7 +300,7 @@ my class Any { # declared in BOOTSTRAP
}

proto method BIND-POS(|) { * }
multi method BIND-POS(Any:D: **@indices is raw) {
multi method BIND-POS(Any:D: **@indices is raw) is raw {
my int $elems = @indices.elems;
my \value := @indices.AT-POS($elems - 1);
my $final := @indices.AT-POS($elems - 2);
Expand All @@ -320,33 +320,33 @@ my class Any { # declared in BOOTSTRAP

# internals
proto method AT-KEY(|) is nodal { * }
multi method AT-KEY(Any:D: $key) is rw {
multi method AT-KEY(Any:D: $key) is raw {
if self ~~ Associative {
fail "Associative indexing implementation missing from type {self.WHAT.perl}";
}
else {
fail "Type {self.WHAT.perl} does not support associative indexing.";
}
}
multi method AT-KEY(Any:U \SELF: $key) is rw {
multi method AT-KEY(Any:U \SELF: $key) is raw {
nqp::bindattr(my $v, Scalar, '$!whence',
-> { SELF.defined || (SELF = Hash.new);
SELF.BIND-KEY($key, $v) });
$v
}

proto method BIND-KEY(|) is nodal { * }
multi method BIND-KEY(Any:D: \k, \v) is rw {
multi method BIND-KEY(Any:D: \k, \v) is raw {
fail X::Bind.new(target => self.^name);
}
multi method BIND-KEY(Any:U \SELF: $key, $BIND ) is rw {
multi method BIND-KEY(Any:U \SELF: $key, $BIND ) is raw {
SELF = Hash.new;
SELF.BIND-KEY($key, $BIND);
$BIND
}

proto method ASSIGN-KEY(|) is nodal { * }
multi method ASSIGN-KEY(\SELF: \key, Mu \assignee) {
multi method ASSIGN-KEY(\SELF: \key, Mu \assignee) is raw {
SELF.AT-KEY(key) = assignee;
}

Expand Down
40 changes: 20 additions & 20 deletions src/core/Array.pm
Expand Up @@ -86,11 +86,11 @@ my class Array { # declared in BOOTSTRAP
my role ShapedArray[::TValue] does Positional[TValue] {
has $.shape;

proto method AT-POS(|) is rw {*}
multi method AT-POS(Array:U: |c) is rw {
proto method AT-POS(|) is raw {*}
multi method AT-POS(Array:U: |c) is raw {
self.Any::AT-POS(|c)
}
multi method AT-POS(Array:D: **@indices) is rw {
multi method AT-POS(Array:D: **@indices) is raw {
my Mu $storage := nqp::getattr(self, List, '$!reified');
my int $numdims = nqp::numdimensions($storage);
my int $numind = @indices.elems;
Expand All @@ -114,11 +114,11 @@ my class Array { # declared in BOOTSTRAP
}
}

proto method ASSIGN-POS(|) is rw {*}
multi method ASSIGN-POS(Array:U: |c) is rw {
proto method ASSIGN-POS(|) {*}
multi method ASSIGN-POS(Array:U: |c) {
self.Any::ASSIGN-POS(|c)
}
multi method ASSIGN-POS(**@indices) is rw {
multi method ASSIGN-POS(**@indices) {
my \value = @indices.pop;
my Mu $storage := nqp::getattr(self, List, '$!reified');
my int $numdims = nqp::numdimensions($storage);
Expand Down Expand Up @@ -184,7 +184,7 @@ my class Array { # declared in BOOTSTRAP
}
}

proto method DELETE-POS(|) is rw {*}
proto method DELETE-POS(|) {*}
multi method DELETE-POS(Array:U: |c) {
self.Any::DELETE-POS(|c)
}
Expand Down Expand Up @@ -217,11 +217,11 @@ my class Array { # declared in BOOTSTRAP
}
}

proto method BIND-POS(|) is rw {*}
multi method BIND-POS(Array:U: |c) is rw {
proto method BIND-POS(|) is raw {*}
multi method BIND-POS(Array:U: |c) is raw {
self.Any::BIND-POS(|c)
}
multi method BIND-POS(**@indices is raw) is rw {
multi method BIND-POS(**@indices is raw) is raw {
my Mu $storage := nqp::getattr(self, List, '$!reified');
my int $numdims = nqp::numdimensions($storage);
my int $numind = @indices.elems - 1;
Expand Down Expand Up @@ -392,22 +392,22 @@ my class Array { # declared in BOOTSTRAP

method shape() { (*,) }

multi method AT-POS(Array:D: int $ipos) is rw {
multi method AT-POS(Array:D: int $ipos) is raw {
my Mu \reified := nqp::getattr(self, List, '$!reified');
reified.DEFINITE && $ipos < nqp::elems(reified) && $ipos >= 0
?? nqp::ifnull(nqp::atpos(reified, $ipos),
self!AT-POS-SLOWPATH($ipos))
!! self!AT-POS-SLOWPATH($ipos)
}
multi method AT-POS(Array:D: Int:D $pos) is rw {
multi method AT-POS(Array:D: Int:D $pos) is raw {
my int $ipos = nqp::unbox_i($pos);
my Mu \reified := nqp::getattr(self, List, '$!reified');
reified.DEFINITE && $ipos < nqp::elems(reified) && $ipos >= 0
?? nqp::ifnull(nqp::atpos(reified, $ipos),
self!AT-POS-SLOWPATH($ipos))
!! self!AT-POS-SLOWPATH($ipos)
}
method !AT-POS-SLOWPATH(int $ipos) is rw {
method !AT-POS-SLOWPATH(int $ipos) is raw {
fail X::OutOfRange.new(:what<Index>,:got($ipos),:range<0..Inf>)
if nqp::islt_i($ipos, 0);
self!ensure-allocated();
Expand All @@ -426,7 +426,7 @@ my class Array { # declared in BOOTSTRAP
!! value
}

multi method ASSIGN-POS(Array:D: int $ipos, Mu \assignee) is rw {
multi method ASSIGN-POS(Array:D: int $ipos, Mu \assignee) {
X::OutOfRange.new(:what<Index>,:got($ipos),:range<0..Inf>).throw
if nqp::islt_i($ipos, 0);
my Mu \reified := nqp::getattr(self, List, '$!reified');
Expand All @@ -436,7 +436,7 @@ my class Array { # declared in BOOTSTRAP
!! (nqp::atpos(reified, $ipos) = assignee)
!! self!ASSIGN-POS-SLOWPATH($ipos, assignee)
}
multi method ASSIGN-POS(Array:D: Int:D $pos, Mu \assignee) is rw {
multi method ASSIGN-POS(Array:D: Int:D $pos, Mu \assignee) {
my int $ipos = nqp::unbox_i($pos);
X::OutOfRange.new(:what<Index>,:got($pos),:range<0..Inf>).throw
if nqp::islt_i($ipos, 0);
Expand All @@ -447,7 +447,7 @@ my class Array { # declared in BOOTSTRAP
!! (nqp::atpos(reified, $ipos) = assignee)
!! self!ASSIGN-POS-SLOWPATH($ipos, assignee)
}
method !ASSIGN-POS-SLOWPATH(int $ipos, Mu \assignee) is rw {
method !ASSIGN-POS-SLOWPATH(int $ipos, Mu \assignee) {
fail X::OutOfRange.new(:what<Index>,:got($ipos),:range<0..Inf>)
if nqp::islt_i($ipos, 0);
self!ensure-allocated();
Expand All @@ -461,14 +461,14 @@ my class Array { # declared in BOOTSTRAP
!! (nqp::atpos(reified, $ipos) = assignee)
}

multi method BIND-POS(Int $pos, Mu \bindval) is rw {
multi method BIND-POS(Int $pos, Mu \bindval) is raw {
self!ensure-allocated();
my int $ipos = $pos;
my $todo := nqp::getattr(self, List, '$!todo');
$todo.reify-at-least($ipos + 1) if $todo.DEFINITE;
nqp::bindpos(nqp::getattr(self, List, '$!reified'), $ipos, bindval);
}
multi method BIND-POS(int $pos, Mu \bindval) is rw {
multi method BIND-POS(int $pos, Mu \bindval) is raw {
self!ensure-allocated();
my $todo := nqp::getattr(self, List, '$!todo');
$todo.reify-at-least($pos + 1) if $todo.DEFINITE;
Expand Down Expand Up @@ -744,13 +744,13 @@ my class Array { # declared in BOOTSTRAP
arr.STORE(@values);
arr
}
multi method BIND-POS(Int $pos, TValue \bindval) is rw {
multi method BIND-POS(Int $pos, TValue \bindval) is raw {
my int $ipos = $pos;
my $todo := nqp::getattr(self, List, '$!todo');
$todo.reify-at-least($ipos + 1) if $todo.DEFINITE;
nqp::bindpos(nqp::getattr(self, List, '$!reified'), $ipos, bindval)
}
multi method BIND-POS(int $pos, TValue \bindval) is rw {
multi method BIND-POS(int $pos, TValue \bindval) is raw {
my $todo := nqp::getattr(self, List, '$!todo');
$todo.reify-at-least($pos + 1) if $todo.DEFINITE;
nqp::bindpos(nqp::getattr(self, List, '$!reified'), $pos, bindval)
Expand Down

0 comments on commit ab042e1

Please sign in to comment.