Wow, thats cool! Is it portable between dialects?
Best, Dmitry 2010/10/19, Paolo Bonzini <[email protected]>: > 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 > [email protected] > http://lists.gnu.org/mailman/listinfo/help-smalltalk > _______________________________________________ help-smalltalk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-smalltalk
