pub trait Apply<R: Rt, E: UserEvent>:
Debug
+ Send
+ Sync
+ Any {
// Required methods
fn update(
&mut self,
ctx: &mut ExecCtx<R, E>,
from: &mut [Node<R, E>],
event: &mut Event<E>,
) -> Option<Value>;
fn sleep(&mut self, _ctx: &mut ExecCtx<R, E>);
// Provided methods
fn delete(&mut self, _ctx: &mut ExecCtx<R, E>) { ... }
fn typecheck(
&mut self,
_ctx: &mut ExecCtx<R, E>,
_from: &mut [Node<R, E>],
_phase: TypecheckPhase<'_>,
) -> Result<()> { ... }
fn typ(&self) -> Arc<FnType> { ... }
fn refs<'a>(&self, _refs: &mut Refs) { ... }
}Expand description
Apply is a kind of node that represents a function application. It does not hold ownership of it’s arguments, instead those are held by a CallSite node. This allows us to change the function called at runtime without recompiling the arguments.
Required Methods§
fn update( &mut self, ctx: &mut ExecCtx<R, E>, from: &mut [Node<R, E>], event: &mut Event<E>, ) -> Option<Value>
Provided Methods§
Sourcefn delete(&mut self, _ctx: &mut ExecCtx<R, E>)
fn delete(&mut self, _ctx: &mut ExecCtx<R, E>)
delete any internally generated nodes, only needed for builtins that dynamically generate code at runtime
Sourcefn typecheck(
&mut self,
_ctx: &mut ExecCtx<R, E>,
_from: &mut [Node<R, E>],
_phase: TypecheckPhase<'_>,
) -> Result<()>
fn typecheck( &mut self, _ctx: &mut ExecCtx<R, E>, _from: &mut [Node<R, E>], _phase: TypecheckPhase<'_>, ) -> Result<()>
apply custom typechecking. Phase indicates context:
- Lambda: during lambda body checking (faux args). Return NeedsCallSite to opt in to deferred call-site type checking.
- CallSite: during deferred check or bind (resolved FnType available)