Hi folks. I have a problem and I am completely clueless. I did one simple modification to the method lookup: I want to check whether the class of the receiver is a proxy and if true, send an special message. So I just modify the first lines of:<br>
<br>lookupMethodInClass: class<br> | currentClass dictionary found |<br> <inline: false><br> self assert: class ~~ objectMemory nilObject.<br> currentClass := class.<br> [currentClass ~= objectMemory nilObject]<br>
whileTrue:<br> [dictionary := objectMemory fetchPointer: MethodDictionaryIndex ofObject: currentClass.<br> <br><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"> " THIS IS MY CHANGE "</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);"> (currentClass = (objectMemory splObj: ProxyClass)) ifTrue: [</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"> self createActualMessageTo: currentClass.</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);"> messageSelector := objectMemory splObj: SelectorHandleProxyInvocation.</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"> self sendBreak: messageSelector + BaseHeaderSize</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);"> point: (objectMemory lengthOf: messageSelector)</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"> receiver: nil.</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);"> ^self lookupMethodInClass: (self superclassOf: currentClass)</span><br style="background-color: rgb(255, 255, 0);"><span style="background-color: rgb(255, 255, 0);"> ].</span><br style="background-color: rgb(255, 255, 0);">
<span style="background-color: rgb(255, 255, 0);"> " HERE FINISH MY CHANGE "</span><br> <br> dictionary = objectMemory nilObject ifTrue:<br> ["MethodDict pointer is nil (hopefully due a swapped out stub)<br>
-- raise exception #cannotInterpret:."<br> self createActualMessageTo: class.<br> messageSelector := objectMemory splObj: SelectorCannotInterpret.<br> self sendBreak: messageSelector + BaseHeaderSize<br>
point: (objectMemory lengthOf: messageSelector)<br> receiver: nil.<br> ^self lookupMethodInClass: (self superclassOf: currentClass)].<br> found := self lookupMethodInDictionary: dictionary.<br>
found ifTrue: [^currentClass].<br> currentClass := self superclassOf: currentClass].<br><br> "Could not find #doesNotUnderstand: -- unrecoverable error."<br> messageSelector = (objectMemory splObj: SelectorDoesNotUnderstand) ifTrue:<br>
[self error: 'Recursive not understood error encountered'].<br><br> "Cound not find a normal message -- raise exception #doesNotUnderstand:"<br> self createActualMessageTo: class.<br> messageSelector := objectMemory splObj: SelectorDoesNotUnderstand.<br>
self sendBreak: messageSelector + BaseHeaderSize<br> point: (objectMemory lengthOf: messageSelector)<br> receiver: nil.<br> ^self lookupMethodInClass: class<br><br><br><br>Now, from the image side, I added ProxyClass and SelectorHandleProxyInvocation and:<br>
<br>ClassProxy>> handleProxyInvocation: aMessage<br> Transcript show: 'a message: '; aMessage selector, 'was sent'; cr. <br><br><br>If I do ClassProxy new foo. I see TWO times the message in the Transcript. I mean, handleProxyInvocation: is being invoke twice per message. <br>
<br>Thanks in advance for any help.<br><br>Mariano<br>