cranelift_isle::sema

Trait 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_bool(
        &mut self,
        input: Self::PatternId,
        ty: TypeId,
        bool_val: bool,
    );
    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_bool(&mut self, input: Self::PatternId, ty: TypeId, bool_val: bool)

Match if input is the given boolean constant.

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§