C variables are created in their enclosing block instead of their enclosing function

This commit is contained in:
Zahary Karadjov 2012-04-12 14:12:32 +03:00
commit d2b45dbe85
8 changed files with 180 additions and 151 deletions

View file

@ -10,6 +10,8 @@
## Thread var support for crappy architectures that lack native support for
## thread local storage. (**Thank you Mac OS X!**)
# included from cgen.nim
proc emulatedThreadVars(): bool {.inline.} =
result = {optThreads, optTlsEmulation} <= gGlobalOptions
@ -17,7 +19,7 @@ proc AccessThreadLocalVar(p: BProc, s: PSym) =
if emulatedThreadVars() and not p.ThreadVarAccessed:
p.ThreadVarAccessed = true
p.module.usesThreadVars = true
appf(p.s[cpsLocals], "NimThreadVars* NimTV;$n")
appf(p.s(cpsLocals), "NimThreadVars* NimTV;$n")
appcg(p, cpsInit, "NimTV=(NimThreadVars*)#GetThreadLocalVars();$n")
var