added system.onRaise to support a condition system

This commit is contained in:
Araq 2012-11-05 08:36:44 +01:00
commit 865d9cc6e6
7 changed files with 100 additions and 36 deletions

View file

@ -52,6 +52,7 @@ proc setFrame(s: PFrame) {.compilerRtl, inl.} =
framePtr = s
proc pushSafePoint(s: PSafePoint) {.compilerRtl, inl.} =
s.raiseAction = nil
s.prev = excHandler
excHandler = s
@ -198,8 +199,9 @@ proc raiseExceptionAux(e: ref E_Base) =
if globalRaiseHook != nil:
if not globalRaiseHook(e): return
if excHandler != nil:
pushCurrentException(e)
c_longjmp(excHandler.context, 1)
if isNil(excHandler.raiseAction) or excHandler.raiseAction(e):
pushCurrentException(e)
c_longjmp(excHandler.context, 1)
elif e[] of EOutOfMemory:
writeToStdErr(e.name)
quitOrDebug()