gwr/execution/stack

Types

Activation frames carry the return arity of the respective function, hold the values of its locals (including arguments) in the order corresponding to their static local indices, and a reference to the function’s own module instance:

https://webassembly.github.io/spec/core/exec/runtime.html#activation-frames

pub type ActivationFrame {
  ActivationFrame(arity: Int, framestate: FrameState)
}

Constructors

  • ActivationFrame(arity: Int, framestate: FrameState)

https://webassembly.github.io/spec/core/exec/runtime.html#activation-frames

pub type FrameState {
  FrameState(
    locals: List(runtime.Value),
    module_instance: runtime.ModuleInstance,
  )
}

Constructors

  • FrameState(
      locals: List(runtime.Value),
      module_instance: runtime.ModuleInstance,
    )

Labels carry an argument arity and their associated branch target, which is expressed syntactically as an instruction sequence:

https://webassembly.github.io/spec/core/exec/runtime.html#labels

pub type Label {
  Label(arity: Int, target: List(instruction.Instruction))
}

Constructors

  • Label(arity: Int, target: List(instruction.Instruction))

https://webassembly.github.io/spec/core/exec/runtime.html#stack

pub type Stack {
  Stack(entries: List(StackEntry))
}

Constructors

  • Stack(entries: List(StackEntry))

https://webassembly.github.io/spec/core/exec/runtime.html#stack

pub type StackEntry {
  ValueEntry(runtime.Value)
  LabelEntry(Label)
  ActivationEntry(ActivationFrame)
}

Constructors

  • ValueEntry(runtime.Value)
  • LabelEntry(Label)
  • ActivationEntry(ActivationFrame)

Functions

pub fn create() -> Stack
pub fn length(from stack: Stack) -> Int
pub fn peek(from stack: Stack) -> Option(StackEntry)
pub fn pop(from stack: Stack) -> #(Stack, Option(StackEntry))
pub fn pop_repeat(
  from stack: Stack,
  up_to count: Int,
) -> #(Stack, List(Option(StackEntry)))
pub fn push(to stack: Stack, push new_entry: StackEntry) -> Stack
Search Document