summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/astalgo.nim16
-rw-r--r--compiler/docgen.nim6
-rw-r--r--compiler/main.nim2
-rw-r--r--compiler/modules.nim4
-rw-r--r--compiler/nim.nim2
-rw-r--r--compiler/nimconf.nim4
-rw-r--r--compiler/options.nim4
7 files changed, 17 insertions, 21 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim
index 5912f1359..fff1527d3 100644
--- a/compiler/astalgo.nim
+++ b/compiler/astalgo.nim
@@ -33,22 +33,22 @@ when declared(echo):
 
 template mdbg*: bool {.dirty.} =
   when compiles(c.module):
-    c.module.fileIdx.int32 == c.config.projectMainIdx
+    c.module.fileIdx == c.config.projectMainIdx
   elif compiles(c.c.module):
-    c.c.module.fileIdx.int32 == c.c.config.projectMainIdx
+    c.c.module.fileIdx == c.c.config.projectMainIdx
   elif compiles(m.c.module):
-    m.c.module.fileIdx.int32 == m.c.config.projectMainIdx
+    m.c.module.fileIdx == m.c.config.projectMainIdx
   elif compiles(cl.c.module):
-    cl.c.module.fileIdx.int32 == cl.c.config.projectMainIdx
+    cl.c.module.fileIdx == cl.c.config.projectMainIdx
   elif compiles(p):
     when compiles(p.lex):
-      p.lex.fileIdx.int32 == p.lex.config.projectMainIdx
+      p.lex.fileIdx == p.lex.config.projectMainIdx
     else:
-      p.module.module.fileIdx.int32 == p.config.projectMainIdx
+      p.module.module.fileIdx == p.config.projectMainIdx
   elif compiles(m.module.fileIdx):
-    m.module.fileIdx.int32 == m.config.projectMainIdx
+    m.module.fileIdx == m.config.projectMainIdx
   elif compiles(L.fileIdx):
