saves/loads flags of nkIdent node

This commit is contained in:
demotomohiro
2025-11-01 10:14:38 +09:00
parent 9f73412e93
commit f3178e4515
3 changed files with 10 additions and 9 deletions

View File

@@ -266,11 +266,14 @@ proc fromNif(c: var DecodeContext; n: var Cursor): PNode =
result.flags = flags
skipParRi n
of nkIdent:
inc n
let info = c.fromNifLineInfo(n)
incExpect n, {DotToken, Ident}
let flags = fromNifNodeFlags n
let typ = c.fromNifType n
expect n, Ident
result = newIdentNode(c.graph.cache.getIdent(pool.strings[n.litId]), c.fromNifLineInfo(n))
result = newIdentNode(c.graph.cache.getIdent(pool.strings[n.litId]), info)
inc n
result.flags = flags
result.typ = typ
skipParRi n
of nkSym:

View File

@@ -147,11 +147,9 @@ proc toNif(c: var EncodeContext; n: PNode) =
c.dest.writeNodeFlags(n.flags)
c.dest.addParRi
of nkIdent:
let info = c.toNif n.info
c.dest.addParLe pool.tags.getOrIncl(toNifTag(nkIdent)), info
c.toNif n.typ
c.dest.addIdent n.ident.s
c.dest.addParRi
# nkIdent uses flags and typ when it is a generic parameter
c.withNode n:
c.dest.addIdent n.ident.s
of nkSym:
when false:
echo "nkSym: ", n.sym.name.s

View File

@@ -257,7 +257,7 @@ proc eql(x, y: PNode; c: var EqlContext): bool =
echo "node kind mismatch: ", x.kind, "/", y.kind
result = false
elif x.flags != y.flags:
echo "node flag mismatch: ", x.flags, "/", y.flags
echo "node flag mismatch: ", x.flags, "/", y.flags, " at ", `$`(c.confX, x.info)
debug(x)
debug(y)
result = false
@@ -338,7 +338,7 @@ proc testNifEncDec(graph: ModuleGraph; src: string) =
let n2 = loadNifFromBuffer(nif, graphForLoad)
#debug(n2)
var c = EqlContext(confX: graph.config, confY: graphForLoad.config)
assert eql(n, n2, c)
assert eql(n, n2, c), "test failed: " & $fullPath
var conf = newConfigRefForTest()
var cache = newIdentCache()