[squeak-dev] Detecting DNU sent by VM, not by code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Detecting DNU sent by VM, not by code

Igor Stasenko
Hello list,
is there any way to detect that DNU message was sent by VM , as result
of failed method lookup, not intentionally by language side?

I need to have a pseudo-class which intercepts _any_ message you
sending to its instance, including #doesNotUnderstood: sent directly
by language side.
Of course, i can't do anything with messages which handled directly by
VM , such as #class , but at least i want to make sure that rest of
messages is intercepted with guarantee.


--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Detecting DNU sent by VM, not by code

Michael van der Gulik-2


On Mon, Nov 24, 2008 at 2:08 PM, Igor Stasenko <[hidden email]> wrote:
Hello list,
is there any way to detect that DNU message was sent by VM , as result
of failed method lookup, not intentionally by language side?

I need to have a pseudo-class which intercepts _any_ message you
sending to its instance, including #doesNotUnderstood: sent directly
by language side.
Of course, i can't do anything with messages which handled directly by
VM , such as #class , but at least i want to make sure that rest of
messages is intercepted with guarantee.


Spoon has one of these; it involves VM modifications. Craig made a *special* class that the VM is aware of, which captures any message sent to it. I believe it'll capture every sent message.

Otherwise, it might be possible to kludge together a message catcher which uses various techniques to detect special messages sent to it. I remember doing something like that to catch >>ifTrue: and friends somehow using exceptions (I forget). You could probably detect #doesNotUnderstand: by determining whether the sender actually sent #doesNotUnderstand: explicitely somehow by looking at thisContext and tracing back to see what the sent selector was.

Gulik.

--
http://people.squeakfoundation.org/person/mikevdg
http://gulik.pbwiki.com/

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Detecting DNU sent by VM, not by code

Igor Stasenko
In reply to this post by Igor Stasenko
i think i found the way..

AlmostTransparentProxy class>>new

   | anonClass |
   anonClass := self clone.
   anonClass superClass: self ; methodDict: nil.
   ^ anonClass basicNew

Then if i do:

proxy := AlmostTransparentProxy new.

on any message i sending to proxy, i'll get #cannotInterpret: message.
And event if you send #cannotInterpret: from language,
it will receive #cannotInterpret: with message selector == #cannotInterpret:  :)


2008/11/24 Igor Stasenko <[hidden email]>:

> Hello list,
> is there any way to detect that DNU message was sent by VM , as result
> of failed method lookup, not intentionally by language side?
>
> I need to have a pseudo-class which intercepts _any_ message you
> sending to its instance, including #doesNotUnderstood: sent directly
> by language side.
> Of course, i can't do anything with messages which handled directly by
> VM , such as #class , but at least i want to make sure that rest of
> messages is intercepted with guarantee.
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>


--
Best regards,
Igor Stasenko AKA sig.