Skip to content

Commit 05b7f78

Browse files
committed
Implement .^shortname in NQP MOP.
1 parent bf7b9bb commit 05b7f78

File tree

6 files changed

+30
-0
lines changed

6 files changed

+30
-0
lines changed

src/how/NQPClassHOW.nqp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,11 @@ knowhow NQPClassHOW {
636636
$!name
637637
}
638638

639+
method shortname($obj) {
640+
my @parts := nqp::split('::', self.name($obj) // '');
641+
@parts ?? @parts[nqp::elems(@parts) - 1] !! '<anon>'
642+
}
643+
639644
method traced($obj) {
640645
$!trace
641646
}

src/how/NQPConcreteRoleHOW.nqp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ knowhow NQPConcreteRoleHOW {
143143
$!name
144144
}
145145

146+
method shortname($obj) {
147+
my @parts := nqp::split('::', self.name($obj) // '');
148+
@parts ?? @parts[nqp::elems(@parts) - 1] !! '<anon>'
149+
}
150+
146151
method attributes($obj, :$local) {
147152
my @attrs;
148153
for @!attributes {

src/how/NQPCurriedRoleHOW.nqp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ knowhow NQPCurriedRoleHOW {
3030
method name($obj) {
3131
$!curried_role.HOW.name($!curried_role)
3232
}
33+
34+
method shortname($obj) {
35+
my @parts := nqp::split('::', self.name($obj) // '');
36+
@parts ?? @parts[nqp::elems(@parts) - 1] !! '<anon>'
37+
}
3338

3439
method curried_role($obj) {
3540
$!curried_role

src/how/NQPModuleHOW.nqp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ knowhow NQPModuleHOW {
5050
method name($obj) {
5151
$!name
5252
}
53+
54+
method shortname($obj) {
55+
my @parts := nqp::split('::', self.name($obj) // '');
56+
@parts ?? @parts[nqp::elems(@parts) - 1] !! '<anon>'
57+
}
5358
}

src/how/NQPNativeHOW.nqp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,9 @@ knowhow NQPNativeHOW {
4545
method name($obj) {
4646
$!name
4747
}
48+
49+
method shortname($obj) {
50+
my @parts := nqp::split('::', self.name($obj) // '');
51+
@parts ?? @parts[nqp::elems(@parts) - 1] !! '<anon>'
52+
}
4853
}

src/how/NQPParametricRoleHOW.nqp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ knowhow NQPParametricRoleHOW {
182182
$!name
183183
}
184184

185+
method shortname($obj) {
186+
my @parts := nqp::split('::', self.name($obj) // '');
187+
@parts ?? @parts[nqp::elems(@parts) - 1] !! '<anon>'
188+
}
189+
185190
method attributes($obj, :$local) {
186191
my @attrs;
187192
for @!attributes {

0 commit comments

Comments
 (0)