Searching for "thisContext selector"

Tim Olson tim at
Mon Aug 17 02:21:27 UTC 1998

>The problem is with the expression "thisContext selector"
> that find the selector searching in the receiver's class
> for the selector who is implemented using "thisContext method"
>As I use the same method for all the swappedOut methods
> then, the returned selector is the first selector implemented in
> the receiver's class!
>What can I do to get the sent selector of thisContext
> from the VM stack (or current method) ?

You will have to look at the bytecode prior to the sender's PC to 
determine its type.  If it is a literal send (> 208), then you can get 
the selector using something like:

	| method pc |
	method := thisContext sender method.
	pc := thisContext sender pc.
	^ method literals at: ((method at: pc-1) - 207)

Common selectors such as the arithmetic primitives and things like "at:" 
use special bytecodes in the following ranges:

		 176-191 sendArithmeticSelectorBytecode
		 192-207 sendCommonSelectorBytecode

You can determine the selector for these by building a bytecode->selector 

     -- tim

More information about the Squeak-dev mailing list