Sha256: 15899c5462790fd1508024dc52017fea1bdef65608fecbfc9baca1c478ebd7eb

Contents?: true

Size: 1.27 KB

Versions: 17

Compression:

Stored size: 1.27 KB

Contents

mod multi_extractor;

use multi_extractor::{ContextIter, IntoContextIter};

const MAX_ISLE_RETURNS: usize = 100;

#[derive(Clone)]
pub enum A {
    B,
    C,
}

#[derive(Default)]
struct It {
    i: u32,
    arg: u32,
}

impl ContextIter for It {
    type Context = Context;
    type Output = (A, u32);
    fn next(&mut self, _ctx: &mut Self::Context) -> Option<Self::Output> {
        if self.i >= 32 {
            None
        } else {
            let idx = self.i;
            self.i += 1;
            let a = if self.arg & (1u32 << idx) != 0 {
                A::B
            } else {
                A::C
            };
            Some((a, idx))
        }
    }
}

impl IntoContextIter for It {
    type Context = Context;
    type IntoIter = It;
    type Output = (A, u32);
    fn into_context_iter(self) -> It {
        self
    }
}

struct Context;
impl multi_extractor::Context for Context {
    type e1_etor_returns = It;
    fn e1_etor(&mut self, arg0: u32, returns: &mut It) {
        returns.i = 0;
        returns.arg = arg0;
    }
}

fn main() {
    let mut ctx = Context;
    let mut x = vec![];
    multi_extractor::constructor_Rule(&mut ctx, 0xf0, &mut x);
    let mut y = vec![];
    multi_extractor::constructor_Rule(&mut ctx, 0, &mut y);
    println!("x = {:?} y = {:?}", x, y);
}

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/cranelift-isle-0.116.0/isle_examples/link/multi_extractor_main.rs
wasmtime-28.0.0 ./ext/cargo-vendor/cranelift-isle-0.115.0/isle_examples/link/multi_extractor_main.rs
wasmtime-27.0.0 ./ext/cargo-vendor/cranelift-isle-0.114.0/isle_examples/link/multi_extractor_main.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cranelift-isle-0.113.0/isle_examples/link/multi_extractor_main.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cranelift-isle-0.112.2/isle_examples/link/multi_extractor_main.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cranelift-isle-0.112.1/isle_examples/link/multi_extractor_main.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cranelift-isle-0.112.0/isle_examples/link/multi_extractor_main.rs
wasmtime-24.0.0 ./ext/cargo-vendor/cranelift-isle-0.111.0/isle_examples/link/multi_extractor_main.rs
wasmtime-23.0.2 ./ext/cargo-vendor/cranelift-isle-0.110.2/isle_examples/link/multi_extractor_main.rs
wasmtime-22.0.0 ./ext/cargo-vendor/cranelift-isle-0.109.0/isle_examples/link/multi_extractor_main.rs
wasmtime-21.0.1 ./ext/cargo-vendor/cranelift-isle-0.108.1/isle_examples/link/multi_extractor_main.rs
wasmtime-20.0.2 ./ext/cargo-vendor/cranelift-isle-0.107.2/isle_examples/link/multi_extractor_main.rs
wasmtime-20.0.0 ./ext/cargo-vendor/cranelift-isle-0.107.2/isle_examples/link/multi_extractor_main.rs
wasmtime-18.0.3 ./ext/cargo-vendor/cranelift-isle-0.105.3/isle_examples/link/multi_extractor_main.rs
wasmtime-17.0.1 ./ext/cargo-vendor/cranelift-isle-0.104.1/isle_examples/link/multi_extractor_main.rs
wasmtime-17.0.0 ./ext/cargo-vendor/cranelift-isle-0.104.0/isle_examples/link/multi_extractor_main.rs
wasmtime-16.0.0 ./ext/cargo-vendor/cranelift-isle-0.103.0/isle_examples/link/multi_extractor_main.rs