Check if CompiledMethod sends to self
Hi everyone. I need to check if a method sends anything to self. There is a method #sendsToSuper, but I donât really know how can I search for self reference in a same way. Can anybody suggest me where can I learn this? Cheers. Uko
On Thu, Mar 20, 2014 at 10:45 AM, Yuriy Tymchuk <yuriy.tymchuk@me.com>wrote:
Hi everyone.
I need to check if a method sends anything to self. There is a method #sendsToSuper, but I don't really know how can I search for self reference in a same way. Can anybody suggest me where can I learn this?
(This below is for Squeak, but probably applies to Pharo too). You /could/ try and use InstructionStream. There's a problem here. For 0-argument sends the problem is simple; simply scan for anInstructionStream willSend following a pushSelf. But with N-argument sends, argument marshalling bytecodes occur between the pushSelf and the send bytecode. So you could look at classes such as BlockLocalTempCounter, ClosureExtractor, InstVarRefLocator that implement specific scanning patterns. The idea is to model the stack, e.g. pushing true on a stack whenever the scanner responds to pushSelf, and pushing false when pushing anything else. Then when encountering a send it checks for true on the stack. HTH, Eliot
On 20 Mar 2014, at 18:45, Yuriy Tymchuk <yuriy.tymchuk@me.com> wrote:
Hi everyone.
I need to check if a method sends anything to self. There is a method #sendsToSuper, but I donât really know how can I search for self reference in a same way. Can anybody suggest me where can I learn this?
I did something like that with Alex :) The code is here: http://smalltalkhub.com/#!/~BenjaminVanRyseghem/PrivacyChecker/ You can have a look at the class SelfSendCollector. Basically it creates the AST of the method, and visit it to collect the self sends Hope it helps, Ben
participants (3)
-
Benjamin -
Eliot Miranda -
Yuriy Tymchuk