summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xcompiler/main.nim17
-rwxr-xr-xcompiler/msgs.nim16
-rwxr-xr-xcompiler/passes.nim2
-rwxr-xr-xcompiler/syntaxes.nim2
4 files changed, 18 insertions, 19 deletions
diff --git a/compiler/main.nim b/compiler/main.nim
index 7bb277812..8a563e424 100755
--- a/compiler/main.nim
+++ b/compiler/main.nim
@@ -175,9 +175,6 @@ proc compileModule(fileIdx: int32, flags: TSymFlags): PSym =
     else:
       result = gCompiledModules[fileIdx]
 
-proc compileModule(filename: string, flags: TSymFlags): PSym =
-  result = compileModule(filename.fileInfoIdx, flags)
-
 proc importModule(s: PSym, fileIdx: int32): PSym =
   # this is called by the semantic checking phase
   result = compileModule(fileIdx, {})
@@ -203,9 +200,9 @@ proc compileSystemModule =
     SystemFileIdx = fileInfoIdx(options.libpath/"system.nim")
     discard CompileModule(SystemFileIdx, {sfSystemModule})
 
-proc CompileProject(projectFile = gProjectFull) =
-  let systemFile = options.libpath / "system"
-  if projectFile.addFileExt(nimExt) ==^ systemFile.addFileExt(nimExt):
+proc CompileProject(projectFile = gProjectMainIdx) =
+  let systemFileIdx = fileInfoIdx(options.libpath / "system.nim")
+  if projectFile == SystemFileIdx:
     discard CompileModule(projectFile, {sfMainModule, sfSystemModule})
   else:
     compileSystemModule()
@@ -232,15 +229,15 @@ proc CommandCheck =
   msgs.gErrorMax = high(int)  # do not stop after first error
   semanticPasses()            # use an empty backend for semantic checking only
   rodPass()
-  compileProject(mainCommandArg())
+  compileProject()
 
 proc CommandDoc2 =
   msgs.gErrorMax = high(int)  # do not stop after first error
   semanticPasses()
   registerPass(docgen2Pass)
   #registerPass(cleanupPass())
-  compileProject(mainCommandArg())
-  finishDoc2Pass(gProjectFull)
+  compileProject()
+  finishDoc2Pass(gProjectName)
 
 proc CommandCompileToC =
   semanticPasses()
@@ -336,7 +333,7 @@ proc CommandInteractive =
   InteractivePasses()
   compileSystemModule()
   if commandArgs.len > 0:
-    discard CompileModule(mainCommandArg(), {})
+    discard CompileModule(gProjectMainIdx, {})
   else:
     var m = makeStdinModule()
     incl(m.flags, sfMainModule)
diff --git a/compiler/msgs.nim b/compiler/msgs.nim
index e45a1b0ef..2a66e5c97 100755
--- a/compiler/msgs.nim
+++ b/compiler/msgs.nim
@@ -561,17 +561,19 @@ proc getInfoContext*(index: int): TLineInfo =
   if i >=% L: result = UnknownLineInfo()
   else: result = msgContext[i]
 
-proc toFilename*(info: TLineInfo): string =
-  if info.fileIndex < 0: result = "???"
-  else: result = fileInfos[info.fileIndex].projPath
-
 proc toFilename*(fileIdx: int32): string =
   if fileIdx < 0: result = "???"
   else: result = fileInfos[fileIdx].projPath
 
-proc toFullPath*(info: TLineInfo): string =
-  if info.fileIndex < 0: result = "???"
-  else: result = fileInfos[info.fileIndex].fullPath
+proc toFullPath*(fileIdx: int32): string =
+  if fileIdx < 0: result = "???"
+  else: result = fileInfos[fileIdx].fullPath
+
+template toFilename*(info: TLineInfo): string =
+  info.fileIndex.toFilename
+
+template toFullPath*(info: TLineInfo): string =
+  info.fileIndex.toFullPath
   
 proc toLinenumber*(info: TLineInfo): int {.inline.} = 
   result = info.line
diff --git a/compiler/passes.nim b/compiler/passes.nim
index e1b1630a8..8d228fe9a 100755
--- a/compiler/passes.nim
+++ b/compiler/passes.nim
@@ -168,7 +168,7 @@ proc processModule(module: PSym, stream: PLLStream, rd: PRodReader) =
   if rd == nil: 
     openPasses(a, module)
     if stream == nil: 
-      let filename = fileIdx.toFilename
+      let filename = fileIdx.toFullPath
       s = LLStreamOpen(filename, fmRead)
       if s == nil: 
         rawMessage(errCannotOpenFile, filename)
diff --git a/compiler/syntaxes.nim b/compiler/syntaxes.nim
index e45151995..83c9180f4 100755
--- a/compiler/syntaxes.nim
+++ b/compiler/syntaxes.nim
@@ -44,7 +44,7 @@ proc ParseFile(fileIdx: int32): PNode =
   var 
     p: TParsers
     f: tfile
-  let filename = fileIdx.toFilename
+  let filename = fileIdx.toFullPath
   if not open(f, filename):
     rawMessage(errCannotOpenFile, filename)
     return