gc: destructors is beginning to work (#10483)
* kochdocs.nim: code cleanup * docgen: nicer indentation * parser.nim: code cleanup * fixes #10458 * make tests green again * make =destroy mixins * gc:destructors: produced C code is almost working * --gc:destructors simple program compiles (but leaks memory) * gc:destructors make examples compile in C++ mode * destructors: string implementation bugfixes * strs.nim: minor code cleanup * destructors: builtin seqs are beginning to work * remove debugging helpers
This commit is contained in:
parent
15422a3e5a
commit
dee8e6e98a
19 changed files with 162 additions and 101 deletions
|
|
@ -220,11 +220,12 @@ proc auxWriteStackTrace(f: PFrame; s: var seq[StackTraceEntry]) =
|
|||
inc(i)
|
||||
it = it.prev
|
||||
var last = i-1
|
||||
if s.len == 0:
|
||||
s = newSeq[StackTraceEntry](i)
|
||||
else:
|
||||
last = s.len + i - 1
|
||||
s.setLen(last+1)
|
||||
when true: # not defined(gcDestructors):
|
||||
if s.len == 0:
|
||||
s = newSeq[StackTraceEntry](i)
|
||||
else:
|
||||
last = s.len + i - 1
|
||||
s.setLen(last+1)
|
||||
it = f
|
||||
while it != nil:
|
||||
s[last] = StackTraceEntry(procname: it.procname,
|
||||
|
|
@ -440,11 +441,13 @@ proc getStackTrace(e: ref Exception): string =
|
|||
else:
|
||||
result = ""
|
||||
|
||||
when not defined(gcDestructors):
|
||||
proc getStackTraceEntries*(e: ref Exception): seq[StackTraceEntry] =
|
||||
## Returns the attached stack trace to the exception ``e`` as
|
||||
## a ``seq``. This is not yet available for the JS backend.
|
||||
proc getStackTraceEntries*(e: ref Exception): seq[StackTraceEntry] =
|
||||
## Returns the attached stack trace to the exception ``e`` as
|
||||
## a ``seq``. This is not yet available for the JS backend.
|
||||
when not defined(gcDestructors):
|
||||
shallowCopy(result, e.trace)
|
||||
else:
|
||||
result = move(e.trace)
|
||||
|
||||
const nimCallDepthLimit {.intdefine.} = 2000
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue