avoid duplicated variable names in unrolled loops
This commit is contained in:
parent
20d56875de
commit
57fe3e8c41
2 changed files with 7 additions and 2 deletions
|
|
@ -62,6 +62,7 @@ type
|
||||||
AmbiguousSymbols*: TIntSet # ids of all ambiguous symbols (cannot
|
AmbiguousSymbols*: TIntSet # ids of all ambiguous symbols (cannot
|
||||||
# store this info in the syms themselves!)
|
# store this info in the syms themselves!)
|
||||||
InGenericContext*: int # > 0 if we are in a generic
|
InGenericContext*: int # > 0 if we are in a generic
|
||||||
|
InUnrolledContext*: int # > 0 if we are unrolling a loop
|
||||||
converters*: TSymSeq # sequence of converters
|
converters*: TSymSeq # sequence of converters
|
||||||
optionStack*: TLinkedList
|
optionStack*: TLinkedList
|
||||||
libs*: TLinkedList # all libs used by this module
|
libs*: TLinkedList # all libs used by this module
|
||||||
|
|
|
||||||
|
|
@ -274,8 +274,10 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
var v = semIdentDef(c, a.sons[j], symkind)
|
var v = semIdentDef(c, a.sons[j], symkind)
|
||||||
addInterfaceDecl(c, v)
|
addInterfaceDecl(c, v)
|
||||||
when oKeepVariableNames:
|
when oKeepVariableNames:
|
||||||
let shadowed = findShadowedVar(c, v)
|
if c.InUnrolledContext > 0: v.flags.incl(sfShadowed)
|
||||||
if shadowed != nil: shadowed.flags.incl(sfShadowed)
|
else:
|
||||||
|
let shadowed = findShadowedVar(c, v)
|
||||||
|
if shadowed != nil: shadowed.flags.incl(sfShadowed)
|
||||||
if def != nil and def.kind != nkEmpty:
|
if def != nil and def.kind != nkEmpty:
|
||||||
# this is only needed for the evaluation pass:
|
# this is only needed for the evaluation pass:
|
||||||
v.ast = def
|
v.ast = def
|
||||||
|
|
@ -401,7 +403,9 @@ proc semForFields(c: PContext, n: PNode, m: TMagic): PNode =
|
||||||
openScope(c.tab)
|
openScope(c.tab)
|
||||||
var body = transfFieldLoopBody(loopBody, n, tupleTypeA, i,
|
var body = transfFieldLoopBody(loopBody, n, tupleTypeA, i,
|
||||||
ord(m==mFieldPairs))
|
ord(m==mFieldPairs))
|
||||||
|
inc c.InUnrolledContext
|
||||||
stmts.add(SemStmt(c, body))
|
stmts.add(SemStmt(c, body))
|
||||||
|
dec c.InUnrolledContext
|
||||||
closeScope(c.tab)
|
closeScope(c.tab)
|
||||||
Dec(c.p.nestedLoopCounter)
|
Dec(c.p.nestedLoopCounter)
|
||||||
var b = newNodeI(nkBreakStmt, n.info)
|
var b = newNodeI(nkBreakStmt, n.info)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue