Skip to main content

Engine

Struct Engine 

Source
pub struct Engine {
    pub env: Rc<Env>,
    pub deferred_slots: RefCell<Vec<(Inst, String)>>,
    pub failed_inputs: RefCell<HashSet<String>>,
    pub reads: RefCell<HashMap<String, HashSet<String>>>,
    pub computing: RefCell<Vec<String>>,
    pub slots_by_key: RefCell<HashMap<String, (Inst, String)>>,
    pub deferred_roots: RefCell<Vec<DeferredRoot>>,
    /* private fields */
}

Fields§

§env: Rc<Env>§deferred_slots: RefCell<Vec<(Inst, String)>>§failed_inputs: RefCell<HashSet<String>>

inputs whose fallback failed to bind: later demands are tainted, not re-reported

§reads: RefCell<HashMap<String, HashSet<String>>>§computing: RefCell<Vec<String>>§slots_by_key: RefCell<HashMap<String, (Inst, String)>>§deferred_roots: RefCell<Vec<DeferredRoot>>

roots whose binding deferred through $referrers in phase 1: bound again after the deferred slots

Implementations§

Source§

impl Engine

Source

pub fn bare(env: Rc<Env>) -> Rc<Engine>

an engine without registering itself as the environment’s evaluator

Source

pub fn slot_key(inst: &Inst, name: &str) -> String

Source

pub fn record(&self, read: String)

Source

pub fn step<T>(&self, key: &str, f: impl FnOnce() -> T) -> T

Source

pub fn phase(&self) -> u8

Source

pub fn new(env: Rc<Env>) -> Rc<Engine>

Source

pub fn install_hooks(self: &Rc<Self>, env: &Rc<Env>, with_menv: bool)

§4.13 / unit factors: let the environment evaluate constants through this engine

Source

pub fn ev(&self, e: &Rc<Expr>, sc: &Scope) -> R<Value>

Source

pub fn member_of(&self, v: &Value, rt: &RT, sc: &Scope) -> bool

Source

pub fn demand_input(&self, menv: &Rc<Env>, name: &str) -> R<Option<Value>>

Source

pub fn bind_root(&self, name: &str, src: RootSrc<'_>, rt: &RT, sc: &Scope)

Source

pub fn bind_deferred_roots(&self)

phase 2: the roots that deferred are bound again (after the deferred slots)

Source

pub fn deref(&self, v: Value) -> R<Value>

Source

pub fn resolve_segs(&self, segs: &[Seg]) -> R<Value>

Source

pub fn resolve_canonical(&self, segs: &[Seg]) -> R<Value>

Source

pub fn call(&self, f: &Value, args: Vec<Value>, sc: &Scope) -> R<Value>

Source

pub fn bind( &self, raw: Value, rt: &RT, path: &[Seg], parent: Option<&Inst>, sc: &Scope, ) -> R<Value>

Source

pub fn eval_place(&self, e: &Rc<Expr>, sc: &Scope) -> R<Option<SegPath>>

Source

pub fn materialize(&self, v: Value, path: &[Seg]) -> R<Value>

Source

pub fn force_state(&self, inst: &Inst, name: &str) -> SlotState

Source

pub fn force_slot_safe(&self, inst: &Inst, name: &str)

Source

pub fn force_slot(&self, inst: &Inst, name: &str) -> R<Value>

Source

pub fn force_const_in( &self, env: &Rc<Env>, name: &str, root_name: &str, ) -> R<Value>

Source

pub fn force_all(&self, v: &Value)

Source

pub fn set_phase(&self, p: u8)

the evaluation phase: 1 materialization, 2 universe complete ($referrers answers)

Source

pub fn force_roots(&self, env: &Env)

force every root, run the $referrers phase, then the assertion pass force every root, the roots demanded on the way included (an input bound through its fallback while another root is forced becomes a root too, and is forced in the same pass — the reference walks the live root map)

Source

pub fn drive(&self, env: &Env)

Source

pub fn validate_all(&self, root_name: &str)

Source

pub fn validate_inst(&self, inst: &Inst, root_name: &str)

Source

pub fn reset_slot(&self, key: &str) -> bool

reset a computed slot so that it is computed again (dependency tracking)

Source

pub fn serialize( &self, v: &Value, root_name: &str, settable_only: bool, ) -> String

canonical JSON of a value (§10.4, D29): derived members included, hidden never; settable_only is the tool option D29 provides — the settable projection (required, optional, defaulted members) that a document for the same type would carry

Auto Trait Implementations§

§

impl !Freeze for Engine

§

impl !RefUnwindSafe for Engine

§

impl !Send for Engine

§

impl !Sync for Engine

§

impl !UnwindSafe for Engine

§

impl Unpin for Engine

§

impl UnsafeUnpin for Engine

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.