This commit is contained in:
araq
2025-12-12 08:44:26 +01:00
parent 38bd228dda
commit ba9e23766b
2 changed files with 15 additions and 15 deletions

View File

@@ -124,7 +124,7 @@ proc fillLocalName(p: BProc; s: PSym) =
elif s.kind != skResult:
result.add "_" & rope(counter+1)
p.sigConflicts.inc(key)
ensureMutable s
backendEnsureMutable s
s.locImpl.snippet = result
proc scopeMangledParam(p: BProc; param: PSym) =

View File

@@ -651,7 +651,7 @@ proc localVarDecl(res: var Builder, p: BProc; n: PNode,
let s = n.sym
if s.loc.k == locNone:
fillLocalName(p, s)
ensureMutable s
backendEnsureMutable s
fillLoc(s.locImpl, locLocalVar, n, OnStack)
if s.kind == skLet: incl(s, lfNoDeepCopy)
@@ -713,7 +713,7 @@ proc assignGlobalVar(p: BProc, n: PNode; value: Rope) =
let s = n.sym
if s.loc.k == locNone:
fillBackendName(p.module, s)
ensureMutable s
backendEnsureMutable s
fillLoc(s.locImpl, locGlobalVar, n, OnHeap)
if treatGlobalDifferentlyForHCR(p.module, s): incl(s, lfIndirect)
@@ -722,7 +722,7 @@ proc assignGlobalVar(p: BProc, n: PNode; value: Rope) =
if q != nil and not containsOrIncl(q.declaredThings, s.id):
varInDynamicLib(q, s)
else:
ensureMutable s
backendEnsureMutable s
s.locImpl.snippet = mangleDynLibProc(s)
if value != "":
internalError(p.config, n.info, ".dynlib variables cannot have a value")
@@ -763,13 +763,13 @@ proc assignGlobalVar(p: BProc, n: PNode; value: Rope) =
genGlobalVarDecl(p.module.s[cfsVars], p, n, td, initializer = initializer)
if p.withinLoop > 0 and value == "":
# fixes tests/run/tzeroarray:
ensureMutable s
backendEnsureMutable s
resetLoc(p, s.locImpl)
proc callGlobalVarCppCtor(p: BProc; v: PSym; vn, value: PNode; didGenTemp: var bool) =
let s = vn.sym
fillBackendName(p.module, s)
ensureMutable s
backendEnsureMutable s
fillLoc(s.locImpl, locGlobalVar, vn, OnHeap)
let td = getTypeDesc(p.module, vn.sym.typ, dkVar)
var val = genCppParamsForCtor(p, value, didGenTemp)
@@ -959,7 +959,7 @@ proc symInDynamicLib(m: BModule, sym: PSym) =
var extname = sym.loc.snippet
if not isCall: loadDynamicLib(m, lib)
var tmp = mangleDynLibProc(sym)
ensureMutable sym
backendEnsureMutable sym
sym.locImpl.snippet = tmp # from now on we only need the internal name
sym.typ.sym = nil # generate a new name
inc(m.labels, 2)
@@ -1004,7 +1004,7 @@ proc varInDynamicLib(m: BModule, sym: PSym) =
loadDynamicLib(m, lib)
incl(sym, lfIndirect)
var tmp = mangleDynLibProc(sym)
ensureMutable sym
backendEnsureMutable sym
sym.locImpl.snippet = tmp # from now on we only need the internal name
inc(m.labels, 2)
let t = ptrType(getTypeDesc(m, sym.typ, dkVar))
@@ -1018,7 +1018,7 @@ proc varInDynamicLib(m: BModule, sym: PSym) =
m.s[cfsVars].addVar(name = sym.loc.snippet, typ = t)
proc symInDynamicLibPartial(m: BModule, sym: PSym) =
ensureMutable sym
backendEnsureMutable sym
sym.locImpl.snippet = mangleDynLibProc(sym)
sym.typ.sym = nil # generate a new name
@@ -1336,9 +1336,9 @@ proc genProcLvl3*(m: BModule, prc: PSym) =
returnStmt = extract(returnBuilder)
elif sfConstructor in prc.flags:
resNode.sym.incl lfIndirect
ensureMutable resNode.sym
backendEnsureMutable resNode.sym
fillLoc(resNode.sym.locImpl, locParam, resNode, "this", OnHeap)
ensureMutable prc
backendEnsureMutable prc
prc.locImpl.snippet = getTypeDesc(m, resNode.sym.locImpl.t, dkVar)
else:
fillResult(p.config, resNode, prc.typ)
@@ -1352,11 +1352,11 @@ proc genProcLvl3*(m: BModule, prc: PSym) =
if sfNoInit in prc.flags: discard
elif allPathsAsgnResult(p, procBody) == InitSkippable: discard
else:
ensureMutable res
backendEnsureMutable res
resetLoc(p, res.locImpl)
if skipTypes(res.typ, abstractInst).kind == tyArray:
#incl(res.loc.flags, lfIndirect)
ensureMutable res
backendEnsureMutable res
res.locImpl.storage = OnUnknown
for i in 1..<prc.typ.n.len:
@@ -2103,7 +2103,7 @@ proc hcrGetProcLoadCode(builder: var Builder, m: BModule, sym, prefix, handle, g
var extname = prefix & sym
var tmp = mangleDynLibProc(prc)
ensureMutable prc
backendEnsureMutable prc
prc.locImpl.snippet = tmp
prc.typ.sym = nil
@@ -2562,7 +2562,7 @@ proc generateLibraryDestroyGlobals(graph: ModuleGraph; m: BModule; body: PNode;
result = newSym(skProc, procname, m.idgen, m.module.owner, m.module.info)
result.typ = newProcType(m.module.info, m.idgen, m.module.owner)
result.typ.callConv = ccCDecl
ensureMutable result
backendEnsureMutable result
incl result.flagsImpl, sfExportc
result.locImpl.snippet = prefixedName
if isDynlib: