summary refs log tree commit diff stats
path: root/compiler/vmgen.nim
diff options
context:
space:
mode:
authorFelix Krause <flyx@isobeef.org>2014-06-25 17:01:22 +0200
committerFelix Krause <flyx@isobeef.org>2014-06-25 17:01:22 +0200
commitb090b7ea4dd1d996aa80cab6a95d63187866771d (patch)
treef5e4b756cad970b8855a86840119466bcb10d09d /compiler/vmgen.nim
parent0449791185042ddb8ad2819d773b3aefbe4a91a6 (diff)
downloadNim-b090b7ea4dd1d996aa80cab6a95d63187866771d.tar.gz
Fixed handling swap in vmgen
Diffstat (limited to 'compiler/vmgen.nim')
-rw-r--r--compiler/vmgen.nim10
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index 186d27ae4..305ea7f9e 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -787,10 +787,12 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest) =
     c.freeTemp(tmp)
   of mSwap: 
     unused(n, dest)
-    var d = c.genx(n.sons[1])
-    var tmp = c.genx(n.sons[2])
-    c.gABC(n, opcSwap, d, tmp)
-    c.freeTemp(tmp)
+    var
+      d1 = c.genx(n.sons[1])
+      d2 = c.genx(n.sons[2])
+    c.gABC(n, opcSwap, d1, d2)
+    c.genAsgnPatch(n.sons[1], d1)
+    c.genAsgnPatch(n.sons[2], d2)
   of mIsNil: genUnaryABC(c, n, dest, opcIsNil)
   of mCopyStr:
     if dest < 0: dest = c.getTemp(n.typ)