At Thu, 28 Apr 2011 12:22:33 +0200, Mariano Martinez Peck wrote:
Hi. Suppose I am doing something in #commonSend:
commonSend "Send a message, starting lookup with the receiver's class." "Assume: messageSelector and argumentCount have been set, and that the receiver and arguments have been pushed onto the stack," "Note: This method is inlined into the interpreter dispatch loop." <sharedCodeNamed: 'commonSend' inCase: 131> self internalFindNewMethod. self internalExecuteNewMethod. self fetchNextBytecode
and somewhere there I want to do something like this:
(messageSelector = '#foo') ifTrue: [ self print: 'the message foo was called'; cr ].
messageSelector is the instVar of Interpreter and it is already in the stack.
Of course, the part that doesn't work is (messageSelector = '#foo') I tried several things but I don't find how to do it.
Perhaps something along the line of:
(self cCode: 'stSizeOf(messageSelector) == sizeOf('foo') && (strncmp(firstIndexableField(messageSelector), 'foo', sizeOf('foo')) == 0)) ifTrue: [self print: 'the message foo was called': cr].
(Not tested this particualr one, but have done similar thing before. This assumes that messageSelector is always a Symbol, which may not be the case for you...)
-- Yoshiki