From 226595515c25785eaf078834dfb6f0ac337a5278 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 25 Oct 2020 08:50:47 +0100 Subject: explicit ID generation for easier IC (#15559) * refactoring: idents don't need inheritance * refactoring: adding an IdGenerator (part 1) * refactoring: adding an IdGenerator (part 2) * refactoring: adding an IdGenerator (part 3) * refactoring: adding an IdGenerator (part 4) * refactoring: adding an IdGenerator (part 5) * refactoring: adding an IdGenerator (part 5) * IdGenerator must be a ref type; hello world works again * make bootstrapping work again * progress: add back the 'exactReplica' ideas * added back the missing exactReplica hacks * make tcompilerapi work again * make important packages green * attempt to fix the build for 32 bit machines (probably need a better solution here) --- compiler/modulegraphs.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'compiler/modulegraphs.nim') diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim index da2a222a4..9e7a487cf 100644 --- a/compiler/modulegraphs.nim +++ b/compiler/modulegraphs.nim @@ -74,11 +74,13 @@ type globalDestructors*: seq[PNode] strongSemCheck*: proc (graph: ModuleGraph; owner: PSym; body: PNode) {.nimcall.} compatibleProps*: proc (graph: ModuleGraph; formal, actual: PType): bool {.nimcall.} + idgen*: IdGenerator TPassContext* = object of RootObj # the pass's context + idgen*: IdGenerator PPassContext* = ref TPassContext - TPassOpen* = proc (graph: ModuleGraph; module: PSym): PPassContext {.nimcall.} + TPassOpen* = proc (graph: ModuleGraph; module: PSym; idgen: IdGenerator): PPassContext {.nimcall.} TPassClose* = proc (graph: ModuleGraph; p: PPassContext, n: PNode): PNode {.nimcall.} TPassProcess* = proc (p: PPassContext, topLevelStmt: PNode): PNode {.nimcall.} @@ -165,12 +167,13 @@ proc stopCompile*(g: ModuleGraph): bool {.inline.} = result = g.doStopCompile != nil and g.doStopCompile() proc createMagic*(g: ModuleGraph; name: string, m: TMagic): PSym = - result = newSym(skProc, getIdent(g.cache, name), nil, unknownLineInfo, {}) + result = newSym(skProc, getIdent(g.cache, name), nextId(g.idgen), nil, unknownLineInfo, {}) result.magic = m result.flags = {sfNeverRaises} proc newModuleGraph*(cache: IdentCache; config: ConfigRef): ModuleGraph = result = ModuleGraph() + result.idgen = IdGenerator(module: -1'i32, item: 0'i32) initStrTable(result.packageSyms) result.deps = initIntSet() result.importDeps = initTable[FileIndex, seq[FileIndex]]() -- cgit 1.4.1-2-gfad0