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).
impl<'p, 'a> Ctx<'p, 'a>
§Elaboration
Most of this is a very direct translation of the specification (section 3.4 Type Elaboration).
pub fn elab_component<'c>( &'c mut self, decls: &[ComponentTypeDeclaration<'a>], ) -> Result<Component<'a>, Error<'a>>
Source§impl<'p, 'a> Ctx<'p, 'a>
impl<'p, 'a> Ctx<'p, 'a>
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.
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.
pub fn subtype_value<'r>( &self, vt1: &'r Value<'a>, vt2: &'r Value<'a>, ) -> Result<(), Error<'a>>
pub fn subtype_value_option<'r>( &self, vt1: &'r Option<Value<'a>>, vt2: &'r Option<Value<'a>>, ) -> Result<(), Error<'a>>
pub fn subtype_var_var<'r>( &self, v1: &'r Tyvar, v2: &'r Tyvar, ) -> Result<(), Error<'a>>
pub fn subtype_var_resource<'r>( &self, v1: &'r Tyvar, rid2: &'r ResourceId, ) -> Result<(), Error<'a>>
pub fn subtype_resource_var<'r>( &self, rid1: &'r ResourceId, v2: &'r Tyvar, ) -> Result<(), Error<'a>>
pub fn subtype_handleable<'r>( &self, ht1: &'r Handleable, ht2: &'r Handleable, ) -> Result<(), Error<'a>>
pub fn subtype_func<'r>( &self, _ft1: &'r Func<'a>, _ft2: &'r Func<'a>, ) -> Result<(), Error<'a>>
pub fn subtype_qualified_instance<'r>( &self, _qi1: &'r QualifiedInstance<'a>, _qi2: &'r QualifiedInstance<'a>, ) -> Result<(), Error<'a>>
pub fn subtype_component<'r>( &self, _ct1: &'r Component<'a>, _ct2: &'r Component<'a>, ) -> Result<(), Error<'a>>
pub fn subtype_defined<'r>( &self, dt1: &'r Defined<'a>, dt2: &'r Defined<'a>, ) -> Result<(), Error<'a>>
pub fn subtype_handleable_is_resource<'r>( &self, ht: &'r Handleable, ) -> Result<(), Error<'a>>
Source§impl<'p, 'a> Ctx<'p, 'a>
impl<'p, 'a> Ctx<'p, 'a>
Sourcepub fn var_bound<'c>(&'c self, tv: &Tyvar) -> &'c TypeBound<'a>
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.
Sourcepub fn resolve_tyvar<'c>(&'c self, v: &Tyvar) -> ResolvedTyvar<'a>
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.
Sourcepub fn bound_to_evars(
&mut self,
origin: Option<&'a str>,
vs: &[BoundedTyvar<'a>],
) -> Opening
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
Sourcepub fn bound_to_uvars(
&mut self,
origin: Option<&'a str>,
vs: &[BoundedTyvar<'a>],
imported: bool,
) -> Opening
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).
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).
pub fn wf_defined<'r>( &'r self, p: DefinedTypePosition, dt: &'r Defined<'a>, ) -> Result<(), Error<'a>>
pub fn wf_qualified_instance<'r>( &self, p: DefinedTypePosition, qit: &'r QualifiedInstance<'a>, ) -> Result<(), Error<'a>>
pub fn wf_component<'r>( &self, p: DefinedTypePosition, ct: &'r Component<'a>, ) -> Result<(), Error<'a>>
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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