summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-01-13 22:30:56 +0100
committerAraq <rumpf_a@web.de>2015-01-13 22:30:56 +0100
commit8889fa9117cdb2b4b169396e53b0fd78988494cd (patch)
tree8367bbccc0964e4624e691ef04774d4c01736c3a /compiler
parent6b3473ad1b4eec3a2a0504e22de01ba52ab52c6e (diff)
downloadNim-8889fa9117cdb2b4b169396e53b0fd78988494cd.tar.gz
handle 'T&' properly for better C++ support
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgcalls.nim14
1 files changed, 11 insertions, 3 deletions
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim
index b01a81c5e..65244b3eb 100644
--- a/compiler/ccgcalls.nim
+++ b/compiler/ccgcalls.nim
@@ -217,7 +217,7 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
       genAssignment(p, d, list, {}) # no need for deep copying
   else:
     genCallPattern()
-  
+
 proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) =
   var op, a: TLoc
   initLocExpr(p, ri.sons[0], op)
@@ -229,7 +229,10 @@ proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) =
   assert(sonsLen(typ) == sonsLen(typ.n))
   
   var param = typ.n.sons[1].sym
-  app(pl, genArg(p, ri.sons[1], param))
+  if typ.sons[1].kind == tyVar and ri.sons[1].kind == nkHiddenAddr:
+    app(pl, genArgNoParam(p, ri.sons[1][0]))
+  else:
+    app(pl, genArg(p, ri.sons[1], param))
   
   if skipTypes(param.typ, {tyGenericInst}).kind == tyPtr: app(pl, ~"->")
   else: app(pl, ~".")
@@ -239,8 +242,13 @@ proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) =
     if params != nil: params.app(~", ")
     assert(sonsLen(typ) == sonsLen(typ.n))
     if i < sonsLen(typ):
+      # 'var T' is 'T&' in C++. This means we ignore the request of
+      # any nkHiddenAddr when it's a 'var T'.
       assert(typ.n.sons[i].kind == nkSym)
-      app(params, genArg(p, ri.sons[i], typ.n.sons[i].sym))
+      if typ.sons[i].kind == tyVar and ri.sons[i].kind == nkHiddenAddr:
+        app(params, genArgNoParam(p, ri.sons[i][0]))
+      else:
+        app(params, genArg(p, ri.sons[i], typ.n.sons[i].sym))
     else:
       app(params, genArgNoParam(p, ri.sons[i]))
   fixupCall(p, le, ri, d, pl, params)