Ctx

Struct Ctx 

Source
pub struct Ctx<'p, 'a> {
    pub parent: Option<&'p Ctx<'p, 'a>>,
    pub outer_boundary: bool,
    pub core: CoreCtx<'a>,
    pub uvars: Vec<(BoundedTyvar<'a>, bool)>,
    pub evars: Vec<(BoundedTyvar<'a>, Option<Defined<'a>>)>,
    pub rtypes: Vec<Resource>,
    pub types: Vec<Defined<'a>>,
    pub components: Vec<Component<'a>>,
    pub instances: Vec<Instance<'a>>,
    pub funcs: Vec<Func<'a>>,
}
Expand description

gamma in the specification

Fields§

§parent: Option<&'p Ctx<'p, 'a>>§outer_boundary: bool§core: CoreCtx<'a>§uvars: Vec<(BoundedTyvar<'a>, bool)>

Universally-quantified variables, specifying for each the known bound and whether or not it was imported. Uvars can come from imports or component instantiations; only the imported ones can be allowed to escape in the type of a components exports/imports, since only those can be named outside of the component itself.

§evars: Vec<(BoundedTyvar<'a>, Option<Defined<'a>>)>

Existentially-quantified variables, specifying for each the known bound and, if it was locally defined, the type which instantiates it.

§rtypes: Vec<Resource>§types: Vec<Defined<'a>>§components: Vec<Component<'a>>§instances: Vec<Instance<'a>>§funcs: Vec<Func<'a>>

Implementations§

Source§

impl<'p, 'a> Ctx<'p, 'a>

§Elaboration

Most of this is a very direct translation of the specification (section 3.4 Type Elaboration).

Source

pub fn elab_component<'c>( &'c mut self, decls: &[ComponentTypeDeclaration<'a>], ) -> Result<Component<'a>, Error<'a>>

Source§

impl<'p, 'a> Ctx<'p, 'a>

Source

pub fn new<'c>(parent: Option<&'p Ctx<'c, 'a>>, outer_boundary: bool) -> Self

Source§

impl<'p, 'a> Ctx<'p, 'a>

Source

pub fn parents<'i>(&'i self) -> CtxParentIterator<'i, 'p, 'a>

Source§

impl<'p, 'a> Ctx<'p, 'a>

§Subtyping

Most of this is a very direct translation of the subset of the OCaml reference interpreter that we need here. Most of the bits with variables and instantiation that require being quite careful are not involved here, since during the elaboration that we are doing we never need to fully subtype entire component types, which makes this quite a bit simpler.

Source

pub fn subtype_value<'r>( &self, vt1: &'r Value<'a>, vt2: &'r Value<'a>, ) -> Result<(), Error<'a>>

Source

pub fn subtype_value_option<'r>( &self, vt1: &'r Option<Value<'a>>, vt2: &'r Option<Value<'a>>, ) -> Result<(), Error<'a>>

Source

pub fn subtype_var_var<'r>( &self, v1: &'r Tyvar, v2: &'r Tyvar, ) -> Result<(), Error<'a>>

Source

pub fn subtype_var_resource<'r>( &self, v1: &'r Tyvar, rid2: &'r ResourceId, ) -> Result<(), Error<'a>>

Source

pub fn subtype_resource_var<'r>( &self, rid1: &'r ResourceId, v2: &'r Tyvar, ) -> Result<(), Error<'a>>

Source

pub fn subtype_handleable<'r>( &self, ht1: &'r Handleable, ht2: &'r Handleable, ) -> Result<(), Error<'a>>

Source

pub fn subtype_func<'r>( &self, _ft1: &'r Func<'a>, _ft2: &'r Func<'a>, ) -> Result<(), Error<'a>>

Source

pub fn subtype_qualified_instance<'r>( &self, _qi1: &'r QualifiedInstance<'a>, _qi2: &'r QualifiedInstance<'a>, ) -> Result<(), Error<'a>>

Source

pub fn subtype_component<'r>( &self, _ct1: &'r Component<'a>, _ct2: &'r Component<'a>, ) -> Result<(), Error<'a>>

Source

pub fn subtype_defined<'r>( &self, dt1: &'r Defined<'a>, dt2: &'r Defined<'a>, ) -> Result<(), Error<'a>>

Source

pub fn subtype_handleable_is_resource<'r>( &self, ht: &'r Handleable, ) -> Result<(), Error<'a>>

Source§

impl<'p, 'a> Ctx<'p, 'a>

Source

pub fn var_bound<'c>(&'c self, tv: &Tyvar) -> &'c TypeBound<'a>

Find a bound for the given free tyvar. Panics if given a TV_bound; by the time you call this, you should have used bound_to_[e/u]var.

Source

pub fn resolve_tyvar<'c>(&'c self, v: &Tyvar) -> ResolvedTyvar<'a>

Try really hard to resolve a tyvar to a definite type or a descriptive bound.

Source

pub fn bound_to_evars( &mut self, origin: Option<&'a str>, vs: &[BoundedTyvar<'a>], ) -> Opening

Modify the context to move the given variables into it as existential variables and compute a substitution that replaces bound variable references to them with free variable references

Source

pub fn bound_to_uvars( &mut self, origin: Option<&'a str>, vs: &[BoundedTyvar<'a>], imported: bool, ) -> Opening

Modify the context to move the given variables into it as universal variables and compute a substitution that replaces bound variable references to them with free variable references

Source§

impl<'p, 'a> Ctx<'p, 'a>

§Well-formedness

Most of this is a very direct translation of the specification (Well-formedness subsections of section 3.4 Type Elaboration).

Source

pub fn wf_defined<'r>( &'r self, p: DefinedTypePosition, dt: &'r Defined<'a>, ) -> Result<(), Error<'a>>

Source

pub fn wf_qualified_instance<'r>( &self, p: DefinedTypePosition, qit: &'r QualifiedInstance<'a>, ) -> Result<(), Error<'a>>

Source

pub fn wf_component<'r>( &self, p: DefinedTypePosition, ct: &'r Component<'a>, ) -> Result<(), Error<'a>>

Trait Implementations§

Source§

impl<'p, 'a> Clone for Ctx<'p, 'a>

Source§

fn clone(&self) -> Ctx<'p, 'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'p, 'a> Debug for Ctx<'p, 'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'p, 'a> Freeze for Ctx<'p, 'a>

§

impl<'p, 'a> RefUnwindSafe for Ctx<'p, 'a>

§

impl<'p, 'a> Send for Ctx<'p, 'a>

§

impl<'p, 'a> Sync for Ctx<'p, 'a>

§

impl<'p, 'a> Unpin for Ctx<'p, 'a>

§

impl<'p, 'a> UnwindSafe for Ctx<'p, 'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.