symbol files: delay the emission of forwarded procs
This commit is contained in:
parent
046ed4ed22
commit
67380f71d6
3 changed files with 20 additions and 9 deletions
|
|
@ -20,6 +20,8 @@ when not defined(nimSymbolfiles):
|
||||||
|
|
||||||
template addModuleDep*(module, fileIdx: int32; isIncludeFile: bool) = discard
|
template addModuleDep*(module, fileIdx: int32; isIncludeFile: bool) = discard
|
||||||
|
|
||||||
|
template storeRemaining*(module: PSym) = discard
|
||||||
|
|
||||||
else:
|
else:
|
||||||
include rodimpl
|
include rodimpl
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ import strutils, os, intsets, tables, ropes, db_sqlite, msgs, options, types,
|
||||||
## Todo:
|
## Todo:
|
||||||
## - Implement the 'import' replay logic so that the codegen runs over
|
## - Implement the 'import' replay logic so that the codegen runs over
|
||||||
## dependent modules.
|
## dependent modules.
|
||||||
|
## - Make conditional symbols and the configuration part of a module's
|
||||||
|
## dependencies.
|
||||||
## - Test multi methods.
|
## - Test multi methods.
|
||||||
## - Implement the limited VM support based on sets.
|
## - Implement the limited VM support based on sets.
|
||||||
## - Depencency computation should use signature hashes in order to
|
## - Depencency computation should use signature hashes in order to
|
||||||
|
|
@ -49,7 +51,7 @@ proc getModuleId*(fileIdx: int32; fullpath: string): int =
|
||||||
if gSymbolFiles != v2Sf: return getID()
|
if gSymbolFiles != v2Sf: return getID()
|
||||||
let module = db.getRow(
|
let module = db.getRow(
|
||||||
sql"select id, fullHash from modules where fullpath = ?", fullpath)
|
sql"select id, fullHash from modules where fullpath = ?", fullpath)
|
||||||
let currentFullhash = $secureHashFile(fullpath)
|
let currentFullhash = hashFileCached(fileIdx, fullpath)
|
||||||
if module[0].len == 0:
|
if module[0].len == 0:
|
||||||
result = int db.insertID(sql"insert into modules(fullpath, interfHash, fullHash) values (?, ?, ?)",
|
result = int db.insertID(sql"insert into modules(fullpath, interfHash, fullHash) values (?, ?, ?)",
|
||||||
fullpath, "", currentFullhash)
|
fullpath, "", currentFullhash)
|
||||||
|
|
@ -75,12 +77,13 @@ type
|
||||||
sstack: seq[PSym] # a stack of symbols to process
|
sstack: seq[PSym] # a stack of symbols to process
|
||||||
tstack: seq[PType] # a stack of types to process
|
tstack: seq[PType] # a stack of types to process
|
||||||
tmarks, smarks: IntSet
|
tmarks, smarks: IntSet
|
||||||
|
forwardedSyms: seq[PSym]
|
||||||
|
|
||||||
PRodWriter = var TRodWriter
|
PRodWriter = var TRodWriter
|
||||||
|
|
||||||
proc initRodWriter(module: PSym): TRodWriter =
|
proc initRodWriter(module: PSym): TRodWriter =
|
||||||
result = TRodWriter(module: module, sstack: @[], tstack: @[],
|
result = TRodWriter(module: module, sstack: @[], tstack: @[],
|
||||||
tmarks: initIntSet(), smarks: initIntSet())
|
tmarks: initIntSet(), smarks: initIntSet(), forwardedSyms: @[])
|
||||||
|
|
||||||
when false:
|
when false:
|
||||||
proc getDefines(): string =
|
proc getDefines(): string =
|
||||||
|
|
@ -89,13 +92,6 @@ when false:
|
||||||
if result.len != 0: add(result, " ")
|
if result.len != 0: add(result, " ")
|
||||||
add(result, d)
|
add(result, d)
|
||||||
|
|
||||||
proc addInclDep(w: PRodWriter, dep: string; info: TLineInfo) =
|
|
||||||
let resolved = dep.findModule(info.toFullPath)
|
|
||||||
encodeVInt(fileIdx(w, resolved), w.inclDeps)
|
|
||||||
add(w.inclDeps, " ")
|
|
||||||
encodeStr($secureHashFile(resolved), w.inclDeps)
|
|
||||||
add(w.inclDeps, rodNL)
|
|
||||||
|
|
||||||
const
|
const
|
||||||
rodNL = "\L"
|
rodNL = "\L"
|
||||||
|
|
||||||
|
|
@ -381,6 +377,9 @@ proc encodeSym(w: PRodWriter, s: PSym, result: var string) =
|
||||||
encodeNode(w, s.info, s.ast, result)
|
encodeNode(w, s.info, s.ast, result)
|
||||||
|
|
||||||
proc storeSym(w: PRodWriter; s: PSym) =
|
proc storeSym(w: PRodWriter; s: PSym) =
|
||||||
|
if sfForward in s.flags and s.kind != skModule:
|
||||||
|
w.forwardedSyms.add s
|
||||||
|
return
|
||||||
var buf = newStringOfCap(160)
|
var buf = newStringOfCap(160)
|
||||||
encodeSym(w, s, buf)
|
encodeSym(w, s, buf)
|
||||||
# XXX only store the name for exported symbols in order to speed up lookup
|
# XXX only store the name for exported symbols in order to speed up lookup
|
||||||
|
|
@ -421,6 +420,14 @@ proc storeNode*(module: PSym; n: PNode) =
|
||||||
break
|
break
|
||||||
inc i
|
inc i
|
||||||
|
|
||||||
|
proc storeRemaining*(module: PSym) =
|
||||||
|
if gSymbolFiles != v2Sf: return
|
||||||
|
w.module = module
|
||||||
|
for s in w.forwardedSyms:
|
||||||
|
assert sfForward notin s.flags
|
||||||
|
storeSym(w, s)
|
||||||
|
w.forwardedSyms.setLen 0
|
||||||
|
|
||||||
# ---------------- decoder -----------------------------------
|
# ---------------- decoder -----------------------------------
|
||||||
type
|
type
|
||||||
TRodReader = object
|
TRodReader = object
|
||||||
|
|
@ -781,6 +788,7 @@ proc loadSymFromBlob(r; b; info: TLineInfo): PSym =
|
||||||
result.ast = decodeNode(r, b, result.info)
|
result.ast = decodeNode(r, b, result.info)
|
||||||
if sfCompilerProc in result.flags:
|
if sfCompilerProc in result.flags:
|
||||||
registerCompilerProc(result)
|
registerCompilerProc(result)
|
||||||
|
#echo "loading ", result.name.s
|
||||||
|
|
||||||
proc loadSym(r; id: int; info: TLineInfo): PSym =
|
proc loadSym(r; id: int; info: TLineInfo): PSym =
|
||||||
result = r.syms.getOrDefault(id)
|
result = r.syms.getOrDefault(id)
|
||||||
|
|
|
||||||
|
|
@ -619,6 +619,7 @@ proc myClose(graph: ModuleGraph; context: PPassContext, n: PNode): PNode =
|
||||||
replayMethodDefs(graph, c.rd)
|
replayMethodDefs(graph, c.rd)
|
||||||
popOwner(c)
|
popOwner(c)
|
||||||
popProcCon(c)
|
popProcCon(c)
|
||||||
|
storeRemaining(c.module)
|
||||||
if c.runnableExamples != nil: testExamples(c)
|
if c.runnableExamples != nil: testExamples(c)
|
||||||
|
|
||||||
const semPass* = makePass(myOpen, myOpenCached, myProcess, myClose,
|
const semPass* = makePass(myOpen, myOpenCached, myProcess, myClose,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue