diff options
author | 2020-12-10 20:33:13 +0100 | |
---|---|---|
committer | 2020-12-10 20:33:13 +0100 | |
commit | 97a48983d2859740983cbf342e1287182426ed44 (patch) | |
tree | 77c9fb55d1ad9cd3fa2e9343397c56ba47928684 /macros/src/codegen/init.rs | |
parent | b23bb1192c8dc1f2e8f157db2147b1737abc1033 (diff) | |
download | rtic-97a48983d2859740983cbf342e1287182426ed44.tar.gz rtic-97a48983d2859740983cbf342e1287182426ed44.tar.zst rtic-97a48983d2859740983cbf342e1287182426ed44.zip |
More work
Diffstat (limited to 'macros/src/codegen/init.rs')
-rw-r--r-- | macros/src/codegen/init.rs | 53 |
1 files changed, 3 insertions, 50 deletions
diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index 6b57add1..66c3bc4e 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -5,7 +5,7 @@ use rtic_syntax::{ast::App, Context}; use crate::{ analyze::Analysis, check::Extra, - codegen::{locals, module, resources_struct, util}, + codegen::{locals, module, resources_struct}, }; type CodegenResult = ( @@ -32,50 +32,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult { let mut root_init = vec![]; - let late_fields = analysis - .late_resources - .iter() - .flat_map(|resources| { - resources.iter().map(|name| { - let ty = &app.late_resources[name].ty; - let cfgs = &app.late_resources[name].cfgs; - - quote!( - #(#cfgs)* - pub #name: #ty - ) - }) - }) - .collect::<Vec<_>>(); - - let late_resources = util::late_resources_ident(&name); - - root_init.push(quote!( - /// Resources initialized at runtime - #[allow(non_snake_case)] - pub struct #late_resources { - #(#late_fields),* - } - )); - - let monotonic_types: Vec<_> = app - .monotonics - .iter() - .map(|(_, monotonic)| { - let mono = &monotonic.ty; - quote! {#mono} - }) - .collect(); - let monotonics = util::monotonics_ident(&name); - - root_init.push(quote!( - /// Monotonics used by the system - #[allow(non_snake_case)] - pub struct #monotonics( - #(#monotonic_types),* - ); - )); - let mut locals_pat = None; let mut locals_new = None; if !init.locals.is_empty() { @@ -91,15 +47,12 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult { let stmts = &init.stmts; let locals_pat = locals_pat.iter(); - let mut user_init_return = vec![quote! {#name::LateResources}]; - if !app.monotonics.is_empty() { - user_init_return.push(quote! {#name::Monotonics}); - } + let user_init_return = quote! {#name::LateResources, #name::Monotonics}; let user_init = Some(quote!( #(#attrs)* #[allow(non_snake_case)] - fn #name(#(#locals_pat,)* #context: #name::Context) -> (#(#user_init_return,)*) { + fn #name(#(#locals_pat,)* #context: #name::Context) -> (#user_init_return) { #(#stmts)* } )); |