@@ -84,7 +84,8 @@ proc fillBackendName(m: BModule; s: PSym) =
8484 if m.hcrOn:
8585 result .add '_'
8686 result .add (idOrSig (s, m.module.name.s.mangle, m.sigConflicts, m.config))
87- s.loc.snippet = result
87+ ensureMutable s
88+ s.locImpl.snippet = result
8889
8990proc fillParamName (m: BModule ; s: PSym ) =
9091 if s.loc.snippet == " " :
@@ -107,7 +108,8 @@ proc fillParamName(m: BModule; s: PSym) =
107108 # and a function called in main or proxy uses `socket` as a parameter name.
108109 # That would lead to either needing to reload `proxy` or to overwrite the
109110 # executable file for the main module, which is running (or both!) -> error.
110- s.loc.snippet = res.rope
111+ ensureMutable s
112+ s.locImpl.snippet = res.rope
111113
112114proc fillLocalName (p: BProc ; s: PSym ) =
113115 assert s.kind in skLocalVars+ {skTemp}
@@ -122,7 +124,8 @@ proc fillLocalName(p: BProc; s: PSym) =
122124 elif s.kind != skResult:
123125 result .add " _" & rope (counter+ 1 )
124126 p.sigConflicts.inc (key)
125- s.loc.snippet = result
127+ ensureMutable s
128+ s.locImpl.snippet = result
126129
127130proc scopeMangledParam (p: BProc ; param: PSym ) =
128131 # # parameter generation only takes BModule, not a BProc, so we have to
@@ -155,9 +158,10 @@ proc getTypeName(m: BModule; typ: PType; sig: SigHash): Rope =
155158 else :
156159 break
157160 let typ = if typ.kind in {tyAlias, tySink, tyOwned}: typ.elementType else : typ
161+ ensureMutable typ
158162 if typ.loc.snippet == " " :
159- typ.typeName (typ.loc .snippet)
160- typ.loc .snippet.add $ sig
163+ typ.typeName (typ.locImpl .snippet)
164+ typ.locImpl .snippet.add $ sig
161165 else :
162166 when defined (debugSigHashes):
163167 # check consistency:
@@ -300,12 +304,13 @@ proc addAbiCheck(m: BModule; t: PType, name: Rope) =
300304
301305
302306proc fillResult (conf: ConfigRef ; param: PNode , proctype: PType ) =
303- fillLoc (param.sym.loc, locParam, param, " Result" ,
307+ ensureMutable param.sym
308+ fillLoc (param.sym.locImpl, locParam, param, " Result" ,
304309 OnStack )
305310 let t = param.sym.typ
306311 if mapReturnType (conf, t) != ctArray and isInvalidReturnType (conf, proctype):
307- incl (param.sym.loc .flags, lfIndirect)
308- param.sym.loc .storage = OnUnknown
312+ incl (param.sym.locImpl .flags, lfIndirect)
313+ param.sym.locImpl .storage = OnUnknown
309314
310315proc typeNameOrLiteral (m: BModule ; t: PType , literal: string ): Rope =
311316 if t.sym != nil and sfImportc in t.sym.flags and t.sym.magic == mNone:
@@ -524,14 +529,15 @@ proc genMemberProcParams(m: BModule; prc: PSym, superCall, rettype, name, params
524529 var types, names, args: seq [string ] = @ []
525530 if not isCtor:
526531 var this = t.n[1 ].sym
532+ ensureMutable this
527533 fillParamName (m, this)
528- fillLoc (this.loc , locParam, t.n[1 ],
534+ fillLoc (this.locImpl , locParam, t.n[1 ],
529535 this.paramStorageLoc)
530536 if this.typ.kind == tyPtr:
531- this.loc .snippet = " this"
537+ this.locImpl .snippet = " this"
532538 else :
533- this.loc .snippet = " (*this)"
534- names.add this.loc .snippet
539+ this.locImpl .snippet = " (*this)"
540+ names.add this.locImpl .snippet
535541 types.add getTypeDescWeak (m, this.typ, check, dkParam)
536542
537543 let firstParam = if isCtor: 1 else : 2
@@ -545,21 +551,22 @@ proc genMemberProcParams(m: BModule; prc: PSym, superCall, rettype, name, params
545551 else :
546552 descKind = dkRefParam
547553 var typ, name: string
554+ ensureMutable param
548555 fillParamName (m, param)
549- fillLoc (param.loc , locParam, t.n[i],
556+ fillLoc (param.locImpl , locParam, t.n[i],
550557 param.paramStorageLoc)
551558 if ccgIntroducedPtr (m.config, param, t.returnType) and descKind == dkParam:
552559 typ = getTypeDescWeak (m, param.typ, check, descKind) & " *"
553- incl (param.loc .flags, lfIndirect)
554- param.loc .storage = OnUnknown
560+ incl (param.locImpl .flags, lfIndirect)
561+ param.locImpl .storage = OnUnknown
555562 elif weakDep:
556563 typ = getTypeDescWeak (m, param.typ, check, descKind)
557564 else :
558565 typ = getTypeDescAux (m, param.typ, check, descKind)
559566 if sfNoalias in param.flags:
560567 typ.add (" NIM_NOALIAS " )
561568
562- name = param.loc .snippet
569+ name = param.locImpl .snippet
563570 types.add typ
564571 names.add name
565572 if sfCodegenDecl notin param.flags:
@@ -601,14 +608,15 @@ proc genProcParams(m: BModule; t: PType, rettype: var Rope, params: var Builder,
601608 else :
602609 descKind = dkRefParam
603610 if isCompileTimeOnly (param.typ): continue
611+ ensureMutable param
604612 fillParamName (m, param)
605- fillLoc (param.loc , locParam, t.n[i],
613+ fillLoc (param.locImpl , locParam, t.n[i],
606614 param.paramStorageLoc)
607615 var typ: Rope
608616 if ccgIntroducedPtr (m.config, param, t.returnType) and descKind == dkParam:
609617 typ = ptrType (getTypeDescWeak (m, param.typ, check, descKind))
610- incl (param.loc .flags, lfIndirect)
611- param.loc .storage = OnUnknown
618+ incl (param.locImpl .flags, lfIndirect)
619+ param.locImpl .storage = OnUnknown
612620 elif weakDep:
613621 typ = (getTypeDescWeak (m, param.typ, check, descKind))
614622 else :
@@ -620,9 +628,9 @@ proc genProcParams(m: BModule; t: PType, rettype: var Rope, params: var Builder,
620628 var j = 0
621629 while arr.kind in {tyOpenArray, tyVarargs}:
622630 # this fixes the 'sort' bug:
623- if param.typ.kind in {tyVar, tyLent}: param.loc .storage = OnUnknown
631+ if param.typ.kind in {tyVar, tyLent}: param.locImpl .storage = OnUnknown
624632 # need to pass hidden parameter:
625- params.addParam (paramBuilder, name = param.loc .snippet & " Len_" & $ j, typ = NimInt )
633+ params.addParam (paramBuilder, name = param.locImpl .snippet & " Len_" & $ j, typ = NimInt )
626634 inc (j)
627635 arr = arr[0 ].skipTypes ({tySink})
628636 if t.returnType != nil and isInvalidReturnType (m.config, t):
@@ -707,7 +715,8 @@ proc genRecordFieldsAux(m: BModule; n: PNode,
707715 if field.typ.kind == tyVoid: return
708716 # assert(field.ast == nil)
709717 let sname = mangleRecFieldName (m, field)
710- fillLoc (field.loc, locField, n, unionPrefix & sname, OnUnknown )
718+ ensureMutable field
719+ fillLoc (field.locImpl, locField, n, unionPrefix & sname, OnUnknown )
711720 # for importcpp'ed objects, we only need to set field.loc, but don't
712721 # have to recurse via 'getTypeDescAux'. And not doing so prevents problems
713722 # with heavily templatized C++ code:
@@ -1155,7 +1164,8 @@ proc genMemberProcHeader(m: BModule; prc: PSym; result: var Builder; asPtr: bool
11551164 let isCtor = sfConstructor in prc.flags
11561165 var check = initIntSet ()
11571166 fillBackendName (m, prc)
1158- fillLoc (prc.loc, locProc, prc.ast[namePos], OnUnknown )
1167+ ensureMutable prc
1168+ fillLoc (prc.locImpl, locProc, prc.ast[namePos], OnUnknown )
11591169 var memberOp = " #." # only virtual
11601170 var typ: PType
11611171 if isCtor:
@@ -1187,7 +1197,7 @@ proc genMemberProcHeader(m: BModule; prc: PSym; result: var Builder; asPtr: bool
11871197 superCall = " "
11881198 else :
11891199 if not isCtor:
1190- prc.loc .snippet = " $1$2(@)" % [memberOp, name]
1200+ prc.locImpl .snippet = " $1$2(@)" % [memberOp, name]
11911201 elif superCall != " " :
11921202 superCall = " : " & superCall
11931203
@@ -1202,14 +1212,15 @@ proc genProcHeader(m: BModule; prc: PSym; result: var Builder; visibility: var D
12021212 # using static is needed for inline procs
12031213 var check = initIntSet ()
12041214 fillBackendName (m, prc)
1205- fillLoc (prc.loc, locProc, prc.ast[namePos], OnUnknown )
1215+ ensureMutable prc
1216+ fillLoc (prc.locImpl, locProc, prc.ast[namePos], OnUnknown )
12061217 var rettype: Snippet = " "
12071218 var desc = newBuilder (" " )
12081219 genProcParams (m, prc.typ, rettype, desc, check, true , false )
12091220 let params = extract (desc)
12101221 # handle the 2 options for hotcodereloading codegen - function pointer
12111222 # (instead of forward declaration) or header for function body with "_actual" postfix
1212- var name = prc.loc .snippet
1223+ var name = prc.locImpl .snippet
12131224 if not asPtr and isReloadable (m, prc):
12141225 name.add (" _actual" )
12151226 # careful here! don't access ``prc.ast`` as that could reload large parts of
@@ -1449,7 +1460,7 @@ proc genObjectInfo(m: BModule; typ, origType: PType, name: Rope; info: TLineInfo
14491460 var t = typ.baseClass
14501461 while t != nil :
14511462 t = t.skipTypes (skipPtrs)
1452- t.flags. incl tfObjHasKids
1463+ t.incl tfObjHasKids
14531464 t = t.baseClass
14541465
14551466proc genTupleInfo (m: BModule ; typ, origType: PType , name: Rope ; info: TLineInfo ) =
@@ -1645,8 +1656,8 @@ proc generateRttiDestructor(g: ModuleGraph; typ: PType; owner: PSym; kind: TType
16451656 n[bodyPos] = body
16461657 result .ast = n
16471658
1648- incl result .flags , sfFromGeneric
1649- incl result .flags , sfGeneratedOp
1659+ incl result .flagsImpl , sfFromGeneric
1660+ incl result .flagsImpl , sfGeneratedOp
16501661
16511662proc genHook (m: BModule ; t: PType ; info: TLineInfo ; op: TTypeAttachedOp ; result: var Builder ) =
16521663 let theProc = getAttachedOp (m.g.graph, t, op)
0 commit comments