This commit is contained in:
Andreas Rumpf 2016-09-01 16:57:34 +02:00
commit 11f7eb2d9b

View file

@ -124,8 +124,7 @@ proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel,
of tyObject: of tyObject:
# copy type field: # copy type field:
var pint = cast[ptr PNimType](dest) var pint = cast[ptr PNimType](dest)
# XXX use dynamic type here! pint[] = cast[ptr PNimType](src)[]
pint[] = mt
if mt.base != nil: if mt.base != nil:
storeAux(dest, src, mt.base, t, mode) storeAux(dest, src, mt.base, t, mode)
storeAux(dest, src, mt.node, t, mode) storeAux(dest, src, mt.node, t, mode)
@ -144,13 +143,12 @@ proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel,
else: else:
unsureAsgnRef(x, nil) unsureAsgnRef(x, nil)
else: else:
let size = if mt.base.kind == tyObject: cast[ptr PNimType](s)[].size
else: mt.base.size
if mode == mStore: if mode == mStore:
x[] = alloc(t.region, mt.base.size) x[] = alloc(t.region, size)
else: else:
# XXX we should use the dynamic type here too, but that is not stored var obj = newObj(mt, size)
# in the inbox at all --> use source[]'s object type? but how? we need
# a tyRef to the object!
var obj = newObj(mt, mt.base.size)
unsureAsgnRef(x, obj) unsureAsgnRef(x, obj)
storeAux(x[], s, mt.base, t, mode) storeAux(x[], s, mt.base, t, mode)
if mode != mStore: dealloc(t.region, s) if mode != mStore: dealloc(t.region, s)