[−][src]Struct cranelift_codegen_meta::cdsl::type_inference::TypeEnvironment
Class encapsulating the necessary bookkeeping for type inference.
Fields
vars: HashSet<VarIndex>
ranks: HashMap<TypeVar, TypeEnvRank>
equivalency_map: HashMap<TypeVar, TypeVar>
constraints: Vec<Constraint>
Methods
impl TypeEnvironment
[src]
fn new() -> Self
[src]
fn register(&mut self, var_index: VarIndex, var: &mut Var)
[src]
fn add_constraint(&mut self, constraint: Constraint)
[src]
pub fn get_equivalent(&self, tv: &TypeVar) -> TypeVar
[src]
Returns the canonical representative of the equivalency class of the given argument, or duplicates it if it's not there yet.
fn rank(&self, tv: &TypeVar) -> u8
[src]
Get the rank of tv in the partial order:
- TVs directly associated with a Var get their rank from the Var (see register()).
- Internally generated non-derived TVs implicitly get the lowest rank (0).
- Derived variables get their rank from their free typevar.
- Singletons have the highest rank.
- TVs associated with vars in a source pattern have a higher rank than TVs associated with temporary vars.
fn record_equivalent(&mut self, tv1: TypeVar, tv2: TypeVar)
[src]
Record the fact that the free tv1 is part of the same equivalence class as tv2. The canonical representative of the merged class is tv2's canonical representative.
pub fn free_typevars(&self, var_pool: &mut VarPool) -> Vec<TypeVar>
[src]
Get the free typevars in the current type environment.
fn normalize(&mut self, var_pool: &mut VarPool)
[src]
Normalize by collapsing any roots that don't correspond to a concrete type var AND have a single type var derived from them or equivalent to them.
e.g. if we have a root of the tree that looks like:
typeof_a typeof_b \ / typeof_x | half_width(1) | 1
we want to collapse the linear path between 1 and typeof_x. The resulting graph is:
typeof_a typeof_b \ / typeof_x
fn extract(self, var_pool: &mut VarPool) -> TypeEnvironment
[src]
Extract a clean type environment from self, that only mentions type vars associated with real variables.
Auto Trait Implementations
impl !RefUnwindSafe for TypeEnvironment
impl !Send for TypeEnvironment
impl !Sync for TypeEnvironment
impl Unpin for TypeEnvironment
impl !UnwindSafe for TypeEnvironment
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>,