Class ExternalFunction
Represents a function whose implementation is provided by the host code.
Assembly: WaaS.Core.dll
View Source
public abstract class ExternalFunction : IFunction, ISortedExportable, ISorted
Derived:
WaaS.ComponentModel.Binding.ExternalFunctionDelegate
Implements:
WaaS.ComponentModel.Runtime.IFunction, WaaS.ComponentModel.Runtime.ISortedExportable, WaaS.ComponentModel.Runtime.ISorted
Properties
Type
View Source
public abstract IFunctionType Type { get; }
SupportsDirectInvoke
Whether WaaS.ComponentModel.Binding.ExternalFunction.InvokeDirect(WaaS.ComponentModel.Binding.DirectInvocationContext%2cSystem.ReadOnlySpan%7bWaaS.Runtime.StackValueItem%7d) is available. Generated for the functions whose values have a fixed
representation: numbers of the same width as a core value, strings, records of them and borrowed handles.
View Source
public virtual bool SupportsDirectInvoke { get; }
DirectInvokeUsesMemory
Whether WaaS.ComponentModel.Binding.ExternalFunction.InvokeDirect(WaaS.ComponentModel.Binding.DirectInvocationContext%2cSystem.ReadOnlySpan%7bWaaS.Runtime.StackValueItem%7d) accesses the memory of the guest as UTF-8.
View Source
public virtual bool DirectInvokeUsesMemory { get; }
Methods
InvokeDirect(DirectInvocationContext, ReadOnlySpan<StackValueItem>)
Invokes the host implementation with the core values of the parameters and returns the core value of the result, without a stack frame and the formatters.
View Source
public virtual ValueTask<StackValueItem> InvokeDirect(DirectInvocationContext invocation, ReadOnlySpan<StackValueItem> parameters)
Returns
System.Threading.Tasks.ValueTask<WaaS.Runtime.StackValueItem>
Parameters
| Type | Name |
|---|---|
| WaaS.ComponentModel.Binding.DirectInvocationContext | invocation |
System.ReadOnlySpan<WaaS.Runtime.StackValueItem> | parameters |
InvokeAsync(ExecutionContext, Pullable, STaskVoid, STask<ValuePusher>)
Invokes the host implementation. It is called when the frame of the function is first moved, after all the arguments are pushed, so that <code class="paramref">arguments</code> can be pulled, and <code class="paramref">frameMove</code> and <code class="paramref">resultPusher</code> can be awaited without suspension.
View Source
protected abstract STaskVoid InvokeAsync(ExecutionContext context, Pullable arguments, STaskVoid frameMove, STask<ValuePusher> resultPusher)
Returns
Parameters
| Type | Name |
|---|---|
| WaaS.Runtime.ExecutionContext | context |
| WaaS.ComponentModel.Binding.Pullable | arguments |
| STask.STaskVoid | frameMove |
| STask.STask<TResult> | resultPusher |