Skip to content

Commit

Permalink
uintify the Array::Shaped3 role
Browse files Browse the repository at this point in the history
This is mostly about showing intent.  The actual bounds checking
is actually done inside of the shaped array machinery.
  • Loading branch information
lizmat committed Feb 13, 2022
1 parent 3e89b30 commit 96cbc2b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core.c/Array/Shaped3.pm6
@@ -1,5 +1,5 @@
my role Array::Shaped3 does Array::Shaped {
multi method AT-POS(::?CLASS:D: int $one, int $two, int $three) is raw {
multi method AT-POS(::?CLASS:D: uint $one, uint $two, uint $three) is raw {
nqp::ifnull(
nqp::atpos3d(nqp::getattr(self,List,'$!reified'),$one,$two,$three),
AT-POS-CONTAINER(self, $one, $two, $three)
Expand All @@ -13,7 +13,7 @@ my role Array::Shaped3 does Array::Shaped {
AT-POS-CONTAINER(self, $one, $two, $three)
)
}
sub AT-POS-CONTAINER(\array, int $one, int $two, int $three) is raw {
sub AT-POS-CONTAINER(\array, uint $one, uint $two, uint $three) is raw {
nqp::p6scalarfromdesc(
ContainerDescriptor::BindArrayPos3D.new(
nqp::getattr(array,Array,'$!descriptor'),
Expand All @@ -24,7 +24,7 @@ my role Array::Shaped3 does Array::Shaped {
}

multi method ASSIGN-POS(::?CLASS:D:
int $one, int $two, int $three, \value
uint $one, uint $two, uint $three, \value
) {
my \reified := nqp::getattr(self,List,'$!reified');
nqp::ifnull(
Expand All @@ -45,7 +45,7 @@ my role Array::Shaped3 does Array::Shaped {
}

multi method EXISTS-POS(::?CLASS:D:
int $one, int $two, int $three
uint $one, uint $two, uint $three
--> Bool:D) {
my \reified := nqp::getattr(self,List,'$!reified');
my \dims := nqp::dimensions(reified);
Expand Down Expand Up @@ -74,7 +74,7 @@ my role Array::Shaped3 does Array::Shaped {
}

multi method DELETE-POS(::?CLASS:D:
int $one, int $two, int $three
uint $one, uint $two, uint $three
) is raw {
my \reified := nqp::getattr(self,List,'$!reified');
nqp::if(
Expand All @@ -100,7 +100,9 @@ my role Array::Shaped3 does Array::Shaped {
)
}

multi method BIND-POS(::?CLASS:D: int $one, int $two, int $three, \value) {
multi method BIND-POS(::?CLASS:D:
uint $one, uint $two, uint $three, \value
) {
nqp::bindpos3d(
nqp::getattr(self,List,'$!reified'),$one,$two,$three,value
)
Expand Down

0 comments on commit 96cbc2b

Please sign in to comment.