diff options
author | Araq <rumpf_a@web.de> | 2018-11-22 23:17:38 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-11-22 23:17:47 +0100 |
commit | 61d08ebcd8f9ab2f4cb63c0cc61866d46434f2ab (patch) | |
tree | c8f6a3bbab494b175474770504c08d9e27eb5aa4 | |
parent | 962b2e4b39e92c755975e2e0225fdd7c75fef6d1 (diff) | |
download | Nim-61d08ebcd8f9ab2f4cb63c0cc61866d46434f2ab.tar.gz |
IC: further progress
-rw-r--r-- | compiler/importer.nim | 2 | ||||
-rw-r--r-- | compiler/msgs.nim | 2 | ||||
-rw-r--r-- | compiler/rodimpl.nim | 37 |
3 files changed, 30 insertions, 11 deletions
diff --git a/compiler/importer.nim b/compiler/importer.nim index 60b7872fe..131b1ad8a 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -100,7 +100,7 @@ proc importAllSymbolsExcept(c: PContext, fromMod: PSym, exceptSet: IntSet) = if s.kind != skModule: if s.kind != skEnumField: 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: rawImportSymbol(c, s) s = nextIter(i, fromMod.tab) diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 4ac5a839d..7e6b67cbe 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -190,7 +190,7 @@ template toFullPath*(conf: ConfigRef; info: TLineInfo): string = proc toMsgFilename*(conf: ConfigRef; info: TLineInfo): string = if info.fileIndex.int32 < 0: result = "???" - return + return let absPath = conf.m.fileInfos[info.fileIndex.int32].fullPath.string let relPath = conf.m.fileInfos[info.fileIndex.int32].projPath.string if optListFullPaths in conf.globalOptions: diff --git a/compiler/rodimpl.nim b/compiler/rodimpl.nim index f2e0fd1a2..730328642 100644 --- a/compiler/rodimpl.nim +++ b/compiler/rodimpl.nim @@ -366,13 +366,7 @@ proc storeType(g: ModuleGraph; t: PType) = db.exec(sql"insert into types(nimid, module, data) values (?, ?, ?)", t.id, mid, buf) -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 +proc transitiveClosure(g: ModuleGraph) = var i = 0 while true: if i > 10_000: @@ -391,9 +385,25 @@ proc storeNode*(g: ModuleGraph; module: PSym; n: PNode) = break 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) = 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) = if g.config.symbolFiles == disabledSf: return var stillForwarded: seq[PSym] = @[] @@ -403,6 +413,13 @@ proc storeRemaining*(g: ModuleGraph; module: PSym) = else: stillForwarded.add s 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 ----------------------------------- @@ -880,20 +897,22 @@ proc setupModuleCache*(g: ModuleGraph) = if g.config.symbolFiles == writeOnlySf: removeFile(dbfile) createDir getNimcacheDir(g.config) + let ec = encodeConfig(g) if not fileExists(dbfile): db = open(connection=string dbfile, user="nim", password="", database="nim") createDb(db) - db.exec(sql"insert into config(config) values (?)", encodeConfig(g)) + db.exec(sql"insert into config(config) values (?)", ec) else: db = open(connection=string dbfile, user="nim", password="", database="nim") 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: for row in db.rows(sql"select fullpath, nimid from filenames order by nimid"): let id = fileInfoIdx(g.config, AbsoluteFile row[0]) doAssert id.int == parseInt(row[1]) + db.exec(sql"update config set config = ?", ec) db.exec(sql"pragma journal_mode=off") # This MUST be turned off, otherwise it's way too slow even for testing purposes: db.exec(sql"pragma SYNCHRONOUS=off") |