From c7951504b7a79c1d6e28b33646727095b34972c3 Mon Sep 17 00:00:00 2001 From: bung87 Date: Sat, 9 Sep 2023 13:27:16 +0800 Subject: [PATCH] remove graph usageSym --- compiler/modules/importer.nim | 4 ++-- compiler/modules/modulegraphs.nim | 6 ++---- compiler/sem/semdata.nim | 2 +- compiler/sem/semexprs.nim | 2 +- compiler/sem/semstmts.nim | 8 ++++---- compiler/sem/semtempl.nim | 2 +- compiler/sem/semtypes.nim | 2 +- compiler/tools/suggest.nim | 17 +++++++---------- nimsuggest/nimsuggest.nim | 8 +++----- 9 files changed, 22 insertions(+), 29 deletions(-) diff --git a/compiler/modules/importer.nim b/compiler/modules/importer.nim index 3eba480b501..ec388126e3d 100644 --- a/compiler/modules/importer.nim +++ b/compiler/modules/importer.nim @@ -179,7 +179,7 @@ proc importSymbol(c: PContext, n: PNode, fromMod: PSym; importSet: var IntSet): else: rawImportSymbol(c, s, fromMod, importSet) if c.graph.onSymImport != nil: - c.graph.onSymImport(c.graph, n.info, s, c.graph.usageSym, false) + c.graph.onSymImport(c.graph, n.info, s, false) else: result = newSym(skError, ident, nextSymId(c.idgen), getCurrOwner(c), n.info) @@ -332,7 +332,7 @@ proc myImportModule(c: PContext, n: var PNode, importStmtResult: PNode): PSym = localReport(c.config, n.info, reportSym(rsemDeprecated, realModule)) if c.graph.onSymImport != nil: - c.graph.onSymImport(c.graph, n.info, result, c.graph.usageSym, false) + c.graph.onSymImport(c.graph, n.info, result, false) importStmtResult.add: case result.kind diff --git a/compiler/modules/modulegraphs.nim b/compiler/modules/modulegraphs.nim index a5ebd4d05b2..7f7b2cb9814 100644 --- a/compiler/modules/modulegraphs.nim +++ b/compiler/modules/modulegraphs.nim @@ -120,7 +120,7 @@ type vm*: RootRef # unfortunately the 'vm' state is shared project-wise, this will # be clarified in later compiler implementations. doStopCompile*: proc(): bool {.closure.} - usageSym*: PSym # for nimsuggest + forwardedSym*: PSym # for nimsuggest owners*: seq[PSym] methods*: seq[tuple[methods: seq[PSym], dispatcher: PSym]] # needs serialization! systemModule*: PSym @@ -158,8 +158,7 @@ type close: TPassClose, isFrontend: bool] - SuggestCallback* = proc (graph: ModuleGraph, info: TLineInfo, s: PSym, - usageSym: var PSym, isDecl: bool) + SuggestCallback* = proc (graph: ModuleGraph, info: TLineInfo, s: PSym, isDecl: bool) ## callback is used to decouple regular compiler code from suggest tool proc resetForBackend*(g: ModuleGraph) = @@ -528,7 +527,6 @@ proc resetAllModules*(g: ModuleGraph) = g.importStack = @[] g.transformed = @[] g.inclToMod = initTable[FileIndex, FileIndex]() - g.usageSym = nil g.owners = @[] g.methods = @[] initStrTable(g.compilerprocs) diff --git a/compiler/sem/semdata.nim b/compiler/sem/semdata.nim index 85ee7324019..132819078df 100644 --- a/compiler/sem/semdata.nim +++ b/compiler/sem/semdata.nim @@ -1165,7 +1165,7 @@ proc markUsed*(c: PContext; info: TLineInfo; s: PSym) = if sfError in s.flags: userError(conf, info, s) when defined(nimsuggest): if c.graph.onMarkUsed != nil: - c.graph.onMarkUsed(c.graph, info, s, c.graph.usageSym, false) + c.graph.onMarkUsed(c.graph, info, s, false) if {optStyleHint, optStyleError} * conf.globalOptions != {}: styleCheckUse(conf, info, s) markOwnerModuleAsUsed(c, s) diff --git a/compiler/sem/semexprs.nim b/compiler/sem/semexprs.nim index 06c979829b3..1c409f92340 100644 --- a/compiler/sem/semexprs.nim +++ b/compiler/sem/semexprs.nim @@ -3246,7 +3246,7 @@ proc semBlock(c: PContext, n: PNode; flags: TExprFlags): PNode = elif labl.owner == nil: labl.owner = c.p.owner - suggestSym(c.graph, lablNode.info, labl, c.graph.usageSym) + suggestSym(c.graph, lablNode.info, labl) styleCheckDef(c.config, labl) lablNode diff --git a/compiler/sem/semstmts.nim b/compiler/sem/semstmts.nim index aa90638632e..a827e0b1175 100644 --- a/compiler/sem/semstmts.nim +++ b/compiler/sem/semstmts.nim @@ -41,7 +41,7 @@ proc semBreakStmt(c: PContext, n: PNode): ElaborateAst = # make sure the label is okay to use: if s.kind == skLabel and s.owner.id == c.p.owner.id: incl(s.flags, sfUsed) - suggestSym(c.graph, n.info, s, c.graph.usageSym) + suggestSym(c.graph, n.info, s) else: # a label not part of the current context result.diag = PAstDiag(kind: adSemInvalidControlFlow, label: s) @@ -352,7 +352,7 @@ proc semIdentDef(c: PContext, n: PNode, kind: TSymKind): PSym = result.options = c.config.options let info = getIdentLineInfo(n) - suggestSym(c.graph, info, result, c.graph.usageSym) + suggestSym(c.graph, info, result) proc checkNilableOrError(c: PContext; def: PNode): PNode = ## checks if a symbol node is nilable, on success returns def, else nkError @@ -2513,7 +2513,7 @@ proc semRoutineName(c: PContext, n: PNode, kind: TSymKind; allowAnon = true): PN if c.isTopLevel: incl(s.flags, sfGlobal) - suggestSym(c.graph, getIdentLineInfo(n), s, c.graph.usageSym) + suggestSym(c.graph, getIdentLineInfo(n), s) styleCheckDef(c.config, s) else: # XXX: this should be the resonsibility of the macro sanitizer instead @@ -2717,7 +2717,7 @@ proc semProcAux(c: PContext, n: PNode, validPragmas: TSpecialWords, if not comesFromShadowScope: excl(proto.flags, sfForward) incl(proto.flags, sfWasForwarded) - suggestSym(c.graph, s.info, proto, c.graph.usageSym) + suggestSym(c.graph, s.info, proto) closeScope(c) # close scope with wrong parameter symbols openScope(c) # open scope for old (correct) parameter symbols if proto.ast[genericParamsPos].isGenericParams: diff --git a/compiler/sem/semtempl.nim b/compiler/sem/semtempl.nim index e4c029e09e1..399c9651ad1 100644 --- a/compiler/sem/semtempl.nim +++ b/compiler/sem/semtempl.nim @@ -436,7 +436,7 @@ proc semTemplSymbol(c: PContext, n: PNode, s: PSym; isField: bool): PNode = result = newSymNode(s, n.info) # Issue #12832 when defined(nimsuggest): - suggestSym(c.graph, n.info, s, c.graph.usageSym, false) + suggestSym(c.graph, n.info, s, false) # field access (dot expr) will be handled by builtinFieldAccess if not isField and {optStyleHint, optStyleError} * c.config.globalOptions != {}: styleCheckUse(c.config, n.info, s) diff --git a/compiler/sem/semtypes.nim b/compiler/sem/semtypes.nim index 2830a00e9c8..8719367736c 100644 --- a/compiler/sem/semtypes.nim +++ b/compiler/sem/semtypes.nim @@ -1028,7 +1028,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int, for i in 0..