summary refs log tree commit diff stats
path: root/compiler/rodimpl.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rodimpl.nim')
-rw-r--r--compiler/rodimpl.nim26
1 files changed, 17 insertions, 9 deletions
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)