IC: bugfix (#17533)

* cleanups
* IC: bugfix
This commit is contained in:
Andreas Rumpf 2021-03-27 12:21:57 +01:00 • committed by GitHub
commit cf5ce7616b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -28,6 +28,7 @@ type
PackedModule* = object ## the parts of a PackedEncoder that are part of the .rod file PackedModule* = object ## the parts of a PackedEncoder that are part of the .rod file
definedSymbols: string definedSymbols: string
moduleFlags: TSymFlags
includes: seq[(LitId, string)] # first entry is the module filename itself includes: seq[(LitId, string)] # first entry is the module filename itself
imports: seq[LitId] # the modules this module depends on imports: seq[LitId] # the modules this module depends on
toReplay: PackedTree # pragmas and VM specific state to replay. toReplay: PackedTree # pragmas and VM specific state to replay.
@ -139,6 +140,7 @@ proc initEncoder*(c: var PackedEncoder; m: var PackedModule; moduleSym: PSym; co
m.sh = Shared() m.sh = Shared()
c.thisModule = moduleSym.itemId.module c.thisModule = moduleSym.itemId.module
c.config = config c.config = config
m.moduleFlags = moduleSym.flags
m.bodies = newTreeFrom(m.topLevel) m.bodies = newTreeFrom(m.topLevel)
m.toReplay = newTreeFrom(m.topLevel) m.toReplay = newTreeFrom(m.topLevel)
@ -511,6 +513,7 @@ proc loadRodFile*(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef
f.loadSection configSection f.loadSection configSection
f.loadPrim m.definedSymbols f.loadPrim m.definedSymbols
f.loadPrim m.moduleFlags
f.loadPrim m.cfg f.loadPrim m.cfg
if f.err == ok and not configIdentical(m, config) and not ignoreConfig: if f.err == ok and not configIdentical(m, config) and not ignoreConfig:
@ -581,6 +584,7 @@ proc saveRodFile*(filename: AbsoluteFile; encoder: var PackedEncoder; m: var Pac
f.storeHeader() f.storeHeader()
f.storeSection configSection f.storeSection configSection
f.storePrim m.definedSymbols f.storePrim m.definedSymbols
f.storePrim m.moduleFlags
f.storePrim m.cfg f.storePrim m.cfg
template storeSeqSection(section, data) {.dirty.} = template storeSeqSection(section, data) {.dirty.} =
@ -909,8 +913,7 @@ proc setupLookupTables(g: var PackedModuleGraph; conf: ConfigRef; cache: IdentCa
info: newLineInfo(fileIdx, 1, 1), info: newLineInfo(fileIdx, 1, 1),
position: int(fileIdx)) position: int(fileIdx))
m.module.owner = newPackage(conf, cache, fileIdx) m.module.owner = newPackage(conf, cache, fileIdx)
if fileIdx == conf.projectMainIdx2: m.module.flags = m.fromDisk.moduleFlags
m.module.flags.incl sfMainModule
proc loadToReplayNodes(g: var PackedModuleGraph; conf: ConfigRef; cache: IdentCache; proc loadToReplayNodes(g: var PackedModuleGraph; conf: ConfigRef; cache: IdentCache;
fileIdx: FileIndex; m: var LoadedModule) = fileIdx: FileIndex; m: var LoadedModule) =

View file

@ -29,8 +29,7 @@ proc transformBody*(g: ModuleGraph; idgen: IdGenerator, prc: PSym, cache: bool):
import closureiters, lambdalifting import closureiters, lambdalifting
type type
PTransCon = ref TTransCon PTransCon = ref object # part of TContext; stackable
TTransCon{.final.} = object # part of TContext; stackable
mapping: TIdNodeTable # mapping from symbols to nodes mapping: TIdNodeTable # mapping from symbols to nodes
owner: PSym # current owner owner: PSym # current owner
forStmt: PNode # current for stmt forStmt: PNode # current for stmt
@ -40,7 +39,7 @@ type
# if we encounter the 2nd yield statement # if we encounter the 2nd yield statement
next: PTransCon # for stacking next: PTransCon # for stacking
TTransfContext = object PTransf = ref object
module: PSym module: PSym
transCon: PTransCon # top of a TransCon stack transCon: PTransCon # top of a TransCon stack
inlining: int # > 0 if we are in inlining context (copy vars) inlining: int # > 0 if we are in inlining context (copy vars)
@ -49,7 +48,6 @@ type
deferDetected, tooEarly: bool deferDetected, tooEarly: bool
graph: ModuleGraph graph: ModuleGraph
idgen: IdGenerator idgen: IdGenerator
PTransf = ref TTransfContext
proc newTransNode(a: PNode): PNode {.inline.} = proc newTransNode(a: PNode): PNode {.inline.} =
result = shallowCopy(a) result = shallowCopy(a)