lineinfos
nimony/src/lib/lineinfos.nim
type PackedLineInfo = distinct uint32type FileId = distinct uint32func ==(a: FileId; b: FileId): boolfunc ==(a: PackedLineInfo; b: PackedLineInfo): boolfunc hash(a: FileId): uint64func hash(a: PackedLineInfo): uint64type LineInfoUnpacked = object file: FileId line: int32 col: int32 comment: uint32
type LineInfoManager = object aside: seq
const NoLineInfo: PackedLineInfoconst NoFile: FileIdproc isValid(x: PackedLineInfo): boolproc isValid(x: FileId): boolproc pack(m: var LineInfoManager; file: FileId; line: int32; col: int32): PackedLineInfoproc packWithComment(m: var LineInfoManager; file: FileId; line: int32; col: int32; comment: uint32): PackedLineInfoLike
packbut also attaches a#comment#to the position. Comment-bearing infos always use the aside path (the inline encoding has no room for a comment id).comment == 0means no comment — callers should use the plainpackin that case.proc isPayload(i: PackedLineInfo): boolproc unpack(m: LineInfoManager; info: PackedLineInfo): LineInfoUnpackedproc stripComment(m: var LineInfoManager; info: PackedLineInfo): PackedLineInfoReturn the same file/line/col but with no comment attached. Useful when propagating a parent's info to children for relative-position math: comments are decorations on a single token, not inherited by descendants.
proc getPayload(i: PackedLineInfo): uint32proc toPayload(val: uint32): PackedLineInfoproc getFileId(m: LineInfoManager; i: PackedLineInfo): FileIdproc memSize(m: LineInfoManager): int64