mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
Don't leak sem PContext into transf
This commit is contained in:
@@ -145,7 +145,7 @@ proc instantiateBody(c: PContext, n, params: PNode, result, orig: PSym) =
|
||||
freshGenSyms(b, result, orig, symMap)
|
||||
b = semProcBody(c, b)
|
||||
b = hloBody(c, b)
|
||||
n.sons[bodyPos] = transformBody(c, b, result)
|
||||
n.sons[bodyPos] = transformBody(c.module, c.features, b, result)
|
||||
#echo "code instantiated ", result.name.s
|
||||
excl(result.flags, sfForward)
|
||||
dec c.inGenericInst
|
||||
|
||||
@@ -1236,7 +1236,7 @@ proc semLambda(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
addResult(c, s.typ.sons[0], n.info, skProc)
|
||||
addResultNode(c, n)
|
||||
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
||||
n.sons[bodyPos] = transformBody(c, semBody, s)
|
||||
n.sons[bodyPos] = transformBody(c.module, c.features, semBody, s)
|
||||
popProcCon(c)
|
||||
elif efOperand notin flags:
|
||||
localError(n.info, errGenericLambdaNotAllowed)
|
||||
@@ -1277,7 +1277,7 @@ proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode =
|
||||
addResult(c, n.typ.sons[0], n.info, skProc)
|
||||
addResultNode(c, n)
|
||||
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
||||
n.sons[bodyPos] = transformBody(c, semBody, s)
|
||||
n.sons[bodyPos] = transformBody(c.module, c.features, semBody, s)
|
||||
popProcCon(c)
|
||||
popOwner(c)
|
||||
closeScope(c)
|
||||
@@ -1590,7 +1590,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
||||
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
||||
# unfortunately we cannot skip this step when in 'system.compiles'
|
||||
# context as it may even be evaluated in 'system.compiles':
|
||||
n.sons[bodyPos] = transformBody(c, semBody, s)
|
||||
n.sons[bodyPos] = transformBody(c.module, c.features, semBody, s)
|
||||
else:
|
||||
if s.typ.sons[0] != nil and kind != skIterator:
|
||||
addDecl(c, newSym(skUnknown, getIdent"result", nil, n.info))
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
|
||||
import
|
||||
intsets, strutils, options, ast, astalgo, trees, treetab, msgs, os, lookups,
|
||||
idents, renderer, types, passes, semfold, magicsys, cgmeth, rodread, semdata,
|
||||
idents, renderer, types, passes, semfold, magicsys, cgmeth, rodread,
|
||||
lambdalifting, sempass2, lowerings, destroyer, liftlocals, closureiters
|
||||
|
||||
|
||||
type
|
||||
PTransNode* = distinct PNode
|
||||
|
||||
@@ -968,11 +967,11 @@ template liftDefer(c, root) =
|
||||
if c.deferDetected:
|
||||
liftDeferAux(root)
|
||||
|
||||
proc transformBody*(ctx: PContext, n: PNode, prc: PSym): PNode =
|
||||
proc transformBody*(module: PSym, features: set[Feature], n: PNode, prc: PSym): PNode =
|
||||
result = n
|
||||
if nfTransf notin n.flags and prc.kind notin {skTemplate}:
|
||||
var c = openTransf(ctx.module, "")
|
||||
result = liftLambdas(ctx.features, prc, result, c.tooEarly)
|
||||
var c = openTransf(module, "")
|
||||
result = liftLambdas(features, prc, result, c.tooEarly)
|
||||
result = processTransf(c, result, prc)
|
||||
liftDefer(c, result)
|
||||
|
||||
@@ -981,7 +980,7 @@ proc transformBody*(ctx: PContext, n: PNode, prc: PSym): PNode =
|
||||
if c.needsDestroyPass: #and newDestructors:
|
||||
result = injectDestructorCalls(prc, result)
|
||||
|
||||
if prc.isIterator and oldIterTransf notin ctx.features:
|
||||
if prc.isIterator and oldIterTransf notin features:
|
||||
result = transformClosureIterator(prc, result)
|
||||
|
||||
incl(result.flags, nfTransf)
|
||||
|
||||
Reference in New Issue
Block a user