From 1ca2f18b7620425b29f493638bf1b1edd3dc939c Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Sun, 31 Mar 2024 16:05:07 +0200 Subject: [PATCH] Add "code_of_method" and "declares_method" methods 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. --- src/how/NQPClassHOW.nqp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/how/NQPClassHOW.nqp b/src/how/NQPClassHOW.nqp index 2b437c3d6..cbff6ed38 100644 --- a/src/how/NQPClassHOW.nqp +++ b/src/how/NQPClassHOW.nqp @@ -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)