refactorings (#20536)
* refactoring * refactoring: removed unused macroUsagesSection * enum instead of bool for better readability
This commit is contained in:
parent
e290b028ab
commit
08ae3467b9
9 changed files with 16 additions and 16 deletions
|
|
@ -27,7 +27,11 @@ import
|
|||
when defined(nimPreviewSlimSystem):
|
||||
import std/assertions
|
||||
|
||||
proc transformBody*(g: ModuleGraph; idgen: IdGenerator, prc: PSym, cache: bool): PNode
|
||||
type
|
||||
TransformBodyFlag* = enum
|
||||
dontUseCache, useCache
|
||||
|
||||
proc transformBody*(g: ModuleGraph; idgen: IdGenerator, prc: PSym, flag: TransformBodyFlag): PNode
|
||||
|
||||
import closureiters, lambdalifting
|
||||
|
||||
|
|
@ -114,7 +118,7 @@ proc transformSymAux(c: PTransf, n: PNode): PNode =
|
|||
let s = n.sym
|
||||
if s.typ != nil and s.typ.callConv == ccClosure:
|
||||
if s.kind in routineKinds:
|
||||
discard transformBody(c.graph, c.idgen, s, true)
|
||||
discard transformBody(c.graph, c.idgen, s, useCache)
|
||||
if s.kind == skIterator:
|
||||
if c.tooEarly: return n
|
||||
else: return liftIterSym(c.graph, n, c.idgen, getCurrOwner(c))
|
||||
|
|
@ -748,7 +752,7 @@ proc transformFor(c: PTransf, n: PNode): PNode =
|
|||
stmtList.add(newAsgnStmt(c, nkFastAsgn, temp, arg, true))
|
||||
idNodeTablePut(newC.mapping, formal, temp)
|
||||
|
||||
let body = transformBody(c.graph, c.idgen, iter, true)
|
||||
let body = transformBody(c.graph, c.idgen, iter, useCache)
|
||||
pushInfoContext(c.graph.config, n.info)
|
||||
inc(c.inlining)
|
||||
stmtList.add(transform(c, body))
|
||||
|
|
@ -1147,7 +1151,7 @@ template liftDefer(c, root) =
|
|||
if c.deferDetected:
|
||||
liftDeferAux(root)
|
||||
|
||||
proc transformBody*(g: ModuleGraph; idgen: IdGenerator; prc: PSym; cache: bool): PNode =
|
||||
proc transformBody*(g: ModuleGraph; idgen: IdGenerator; prc: PSym; flag: TransformBodyFlag): PNode =
|
||||
assert prc.kind in routineKinds
|
||||
|
||||
if prc.transformedBody != nil:
|
||||
|
|
@ -1167,7 +1171,7 @@ proc transformBody*(g: ModuleGraph; idgen: IdGenerator; prc: PSym; cache: bool):
|
|||
|
||||
incl(result.flags, nfTransf)
|
||||
|
||||
if cache or prc.typ.callConv == ccInline:
|
||||
if flag == useCache or prc.typ.callConv == ccInline:
|
||||
# genProc for inline procs will be called multiple times from different modules,
|
||||
# it is important to transform exactly once to get sym ids and locations right
|
||||
prc.transformedBody = result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue