itemids

Source   Edit  

ItemId is the identity of a symbol or type: a (module, item) pair.

The fields are private on purpose: the module half reserves bit 30 as the "backend minted" marker, so all construction and inspection has to go through this module's API and the marker bit can never leak into module indexing or arithmetic.

Three id spaces coexist per module:

  • Semantic-phase and NIF-loader ids: itemId(module, item) with item > 0.
  • Backend-minted ids (IC codegen, nim nifc: transf labels and temps, lifted hooks): backendItemId sets BackendModuleBit, so these can never compare equal to a loader id even though both counters mint the same small item range in one process. They never cross a process boundary and must never be written to a NIF file.
  • Derived env/tuple-field ids (lowerings.addField): the source local's id with item negated. derivedFieldId preserves the backend marker, keeping the derivation collision-free for both id spaces above.

Types

ItemId = object
Source   Edit  

Consts

PackageModuleId = -3'i32
Source   Edit  

Procs

proc `$`(x: ItemId): string {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc `==`(a, b: ItemId): bool {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc backendItemId(module, item: int32): ItemId {.inline, ...raises: [], tags: [],
    forbids: [].}
An id minted during IC codegen; distinct from every itemId of the same module so that the loader's stub counter and the backend's counter cannot collide in id-keyed tables. Source   Edit  
proc derivedFieldId(source: ItemId): ItemId {.inline, ...raises: [], tags: [],
    forbids: [].}
The id of the env/tuple field that lowerings.addField derives for a captured local: item negated, module bits (including the backend marker) preserved. Source   Edit  
proc hash(x: ItemId): Hash {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc isBackendMinted(x: ItemId): bool {.inline, ...raises: [], tags: [],
                                        forbids: [].}
Source   Edit  
proc item(x: ItemId): int32 {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc itemId(module, item: int32): ItemId {.inline, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc matchesDerivedFieldId(field, source: ItemId): bool {.inline, ...raises: [],
    tags: [], forbids: [].}
Does field carry the id derivedFieldId would derive for source? source may itself already be the derived field id. Source   Edit  
proc module(x: ItemId): int32 {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc toId(a: ItemId): int {.inline, ...raises: [], tags: [], forbids: [].}
Packs an ItemId into a single int. Uses the raw module bits so the backend marker keeps the two id spaces disjoint (bit 30 shifts to bit 54; like the module/item split itself this needs a 64-bit int). Source   Edit