wasm_config_new()
Create a new default Wasmer configuration.
wasm_config_new() : resource
<?php
// Create the configuration.
$config = wasm_config_new();
// Create the engine using the configuration.
$engine = wasm_engine_new_with_config($config);
// Free everything.
wasm_engine_delete($engine);
-
throws
-
RuntimeException
wasm_config_delete()
Delete a config object.
wasm_config_delete(resource $config) : bool
<?php
// Create the configuration.
$config = wasm_config_new();
// Delete the configuration
wasm_config_delete($config);
ℹ️ This function does not need to be called if the configuration was used as an argument of
wasm_engine_new_with_config
.
Parameters
-
$config
: resource
-
wasm_config_set_compiler()
Update the configuration to specify a particular compiler to use.
wasm_config_set_compiler(resource $config, int $compiler) : bool
<?php
// Create the configuration.
$config = wasm_config_new();
// Use the Cranelift compiler.
wasm_config_set_compiler($config, WASM_COMPILER_CRANELIFT);
// Create the engine.
$engine = wasm_engine_new_with_config($config);
// Free everything.
wasm_engine_delete($engine);
⚠️ This is a Wasmer-specific function.
Parameters
-
$config
: resource
-
-
$compiler
: int
-
wasm_config_set_engine()
Update the configuration to specify a particular engine to use.
wasm_config_set_engine(resource $config, int $engine) : bool
<?php
// Create the configuration.
$config = wasm_config_new();
// Use the JIT engine.
wasm_config_set_compiler($config, WASM_ENGINE_JIT);
// Create the engine.
$engine = wasm_engine_new_with_config($config);
// Free everything.
wasm_engine_delete($engine);
⚠️ This is a Wasmer-specific function.
Parameters
-
$config
: resource
-
-
$engine
: int
-
wasm_engine_new()
Create a new JIT engine with the default compiler.
wasm_engine_new() : resource
-
see
-
wasm_engine_delete()
wasm_engine_new_with_config()
Create an engine with a particular configuration.
wasm_engine_new_with_config(resource $config) : resource
Parameters
-
$config
: resource
-
-
see
-
wasm_config_new()
wasm_engine_delete()
Delete an engine.
wasm_engine_delete(resource $engine) : bool
<?php
// Create a default engine.
$engine = wasm_engine_new();
// Free everything.
wasm_engine_delete($engine);
Parameters
-
$engine
: resource
-
wasm_store_new()
Create a new WebAssembly store given a specific engine.
wasm_store_new(resource $engine) : resource
<?php
// Create a default engine.
$engine = wasm_engine_new();
// Create a store.
$store = wasm_store_new($store);
// Free everything.
wasm_store_delete($store);
wasm_engine_delete($engine);
Parameters
-
$engine
: resource
-
wasm_store_delete()
Delete a store.
wasm_store_delete(resource $store) : bool
Parameters
-
$store
: resource
-
-
see
-
wasm_store_new()
wasm_valtype_new()
Create a new valtype.
wasm_valtype_new(int $kind) : resource
<?php
// Create a valtype of kind i32
$valtype = wasm_valtype_new(WASM_I32);
// Free everything.
wasm_valtype_delete($valtype);
Parameters
-
$kind
: int
-
The kind of valuetype.
This must be one of WASM_I32
, WASM_F32
, WASM_I64
, WASM_F64
, WASM_ANYREF
or WASM_FUNCREF
.
wasm_valtype_delete()
Delete a valtype.
wasm_valtype_delete(resource $valtype) : bool
Parameters
-
$valtype
: resource
-
a wasm_valtype_t
resource
ℹ️ This function does not need to be called if the configuration was used as an argument of
wasm_functype_new
, wasm_globaltype_new
, wasm_tabletype_new
or was added to a \Wasm\Vec\Val
-
see
-
wasm_valtype_new()
wasm_valtype_kind()
Return the valtype kind.
wasm_valtype_kind(resource $valtype) : int
<?php
// Create a valtype of kind i32
$valtype = wasm_valtype_new(WASM_I32);
var_dump(wasm_valtype_kind($valtype) === WASM_I32); // bool(true)
// Free everything.
wasm_valtype_delete($valtype);
Parameters
-
$valtype
: resource
-
A wasm_valtype_t
resource
wasm_valtype_is_num()
Return `true` if the given valtype has a numeric kind.
wasm_valtype_is_num(resource $valtype) : bool
<?php
// Create some valtypes
$i32 = wasm_valtype_new(WASM_I32);
$ref = wasm_valtype_new(WASM_ANYREF);
var_dump(wasm_valtype_is_num($i32)); // bool(true)
var_dump(wasm_valtype_is_num($ref)); // bool(false)
// Free everything.
wasm_valtype_delete($i32);
wasm_valtype_delete($ref);
Parameters
-
$valtype
: resource
-
A wasm_valtype_t
resource
wasm_valtype_is_ref()
Return `true` if the given valtype has a reference kind.
wasm_valtype_is_ref(resource $valtype) : bool
<?php
// Create some valtypes
$i32 = wasm_valtype_new(WASM_I32);
$ref = wasm_valtype_new(WASM_ANYREF);
var_dump(wasm_valtype_is_ref($i32)); // bool(false)
var_dump(wasm_valtype_is_ref($ref)); // bool(true)
// Free everything.
wasm_valtype_delete($i32);
wasm_valtype_delete($ref);
Parameters
-
$valtype
: resource
-
A wasm_valtype_t
resource
wasm_valtype_copy()
Create a copy of the given valtype.
wasm_valtype_copy(resource $valtype) : resource
<?php
// Create a valtype of kind i32
$valtype = wasm_valtype_new(WASM_I32);
$copy = wasm_valtype_copy($valtype);
// Free everything
wasm_valtype_delete($copy);
wasm_valtype_delete($valtype);
Parameters
-
$valtype
: resource
-
The wasm_valtype_t
resource to copy
wasm_valkind_is_num()
Verify whether the given kind is numeric.
wasm_valkind_is_num(int $kind) : bool
<?php
var_dump(wasm_valkind_is_num(WASM_I32)); // bool(true)
var_dump(wasm_valkind_is_num(WASM_ANYREF)); // bool(false)
Parameters
-
$kind
: int
-
The kind of valuetype.
This must be one of WASM_I32
, WASM_F32
, WASM_I64
, WASM_F64
, WASM_ANYREF
or WASM_FUNCREF
.
wasm_valkind_is_ref()
Verify whether the given kind is a reference.
wasm_valkind_is_ref(int $kind) : bool
<?php
var_dump(wasm_valkind_is_ref(WASM_ANYREF)); // bool(true)
var_dump(wasm_valkind_is_ref(WASM_I32)); // bool(false)
Parameters
-
$kind
: int
-
The kind of valuetype.
This must be one of WASM_I32
, WASM_F32
, WASM_I64
, WASM_F64
, WASM_ANYREF
or WASM_FUNCREF
.
wasm_functype_new()
Create a new valtype.
wasm_functype_new(ValType $params, ValType $results) : resource
<?php
use Wasm\Vec\ValType;
// Create a valtype of kind i32
$functype = wasm_functype_new(new ValType(), new ValType());
// Free everything.
wasm_functype_delete($functype);
Parameters
-
$params
: ValType
-
-
$results
: ValType
-
wasm_functype_delete()
Delete a functype.
wasm_functype_delete(resource $functype) : bool
Parameters
-
$functype
: resource
-
A wasm_functype_t
resource
-
see
-
wasm_functype_new()
wasm_functype_params()
wasm_functype_params(resource $functype) : ValType
Parameters
-
$functype
: resource
-
A wasm_functype_t
resource
wasm_functype_results()
wasm_functype_results(resource $functype) : ValType
Parameters
-
$functype
: resource
-
A wasm_functype_t
resource
wasm_functype_copy()
wasm_functype_copy(resource $functype) : resource
Parameters
-
$functype
: resource
-
A wasm_functype_t
resource
wasm_functype_as_externtype()
wasm_functype_as_externtype(resource $functype) : resource
Parameters
-
$functype
: resource
-
A wasm_functype_t
resource
wasm_globaltype_new()
wasm_globaltype_new(resource $valtype, int $mutability) : resource
Parameters
-
$valtype
: resource
-
A wasm_valtype_t
resource
-
$mutability
: int
-
wasm_globaltype_delete()
Delete a globaltype.
wasm_globaltype_delete(resource $globaltype) : bool
Parameters
-
$globaltype
: resource
-
A wasm_globaltype_t
resource
-
see
-
wasm_globaltype_new()
wasm_globaltype_content()
wasm_globaltype_content(resource $globaltype) : resource
Parameters
-
$globaltype
: resource
-
wasm_globaltype_mutability()
wasm_globaltype_mutability(resource $globaltype) : int
Parameters
-
$globaltype
: resource
-
A wasm_globaltype_t
resource
wasm_globaltype_copy()
wasm_globaltype_copy(resource $globaltype) : resource
Parameters
-
$globaltype
: resource
-
A wasm_globaltype_t
resource
wasm_globaltype_as_externtype()
wasm_globaltype_as_externtype(resource $globaltype) : resource
Parameters
-
$globaltype
: resource
-
A wasm_globaltype_t
resource
wasm_limits_new()
Create a new limits.
wasm_limits_new(int $min, int $max) : resource
Parameters
-
$min
: int
-
-
$max
: int
-
-
see
-
wasm_memorytype_new()
-
see
-
wasm_tabletype_new()
wasm_limits_min()
wasm_limits_min(resource $limits) : int
Parameters
-
$limits
: resource
-
wasm_limits_max()
wasm_limits_max(resource $limits) : int
Parameters
-
$limits
: resource
-
wasm_tabletype_new()
wasm_tabletype_new(resource $valtype, resource $limits) : resource
Parameters
-
$valtype
: resource
-
A wasm_valtype_t
resource
-
$limits
: resource
-
wasm_tabletype_delete()
Delete a tabletype.
wasm_tabletype_delete(resource $tabletype) : bool
Parameters
-
$tabletype
: resource
-
A wasm_tabletype_t
resource
-
see
-
wasm_tabletype_new()
wasm_tabletype_element()
wasm_tabletype_element(resource $tabletype) : resource
Parameters
-
$tabletype
: resource
-
A wasm_tabletype_t
resource
wasm_tabletype_limits()
wasm_tabletype_limits(resource $tabletype) : resource
Parameters
-
$tabletype
: resource
-
A wasm_tabletype_t
resource
wasm_tabletype_copy()
wasm_tabletype_copy(resource $tabletype) : resource
Parameters
-
$tabletype
: resource
-
A wasm_tabletype_t
resource
wasm_tabletype_as_externtype()
wasm_tabletype_as_externtype(resource $tabletype) : resource
Parameters
-
$tabletype
: resource
-
A wasm_tabletype_t
resource
wasm_memorytype_new()
Create a new memorytype.
wasm_memorytype_new(resource $limits) : resource
<?php
$limits = wasm_limits_new(1, 2);
$memorytype = wasm_memorytype_new($limits);
// Free everything
wasm_memorytype_delete($memorytype);
Parameters
-
$limits
: resource
-
wasm_memorytype_delete()
Delete a memorytype.
wasm_memorytype_delete(resource $memorytype) : bool
Parameters
-
$memorytype
: resource
-
A wasm_memorytype_t
resource
-
see
-
wasm_memorytype_new()
wasm_memorytype_limits()
wasm_memorytype_limits(resource $memorytype) : resource
Parameters
-
$memorytype
: resource
-
A wasm_memorytype_t
resource
wasm_memorytype_copy()
wasm_memorytype_copy(resource $memorytype) : resource
Parameters
-
$memorytype
: resource
-
A wasm_memorytype_t
resource
wasm_memorytype_as_externtype()
wasm_memorytype_as_externtype(resource $memorytype) : resource
Parameters
-
$memorytype
: resource
-
A wasm_memorytype_t
resource
wasm_externtype_delete()
wasm_externtype_delete(resource $externtype) : bool
Parameters
-
$externtype
: resource
-
A wasm_externtype_t
resource
wasm_externtype_kind()
wasm_externtype_kind(resource $externtype) : int
Parameters
-
$externtype
: resource
-
A wasm_externtype_t
resource
wasm_externtype_as_functype()
wasm_externtype_as_functype(resource $externtype) : resource
Parameters
-
$externtype
: resource
-
A wasm_externtype_t
resource
-
throws
-
RuntimeException
wasm_externtype_as_globaltype()
wasm_externtype_as_globaltype(resource $externtype) : resource
Parameters
-
$externtype
: resource
-
A wasm_externtype_t
resource
-
throws
-
RuntimeException
wasm_externtype_as_tabletype()
wasm_externtype_as_tabletype(resource $externtype) : resource
Parameters
-
$externtype
: resource
-
A wasm_externtype_t
resource
-
throws
-
RuntimeException
wasm_externtype_as_memorytype()
wasm_externtype_as_memorytype(resource $externtype) : resource
Parameters
-
$externtype
: resource
-
A wasm_externtype_t
resource
-
throws
-
RuntimeException
wasm_importtype_new()
wasm_importtype_new(string $module, string $name, resource $externtype) : resource
Parameters
-
$module
: string
-
-
$name
: string
-
-
$externtype
: resource
-
A wasm_externtype_t
resource
wasm_importtype_delete()
Delete a importtype.
wasm_importtype_delete(resource $importtype) : bool
Parameters
-
$importtype
: resource
-
A wasm_importtype_t
resource
-
see
-
wasm_importtype_new()
wasm_importtype_module()
wasm_importtype_module(resource $importtype) : string
Parameters
-
$importtype
: resource
-
A wasm_importtype_t
resource
wasm_importtype_name()
wasm_importtype_name(resource $importtype) : string
Parameters
-
$importtype
: resource
-
A wasm_importtype_t
resource
wasm_importtype_type()
wasm_importtype_type(resource $importtype) : resource
Parameters
-
$importtype
: resource
-
A wasm_importtype_t
resource
wasm_importtype_copy()
wasm_importtype_copy(resource $importtype) : resource
Parameters
-
$importtype
: resource
-
A wasm_importtype_t
resource
wasm_exporttype_new()
wasm_exporttype_new(string $name, resource $externtype) : resource
Parameters
-
$name
: string
-
-
$externtype
: resource
-
A wasm_externtype_t
resource
wasm_exporttype_delete()
Delete a exporttype.
wasm_exporttype_delete(resource $exporttype) : bool
Parameters
-
$exporttype
: resource
-
A wasm_exporttype_t
resource
-
see
-
wasm_exporttype_new()
wasm_exporttype_name()
wasm_exporttype_name(resource $exporttype) : string
Parameters
-
$exporttype
: resource
-
A wasm_exporttype_t
resource
wasm_exporttype_type()
wasm_exporttype_type(resource $exporttype) : resource
Parameters
-
$exporttype
: resource
-
A wasm_exporttype_t
resource
wasm_exporttype_copy()
wasm_exporttype_copy(resource $exporttype) : resource
Parameters
-
$exporttype
: resource
-
A wasm_exporttype_t
resource
wasm_val_delete()
Delete a val.
wasm_val_delete(resource $val) : bool
Parameters
-
$val
: resource
-
wasm_val_value()
wasm_val_value(resource $val) : mixed
Parameters
-
$val
: resource
-
wasm_val_kind()
wasm_val_kind(resource $val) : int
Parameters
-
$val
: resource
-
wasm_val_copy()
wasm_val_copy(resource $val) : resource
Parameters
-
$val
: resource
-
wasm_val_i32()
wasm_val_i32(int $val) : resource
Parameters
-
$val
: int
-
wasm_val_i64()
wasm_val_i64(int $val) : resource
Parameters
-
$val
: int
-
wasm_val_f32()
wasm_val_f32(float $val) : resource
Parameters
-
$val
: float
-
wasm_val_f64()
wasm_val_f64(float $val) : resource
Parameters
-
$val
: float
-
wasm_frame_copy()
wasm_frame_copy(resource $frame) : resource
Parameters
-
$frame
: resource
-
wasm_frame_instance()
wasm_frame_instance(resource $frame) : resource
Parameters
-
$frame
: resource
-
wasm_frame_func_index()
wasm_frame_func_index(resource $frame) : int
Parameters
-
$frame
: resource
-
wasm_frame_func_offset()
wasm_frame_func_offset(resource $frame) : int
Parameters
-
$frame
: resource
-
wasm_frame_module_offset()
wasm_frame_module_offset(resource $frame) : int
Parameters
-
$frame
: resource
-
wasm_trap_new()
wasm_trap_new(resource $store, string $message) : resource
Parameters
-
$store
: resource
-
-
$message
: string
-
-
throws
-
RuntimeException
wasm_trap_delete()
wasm_trap_delete(resource $trap) : bool
Parameters
-
$trap
: resource
-
wasm_trap_copy()
wasm_trap_copy(resource $trap) : resource
Parameters
-
$trap
: resource
-
wasm_trap_message()
wasm_trap_message(resource $trap) : string
Parameters
-
$trap
: resource
-
wasm_trap_origin()
wasm_trap_origin(resource $trap) : resource
Parameters
-
$trap
: resource
-
wasm_trap_trace()
wasm_trap_trace(resource $trap) : Frame
Parameters
-
$trap
: resource
-
wasm_module_new()
wasm_module_new(resource $store, string $wasm) : resource
Parameters
-
$store
: resource
-
-
$wasm
: string
-
-
throws
-
RuntimeException
wasm_module_delete()
Delete a module.
wasm_module_delete(resource $module) : bool
Parameters
-
$module
: resource
-
-
see
-
wasm_module_new()
wasm_module_validate()
wasm_module_validate(resource $store, string $wasm) : bool
Parameters
-
$store
: resource
-
-
$wasm
: string
-
-
throws
-
RuntimeException
wasm_module_imports()
wasm_module_imports(resource $module) : ImportType
Parameters
-
$module
: resource
-
wasm_module_exports()
wasm_module_exports(resource $module) : ExportType
Parameters
-
$module
: resource
-
wasm_module_serialize()
wasm_module_serialize(resource $module) : string
Parameters
-
$module
: resource
-
wasm_module_deserialize()
wasm_module_deserialize(resource $store, string $wasm) : resource
Parameters
-
$store
: resource
-
-
$wasm
: string
-
-
throws
-
RuntimeException
wasm_module_name()
wasm_module_name(resource $module) : string
Parameters
-
$module
: resource
-
wasm_module_set_name()
wasm_module_set_name(resource $module, string $name) : bool
Parameters
-
$module
: resource
-
-
$name
: string
-
wasm_module_copy()
wasm_module_copy(resource $module) : resource
Parameters
-
$module
: resource
-
wasm_func_new()
wasm_func_new(resource $store, resource $functype, callable $func) : resource
Parameters
-
$store
: resource
-
-
$functype
: resource
-
A wasm_functype_t
resource
-
$func
: callable
-
wasm_func_delete()
Delete a func.
wasm_func_delete(resource $func) : bool
Parameters
-
$func
: resource
-
-
see
-
wasm_func_new()
wasm_func_type()
wasm_func_type(resource $func) : resource
Parameters
-
$func
: resource
-
wasm_func_param_arity()
wasm_func_param_arity(resource $func) : int
Parameters
-
$func
: resource
-
wasm_func_result_arity()
wasm_func_result_arity(resource $func) : int
Parameters
-
$func
: resource
-
wasm_func_call()
wasm_func_call(resource $func, Val $args) : Val
Parameters
-
$func
: resource
-
-
$args
: Val
-
wasm_func_as_extern()
wasm_func_as_extern(resource $func) : resource
Parameters
-
$func
: resource
-
wasm_global_new()
wasm_global_new(resource $store, resource $globaltype, resource $val) : resource
Parameters
-
$store
: resource
-
-
$globaltype
: resource
-
A wasm_globaltype_t
resource
-
$val
: resource
-
wasm_global_delete()
Delete a global.
wasm_global_delete(resource $global) : bool
Parameters
-
$global
: resource
-
-
see
-
wasm_global_new()
wasm_global_type()
wasm_global_type(resource $global) : resource
Parameters
-
$global
: resource
-
wasm_global_get()
wasm_global_get(resource $global) : resource
Parameters
-
$global
: resource
-
wasm_global_set()
wasm_global_set(resource $global, resource $val) : void
Parameters
-
$global
: resource
-
-
$val
: resource
-
wasm_global_copy()
wasm_global_copy(resource $global) : resource
Parameters
-
$global
: resource
-
wasm_global_same()
wasm_global_same(resource $left, resource $right) : bool
Parameters
-
$left
: resource
-
-
$right
: resource
-
wasm_global_as_extern()
wasm_global_as_extern(resource $global) : resource
Parameters
-
$global
: resource
-
wasm_extern_delete()
Delete an extern.
wasm_extern_delete(resource $extern) : bool
Parameters
-
$extern
: resource
-
wasm_extern_kind()
wasm_extern_kind(resource $extern) : int
Parameters
-
$extern
: resource
-
wasm_extern_type()
wasm_extern_type(resource $extern) : resource
Parameters
-
$extern
: resource
-
wasm_extern_as_func()
wasm_extern_as_func(resource $extern) : resource
Parameters
-
$extern
: resource
-
-
throws
-
RuntimeException
wasm_extern_as_global()
wasm_extern_as_global(resource $extern) : resource
Parameters
-
$extern
: resource
-
-
throws
-
RuntimeException
wasm_extern_as_table()
wasm_extern_as_table(resource $extern) : resource
Parameters
-
$extern
: resource
-
-
throws
-
RuntimeException
wasm_extern_as_memory()
wasm_extern_as_memory(resource $extern) : resource
Parameters
-
$extern
: resource
-
-
throws
-
RuntimeException
wasm_instance_new()
wasm_instance_new(resource $store, resource $module, Extern $externs) : resource
Parameters
-
$store
: resource
-
-
$module
: resource
-
-
$externs
: Extern
-
wasm_instance_delete()
Delete an instance.
wasm_instance_delete(resource $instance) : bool
Parameters
-
$instance
: resource
-
A wasm_instance_t
resource
-
see
-
wasm_instance_new()
wasm_instance_exports()
wasm_instance_exports(resource $instance) : Extern
Parameters
-
$instance
: resource
-
A wasm_instance_t
resource
wasm_instance_copy()
wasm_instance_copy(resource $instance) : resource
Parameters
-
$instance
: resource
-
A wasm_instance_t
resource
wasmer_version()
Return the version of the Wasmer C API.
wasmer_version() : string
Example
<?php
$version = wasmer_version();
⚠️ This is a Wasmer-specific function.
wasmer_version_major()
Return the major version of the Wasmer C API.
wasmer_version_major() : int
Example
<?php
$major = wasmer_version_major();
⚠️ This is a Wasmer-specific function.
wasmer_version_minor()
Return the minor version of the Wasmer C API.
wasmer_version_minor() : int
Example
<?php
$minor = wasmer_version_minor();
⚠️ This is a Wasmer-specific function.
wasmer_version_patch()
Return the patch version of the Wasmer C API.
wasmer_version_patch() : int
Example
<?php
$patch = wasmer_version_patch();
⚠️ This is a Wasmer-specific function.
wasmer_version_pre()
Return the pre-release label of the Wasmer C API.
wasmer_version_pre() : string
This function will return an empty string if the Wasmer C API is stable.
Example
<?php
$pre = wasmer_version_pre();
⚠️ This is a Wasmer-specific function.
wat2wasm()
⚠️ This is a Wasmer-specific function.
wat2wasm(string $wat) : string
Parameters
-
$wat
: string
-
-
throws
-
RuntimeException