From caa4766a33050d7fb89565da128afd2da8272e1c Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 11 Dec 2011 12:41:06 +0200 Subject: [PATCH] the current directory is no longer taken into account when resolving module paths --- compiler/ast.nim | 17 +---------------- compiler/docgen.nim | 2 +- compiler/importer.nim | 15 +++++++++++++++ compiler/nimrod.cfg | 1 + compiler/options.nim | 19 ++++++------------- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index 8d1aeeb6a7..419d575627 100755 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -11,7 +11,7 @@ import msgs, hashes, nversion, options, strutils, crc, ropes, idents, lists, - intsets, idgen, os + intsets, idgen const ImportTablePos* = 0 # imported symbols are at level 0 @@ -1001,18 +1001,3 @@ proc getStrOrChar*(a: PNode): string = internalError(a.info, "getStrOrChar") result = "" -proc getModuleName*(n: PNode): string = - # This returns a short relative module name without the nim extension - # e.g. like "system", "importer" or "somepath/module" - # The proc won't perform any checks that the path is actually valid - case n.kind - of nkStrLit, nkRStrLit, nkTripleStrLit: - result = UnixToNativePath(n.strVal) - of nkIdent: - result = n.ident.s - of nkSym: - result = n.sym.name.s - else: - internalError(n.info, "getModuleName") - result = "" - diff --git a/compiler/docgen.nim b/compiler/docgen.nim index f22c81a9f6..0f80187142 100755 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -13,7 +13,7 @@ import ast, astalgo, strutils, hashes, options, nversion, msgs, os, ropes, idents, - wordrecg, math, syntaxes, renderer, lexer, rst, times, highlite + wordrecg, math, syntaxes, renderer, lexer, rst, times, highlite, importer proc CommandDoc*() proc CommandRst2Html*() diff --git a/compiler/importer.nim b/compiler/importer.nim index 682b852f7c..6d502f627a 100755 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -17,6 +17,21 @@ proc evalImport*(c: PContext, n: PNode): PNode proc evalFrom*(c: PContext, n: PNode): PNode proc importAllSymbols*(c: PContext, fromMod: PSym) +proc getModuleName*(n: PNode): string = + # This returns a short relative module name without the nim extension + # e.g. like "system", "importer" or "somepath/module" + # The proc won't perform any checks that the path is actually valid + case n.kind + of nkStrLit, nkRStrLit, nkTripleStrLit: + result = UnixToNativePath(n.strVal) + of nkIdent: + result = n.ident.s + of nkSym: + result = n.sym.name.s + else: + internalError(n.info, "getModuleName") + result = "" + proc checkModuleName*(n: PNode): string = # This returns the full canonical path for a given module import var modulename = n.getModuleName diff --git a/compiler/nimrod.cfg b/compiler/nimrod.cfg index 5168a3bb93..7d8d4d94f0 100755 --- a/compiler/nimrod.cfg +++ b/compiler/nimrod.cfg @@ -2,6 +2,7 @@ --hint[XDeclaredButNotUsed]=off path="llvm" +path="$projectPath/.." @if llvm_gcc or gcc: # GCC, LLVM and Visual C++ have a problem to optimize some modules. diff --git a/compiler/options.nim b/compiler/options.nim index 1c5fc290f3..8aef6288cc 100755 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -186,21 +186,14 @@ iterator iterSearchPath*(): string = var it = PStrEntry(SearchPaths.head) while it != nil: yield it.data - it = PStrEntry(it.Next) + it = PStrEntry(it.Next) proc rawFindFile(f: string): string = - template ret(e: expr) = - result = e.canonicalizePath - return - - if ExistsFile(f): - ret f - else: - for it in iterSearchPath(): - result = JoinPath(it, f) - if ExistsFile(result): - ret result - result = "" + for it in iterSearchPath(): + result = JoinPath(it, f) + if ExistsFile(result): + return result.canonicalizePath + result = "" proc FindFile*(f: string): string = result = rawFindFile(f)