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)
This commit is contained in:
Andreas Rumpf 2020-10-25 08:50:47 +01:00 • committed by GitHub
commit 226595515c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
67 changed files with 853 additions and 903 deletions

View file

@ -279,7 +279,7 @@ proc replaceTypeVarsS(cl: var TReplTypeVars, s: PSym): PSym =
var g: G[string]
]#
result = copySym(s)
result = copySym(s, nextId cl.c.idgen)
incl(result.flags, sfFromGeneric)
#idTablePut(cl.symMap, s, result)
result.owner = s.owner
@ -302,7 +302,12 @@ proc lookupTypeVar(cl: var TReplTypeVars, t: PType): PType =
proc instCopyType*(cl: var TReplTypeVars, t: PType): PType =
# XXX: relying on allowMetaTypes is a kludge
result = copyType(t, t.owner, cl.allowMetaTypes)
if cl.allowMetaTypes:
result = t.exactReplica
else:
result = copyType(t, nextId(cl.c.idgen), t.owner)
#cl.typeMap.topLayer.idTablePut(result, t)
if cl.allowMetaTypes: return
result.flags.incl tfFromGeneric
if not (t.kind in tyMetaTypes or
@ -355,7 +360,7 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
else:
header = instCopyType(cl, t)
result = newType(tyGenericInst, t[0].owner)
result = newType(tyGenericInst, nextId(cl.c.idgen), t[0].owner)
result.flags = header.flags
# be careful not to propagate unnecessary flags here (don't use rawAddSon)
result.sons = @[header[0]]
@ -459,11 +464,11 @@ proc eraseVoidParams*(t: PType) =
setLen t.n.sons, pos
break
proc skipIntLiteralParams*(t: PType) =
proc skipIntLiteralParams*(t: PType; idgen: IdGenerator) =
for i in 0..<t.len:
let p = t[i]
if p == nil: continue
let skipped = p.skipIntLit
let skipped = p.skipIntLit(idgen)
if skipped != p:
t[i] = skipped
if i > 0: t.n[i].sym.typ = skipped
@ -553,7 +558,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
result = n.typ
of tyInt, tyFloat:
result = skipIntLit(t)
result = skipIntLit(t, cl.c.idgen)
of tyTypeDesc:
let lookup = cl.typeMap.lookup(t)
@ -617,7 +622,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
of tyProc:
eraseVoidParams(result)
skipIntLiteralParams(result)
skipIntLiteralParams(result, cl.c.idgen)
of tyRange:
result[0] = result[0].skipTypes({tyStatic, tyDistinct})