compiler/mir/sourcemaps

  Source   Edit

This module implements a simple database for mapping MIR SourceIds to non-critical meta-data (currently only a PNode).

Information about which PNode a MirNode originated from is needed for source-code position information and other reporting-related tasks.

The meta-data doesn't affect the semantics of MIR code and it's thus stored and implemented separately. This allows for using a different way of storing such information without requiring adjustments to the core MIR data structures.

Types

SourceMap = object
  source: Store[SourceId, PNode] ## stores the ``PNode``s used as the source/origin information
  
Associates meta-data (currently only PNode) with SourceIds. The map is meant to be used together with MirTrees.   Source   Edit

Procs

func `[]`(m: SourceMap; i: SourceId): PNode {.inline, ...raises: [], tags: [].}
  Source   Edit
func add(m: var SourceMap; origin: PNode): SourceId {.inline, ...raises: [],
    tags: [].}
Adds origin to the database and returns the ID through which it can be looked up again.   Source   Edit
func merge(dst: var SourceMap; tree: var MirTree; src: sink SourceMap) {.
    ...raises: [], tags: [].}
Merges all entries from src into dst and updates all references in tree.   Source   Edit