Implement function-like procedural macros ( #[proc_macro])
This commit is contained in:
parent
4be034e622
commit
2fcbb48c72
10 changed files with 213 additions and 10 deletions
|
|
@ -586,7 +586,7 @@ impl<'a> CrateLoader<'a> {
|
|||
use proc_macro::__internal::Registry;
|
||||
use rustc_back::dynamic_lib::DynamicLibrary;
|
||||
use syntax_ext::deriving::custom::ProcMacroDerive;
|
||||
use syntax_ext::proc_macro_impl::AttrProcMacro;
|
||||
use syntax_ext::proc_macro_impl::{AttrProcMacro, BangProcMacro};
|
||||
|
||||
let path = match dylib {
|
||||
Some(dylib) => dylib,
|
||||
|
|
@ -630,6 +630,15 @@ impl<'a> CrateLoader<'a> {
|
|||
);
|
||||
self.0.push((Symbol::intern(name), Rc::new(expand)));
|
||||
}
|
||||
|
||||
fn register_bang_proc_macro(&mut self,
|
||||
name: &str,
|
||||
expand: fn(TokenStream) -> TokenStream) {
|
||||
let expand = SyntaxExtension::ProcMacro(
|
||||
Box::new(BangProcMacro { inner: expand })
|
||||
);
|
||||
self.0.push((Symbol::intern(name), Rc::new(expand)));
|
||||
}
|
||||
}
|
||||
|
||||
let mut my_registrar = MyRegistrar(Vec::new());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue