I cannot believe it but it seems to work. I would really appreaciate if someone can take a look, and consider to integrate it. <br>Having no way to execute a method on a receveir WITHOUT sending a message to the object, is really a problem. I am implementing proxies, which understand NOTHING (their class has method dictionary in nil and I use the cannotInterpret trick) and so I CANNOT send a message because I will be in loop. I have a similar problem with primitiveChangeClassTo: but fortunately, Eliot did #adoptInstance: which receiver is the class and not the object. <br>
<br>Anyway, this is the method <br><br>CompiledMethod >> executeWithReceiver: aReceiver arguments: anArray <br> "Execute the compiledMethod against the aReceiver and args in argArray."<br><br><primitive: 190><br>
self primitiveFailed<br><br><br>And this is the primitive. <br><br><br>StackInterpreterPrimitives >> primitiveExecuteWithReceiverArguments<br> "method, recevier, and the array of arguments are on top of stack. Execute method against receiver and args.<br>
Set primitiveFunctionPointer because no cache lookup has been done for the method, and<br> hence primitiveFunctionPointer is stale."<br> | receiverMethod argCnt argumentArray primitiveIndex receiverObject |<br>
receiverMethod := self stackValue: 2.<br> receiverObject := self stackValue: 1.<br> argumentArray := self stackTop.<br> ((objectMemory isOopCompiledMethod: receiverMethod)<br> and: [objectMemory isArray: argumentArray]) ifFalse:<br>
[^self primitiveFailFor: PrimErrBadArgument].<br> argCnt := self argumentCountOf: receiverMethod.<br> argCnt = (objectMemory fetchWordLengthOf: argumentArray) ifFalse:<br> [^self primitiveFailFor: PrimErrBadNumArgs].<br>
self pop: 3.<br> self push: receiverObject.<br> 0 to: argCnt - 1 do:<br> [:i|<br> self push: (objectMemory fetchPointer: i ofObject: argumentArray)].<br> newMethod := receiverMethod.<br> primitiveIndex := self primitiveIndexOf: newMethod.<br>
primitiveFunctionPointer := self functionPointerFor: primitiveIndex inClass: nil.<br> argumentCount := argCnt.<br> "We set the messageSelector for executeMethod below since things<br> like the at cache read messageSelector and so it cannot be left stale."<br>
messageSelector := objectMemory nilObject.<br> self executeNewMethod.<br> "Recursive xeq affects primErrorCode"<br> self initPrimCall<br><br><br>Thanks for taking a look and hopefully integrate this or something better,<br>
<br>Mariano<br><br><br><div class="gmail_quote">On Wed, Apr 20, 2011 at 2:42 PM, Andreas Raab <span dir="ltr"><<a href="mailto:andreas.raab@gmx.de">andreas.raab@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On 4/20/2011 14:29, Mariano Martinez Peck wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
CompiledMethod >> valueWithReceiver: aReceiver arguments: anArray<br>
"Execute compiledMethod against the receiver and args in argArray. The receiver is the CompiledMethod"<br>
<br>
<primitive: 666><br>
self primitiveFailed<br>
<br>
<br>
Where the primitive is send directly, and not a message to the receiver.<br>
<br>
Is something like this available or I would need to create a new primitive?<br>
</blockquote>
<br></div>
Which by the way, is the primitive that should exist, and Object>>withArgs:executeMethod: should be nuked ASAP. There is no reason to pollute the Object namespace any more than absolutely necessary.<br>
<br>
Cheers,<br><font color="#888888">
- Andreas<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>