diff options
Diffstat (limited to 'lib/system/assign.nim')
-rwxr-xr-x | lib/system/assign.nim | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/lib/system/assign.nim b/lib/system/assign.nim index cd4a34f6c..4b8d2033d 100755 --- a/lib/system/assign.nim +++ b/lib/system/assign.nim @@ -60,7 +60,7 @@ proc genericAssignAux(dest, src: Pointer, mt: PNimType, shallow: bool) = unsureAsgnRef(x, s2) return sysAssert(dest != nil, "genericAssignAux 3") - unsureAsgnRef(x, newObj(mt, seq.len * mt.base.size + GenericSeqSize)) + unsureAsgnRef(x, newSeq(mt, seq.len)) var dst = cast[taddress](cast[ppointer](dest)[]) for i in 0..seq.len-1: genericAssignAux( @@ -68,9 +68,6 @@ proc genericAssignAux(dest, src: Pointer, mt: PNimType, shallow: bool) = cast[pointer](cast[taddress](s2) +% i *% mt.base.size +% GenericSeqSize), mt.Base, shallow) - var dstseq = cast[PGenericSeq](dst) - dstseq.len = seq.len - dstseq.reserved = seq.len of tyObject: # we need to copy m_type field for tyObject, as it could be empty for # sequence reallocations: @@ -98,6 +95,35 @@ proc genericShallowAssign(dest, src: Pointer, mt: PNimType) {.compilerProc.} = genericAssignAux(dest, src, mt, true) GC_enable() +when false: + proc debugNimType(t: PNimType) = + if t.isNil: + cprintf("nil!") + return + var k: cstring + case t.kind + of tyBool: k = "bool" + of tyChar: k = "char" + of tyEnum: k = "enum" + of tyArray: k = "array" + of tyObject: k = "object" + of tyTuple: k = "tuple" + of tyRange: k = "range" + of tyPtr: k = "ptr" + of tyRef: k = "ref" + of tyVar: k = "var" + of tySequence: k = "seq" + of tyProc: k = "proc" + of tyPointer: k = "range" + of tyOpenArray: k = "openarray" + of tyString: k = "string" + of tyCString: k = "cstring" + of tyInt: k = "int" + of tyInt32: k = "int32" + else: k = "other" + cprintf("%s %ld\n", k, t.size) + debugNimType(t.base) + proc genericSeqAssign(dest, src: Pointer, mt: PNimType) {.compilerProc.} = var src = src # ugly, but I like to stress the parser sometimes :-) genericAssign(dest, addr(src), mt) |