diff options
author | Araq <rumpf_a@web.de> | 2013-09-18 02:03:56 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-09-18 02:03:56 +0200 |
commit | 51672aef724ee7c0cac260a8172ae70b3ccd9494 (patch) | |
tree | 1c25a83630c1fefef48dbbe9c278445b694a0578 /compiler | |
parent | 9de3bc8ef64fbd2fa1e336b05a09ad8f898a5d45 (diff) | |
download | Nim-51672aef724ee7c0cac260a8172ae70b3ccd9494.tar.gz |
should fix newly introduced bugs wrt TR macros
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/hlo.nim | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/hlo.nim b/compiler/hlo.nim index f19f6dd92..1492ed76f 100644 --- a/compiler/hlo.nim +++ b/compiler/hlo.nim @@ -47,7 +47,7 @@ proc applyPatterns(c: PContext, n: PNode): PNode = if evalTemplateCounter > 100: GlobalError(n.info, errTemplateInstantiationTooNested) # deactivate this pattern: - #c.patterns[i] = nil + c.patterns[i] = nil if x.kind == nkStmtList: assert x.len == 3 x.sons[1] = evalPattern(c, x.sons[1], result) @@ -56,17 +56,21 @@ proc applyPatterns(c: PContext, n: PNode): PNode = result = evalPattern(c, x, result) dec(evalTemplateCounter) # activate this pattern again: - #c.patterns[i] = pattern + c.patterns[i] = pattern proc hlo(c: PContext, n: PNode): PNode = inc(c.hloLoopDetector) # simply stop and do not perform any further transformations: - if c.hloLoopDetector > 300: result = n + if c.hloLoopDetector > 300: return n case n.kind of nkMacroDef, nkTemplateDef, procDefs: # already processed (special cases in semstmts.nim) result = n else: + if n.kind in {nkFastAsgn, nkAsgn, nkIdentDefs, nkVarTuple} and + n.sons[0].kind == nkSym and sfGlobal in n.sons[0].sym.flags: + # do not optimize 'var g {.global} = re(...)' again! + return n result = applyPatterns(c, n) if result == n: # no optimization applied, try subtrees: |