On 18 Dec 2019, at 14:06, Mehrdad Abdi <newmrd@gmail.com> wrote:
Hello
For a specific method, I need to log some information when the method is called, like the state of the receiver, values of arguments, where the method is called, ... .
Using following MetaLink, Iâm able to capture the receiver and arguments and context.
link := MetaLink new metaObject: self; selector: #linkBeforeMethodArguments:receiver:selector:context:; control: #before; level: 0; arguments: #( arguments receiver selector context ). aMethod := MyClass methodNamed: #myMethodArg1:arg2. aMethod ast link: link
For capturing the information related to where this method is called, It's possible to extract it from Context, but itâs a dirty way. Is there any way to access the MessageNode which called this MethodNode?
No, the information is only available via the context⦠even the #sender reification is internally is compiled to "thisContext sender receiverâ. You could add your own reification (that is a class similar to RFSenderReification and implement your own âsendingMethodNodeâ reification, but this would just make it look nicer, not be different from an implementation point of view⦠Marcus