parent
39d0a93d0e
commit
c4dd0c4301
1 changed files with 9 additions and 3 deletions
|
|
@ -480,6 +480,9 @@ proc resetLoc(p: BProc, loc: var TLoc) =
|
||||||
# on the bytes following the m_type field?
|
# on the bytes following the m_type field?
|
||||||
genObjectInit(p, cpsStmts, loc.t, loc, constructObj)
|
genObjectInit(p, cpsStmts, loc.t, loc, constructObj)
|
||||||
|
|
||||||
|
proc isOrHasImportedCppType(typ: PType): bool =
|
||||||
|
searchTypeFor(typ.skipTypes({tyRef}), isImportedCppType)
|
||||||
|
|
||||||
proc constructLoc(p: BProc, loc: var TLoc, isTemp = false) =
|
proc constructLoc(p: BProc, loc: var TLoc, isTemp = false) =
|
||||||
let typ = loc.t
|
let typ = loc.t
|
||||||
if optSeqDestructors in p.config.globalOptions and skipTypes(typ, abstractInst + {tyStatic}).kind in {tyString, tySequence}:
|
if optSeqDestructors in p.config.globalOptions and skipTypes(typ, abstractInst + {tyStatic}).kind in {tyString, tySequence}:
|
||||||
|
|
@ -497,7 +500,7 @@ proc constructLoc(p: BProc, loc: var TLoc, isTemp = false) =
|
||||||
if not isTemp or containsGarbageCollectedRef(loc.t):
|
if not isTemp or containsGarbageCollectedRef(loc.t):
|
||||||
# don't use nimZeroMem for temporary values for performance if we can
|
# don't use nimZeroMem for temporary values for performance if we can
|
||||||
# avoid it:
|
# avoid it:
|
||||||
if not isImportedCppType(typ):
|
if not isOrHasImportedCppType(typ):
|
||||||
linefmt(p, cpsStmts, "#nimZeroMem((void*)$1, sizeof($2));$n",
|
linefmt(p, cpsStmts, "#nimZeroMem((void*)$1, sizeof($2));$n",
|
||||||
[addrLoc(p.config, loc), getTypeDesc(p.module, typ, mapTypeChooser(loc))])
|
[addrLoc(p.config, loc), getTypeDesc(p.module, typ, mapTypeChooser(loc))])
|
||||||
genObjectInit(p, cpsStmts, loc.t, loc, constructObj)
|
genObjectInit(p, cpsStmts, loc.t, loc, constructObj)
|
||||||
|
|
@ -517,6 +520,9 @@ proc initLocalVar(p: BProc, v: PSym, immediateAsgn: bool) =
|
||||||
proc getTemp(p: BProc, t: PType, result: var TLoc; needsInit=false) =
|
proc getTemp(p: BProc, t: PType, result: var TLoc; needsInit=false) =
|
||||||
inc(p.labels)
|
inc(p.labels)
|
||||||
result.r = "T" & rope(p.labels) & "_"
|
result.r = "T" & rope(p.labels) & "_"
|
||||||
|
if p.module.compileToCpp and isOrHasImportedCppType(t):
|
||||||
|
linefmt(p, cpsLocals, "$1 $2{};$n", [getTypeDesc(p.module, t, skVar), result.r])
|
||||||
|
else:
|
||||||
linefmt(p, cpsLocals, "$1 $2;$n", [getTypeDesc(p.module, t, skVar), result.r])
|
linefmt(p, cpsLocals, "$1 $2;$n", [getTypeDesc(p.module, t, skVar), result.r])
|
||||||
result.k = locTemp
|
result.k = locTemp
|
||||||
result.lode = lodeTyp t
|
result.lode = lodeTyp t
|
||||||
|
|
@ -575,7 +581,7 @@ proc assignLocalVar(p: BProc, n: PNode) =
|
||||||
# this need not be fulfilled for inline procs; they are regenerated
|
# this need not be fulfilled for inline procs; they are regenerated
|
||||||
# for each module that uses them!
|
# for each module that uses them!
|
||||||
let nl = if optLineDir in p.config.options: "" else: "\L"
|
let nl = if optLineDir in p.config.options: "" else: "\L"
|
||||||
let decl = localVarDecl(p, n) & ";" & nl
|
let decl = localVarDecl(p, n) & (if p.module.compileToCpp and isOrHasImportedCppType(n.typ): "{};" else: ";") & nl
|
||||||
line(p, cpsLocals, decl)
|
line(p, cpsLocals, decl)
|
||||||
|
|
||||||
include ccgthreadvars
|
include ccgthreadvars
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue