Skip to content
Permalink
Browse files

Added .name methods for several autovivification classes

Fixes R#2361 . But could probably still use some further investigation
improvement for some classes, as it appeared to be impossible to get
at the name of the target.
  • Loading branch information...
lizmat committed Oct 10, 2018
1 parent 8c3a413 commit bf10f4c52c66918f9084bff1f80b80120d956b3c
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/Perl6/Metamodel/BOOTSTRAP.nqp
@@ -1182,6 +1182,7 @@ class ContainerDescriptor::BindArrayPos does ContainerDescriptor::Whence {
$self
}

method name() { self.next.name ~ '[' ~ $!pos ~ ']' }
method assigned($scalar) {
nqp::bindpos($!target, $!pos, $scalar);
}
@@ -1204,6 +1205,9 @@ class ContainerDescriptor::BindArrayPos2D does ContainerDescriptor::Whence {
$self
}

method name() {
'element at [' ~ $!one ~ ',' ~ $!two ~ ']' # XXX name ?
}
method assigned($scalar) {
nqp::bindpos2d($!target, $!one, $!two, $scalar);
}
@@ -1229,6 +1233,9 @@ class ContainerDescriptor::BindArrayPos3D does ContainerDescriptor::Whence {
$self
}

method name() {
'element at [' ~ $!one ~ ',' ~ $!two ~ ',' ~ $!three ~ ']'
}
method assigned($scalar) {
nqp::bindpos3d($!target, $!one, $!two, $!three, $scalar);
}
@@ -1248,6 +1255,7 @@ class ContainerDescriptor::BindArrayPosND does ContainerDescriptor::Whence {
$self
}

method name() { 'element of ' ~ self.next.name } # XXX show indexes
method assigned($scalar) {
nqp::bindposnd($!target, $!idxs, $scalar);
}
@@ -1267,6 +1275,7 @@ class ContainerDescriptor::BindHashPos does ContainerDescriptor::Whence {
$self
}

method name() { self.next.name ~ "\{'" ~ $!key ~ "'\}" }
method assigned($scalar) {
my $hash := nqp::getattr($!target, Map, '$!storage');
$hash := nqp::bindattr($!target, Map, '$!storage', nqp::hash())
@@ -1295,6 +1304,7 @@ class ContainerDescriptor::BindObjHashKey does ContainerDescriptor::Whence {
$self
}

method name() { 'element of ' ~ self.next.name } # XXX correct key
method assigned($scalar) {
my $hash := nqp::getattr($!target, Map, '$!storage');
$hash := nqp::bindattr($!target, Map, '$!storage', nqp::hash())
@@ -1315,6 +1325,7 @@ class ContainerDescriptor::VivifyArray does ContainerDescriptor::Whence {
$self
}

method name() { self.next.name ~ '[' ~ $!pos ~ ']' }
method assigned($scalar) {
my $target := $!target;
my $array := nqp::isconcrete($target)
@@ -1336,6 +1347,7 @@ class ContainerDescriptor::VivifyHash does ContainerDescriptor::Whence {
$self
}

method name() { self.next.name ~ "\{'" ~ $!key ~ "'\}" }
method assigned($scalar) {
my $target := $!target;
my $array := nqp::isconcrete($target)

0 comments on commit bf10f4c

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