diff options
-rw-r--r-- | compiler/astalgo.nim | 3 | ||||
-rw-r--r-- | compiler/incremental.nim | 1 | ||||
-rw-r--r-- | compiler/modules.nim | 9 | ||||
-rw-r--r-- | compiler/rodimpl.nim | 12 |
4 files changed, 14 insertions, 11 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index fff1527d3..0afe56bb7 100644 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -66,7 +66,6 @@ proc idNodeTablePut*(t: var TIdNodeTable, key: PIdObj, val: PNode) proc getSymFromList*(list: PNode, ident: PIdent, start: int = 0): PSym proc lookupInRecord*(n: PNode, field: PIdent): PSym -proc getModule*(s: PSym): PSym proc mustRehash*(length, counter: int): bool proc nextTry*(h, maxHash: Hash): Hash {.inline.} @@ -157,7 +156,7 @@ proc lookupInRecord(n: PNode, field: PIdent): PSym = if n.sym.name.id == field.id: result = n.sym else: return nil -proc getModule(s: PSym): PSym = +proc getModule*(s: PSym): PSym = result = s assert((result.kind == skModule) or (result.owner != result)) while result != nil and result.kind != skModule: result = result.owner diff --git a/compiler/incremental.nim b/compiler/incremental.nim index 378ba0665..c0d89a598 100644 --- a/compiler/incremental.nim +++ b/compiler/incremental.nim @@ -104,6 +104,7 @@ when nimIncremental: db.exec(sql""" create table if not exists modules( id integer primary key, + nimid integer not null, fullpath varchar(8000) not null, interfHash varchar(256) not null, fullHash varchar(256) not null, diff --git a/compiler/modules.nim b/compiler/modules.nim index 04b1506f4..b3a1e90d6 100644 --- a/compiler/modules.nim +++ b/compiler/modules.nim @@ -95,8 +95,13 @@ proc includeModule*(graph: ModuleGraph; s: PSym, fileIdx: FileIndex): PNode {.pr graph.addDep(s, fileIdx) graph.addIncludeDep(s.position.FileIndex, fileIdx) +proc connectCallbacks*(graph: ModuleGraph) = + graph.includeFileCallback = includeModule + graph.importModuleCallback = importModule + proc compileSystemModule*(graph: ModuleGraph) = if graph.systemModule == nil: + connectCallbacks(graph) graph.config.m.systemFileIdx = fileInfoIdx(graph.config, graph.config.libpath / "system.nim") discard graph.compileModule(graph.config.m.systemFileIdx, {sfSystemModule}) @@ -105,10 +110,6 @@ proc wantMainModule*(conf: ConfigRef) = fatal(conf, newLineInfo(conf, "command line", 1, 1), errGenerated, "command expects a filename") conf.projectMainIdx = fileInfoIdx(conf, addFileExt(conf.projectFull, NimExt)) -proc connectCallbacks*(graph: ModuleGraph) = - graph.includeFileCallback = includeModule - graph.importModuleCallback = importModule - proc compileProject*(graph: ModuleGraph; projectFileIdx = InvalidFileIDX) = connectCallbacks(graph) let conf = graph.config diff --git a/compiler/rodimpl.nim b/compiler/rodimpl.nim index 46a0e16db..e9054fd26 100644 --- a/compiler/rodimpl.nim +++ b/compiler/rodimpl.nim @@ -42,13 +42,14 @@ proc needsRecompile(g: ModuleGraph; fileIdx: FileIndex; fullpath: string; proc getModuleId*(g: ModuleGraph; fileIdx: FileIndex; fullpath: string): int = if g.config.symbolFiles in {disabledSf, writeOnlySf}: return getID() let module = g.incr.db.getRow( - sql"select id, fullHash from modules where fullpath = ?", fullpath) + sql"select id, fullHash, nimid from modules where fullpath = ?", fullpath) let currentFullhash = hashFileCached(g.config, fileIdx, fullpath) if module[0].len == 0: - result = int db.insertID(sql"insert into modules(fullpath, interfHash, fullHash) values (?, ?, ?)", - fullpath, "", currentFullhash) + result = getID() + db.exec(sql"insert into modules(fullpath, interfHash, fullHash, nimid) values (?, ?, ?, ?)", + fullpath, "", currentFullhash, result) else: - result = parseInt(module[0]) + result = parseInt(module[2]) if currentFullhash == module[1]: # not changed, so use the cached AST: doAssert(result != 0) @@ -844,13 +845,14 @@ proc loadNode*(g: ModuleGraph; module: PSym): PNode = result.add decodeNode(g, b, module.info) db.exec(sql"insert into controlblock(idgen) values (?)", gFrontEndId) - echo result replay(g, module, result) proc setupModuleCache*(g: ModuleGraph) = if g.config.symbolFiles == disabledSf: return g.recordStmt = recordStmt let dbfile = getNimcacheDir(g.config) / "rodfiles.db" + if g.config.symbolFiles == writeOnlySf: + removeFile(dbfile) if not fileExists(dbfile): db = open(connection=dbfile, user="nim", password="", database="nim") |