removed unneeded code and reimplemented Exception>>retry,resume,return
This commit is contained in:
@ -558,12 +558,12 @@
|
||||
{
|
||||
#method(#class) signal
|
||||
{
|
||||
self new signal
|
||||
^self new signal
|
||||
}
|
||||
|
||||
#method(#class) signal: text
|
||||
{
|
||||
self new signal: text
|
||||
^self new signal: text
|
||||
}
|
||||
|
||||
#method handlerContext: context
|
||||
@ -587,7 +587,6 @@
|
||||
| excctx excblk retval actpos |
|
||||
|
||||
self.signalContext := thisContext.
|
||||
|
||||
excctx := (thisContext sender) findExceptionContext.
|
||||
[excctx notNil] whileTrue: [
|
||||
excblk := excctx findExceptionHandlerFor: (self class).
|
||||
@ -608,7 +607,8 @@
|
||||
## -----------------------------------------------------------------
|
||||
## FATAL ERROR - no exception handler.
|
||||
## -----------------------------------------------------------------
|
||||
thisContext unwindTo: nil return: nil.
|
||||
##thisContext unwindTo: nil return: nil.
|
||||
thisContext unwindTo: (Processor activeProcess initialContext) return: nil.
|
||||
('### EXCEPTION NOT HANDLED #### ', self class name, ' - ', self messageText) dump.
|
||||
## TODO: debug the current process???? "
|
||||
Processor activeProcess terminate.
|
||||
@ -617,7 +617,7 @@
|
||||
#method signal: text
|
||||
{
|
||||
self.messageText := text.
|
||||
self signal.
|
||||
^self signal.
|
||||
}
|
||||
|
||||
#method pass
|
||||
@ -626,38 +626,39 @@
|
||||
((self.handlerContext sender) findExceptionContext) handleException: self.
|
||||
}
|
||||
|
||||
"
|
||||
TODO: implement these methods....
|
||||
#method return: value
|
||||
{
|
||||
self.handlerContext notNil ifTrue: [
|
||||
Processor return: value to: (self.handlerContext sender)
|
||||
]
|
||||
(self.handlerContext notNil) ifTrue: [
|
||||
Processor return: value to: self.handlerContext.
|
||||
].
|
||||
}
|
||||
|
||||
#method retry
|
||||
{
|
||||
## TODO: verify if return:to: causes unnecessary stack growth.
|
||||
self.handlerContext notNil
|
||||
ifTrue: [
|
||||
## TODO: should i reset self.handlerContext and self.signalContext to nil?
|
||||
self.handlerContext pc: 0.
|
||||
Processor return: self to: self.handlerContext.
|
||||
##Processor forceContext: self.handlerContext.
|
||||
]
|
||||
## TODO: verify if return:to: causes unnecessary stack growth.
|
||||
(self.handlerContext notNil) ifTrue: [
|
||||
self.handlerContext pc: 0.
|
||||
Processor return: self to: self.handlerContext.
|
||||
].
|
||||
}
|
||||
|
||||
#method resume: value
|
||||
{
|
||||
## TODO: verify if return:to: causes unnecessary stack growth.
|
||||
## is this correct???
|
||||
(self.signalContext notNil and: [self.handlerContext notNil]) ifTrue: [
|
||||
| ctx |
|
||||
ctx := self.signalContext sender.
|
||||
self.signalContext := nil.
|
||||
self.handlerContext := nil.
|
||||
Processor return: value to: ctx.
|
||||
].
|
||||
}
|
||||
|
||||
#method resume
|
||||
{
|
||||
## TODO: verify if return:to: causes unnecessary stack growth.
|
||||
## is this correct???
|
||||
self.signalContext notNil
|
||||
ifTrue: [
|
||||
## TODO: should i reset self.handlerContext and self.signalContext to nil?
|
||||
Processor return: self to: (self.signalContext sender).
|
||||
]
|
||||
^self resume: nil.
|
||||
}
|
||||
"
|
||||
}
|
||||
|
||||
#class NoSuchMessageException(Exception)
|
||||
|
@ -19,14 +19,14 @@
|
||||
^self.next.
|
||||
}
|
||||
|
||||
#method next: aProcess
|
||||
#method next: process
|
||||
{
|
||||
self.next := aProcess.
|
||||
self.next := process.
|
||||
}
|
||||
|
||||
#method prev: aProcess
|
||||
#method prev: process
|
||||
{
|
||||
self.prev := aProcess.
|
||||
self.prev := process.
|
||||
}
|
||||
|
||||
#method resume
|
||||
@ -51,7 +51,12 @@
|
||||
|
||||
#method sp
|
||||
{
|
||||
^sp.
|
||||
^self.sp.
|
||||
}
|
||||
|
||||
#method initialContext
|
||||
{
|
||||
^self.initial_context
|
||||
}
|
||||
|
||||
#method sleep: seconds
|
||||
@ -341,7 +346,7 @@
|
||||
^self.active.
|
||||
}
|
||||
|
||||
#method resume: aProcess
|
||||
#method resume: process
|
||||
{
|
||||
<primitive: #_processor_schedule>
|
||||
self primitiveFailed.
|
||||
@ -349,14 +354,14 @@
|
||||
"The primitive does something like the following in principle:
|
||||
(self.tally = 0)
|
||||
ifTrue: [
|
||||
self.head := aProcess.
|
||||
self.tail := aProcess.
|
||||
self.head := process.
|
||||
self.tail := process.
|
||||
self.tally := 1.
|
||||
]
|
||||
ifFalse: [
|
||||
aProcess next: self.head.
|
||||
self.head prev: aProcess.
|
||||
self.head := aProcess.
|
||||
process next: self.head.
|
||||
self.head prev: process.
|
||||
self.head := process.
|
||||
self.tally := self.tally + 1.
|
||||
].
|
||||
"
|
||||
@ -370,47 +375,34 @@
|
||||
}
|
||||
"
|
||||
|
||||
#method signal: aSemaphore after: anInteger
|
||||
#method signal: semaphore after: secs
|
||||
{
|
||||
<primitive: #_processor_add_timed_semaphore>
|
||||
self primitiveFailed.
|
||||
}
|
||||
|
||||
#method signal: aSemaphore after: aSecond and: aNanoSecond
|
||||
#method signal: semaphore after: secs and: nanosecs
|
||||
{
|
||||
<primitive: #_processor_add_timed_semaphore>
|
||||
self primitiveFailed.
|
||||
}
|
||||
|
||||
#method unsignal: aSemaphore
|
||||
#method unsignal: semaphore
|
||||
{
|
||||
<primitive: #_processor_remove_semaphore>
|
||||
self primitiveFailed.
|
||||
}
|
||||
|
||||
"#method signal: aSemaphore onInput: file
|
||||
"#method signal: semaphore onInput: file
|
||||
{
|
||||
}"
|
||||
"#method signal: aSemaphore onOutput: file
|
||||
"#method signal: semaphore onOutput: file
|
||||
{
|
||||
}"
|
||||
|
||||
#method return: anObject to: aContext
|
||||
#method return: object to: context
|
||||
{
|
||||
<primitive: #_processor_return_to>
|
||||
self primitiveFailed.
|
||||
}
|
||||
|
||||
#method returnTo: aContext andEval: aBlock with: arg
|
||||
{
|
||||
<primitive: #_processor_return_to_and_eval>
|
||||
self primitiveFailed.
|
||||
}
|
||||
|
||||
#method forceContext: aContext
|
||||
{
|
||||
<primitive: #_processor_force_context>
|
||||
self primitiveFailed.
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,9 +39,9 @@
|
||||
|
||||
#method(#class) main2
|
||||
{
|
||||
| k |
|
||||
| k q |
|
||||
'BEGINNING OF main2' dump.
|
||||
k := ['this is test-011' dump. Exception signal: 'main2 screwed...'. 8888 dump. ]
|
||||
k := [ 'this is test-011' dump. q := Exception signal: 'main2 screwed...'. q dump. 8888 dump. ]
|
||||
on: Exception do: [ :ex |
|
||||
'Exception occurred' dump.
|
||||
ex messageText dump.
|
||||
@ -51,6 +51,7 @@
|
||||
'AFTER RETURN' dump.
|
||||
].
|
||||
|
||||
'k=>>> ' dump.
|
||||
k dump.
|
||||
'END OF main2' dump.
|
||||
}
|
||||
@ -149,10 +150,10 @@
|
||||
'BEGINNING OF test11' dump.
|
||||
[
|
||||
|p |
|
||||
p := [ Exception signal: 'Exception in a new process of test11'. ] newProcess.
|
||||
p := [ 'TEST11 IN NEW PROCESS' dump. Exception signal: 'Exception raised in a new process of test11'. ] newProcess.
|
||||
'JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ' dump.
|
||||
p resume.
|
||||
] on: Exception do: [:ex | 'EXCEPTION ----------' dump. ex messageText dump ].
|
||||
p resume. ## resume the new process
|
||||
] on: Exception do: [:ex | '---- EXCEPTION IN TEST11. THIS MUST NOT BE PRINTED----------' dump. ex messageText dump ].
|
||||
'END OF test11' dump.
|
||||
}
|
||||
|
||||
@ -181,9 +182,10 @@
|
||||
[ self main2 ] on: Exception do: [ :ex |
|
||||
'EXCEPTION CAUGHT IN MAIN....' dump.
|
||||
ex messageText dump.
|
||||
"ex pass."
|
||||
##ex pass.
|
||||
'Returning back to where the exception has signalled in main2...' dump.
|
||||
ex resume.
|
||||
##ex resume.
|
||||
ex resume: 'RESUMED WITH THIS STRING'.
|
||||
].
|
||||
|
||||
'##############################' dump.
|
||||
@ -218,6 +220,9 @@
|
||||
## on: PrimitiveFailureException do: [:ex | 'PRIMITIVE FAILURE CAUGHT HERE HERE HERE' dump]
|
||||
## on: Exception do: [:ex | ex messageText dump].
|
||||
|
||||
'SLEEPING FOR 10 seconds ....' dump.
|
||||
Processor activeProcess sleep: 10.
|
||||
|
||||
'>>>>> END OF MAIN' dump.
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user