summary refs log tree commit diff stats
path: root/compiler/cgen.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-08-22 19:28:58 +0200
committerAraq <rumpf_a@web.de>2013-08-22 19:28:58 +0200
commita8c8a85135e73777ea2c115bf1352456c1dd69aa (patch)
treea06a9a97f6e98480d98d6b063dfe224951c233db /compiler/cgen.nim
parentcf38d635bf8e94abbc68cca55fd6deb6ebc3da5d (diff)
parentca3a4ce6721c87cfcbb9eb02002ecf8aeb89233c (diff)
downloadNim-a8c8a85135e73777ea2c115bf1352456c1dd69aa.tar.gz
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'compiler/cgen.nim')
-rw-r--r--compiler/cgen.nim19
1 files changed, 16 insertions, 3 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 18f33f32a..0c3f2da84 100644
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -284,6 +284,9 @@ proc genLineDir(p: BProc, t: PNode) =
     linefmt(p, cpsStmts, "nimln($1, $2);$n",
             line.toRope, t.info.quotedFilename)
 
+proc accessThreadLocalVar(p: BProc, s: PSym)
+proc emulatedThreadVars(): bool {.inline.}
+
 include "ccgtypes.nim"
 
 # ------------------------------ Manager of temporaries ------------------
@@ -858,8 +861,8 @@ proc isActivated(prc: PSym): bool = prc.typ != nil
 proc genProc(m: BModule, prc: PSym) = 
   if sfBorrow in prc.flags or not isActivated(prc): return
   fillProcLoc(prc)
-  if {sfForward, sfFromGeneric} * prc.flags != {}: addForwardedProc(m, prc)
-  else: 
+  if sfForward in prc.flags: addForwardedProc(m, prc)
+  else:
     genProcNoForward(m, prc)
     if {sfExportc, sfCompilerProc} * prc.flags == {sfExportc} and
         generatedHeader != nil and lfNoDecl notin prc.loc.Flags:
@@ -1028,8 +1031,9 @@ proc genInitCode(m: BModule) =
   app(prc, initGCFrame(m.initProc))
  
   app(prc, genSectionStart(cpsLocals))
-  app(prc, m.initProc.s(cpsLocals))
   app(prc, m.preInitProc.s(cpsLocals))
+  app(prc, m.initProc.s(cpsLocals))
+  app(prc, m.postInitProc.s(cpsLocals))
   app(prc, genSectionEnd(cpsLocals))
 
   if optStackTrace in m.initProc.options and not m.FrameDeclared:
@@ -1045,11 +1049,13 @@ proc genInitCode(m: BModule) =
   app(prc, genSectionStart(cpsInit))
   app(prc, m.preInitProc.s(cpsInit))
   app(prc, m.initProc.s(cpsInit))
+  app(prc, m.postInitProc.s(cpsInit))
   app(prc, genSectionEnd(cpsInit))
 
   app(prc, genSectionStart(cpsStmts))
   app(prc, m.preInitProc.s(cpsStmts))
   app(prc, m.initProc.s(cpsStmts))
+  app(prc, m.postInitProc.s(cpsStmts))
   app(prc, genSectionEnd(cpsStmts))
   if optStackTrace in m.initProc.options and not m.PreventStackTrace:
     app(prc, deinitFrame(m.initProc))
@@ -1094,6 +1100,11 @@ proc newPreInitProc(m: BModule): BProc =
   # little hack so that unique temporaries are generated:
   result.labels = 100_000
 
+proc newPostInitProc(m: BModule): BProc =
+  result = newProc(nil, m)
+  # little hack so that unique temporaries are generated:
+  result.labels = 200_000
+
 proc rawNewModule(module: PSym, filename: string): BModule =
   new(result)
   InitLinkedList(result.headerFiles)
@@ -1108,6 +1119,7 @@ proc rawNewModule(module: PSym, filename: string): BModule =
   result.initProc = newProc(nil, result)
   result.initProc.options = gOptions
   result.preInitProc = newPreInitProc(result)
+  result.postInitProc = newPostInitProc(result)
   initNodeTable(result.dataCache)
   result.typeStack = @[]
   result.forwardedProcs = @[]
@@ -1128,6 +1140,7 @@ proc resetModule*(m: var BModule) =
   m.initProc = newProc(nil, m)
   m.initProc.options = gOptions
   m.preInitProc = newPreInitProc(m)
+  m.postInitProc = newPostInitProc(m)
   initNodeTable(m.dataCache)
   m.typeStack = @[]
   m.forwardedProcs = @[]