[][src]Struct rusttyc::TypeChecker

pub struct TypeChecker<Key: EnaKey> where
    Key::Value: AbstractType
{ /* fields omitted */ }

Represents a type checker. The main struct for the type checking procedure. It manages a set of abstract types in a lattice-like structure and perform a union-find procedure to derive the least concrete abstract type that satisfies a defined set of constraints. Each abstract type is referred to with a key assigned by the TypeChecker

The TypeChecker allows for the creation of keys and imposition of constraints on them, refer to TypeChecker::new_key(&mut self) and TypeChecker::impose(&mut self, constr: TypeConstraint<Key>), respectively.

Methods

impl<Key: UnifyKey> TypeChecker<Key> where
    Key::Value: AbstractType + TryReifiable
[src]

pub fn try_get_reified_type_table(
    &mut self
) -> Vec<(TypeCheckKey<Key>, Result<<Key::Value as TryReifiable>::Reified, ReificationError>)>
[src]

Returns a mapping of all registered abstract type nodes to their reification.

impl<Key: UnifyKey> TypeChecker<Key> where
    Key::Value: AbstractType + Reifiable
[src]

pub fn get_reified_type_table(
    &mut self
) -> Vec<(TypeCheckKey<Key>, <Key::Value as Reifiable>::Reified)>
[src]

Returns a mapping of all registered abstract type nodes to their reification.

impl<Key: EnaKey> TypeChecker<Key> where
    Key::Value: AbstractType
[src]

pub fn new() -> Self[src]

Creates a new, empty TypeChecker.

impl<Key: EnaKey> TypeChecker<Key> where
    Key::Value: AbstractType
[src]

pub fn get_type_table(&mut self) -> Vec<(TypeCheckKey<Key>, Key::Value)>[src]

Returns a view on the current state of self. Returns a mapping of all keys known to self to the Key::Value associated with it.

pub fn new_key(&mut self) -> TypeCheckKey<Key>[src]

Creates a new unconstrained variable that can be referred to using the returned TypeCheckKey. The current state of it can be accessed using TypeChecker::get_type(TypeCheckKey) and constraints can be imposed using TypeChecker::impose(TypeConstraint). TypeCheckKey provides means to create such TypeConstraints.

pub fn impose(
    &mut self,
    constr: TypeConstraint<Key>
) -> Result<(), <Key::Value as EnaValue>::Error>
[src]

Imposes constr on the current state of the type checking procedure. This may or may not change the abstract types of some keys. This process might entail that several values need to be met. The evaluation is lazy, i.e. it stops the entire process as soon as a single meet fails, leaving all other meet operations unattempted. This potentially shadows additional type errors!

pub fn get_type(&mut self, key: TypeCheckKey<Key>) -> Key::Value[src]

Returns the abstract type associated with key.

pub fn keys(&self) -> Iter<TypeCheckKey<Key>>[src]

Returns an iterator over all keys currently present in the type checking procedure.

pub fn snapshot(&mut self)[src]

Takes a snapshot and stores it internally. Can be rolled back via TypeChecker::rollback(&mut self) and committed via TypeChecker::commit_last_ss(&mut self). When external access to the snapshot is desired or necessary, refer to TypeChecker::take_snapshot(&mut self) -> Snapshot<...>.

pub fn take_snapshot(&mut self) -> Snapshot<InPlace<Key>>[src]

Takes and returns a snapshot that needs to be managed externally. Can be rolled back via TypeChecker::rollback_to(&mut self, Snapshot<...>) and committed via TypeChecker::commit_to(&mut self, Snapshot<...>). When external management is undesired or unnecessary, refer to TypeChecker::snapshot(&mut self).

pub fn commit_last_ss(&mut self)[src]

Commits to the last snapshot taken with TypeChecker::snapshot(&mut self). For committing to a specific snapshot, refer to TypeChecker::commit_to(&mut self, Snapshot<...>).

pub fn commit_to(&mut self, snapshot: Snapshot<InPlace<Key>>)[src]

Commits to snapshot. For committing to the last snapshot taken, refer to TypeChecker::commit_last_ss(&mut self).

pub fn rollback_to_last_ss(&mut self)[src]

Rolls back to the last snapshot taken with TypeChecker::snapshot(&mut self). For rolling back to a specific snapshot, refer to TypeChecker::rollback_to(&mut self, Snapshot<...>).

pub fn rollback_to(&mut self, snapshot: Snapshot<InPlace<Key>>)[src]

Rolls back to snapshot. For rolling back to the last snapshot taken, refer to TypeChecker::rollback_to(&mut self, Snapshot<...>).

Trait Implementations

impl<Key: EnaKey> Default for TypeChecker<Key> where
    Key::Value: AbstractType
[src]

Auto Trait Implementations

impl<Key> RefUnwindSafe for TypeChecker<Key> where
    Key: RefUnwindSafe,
    <Key as UnifyKey>::Value: RefUnwindSafe

impl<Key> Send for TypeChecker<Key> where
    Key: Send,
    <Key as UnifyKey>::Value: Send

impl<Key> Sync for TypeChecker<Key> where
    Key: Sync,
    <Key as UnifyKey>::Value: Sync

impl<Key> Unpin for TypeChecker<Key> where
    Key: Unpin,
    <Key as UnifyKey>::Value: Unpin

impl<Key> UnwindSafe for TypeChecker<Key> where
    Key: UnwindSafe,
    <Key as UnifyKey>::Value: UnwindSafe

Blanket Implementations

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

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

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

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

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

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.

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.