Skip to main content

NativeOps

Trait NativeOps 

Source
pub trait NativeOps {
    // Required methods
    fn truthy(&self, frame: &mut NativeFrame<'_>, value: Value) -> bool;
    fn dispatch(
        &self,
        frame: &mut NativeFrame<'_>,
        call: HelperCall,
    ) -> HelperResult;
}
Expand description

The runtime semantic engine the exported helpers dispatch into. Implemented by bamts_runtime’s native engine; installed for the current thread with with_native_ops.

Methods take &self because dispatch is re-entrant: a Call, Construct, or CreateClosure may re-enter native code that calls another helper, which dispatches back into the same instance on the same thread. Shared &self reborrows alias soundly, so the outer dispatch may resume touching self after the nested call returns — e.g. to pop an activation record or record a result. The engine therefore holds its mutable state behind interior mutability (Cell/RefCell/UnsafeCell); the one discipline is to never hold a RefCell borrow guard across a nested native re-entry (the re-entrant borrow would panic). Nested execution always uses a distinct child ShadowFrame, so the outer frame borrow never aliases it.

Required Methods§

Source

fn truthy(&self, frame: &mut NativeFrame<'_>, value: Value) -> bool

The total ToBoolean coercion. Never throws.

Source

fn dispatch( &self, frame: &mut NativeFrame<'_>, call: HelperCall, ) -> HelperResult

Executes one completion helper, writing any register side effects through frame and returning the completion.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§