mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-18 18:47:16 +00:00
saves/loads symbol magic, options and offset
This commit is contained in:
@@ -98,7 +98,13 @@ proc fromNifSymDef(c: var DecodeContext; n: var Cursor): PSym =
|
||||
incExpect n, Ident
|
||||
let ident = c.graph.cache.getIdent(pool.strings[n.litId])
|
||||
incExpect n, {Ident, DotToken}
|
||||
let magic = if n.kind == Ident: pool.strings[n.litId].parseMagic else: mNone
|
||||
incExpect n, {Ident, DotToken}
|
||||
let flags = if n.kind == Ident: pool.strings[n.litId].parseSymFlags else: {}
|
||||
incExpect n, {Ident, DotToken}
|
||||
let options = if n.kind == Ident: pool.strings[n.litId].parseOptions else: {}
|
||||
incExpect n, IntLit
|
||||
let offset = pool.integers[n.intId].int32
|
||||
incExpect n, IntLit
|
||||
let disamb = pool.integers[n.intId].int32
|
||||
incExpect n, ParLe
|
||||
@@ -107,9 +113,12 @@ proc fromNifSymDef(c: var DecodeContext; n: var Cursor): PSym =
|
||||
|
||||
result = PSym(itemId: ItemId(module: itemIdModule.int32, item: itemId),
|
||||
kind: kind,
|
||||
magic: magic,
|
||||
name: ident,
|
||||
info: info,
|
||||
flags: flags,
|
||||
options: options,
|
||||
offset: offset,
|
||||
disamb: disamb)
|
||||
|
||||
# PNode, PSym or PType type fields in PSym can have cycles.
|
||||
|
||||
@@ -59,7 +59,13 @@ proc toNifDef(c: var EncodeContext; sym: PSym) =
|
||||
c.toNifModuleId sym.itemId.module
|
||||
c.dest.addIntLit sym.itemId.item
|
||||
c.dest.addIdent sym.name.s
|
||||
if sym.magic == mNone:
|
||||
c.dest.addDotToken
|
||||
else:
|
||||
c.dest.addIdent toNifTag(sym.magic)
|
||||
c.dest.writeFlags sym.flags
|
||||
c.dest.writeFlags sym.options
|
||||
c.dest.addIntLit sym.offset
|
||||
c.dest.addIntLit sym.disamb
|
||||
c.dest.buildTree sym.kind.toNifTag:
|
||||
case sym.kind
|
||||
|
||||
@@ -143,14 +143,23 @@ proc eql(x, y: PSym; c: var EqlContext): bool =
|
||||
elif x.kind != y.kind:
|
||||
echo "symbol kind mismatch: ", x.kind, "/", y.kind
|
||||
result = false
|
||||
elif x.magic != y.magic:
|
||||
echo "symbol magic mismatch: ", x.magic, "/", y.magic
|
||||
result = false
|
||||
elif not eql(x.info, y.info, c):
|
||||
echo "symbol line info mismatch"
|
||||
result = false
|
||||
elif x.flags != y.flags:
|
||||
echo "symbol flag mismatch: ", x.flags, "/", y.flags
|
||||
result = false
|
||||
elif x.options != y.options:
|
||||
echo "symbol options mismatch: ", x.options, "/", y.options
|
||||
result = false
|
||||
elif not eqlSymPos(x, y, c):
|
||||
result = false
|
||||
elif x.offset != y.offset:
|
||||
echo "symbol offset mismatch: ", x.offset, "/", y.offset
|
||||
result = false
|
||||
elif x.disamb != y.disamb:
|
||||
echo "symbol disamb mismatch: ", x.disamb, "/", y.disamb
|
||||
result = false
|
||||
|
||||
Reference in New Issue
Block a user