Context

Struct Context 

Source
pub struct Context {
    pub type_info_directory: TypeInfoDirectory,
    pub space_info_directory: SpaceInfoDirectory,
    pub primitive_directory: PrimitiveDirectory,
}
Expand description

Stores interpreter-global context information, such as the collection of all types in the language, the collection of all primitives, and the definitions of their associated featurization maps. See TypeInfoDirectory, SpaceInfoDirectory, PrimitiveDirectory for these individual components.

Fields§

§type_info_directory: TypeInfoDirectory§space_info_directory: SpaceInfoDirectory§primitive_directory: PrimitiveDirectory

Implementations§

Source§

impl Context

Source

pub fn get_primitive( &self, primitive_term_pointer: PrimitiveTermPointer, ) -> &dyn FuncImpl

Given a PrimitiveTermPointer, yields the FuncImpl it references.

Source

pub fn get_feature_space_info(&self, type_id: TypeId) -> &FeatureSpaceInfo

Gets a reference to the FeatureSpaceInfo for the given TypeId.

Source

pub fn build_function_space_info( &self, arg_type_id: TypeId, ret_type_id: TypeId, ) -> FunctionSpaceInfo<'_>

Gets the FunctionSpaceInfo for functions going from the given arg_type_id to the given ret_type_id.

Source

pub fn get_function_space_info( &self, func_type_id: TypeId, ) -> FunctionSpaceInfo<'_>

Gets the FunctionSpaceInfo for the given function TypeId.

Source

pub fn get_func_type_id( &self, arg_type_id: TypeId, ret_type_id: TypeId, ) -> TypeId

Given the argument and result types for a function type, returns the TypeId of the corresponding function type, assuming that it exists.

Source

pub fn get_type(&self, id: TypeId) -> Type

Given a TypeId, yields the Type struct describing the type.

Source

pub fn has_func_type(&self, arg_type_id: TypeId, ret_type_id: TypeId) -> bool

Given the argument and result types for a function type, returns true iff the function type actually exists in the TypeInfoDirectory.

Source

pub fn get_application_type_ids(&self, id: TypeId) -> Vec<(TypeId, TypeId)>

Given a target type, yields the collection of all pairs (func_type_id, arg_type_id) in the TypeInfoDirectory for which the return type is the given target.

Source

pub fn get_total_num_types(&self) -> usize

Returns the total number of types registered in the TypeInfoDirectory.

Source

pub fn get_dimension(&self, vec_type_id: TypeId) -> usize

Given the TypeId of a vector type, yields the dimensionality of the corresponding vector space.

Source

pub fn get_arg_type_id(&self, func_type_id: TypeId) -> TypeId

Given the TypeId of a function type, yields the TypeId of the function’s argument type.

Source

pub fn get_ret_type_id(&self, func_type_id: TypeId) -> TypeId

Given the TypeId of a function type, yields the TypeId of the function’s return type.

Source

pub fn is_vector_type(&self, id: TypeId) -> bool

Given a TypeId, returns true if the underlying Type is a vector type, and false if it’s a function type instead.

Auto Trait Implementations§

§

impl Freeze for Context

§

impl !RefUnwindSafe for Context

§

impl !Send for Context

§

impl !Sync for Context

§

impl Unpin for Context

§

impl !UnwindSafe for Context

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