fixed processor_return_to
This commit is contained in:
parent
94717d197a
commit
77990a5172
@ -302,6 +302,12 @@ thisContext isHandlerContext dump.
|
|||||||
self signal.
|
self signal.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#method pass
|
||||||
|
{
|
||||||
|
## pass the exception to the outer context
|
||||||
|
## TODO:
|
||||||
|
}
|
||||||
|
|
||||||
#method isHandled
|
#method isHandled
|
||||||
{
|
{
|
||||||
^self handlerContext notNil
|
^self handlerContext notNil
|
||||||
@ -309,7 +315,7 @@ thisContext isHandlerContext dump.
|
|||||||
|
|
||||||
#method handle
|
#method handle
|
||||||
{
|
{
|
||||||
self return: (self.handlerContext handlerBlock value: self)
|
Processor return: (self.handlerContext handlerBlock value: self) to: (self.handlerContext sender)
|
||||||
}
|
}
|
||||||
|
|
||||||
#method notHandled
|
#method notHandled
|
||||||
@ -322,28 +328,23 @@ Processor activeProcess terminate.
|
|||||||
#method handlerContext
|
#method handlerContext
|
||||||
{
|
{
|
||||||
(self.handlerContext notNil) ifTrue: [ ^self.handlerContext ].
|
(self.handlerContext notNil) ifTrue: [ ^self.handlerContext ].
|
||||||
^self handlerContextStartingFrom: self.signalContext sender.
|
self.handlerContext := self findHandlerContextStartingFrom: self.signalContext.
|
||||||
|
^self.handlerContext.
|
||||||
}
|
}
|
||||||
|
|
||||||
#method handlerContextStartingFrom: aContext
|
#method findHandlerContextStartingFrom: aContext
|
||||||
{
|
{
|
||||||
## Find exception handling context starting from a given context
|
## Find exception handling context starting from a given context
|
||||||
|
|
||||||
| ctx |
|
| ctx |
|
||||||
|
|
||||||
ctx := aContext.
|
ctx := aContext.
|
||||||
[ ctx notNil ]
|
[ ctx notNil ]
|
||||||
whileTrue: [
|
whileTrue: [
|
||||||
(ctx handles: self) ifTrue: [ ^self.handlerContext := ctx ].
|
(ctx handles: self) ifTrue: [ ^ ctx ].
|
||||||
ctx := ctx sender
|
ctx := ctx sender
|
||||||
].
|
].
|
||||||
^nil
|
^nil
|
||||||
}
|
}
|
||||||
|
|
||||||
#method return: anObject
|
|
||||||
{
|
|
||||||
Processor return: anObject to: (self.handlerContext parent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#class NoSuchMessageException(Exception)
|
#class NoSuchMessageException(Exception)
|
||||||
|
@ -37,8 +37,22 @@
|
|||||||
#class MyObject(TestObject)
|
#class MyObject(TestObject)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#method(#class) main2
|
||||||
|
{
|
||||||
|
| k |
|
||||||
|
k := ['this is test-011' dump. Exception signal. 8888 dump. ]
|
||||||
|
on: Exception do: [ :ex | 'Exception occurred' dump. ex dump. 'Getting back to' dump. 80. ex pass ].
|
||||||
|
|
||||||
|
k dump.
|
||||||
|
'END OF test-011' dump.
|
||||||
|
}
|
||||||
|
|
||||||
#method(#class) main
|
#method(#class) main
|
||||||
{
|
{
|
||||||
['this is test-011' dump. Exception signal. ] on: Exception do: [ :ex | 'Exception occurred' dump ].
|
'>>>>> BEGINNING OF MAIN' dump.
|
||||||
|
|
||||||
|
[ self main2 ] on: Exception do: [ :ex | 'EXCEPTION CAUGHT IN MAIN....' dump ].
|
||||||
|
|
||||||
|
'>>>>> END OF MAIN' dump.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1839,9 +1839,14 @@ static int prim_processor_return_to (stix_t* stix, stix_ooi_t nargs)
|
|||||||
|
|
||||||
if (rcv != (stix_oop_t)stix->processor) return 0;
|
if (rcv != (stix_oop_t)stix->processor) return 0;
|
||||||
/* TODO: check if ctx is a block context or a method context */
|
/* TODO: check if ctx is a block context or a method context */
|
||||||
|
STIX_ASSERT (STIX_CLASSOF(stix, ctx) == stix->_block_context ||
|
||||||
|
STIX_CLASSOF(stix, ctx) == stix->_method_context);
|
||||||
|
|
||||||
ACTIVE_STACK_POPS (stix, nargs + 1); /* pop arguments and receiver */
|
ACTIVE_STACK_POPS (stix, nargs + 1); /* pop arguments and receiver */
|
||||||
SWITCH_ACTIVE_CONTEXT (stix, ctx);
|
|
||||||
|
|
||||||
|
ACTIVE_STACK_PUSH (stix, ret);
|
||||||
|
SWITCH_ACTIVE_CONTEXT (stix, (stix_oop_context_t)ctx);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user