Browse files

Make @a.VAR.name and %h.VAR.name work

  • Loading branch information...
1 parent 38a0f9a commit 283f763a5e670e66951ec837a761088f26e9cad9 @lizmat lizmat committed Aug 26, 2013
Showing with 13 additions and 4 deletions.
  1. +6 −2 src/core/Array.pm
  2. +7 −2 src/core/Hash.pm
View
8 src/core/Array.pm
@@ -9,7 +9,7 @@ class Array { # declared in BOOTSTRAP
nqp::shift($args);
nqp::p6list($args, self.WHAT, Bool::True);
}
-
+
multi method at_pos(Array:D: $pos) is rw {
#?if jvm
if nqp::istype($pos, Num) && nqp::isnanorinf($pos) {
@@ -87,6 +87,11 @@ class Array { # declared in BOOTSTRAP
method flattens() { 1 }
+ # introspection
+ method name() {
+ my $d := $!descriptor;
+ nqp::isnull($d) ?? Str !! $d.name()
+ }
method of() {
my $d := $!descriptor;
nqp::isnull($d) ?? Mu !! $d.of;
@@ -99,7 +104,6 @@ class Array { # declared in BOOTSTRAP
my $d := $!descriptor;
nqp::isnull($d) ?? Mu !! so $d.dynamic;
}
-
multi method perl(Array:D \SELF:) {
nqp::iscont(SELF)
?? '[' ~ self.map({.perl}).join(', ') ~ ']'
View
9 src/core/Hash.pm
@@ -9,8 +9,7 @@ my class Hash { # declared in BOOTSTRAP
%h.STORE(@args) if @args;
%h;
}
- method keyof () { Any }
-
+
multi method at_key(Hash:D: $key is copy) is rw {
my Mu $storage := nqp::defined(nqp::getattr(self, EnumMap, '$!storage')) ??
nqp::getattr(self, EnumMap, '$!storage') !!
@@ -77,6 +76,12 @@ my class Hash { # declared in BOOTSTRAP
self
}
+ # introspection
+ method name() {
+ my $d := $!descriptor;
+ nqp::isnull($d) ?? Str !! $d.name()
+ }
+ method keyof () { Any }
method of() {
my $d := $!descriptor;
nqp::isnull($d) ?? Mu !! $d.of;

0 comments on commit 283f763

Please sign in to comment.