Skip to content

Commit 7748987

Browse files
committed
saves/loads symbol magic, options and offset
1 parent 96ff1a8 commit 7748987

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

compiler/icnif/nifdecoder.nim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ proc fromNifSymDef(c: var DecodeContext; n: var Cursor): PSym =
9898
incExpect n, Ident
9999
let ident = c.graph.cache.getIdent(pool.strings[n.litId])
100100
incExpect n, {Ident, DotToken}
101+
let magic = if n.kind == Ident: pool.strings[n.litId].parseMagic else: mNone
102+
incExpect n, {Ident, DotToken}
101103
let flags = if n.kind == Ident: pool.strings[n.litId].parseSymFlags else: {}
104+
incExpect n, {Ident, DotToken}
105+
let options = if n.kind == Ident: pool.strings[n.litId].parseOptions else: {}
106+
incExpect n, IntLit
107+
let offset = pool.integers[n.intId].int32
102108
incExpect n, IntLit
103109
let disamb = pool.integers[n.intId].int32
104110
incExpect n, ParLe
@@ -107,9 +113,12 @@ proc fromNifSymDef(c: var DecodeContext; n: var Cursor): PSym =
107113

108114
result = PSym(itemId: ItemId(module: itemIdModule.int32, item: itemId),
109115
kind: kind,
116+
magic: magic,
110117
name: ident,
111118
info: info,
112119
flags: flags,
120+
options: options,
121+
offset: offset,
113122
disamb: disamb)
114123

115124
# PNode, PSym or PType type fields in PSym can have cycles.

compiler/icnif/nifencoder.nim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ proc toNifDef(c: var EncodeContext; sym: PSym) =
5959
c.toNifModuleId sym.itemId.module
6060
c.dest.addIntLit sym.itemId.item
6161
c.dest.addIdent sym.name.s
62+
if sym.magic == mNone:
63+
c.dest.addDotToken
64+
else:
65+
c.dest.addIdent toNifTag(sym.magic)
6266
c.dest.writeFlags sym.flags
67+
c.dest.writeFlags sym.options
68+
c.dest.addIntLit sym.offset
6369
c.dest.addIntLit sym.disamb
6470
c.dest.buildTree sym.kind.toNifTag:
6571
case sym.kind

tests/icnif/tencode_node2node.nim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,23 @@ proc eql(x, y: PSym; c: var EqlContext): bool =
143143
elif x.kind != y.kind:
144144
echo "symbol kind mismatch: ", x.kind, "/", y.kind
145145
result = false
146+
elif x.magic != y.magic:
147+
echo "symbol magic mismatch: ", x.magic, "/", y.magic
148+
result = false
146149
elif not eql(x.info, y.info, c):
147150
echo "symbol line info mismatch"
148151
result = false
149152
elif x.flags != y.flags:
150153
echo "symbol flag mismatch: ", x.flags, "/", y.flags
151154
result = false
155+
elif x.options != y.options:
156+
echo "symbol options mismatch: ", x.options, "/", y.options
157+
result = false
152158
elif not eqlSymPos(x, y, c):
153159
result = false
160+
elif x.offset != y.offset:
161+
echo "symbol offset mismatch: ", x.offset, "/", y.offset
162+
result = false
154163
elif x.disamb != y.disamb:
155164
echo "symbol disamb mismatch: ", x.disamb, "/", y.disamb
156165
result = false

0 commit comments

Comments
 (0)