Added support for exceptions in coroutines and added exception test

Fix bug where first coroutine ending would terminate main loop
This commit is contained in:
Rokas Kupstys 2017-02-11 11:45:50 +02:00
commit 9a754156d7
2 changed files with 46 additions and 9 deletions

View file

@ -45,6 +45,17 @@ var
# a global variable for the root of all try blocks
currException {.threadvar.}: ref Exception
type
FrameState = tuple[framePtr: PFrame, excHandler: PSafePoint, currException: ref Exception]
proc getFrameState*(): FrameState {.compilerRtl, inl.} =
return (framePtr, excHandler, currException)
proc setFrameState*(state: FrameState) {.compilerRtl, inl.} =
framePtr = state.framePtr
excHandler = state.excHandler
currException = state.currException
proc getFrame*(): PFrame {.compilerRtl, inl.} = framePtr
proc popFrame {.compilerRtl, inl.} =