Don't leak sem PContext into transf
This commit is contained in:
parent
13167c85f6
commit
48d8e215d5
3 changed files with 9 additions and 10 deletions
|
|
@ -145,7 +145,7 @@ proc instantiateBody(c: PContext, n, params: PNode, result, orig: PSym) =
|
||||||
freshGenSyms(b, result, orig, symMap)
|
freshGenSyms(b, result, orig, symMap)
|
||||||
b = semProcBody(c, b)
|
b = semProcBody(c, b)
|
||||||
b = hloBody(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
|
#echo "code instantiated ", result.name.s
|
||||||
excl(result.flags, sfForward)
|
excl(result.flags, sfForward)
|
||||||
dec c.inGenericInst
|
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)
|
addResult(c, s.typ.sons[0], n.info, skProc)
|
||||||
addResultNode(c, n)
|
addResultNode(c, n)
|
||||||
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
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)
|
popProcCon(c)
|
||||||
elif efOperand notin flags:
|
elif efOperand notin flags:
|
||||||
localError(n.info, errGenericLambdaNotAllowed)
|
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)
|
addResult(c, n.typ.sons[0], n.info, skProc)
|
||||||
addResultNode(c, n)
|
addResultNode(c, n)
|
||||||
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
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)
|
popProcCon(c)
|
||||||
popOwner(c)
|
popOwner(c)
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
|
|
@ -1590,7 +1590,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
||||||
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
let semBody = hloBody(c, semProcBody(c, n.sons[bodyPos]))
|
||||||
# unfortunately we cannot skip this step when in 'system.compiles'
|
# unfortunately we cannot skip this step when in 'system.compiles'
|
||||||
# context as it may even be evaluated 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:
|
else:
|
||||||
if s.typ.sons[0] != nil and kind != skIterator:
|
if s.typ.sons[0] != nil and kind != skIterator:
|
||||||
addDecl(c, newSym(skUnknown, getIdent"result", nil, n.info))
|
addDecl(c, newSym(skUnknown, getIdent"result", nil, n.info))
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
intsets, strutils, options, ast, astalgo, trees, treetab, msgs, os, lookups,
|
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
|
lambdalifting, sempass2, lowerings, destroyer, liftlocals, closureiters
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
PTransNode* = distinct PNode
|
PTransNode* = distinct PNode
|
||||||
|
|
||||||
|
|
@ -968,11 +967,11 @@ template liftDefer(c, root) =
|
||||||
if c.deferDetected:
|
if c.deferDetected:
|
||||||
liftDeferAux(root)
|
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
|
result = n
|
||||||
if nfTransf notin n.flags and prc.kind notin {skTemplate}:
|
if nfTransf notin n.flags and prc.kind notin {skTemplate}:
|
||||||
var c = openTransf(ctx.module, "")
|
var c = openTransf(module, "")
|
||||||
result = liftLambdas(ctx.features, prc, result, c.tooEarly)
|
result = liftLambdas(features, prc, result, c.tooEarly)
|
||||||
result = processTransf(c, result, prc)
|
result = processTransf(c, result, prc)
|
||||||
liftDefer(c, result)
|
liftDefer(c, result)
|
||||||
|
|
||||||
|
|
@ -981,7 +980,7 @@ proc transformBody*(ctx: PContext, n: PNode, prc: PSym): PNode =
|
||||||
if c.needsDestroyPass: #and newDestructors:
|
if c.needsDestroyPass: #and newDestructors:
|
||||||
result = injectDestructorCalls(prc, result)
|
result = injectDestructorCalls(prc, result)
|
||||||
|
|
||||||
if prc.isIterator and oldIterTransf notin ctx.features:
|
if prc.isIterator and oldIterTransf notin features:
|
||||||
result = transformClosureIterator(prc, result)
|
result = transformClosureIterator(prc, result)
|
||||||
|
|
||||||
incl(result.flags, nfTransf)
|
incl(result.flags, nfTransf)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue