pub struct ExecCtx<R: Rt, E: UserEvent> {
pub libstate: LibState,
pub env: Env<R, E>,
pub cached: FxHashMap<BindId, Value>,
pub rt: R,
/* private fields */
}Fields§
§libstate: LibStatecontext global library state for built-in functions
env: Env<R, E>the language environment, typdefs, binds, lambdas, etc
cached: FxHashMap<BindId, Value>the last value of every bound variable
rt: Rthe runtime
Implementations§
Source§impl<R: Rt, E: UserEvent> ExecCtx<R, E>
impl<R: Rt, E: UserEvent> ExecCtx<R, E>
pub fn clear(&mut self)
Sourcepub fn new(user: R) -> Self
pub fn new(user: R) -> Self
Build a new execution context.
This is a very low level interface that you can use to build a custom runtime with deep integration to your code. It is very difficult to use, and if you don’t implement everything correctly the semantics of the language can be wrong.
Most likely you want to use the rt module instead.
pub fn register_builtin<T: BuiltIn<R, E>>(&mut self) -> Result<()>
Sourcepub fn set_var(&mut self, id: BindId, v: Value)
pub fn set_var(&mut self, id: BindId, v: Value)
Built in functions should call this when variables are set unless they are sure the variable does not need to be cached. This will also call the user ctx set_var.
Sourcepub fn with_restored<T, F: FnOnce(&mut Self) -> T>(
&mut self,
env: Env<R, E>,
f: F,
) -> T
pub fn with_restored<T, F: FnOnce(&mut Self) -> T>( &mut self, env: Env<R, E>, f: F, ) -> T
Restore the lexical environment to the snapshot env for the
duration of f restoring it to it’s original value
afterwords. by_id and lambdas defined by the closure will
be retained.