Skip to main content

Class ExternalFunction

Represents a function whose implementation is provided by the host code.

Assembly: WaaS.Core.dll​
View Source​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
public virtual ValueTask<StackValueItem> InvokeDirect(DirectInvocationContext invocation, ReadOnlySpan<StackValueItem> parameters)
Returns​

System.Threading.Tasks.ValueTask<WaaS.Runtime.StackValueItem>

Parameters​
TypeName
WaaS.ComponentModel.Binding.DirectInvocationContextinvocation
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​
Declaration
protected abstract STaskVoid InvokeAsync(ExecutionContext context, Pullable arguments, STaskVoid frameMove, STask<ValuePusher> resultPusher)
Returns​

STask.STaskVoid

Parameters​
TypeName
WaaS.Runtime.ExecutionContextcontext
WaaS.ComponentModel.Binding.Pullablearguments
STask.STaskVoidframeMove
STask.STask<TResult>resultPusher

Implements​