-    L.fileIdx.int32 == L.config.projectMainIdx
+    L.fileIdx == L.config.projectMainIdx
   else:
     error()
 
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index 4be49da6d..e39b38365 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -807,7 +807,7 @@ proc writeOutputJson*(d: PDoc, filename, outExt: string,
       discard "fixme: error report"
 
 proc commandDoc*(cache: IdentCache, conf: ConfigRef) =
-  var ast = parseFile(conf.projectMainIdx.FileIndex, newIdentCache(), conf)
+  var ast = parseFile(conf.projectMainIdx, cache, conf)
   if ast == nil: return
   var d = newDocumentor(conf.projectFull, cache, conf)
   d.hasToc = true
@@ -857,7 +857,7 @@ proc commandRst2TeX*(cache: IdentCache, conf: ConfigRef) =
   commandRstAux(cache, conf, conf.projectFull, TexExt)
 
 proc commandJson*(cache: IdentCache, conf: ConfigRef) =
-  var ast = parseFile(conf.projectMainIdx.FileIndex, newIdentCache(), conf)
+  var ast = parseFile(conf.projectMainIdx, cache, conf)
   if ast == nil: return
   var d = newDocumentor(conf.projectFull, cache, conf)
   d.hasToc = true
@@ -874,7 +874,7 @@ proc commandJson*(cache: IdentCache, conf: ConfigRef) =
       rawMessage(conf, errCannotOpenFile, filename)
 
 proc commandTags*(cache: IdentCache, conf: ConfigRef) =
-  var ast = parseFile(conf.projectMainIdx.FileIndex, newIdentCache(), conf)
+  var ast = parseFile(conf.projectMainIdx, cache, conf)
   if ast == nil: return
   var d = newDocumentor(conf.projectFull, cache, conf)
   d.hasToc = true
diff --git a/compiler/main.nim b/compiler/main.nim
index fe95f3b9b..3b5370fa5 100644
--- a/compiler/main.nim
+++ b/compiler/main.nim
@@ -261,7 +261,7 @@ proc mainCommand*(graph: ModuleGraph; cache: IdentCache) =
   of "parse":
     conf.cmd = cmdParse
     wantMainModule(conf)
-    discard parseFile(FileIndex conf.projectMainIdx, cache, conf)
+    discard parseFile(conf.projectMainIdx, cache, conf)
   of "scan":
     conf.cmd = cmdScan
     wantMainModule(conf)
diff --git a/compiler/modules.nim b/compiler/modules.nim
index 2ba9e8170..9ac3dbb0b 100644
--- a/compiler/modules.nim
+++ b/compiler/modules.nim
@@ -124,7 +124,7 @@ proc compileSystemModule*(graph: ModuleGraph; cache: IdentCache) =
 proc wantMainModule*(conf: ConfigRef) =
   if conf.projectFull.len == 0:
     fatal(conf, newLineInfo(conf, "command line", 1, 1), errGenerated, "command expects a filename")
-  conf.projectMainIdx = int32 fileInfoIdx(conf, addFileExt(conf.projectFull, NimExt))
+  conf.projectMainIdx = fileInfoIdx(conf, addFileExt(conf.projectFull, NimExt))
 
 passes.gIncludeFile = includeModule
 passes.gImportModule = importModule
@@ -134,7 +134,7 @@ proc compileProject*(graph: ModuleGraph; cache: IdentCache;
   let conf = graph.config
   wantMainModule(conf)
   let systemFileIdx = fileInfoIdx(conf, conf.libpath / "system.nim")
-  let projectFile = if projectFileIdx == InvalidFileIDX: FileIndex(conf.projectMainIdx) else: projectFileIdx
+  let projectFile = if projectFileIdx == InvalidFileIDX: conf.projectMainIdx else: projectFileIdx
   graph.importStack.add projectFile
   if projectFile == systemFileIdx:
     discard graph.compileModule(projectFile, cache, {sfMainModule, sfSystemModule})
diff --git a/compiler/nim.nim b/compiler/nim.nim
index 70de254b4..756ddd7f5 100644
--- a/compiler/nim.nim
+++ b/compiler/nim.nim
@@ -79,7 +79,7 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
       conf.projectName = p.name
     else:
       conf.projectPath = canonicalizePath(conf, getCurrentDir())
-    loadConfigs(DefaultConfig, conf) # load all config files
+    loadConfigs(DefaultConfig, cache, conf) # load all config files
     let scriptFile = conf.projectFull.changeFileExt("nims")
     if fileExists(scriptFile):
       runNimScript(cache, scriptFile, freshDefines=false, conf)
diff --git a/compiler/nimconf.nim b/compiler/nimconf.nim
index 04903e690..1bc2c27e3 100644
--- a/compiler/nimconf.nim
+++ b/compiler/nimconf.nim
@@ -253,7 +253,3 @@ proc loadConfigs*(cfg: string; cache: IdentCache; conf: ConfigRef) =
       if not fileExists(projectConfig):
         projectConfig = changeFileExt(conf.projectFull, "nim.cfg")
       readConfigFile(projectConfig, cache, conf)
-
-proc loadConfigs*(cfg: string; conf: ConfigRef) =
-  # for backwards compatibility only.
-  loadConfigs(cfg, newIdentCache(), conf)
diff --git a/compiler/options.nim b/compiler/options.nim
index d9ab9bf61..6cfaad9fb 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -204,7 +204,7 @@ type
     projectPath*: string # holds a path like /home/alice/projects/nim/compiler/
     projectFull*: string # projectPath/projectName
     projectIsStdin*: bool # whether we're compiling from stdin
-    projectMainIdx*: int32 # the canonical path id of the main module
+    projectMainIdx*: FileIndex # the canonical path id of the main module
     command*: string # the main command (e.g. cc, check, scan, etc)
     commandArgs*: seq[string] # any arguments after the main command
     keepComments*: bool # whether the parser needs to keep comments
@@ -278,7 +278,7 @@ proc newConfigRef*(): ConfigRef =
     projectPath: "", # holds a path like /home/alice/projects/nim/compiler/
     projectFull: "", # projectPath/projectName
     projectIsStdin: false, # whether we're compiling from stdin
-    projectMainIdx: 0'i32, # the canonical path id of the main module
+    projectMainIdx: FileIndex(0'i32), # the canonical path id of the main module
     command: "", # the main command (e.g. cc, check, scan, etc)
     commandArgs: @[], # any arguments after the main command
     keepComments: true, # whether the parser needs to keep comments