symbol files: fixes the logic for multi-methods

This commit is contained in:
Araq 2018-01-03 02:36:29 +01:00
commit 720c73e6d5
4 changed files with 11 additions and 7 deletions

View file

@ -1258,7 +1258,7 @@ proc resetModule*(m: BModule) =
# indicate that this is now cached module # indicate that this is now cached module
# the cache will be invalidated by nullifying gModules # the cache will be invalidated by nullifying gModules
m.fromCache = true #m.fromCache = true
m.g = nil m.g = nil
# we keep only the "merge info" information for the module # 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: # generate code for the init statements of the module:
let cfile = getCFile(m) let cfile = getCFile(m)
if not m.fromCache or optForceFullMake in gGlobalOptions: if m.rd == nil or optForceFullMake in gGlobalOptions:
genInitCode(m) genInitCode(m)
finishTypeDescriptions(m) finishTypeDescriptions(m)
if sfMainModule in m.module.flags: if sfMainModule in m.module.flags:
@ -1465,10 +1465,10 @@ proc cgenWriteModules*(backend: RootRef, config: ConfigRef) =
if g.generatedHeader != nil: finishModule(g.generatedHeader) if g.generatedHeader != nil: finishModule(g.generatedHeader)
while g.forwardedProcsCounter > 0: while g.forwardedProcsCounter > 0:
for m in cgenModules(g): for m in cgenModules(g):
if not m.fromCache: if m.rd == nil:
finishModule(m) finishModule(m)
for m in cgenModules(g): for m in cgenModules(g):
if m.fromCache: if m.rd != nil:
m.updateCachedModule m.updateCachedModule
else: else:
m.writeModule(pending=true) m.writeModule(pending=true)

View file

@ -18,7 +18,7 @@ import
type type
TPassContext* = object of RootObj # the pass's context 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 PPassContext* = ref TPassContext
@ -118,7 +118,7 @@ proc openPassesCached(g: ModuleGraph; a: var TPassContextArray, module: PSym,
if not isNil(gPasses[i].openCached): if not isNil(gPasses[i].openCached):
a[i] = gPasses[i].openCached(g, module, rd) a[i] = gPasses[i].openCached(g, module, rd)
if a[i] != nil: if a[i] != nil:
a[i].fromCache = true a[i].rd = rd
else: else:
a[i] = nil a[i] = nil

View file

@ -501,6 +501,8 @@ proc myOpen(graph: ModuleGraph; module: PSym; cache: IdentCache): PPassContext =
proc myOpenCached(graph: ModuleGraph; module: PSym; rd: PRodReader): PPassContext = proc myOpenCached(graph: ModuleGraph; module: PSym; rd: PRodReader): PPassContext =
result = myOpen(graph, module, rd.cache) result = myOpen(graph, module, rd.cache)
proc replayMethodDefs(graph: ModuleGraph; rd: PRodReader) =
for m in items(rd.methods): methodDef(graph, m, true) for m in items(rd.methods): methodDef(graph, m, true)
proc isImportSystemStmt(n: PNode): bool = proc isImportSystemStmt(n: PNode): bool =
@ -607,6 +609,8 @@ proc myClose(graph: ModuleGraph; context: PPassContext, n: PNode): PNode =
addCodeForGenerics(c, result) addCodeForGenerics(c, result)
if c.module.ast != nil: if c.module.ast != nil:
result.add(c.module.ast) result.add(c.module.ast)
if c.rd != nil:
replayMethodDefs(graph, c.rd)
popOwner(c) popOwner(c)
popProcCon(c) popProcCon(c)
if c.runnableExamples != nil: testExamples(c) if c.runnableExamples != nil: testExamples(c)

View file

@ -914,7 +914,7 @@ proc processTransf(c: PTransf, n: PNode, owner: PSym): PNode =
# Note: For interactive mode we cannot call 'passes.skipCodegen' and skip # Note: For interactive mode we cannot call 'passes.skipCodegen' and skip
# this step! We have to rely that the semantic pass transforms too errornous # this step! We have to rely that the semantic pass transforms too errornous
# nodes into an empty node. # 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)) pushTransCon(c, newTransCon(owner))
result = PNode(transform(c, n)) result = PNode(transform(c, n))
popTransCon(c) popTransCon(c)