help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] MethodWrapper


From: Gwenaël Casaccio
Subject: Re: [Help-smalltalk] MethodWrapper
Date: Tue, 19 Oct 2010 11:25:19 +0200

Good but  shouldn't we put them in the kernel or a package ?
Also, we shouldn't inherit from CompiledCode (ok
that's a detail) since this is a small patch.

On Tue, Oct 19, 2010 at 11:16 AM, Paolo Bonzini <address@hidden> wrote:
> On 10/19/2010 11:00 AM, Gwenaël Casaccio wrote:
>> Hi,
>>
>> I've made (very) small patch for the VM to support methodWrapper.
>> MethodWrapper are objects used to add behavior before and after
>> the method evaluation.
>>
>> This patch ensure that the vm doesn't cast the object to the class format and
>> thus having wrong ivar offset. It also avoids the method check.
>>
>> It is useful for pre and post conditions, test coverage.
>>
>> You could find the patch at
>>
>> git://github.com/MrGwen/smalltalk.git commit  660a66613e62f8d5236f
>
> This is already supported (see examples/Methods.st), you only need
> to subclass from CompiledMethod (you saw why :)) and create the
> instance with the class method #numArgs:.
>
> The method will be sent #valueWithReceiver:withArguments:.
>
> examples/Methods.st even includes a basic port of MethodWrapper
> itself.  You need this to fix bitrot:
>
> diff --git a/examples/Methods.st b/examples/Methods.st
> index 67bdbcf..d80d9a6 100644
> --- a/examples/Methods.st
> +++ b/examples/Methods.st
> @@ -45,6 +45,7 @@ test
>     "InterpretedMethod test"
>     | b |
>     b := Behavior new.
> +    b superclass: Object.
>     b interpretedMethodAt: #testInterp1 put: #(#push 3 #push 4 #add #return).
>     b interpretedMethodAt: #testInterp2 put: #(#push 6 #push 7 #mul #return).
>     Transcript show: '3 + 4 = '. b new testInterp1 printNl.
>
> Paolo
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]