IC: further progress
This commit is contained in:
parent
962b2e4b39
commit
61d08ebcd8
3 changed files with 30 additions and 11 deletions
|
|
@ -100,7 +100,7 @@ proc importAllSymbolsExcept(c: PContext, fromMod: PSym, exceptSet: IntSet) =
|
||||||
if s.kind != skModule:
|
if s.kind != skModule:
|
||||||
if s.kind != skEnumField:
|
if s.kind != skEnumField:
|
||||||
if s.kind notin ExportableSymKinds:
|
if s.kind notin ExportableSymKinds:
|
||||||
internalError(c.config, s.info, "importAllSymbols: " & $s.kind)
|
internalError(c.config, s.info, "importAllSymbols: " & $s.kind & " " & s.name.s)
|
||||||
if exceptSet.isNil or s.name.id notin exceptSet:
|
if exceptSet.isNil or s.name.id notin exceptSet:
|
||||||
rawImportSymbol(c, s)
|
rawImportSymbol(c, s)
|
||||||
s = nextIter(i, fromMod.tab)
|
s = nextIter(i, fromMod.tab)
|
||||||
|
|
|
||||||
|
|
@ -366,13 +366,7 @@ proc storeType(g: ModuleGraph; t: PType) =
|
||||||
db.exec(sql"insert into types(nimid, module, data) values (?, ?, ?)",
|
db.exec(sql"insert into types(nimid, module, data) values (?, ?, ?)",
|
||||||
t.id, mid, buf)
|
t.id, mid, buf)
|
||||||
|
|
||||||
proc storeNode*(g: ModuleGraph; module: PSym; n: PNode) =
|
proc transitiveClosure(g: ModuleGraph) =
|
||||||
if g.config.symbolFiles == disabledSf: return
|
|
||||||
var buf = newStringOfCap(160)
|
|
||||||
encodeNode(g, module.info, n, buf)
|
|
||||||
db.exec(sql"insert into toplevelstmts(module, position, data) values (?, ?, ?)",
|
|
||||||
abs(module.id), module.offset, buf)
|
|
||||||
inc module.offset
|
|
||||||
var i = 0
|
var i = 0
|
||||||
while true:
|
while true:
|
||||||
if i > 10_000:
|
if i > 10_000:
|
||||||
|
|
@ -391,9 +385,25 @@ proc storeNode*(g: ModuleGraph; module: PSym; n: PNode) =
|
||||||
break
|
break
|
||||||
inc i
|
inc i
|
||||||
|
|
||||||
|
proc storeNode*(g: ModuleGraph; module: PSym; n: PNode) =
|
||||||
|
if g.config.symbolFiles == disabledSf: return
|
||||||
|
var buf = newStringOfCap(160)
|
||||||
|
encodeNode(g, module.info, n, buf)
|
||||||
|
db.exec(sql"insert into toplevelstmts(module, position, data) values (?, ?, ?)",
|
||||||
|
abs(module.id), module.offset, buf)
|
||||||
|
inc module.offset
|
||||||
|
transitiveClosure(g)
|
||||||
|
|
||||||
proc recordStmt*(g: ModuleGraph; module: PSym; n: PNode) =
|
proc recordStmt*(g: ModuleGraph; module: PSym; n: PNode) =
|
||||||
storeNode(g, module, n)
|
storeNode(g, module, n)
|
||||||
|
|
||||||
|
proc storeFilename(g: ModuleGraph; fullpath: AbsoluteFile; fileIdx: FileIndex) =
|
||||||
|
let id = db.getValue(sql"select id from filenames where fullpath = ?", fullpath.string)
|
||||||
|
if id.len == 0:
|
||||||
|
let fullhash = hashFileCached(g.config, fileIdx, fullpath)
|
||||||
|
db.exec(sql"insert into filenames(nimid, fullpath, fullhash) values (?, ?, ?)",
|
||||||
|
int(fileIdx), fullpath.string, fullhash)
|
||||||
|
|
||||||
proc storeRemaining*(g: ModuleGraph; module: PSym) =
|
proc storeRemaining*(g: ModuleGraph; module: PSym) =
|
||||||
if g.config.symbolFiles == disabledSf: return
|
if g.config.symbolFiles == disabledSf: return
|
||||||
var stillForwarded: seq[PSym] = @[]
|
var stillForwarded: seq[PSym] = @[]
|
||||||
|
|
@ -403,6 +413,13 @@ proc storeRemaining*(g: ModuleGraph; module: PSym) =
|
||||||
else:
|
else:
|
||||||
stillForwarded.add s
|
stillForwarded.add s
|
||||||
swap w.forwardedSyms, stillForwarded
|
swap w.forwardedSyms, stillForwarded
|
||||||
|
transitiveClosure(g)
|
||||||
|
var nimid = 0
|
||||||
|
for x in items(g.config.m.fileInfos):
|
||||||
|
# don't store the "command line" entry:
|
||||||
|
if nimid != 0:
|
||||||
|
storeFilename(g, x.fullPath, FileIndex(nimid))
|
||||||
|
inc nimid
|
||||||
|
|
||||||
# ---------------- decoder -----------------------------------
|
# ---------------- decoder -----------------------------------
|
||||||
|
|
||||||
|
|
@ -880,20 +897,22 @@ proc setupModuleCache*(g: ModuleGraph) =
|
||||||
if g.config.symbolFiles == writeOnlySf:
|
if g.config.symbolFiles == writeOnlySf:
|
||||||
removeFile(dbfile)
|
removeFile(dbfile)
|
||||||
createDir getNimcacheDir(g.config)
|
createDir getNimcacheDir(g.config)
|
||||||
|
let ec = encodeConfig(g)
|
||||||
if not fileExists(dbfile):
|
if not fileExists(dbfile):
|
||||||
db = open(connection=string dbfile, user="nim", password="",
|
db = open(connection=string dbfile, user="nim", password="",
|
||||||
database="nim")
|
database="nim")
|
||||||
createDb(db)
|
createDb(db)
|
||||||
db.exec(sql"insert into config(config) values (?)", encodeConfig(g))
|
db.exec(sql"insert into config(config) values (?)", ec)
|
||||||
else:
|
else:
|
||||||
db = open(connection=string dbfile, user="nim", password="",
|
db = open(connection=string dbfile, user="nim", password="",
|
||||||
database="nim")
|
database="nim")
|
||||||
let oldConfig = db.getValue(sql"select config from config")
|
let oldConfig = db.getValue(sql"select config from config")
|
||||||
g.incr.configChanged = oldConfig != encodeConfig(g)
|
g.incr.configChanged = oldConfig != ec
|
||||||
# ensure the filename IDs stay consistent:
|
# ensure the filename IDs stay consistent:
|
||||||
for row in db.rows(sql"select fullpath, nimid from filenames order by nimid"):
|
for row in db.rows(sql"select fullpath, nimid from filenames order by nimid"):
|
||||||
let id = fileInfoIdx(g.config, AbsoluteFile row[0])
|
let id = fileInfoIdx(g.config, AbsoluteFile row[0])
|
||||||
doAssert id.int == parseInt(row[1])
|
doAssert id.int == parseInt(row[1])
|
||||||
|
db.exec(sql"update config set config = ?", ec)
|
||||||
db.exec(sql"pragma journal_mode=off")
|
db.exec(sql"pragma journal_mode=off")
|
||||||
# This MUST be turned off, otherwise it's way too slow even for testing purposes:
|
# This MUST be turned off, otherwise it's way too slow even for testing purposes:
|
||||||
db.exec(sql"pragma SYNCHRONOUS=off")
|
db.exec(sql"pragma SYNCHRONOUS=off")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue