instance of a block context from #mustBeBoolean (was: Re: source code of a block context)

Marcus Denker denker at iam.unibe.ch
Thu Aug 11 08:23:39 UTC 2005


Am 11.08.2005 um 04:50 schrieb Rob Withers:

> Hi,
>
> I have a related question, that I have been recently struggling  
> with.   Short of removing the ifTrue:ifFalse: bytecodes from the VM  
> and the compiler, I am trying to write a #mustBeBoolean method and  
> find the boolean protocol sent (#ifTrue:) and the block.  Then I am  
> going to resend it with #perform:with:.  I reached through the  
> methodNode and got the selector.  I can't find the block argument,  
> however.  Is it lost because the #mustBeBoolean overwrote the frame  
> for #ifTrue:?

there is no frame for ifTrue:, we inline ifTrue to jumps because we  
then don't need a frame.

> Can I re-instatiate it in the context of ctx?  Of course, there is  
> no guarantee that that context is where the block was created.
>
> Here's my method, so far:
>
> mustBeBoolean
>     | ctx msgNode sel |
>     ctx := thisContext sender.
>     msgNode := ctx methodNode block statements at: ctx stackPtr.

Is this mapping valid? stackPtr --> statement in the method that is
executed. Why should it?

>     sel := msgNode selector key.
>     ^ context
>         redirectMessage: (MessageSend
>         receiver: nil
>         selector: sel
>         arguments: (Array with: [])).

    Marcus



More information about the Squeak-dev mailing list