Skip to main content

Binding

Enum Binding 

Source
pub enum Binding {
Show 14 variants ConstBool { val: bool, ty: TypeId, }, ConstInt { val: i128, ty: TypeId, }, ConstPrim { val: Sym, }, Argument { index: TupleIndex, }, Extractor { term: TermId, parameter: BindingId, }, Constructor { term: TermId, parameters: Box<[BindingId]>, instance: u32, }, Iterator { source: BindingId, }, MakeVariant { ty: TypeId, variant: VariantId, fields: Box<[BindingId]>, }, MatchVariant { source: BindingId, variant: VariantId, field: TupleIndex, }, MakeStruct { ty: TypeId, fields: Box<[BindingId]>, }, ExtractStruct { source: BindingId, field: TupleIndex, }, MakeSome { inner: BindingId, }, MatchSome { source: BindingId, }, MatchTuple { source: BindingId, field: TupleIndex, },
}
Expand description

Bindings are anything which can be bound to a variable name in Rust. This includes expressions, such as constants or function calls; but it also includes names bound in pattern matches.

Variants§

§

ConstBool

Evaluates to the given boolean literal.

Fields

§val: bool

The constant value.

§ty: TypeId

The constant’s type.

§

ConstInt

Evaluates to the given integer literal.

Fields

§val: i128

The constant value.

§ty: TypeId

The constant’s type. Unsigned types preserve the representation of val, not its value.

§

ConstPrim

Evaluates to the given primitive Rust value.

Fields

§val: Sym

The constant value.

§

Argument

One of the arguments to the top-level function.

Fields

§index: TupleIndex

Which of the function’s arguments is this?

§

Extractor

The result of calling an external extractor.

Fields

§term: TermId

Which extractor should be called?

§parameter: BindingId

What expression should be passed to the extractor?

§

Constructor

The result of calling an external constructor.

Fields

§term: TermId

Which constructor should be called?

§parameters: Box<[BindingId]>

What expressions should be passed to the constructor?

§instance: u32

For impure constructors, a unique number for each use of this term. Always 0 for pure constructors.

§

Iterator

The result of getting one value from a multi-constructor or multi-extractor.

Fields

§source: BindingId

Which expression produced the iterator that this consumes?

§

MakeVariant

The result of constructing an enum variant.

Fields

§ty: TypeId

Which enum type should be constructed?

§variant: VariantId

Which variant of that enum should be constructed?

§fields: Box<[BindingId]>

What expressions should be provided for this variant’s fields?

§

MatchVariant

Pattern-match one of the previous bindings against an enum variant and produce a new binding from one of its fields. There must be a corresponding Constraint::Variant for each source/variant pair that appears in some MatchVariant binding.

Fields

§source: BindingId

Which binding is being matched?

§variant: VariantId

Which enum variant are we pulling binding sites from? This is somewhat redundant with information in a corresponding Constraint. However, it must be here so that different enum variants aren’t hash-consed into the same binding site.

§field: TupleIndex

Which field of this enum variant are we projecting out? Although ISLE uses named fields, we track them by index for constant-time comparisons. The sema::TypeEnv can be used to get the field names.

§

MakeStruct

The result of constructing a struct.

Fields

§ty: TypeId

Which struct type should be constructed?

§fields: Box<[BindingId]>

What expressions should be provided for this struct’s fields?

§

ExtractStruct

Extract the fields of the struct from one of the previous bindings to produce a new binding from one of its fields. There must be a corresponding Constraint::Struct for each source/variant pair that appears in some ExtractStruct binding.

Fields

§source: BindingId

Which binding is being matched?

§field: TupleIndex

Which field of this struct are we projecting out? Although ISLE uses named fields, we track them by index for constant-time comparisons. The sema::TypeEnv can be used to get the field names.

§

MakeSome

The result of constructing an Option::Some variant.

Fields

§inner: BindingId

Contained expression.

§

MatchSome

Pattern-match one of the previous bindings against Option::Some and produce a new binding from its contents. There must be a corresponding Constraint::Some for each source that appears in a MatchSome binding. (This currently only happens with external extractors.)

Fields

§source: BindingId

Which binding is being matched?

§

MatchTuple

Pattern-match one of the previous bindings against a tuple and produce a new binding from one of its fields. This is an irrefutable pattern match so there is no corresponding Constraint. (This currently only happens with external extractors.)

Fields

§source: BindingId

Which binding is being matched?

§field: TupleIndex

Which tuple field are we projecting out?

Implementations§

Source§

impl Binding

Source

pub fn sources(&self) -> &[BindingId]

Returns the binding sites which must be evaluated before this binding.

Source

pub fn term(&self, tyenv: &TypeEnv, termenv: &TermEnv) -> Option<TermId>

Returns the term referenced by this binding.

Trait Implementations§

Source§

impl Clone for Binding

Source§

fn clone(&self) -> Binding

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Binding

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Binding

Source§

impl Hash for Binding

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Binding

Source§

fn eq(&self, other: &Binding) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Binding

Auto Trait Implementations§

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> 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.