summary refs log tree commit diff stats
path: root/compiler/cgen.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-05-19 01:52:06 +0200
committerAraq <rumpf_a@web.de>2013-05-19 01:52:06 +0200
commit2189e9a60f8db752d9423857bafd3c2d63618546 (patch)
tree4f1326d1606b2539d3910abf566b9e4e07e5f3de /compiler/cgen.nim
parent814fca7de569cdfd1fefb9ca932f5ba41383c10f (diff)
downloadNim-2189e9a60f8db752d9423857bafd3c2d63618546.tar.gz
fixes #420
Diffstat (limited to 'compiler/cgen.nim')
-rw-r--r--compiler/cgen.nim9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index ddb9ec0ad..92216d278 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -1078,6 +1078,11 @@ proc genModule(m: BModule, cfilenoext: string): PRope =
     app(result, genSectionEnd(i))
   app(result, m.s[cfsInitProc])
 
+proc newPreInitProc(m: BModule): BProc =
+  result = newProc(nil, m)
+  # little hack so that unique temporaries are generated:
+  result.labels = 100_000
+
 proc rawNewModule(module: PSym, filename: string): BModule =
   new(result)
   InitLinkedList(result.headerFiles)
@@ -1091,7 +1096,7 @@ proc rawNewModule(module: PSym, filename: string): BModule =
   result.typeInfoMarker = initIntSet()
   result.initProc = newProc(nil, result)
   result.initProc.options = gOptions
-  result.preInitProc = newProc(nil, result)
+  result.preInitProc = newPreInitProc(result)
   initNodeTable(result.dataCache)
   result.typeStack = @[]
   result.forwardedProcs = @[]
@@ -1111,7 +1116,7 @@ proc resetModule*(m: var BModule) =
   initIdTable(m.forwTypeCache)
   m.initProc = newProc(nil, m)
   m.initProc.options = gOptions
-  m.preInitProc = newProc(nil, m)
+  m.preInitProc = newPreInitProc(m)
   initNodeTable(m.dataCache)
   m.typeStack = @[]
   m.forwardedProcs = @[]