diff options
author | Clyybber <darkmine956@gmail.com> | 2019-11-28 17:13:04 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-11-28 17:13:04 +0100 |
commit | 7e747d11c66405f08cc7c69e5afc18348663275e (patch) | |
tree | d6277a88b503ddd503d8b769bdae6c72fcf3d27b /compiler/ccgthreadvars.nim | |
parent | b662842bd04852a751993ed506f9e38155a4e4aa (diff) | |
download | Nim-7e747d11c66405f08cc7c69e5afc18348663275e.tar.gz |
Cosmetic compiler cleanup (#12718)
* Cleanup compiler code base * Unify add calls * Unify len invocations * Unify range operators * Fix oversight * Remove {.procvar.} pragma * initCandidate -> newCandidate where reasonable * Unify safeLen calls
Diffstat (limited to 'compiler/ccgthreadvars.nim')
-rw-r--r-- | compiler/ccgthreadvars.nim | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/compiler/ccgthreadvars.nim b/compiler/ccgthreadvars.nim index d2d4ada36..7586aa865 100644 --- a/compiler/ccgthreadvars.nim +++ b/compiler/ccgthreadvars.nim @@ -19,8 +19,8 @@ proc accessThreadLocalVar(p: BProc, s: PSym) = if emulatedThreadVars(p.config) and not p.threadVarAccessed: p.threadVarAccessed = true incl p.module.flags, usesThreadVars - addf(p.procSec(cpsLocals), "\tNimThreadVars* NimTV_;$n", []) - add(p.procSec(cpsInit), + p.procSec(cpsLocals).addf("\tNimThreadVars* NimTV_;$n", []) + p.procSec(cpsInit).add( ropecg(p.module, "\tNimTV_ = (NimThreadVars*) #GetThreadLocalVars();$n", [])) proc declareThreadVar(m: BModule, s: PSym, isExtern: bool) = @@ -30,23 +30,23 @@ proc declareThreadVar(m: BModule, s: PSym, isExtern: bool) = # allocator for it :-( if not containsOrIncl(m.g.nimtvDeclared, s.id): m.g.nimtvDeps.add(s.loc.t) - addf(m.g.nimtv, "$1 $2;$n", [getTypeDesc(m, s.loc.t), s.loc.r]) + m.g.nimtv.addf("$1 $2;$n", [getTypeDesc(m, s.loc.t), s.loc.r]) else: - if isExtern: add(m.s[cfsVars], "extern ") - if optThreads in m.config.globalOptions: add(m.s[cfsVars], "NIM_THREADVAR ") - add(m.s[cfsVars], getTypeDesc(m, s.loc.t)) - addf(m.s[cfsVars], " $1;$n", [s.loc.r]) + if isExtern: m.s[cfsVars].add("extern ") + if optThreads in m.config.globalOptions: m.s[cfsVars].add("NIM_THREADVAR ") + m.s[cfsVars].add(getTypeDesc(m, s.loc.t)) + m.s[cfsVars].addf(" $1;$n", [s.loc.r]) proc generateThreadLocalStorage(m: BModule) = if m.g.nimtv != nil and (usesThreadVars in m.flags or sfMainModule in m.module.flags): for t in items(m.g.nimtvDeps): discard getTypeDesc(m, t) - addf(m.s[cfsSeqTypes], "typedef struct {$1} NimThreadVars;$n", [m.g.nimtv]) + m.s[cfsSeqTypes].addf("typedef struct {$1} NimThreadVars;$n", [m.g.nimtv]) proc generateThreadVarsSize(m: BModule) = if m.g.nimtv != nil: let externc = if m.config.cmd == cmdCompileToCpp or sfCompileToCpp in m.module.flags: "extern \"C\" " else: "" - addf(m.s[cfsProcs], + m.s[cfsProcs].addf( "$#NI NimThreadVarsSize(){return (NI)sizeof(NimThreadVars);}$n", [externc.rope]) |