pub struct PatternSequence {
    pub insts: Vec<PatternInst>,
}
Expand description

A linear sequence of instructions that match on and destructure an argument. A pattern is fallible (may not match). If it does not fail, its result consists of the values produced by the PatternInsts, which may be used by a subsequent Expr.

Fields§

§insts: Vec<PatternInst>

Instruction sequence for pattern.

InstId indexes into this sequence for Value::Pattern values.

Trait Implementations§

source§

impl Clone for PatternSequence

source§

fn clone(&self) -> PatternSequence

Returns a copy 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 Debug for PatternSequence

source§

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

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

impl Default for PatternSequence

source§

fn default() -> PatternSequence

Returns the “default value” for a type. Read more
source§

impl Hash for PatternSequence

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<PatternSequence> for PatternSequence

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PatternVisitor for PatternSequence

§

type PatternId = Value

The type of subpattern identifiers.
source§

fn add_match_equal(&mut self, a: Value, b: Value, ty: TypeId)

Match if a and b have equal values.
source§

fn add_match_int(&mut self, input: Value, ty: TypeId, int_val: i128)

Match if input is the given integer constant.
source§

fn add_match_prim(&mut self, input: Value, ty: TypeId, val: Sym)

Match if input is the given primitive constant.
source§

fn add_match_variant( &mut self, input: Value, input_ty: TypeId, arg_tys: &[TypeId], variant: VariantId ) -> Vec<Value>

Match if input is the given enum variant. Returns an identifier for each field within the enum variant. The length of the return list must equal the length of arg_tys.
source§

fn add_extract( &mut self, input: Value, input_ty: TypeId, output_tys: Vec<TypeId>, term: TermId, infallible: bool, multi: bool ) -> Vec<Value>

Match if the given external extractor succeeds on input. Returns an identifier for each return value from the external extractor. The length of the return list must equal the length of output_tys.
source§

impl RuleVisitor for PatternSequence

§

type PatternVisitor = PatternSequence

The type of pattern visitors constructed by RuleVisitor::add_pattern.
§

type ExprVisitor = ExprSequence

The type of expression visitors constructed by RuleVisitor::add_expr.
§

type Expr = ReturnExpr

The type returned from RuleVisitor::add_expr, which may be exchanged for a subpattern identifier using RuleVisitor::expr_as_pattern.
source§

fn add_arg(&mut self, index: usize, ty: TypeId) -> Value

Visit one of the arguments to the top-level pattern.
source§

fn add_pattern<F: FnOnce(&mut Self)>(&mut self, visitor: F)

Visit a pattern, used once for the rule’s left-hand side and once for each if-let. You can determine which part of the rule the pattern comes from based on whether the PatternId passed to the first call to this visitor came from add_arg or expr_as_pattern.
source§

fn add_expr<F>(&mut self, visitor: F) -> ReturnExprwhere F: FnOnce(&mut ExprSequence) -> VisitedExpr<ExprSequence>,

Visit an expression, used once for each if-let and once for the rule’s right-hand side.
source§

fn expr_as_pattern(&mut self, expr: ReturnExpr) -> Value

Given an expression from RuleVisitor::add_expr, return an identifier that can be used with a pattern visitor in RuleVisitor::add_pattern.
source§

fn pattern_as_expr(&mut self, pattern: Value) -> Value

Given an identifier from the pattern visitor, return an identifier that can be used with the expression visitor.
source§

impl Eq for PatternSequence

source§

impl StructuralEq for PatternSequence

source§

impl StructuralPartialEq for PatternSequence

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.