class

Wasmer::Function

Inherits Wasmer::WithExtern / Reference / Object

Function is a WebAssembly function instance

A function instance is the runtime representation of a function. It effectively is a closure of the original function (defined in either the host or the WebAssembly module) over the runtime Instance of its originating Module.

The module instance is used to resolve references to other definitions during execution of the function.

Spec: https://webassembly.github.io/spec/core/exec/runtime.html#function-instances

Constructors

new(store : Store, type : FunctionType, env : UserEnv, &func : FuncEnvProc)

Instantiates a new Function in the given Store. It takes four arguments, the Store, the FunctionType, host environment and the definition for the Function. environment can be anything. It is Pointer(Void)

The function definition must be a native Crystal function with a Value array as its single argument. The function must return a Value array or raise an exception for abnormal conditions.

Note: Even if the function does not take any argument (or use any argument) it must receive a Value array as its single argument. At runtime, this array will be empty. The same applies to the result.

Source
new(store : Store, type : FunctionType, &func : FuncProc)

Instantiates a new Function in the given Store. It takes three arguments, the Store, the FunctionType and the definition for the Function.

The function definition must be a native Crystal function with a Value array as its single argument. The function must return a Value array or raise an exception for abnormal conditions.

Note: Even if the function does not take any argument (or use any argument) it must receive a Value array as its single argument. At runtime, this array will be empty. The same applies to the result.

Source

Instance methods

call(*params : Number)

call the Function and return its result as native Crystal values.

Source
native

turn the Function into a native Crystal function that can be called.

Source
param_arity

Returns the number of arguments the Function expects as per its definition

Source
result_arity

Returns the number of results the function will return

Source
to_extern
Source
type
Source