Trait cranelift_isle::sema::PatternVisitor

source ·
pub trait PatternVisitor {
    type PatternId: Copy;

    // Required methods
    fn add_match_equal(
        &mut self,
        a: Self::PatternId,
        b: Self::PatternId,
        ty: TypeId
    );
    fn add_match_int(
        &mut self,
        input: Self::PatternId,
        ty: TypeId,
        int_val: i128
    );
    fn add_match_prim(&mut self, input: Self::PatternId, ty: TypeId, val: Sym);
    fn add_match_variant(
        &mut self,
        input: Self::PatternId,
        input_ty: TypeId,
        arg_tys: &[TypeId],
        variant: VariantId
    ) -> Vec<Self::PatternId>;
    fn add_extract(
        &mut self,
        input: Self::PatternId,
        input_ty: TypeId,
        output_tys: Vec<TypeId>,
        term: TermId,
        infallible: bool,
        multi: bool
    ) -> Vec<Self::PatternId>;
}
Expand description

Visitor interface for Patterns. Visitors can assign an arbitrary identifier to each subpattern, which is threaded through to subsequent calls into the visitor.

Required Associated Types§

source

type PatternId: Copy

The type of subpattern identifiers.

Required Methods§

source

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

Match if a and b have equal values.

source

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

Match if input is the given integer constant.

source

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

Match if input is the given primitive constant.

source

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

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: Self::PatternId, input_ty: TypeId, output_tys: Vec<TypeId>, term: TermId, infallible: bool, multi: bool ) -> Vec<Self::PatternId>

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.

Implementors§