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
|
|
@ -3049,6 +3049,19 @@ else:
|
|||
if x < 0: -x else: x
|
||||
{.pop.}
|
||||
|
||||
when defined(nimNewRoof):
|
||||
iterator `..<`*[T](a, b: T): T =
|
||||
var i = T(a)
|
||||
while i < b:
|
||||
yield i
|
||||
inc i
|
||||
else:
|
||||
iterator `..<`*[S, T](a: S, b: T): T =
|
||||
var i = T(a)
|
||||
while i < b:
|
||||
yield i
|
||||
inc i
|
||||
|
||||
when not defined(JS):
|
||||
proc likelyProc(val: bool): bool {.importc: "likely", nodecl, nosideeffect.}
|
||||
proc unlikelyProc(val: bool): bool {.importc: "unlikely", nodecl, nosideeffect.}
|
||||
|
|
@ -3144,7 +3157,7 @@ when not defined(JS): #and not defined(nimscript):
|
|||
# ----------------- IO Part ------------------------------------------------
|
||||
type
|
||||
CFile {.importc: "FILE", header: "<stdio.h>",
|
||||
final, incompletestruct.} = object
|
||||
incompletestruct.} = object
|
||||
File* = ptr CFile ## The type representing a file handle.
|
||||
|
||||
FileMode* = enum ## The file mode when opening a file.
|
||||
|
|
@ -3392,6 +3405,10 @@ when not defined(JS): #and not defined(nimscript):
|
|||
## returns the OS file handle of the file ``f``. This is only useful for
|
||||
## platform specific programming.
|
||||
|
||||
when defined(gcDestructors) and not defined(nimscript):
|
||||
include "core/strs"
|
||||
include "core/seqs"
|
||||
|
||||
when declared(newSeq):
|
||||
proc cstringArrayToSeq*(a: cstringArray, len: Natural): seq[string] =
|
||||
## converts a ``cstringArray`` to a ``seq[string]``. `a` is supposed to be
|
||||
|
|
@ -3483,10 +3500,6 @@ when not defined(JS): #and not defined(nimscript):
|
|||
when defined(memtracker):
|
||||
include "system/memtracker"
|
||||
|
||||
when defined(gcDestructors):
|
||||
include "core/strs"
|
||||
include "core/seqs"
|
||||
|
||||
when hostOS == "standalone":
|
||||
include "system/embedded"
|
||||
else:
|
||||
|
|
@ -3716,19 +3729,6 @@ template `..<`*(a, b: untyped): untyped =
|
|||
## a shortcut for 'a .. (when b is BackwardsIndex: succ(b) else: pred(b))'.
|
||||
a .. (when b is BackwardsIndex: succ(b) else: pred(b))
|
||||
|
||||
when defined(nimNewRoof):
|
||||
iterator `..<`*[T](a, b: T): T =
|
||||
var i = T(a)
|
||||
while i < b:
|
||||
yield i
|
||||
inc i
|
||||
else:
|
||||
iterator `..<`*[S, T](a: S, b: T): T =
|
||||
var i = T(a)
|
||||
while i < b:
|
||||
yield i
|
||||
inc i
|
||||
|
||||
template spliceImpl(s, a, L, b: untyped): untyped =
|
||||
# make room for additional elements or cut:
|
||||
var shift = b.len - max(0,L) # ignore negative slice size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue