summary refs log tree commit diff stats
path: root/compiler/cgen.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-09-26 17:34:46 +0200
committerAraq <rumpf_a@web.de>2013-09-26 17:34:46 +0200
commita0b82db40229620a29726fa33a4358db2f5fcd44 (patch)
tree25ec66fb8dd528a1f265c04829f4e4ad34955fa4 /compiler/cgen.nim
parentc085a1b4f058008b8320ad3a24e6598472f0daf9 (diff)
downloadNim-a0b82db40229620a29726fa33a4358db2f5fcd44.tar.gz
the compiler can now deal with multiple modules of the same name
Diffstat (limited to 'compiler/cgen.nim')
-rw-r--r--compiler/cgen.nim15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index c82c3887c..d61d3055e 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -992,12 +992,15 @@ proc genMainProc(m: BModule) =
         gBreakpoints, mainModInit, toRope(m.labels)])
   if optNoMain notin gGlobalOptions:
     appcg(m, m.s[cfsProcs], otherMain, [])
-  
-proc getInitName(m: PSym): PRope = 
-  result = ropeff("$1Init", "@$1Init", [toRope(m.name.s)])
 
-proc getDatInitName(m: PSym): PRope =
-  result = ropeff("$1DatInit", "@$1DatInit", [toRope(m.name.s)])
+proc getSomeInitName(m: PSym, suffix: string): PRope =
+  if {sfSystemModule, sfMainModule} * m.flags == {}:
+    result = m.info.toFullPath.getPackageName.mangle.toRope
+  result.app m.name.s
+  result.app suffix
+  
+proc getInitName(m: PSym): PRope = getSomeInitName(m, "Init")
+proc getDatInitName(m: PSym): PRope = getSomeInitName(m, "DatInit")
 
 proc registerModuleToMain(m: PSym) = 
   var
@@ -1167,7 +1170,7 @@ proc resetCgenModules* =
   for m in cgenModules(): resetModule(m)
 
 proc rawNewModule(module: PSym): BModule =
-  result = rawNewModule(module, module.filename)
+  result = rawNewModule(module, module.position.int32.toFullPath)
 
 proc newModule(module: PSym): BModule =
   # we should create only one cgen module for each module sym