Trait Pass

Source
pub trait Pass {
    type Input<'a>;
    type Output<'a>;
    type Error;

    // Required method
    fn run<'a>(
        &mut self,
        input: Self::Input<'a>,
    ) -> Result<Self::Output<'a>, Self::Error>;

    // Provided method
    fn chain<P, E>(self, pass: P) -> Chain<Self, P>
       where Self: Sized,
             E: From<Self::Error>,
             P: for<'a> Pass<Input<'a> = Self::Output<'a>, Error = E> { ... }
}
Expand description

This trait represents anything that can be run as a pass.

Passes operate on an input value, and return either the same type, or a new type, depending on the nature of the pass.

Implementations may represent a single pass, or an arbitrary number of passes that will be run as a single unit.

Functions are valid implementations of Pass as long as their signature is fn<I, O, E>(I) -> Result<O, E>.

Required Associated Types§

Source

type Input<'a>

Source

type Output<'a>

Source

type Error

Required Methods§

Source

fn run<'a>( &mut self, input: Self::Input<'a>, ) -> Result<Self::Output<'a>, Self::Error>

Runs the pass on the given input

Errors should be reported via the registered error handler, Passes should return Err to signal that the pass has failed and compilation should be aborted

Provided Methods§

Source

fn chain<P, E>(self, pass: P) -> Chain<Self, P>
where Self: Sized, E: From<Self::Error>, P: for<'a> Pass<Input<'a> = Self::Output<'a>, Error = E>,

Chains two passes together to form a new, fused pass

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Pass for Inlining<'_>

Source§

type Input<'a> = Mir

Source§

type Output<'a> = Mir

Source§

type Error = CompileError

Source§

fn run<'a>( &mut self, ir: <Inlining<'_> as Pass>::Input<'a>, ) -> Result<<Inlining<'_> as Pass>::Output<'a>, <Inlining<'_> as Pass>::Error>

Source§

impl Pass for AstToMir<'_>

Source§

type Input<'a> = Program

Source§

type Output<'a> = Mir

Source§

type Error = CompileError

Source§

fn run<'a>( &mut self, program: <AstToMir<'_> as Pass>::Input<'a>, ) -> Result<<AstToMir<'_> as Pass>::Output<'a>, <AstToMir<'_> as Pass>::Error>

Source§

impl Pass for Unrolling<'_>

Source§

type Input<'a> = Mir

Source§

type Output<'a> = Mir

Source§

type Error = CompileError

Source§

fn run<'a>( &mut self, ir: <Unrolling<'_> as Pass>::Input<'a>, ) -> Result<<Unrolling<'_> as Pass>::Output<'a>, <Unrolling<'_> as Pass>::Error>

Source§

impl<P, T, U, E> Pass for &mut P
where P: for<'a> Pass<Input<'a> = T, Output<'a> = U, Error = E>,

Source§

type Input<'a> = T

Source§

type Output<'a> = U

Source§

type Error = E

Source§

fn run<'a>( &mut self, input: <&mut P as Pass>::Input<'a>, ) -> Result<<&mut P as Pass>::Output<'a>, <&mut P as Pass>::Error>

Source§

impl<P, T, U, E> Pass for Box<P>
where P: for<'a> Pass<Input<'a> = T, Output<'a> = U, Error = E> + ?Sized,

Source§

type Input<'a> = T

Source§

type Output<'a> = U

Source§

type Error = E

Source§

fn run<'a>( &mut self, input: <Box<P> as Pass>::Input<'a>, ) -> Result<<Box<P> as Pass>::Output<'a>, <Box<P> as Pass>::Error>

Source§

impl<T, U, E> Pass for dyn FnMut(T) -> Result<U, E>

Source§

type Input<'a> = T

Source§

type Output<'a> = U

Source§

type Error = E

Source§

fn run<'a>( &mut self, input: <dyn FnMut(T) -> Result<U, E> as Pass>::Input<'a>, ) -> Result<<dyn FnMut(T) -> Result<U, E> as Pass>::Output<'a>, <dyn FnMut(T) -> Result<U, E> as Pass>::Error>

Implementors§

Source§

impl Pass for AstToAir<'_>

Source§

impl Pass for BusOpExpand<'_>

Source§

impl Pass for MirToAir<'_>

Source§

impl Pass for ConstantPropagation<'_>

Source§

impl Pass for air_script::transforms::Inlining<'_>

Source§

impl<A, B, AE, BE> Pass for Chain<A, B>
where A: for<'a> Pass<Error = AE>, B: for<'a> Pass<Input<'a> = <A as Pass>::Output<'a>, Error = BE>, BE: From<AE>,

Source§

type Input<'a> = <A as Pass>::Input<'a>

Source§

type Output<'a> = <B as Pass>::Output<'a>

Source§

type Error = <B as Pass>::Error