help-smalltalk
[Top][All Lists]
Advanced

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

Re: [Help-smalltalk] MethodWrapper


From: Dmitry Matveev
Subject: Re: [Help-smalltalk] MethodWrapper
Date: Tue, 19 Oct 2010 13:53:04 +0400

Wow, thats cool!

Is it portable between dialects?

Best,
Dmitry

2010/10/19, Paolo Bonzini <address@hidden>:
> 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
>
> _______________________________________________
> help-smalltalk mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-smalltalk
>



reply via email to

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