From d171a8b36f10f42d35e64a7ddefa57376b419908 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 11 Dec 2011 09:41:04 +0200 Subject: path canonicalization for imported modules, relative paths written in rod files --- compiler/rodwrite.nim | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'compiler/rodwrite.nim') diff --git a/compiler/rodwrite.nim b/compiler/rodwrite.nim index 154dc13d4..873f97764 100755 --- a/compiler/rodwrite.nim +++ b/compiler/rodwrite.nim @@ -87,17 +87,18 @@ proc newRodWriter(modfilename: string, crc: TCrc32, module: PSym): PRodWriter = result.init = "" result.data = newStringOfCap(12_000) -proc addModDep(w: PRodWriter, dep: string) = +proc addModDep(w: PRodWriter, dep: string) = if w.modDeps.len != 0: add(w.modDeps, ' ') encodeVInt(fileIdx(w, dep), w.modDeps) const rodNL = "\x0A" -proc addInclDep(w: PRodWriter, dep: string) = +proc addInclDep(w: PRodWriter, dep: string) = + var resolved = dep.findModule encodeVInt(fileIdx(w, dep), w.inclDeps) add(w.inclDeps, " ") - encodeVInt(crcFromFile(dep), w.inclDeps) + encodeVInt(crcFromFile(resolved), w.inclDeps) add(w.inclDeps, rodNL) proc pushType(w: PRodWriter, t: PType) = @@ -555,21 +556,21 @@ proc process(c: PPassContext, n: PNode): PNode = # addInterfaceSym(w, a.sons[j].sym); # end of nkImportStmt: - for i in countup(0, sonsLen(n) - 1): addModDep(w, getModuleFile(n.sons[i])) + for i in countup(0, sonsLen(n) - 1): addModDep(w, getModuleName(n.sons[i])) addStmt(w, n) of nkFromStmt: - addModDep(w, getModuleFile(n.sons[0])) + addModDep(w, getModuleName(n.sons[0])) addStmt(w, n) of nkIncludeStmt: - for i in countup(0, sonsLen(n) - 1): addInclDep(w, getModuleFile(n.sons[i])) + for i in countup(0, sonsLen(n) - 1): addInclDep(w, getModuleName(n.sons[i])) of nkPragma: addStmt(w, n) else: nil -proc myOpen(module: PSym, filename: string): PPassContext = +proc myOpen(module: PSym, filename: string): PPassContext = if module.id < 0: InternalError("rodwrite: module ID not set") - var w = newRodWriter(filename, rodread.GetCRC(filename), module) + var w = newRodWriter(filename, rodread.GetCRC(module.info.toFullPath), module) rawAddInterfaceSym(w, module) result = w -- cgit 1.4.1-2-gfad0