closures have an object type field so that we can perform correct deepCopy() for the BoehmGC target

This commit is contained in:
Andreas Rumpf
2017-07-22 11:10:44 +02:00
parent 1f13e94dd0
commit ad608838bf
7 changed files with 40 additions and 19 deletions

View File

@@ -413,7 +413,7 @@ type
## is an int type ranging from one to the maximum value
## of an int. This type is often useful for documentation and debugging.
RootObj* {.exportc: "TNimObject", inheritable.} =
RootObj* {.compilerProc, inheritable.} =
object ## the root of Nim's object hierarchy. Objects should
## inherit from RootObj or one of its descendants. However,
## objects that have no ancestor are allowed.
@@ -3269,7 +3269,7 @@ when not defined(JS): #and not defined(nimscript):
proc finished*[T: proc](x: T): bool {.noSideEffect, inline.} =
## can be used to determine if a first class iterator has finished.
{.emit: """
`result` = *((NI*) `x`.ClE_0) < 0;
`result` = ((NI*) `x`.ClE_0)[1] < 0;
""".}
elif defined(JS):

View File

@@ -148,11 +148,11 @@ proc genericDeepCopyAux(dest, src: pointer, mt: PNimType; tab: var PtrTable) =
let realType = x.typ
sysAssert realType == mt, " types do differ"
# this version should work for any possible GC:
let size = if mt.base.kind == tyObject: cast[ptr PNimType](s2)[].size else: mt.base.size
let z = newObj(mt, size)
let typ = if mt.base.kind == tyObject: cast[ptr PNimType](s2)[] else: mt.base
let z = newObj(mt, typ.size)
unsureAsgnRef(cast[PPointer](dest), z)
tab.put(s2, z)
genericDeepCopyAux(z, s2, mt.base, tab)
genericDeepCopyAux(z, s2, typ, tab)
else:
unsureAsgnRef(cast[PPointer](dest), z)
of tyPtr: