fn dylink_registrar(&mut self, vi: &ast::ViewItem, path: Path, symbol: String) {
        // Make sure the path contains a / or the linker will search for it.
        let path = os::make_absolute(&path);

        let lib = match DynamicLibrary::open(Some(&path)) {
            Ok(lib) => lib,
            // this is fatal: there are almost certainly macros we need
            // inside this crate, so continue would spew "macro undefined"
            // errors
            Err(err) => self.sess.span_fatal(vi.span, err.as_slice())
        };

        unsafe {
            let registrar =
                match lib.symbol(symbol.as_slice()) {
                    Ok(registrar) => {
                        mem::transmute::<*mut u8,PluginRegistrarFun>(registrar)
                    }
                    // again fatal if we can't register macros
                    Err(err) => self.sess.span_fatal(vi.span, err.as_slice())
                };

            self.plugins.registrars.push(registrar);

            // Intentionally leak the dynamic library. We can't ever unload it
            // since the library can make things that will live arbitrarily long
            // (e.g. an @-box cycle or a task).
            mem::forget(lib);

        }
    }
// Dynamically link a registrar function into the compiler process.
Dynamically link a registrar function into the compiler process.
Dynamically link a registrar function into the compiler process .
fn dylink_registrar(&mut self, vi: &ast::ViewItem, path: Path, symbol: String) {
        // Make sure the path contains a / or the linker will search for it.
        let path = os::make_absolute(&path);
        let lib = match DynamicLibrary::open(Some(&path)) {
            Ok(lib) => lib,
            // this is fatal: there are almost certainly macros we need
            // inside this crate, so continue would spew "macro undefined"
            // errors
            Err(err) => self.sess.span_fatal(vi.span, err.as_slice())
        };
        unsafe {
            let registrar =
                match lib.symbol(symbol.as_slice()) {
                    Ok(registrar) => {
                        mem::transmute::<*mut u8,PluginRegistrarFun>(registrar)
                    }
                    // again fatal if we can't register macros
                    Err(err) => self.sess.span_fatal(vi.span, err.as_slice())
                };
            self.plugins.registrars.push(registrar);
            // Intentionally leak the dynamic library. We can't ever unload it
            // since the library can make things that will live arbitrarily long
            // (e.g. an @-box cycle or a task).
            mem::forget(lib);
        }
    }
fn dylink_registrar ( & mut self , vi : & ast :: ViewItem , path : Path , symbol : String ) { // Make sure the path contains a / or the linker will search for it. let path = os :: make_absolute ( & path ) ; let lib = match DynamicLibrary :: open ( Some ( & path ) ) { Ok ( lib ) => lib , // this is fatal: there are almost certainly macros we need // inside this crate, so continue would spew "macro undefined" // errors Err ( err ) => self . sess . span_fatal ( vi . span , err . as_slice ( ) ) } ; unsafe { let registrar = match lib . symbol ( symbol . as_slice ( ) ) { Ok ( registrar ) => { mem :: transmute :: < * mut u8 , PluginRegistrarFun > ( registrar ) } // again fatal if we can't register macros Err ( err ) => self . sess . span_fatal ( vi . span , err . as_slice ( ) ) } ; self . plugins . registrars . push ( registrar ) ; // Intentionally leak the dynamic library. We can't ever unload it // since the library can make things that will live arbitrarily long // (e.g. an @-box cycle or a task). mem :: forget ( lib ) ; } }
Dynamically link a registrar function into the compiler process.
Dynamically link a registrar function into the compiler process .
&mut self
vi
&ast::ViewItem
path
Path
symbol
String
&mut self
vi
&ast::ViewItem
path
Path
symbol
String