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/cgen.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/cgen.nim')
-rw-r--r-- | compiler/cgen.nim | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 86aa7fb45..26d66a0f5 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -14,7 +14,7 @@ import nversion, nimsets, msgs, std / sha1, bitsets, idents, types, ccgutils, os, ropes, math, passes, wordrecg, treetab, cgmeth, condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases, - lowerings, semparallel, tables, sets, ndi, lineinfos, pathutils + lowerings, semparallel, tables, sets, ndi, lineinfos, pathutils, transf import strutils except `%` # collides with ropes.`%` @@ -845,6 +845,8 @@ proc genProcAux(m: BModule, prc: PSym) = var header = genProcHeader(m, prc) var returnStmt: Rope = nil assert(prc.ast != nil) + let procBody = transformBody(m.g.graph, prc, cache = false) + if sfPure notin prc.flags and prc.typ.sons[0] != nil: if resultPos >= prc.ast.len: internalError(m.config, prc.info, "proc has no result symbol") @@ -852,7 +854,7 @@ proc genProcAux(m: BModule, prc: PSym) = let res = resNode.sym # get result symbol if not isInvalidReturnType(m.config, prc.typ.sons[0]): if sfNoInit in prc.flags: incl(res.flags, sfNoInit) - if sfNoInit in prc.flags and p.module.compileToCpp and (let val = easyResultAsgn(prc.getBody); val != nil): + if sfNoInit in prc.flags and p.module.compileToCpp and (let val = easyResultAsgn(procBody); val != nil): var decl = localVarDecl(p, resNode) var a: TLoc initLocExprSingleUse(p, val, a) @@ -873,7 +875,7 @@ proc genProcAux(m: BModule, prc: PSym) = # global is either 'nil' or points to valid memory and so the RC operation # succeeds without touching not-initialized memory. if sfNoInit in prc.flags: discard - elif allPathsAsgnResult(prc.getBody) == InitSkippable: discard + elif allPathsAsgnResult(procBody) == InitSkippable: discard else: resetLoc(p, res.loc) if skipTypes(res.typ, abstractInst).kind == tyArray: @@ -885,7 +887,7 @@ proc genProcAux(m: BModule, prc: PSym) = if param.typ.isCompileTimeOnly: continue assignParam(p, param) closureSetup(p, prc) - genStmts(p, prc.getBody) # modifies p.locals, p.init, etc. + genStmts(p, procBody) # modifies p.locals, p.init, etc. var generatedProc: Rope if sfNoReturn in prc.flags: if hasDeclspec in extccomp.CC[p.config.cCompiler].props: @@ -1522,7 +1524,8 @@ proc myProcess(b: PPassContext, n: PNode): PNode = m.initProc.options = initProcOptions(m) #softRnl = if optLineDir in m.config.options: noRnl else: rnl # XXX replicate this logic! - genStmts(m.initProc, n) + let tranformed_n = transformStmt(m.g.graph, m.module, n) + genStmts(m.initProc, tranformed_n) proc finishModule(m: BModule) = var i = 0 |