mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +00:00
fixes: replace ensureMutable with backendEnsureMutable in ccgtypes (#25640)
This commit is contained in:
@@ -309,7 +309,7 @@ proc addAbiCheck(m: BModule; t: PType, name: Rope) =
|
||||
|
||||
|
||||
proc fillResult(conf: ConfigRef; param: PNode, proctype: PType) =
|
||||
ensureMutable param.sym
|
||||
backendEnsureMutable param.sym
|
||||
fillLoc(param.sym.locImpl, locParam, param, "Result",
|
||||
OnStack)
|
||||
let t = param.sym.typ
|
||||
@@ -542,7 +542,7 @@ proc genMemberProcParams(m: BModule; prc: PSym, superCall, rettype, name, params
|
||||
var types, names, args: seq[string] = @[]
|
||||
if not isCtor:
|
||||
var this = t.n[1].sym
|
||||
ensureMutable this
|
||||
backendEnsureMutable this
|
||||
fillParamName(m, this)
|
||||
fillLoc(this.locImpl, locParam, t.n[1],
|
||||
this.paramStorageLoc)
|
||||
@@ -564,7 +564,7 @@ proc genMemberProcParams(m: BModule; prc: PSym, superCall, rettype, name, params
|
||||
else:
|
||||
descKind = dkRefParam
|
||||
var typ, name: string
|
||||
ensureMutable param
|
||||
backendEnsureMutable param
|
||||
fillParamName(m, param)
|
||||
fillLoc(param.locImpl, locParam, t.n[i],
|
||||
param.paramStorageLoc)
|
||||
@@ -1183,7 +1183,7 @@ proc genMemberProcHeader(m: BModule; prc: PSym; result: var Builder; asPtr: bool
|
||||
let isCtor = sfConstructor in prc.flags
|
||||
var check = initIntSet()
|
||||
fillBackendName(m, prc)
|
||||
ensureMutable prc
|
||||
backendEnsureMutable prc
|
||||
fillLoc(prc.locImpl, locProc, prc.ast[namePos], OnUnknown)
|
||||
var memberOp = "#." #only virtual
|
||||
var typ: PType
|
||||
|
||||
@@ -4,6 +4,8 @@ discard """
|
||||
5
|
||||
3
|
||||
2
|
||||
1.0
|
||||
2.0
|
||||
'''
|
||||
"""
|
||||
|
||||
@@ -42,4 +44,26 @@ proc divmod(a, b: int): (int, int) =
|
||||
|
||||
let (q, r) = divmod(17, 5)
|
||||
echo q
|
||||
echo r
|
||||
echo r
|
||||
|
||||
|
||||
# Shallow object with seq (trigger GC interaction)
|
||||
type
|
||||
Matrix = object
|
||||
rows, cols: int
|
||||
data: seq[float]
|
||||
|
||||
proc newMatrix(r, c: int): Matrix =
|
||||
Matrix(rows: r, cols: c, data: newSeq[float](r * c))
|
||||
|
||||
proc `[]`(m: Matrix, r, c: int): float =
|
||||
m.data[r * m.cols + c]
|
||||
|
||||
proc `[]=`(m: var Matrix, r, c: int, v: float) =
|
||||
m.data[r * m.cols + c] = v
|
||||
|
||||
var m = newMatrix(2, 2)
|
||||
m[0, 0] = 1.0
|
||||
m[1, 1] = 2.0
|
||||
echo m[0, 0]
|
||||
echo m[1, 1]
|
||||
|
||||
Reference in New Issue
Block a user