make goto based exceptions available for 'nim cpp' (#13244)

* make goto based exceptions available for 'nim cpp'
* optimize seq.add to be comparable to C++'s emplace_back
This commit is contained in:
Andreas Rumpf 2020-01-25 20:00:13 +01:00 • committed by GitHub
commit 6efac70181
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 29 additions and 18 deletions

View file

@ -61,7 +61,7 @@ var
currException {.threadvar.}: ref Exception
gcFramePtr {.threadvar.}: GcFrame
when defined(cpp) and not defined(noCppExceptions):
when defined(cpp) and not defined(noCppExceptions) and not gotoBasedExceptions:
var
raiseCounter {.threadvar.}: uint
@ -410,7 +410,7 @@ proc reportUnhandledError(e: ref Exception) {.nodestroy.} =
discard()
proc nimLeaveFinally() {.compilerRtl.} =
when defined(cpp) and not defined(noCppExceptions):
when defined(cpp) and not defined(noCppExceptions) and not gotoBasedExceptions:
{.emit: "throw;".}
else:
if excHandler != nil:
@ -439,7 +439,7 @@ proc raiseExceptionAux(e: sink(ref Exception)) {.nodestroy.} =
if not localRaiseHook(e): return
if globalRaiseHook != nil:
if not globalRaiseHook(e): return
when defined(cpp) and not defined(noCppExceptions):
when defined(cpp) and not defined(noCppExceptions) and not gotoBasedExceptions:
if e == currException:
{.emit: "throw;".}
else:
@ -544,7 +544,7 @@ proc nimFrame(s: PFrame) {.compilerRtl, inl, raises: [].} =
framePtr = s
if s.calldepth == nimCallDepthLimit: callDepthLimitReached()
when defined(cpp) and appType != "lib" and
when defined(cpp) and appType != "lib" and not gotoBasedExceptions and
not defined(js) and not defined(nimscript) and
hostOS != "standalone" and not defined(noCppExceptions):