diff options
Diffstat (limited to 'compiler/hlo.nim')
-rw-r--r-- | compiler/hlo.nim | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler/hlo.nim b/compiler/hlo.nim index bb69a1477..9fdec38c0 100644 --- a/compiler/hlo.nim +++ b/compiler/hlo.nim @@ -8,6 +8,7 @@ # # This include implements the high level optimization pass. +# included from sem.nim proc hlo(c: PContext, n: PNode): PNode @@ -16,9 +17,11 @@ proc evalPattern(c: PContext, n, orig: PNode): PNode = # we need to ensure that the resulting AST is semchecked. However, it's # awful to semcheck before macro invocation, so we don't and treat # templates and macros as immediate in this context. - var rule: string - if c.config.hasHint(hintPattern): - rule = renderTree(n, {renderNoComments}) + var rule: string = + if c.config.hasHint(hintPattern): + renderTree(n, {renderNoComments}) + else: + "" let s = n[0].sym case s.kind of skMacro: @@ -67,9 +70,9 @@ proc hlo(c: PContext, n: PNode): PNode = # already processed (special cases in semstmts.nim) result = n else: - if n.kind in {nkFastAsgn, nkAsgn, nkIdentDefs, nkVarTuple} and + if n.kind in {nkFastAsgn, nkAsgn, nkSinkAsgn, nkIdentDefs, nkVarTuple} and n[0].kind == nkSym and - {sfGlobal, sfPure} * n[0].sym.flags == {sfGlobal, sfPure}: + {sfGlobal, sfPure} <= n[0].sym.flags: # do not optimize 'var g {.global} = re(...)' again! return n result = applyPatterns(c, n) @@ -86,9 +89,9 @@ proc hlo(c: PContext, n: PNode): PNode = else: result = fitNode(c, n.typ, result, n.info) # optimization has been applied so check again: - result = commonOptimizations(c.graph, c.module, result) + result = commonOptimizations(c.graph, c.idgen, c.module, result) result = hlo(c, result) - result = commonOptimizations(c.graph, c.module, result) + result = commonOptimizations(c.graph, c.idgen, c.module, result) proc hloBody(c: PContext, n: PNode): PNode = # fast exit: |