summary refs log tree commit diff stats
path: root/compiler/evaltempl.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-12-21 10:03:33 +0100
committerAraq <rumpf_a@web.de>2017-12-21 10:03:33 +0100
commitee67a67ac450968fc3d753005fe7362ac0414a10 (patch)
tree329b948726df61622d3785ac0da3e760fde954d5 /compiler/evaltempl.nim
parent2775cda6e1eaa9e64ccf1f5cd48e2447e059f2b9 (diff)
downloadNim-ee67a67ac450968fc3d753005fe7362ac0414a10.tar.gz
first steps in adding template/macro calls to stack traces
Diffstat (limited to 'compiler/evaltempl.nim')
-rw-r--r--compiler/evaltempl.nim10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/evaltempl.nim b/compiler/evaltempl.nim
index 7fa6df3da..704ff819c 100644
--- a/compiler/evaltempl.nim
+++ b/compiler/evaltempl.nim
@@ -109,7 +109,7 @@ proc evalTemplateArgs(n: PNode, s: PSym; fromHlo: bool): PNode =
 var evalTemplateCounter* = 0
   # to prevent endless recursion in templates instantiation
 
-proc wrapInComesFrom*(info: TLineInfo; res: PNode): PNode =
+proc wrapInComesFrom*(info: TLineInfo; sym: PSym; res: PNode): PNode =
   when true:
     result = res
     result.info = info
@@ -124,8 +124,12 @@ proc wrapInComesFrom*(info: TLineInfo; res: PNode): PNode =
           if x[i].kind in nkCallKinds:
             x.sons[i].info = info
   else:
-    result = newNodeI(nkPar, info)
+    result = newNodeI(nkStmtListExpr, info)
+    var d = newNodeI(nkComesFrom, info)
+    d.add newSymNode(sym, info)
+    result.add d
     result.add res
+    result.typ = res.typ
 
 proc evalTemplate*(n: PNode, tmpl, genSymOwner: PSym; fromHlo=false): PNode =
   inc(evalTemplateCounter)
@@ -156,6 +160,6 @@ proc evalTemplate*(n: PNode, tmpl, genSymOwner: PSym; fromHlo=false): PNode =
     for i in countup(0, safeLen(body) - 1):
       evalTemplateAux(body.sons[i], args, ctx, result)
   result.flags.incl nfFromTemplate
-  result = wrapInComesFrom(n.info, result)
+  result = wrapInComesFrom(n.info, tmpl, result)
   dec(evalTemplateCounter)