INNER CODE UNIT · Rust

import_offsets

c3rb3ru5d3d53c/binlex · crates/libvex/libvex-macros/src/lib.rs:28

pub fn import_offsets(item: TokenStream) -> TokenStream {
    let offsets = parse_macro_input!(item as ImportArgs);
    let mut output = quote!(
        use vex_sys::Int;
    );
    for reg in &offsets.items {
        // switch order of arguments to make the span of the output depend on the register.
        let offset = format_ident!("OFFSET_{1}_{0}", reg, offsets.arch);
        output = quote!(
            #output
            pub const #reg: Int = vex_sys::#offset as Int;
        );
    }
    // Some arches (MIPS) have lowercase register names.
    quote!(
        #[allow(non_upper_case_globals)]
        pub mod offset {
            #output

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…