wasm v0.1.0 Wasm View Source

Functions and types for WebAssembly. See the spec’s Binary and Structure sections.

To create a complete module see encode/1 and the associated term wasm_module/0.

Link to this section Summary

Types

Term of a code section item. Spec reference.

Term of a custom section item. Spec reference.

Term of a data section item. Spec reference.

Term of a WebAssembly element. Spec reference.

Term of an element type. Spec reference.

Term of a WebAssembly export. Spec reference.

Terms of floats. Spec reference.

Term of a WebAssembly function. Spec reference.

Term of a funcion type. Spec reference.

Term of a WebAssembly global. Spec reference.

Term of a global type. Spec reference.

Term of a WebAssembly import. Spec reference.

Term of a WebAssembly index. Spec reference.

Term of an instruction. Spec reference.

Terms of integers. Spec reference.

Term of memory limits. Spec reference.

Term of WebAssembly locals. Spec reference.

Term of a memory section item. Spec reference.

Term of a memory type. Spec reference.

Term of a WebAssembly module. Spec reference.

Term of a name. Spec reference.

Term of a result type. Spec reference.

Term of a module section. Spec reference.

Term of a start section item. Spec reference.

Term of a WebAssembly table. Spec reference.

Term of a table type. Spec reference.

Terms of a value type. Spec reference.

Functions

Encode a WebAssembly module. Spec reference.

Encode code section contents. Spec reference.

Encode custom section contents. Spec reference.

Encode data section contents. Spec reference.

Encode element section contents. Spec reference.

Encode a table element type. Spec reference.

Encode export section contents. Spec reference.

Encode 32-bit and 64-bit IEEE 754 LE floats. Spec reference.

Encode global section contents. Spec reference.

Encode import section contents. Spec reference.

Encode instructions. Spec reference.

Encode 32-bit or 64-bit integers that are signed or unsigned. Spec reference.

Encode memory section contents. Spec reference.

Encode a memory type. Spec reference.

Encode a module section. Spec reference.

Encode start section contents. Spec reference.

Encode table section contents. Spec reference.

Link to this section Types

Link to this type wasm_code() View Source
wasm_code() :: {:code, [wasm_func]}

Term of a code section item. Spec reference.

Link to this type wasm_custom() View Source
wasm_custom() :: {:custom, wasm_name, binary}

Term of a custom section item. Spec reference.

Link to this type wasm_data() View Source
wasm_data() :: {:data, [wasm_index], wasm_instr, binary}

Term of a data section item. Spec reference.

Link to this type wasm_elem() View Source
wasm_elem() :: {:elem, wasm_index, wasm_instr, [wasm_index]}

Term of a WebAssembly element. Spec reference.

Link to this type wasm_elem_type() View Source
wasm_elem_type() :: :elem_type

Term of an element type. Spec reference.

Link to this type wasm_export() View Source
wasm_export() :: {:export, wasm_name, wasm_index}

Term of a WebAssembly export. Spec reference.

Link to this type wasm_float() View Source
wasm_float() :: {:f32, float} | {:f64, float}

Terms of floats. Spec reference.

Link to this type wasm_func() View Source
wasm_func() :: {:func, [wasm_locals], wasm_instr}

Term of a WebAssembly function. Spec reference.

Link to this type wasm_func_type() View Source
wasm_func_type() :: {:func_type, [wasm_value_type], [wasm_value_type]}

Term of a funcion type. Spec reference.

Link to this type wasm_global() View Source
wasm_global() :: {:global, wasm_global_type, wasm_instr}

Term of a WebAssembly global. Spec reference.

Link to this type wasm_global_type() View Source
wasm_global_type() :: {:global_type, :const | :var, wasm_value_type}

Term of a global type. Spec reference.

Link to this type wasm_import() View Source
wasm_import() :: {:import, wasm_import_desc}

Term of a WebAssembly import. Spec reference.

Link to this type wasm_index() View Source
wasm_index ::
  {:type_index, non_neg_integer} |
  {:func_index, non_neg_integer} |
  {:table_index, non_neg_integer} |
  {:mem_index, non_neg_integer} |
  {:global_index, non_neg_integer} |
  {:local_index, non_neg_integer} |
  {:label_index, non_neg_integer}

Term of a WebAssembly index. Spec reference.

Link to this type wasm_instr() View Source
wasm_instr ::
  atom |
  {atom, wasm_result_type, [wasm_instr]} |
  {atom, wasm_index} |
  {atom, [wasm_index], wasm_index} |
  {atom, wasm_integer, wasm_integer} |
  {atom, integer} |
  {atom, [wasm_instr]}

Term of an instruction. Spec reference.

Link to this type wasm_integer() View Source
wasm_integer ::
  {:u32, non_neg_integer} |
  {:u64, non_neg_integer} |
  {:s32, integer} |
  {:s64, integer}

Terms of integers. Spec reference.

Link to this type wasm_limits() View Source
wasm_limits ::
  {:limits, non_neg_integer} |
  {:limits, non_neg_integer, non_neg_integer}

Term of memory limits. Spec reference.

Link to this type wasm_locals() View Source
wasm_locals() :: {:locals, wasm_integer, wasm_value_type}

Term of WebAssembly locals. Spec reference.

