W3cubDocs

/Nim

ic/packed_ast

Source Edit

Packed AST representation, mostly based on a seq of nodes. For IC support. Far future: Rewrite the compiler passes to use this representation directly in all the transformations, it is superior.

Imports

bitabs, rodfiles, ../ast, ../options, iclineinfos

Types

ModuleId = distinct int32
Source Edit
NodeId = distinct int32
Source Edit
NodePos = distinct int
Source Edit
PackedInstantiation = object
  key*, sym*: PackedItemId
  concreteTypes*: seq[PackedItemId]
Source Edit
PackedItemId = object
  module*: LitId
  item*: int32
Source Edit
PackedLib = object
  kind*: TLibKind
  generated*: bool
  isOverridden*: bool
  name*: LitId
  path*: NodeId
Source Edit
PackedNode = object
  info*: PackedLineInfo
Source Edit
PackedSym = object
  id*: int32
  kind*: TSymKind
  name*: LitId
  typ*: PackedItemId
  flags*: TSymFlags
  magic*: TMagic
  info*: PackedLineInfo
  ast*: NodeId
  owner*: PackedItemId
  guard*: PackedItemId
  bitsize*: int
  alignment*: int
  options*: TOptions
  position*: int
  offset*: int32
  disamb*: int32
  externalName*: LitId
  locFlags*: TLocFlags
  annex*: PackedLib
  when hasFFI:
    cname*: LitId
  constraint*: NodeId
  instantiatedFrom*: PackedItemId
Source Edit
PackedTree = object
usually represents a full Nim module Source Edit
PackedType = object
  id*: int32
  kind*: TTypeKind
  callConv*: TCallingConvention
  flags*: TTypeFlags
  types*: seq[PackedItemId]
  n*: NodeId
  sym*: PackedItemId
  owner*: PackedItemId
  size*: BiggestInt
  align*: int16
  paddingAtEnd*: int16
  typeInst*: PackedItemId
  nonUniqueId*: int32
Source Edit
SymId = distinct int32
Source Edit

Consts

directIntLit = nkNone
Source Edit
emptyNodeId = -1'i32
Source Edit
externIntLit = {nkCharLit, nkIntLit, nkInt8Lit, nkInt16Lit, nkInt32Lit,
                nkInt64Lit, nkUIntLit, nkUInt8Lit, nkUInt16Lit, nkUInt32Lit,
                nkUInt64Lit}
