Starting to move pass_chain logic into codegen

This commit is contained in:
greg 2018-10-20 15:54:46 -07:00
parent d7baf065fb
commit ffe7deb00a

View File

@ -66,6 +66,13 @@ fn get_attribute_identifier(attr_name: &str, attrs: &Vec<Attribute>) -> Option<p
})
}
fn pass_chain_new(idents: Vec<Ident>) -> proc_macro2::TokenStream {
quote! {
let mut chain = pass_chain![self, options; #(#idents),* ];
chain(input)
}
}
#[proc_macro_derive(ProgrammingLanguageInterface,
attributes(LanguageName, SourceFileExtension, PipelineSteps, DocMethod, HandleCustomInterpreterDirectives))]
pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream {
@ -112,6 +119,8 @@ pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream
}
});
let pass_chain = pass_chain_new(pass_idents.collect());
let tokens = quote! {
use schala_repl::PassDescriptor;
impl ProgrammingLanguageInterface for #name {
@ -122,8 +131,8 @@ pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream
#file_ext.to_string()
}
fn execute_pipeline(&mut self, input: &str, options: &EvalOptions) -> FinishedComputation {
let mut chain = pass_chain![self, options; #(#pass_idents),* ];
chain(input)
#pass_chain
}
fn get_passes(&self) -> Vec<PassDescriptor> {
vec![ #(#pass_descriptors),* ]