mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-08 14:03:23 +00:00
initNodeTable and friends now return (#22444)
This commit is contained in:
@@ -1611,21 +1611,13 @@ proc createModuleAlias*(s: PSym, idgen: IdGenerator, newIdent: PIdent, info: TLi
|
||||
result.loc = s.loc
|
||||
result.annex = s.annex
|
||||
|
||||
proc initStrTable*(x: var TStrTable) =
|
||||
x.counter = 0
|
||||
newSeq(x.data, StartSize)
|
||||
proc initStrTable*(): TStrTable =
|
||||
result = TStrTable(counter: 0)
|
||||
newSeq(result.data, StartSize)
|
||||
|
||||
proc newStrTable*: TStrTable =
|
||||
result = default(TStrTable)
|
||||
initStrTable(result)
|
||||
|
||||
proc initIdTable*(x: var TIdTable) =
|
||||
x.counter = 0
|
||||
newSeq(x.data, StartSize)
|
||||
|
||||
proc newIdTable*: TIdTable =
|
||||
result = default(TIdTable)
|
||||
initIdTable(result)
|
||||
proc initIdTable*(): TIdTable =
|
||||
result = TIdTable(counter: 0)
|
||||
newSeq(result.data, StartSize)
|
||||
|
||||
proc resetIdTable*(x: var TIdTable) =
|
||||
x.counter = 0
|
||||
@@ -1633,17 +1625,17 @@ proc resetIdTable*(x: var TIdTable) =
|
||||
setLen(x.data, 0)
|
||||
setLen(x.data, StartSize)
|
||||
|
||||
proc initObjectSet*(x: var TObjectSet) =
|
||||
x.counter = 0
|
||||
newSeq(x.data, StartSize)
|
||||
proc initObjectSet*(): TObjectSet =
|
||||
result = TObjectSet(counter: 0)
|
||||
newSeq(result.data, StartSize)
|
||||
|
||||
proc initIdNodeTable*(x: var TIdNodeTable) =
|
||||
x.counter = 0
|
||||
newSeq(x.data, StartSize)
|
||||
proc initIdNodeTable*(): TIdNodeTable =
|
||||
result = TIdNodeTable(counter: 0)
|
||||
newSeq(result.data, StartSize)
|
||||
|
||||
proc initNodeTable*(x: var TNodeTable) =
|
||||
x.counter = 0
|
||||
newSeq(x.data, StartSize)
|
||||
proc initNodeTable*(): TNodeTable =
|
||||
result = TNodeTable(counter: 0)
|
||||
newSeq(result.data, StartSize)
|
||||
|
||||
proc skipTypes*(t: PType, kinds: TTypeKinds; maxIters: int): PType =
|
||||
result = t
|
||||
|
||||
@@ -1981,7 +1981,7 @@ proc rawNewModule(g: BModuleList; module: PSym, filename: AbsoluteFile): BModule
|
||||
result.preInitProc = newProc(nil, result)
|
||||
result.preInitProc.flags.incl nimErrorFlagDisabled
|
||||
result.preInitProc.labels = 100_000 # little hack so that unique temporaries are generated
|
||||
initNodeTable(result.dataCache)
|
||||
result.dataCache = initNodeTable()
|
||||
result.typeStack = @[]
|
||||
result.typeNodesName = getTempName(result)
|
||||
result.nimTypesName = getTempName(result)
|
||||
|
||||
@@ -373,7 +373,7 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
|
||||
result.seenSymbols = newStringTable(modeCaseInsensitive)
|
||||
result.id = 100
|
||||
result.jEntriesFinal = newJArray()
|
||||
initStrTable result.types
|
||||
result.types = initStrTable()
|
||||
result.onTestSnippet =
|
||||
proc (gen: var RstGenerator; filename, cmd: string; status: int; content: string) {.gcsafe.} =
|
||||
if conf.docCmd == docCmdSkip: return
|
||||
|
||||
@@ -187,7 +187,7 @@ proc evalTemplate*(n: PNode, tmpl, genSymOwner: PSym;
|
||||
ctx.genSymOwner = genSymOwner
|
||||
ctx.config = conf
|
||||
ctx.ic = ic
|
||||
initIdTable(ctx.mapping)
|
||||
ctx.mapping = initIdTable()
|
||||
ctx.instID = instID[]
|
||||
ctx.idgen = idgen
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ proc addUniqueSym*(scope: PScope, s: PSym): PSym =
|
||||
|
||||
proc openScope*(c: PContext): PScope {.discardable.} =
|
||||
result = PScope(parent: c.currentScope,
|
||||
symbols: newStrTable(),
|
||||
symbols: initStrTable(),
|
||||
depthLevel: c.scopeDepth + 1)
|
||||
c.currentScope = result
|
||||
|
||||
@@ -404,7 +404,7 @@ proc openShadowScope*(c: PContext) =
|
||||
## opens a shadow scope, just like any other scope except the depth is the
|
||||
## same as the parent -- see `isShadowScope`.
|
||||
c.currentScope = PScope(parent: c.currentScope,
|
||||
symbols: newStrTable(),
|
||||
symbols: initStrTable(),
|
||||
depthLevel: c.scopeDepth)
|
||||
|
||||
proc closeShadowScope*(c: PContext) =
|
||||
|
||||
@@ -81,8 +81,8 @@ proc getSysType*(g: ModuleGraph; info: TLineInfo; kind: TTypeKind): PType =
|
||||
|
||||
proc resetSysTypes*(g: ModuleGraph) =
|
||||
g.systemModule = nil
|
||||
initStrTable(g.compilerprocs)
|
||||
initStrTable(g.exposed)
|
||||
g.compilerprocs = initStrTable()
|
||||
g.exposed = initStrTable()
|
||||
for i in low(g.sysTypes)..high(g.sysTypes):
|
||||
g.sysTypes[i] = nil
|
||||
|
||||
@@ -124,7 +124,7 @@ proc registerNimScriptSymbol*(g: ModuleGraph; s: PSym) =
|
||||
proc getNimScriptSymbol*(g: ModuleGraph; name: string): PSym =
|
||||
strTableGet(g.exposed, getIdent(g.cache, name))
|
||||
|
||||
proc resetNimScriptSymbols*(g: ModuleGraph) = initStrTable(g.exposed)
|
||||
proc resetNimScriptSymbols*(g: ModuleGraph) = g.exposed = initStrTable()
|
||||
|
||||
proc getMagicEqSymForType*(g: ModuleGraph; t: PType; info: TLineInfo): PSym =
|
||||
case t.kind
|
||||
|
||||
@@ -142,7 +142,7 @@ type
|
||||
isFrontend: bool]
|
||||
|
||||
proc resetForBackend*(g: ModuleGraph) =
|
||||
initStrTable(g.compilerprocs)
|
||||
g.compilerprocs = initStrTable()
|
||||
g.typeInstCache.clear()
|
||||
g.procInstCache.clear()
|
||||
for a in mitems(g.attachedOps):
|
||||
@@ -196,8 +196,8 @@ template semtabAll*(g: ModuleGraph, m: PSym): TStrTable =
|
||||
g.ifaces[m.position].interfHidden
|
||||
|
||||
proc initStrTables*(g: ModuleGraph, m: PSym) =
|
||||
initStrTable(semtab(g, m))
|
||||
initStrTable(semtabAll(g, m))
|
||||
semtab(g, m) = initStrTable()
|
||||
semtabAll(g, m) = initStrTable()
|
||||
|
||||
proc strTableAdds*(g: ModuleGraph, m: PSym, s: PSym) =
|
||||
strTableAdd(semtab(g, m), s)
|
||||
@@ -459,7 +459,7 @@ proc initModuleGraphFields(result: ModuleGraph) =
|
||||
# A module ID of -1 means that the symbol is not attached to a module at all,
|
||||
# but to the module graph:
|
||||
result.idgen = IdGenerator(module: -1'i32, symId: 0'i32, typeId: 0'i32)
|
||||
initStrTable(result.packageSyms)
|
||||
result.packageSyms = initStrTable()
|
||||
result.deps = initIntSet()
|
||||
result.importDeps = initTable[FileIndex, seq[FileIndex]]()
|
||||
result.ifaces = @[]
|
||||
@@ -469,9 +469,9 @@ proc initModuleGraphFields(result: ModuleGraph) =
|
||||
result.suggestSymbols = initTable[FileIndex, seq[SymInfoPair]]()
|
||||
result.suggestErrors = initTable[FileIndex, seq[Suggest]]()
|
||||
result.methods = @[]
|
||||
initStrTable(result.compilerprocs)
|
||||
initStrTable(result.exposed)
|
||||
initStrTable(result.packageTypes)
|
||||
result.compilerprocs = initStrTable()
|
||||
result.exposed = initStrTable()
|
||||
result.packageTypes = initStrTable()
|
||||
result.emptyNode = newNode(nkEmpty)
|
||||
result.cacheSeqs = initTable[string, PNode]()
|
||||
result.cacheCounters = initTable[string, BiggestInt]()
|
||||
@@ -488,7 +488,7 @@ proc newModuleGraph*(cache: IdentCache; config: ConfigRef): ModuleGraph =
|
||||
initModuleGraphFields(result)
|
||||
|
||||
proc resetAllModules*(g: ModuleGraph) =
|
||||
initStrTable(g.packageSyms)
|
||||
g.packageSyms = initStrTable()
|
||||
g.deps = initIntSet()
|
||||
g.ifaces = @[]
|
||||
g.importStack = @[]
|
||||
@@ -496,8 +496,8 @@ proc resetAllModules*(g: ModuleGraph) =
|
||||
g.usageSym = nil
|
||||
g.owners = @[]
|
||||
g.methods = @[]
|
||||
initStrTable(g.compilerprocs)
|
||||
initStrTable(g.exposed)
|
||||
g.compilerprocs = initStrTable()
|
||||
g.exposed = initStrTable()
|
||||
initModuleGraphFields(g)
|
||||
|
||||
proc getModule*(g: ModuleGraph; fileIdx: FileIndex): PSym =
|
||||
|
||||
@@ -462,7 +462,7 @@ proc semAfterMacroCall(c: PContext, call, macroResult: PNode,
|
||||
# e.g. template foo(T: typedesc): seq[T]
|
||||
# We will instantiate the return type here, because
|
||||
# we now know the supplied arguments
|
||||
var paramTypes = newIdTable()
|
||||
var paramTypes = initIdTable()
|
||||
for param, value in genericParamsInMacroCall(s, call):
|
||||
idTablePut(paramTypes, param.typ, value.typ)
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@ proc popProcCon*(c: PContext) {.inline.} = c.p = c.p.next
|
||||
|
||||
proc put*(p: PProcCon; key, val: PSym) =
|
||||
if not p.mappingExists:
|
||||
initIdTable(p.mapping)
|
||||
p.mapping = initIdTable()
|
||||
p.mappingExists = true
|
||||
#echo "put into table ", key.info
|
||||
p.mapping.idTablePut(key, val)
|
||||
@@ -317,13 +317,13 @@ proc newContext*(graph: ModuleGraph; module: PSym): PContext =
|
||||
result.converters = @[]
|
||||
result.patterns = @[]
|
||||
result.includedFiles = initIntSet()
|
||||
initStrTable(result.pureEnumFields)
|
||||
initStrTable(result.userPragmas)
|
||||
result.pureEnumFields = initStrTable()
|
||||
result.userPragmas = initStrTable()
|
||||
result.generics = @[]
|
||||
result.unknownIdents = initIntSet()
|
||||
result.cache = graph.cache
|
||||
result.graph = graph
|
||||
initStrTable(result.signatures)
|
||||
result.signatures = initStrTable()
|
||||
result.features = graph.config.features
|
||||
if graph.config.symbolFiles != disabledSf:
|
||||
let id = module.position
|
||||
@@ -388,7 +388,7 @@ proc reexportSym*(c: PContext; s: PSym) =
|
||||
|
||||
proc newLib*(kind: TLibKind): PLib =
|
||||
new(result)
|
||||
result.kind = kind #initObjectSet(result.syms)
|
||||
result.kind = kind #result.syms = initObjectSet()
|
||||
|
||||
proc addToLib*(lib: PLib, sym: PSym) =
|
||||
#if sym.annex != nil and not isGenericRoutine(sym):
|
||||
|
||||
@@ -2361,8 +2361,7 @@ proc instantiateCreateFlowVarCall(c: PContext; t: PType;
|
||||
let sym = magicsys.getCompilerProc(c.graph, "nimCreateFlowVar")
|
||||
if sym == nil:
|
||||
localError(c.config, info, "system needs: nimCreateFlowVar")
|
||||
var bindings: TIdTable = default(TIdTable)
|
||||
initIdTable(bindings)
|
||||
var bindings: TIdTable = initIdTable()
|
||||
bindings.idTablePut(sym.ast[genericParamsPos][0].typ, t)
|
||||
result = c.semGenerateInstance(c, sym, bindings, info)
|
||||
# since it's an instantiation, we unmark it as a compilerproc. Otherwise
|
||||
|
||||
@@ -122,8 +122,7 @@ proc instantiateBody(c: PContext, n, params: PNode, result, orig: PSym) =
|
||||
inc c.inGenericInst
|
||||
# add it here, so that recursive generic procs are possible:
|
||||
var b = n[bodyPos]
|
||||
var symMap: TIdTable
|
||||
initIdTable symMap
|
||||
var symMap: TIdTable = initIdTable()
|
||||
if params != nil:
|
||||
for i in 1..<params.len:
|
||||
let param = params[i].sym
|
||||
@@ -176,10 +175,10 @@ proc instGenericContainer(c: PContext, info: TLineInfo, header: PType,
|
||||
var
|
||||
cl: TReplTypeVars = default(TReplTypeVars)
|
||||
|
||||
initIdTable(cl.symMap)
|
||||
initIdTable(cl.localCache)
|
||||
cl.symMap = initIdTable()
|
||||
cl.localCache = initIdTable()
|
||||
cl.typeMap = LayeredIdTable()
|
||||
initIdTable(cl.typeMap.topLayer)
|
||||
cl.typeMap.topLayer = initIdTable()
|
||||
|
||||
cl.info = info
|
||||
cl.c = c
|
||||
|
||||
@@ -73,8 +73,7 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
|
||||
counter = toInt64(lastOrd(c.config, base)) + 1
|
||||
rawAddSon(result, base)
|
||||
let isPure = result.sym != nil and sfPure in result.sym.flags
|
||||
var symbols: TStrTable
|
||||
initStrTable(symbols)
|
||||
var symbols: TStrTable = initStrTable()
|
||||
var hasNull = false
|
||||
for i in 1..<n.len:
|
||||
if n[i].kind == nkEmpty: continue
|
||||
|
||||
@@ -98,7 +98,7 @@ proc initLayeredTypeMap*(pt: TIdTable): LayeredIdTable =
|
||||
proc newTypeMapLayer*(cl: var TReplTypeVars): LayeredIdTable =
|
||||
result = LayeredIdTable()
|
||||
result.nextLayer = cl.typeMap
|
||||
initIdTable(result.topLayer)
|
||||
result.topLayer = initIdTable()
|
||||
|
||||
proc lookup(typeMap: LayeredIdTable, key: PType): PType =
|
||||
result = nil
|
||||
@@ -686,8 +686,8 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
|
||||
proc initTypeVars*(p: PContext, typeMap: LayeredIdTable, info: TLineInfo;
|
||||
owner: PSym): TReplTypeVars =
|
||||
result = default(TReplTypeVars)
|
||||
initIdTable(result.symMap)
|
||||
initIdTable(result.localCache)
|
||||
result.symMap = initIdTable()
|
||||
result.localCache = initIdTable()
|
||||
result.typeMap = typeMap
|
||||
result.info = info
|
||||
result.c = p
|
||||
|
||||
@@ -118,7 +118,7 @@ proc initCandidateAux(ctx: PContext,
|
||||
proc initCandidate*(ctx: PContext, c: var TCandidate, callee: PType) =
|
||||
initCandidateAux(ctx, c, callee)
|
||||
c.calleeSym = nil
|
||||
initIdTable(c.bindings)
|
||||
c.bindings = initIdTable()
|
||||
|
||||
proc put(c: var TCandidate, key, val: PType) {.inline.} =
|
||||
## Given: proc foo[T](x: T); foo(4)
|
||||
@@ -154,7 +154,7 @@ proc initCandidate*(ctx: PContext, c: var TCandidate, callee: PSym,
|
||||
c.diagnostics = @[] # if diagnosticsEnabled: @[] else: nil
|
||||
c.diagnosticsEnabled = diagnosticsEnabled
|
||||
c.magic = c.calleeSym.magic
|
||||
initIdTable(c.bindings)
|
||||
c.bindings = initIdTable()
|
||||
if binding != nil and callee.kind in routineKinds:
|
||||
var typeParams = callee.ast[genericParamsPos]
|
||||
for i in 1..min(typeParams.len, binding.len-1):
|
||||
|
||||
@@ -74,9 +74,7 @@ proc newTransNode(kind: TNodeKind, n: PNode,
|
||||
|
||||
proc newTransCon(owner: PSym): PTransCon =
|
||||
assert owner != nil
|
||||
new(result)
|
||||
initIdNodeTable(result.mapping)
|
||||
result.owner = owner
|
||||
result = PTransCon(mapping: initIdNodeTable(), owner: owner)
|
||||
|
||||
proc pushTransCon(c: PTransf, t: PTransCon) =
|
||||
t.next = c.transCon
|
||||
|
||||
Reference in New Issue
Block a user