compiler/mir/mirbodies

  Source   Edit

Implements the MirBody type and basic routines for querying and modifying it.

Types

Local = object
  typ*: TypeId               ## type of the local
  alignment*: uint32         ## alignment of the location, measured in bytes. 0 means "use default"
  flags*: TSymFlags
  isImmutable*: bool ## whether the local was originally defined with ``let``. Used for
                     ## optimization purposes
  name*: PIdent              ## either the user-defined name or 'nil'
  
Static information about a local location ('let' or 'var'). Not modified after initialization.   Source   Edit
Locals = Store[LocalId, Local]
  Source   Edit
MirBody = object
  locals*: Locals            ## all locals part of the body
  nextLabel*: LabelId ## the ID to use for a new label. Incremented when allocating a new
                      ## label
  source*: SourceMap
  code*: MirTree
A MirBody represents a self-contained piece of MIR code. This can either be:
  • the full body of a procedure
  • the partial body a procedure
  • a standalone statement/expression (currently supported for compile time code execution)

In each case, MirBody stores all the local data referenced and needed by the body's MIR code. It also store additional information associated with a body, such as how far the lowering is along.

  Source   Edit

Consts

resultId = 0'u32
the ID of the result variable. A slot for the result variable is always reserved, even if there is no result variable for a body   Source   Edit

Procs

func `[]`(body: MirBody; id: LocalId): lent Local {.inline, ...raises: [], tags: [].}
  Source   Edit
func `[]`(body: MirBody; n: NodePosition): lent MirNode {.inline, ...raises: [],
    tags: [].}
  Source   Edit
func sourceFor(body: MirBody; n: NodePosition): PNode {.inline, ...raises: [],
    tags: [].}
  Source   Edit