Link to this type wasm_mem() View Source
wasm_mem() :: {:mem, wasm_mem_type}

Term of a memory section item. Spec reference.

Link to this type wasm_mem_type() View Source
wasm_mem_type() :: {:mem_type, [wasm_limits]}

Term of a memory type. Spec reference.

Link to this type wasm_module() View Source
wasm_module() :: {:module, [wasm_section]}

Term of a WebAssembly module. Spec reference.

Link to this type wasm_name() View Source
wasm_name() :: {:name, String.t}

Term of a name. Spec reference.

Link to this type wasm_result_type() View Source
wasm_result_type() :: {:result, [wasm_value_type]}

Term of a result type. Spec reference.

Link to this type wasm_section() View Source
wasm_section ::
  {:custom_sec, wasm_custom} |
  {:type_sec, [wasm_func_type]} |
  {:import_sec, [wasm_import]} |
  {:func_sec, [wasm_index]} |
  {:table_sec, [wasm_table]} |
  {:memory_sec, [wasm_mem]} |
  {:global_sec, [wasm_global]} |
  {:export_sec, [wasm_export]} |
  {:start_sec, wasm_start} |
  {:elem_sec, [wasm_elem]} |
  {:code_sec, [wasm_code]} |
  {:data_sec, [wasm_data]}

Term of a module section. Spec reference.

Link to this type wasm_start() View Source
wasm_start() :: {:start, wasm_index}

Term of a start section item. Spec reference.

Link to this type wasm_table() View Source
wasm_table() :: {:table, wasm_table_type}

Term of a WebAssembly table. Spec reference.

Link to this type wasm_table_type() View Source
wasm_table_type() :: {:table_type, wasm_elem_type, wasm_limits}

Term of a table type. Spec reference.

Link to this type wasm_value_type() View Source
wasm_value_type() :: :i32 | :i64 | :f32 | :f64

Terms of a value type. Spec reference.

Link to this section Functions

Encode a WebAssembly module. Spec reference.

Link to this function encode_code(arg) View Source
encode_code(wasm_code) :: binary

Encode code section contents. Spec reference.

Link to this function encode_custom(arg) View Source
encode_custom(wasm_custom) :: binary

Encode custom section contents. Spec reference.

Link to this function encode_data(arg) View Source
encode_data(wasm_data) :: binary

Encode data section contents. Spec reference.

Link to this function encode_elem(arg) View Source
encode_elem(wasm_elem) :: binary

Encode element section contents. Spec reference.

Link to this function encode_elem_type(atom) View Source
encode_elem_type(wasm_elem_type) :: binary

Encode a table element type. Spec reference.

Link to this function encode_export(arg) View Source
encode_export(wasm_export) :: binary

Encode export section contents. Spec reference.

Link to this function encode_float(arg) View Source
encode_float(wasm_float) :: binary

Encode 32-bit and 64-bit IEEE 754 LE floats. Spec reference.

Link to this function encode_func_type(arg) View Source
encode_func_type(wasm_func_type) :: binary

Encode a func type. Spec reference.

Link to this function encode_global(arg) View Source
encode_global(wasm_global) :: binary

Encode global section contents. Spec reference.

Link to this function encode_global_type(arg) View Source
encode_global_type(wasm_global_type) :: binary

Encode a global type. Spec reference.

Link to this function encode_import(arg) View Source
encode_import(wasm_import) :: binary

Encode import section contents. Spec reference.

Link to this function encode_index(arg) View Source
encode_index(wasm_index) :: binary

Encode an index. Spec reference.

Link to this function encode_instr(instr) View Source
encode_instr(wasm_instr) :: binary

Encode instructions. Spec reference.

Link to this function encode_integer(arg) View Source
encode_integer(wasm_integer) :: binary

Encode 32-bit or 64-bit integers that are signed or unsigned. Spec reference.

The LEB128 encoder inspired from funbox/eleb128 and “LEB128” on Wikipedia.

Link to this function encode_limits(arg) View Source
encode_limits(wasm_limits) :: binary

Encode a limit. Spec reference.

Link to this function encode_mem(arg) View Source
encode_mem(wasm_mem) :: binary

Encode memory section contents. Spec reference.

Link to this function encode_mem_type(arg) View Source
encode_mem_type(wasm_mem_type) :: binary

Encode a memory type. Spec reference.

Link to this function encode_name(arg) View Source
encode_name(wasm_name) :: binary

Encode a name. Spec reference.

Link to this function encode_result_type(arg) View Source
encode_result_type(wasm_result_type) :: binary

Encode a result type. Spec reference.

Link to this function encode_section(arg) View Source
encode_section(wasm_section) :: binary

Encode a module section. Spec reference.

Link to this function encode_start(arg) View Source
encode_start(wasm_start) :: binary

Encode start section contents. Spec reference.

Link to this function encode_table(arg) View Source
encode_table(wasm_table) :: binary

Encode table section contents. Spec reference.

Link to this function encode_table_type(arg) View Source
encode_table_type(wasm_table_type) :: binary

Encode a table type. Spec reference.

Link to this function encode_value_type(name) View Source
encode_value_type(wasm_value_type) :: binary

Encode a value type. Spec reference.