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
This commit is contained in:
parent
15dbd973de
commit
eaca5be9d6
22 changed files with 188 additions and 85 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue