Skip to content

Commit

Permalink
Add "code_of_method" and "declares_method" methods
Browse files Browse the repository at this point in the history
to NQPClassHOW.

- declares_method returns 1 if there's a method by that name in
  the method table (effectively wrapping an nqp::existskey)
- code_of_method returns the code object of the method by the given
  name, or nqp::null if there's no method by that name (effectively
  wrapping an nqp::atkey.

This is mostly to provide compatibility with methods by the same
name in Raku's ClassHOW, where the check is a little more involved
thanks to the existence of submethods.  By abstracting the lookup
it will now also be possible to remove a lot of checks for submethod
tables, as they can now be abstracted in methods with these names.
  • Loading branch information
lizmat committed Mar 31, 2024
1 parent 3af1893 commit 1ca2f18
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/how/NQPClassHOW.nqp
Expand Up @@ -808,6 +808,13 @@ knowhow NQPClassHOW {
method method_table($XXX?) { $!methods }
method tweaks($XXX?) { $!tweaks }

method declares_method($XXX, $name) {
nqp::existskey($!methods, $name)
}
method code_of_method($XXX, $name) {
nqp::atkey($!methods, $name)
}

method methods($XXX?, :$local = 0, :$all) {
if $local {
nqp::clone($!method_order)
Expand Down

0 comments on commit 1ca2f18

Please sign in to comment.