Starting to move pass_chain logic into codegen
This commit is contained in:
parent
d7baf065fb
commit
ffe7deb00a
@ -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,
|
#[proc_macro_derive(ProgrammingLanguageInterface,
|
||||||
attributes(LanguageName, SourceFileExtension, PipelineSteps, DocMethod, HandleCustomInterpreterDirectives))]
|
attributes(LanguageName, SourceFileExtension, PipelineSteps, DocMethod, HandleCustomInterpreterDirectives))]
|
||||||
pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream {
|
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! {
|
let tokens = quote! {
|
||||||
use schala_repl::PassDescriptor;
|
use schala_repl::PassDescriptor;
|
||||||
impl ProgrammingLanguageInterface for #name {
|
impl ProgrammingLanguageInterface for #name {
|
||||||
@ -122,8 +131,8 @@ pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream
|
|||||||
#file_ext.to_string()
|
#file_ext.to_string()
|
||||||
}
|
}
|
||||||
fn execute_pipeline(&mut self, input: &str, options: &EvalOptions) -> FinishedComputation {
|
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> {
|
fn get_passes(&self) -> Vec<PassDescriptor> {
|
||||||
vec![ #(#pass_descriptors),* ]
|
vec![ #(#pass_descriptors),* ]
|
||||||
|
Loading…
Reference in New Issue
Block a user