Packages

An experimental work-in-progress (WIP) WebAssembly runtime written in Gleam.

Current section

Files

Jump to
gwr src gwr@execution@runtime.erl
Raw

src/gwr@execution@runtime.erl

-module(gwr@execution@runtime).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export_type([reference_value_type/0, value/0, execution_result/0, store/0, address/0, module_instance/0, function_instance/0, table_instance/0, memory_instance/0, global_instance/0, element_instance/0, data_instance/0, export_instance/0, external_value/0]).
-type reference_value_type() :: null |
{to_function_address, address()} |
{to_extern_address, address()}.
-type value() :: {number, integer()} |
{vector, integer()} |
{reference, reference_value_type()}.
-type execution_result() :: {success, list(value())} | trap.
-type store() :: {store,
list(function_instance()),
list(table_instance()),
list(memory_instance()),
list(global_instance()),
list(element_instance()),
list(data_instance())}.
-type address() :: {function_address, integer()} |
{table_address, integer()} |
{memory_address, integer()} |
{global_address, integer()} |
{element_address, integer()} |
{data_address, integer()} |
{extern_address, integer()}.
-type module_instance() :: {module_instance,
list(gwr@syntax@types:function_type()),
list(address()),
list(address()),
list(address()),
list(address()),
list(address()),
list(address()),
list(export_instance())}.
-type function_instance() :: {web_assembly_function_instance,
gwr@syntax@types:function_type(),
module_instance(),
gwr@syntax@module:function_()} |
{host_function_instance,
gwr@syntax@types:function_type(),
fun((list(gleam@dynamic:dynamic_())) -> list(gleam@dynamic:dynamic_()))}.
-type table_instance() :: {table_instance,
gwr@syntax@types:table_type(),
list(value())}.
-type memory_instance() :: {memory_instance,
gwr@syntax@types:limits(),
bitstring()}.
-type global_instance() :: {global_instance,
gwr@syntax@types:global_type(),
value()}.
-type element_instance() :: {element_instance,
gwr@syntax@types:reference_type(),
list(value())}.
-type data_instance() :: {data_instance, bitstring()}.
-type export_instance() :: {export_instance, binary(), external_value()}.
-type external_value() :: {function, address()} |
{table, address()} |
{memory, address()} |
{global, address()}.