mirror of
https://github.com/logos-messaging/nim-sds.git
synced 2026-05-18 16:09:30 +00:00
49 lines
1.4 KiB
Diff
49 lines
1.4 KiB
Diff
--- a/compiler/modulegraphs.nim
|
|
+++ b/compiler/modulegraphs.nim
|
|
@@ -506,7 +506,11 @@
|
|
for i in 0..<trunc:
|
|
let c = rel[i]
|
|
case c
|
|
- of 'a'..'z', '0'..'9':
|
|
+ of 'a'..'m':
|
|
+ result.add char(c.uint8 + 13)
|
|
+ of 'n'..'z':
|
|
+ result.add char(c.uint8 - 13)
|
|
+ of '0'..'9':
|
|
result.add c
|
|
of {os.DirSep, os.AltSep}:
|
|
result.add 'Z' # because it looks a bit like '/'
|
|
--- a/compiler/modulepaths.nim
|
|
+++ b/compiler/modulepaths.nim
|
|
@@ -79,6 +79,17 @@
|
|
else:
|
|
result = fileInfoIdx(conf, fullPath)
|
|
|
|
+proc rot13(result: var string) =
|
|
+ # don't mangle .nim
|
|
+ let finalIdx =
|
|
+ if result.endsWith(".nim"): result.len - 4
|
|
+ else: result.len
|
|
+ for i, c in result[0..<finalIdx]:
|
|
+ case c
|
|
+ of 'a'..'m', 'A'..'M': result[i] = char(c.uint8 + 13)
|
|
+ of 'n'..'z', 'N'..'Z': result[i] = char(c.uint8 - 13)
|
|
+ else: discard
|
|
+
|
|
type
|
|
SelectedBase = enum
|
|
FromProject, FromSearchPath, FromNimblePath
|
|
@@ -109,9 +120,11 @@
|
|
of FromSearchPath: "@p"
|
|
of FromNimblePath: "@n"
|
|
|
|
- prefix & best.multiReplace(
|
|
+ result = prefix & best.multiReplace(
|
|
{$os.DirSep: "@s", $os.AltSep: "@s", "#": "@h", "@": "@@", ":": "@c"})
|
|
+ rot13(result)
|
|
|
|
proc demangleModuleName*(path: string): string =
|
|
## Demangle a relative module path.
|
|
result = path.multiReplace({"@@": "@", "@h": "#", "@s": "/", "@m": "", "@p": "", "@n": "", "@c": ":"})
|
|
+ rot13(result)
|