bugfix: GC more forgiving
This commit is contained in:
parent
623fd8a8ab
commit
b38c7adad1
5 changed files with 14 additions and 8 deletions
|
|
@ -333,11 +333,11 @@ proc parse(x: var TXmlParser, errors: var seq[string]): PXmlNode =
|
||||||
of xmlElementOpen:
|
of xmlElementOpen:
|
||||||
result = newElement(x.elementName.toLower)
|
result = newElement(x.elementName.toLower)
|
||||||
next(x)
|
next(x)
|
||||||
result.attr = newStringTable()
|
result.attrs = newStringTable()
|
||||||
while true:
|
while true:
|
||||||
case x.kind
|
case x.kind
|
||||||
of xmlAttribute:
|
of xmlAttribute:
|
||||||
result.attr[x.attrKey] = x.attrValue
|
result.attrs[x.attrKey] = x.attrValue
|
||||||
next(x)
|
next(x)
|
||||||
of xmlElementClose:
|
of xmlElementClose:
|
||||||
next(x)
|
next(x)
|
||||||
|
|
|
||||||
|
|
@ -1213,14 +1213,14 @@ iterator fieldPairs*(x, y: tuple[]): tuple[a, b: expr] {.
|
||||||
## in the loop body.
|
## in the loop body.
|
||||||
|
|
||||||
proc `==`*[T: tuple](x, y: T): bool =
|
proc `==`*[T: tuple](x, y: T): bool =
|
||||||
## generic ``==`` operator that is lifted from the components
|
## generic ``==`` operator for tuples that is lifted from the components
|
||||||
## of `x` and `y`.
|
## of `x` and `y`.
|
||||||
for a, b in fields(x, y):
|
for a, b in fields(x, y):
|
||||||
if a != b: return false
|
if a != b: return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc `<=`*[T: tuple](x, y: T): bool =
|
proc `<=`*[T: tuple](x, y: T): bool =
|
||||||
## generic ``<=`` operator that is lifted from the components
|
## generic ``<=`` operator for tuples that is lifted from the components
|
||||||
## of `x` and `y`. This implementation uses `cmp`.
|
## of `x` and `y`. This implementation uses `cmp`.
|
||||||
for a, b in fields(x, y):
|
for a, b in fields(x, y):
|
||||||
var c = cmp(a, b)
|
var c = cmp(a, b)
|
||||||
|
|
@ -1229,7 +1229,7 @@ proc `<=`*[T: tuple](x, y: T): bool =
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc `<`*[T: tuple](x, y: T): bool =
|
proc `<`*[T: tuple](x, y: T): bool =
|
||||||
## generic ``<`` operator that is lifted from the components
|
## generic ``<`` operator for tuples that is lifted from the components
|
||||||
## of `x` and `y`. This implementation uses `cmp`.
|
## of `x` and `y`. This implementation uses `cmp`.
|
||||||
for a, b in fields(x, y):
|
for a, b in fields(x, y):
|
||||||
var c = cmp(a, b)
|
var c = cmp(a, b)
|
||||||
|
|
@ -1238,7 +1238,8 @@ proc `<`*[T: tuple](x, y: T): bool =
|
||||||
return false
|
return false
|
||||||
|
|
||||||
proc `$`*[T: tuple](x: T): string =
|
proc `$`*[T: tuple](x: T): string =
|
||||||
## generic ``$`` operator that is lifted from the components of `x`.
|
## generic ``$`` operator for tuples that is lifted from the components
|
||||||
|
## of `x`.
|
||||||
result = "("
|
result = "("
|
||||||
for name, value in fieldPairs(x):
|
for name, value in fieldPairs(x):
|
||||||
if result.len > 1: result.add(", ")
|
if result.len > 1: result.add(", ")
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,10 @@ proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerProc.} =
|
||||||
# reference is in the stack or not (this can happen for var parameters).
|
# reference is in the stack or not (this can happen for var parameters).
|
||||||
if not IsOnStack(dest):
|
if not IsOnStack(dest):
|
||||||
if src != nil: incRef(usrToCell(src))
|
if src != nil: incRef(usrToCell(src))
|
||||||
if dest^ != nil: decRef(usrToCell(dest^))
|
# XXX finally use assembler for the stack checking instead!
|
||||||
|
# the test for '!= nil' is correct, but I got tired of the segfaults
|
||||||
|
# resulting from the crappy stack checking:
|
||||||
|
if cast[int](dest^) >=% PageSize: decRef(usrToCell(dest^))
|
||||||
dest^ = src
|
dest^ = src
|
||||||
|
|
||||||
proc initGC() =
|
proc initGC() =
|
||||||
|
|
|
||||||
|
|
@ -694,6 +694,8 @@ proc semGenericParamList(c: PContext, n: PNode, father: PType = nil): PNode =
|
||||||
if a.sons[L-2].kind != nkEmpty:
|
if a.sons[L-2].kind != nkEmpty:
|
||||||
typ = newTypeS(tyGenericParam, c)
|
typ = newTypeS(tyGenericParam, c)
|
||||||
semGenericConstraints(c, a.sons[L-2], typ)
|
semGenericConstraints(c, a.sons[L-2], typ)
|
||||||
|
if sonsLen(typ) == 1 and typ.sons[0].kind == tyTypeDesc:
|
||||||
|
typ = typ.sons[0]
|
||||||
elif def.kind != nkEmpty: typ = newTypeS(tyExpr, c)
|
elif def.kind != nkEmpty: typ = newTypeS(tyExpr, c)
|
||||||
else: typ = nil
|
else: typ = nil
|
||||||
for j in countup(0, L-3):
|
for j in countup(0, L-3):
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
file: "tambsym.nim"
|
file: "ttypenoval.nim"
|
||||||
line: 36
|
line: 36
|
||||||
errormsg: "a type has no value"
|
errormsg: "a type has no value"
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue