reorder pass: consider the 'using' statement; disabled debug output

This commit is contained in:
Andreas Rumpf 2017-07-29 10:20:39 +02:00
commit dfe067a74a
2 changed files with 10 additions and 6 deletions

View file

@ -35,7 +35,7 @@ proc computeDeps(n: PNode, declares, uses: var IntSet; topLevel: bool) =
of procDefs: of procDefs:
decl(n[0]) decl(n[0])
for i in 1..bodyPos: deps(n[i]) for i in 1..bodyPos: deps(n[i])
of nkLetSection, nkVarSection: of nkLetSection, nkVarSection, nkUsingStmt:
for a in n: for a in n:
if a.kind in {nkIdentDefs, nkVarTuple}: if a.kind in {nkIdentDefs, nkVarTuple}:
for j in countup(0, a.len-3): decl(a[j]) for j in countup(0, a.len-3): decl(a[j])
@ -99,4 +99,4 @@ proc reorder*(n: PNode): PNode =
result.sons[i].flags = result.sons[i].flags - {nfTempMark, nfPermMark} result.sons[i].flags = result.sons[i].flags - {nfTempMark, nfPermMark}
result.sons[L - i].flags = result.sons[L - i].flags - {nfTempMark, nfPermMark} result.sons[L - i].flags = result.sons[L - i].flags - {nfTempMark, nfPermMark}
swap(result.sons[i], result.sons[L - i]) swap(result.sons[i], result.sons[L - i])
echo result #echo result

View file

@ -3,10 +3,11 @@ discard """
output: '''works 34 output: '''works 34
34 34
defined defined
first impl''' 3'''
""" """
{.reorder: on.} {.reorder: on.}
{.experimental.}
{.push callconv: stdcall.} {.push callconv: stdcall.}
proc bar(x: T) proc bar(x: T)
@ -32,11 +33,14 @@ else:
proc whendep() = echo "undefined" proc whendep() = echo "undefined"
when not declared(goo): when not declared(goo):
proc goo() = echo "first impl" proc goo(my, omy) = echo my
when not declared(goo): when not declared(goo):
proc goo() = echo "second impl" proc goo(my, omy) = echo omy
goo() using
my, omy: int
goo(3, 4)
{.pop.} {.pop.}