InterpreterState

Struct InterpreterState 

Source
pub struct InterpreterState<'a> {
    pub application_tables: HashMap<TypeId, ApplicationTable<'a>>,
    pub type_spaces: HashMap<TypeId, TypeSpace>,
    pub ctxt: &'a Context,
}
Expand description

Represents the state of a simple interpreter for the combinatorial language defined through the referenced Context, with the given TypeId-indexed TypeSpaces and ApplicationTables memoizing all known non-primitive terms and results of term evaluations, respectively.

Fields§

§application_tables: HashMap<TypeId, ApplicationTable<'a>>§type_spaces: HashMap<TypeId, TypeSpace>§ctxt: &'a Context

Implementations§

Source§

impl<'a> InterpreterState<'a>

Source

pub fn get_context(&self) -> &Context

Gets the Context that this InterpreterState operates within.

Source

pub fn store_term( &mut self, type_id: TypeId, term: PartiallyAppliedTerm, ) -> NonPrimitiveTermPointer

Stores the given PartiallyAppliedTerm in the TypeSpace for the given TypeId, if it wasn’t already present. Returns a NonPrimitiveTermPointer referencing where it was stored in this InterpreterState.

Source

pub fn get(&self, term_ptr: TermPointer) -> PartiallyAppliedTerm

Given a TermPointer, yields the PartiallyAppliedTerm which is stored at that location within this InterpreterState (or, in the case of a primitive, within the containing Context)

Source

pub fn get_nonprimitive( &self, term_ptr: NonPrimitiveTermPointer, ) -> &PartiallyAppliedTerm

Given a NonPrimitiveTermPointer, yields the PartiallyAppliedTerm which is stored at that location within this InterpreterState.

Source

pub fn get_app_results_with_arg( &self, arg: &TermReference, ) -> Vec<TermApplicationResult>

Gets all currently-known TermApplicationResults which use the given TermReference argument.

Source

pub fn get_app_results_with_func( &self, func: TermPointer, ) -> Vec<TermApplicationResult>

Gets all currently-known TermApplicationResults which involve the function that the given TermPointer points to.

Source

pub fn get_app_results_with_result( &self, result_term: &TermReference, ) -> Vec<TermApplicationResult>

Gets all currently-known TermApplicationResults which had the given TermReference result.

Source

pub fn evaluate( &mut self, term_app: &TermApplication, ) -> (TermReference, NewlyEvaluatedTerms)

Evaluates the given TermApplication against this InterpreterState, assuming that the function pointed to in the TermApplication is a primitive. Yields a TermReference to the result of the evaluation, and a list of NewlyEvaluatedTerms for this InterpreterState which resulted from evaluating the application.

Source

pub fn ensure_every_type_has_a_term_on_init(&mut self) -> NewlyEvaluatedTerms

Convenience method that ensures that every type has at least one term, assuming that this InterpreterState was just-initialized. Returns NewlyEvaluatedTerms for evaluations that were performed as a result of this operation.

Source

pub fn new(ctxt: &'a Context) -> InterpreterState<'a>

Constructs a fresh InterpreterState operating within the given Context.

Auto Trait Implementations§

§

impl<'a> Freeze for InterpreterState<'a>

§

impl<'a> !RefUnwindSafe for InterpreterState<'a>

§

impl<'a> !Send for InterpreterState<'a>

§

impl<'a> !Sync for InterpreterState<'a>

§

impl<'a> Unpin for InterpreterState<'a>

§

impl<'a> !UnwindSafe for InterpreterState<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V