compiler/mir/datatables

  Source   Edit

Implements a bi-directional table that associates constant data (represented by a subset of the MIR) with a DataId and vice versa.

Types

DataTable = object
  vals: Store[DataId, ConstrTree]
  keys: seq[uint32] ## indexed by ``hash(ConstrTree)``, using an open-addressing scheme.
                    ## Empty slots have value '0'. Subtracting one from the value in a non-
                    ## empty slot yields a ``DataId``
  
A bi-directional table that associates constant expressions with an ID.   Source   Edit

Procs

func `[]`(t: DataTable; id: DataId): lent ConstrTree {.inline, ...raises: [],
    tags: [].}
  Source   Edit
func checkpoint(t: DataTable): Checkpoint {.inline, ...raises: [], tags: [].}
  Source   Edit
proc getOrPut(t: var DataTable; tree: sink MirTree): DataId {....raises: [],
    tags: [].}
Adds tree to t and returns the ID the tree can be queried with later. If the tree already exists in the table, only the ID is returned.   Source   Edit
proc len(t: DataTable): int {.inline, ...raises: [], tags: [].}
The number of items in t.   Source   Edit
proc rewind(t: var DataTable; p: Checkpoint) {....raises: [], tags: [].}
  Source   Edit

Iterators

iterator pairs(t: DataTable): (DataId, lent ConstrTree) {....raises: [], tags: [].}
  Source   Edit
iterator since(t: DataTable; p: Checkpoint): (DataId, lent ConstrTree) {.
    ...raises: [], tags: [].}
Returns all entries added since p was created.   Source   Edit