store full definition AST for consts, fix noRewrite (#20115)

* continue #9582 for consts, close #9331, fix #20114

also move extractPragma to ast to pave the way for things like {.strdefine: "abc".} etc

* changelog correctly

* fix jsgen

* update tgetimpl

* fix sighashes

* fix #19766, add comment about postfix

* fix noRewrite LOL

refs #16620

* fix changelog

* fix destructors
This commit is contained in:
metagn 2022-09-28 16:05:01 +03:00 • committed by GitHub
commit de4b0346bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 176 additions and 65 deletions

View file

@ -184,10 +184,12 @@ proc transformVarSection(c: PTransf, v: PNode): PNode =
if it.kind == nkCommentStmt:
result[i] = it
elif it.kind == nkIdentDefs:
if it[0].kind == nkSym:
var vn = it[0]
if vn.kind == nkPragmaExpr: vn = vn[0]
if vn.kind == nkSym:
internalAssert(c.graph.config, it.len == 3)
let x = freshVar(c, it[0].sym)
idNodeTablePut(c.transCon.mapping, it[0].sym, x)
let x = freshVar(c, vn.sym)
idNodeTablePut(c.transCon.mapping, vn.sym, x)
var defs = newTransNode(nkIdentDefs, it.info, 3)
if importantComments(c.graph.config):
# keep documentation information:
@ -1036,7 +1038,7 @@ proc transform(c: PTransf, n: PNode): PNode =
result = transformAsgn(c, n)
of nkIdentDefs, nkConstDef:
result = newTransNode(n)
result[0] = transform(c, n[0])
result[0] = transform(c, skipPragmaExpr(n[0]))
# Skip the second son since it only contains an unsemanticized copy of the
# variable type used by docgen
let last = n.len-1