WasmFunction class

A Wasm function.

final wasmFunction = WasmFunction(
  (int a, int b) => a + b,
  params: [ValueTy.i32, ValueTy.i32],
  results: [ValueTy.i32],
);
final result = wasmFunction([1, 2]);
assert(result.first == 3);
final resultInner = wasmFunction.inner(1, 2);
assert(resultInner, 3);
Inheritance
Annotations
  • @immutable

Constructors

WasmFunction(Function inner, {required List<ValueTy?> params, required List<ValueTy>? results, String? name, List<Object?> call([List<Object?>? args])?})
Constructs a Wasm function.
const
WasmFunction.voidReturn(Function inner, {required List<ValueTy?> params, String? name, List<Object?> call([List<Object?>? args])?})
Constructs a Wasm function with no results.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
inner Function
The inner function that is called when this function is invoked. It receives positional parameters and does not receive a list of values like call. If you execute it, you will need to pass the Dart values as positional parameters as the expected params and the return type will not be cast to a List.
final
kind WasmExternalKind
The kind of this WasmExternal.
no setterinherited
name String?
Optional name for debugging purposes.
final
numberOfParameters int
The number of parameters of the function.
no setter
params List<ValueTy?>
The parameters of the function. The types may be null if the wasm runtime does not expose this information. For example in web browsers. However, the length of the list is always the number of parameters.
final
results List<ValueTy>?
The result types of the function. May be null if the wasm runtime does not expose this information. For example in web browsers.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call([List<Object?>? args]) List<Object?>
Invokes inner with the given args and casts the result to a List of Dart values.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
when<T>({required T memory(WasmMemory memory), required T table(WasmTable table), required T global(WasmGlobal global), required T function(WasmFunction function)}) → T
Executes the given function depending on the type of this WasmExternal.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override