Skip to content

Commit

Permalink
IC: bugfix (nim-lang#17533)
Browse files Browse the repository at this point in the history
* cleanups
* IC: bugfix
  • Loading branch information
Araq authored Mar 27, 2021
1 parent 30959e2 commit cf5ce76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 5 additions & 2 deletions compiler/ic/ic.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type

PackedModule* = object ## the parts of a PackedEncoder that are part of the .rod file
definedSymbols: string
moduleFlags: TSymFlags
includes: seq[(LitId, string)] # first entry is the module filename itself
imports: seq[LitId] # the modules this module depends on
toReplay: PackedTree # pragmas and VM specific state to replay.
Expand Down Expand Up @@ -139,6 +140,7 @@ proc initEncoder*(c: var PackedEncoder; m: var PackedModule; moduleSym: PSym; co
m.sh = Shared()
c.thisModule = moduleSym.itemId.module
c.config = config
m.moduleFlags = moduleSym.flags
m.bodies = newTreeFrom(m.topLevel)
m.toReplay = newTreeFrom(m.topLevel)

Expand Down Expand Up @@ -511,6 +513,7 @@ proc loadRodFile*(filename: AbsoluteFile; m: var PackedModule; config: ConfigRef
f.loadSection configSection

f.loadPrim m.definedSymbols
f.loadPrim m.moduleFlags
f.loadPrim m.cfg

if f.err == ok and not configIdentical(m, config) and not ignoreConfig:
Expand Down Expand Up @@ -581,6 +584,7 @@ proc saveRodFile*(filename: AbsoluteFile; encoder: var PackedEncoder; m: var Pac
f.storeHeader()
f.storeSection configSection
f.storePrim m.definedSymbols
f.storePrim m.moduleFlags
f.storePrim m.cfg

template storeSeqSection(section, data) {.dirty.} =
Expand Down Expand Up @@ -909,8 +913,7 @@ proc setupLookupTables(g: var PackedModuleGraph; conf: ConfigRef; cache: IdentCa
info: newLineInfo(fileIdx, 1, 1),
position: int(fileIdx))
m.module.owner = newPackage(conf, cache, fileIdx)
if fileIdx == conf.projectMainIdx2:
m.module.flags.incl sfMainModule
m.module.flags = m.fromDisk.moduleFlags

proc loadToReplayNodes(g: var PackedModuleGraph; conf: ConfigRef; cache: IdentCache;
fileIdx: FileIndex; m: var LoadedModule) =
Expand Down
6 changes: 2 additions & 4 deletions compiler/transf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ proc transformBody*(g: ModuleGraph; idgen: IdGenerator, prc: PSym, cache: bool):
import closureiters, lambdalifting

type
PTransCon = ref TTransCon
TTransCon{.final.} = object # part of TContext; stackable
PTransCon = ref object # part of TContext; stackable
mapping: TIdNodeTable # mapping from symbols to nodes
owner: PSym # current owner
forStmt: PNode # current for stmt
Expand All @@ -40,7 +39,7 @@ type
# if we encounter the 2nd yield statement
next: PTransCon # for stacking

TTransfContext = object
PTransf = ref object
module: PSym
transCon: PTransCon # top of a TransCon stack
inlining: int # > 0 if we are in inlining context (copy vars)
Expand All @@ -49,7 +48,6 @@ type
deferDetected, tooEarly: bool
graph: ModuleGraph
idgen: IdGenerator
PTransf = ref TTransfContext

proc newTransNode(a: PNode): PNode {.inline.} =
result = shallowCopy(a)
Expand Down

0 comments on commit cf5ce76

Please sign in to comment.