diff options
Diffstat (limited to 'compiler/ast.nim')
-rwxr-xr-x | compiler/ast.nim | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 2b84c415f..6ac7dc0de 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 + intsets, idgen, os const ImportTablePos* = 0 # imported symbols are at level 0 @@ -1030,3 +1030,18 @@ 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 = "" + |