☰

# layeredtable

Theme:

- Index

Search:
Group by:
Source Edit

# Imports

ast, astalgo

# Types

    LayeredIdTable = LayeredIdTableObj

  Source Edit

    LayeredIdTableObj {.acyclic.} = object
      topLayer*: TypeMapping     ## the mappings on the current layer
      nextLayer*: ref LayeredIdTableObj ## the parent type binding context, possibly `nil`
      previousLen*: int ## total length of the bindings up to the parent layer,
                        ## used to track if new bindings were added

  stack of type binding contexts implemented as a linked list Source Edit

# Procs

    proc currentLen(pt: LayeredIdTable): int {....raises: [], tags: [], forbids: [].}

  the sum of the cached total binding count of the parents and the current binding count, just used to track if bindings were added Source Edit

    proc initLayeredTypeMap(pt: sink TypeMapping = initTypeMapping()): LayeredIdTable {.
        ...raises: [], tags: [], forbids: [].}

  Source Edit

    proc newTypeMapLayer(pt: LayeredIdTable): LayeredIdTable {....raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc setToPreviousLayer(pt: var LayeredIdTable) {.inline, ...raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc shallowCopy(pt: LayeredIdTable): LayeredIdTable {.inline, ...raises: [],
        tags: [], forbids: [].}

  copies only the type bindings of the current layer, but not any parent layers, useful for write-only bindings Source Edit

# Iterators

    iterator pairs(pt: LayeredIdTable): (ItemId, PType) {....raises: [], tags: [],
        forbids: [].}

  Source Edit

# Templates

    template lookup(typeMap: LayeredIdTableObj; key: PType): PType

  Source Edit

    template lookup(typeMap: ref LayeredIdTableObj; key: PType): PType

  recursively looks up binding of `key` in all parent layers Source Edit

    template put(typeMap: var LayeredIdTable; key, value: PType)

  binds `key` to `value` only in current layer Source Edit