Skip to content

Commit

Permalink
followup
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Jun 26, 2021
1 parent 2a3e22d commit 84c0855
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 30 deletions.
9 changes: 0 additions & 9 deletions compiler/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,6 @@ type
TSym* {.acyclic.} = object of TIdObj # Keep in sync with PackedSym
# proc and type instantiations are cached in the generic symbol
case kind*: TSymKind
of skModule:
realModule*: PSym # for `createModuleAlias`
of routineKinds:
#procInstCache*: seq[PInstantiation]
gcUnsafetyReason*: PSym # for better error messages wrt gcsafe
Expand Down Expand Up @@ -1497,13 +1495,6 @@ proc createModuleAlias*(s: PSym, id: ItemId, newIdent: PIdent, info: TLineInfo;
result.position = s.position
result.loc = s.loc
result.annex = s.annex
result.realModule = s

proc resolveModuleAlias*(s: PSym): PSym =
assert s.kind == skModule
result = s
if result.realModule != nil: # owner is unrelated
result = result.realModule

proc initStrTable*(x: var TStrTable) =
x.counter = 0
Expand Down
12 changes: 2 additions & 10 deletions compiler/ic/ic.nim
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,11 @@ proc storeSym*(s: PSym; c: var PackedEncoder; m: var PackedModule): PackedItemId
storeNode(p, s, ast)
storeNode(p, s, constraint)

case s.kind
of {skLet, skVar, skField, skForVar}:
if s.kind in {skLet, skVar, skField, skForVar}:
c.addMissing s.guard
p.guard = s.guard.safeItemId(c, m)
p.bitsize = s.bitsize
p.alignment = s.alignment
of skModule:
p.realModule = s.realModule.safeItemId(c, m)
else: discard

p.externalName = toLitId(if s.loc.r.isNil: "" else: $s.loc.r, m)
p.locFlags = s.loc.flags
Expand Down Expand Up @@ -854,14 +850,10 @@ proc symBodyFromPacked(c: var PackedDecoder; g: var PackedModuleGraph;
when hasFFI:
result.cname = g[si].fromDisk.strings[s.cname]

case s.kind
of {skLet, skVar, skField, skForVar}:
if s.kind in {skLet, skVar, skField, skForVar}:
result.guard = loadSym(c, g, si, s.guard)
result.bitsize = s.bitsize
result.alignment = s.alignment
of skModule:
result.realModule = loadSym(c, g, si, s.realModule)
else: discard
result.owner = loadSym(c, g, si, s.owner)
let externalName = g[si].fromDisk.strings[s.externalName]
if externalName != "":
Expand Down
1 change: 0 additions & 1 deletion compiler/ic/packed_ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ type
when hasFFI:
cname*: LitId
constraint*: NodeId
realModule*: PackedItemId

PackedType* = object
kind*: TTypeKind
Expand Down
13 changes: 5 additions & 8 deletions compiler/importer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,13 @@ proc myImportModule(c: PContext, n: var PNode, importStmtResult: PNode): PSym =
c.graph.importStack.setLen(L)
# we cannot perform this check reliably because of
# test: modules/import_in_config) # xxx is that still true?
# let realModule = result.resolveModuleAlias
let realModule = result
if realModule == c.module:
if result == c.module:
localError(c.config, n.info, "module '$1' cannot import itself" % c.module.name.s)
if sfDeprecated in realModule.flags:
if realModule.constraint != nil:
message(c.config, n.info, warnDeprecated, realModule.constraint.strVal & "; " & realModule.name.s & " is deprecated")
if sfDeprecated in result.flags:
if result.constraint != nil:
message(c.config, n.info, warnDeprecated, result.constraint.strVal & "; " & result.name.s & " is deprecated")
else:
message(c.config, n.info, warnDeprecated, realModule.name.s & " is deprecated")
message(c.config, n.info, warnDeprecated, result.name.s & " is deprecated")
suggestSym(c.graph, n.info, result, c.graph.usageSym, false)
importStmtResult.add newSymNode(result, n.info)
#newStrNode(toFullPath(c.config, f), n.info)
Expand All @@ -306,7 +304,6 @@ proc impMod(c: PContext; it: PNode; importStmtResult: PNode) =
importAllSymbols(c, m)
#importForwarded(c, m.ast, emptySet, m)
for s in allSyms(c.graph, m): # fixes bug #17510, for re-exported symbols
# if s.owner != m.resolveModuleAlias:
if s.owner != m:
c.exportIndirections.incl((m.id, s.id))

Expand Down
3 changes: 1 addition & 2 deletions compiler/suggest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,7 @@ proc markOwnerModuleAsUsed(c: PContext; s: PSym) =
var i = 0
while i <= high(c.unusedImports):
let candidate = c.unusedImports[i][0]
# let candidate2 = candidate.resolveModuleAlias
let candidate2 = candidate
let candidate2 = candidate # PRTEMP
if candidate2 == module or c.exportIndirections.contains((candidate.id, s.id)):
# mark it as used:
c.unusedImports.del(i)
Expand Down

0 comments on commit 84c0855

Please sign in to comment.