added some exception handling implementation code

This commit is contained in:
hyunghwan.chung 2016-04-29 16:40:25 +00:00
parent e52fe398c7
commit 94717d197a
2 changed files with 49 additions and 5 deletions

View File

@ -6,6 +6,21 @@
{ {
^self.sender ^self.sender
} }
" #method isHandlerContext
{
return ^false
}"
#method handles: anException
{
^false.
}
## #method parent
## {
## ^self.sender
## }
} }
#class(#pointer) MethodContext(Context) #class(#pointer) MethodContext(Context)
@ -40,9 +55,27 @@
##sp := sp - 1. ##sp := sp - 1.
} }
## #method methodName
## {
## ^self.method basicAt: 0.
## }
#method isHandlerContext #method isHandlerContext
{ {
^self.method primitive == 512 ## 10 - STIX_METHOD_PREAMBLE_EXCEPTION in VM.
^self.method preambleCode == 10.
}
#method handles: anException
{
(self isHandlerContext) ifTrue: [^true]. ## TODO: check if xxxx
^false
}
#method handlerBlock
{
## for this to work, self must be a handler context.
^self basicAt: 9
} }
} }
@ -201,7 +234,6 @@
ip := source pc. ip := source pc.
} }
"------ TODO: -------------------------------------" "------ TODO: -------------------------------------"
#method on: anException do: anExceptionBlock #method on: anException do: anExceptionBlock
{ {
@ -209,11 +241,18 @@
<exception> <exception>
handlerActive := true. handlerActive := true.
(thisContext basicAt: 9) dump. thisContext isHandlerContext dump.
(thisContext basicSize) dump.
(thisContext basicAt: 8) dump. ## this should be anException
(thisContext basicAt: 9) dump. ## this should be anExceptionBlock
(thisContext basicAt: 10) dump. ## this should be handlerActive
'on:do: ok.............' dump.
^self value. ^self value.
} }
#method ensure: aBlock #method ensure: aBlock
{ {
"## "##
@ -273,9 +312,9 @@
self return: (self.handlerContext handlerBlock value: self) self return: (self.handlerContext handlerBlock value: self)
} }
#method notHandle #method notHandled
{ {
'EXCEPTION NOT HANDLED' dump. '####################### EXCEPTION NOT HANDLED ###############################' dump.
## TODO: debug the current process???? " ## TODO: debug the current process???? "
Processor activeProcess terminate. Processor activeProcess terminate.
} }

View File

@ -259,6 +259,11 @@
{ {
^self.preamble ^self.preamble
} }
#method preambleCode
{
^self.preamble bitAnd: 16rFF.
}
} }
#include 'Context.st'. #include 'Context.st'.