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§
Required Methods§
sourcefn add_match_equal(
&mut self,
a: Self::PatternId,
b: Self::PatternId,
ty: TypeId
)
fn add_match_equal( &mut self, a: Self::PatternId, b: Self::PatternId, ty: TypeId )
Match if a
and b
have equal values.
sourcefn add_match_int(&mut self, input: Self::PatternId, ty: TypeId, int_val: i128)
fn add_match_int(&mut self, input: Self::PatternId, ty: TypeId, int_val: i128)
Match if input
is the given integer constant.
sourcefn add_match_prim(&mut self, input: Self::PatternId, ty: TypeId, val: Sym)
fn add_match_prim(&mut self, input: Self::PatternId, ty: TypeId, val: Sym)
Match if input
is the given primitive constant.
sourcefn add_match_variant(
&mut self,
input: Self::PatternId,
input_ty: TypeId,
arg_tys: &[TypeId],
variant: VariantId
) -> Vec<Self::PatternId>
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
.
sourcefn add_extract(
&mut self,
input: Self::PatternId,
input_ty: TypeId,
output_tys: Vec<TypeId>,
term: TermId,
infallible: bool,
multi: bool
) -> 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>
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
.