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

@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
proc checkForSink*(config: ConfigRef; owner: PSym; arg: PNode) =
proc checkForSink*(config: ConfigRef; idgen: IdGenerator; owner: PSym; arg: PNode) =
#[ Patterns we seek to detect:
someLocation = p # ---> p: sink T
@ -32,7 +32,7 @@ proc checkForSink*(config: ConfigRef; owner: PSym; arg: PNode) =
if sfWasForwarded notin owner.flags:
let argType = arg.sym.typ
let sinkType = newType(tySink, owner)
let sinkType = newType(tySink, nextId(idgen), owner)
sinkType.size = argType.size
sinkType.align = argType.align
sinkType.paddingAtEnd = argType.paddingAtEnd
@ -52,18 +52,18 @@ proc checkForSink*(config: ConfigRef; owner: PSym; arg: PNode) =
#echo config $ arg.info, " candidate for a sink parameter here"
of nkStmtList, nkStmtListExpr, nkBlockStmt, nkBlockExpr:
if not isEmptyType(arg.typ):
checkForSink(config, owner, arg.lastSon)
checkForSink(config, idgen, owner, arg.lastSon)
of nkIfStmt, nkIfExpr, nkWhen:
for branch in arg:
let value = branch.lastSon
if not isEmptyType(value.typ):
checkForSink(config, owner, value)
checkForSink(config, idgen, owner, value)
of nkCaseStmt:
for i in 1..<arg.len:
let value = arg[i].lastSon
if not isEmptyType(value.typ):
checkForSink(config, owner, value)
checkForSink(config, idgen, owner, value)
of nkTryStmt:
checkForSink(config, owner, arg[0])
checkForSink(config, idgen, owner, arg[0])
else:
discard "nothing to do"