added more code for exception handling
This commit is contained in:
parent
8ea80dae91
commit
90eb7d5507
@ -246,7 +246,7 @@ thisContext isHandlerContext dump.
|
|||||||
(thisContext basicAt: 8) dump. ## this should be anException
|
(thisContext basicAt: 8) dump. ## this should be anException
|
||||||
(thisContext basicAt: 9) dump. ## this should be anExceptionBlock
|
(thisContext basicAt: 9) dump. ## this should be anExceptionBlock
|
||||||
(thisContext basicAt: 10) dump. ## this should be handlerActive
|
(thisContext basicAt: 10) dump. ## this should be handlerActive
|
||||||
'on:do: ok.............' dump.
|
'on:do: ABOUT TO EVALUE THE RECEIVER BLOCK' dump.
|
||||||
|
|
||||||
^self value.
|
^self value.
|
||||||
}
|
}
|
||||||
@ -291,9 +291,18 @@ thisContext isHandlerContext dump.
|
|||||||
#method signal
|
#method signal
|
||||||
{
|
{
|
||||||
self.signalContext := thisContext.
|
self.signalContext := thisContext.
|
||||||
self isHandled
|
|
||||||
ifTrue: [ self handle ]
|
self.handlerContext isNil ifTrue: [
|
||||||
ifFalse: [ self notHandled ].
|
self.handlerContext := self findHandlerContextStartingFrom: self.signalContext
|
||||||
|
].
|
||||||
|
|
||||||
|
self.handlerContext isNil
|
||||||
|
ifTrue: [ self notHandled ]
|
||||||
|
ifFalse: [ self handle ].
|
||||||
|
|
||||||
|
## self isHandled
|
||||||
|
## ifTrue: [ self handle ]
|
||||||
|
## ifFalse: [ self notHandled ].
|
||||||
}
|
}
|
||||||
|
|
||||||
#method signal: text
|
#method signal: text
|
||||||
@ -306,8 +315,33 @@ thisContext isHandlerContext dump.
|
|||||||
{
|
{
|
||||||
## pass the exception to the outer context
|
## pass the exception to the outer context
|
||||||
## TODO:
|
## TODO:
|
||||||
|
self.handlerContext := self findHandlerContextStartingFrom: (self.handlerContext sender).
|
||||||
|
self.handlerContext isNil
|
||||||
|
ifTrue: [ self notHandled ]
|
||||||
|
ifFalse: [ self handle ].
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#method return: value
|
||||||
|
{
|
||||||
|
self.handlerContext isNil ifFalse: [
|
||||||
|
Processor return: value to: (self.handlerContext sender)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
#method retry
|
||||||
|
{
|
||||||
|
## ##>>> Processor return: nil to: (self.signalContext sender).
|
||||||
|
}
|
||||||
|
|
||||||
|
#method resume
|
||||||
|
{
|
||||||
|
## is this correct???
|
||||||
|
Processor return: nil to: (self.signalContext sender).
|
||||||
|
}
|
||||||
|
|
||||||
|
## ####################################################################
|
||||||
|
## ####################################################################
|
||||||
|
|
||||||
#method isHandled
|
#method isHandled
|
||||||
{
|
{
|
||||||
^self handlerContext notNil
|
^self handlerContext notNil
|
||||||
|
@ -41,7 +41,23 @@
|
|||||||
{
|
{
|
||||||
| k |
|
| k |
|
||||||
k := ['this is test-011' dump. Exception signal. 8888 dump. ]
|
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 ].
|
on: Exception do: [ :ex | 'Exception occurred' dump. ex dump. 'Getting back to' dump. ex return: 9999. 'AFTER RETURN' dump. ].
|
||||||
|
|
||||||
|
k dump.
|
||||||
|
'END OF test-011' dump.
|
||||||
|
}
|
||||||
|
|
||||||
|
#method(#class) test3
|
||||||
|
{
|
||||||
|
| k j |
|
||||||
|
j := 20.
|
||||||
|
k := [
|
||||||
|
'>>> TEST3 METHOD >>> ' dump.
|
||||||
|
j dump.
|
||||||
|
(j < 25) ifTrue: [Exception signal].
|
||||||
|
'OOOOOOOOOOOOOOOOOOOOOOO' dump.
|
||||||
|
'JJJJJJJJJJJJJJ' dump.
|
||||||
|
] on: Exception do: [ :ex | 'Exception occurred' dump. j := j + 1. ex resume. ].
|
||||||
|
|
||||||
k dump.
|
k dump.
|
||||||
'END OF test-011' dump.
|
'END OF test-011' dump.
|
||||||
@ -51,8 +67,10 @@
|
|||||||
{
|
{
|
||||||
'>>>>> BEGINNING OF MAIN' dump.
|
'>>>>> BEGINNING OF MAIN' dump.
|
||||||
|
|
||||||
[ self main2 ] on: Exception do: [ :ex | 'EXCEPTION CAUGHT IN MAIN....' dump ].
|
[ self main2 ] on: Exception do: [ :ex | 'EXCEPTION CAUGHT IN MAIN....' dump. "ex pass" ].
|
||||||
|
|
||||||
|
'##############################' dump.
|
||||||
|
self test3.
|
||||||
'>>>>> END OF MAIN' dump.
|
'>>>>> END OF MAIN' dump.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1854,13 +1854,12 @@ static int prim_processor_return_to (stix_t* stix, stix_ooi_t nargs)
|
|||||||
ctx = ACTIVE_STACK_GET(stix, stix->sp);
|
ctx = ACTIVE_STACK_GET(stix, stix->sp);
|
||||||
|
|
||||||
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 */
|
|
||||||
STIX_ASSERT (STIX_CLASSOF(stix, ctx) == stix->_block_context ||
|
if (STIX_CLASSOF(stix, ctx) != stix->_block_context &&
|
||||||
STIX_CLASSOF(stix, ctx) == stix->_method_context);
|
STIX_CLASSOF(stix, ctx) == stix->_method_context) return 0;
|
||||||
|
|
||||||
ACTIVE_STACK_POPS (stix, nargs + 1); /* pop arguments and receiver */
|
ACTIVE_STACK_POPS (stix, nargs + 1); /* pop arguments and receiver */
|
||||||
|
|
||||||
|
|
||||||
ACTIVE_STACK_PUSH (stix, ret);
|
ACTIVE_STACK_PUSH (stix, ret);
|
||||||
SWITCH_ACTIVE_CONTEXT (stix, (stix_oop_context_t)ctx);
|
SWITCH_ACTIVE_CONTEXT (stix, (stix_oop_context_t)ctx);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user