QuickBEAM.Bytecode (QuickBEAM v0.10.6)

Copy Markdown View Source

Disassembled QuickJS bytecode.

Returned by QuickBEAM.disasm/1 and QuickBEAM.disasm/2. Contains the function metadata, local/closure variable definitions, constant pool, and the decoded opcode stream.

Opcodes

Each opcode is a tuple of {offset, name, ...operands}:

{0, :push_i32, 40}
{5, :push_i32, 2}
{10, :add}
{11, :return}

Labels in branch instructions are resolved to absolute byte offsets. Local/arg/closure-var operands use numeric indices matching the locals, args, and closure_vars lists.

Constant pool

Nested functions appear as %QuickBEAM.Bytecode{} structs in the cpool list. Other constant pool entries are plain Elixir terms.

Summary

Types

closure_var()

@type closure_var() :: %{
  name: String.t(),
  kind: String.t(),
  type: String.t(),
  index: integer()
}

local()

@type local() :: %{name: String.t(), kind: String.t()}

t()

@type t() :: %QuickBEAM.Bytecode{
  arg_count: integer(),
  args: [String.t()],
  byte_code_len: integer(),
  closure_vars: [closure_var()],
  column: integer() | nil,
  cpool: [t() | term()],
  defined_arg_count: integer(),
  filename: String.t() | nil,
  is_strict: boolean(),
  kind: String.t(),
  line: integer() | nil,
  locals: [local()],
  name: String.t() | nil,
  opcodes: [tuple()],
  source: String.t() | nil,
  stack_size: integer(),
  var_count: integer()
}