Source Edit
externSIntLit = {nkIntLit, nkInt8Lit, nkInt16Lit, nkInt32Lit, nkInt64Lit}
Source Edit
externUIntLit = {nkUIntLit, nkUInt8Lit, nkUInt16Lit, nkUInt32Lit, nkUInt64Lit}
Source Edit
nilItemId = (module: 0'u, item: 0)
Source Edit

Procs

proc `==`(a, b: NodeId): bool {.borrow, ...raises: [], tags: [], forbids: [].}
Source Edit
proc `==`(a, b: NodePos): bool {.borrow, ...raises: [], tags: [], forbids: [].}
Source Edit
proc `==`(a, b: SymId): bool {.borrow, ...raises: [], tags: [], forbids: [].}
Source Edit
proc `[]`(tree: PackedTree; i: NodePos): lent PackedNode {.inline, ...raises: [],
    tags: [], forbids: [].}
Source Edit
proc addIdent(tree: var PackedTree; s: LitId; info: PackedLineInfo) {.
    ...raises: [], tags: [], forbids: [].}
Source Edit
proc addNode(t: var PackedTree; kind: TNodeKind; operand: int32;
             typeId: PackedItemId = nilItemId; info: PackedLineInfo;
             flags: TNodeFlags = {}) {....raises: [], tags: [], forbids: [].}
Source Edit
proc addSym(tree: var PackedTree; s: int32; info: PackedLineInfo) {....raises: [],
    tags: [], forbids: [].}
Source Edit
proc addSymDef(tree: var PackedTree; s: SymId; info: PackedLineInfo) {.
    ...raises: [], tags: [], forbids: [].}
Source Edit
proc findFlags(tree: PackedTree; n: NodePos): TNodeFlags {....raises: [], tags: [],
    forbids: [].}
Source Edit
proc findType(tree: PackedTree; n: NodePos): PackedItemId {....raises: [],
    tags: [], forbids: [].}
Source Edit
proc firstSon(n: NodePos): NodePos {.inline, ...raises: [], tags: [], forbids: [].}
Source Edit
proc firstSon(tree: PackedTree; n: NodePos): NodePos {.inline, ...raises: [],
    tags: [], forbids: [].}
Source Edit
proc getNodeId(tree: PackedTree): NodeId {.inline, ...raises: [], tags: [],
    forbids: [].}
Source Edit
proc hasAtLeastXsons(tree: PackedTree; n: NodePos; x: int): bool {....raises: [],
    tags: [], forbids: [].}
Source Edit
proc hash(a: SymId): Hash {.borrow, ...raises: [], tags: [], forbids: [].}
Source Edit
proc hasXsons(tree: PackedTree; n: NodePos; x: int): bool {....raises: [],
    tags: [], forbids: [].}
Source Edit
proc info(tree: PackedTree; n: NodePos): PackedLineInfo {.inline, ...raises: [],
    tags: [], forbids: [].}
Source Edit
proc isAtom(tree: PackedTree; pos: int): bool {.inline, ...raises: [], tags: [],
    forbids: [].}
Source Edit
proc ithSon(tree: PackedTree; n: NodePos; i: int): NodePos {....raises: [],
    tags: [], forbids: [].}
Source Edit
proc kind(tree: PackedTree; n: NodePos): TNodeKind {.inline, ...raises: [],
    tags: [], forbids: [].}
Source Edit
proc len(tree: PackedTree): int {.inline, ...raises: [], tags: [], forbids: [].}
Source Edit
proc litId(tree: PackedTree; n: NodePos): LitId {.inline, ...raises: [], tags: [],
    forbids: [].}
Source Edit
proc load(f: var RodFile; t: var PackedTree) {....raises: [IOError],
    tags: [ReadIOEffect], forbids: [].}
Source Edit
proc newTreeFrom(old: PackedTree): PackedTree {....raises: [], tags: [],
    forbids: [].}
Source Edit
proc patch(tree: var PackedTree; pos: PatchPos) {....raises: [], tags: [],
    forbids: [].}
Source Edit
proc prepare(dest: var PackedTree; source: PackedTree; sourcePos: NodePos): PatchPos {.
    ...raises: [], tags: [], forbids: [].}
Source Edit
proc prepare(tree: var PackedTree; kind: TNodeKind; flags: TNodeFlags;
             typeId: PackedItemId; info: PackedLineInfo): PatchPos {....raises: [],
    tags: [], forbids: [].}
Source Edit
proc sons2(tree: PackedTree; n: NodePos): (NodePos, NodePos) {....raises: [],
    tags: [], forbids: [].}
Source Edit
proc sons3(tree: PackedTree; n: NodePos): (NodePos, NodePos, NodePos) {.
    ...raises: [], tags: [], forbids: [].}
Source Edit
proc span(tree: PackedTree; pos: int): int {.inline, ...raises: [], tags: [],
    forbids: [].}
Source Edit
proc store(f: var RodFile; t: PackedTree) {....raises: [IOError],
    tags: [WriteIOEffect], forbids: [].}
Source Edit
proc toPackedItemId(item: int32): PackedItemId {.inline, ...raises: [], tags: [],
    forbids: [].}
Source Edit

Iterators

iterator allNodes(tree: PackedTree): NodePos {....raises: [], tags: [], forbids: [].}
Source Edit
iterator isons(dest: var PackedTree; tree: PackedTree; n: NodePos): (int,
    NodePos) {....raises: [], tags: [], forbids: [].}
Source Edit
iterator sons(dest: var PackedTree; tree: PackedTree; n: NodePos): NodePos {.
    ...raises: [], tags: [], forbids: [].}
Source Edit
iterator sonsFrom1(tree: PackedTree; n: NodePos): NodePos {....raises: [],
    tags: [], forbids: [].}
Source Edit
iterator sonsReadonly(tree: PackedTree; n: NodePos): NodePos {....raises: [],
    tags: [], forbids: [].}
Source Edit
iterator sonsWithoutLast2(tree: PackedTree; n: NodePos): NodePos {....raises: [],
    tags: [], forbids: [].}
Source Edit

Templates

template copyInto(dest, n, body)
Source Edit
template copyIntoKind(dest, kind, info, body)
Source Edit
template flags(n: NodePos): TNodeFlags
Source Edit
template info(n: NodePos): PackedLineInfo
Source Edit
template kind(n: NodePos): TNodeKind
Source Edit
template kind(n: PackedNode): TNodeKind
Source Edit
template litId(n: NodePos): LitId
Source Edit
template parent(n: NodePos): NodePos
Source Edit
template soperand(n: PackedNode): int32
Source Edit
template symId(n: NodePos): SymId
Source Edit
template typ(n: NodePos): PackedItemId
Source Edit
template typeId(n: PackedNode): PackedItemId
Source Edit
template uoperand(n: NodePos): uint32
Source Edit
template uoperand(n: PackedNode): uint32
Source Edit

© 2006–2024 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/compiler/ic/packed_ast.html