[squeak-dev] About on:do:

David T. Lewis lewis at mail.msen.com
Mon Jul 21 11:05:17 UTC 2008


On Mon, Jul 21, 2008 at 12:46:15PM +0200, Lukas Renggli wrote:
> >  on: exception do: handlerAction
> >         "Evaluate the receiver in the scope of an exception handler."
> >
> >         | handlerActive |
> >         <primitive: 199>  "just a marker, fail and execute the following"
> >         handlerActive _ true.
> >         ^ self value
> 
> 199 is a primitive that marks the context (it just sets a bit in the
> context object) and always fails. The fallback code is then evaluated
> that causes the receiving block to evaluate. That's all.
> 
> In case of an exception the VM can quickly find marked contexts.

And the implementation of primitive 199 in class Interpreter is just this:

primitiveMarkHandlerMethod
	"Primitive. Mark the method for exception handling. The primitive must fail after marking the context so that the regular code is run."
	self inline: false.
	^self primitiveFail

Or in C:

/*	Primitive. Mark the method for exception handling. The primitive must fail after marking the context so that the regular code is run. */

sqInt primitiveMarkHandlerMethod(void) {
	/* begin primitiveFail */
	foo->successFlag = 0;
	return null;
}






More information about the Squeak-dev mailing list