bro/engine/sourcemap

Types

MapSegment = object
  genLine*: int
  genCol*: int
  file*: string
  line*: int
  col*: int
A single generated->original mapping.
SourceInfo = object
  segments*: seq[MapSegment]
  contents*: Table[string, string]
Accumulator for mappings + optional embedded source contents.
SourceMap = object
  version*: int
  file*: string
  sources*: seq[string]
  sourcesContent*: seq[string]
  names*: seq[string]
  mappings*: string
A v3 source map ready to be serialized to JSON.

Procs

proc addContent(info: var SourceInfo; file, content: string) {....raises: [],
    tags: [], forbids: [].}
Attach the raw source content for file so it can be embedded into sourcesContent.
proc addSegment(info: var SourceInfo; genLine, genCol: int; file: string;
                line, col: int) {....raises: [], tags: [], forbids: [].}
Record a single generated->original mapping.
proc encode(values: seq[int]): string {....raises: [], tags: [], forbids: [].}
Encodes a series of integers into a VLQ base64 encoded string
proc initSourceInfo(): SourceInfo {....raises: [], tags: [], forbids: [].}
proc toSourceMap(info: SourceInfo; outputFile: string): SourceMap {.
    ...raises: [KeyError], tags: [], forbids: [].}
Convert the accumulated mappings into a v3 SourceMap object.