summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-08-06 09:54:23 +0200
committerAraq <rumpf_a@web.de>2014-08-06 09:54:23 +0200
commita64d733029b1f8c76575f5d117399d587346b9cc (patch)
treeb0da407036a22032376169fc1977e42f934b8b4d /compiler
parent1e8a9aead060d27099bdd8634cbab6b89ecd9995 (diff)
downloadNim-a64d733029b1f8c76575f5d117399d587346b9cc.tar.gz
some bugfixes for 'deepCopy'
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgexprs.nim11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index b4beb5a7e..d480373d4 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -360,13 +360,13 @@ proc genAssignment(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) =
   else: internalError("genAssignment: " & $ty.kind)
 
 proc genDeepCopy(p: BProc; dest, src: TLoc) =
-  var ty = skipTypes(dest.t, abstractRange)
+  var ty = skipTypes(dest.t, abstractVarRange)
   case ty.kind
-  of tyPtr, tyRef, tyString, tyProc, tyTuple, tyObject, tyArray, tyArrayConstr:
+  of tyPtr, tyRef, tyProc, tyTuple, tyObject, tyArray, tyArrayConstr:
     # XXX optimize this
     linefmt(p, cpsStmts, "#genericDeepCopy((void*)$1, (void*)$2, $3);$n",
             addrLoc(dest), addrLoc(src), genTypeInfo(p.module, dest.t))
-  of tySequence:
+  of tySequence, tyString:
     linefmt(p, cpsStmts, "#genericSeqDeepCopy($1, $2, $3);$n",
             addrLoc(dest), rdLoc(src), genTypeInfo(p.module, dest.t))
   of tyOpenArray, tyVarargs:
@@ -1687,9 +1687,10 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
     expr(p, n, d)
   of mDeepCopy:
     var a, b: TLoc
-    initLocExpr(p, e.sons[1], a)
+    let x = if e[1].kind in {nkAddr, nkHiddenAddr}: e[1][0] else: e[1]
+    initLocExpr(p, x, a)
     initLocExpr(p, e.sons[2], b)
-    genDeepCopy(p, a, b) 
+    genDeepCopy(p, a, b)
   else: internalError(e.info, "genMagicExpr: " & $op)
 
 proc genConstExpr(p: BProc, n: PNode): PRope