From b090b7ea4dd1d996aa80cab6a95d63187866771d Mon Sep 17 00:00:00 2001
From: Felix Krause <flyx@isobeef.org>
Date: Wed, 25 Jun 2014 17:01:22 +0200
Subject: Fixed handling swap in vmgen

---
 compiler/vmgen.nim | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'compiler/vmgen.nim')

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)
-- 
cgit 1.4.1-2-gfad0