diff options
author | cooldome <cdome@bk.ru> | 2018-10-18 19:21:25 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-10-18 20:21:25 +0200 |
commit | eaca5be9d6e205e8aa7055306122a6c053ef35a6 (patch) | |
tree | 784c5f2726a94b656e3f85ab231c4dfc377cc167 /compiler/sempass2.nim | |
parent | 15dbd973dec848f1c429fe7043e53254a501812b (diff) | |
download | Nim-eaca5be9d6e205e8aa7055306122a6c053ef35a6.tar.gz |
Change the order of compilation passes, transformation is made lazy at code gen (#8489)
* Ast no transformation * Add getImplNoTransform to the macros module * progress on delaying transf * Fix methods tranformation * Fix lazy lambdalifting * fix create thread wrapper * transform for lambda lifting * improve getImplTransformed * Fix destructor tests * try to fix nimprof for linux
Diffstat (limited to 'compiler/sempass2.nim')
-rw-r--r-- | compiler/sempass2.nim | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 0a9de674b..c1bdb08a8 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -9,7 +9,7 @@ import intsets, ast, astalgo, msgs, renderer, magicsys, types, idents, trees, - wordrecg, strutils, options, guards, writetracking, lineinfos, + wordrecg, strutils, options, guards, writetracking, lineinfos, semfold, modulegraphs when defined(useDfa): @@ -48,6 +48,7 @@ type tags: PNode # list of tags bottom, inTryStmt: int owner: PSym + owner_module: PSym init: seq[int] # list of initialized variables guards: TModel # nested guards locked: seq[PNode] # locked locations @@ -562,8 +563,10 @@ proc trackOperand(tracked: PEffects, n: PNode, paramType: PType) = if op != nil and op.kind == tyProc and n.skipConv.kind != nkNilLit: internalAssert tracked.config, op.n.sons[0].kind == nkEffectList var effectList = op.n.sons[0] - let s = n.skipConv - if s.kind == nkSym and s.sym.kind in routineKinds: + var s = n.skipConv + if s.kind == nkCast and s[1].typ.kind == tyProc: + s = s[1] + if s.kind == nkSym and s.sym.kind in routineKinds and isNoEffectList(effectList): propagateEffects(tracked, n, s.sym) elif isNoEffectList(effectList): if isForwardedProc(n): @@ -709,9 +712,13 @@ proc track(tracked: PEffects, n: PNode) = for i in 0 ..< safeLen(n): track(tracked, n.sons[i]) of nkCallKinds: + if getConstExpr(tracked.owner_module, n, tracked.graph) != nil: + return # p's effects are ours too: - let a = n.sons[0] + var a = n.sons[0] let op = a.typ + if a.kind == nkCast and a[1].typ.kind == tyProc: + a = a[1] # XXX: in rare situations, templates and macros will reach here after # calling getAst(templateOrMacro()). Currently, templates and macros # are indistinguishable from normal procs (both have tyProc type) and @@ -934,6 +941,7 @@ proc initEffects(g: ModuleGraph; effects: PNode; s: PSym; t: var TEffects) = t.exc = effects.sons[exceptionEffects] t.tags = effects.sons[tagEffects] t.owner = s + t.owner_module = s.getModule t.init = @[] t.guards.s = @[] t.guards.o = initOperators(g) |