From 669a5644926290e19a3fc32fd319c056183ff2d9 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 27 May 2018 11:10:56 +0200 Subject: remove more global variables in the Nim compiler --- compiler/evaltempl.nim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'compiler/evaltempl.nim') diff --git a/compiler/evaltempl.nim b/compiler/evaltempl.nim index a1b5e731c..e3dd0f342 100644 --- a/compiler/evaltempl.nim +++ b/compiler/evaltempl.nim @@ -11,7 +11,7 @@ import strutils, options, ast, astalgo, msgs, os, idents, wordrecg, renderer, - rodread + rodread, lineinfos type TemplCtx = object @@ -114,7 +114,6 @@ proc evalTemplateArgs(n: PNode, s: PSym; conf: ConfigRef; fromHlo: bool): PNode # to prevent endless recursion in template instantiation const evalTemplateLimit* = 1000 -var evalTemplateCounter* = 0 # XXX remove this global proc wrapInComesFrom*(info: TLineInfo; sym: PSym; res: PNode): PNode = when true: @@ -140,8 +139,8 @@ proc wrapInComesFrom*(info: TLineInfo; sym: PSym; res: PNode): PNode = proc evalTemplate*(n: PNode, tmpl, genSymOwner: PSym; conf: ConfigRef; fromHlo=false): PNode = - inc(evalTemplateCounter) - if evalTemplateCounter > evalTemplateLimit: + inc(conf.evalTemplateCounter) + if conf.evalTemplateCounter > evalTemplateLimit: globalError(conf, n.info, errTemplateInstantiationTooNested) result = n @@ -170,5 +169,5 @@ proc evalTemplate*(n: PNode, tmpl, genSymOwner: PSym; evalTemplateAux(body.sons[i], args, ctx, result) result.flags.incl nfFromTemplate result = wrapInComesFrom(n.info, tmpl, result) - dec(evalTemplateCounter) + dec(conf.evalTemplateCounter) -- cgit 1.4.1-2-gfad0