From e2af486434c7ff401c412d890b490b4ac11ab321 Mon Sep 17 00:00:00 2001 From: BigEpsilon Date: Sat, 28 Oct 2017 11:33:35 +0200 Subject: Add sections (type, var, let, const, using) support for reorder pragma (#6326) --- compiler/passes.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'compiler/passes.nim') diff --git a/compiler/passes.nim b/compiler/passes.nim index 6efd50385..b84fe2f4d 100644 --- a/compiler/passes.nim +++ b/compiler/passes.nim @@ -15,6 +15,7 @@ import condsyms, idents, renderer, types, extccomp, math, magicsys, nversion, nimsets, syntaxes, times, rodread, idgen, modulegraphs, reorder + type TPassContext* = object of RootObj # the pass's context fromCache*: bool # true if created by "openCached" @@ -211,7 +212,7 @@ proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream, if n.kind == nkEmpty: break sl.add n if sfReorder in module.flags: - sl = reorder sl + sl = reorder(graph, sl, module, cache) discard processTopLevelStmt(sl, a) break elif not processTopLevelStmt(n, a): break -- cgit 1.4.1-2-gfad0 From 720c73e6d5c8b21a2d6d528a3a8947e498e9d1ad Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 3 Jan 2018 02:36:29 +0100 Subject: symbol files: fixes the logic for multi-methods --- compiler/cgen.nim | 8 ++++---- compiler/passes.nim | 4 ++-- compiler/sem.nim | 4 ++++ compiler/transf.nim | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'compiler/passes.nim') diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 217138dd0..573a14927 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1258,7 +1258,7 @@ proc resetModule*(m: BModule) = # indicate that this is now cached module # the cache will be invalidated by nullifying gModules - m.fromCache = true + #m.fromCache = true m.g = nil # we keep only the "merge info" information for the module @@ -1390,7 +1390,7 @@ proc writeModule(m: BModule, pending: bool) = # generate code for the init statements of the module: let cfile = getCFile(m) - if not m.fromCache or optForceFullMake in gGlobalOptions: + if m.rd == nil or optForceFullMake in gGlobalOptions: genInitCode(m) finishTypeDescriptions(m) if sfMainModule in m.module.flags: @@ -1465,10 +1465,10 @@ proc cgenWriteModules*(backend: RootRef, config: ConfigRef) = if g.generatedHeader != nil: finishModule(g.generatedHeader) while g.forwardedProcsCounter > 0: for m in cgenModules(g): - if not m.fromCache: + if m.rd == nil: finishModule(m) for m in cgenModules(g): - if m.fromCache: + if m.rd != nil: m.updateCachedModule else: m.writeModule(pending=true) diff --git a/compiler/passes.nim b/compiler/passes.nim index b84fe2f4d..29b27627d 100644 --- a/compiler/passes.nim +++ b/compiler/passes.nim @@ -18,7 +18,7 @@ import type TPassContext* = object of RootObj # the pass's context - fromCache*: bool # true if created by "openCached" + rd*: PRodReader # != nil if created by "openCached" PPassContext* = ref TPassContext @@ -118,7 +118,7 @@ proc openPassesCached(g: ModuleGraph; a: var TPassContextArray, module: PSym, if not isNil(gPasses[i].openCached): a[i] = gPasses[i].openCached(g, module, rd) if a[i] != nil: - a[i].fromCache = true + a[i].rd = rd else: a[i] = nil diff --git a/compiler/sem.nim b/compiler/sem.nim index d2831827a..1098e9961 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -501,6 +501,8 @@ proc myOpen(graph: ModuleGraph; module: PSym; cache: IdentCache): PPassContext = proc myOpenCached(graph: ModuleGraph; module: PSym; rd: PRodReader): PPassContext = result = myOpen(graph, module, rd.cache) + +proc replayMethodDefs(graph: ModuleGraph; rd: PRodReader) = for m in items(rd.methods): methodDef(graph, m, true) proc isImportSystemStmt(n: PNode): bool = @@ -607,6 +609,8 @@ proc myClose(graph: ModuleGraph; context: PPassContext, n: PNode): PNode = addCodeForGenerics(c, result) if c.module.ast != nil: result.add(c.module.ast) + if c.rd != nil: + replayMethodDefs(graph, c.rd) popOwner(c) popProcCon(c) if c.runnableExamples != nil: testExamples(c) diff --git a/compiler/transf.nim b/compiler/transf.nim index 6bc809fd2..f8f7f8746 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -914,7 +914,7 @@ proc processTransf(c: PTransf, n: PNode, owner: PSym): PNode = # Note: For interactive mode we cannot call 'passes.skipCodegen' and skip # this step! We have to rely that the semantic pass transforms too errornous # nodes into an empty node. - if c.fromCache or nfTransf in n.flags: return n + if c.rd != nil or nfTransf in n.flags: return n pushTransCon(c, newTransCon(owner)) result = PNode(transform(c, n)) popTransCon(c) -- cgit 1.4.1-2-gfad0