class Wasmer::Function
- Wasmer::Function
- Reference
- Object
Overview
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
Included Modules
Defined in:
wasmer/function.crConstructors
- .new(store : Store, type : FunctionType, env : UserEnv, &func : FuncEnvProc)
- .new(store : Store, type : FunctionType, &func : FuncProc)
Instance Method Summary
-
#call(*params : Number)
call the Function and return its result as native Crystal values.
-
#native : Native
turn the
Function
into a native Crystal function that can be called. -
#param_arity : UInt32
Returns the number of arguments the Function expects as per its definition
-
#result_arity : UInt32
Returns the number of results the function will return
- #to_extern : Extern
- #type : FunctionType
Instance methods inherited from module Wasmer::WithExtern
to_extern : Extern
to_extern
Constructor Detail
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.
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.
Instance Method Detail
Returns the number of arguments the Function expects as per its definition