diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/rod.nim | 2 | ||||
-rw-r--r-- | compiler/rodimpl.nim | 26 | ||||
-rw-r--r-- | compiler/sem.nim | 1 |
3 files changed, 20 insertions, 9 deletions
diff --git a/compiler/rod.nim b/compiler/rod.nim index bb9beff54..bc2f3931e 100644 --- a/compiler/rod.nim +++ b/compiler/rod.nim @@ -20,6 +20,8 @@ when not defined(nimSymbolfiles): template addModuleDep*(module, fileIdx: int32; isIncludeFile: bool) = discard + template storeRemaining*(module: PSym) = discard + else: include rodimpl diff --git a/compiler/rodimpl.nim b/compiler/rodimpl.nim index 767929aa5..ceed166b4 100644 --- a/compiler/rodimpl.nim +++ b/compiler/rodimpl.nim @@ -15,6 +15,8 @@ import strutils, os, intsets, tables, ropes, db_sqlite, msgs, options, types, ## Todo: ## - Implement the 'import' replay logic so that the codegen runs over ## dependent modules. +## - Make conditional symbols and the configuration part of a module's +## dependencies. ## - Test multi methods. ## - Implement the limited VM support based on sets. ## - 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() let module = db.getRow( sql"select id, fullHash from modules where fullpath = ?", fullpath) - let currentFullhash = $secureHashFile(fullpath) + let currentFullhash = hashFileCached(fileIdx, fullpath) if module[0].len == 0: result = int db.insertID(sql"insert into modules(fullpath, interfHash, fullHash) values (?, ?, ?)", fullpath, "", currentFullhash) @@ -75,12 +77,13 @@ type sstack: seq[PSym] # a stack of symbols to process tstack: seq[PType] # a stack of types to process tmarks, smarks: IntSet + forwardedSyms: seq[PSym] PRodWriter = var TRodWriter proc initRodWriter(module: PSym): TRodWriter = result = TRodWriter(module: module, sstack: @[], tstack: @[], - tmarks: initIntSet(), smarks: initIntSet()) + tmarks: initIntSet(), smarks: initIntSet(), forwardedSyms: @[]) when false: proc getDefines(): string = @@ -89,13 +92,6 @@ when false: if result.len != 0: add(result, " ") 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 rodNL = "\L" @@ -381,6 +377,9 @@ proc encodeSym(w: PRodWriter, s: PSym, result: var string) = encodeNode(w, s.info, s.ast, result) proc storeSym(w: PRodWriter; s: PSym) = + if sfForward in s.flags and s.kind != skModule: + w.forwardedSyms.add s + return var buf = newStringOfCap(160) encodeSym(w, s, buf) # 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 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 ----------------------------------- type TRodReader = object @@ -781,6 +788,7 @@ proc loadSymFromBlob(r; b; info: TLineInfo): PSym = result.ast = decodeNode(r, b, result.info) if sfCompilerProc in result.flags: registerCompilerProc(result) + #echo "loading ", result.name.s proc loadSym(r; id: int; info: TLineInfo): PSym = result = r.syms.getOrDefault(id) diff --git a/compiler/sem.nim b/compiler/sem.nim index 12e77affc..937f1637a 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -619,6 +619,7 @@ proc myClose(graph: ModuleGraph; context: PPassContext, n: PNode): PNode = replayMethodDefs(graph, c.rd) popOwner(c) popProcCon(c) + storeRemaining(c.module) if c.runnableExamples != nil: testExamples(c) const semPass* = makePass(myOpen, myOpenCached, myProcess, myClose, |