[squeak-dev] Debugger / Simulator cannot simulate (some) objects as methods

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Thu Oct 22 17:28:42 UTC 2020


Hi Christian, hi all,


I already implemented the simulation of objects as methods in Kernel-ct.1339 (Inbox). It has been working fine for me since February - we only need to get things like this merged sooner to prevent everyone from reinventing the wheel. :-)


Best,

Christoph

<http://www.hpi.de/>
________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Eliot Miranda <eliot.miranda at gmail.com>
Gesendet: Mittwoch, 21. Oktober 2020 16:59:06
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] Debugger / Simulator cannot simulate (some) objects as methods

Hi,

> On Oct 21, 2020, at 6:09 AM, cmfcmf <cmfcmf.flach at gmail.com> wrote:
>
> Hi,
>
> when using simple objects as methods, the simulator (and therefore the
> debugger also) raises an error if the object used as method does not
> implement certain methods from CompiledMethod (e.g., numArgs). If such code
> is debugged, the debugger opens a never-ending stream of error windows.
>
> I am under the (possibly wrong) assumption that objects as methods should
> _not_ need to implement the complete CompiledMethod protocol to be
> compatible with simulation and debugging.

Since the only gap that needs filling is from the retrieval of the object from the method dictionary to the send of run:asMethod:withAruuments: (or whatever the actual selector is) let me suggest that you create a wrapper class whose instances hold on to an object to be run as a method and the selector and argument count and respond to the required CompiledCode protocol.  Then modify the simulator at the point where it gets the result of the message lookup from the dictionary and wraps the result in one of these if it is neither CompiledCode (isCompiledCode) not nil. We don’t want to litter the simulation code with checks and the wrapper approach has the best chance.

Of course another test will be needed before a new contest is created, and maybe one test at the top of the tryPrimitive: method.

>
> I have attached a failing test called Context2Test that uses the simulator
> to simulate a call of an object as method. You can also see the
> "never-ending stream of error windows" by placing a "self halt" at the top
> of the test and then stepping through the first assertion using the "over"
> button. WARNING: Might make your image unusable.
>
> The root cause is the Context >> #send:to:with:lookupIn: method which
> assumes that all methods are CompiledMethods. I have attached a simple fix
> that works great for me – let me know what you think about it.
>
> Best
> Christian
>
> Context2Test.st <http://forum.world.st/file/t372201/Context2Test.st>
> Context-sendtowithlookupIn.st
> <http://forum.world.st/file/t372201/Context-sendtowithlookupIn.st>
>
>
>
> --
> Sent from: http://forum.world.st/Squeak-Dev-f45488.html
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201022/33d60296/attachment-0001.html>


More information about the Squeak-dev mailing list