[−][src]Struct rusttyc::TypeChecker
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]
Key::Value: AbstractType + TryReifiable,
pub fn try_get_reified_type_table(
&mut self
) -> Vec<(TypeCheckKey<Key>, Result<<Key::Value as TryReifiable>::Reified, ReificationError>)>
[src]
&mut self
) -> Vec<(TypeCheckKey<Key>, Result<<Key::Value as TryReifiable>::Reified, ReificationError>)>
Returns a mapping of all registered abstract type nodes to their reification.
impl<Key: UnifyKey> TypeChecker<Key> where
Key::Value: AbstractType + Reifiable,
[src]
Key::Value: AbstractType + Reifiable,
pub fn get_reified_type_table(
&mut self
) -> Vec<(TypeCheckKey<Key>, <Key::Value as Reifiable>::Reified)>
[src]
&mut self
) -> Vec<(TypeCheckKey<Key>, <Key::Value as Reifiable>::Reified)>
Returns a mapping of all registered abstract type nodes to their reification.
impl<Key: EnaKey> TypeChecker<Key> where
Key::Value: AbstractType,
[src]
Key::Value: AbstractType,
impl<Key: EnaKey> TypeChecker<Key> where
Key::Value: AbstractType,
[src]
Key::Value: AbstractType,
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]
&mut self,
constr: TypeConstraint<Key>
) -> Result<(), <Key::Value as EnaValue>::Error>
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]
Key::Value: AbstractType,
Auto Trait Implementations
impl<Key> RefUnwindSafe for TypeChecker<Key> where
Key: RefUnwindSafe,
<Key as UnifyKey>::Value: RefUnwindSafe,
Key: RefUnwindSafe,
<Key as UnifyKey>::Value: RefUnwindSafe,
impl<Key> Send for TypeChecker<Key> where
Key: Send,
<Key as UnifyKey>::Value: Send,
Key: Send,
<Key as UnifyKey>::Value: Send,
impl<Key> Sync for TypeChecker<Key> where
Key: Sync,
<Key as UnifyKey>::Value: Sync,
Key: Sync,
<Key as UnifyKey>::Value: Sync,
impl<Key> Unpin for TypeChecker<Key> where
Key: Unpin,
<Key as UnifyKey>::Value: Unpin,
Key: Unpin,
<Key as UnifyKey>::Value: Unpin,
impl<Key> UnwindSafe for TypeChecker<Key> where
Key: UnwindSafe,
<Key as UnifyKey>::Value: UnwindSafe,
Key: UnwindSafe,
<Key as UnifyKey>::Value: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,