diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-05-27 11:10:56 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-05-27 11:10:56 +0200 |
commit | 669a5644926290e19a3fc32fd319c056183ff2d9 (patch) | |
tree | e513fe2158b8fc41c44996dac864248151696327 /compiler/evaltempl.nim | |
parent | 12bd1c494cdbb9d3e87d9479098d0892c2e7a453 (diff) | |
download | Nim-669a5644926290e19a3fc32fd319c056183ff2d9.tar.gz |
remove more global variables in the Nim compiler
Diffstat (limited to 'compiler/evaltempl.nim')
-rw-r--r-- | compiler/evaltempl.nim | 9 |
1 files changed, 4 insertions, 5 deletions
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) |