fixed a serious code generation bug leading to wrong RTTI
This commit is contained in:
parent
b800b77a1a
commit
3f82352c2e
7 changed files with 76 additions and 29 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue