mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-26 08:31:44 +00:00
progress
This commit is contained in:
@@ -2054,18 +2054,21 @@ proc genTypeInfo*(config: ConfigRef, m: BModule; t: PType; info: TLineInfo): Rop
|
||||
else:
|
||||
result = genTypeInfoV1(m, t, info)
|
||||
|
||||
proc retrieveSym(n: PNode): PSym =
|
||||
case n.kind
|
||||
of nkPostfix: result = retrieveSym(n[1])
|
||||
of nkPragmaExpr, nkTypeDef: result = retrieveSym(n[0])
|
||||
of nkSym: result = n.sym
|
||||
else: result = nil
|
||||
|
||||
proc genTypeSection(m: BModule, n: PNode) =
|
||||
var intSet = initIntSet()
|
||||
let compress = optCompress in m.config.globalOptions
|
||||
for i in 0..<n.len:
|
||||
if len(n[i]) == 0: continue
|
||||
if n[i][0].kind != nkPragmaExpr: continue
|
||||
for p in 0..<n[i][0].len:
|
||||
if (n[i][0][p].kind notin {nkSym, nkPostfix}): continue
|
||||
var s = n[i][0][p]
|
||||
if s.kind == nkPostfix:
|
||||
s = n[i][0][p][1]
|
||||
if {sfExportc, sfCompilerProc} * s.sym.flags == {sfExportc} or compress:
|
||||
discard getTypeDescAux(m, s.typ, intSet, descKindFromSymKind(s.sym.kind))
|
||||
if m.g.generatedHeader != nil:
|
||||
discard getTypeDescAux(m.g.generatedHeader, s.typ, intSet, descKindFromSymKind(s.sym.kind))
|
||||
for typedef in n:
|
||||
let s = retrieveSym(typedef)
|
||||
if s != nil and ({sfExportc, sfCompilerProc} * s.flags == {sfExportc} or compress) and s.typ != nil and
|
||||
not containsGenericType(s.typ) and
|
||||
s.typ.kind notin {tyVoid, tyNot, tyAnything, tyOr, tyAnd, tyUntyped, tyTyped, tyNone, tyNil, tySink}:
|
||||
discard getTypeDescAux(m, s.typ, intSet, descKindFromSymKind(s.kind))
|
||||
if m.g.generatedHeader != nil:
|
||||
discard getTypeDescAux(m.g.generatedHeader, s.typ, intSet, descKindFromSymKind(s.kind))
|
||||
|
||||
@@ -2264,6 +2264,37 @@ when not defined(js) and declared(alloc0) and declared(dealloc):
|
||||
inc(i)
|
||||
dealloc(a)
|
||||
|
||||
when notJSnotNims and hostOS != "standalone":
|
||||
proc getCurrentException*(): ref Exception {.compilerRtl, inl, benign.} =
|
||||
## Retrieves the current exception; if there is none, `nil` is returned.
|
||||
result = currException
|
||||
|
||||
proc nimBorrowCurrentException(): ref Exception {.compilerRtl, inl, benign, nodestroy.} =
|
||||
# .nodestroy here so that we do not produce a write barrier as the
|
||||
# C codegen only uses it in a borrowed way:
|
||||
result = currException
|
||||
|
||||
proc getCurrentExceptionMsg*(): string {.inline, benign.} =
|
||||
## Retrieves the error message that was attached to the current
|
||||
## exception; if there is none, `""` is returned.
|
||||
return if currException == nil: "" else: currException.msg
|
||||
|
||||
proc setCurrentException*(exc: ref Exception) {.inline, benign.} =
|
||||
## Sets the current exception.
|
||||
##
|
||||
## .. warning:: Only use this if you know what you are doing.
|
||||
currException = exc
|
||||
|
||||
proc raiseDefect() {.compilerRtl.} =
|
||||
let e = getCurrentException()
|
||||
if e of Defect:
|
||||
reportUnhandledError(e)
|
||||
rawQuit(1)
|
||||
|
||||
elif defined(nimscript):
|
||||
proc getCurrentException*(): ref Exception {.compilerRtl.} = discard
|
||||
proc raiseDefect*() {.compilerRtl.} = discard
|
||||
|
||||
when not defined(js):
|
||||
when hasThreadSupport:
|
||||
when hostOS != "standalone":
|
||||
@@ -2349,37 +2380,6 @@ when notJSnotNims and hasThreadSupport and hostOS != "standalone":
|
||||
include "system/channels_builtin"
|
||||
|
||||
|
||||
when notJSnotNims and hostOS != "standalone":
|
||||
proc getCurrentException*(): ref Exception {.compilerRtl, inl, benign.} =
|
||||
## Retrieves the current exception; if there is none, `nil` is returned.
|
||||
result = currException
|
||||
|
||||
proc nimBorrowCurrentException(): ref Exception {.compilerRtl, inl, benign, nodestroy.} =
|
||||
# .nodestroy here so that we do not produce a write barrier as the
|
||||
# C codegen only uses it in a borrowed way:
|
||||
result = currException
|
||||
|
||||
proc getCurrentExceptionMsg*(): string {.inline, benign.} =
|
||||
## Retrieves the error message that was attached to the current
|
||||
## exception; if there is none, `""` is returned.
|
||||
return if currException == nil: "" else: currException.msg
|
||||
|
||||
proc setCurrentException*(exc: ref Exception) {.inline, benign.} =
|
||||
## Sets the current exception.
|
||||
##
|
||||
## .. warning:: Only use this if you know what you are doing.
|
||||
currException = exc
|
||||
|
||||
proc raiseDefect() {.compilerRtl.} =
|
||||
let e = getCurrentException()
|
||||
if e of Defect:
|
||||
reportUnhandledError(e)
|
||||
rawQuit(1)
|
||||
|
||||
elif defined(nimscript):
|
||||
proc getCurrentException*(): ref Exception {.compilerRtl.} = discard
|
||||
proc raiseDefect*() {.compilerRtl.} = discard
|
||||
|
||||
when notJSnotNims:
|
||||
{.push stackTrace: off, profiler: off.}
|
||||
when (defined(profiler) or defined(memProfiler)):
|
||||
|
||||
Reference in New Issue
Block a user