Struct fetish_lib::interpreter_state::InterpreterState[][src]

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

impl<'a> InterpreterState<'a>[src]

pub fn get_context(&self) -> &Context[src]

Gets the Context that this InterpreterState operates within.

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

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.

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

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)

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

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

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

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

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

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

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

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

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

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.

pub fn ensure_every_type_has_a_term_on_init(&mut self) -> NewlyEvaluatedTerms[src]

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.

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

Constructs a fresh InterpreterState operating within the given Context.

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

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

pub fn vzip(self) -> V