compiler/vm/vmutils

  Source   Edit

This module contains some utility procedures for inspecting VM-related data.

The VM doesn't depend on the procedures here in order to function - they are only meant as a logging and debugging aid.

Types

DebugVmCodeEntry = object
  isTarget*: bool
  info*: TLineInfo
  pc*: int
  idx*: int
  case opc*: TOpcode
  of opcConv, opcCast:
      types*: tuple[tfrom, tto: PType]

  of opcLdConst:
      ast*: PNode

  else:
      nil

  ra*: int
  rb*: int
  rc*: int
  Source   Edit

Procs

proc codeListing(c: TCtx; start = 0; last = -1): seq[DebugVmCodeEntry] {.
    ...raises: [], tags: [].}
Produces a listing of the instructions in c that are located in the instruction range start..last. If last < 0, then all instructions after position start are included in the listing. The instructions are ordered by their position   Source   Edit
proc renderCodeListing(config: ConfigRef; sym: PSym;
                       entries: seq[DebugVmCodeEntry]): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
Renders the code listing entries to text. sym is an optional symbol that, if provided, is used for providing additional context.   Source   Edit