bugfix: compiler errors for explicit initialization of thread local variables; os.nim does not rely on it anymore

This commit is contained in:
Araq 2011-12-23 20:05:08 +01:00
commit 76f91b90e2
3 changed files with 9 additions and 4 deletions

View file

@ -92,7 +92,8 @@ type
errCannotInterpretNodeX, errFieldXNotFound, errInvalidConversionFromTypeX, errCannotInterpretNodeX, errFieldXNotFound, errInvalidConversionFromTypeX,
errAssertionFailed, errCannotGenerateCodeForX, errXRequiresOneArgument, errAssertionFailed, errCannotGenerateCodeForX, errXRequiresOneArgument,
errUnhandledExceptionX, errCyclicTree, errXisNoMacroOrTemplate, errUnhandledExceptionX, errCyclicTree, errXisNoMacroOrTemplate,
errXhasSideEffects, errIteratorExpected, errLetNeedsInit, errWrongSymbolX, errXhasSideEffects, errIteratorExpected, errLetNeedsInit,
errThreadvarCannotInit, errWrongSymbolX,
errUser, errUser,
warnCannotOpenFile, warnCannotOpenFile,
warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit, warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit,
@ -321,6 +322,7 @@ const
errXhasSideEffects: "\'$1\' can have side effects", errXhasSideEffects: "\'$1\' can have side effects",
errIteratorExpected: "iterator within for loop context expected", errIteratorExpected: "iterator within for loop context expected",
errLetNeedsInit: "'let' symbol requires an initialization", errLetNeedsInit: "'let' symbol requires an initialization",
errThreadvarCannotInit: "a thread var cannot be initialized explicitly",
errWrongSymbolX: "usage of \'$1\' is a user-defined error", errWrongSymbolX: "usage of \'$1\' is a user-defined error",
errUser: "$1", errUser: "$1",
warnCannotOpenFile: "cannot open \'$1\' [CannotOpenFile]", warnCannotOpenFile: "cannot open \'$1\' [CannotOpenFile]",

View file

@ -269,6 +269,7 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
if def != nil and def.kind != nkEmpty: if def != nil and def.kind != nkEmpty:
# this is only needed for the evaluation pass: # this is only needed for the evaluation pass:
v.ast = def v.ast = def
if sfThread in v.flags: LocalError(def.info, errThreadvarCannotInit)
if a.kind != nkVarTuple: if a.kind != nkVarTuple:
v.typ = typ v.typ = typ
b = newNodeI(nkIdentDefs, a.info) b = newNodeI(nkIdentDefs, a.info)

View file

@ -694,8 +694,8 @@ proc execShellCmd*(command: string): int {.rtl, extern: "nos$1".} =
# iterator depends on ``environment``. # iterator depends on ``environment``.
var var
envComputed {.threadvar.}: bool = false envComputed {.threadvar.}: bool
environment {.threadvar.}: seq[string] = @[] environment {.threadvar.}: seq[string]
when defined(windows): when defined(windows):
# because we support Windows GUI applications, things get really # because we support Windows GUI applications, things get really
@ -705,6 +705,7 @@ when defined(windows):
proc getEnvVarsC() = proc getEnvVarsC() =
if not envComputed: if not envComputed:
environment = @[]
var var
env = getEnvironmentStringsA() env = getEnvironmentStringsA()
e = env e = env
@ -738,6 +739,7 @@ else:
proc getEnvVarsC() = proc getEnvVarsC() =
# retrieves the variables of char** env of C's main proc # retrieves the variables of char** env of C's main proc
if not envComputed: if not envComputed:
environment = @[]
when useNSGetEnviron: when useNSGetEnviron:
var gEnv = NSGetEnviron()[] var gEnv = NSGetEnviron()[]
var i = 0 var i = 0