symbol files: fixes the logic for multi-methods

This commit is contained in:
Araq
2018-01-03 02:36:29 +01:00
parent 29db57a804
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
# 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)

View File

@@ -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

View File

@@ -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)

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
# 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)