From 46bf583cc21bd8fa34e3163149b4327fcc08057e Mon Sep 17 00:00:00 2001 From: Henrik Tjäder Date: Tue, 19 May 2020 19:03:19 +0000 Subject: Handle user hardware and software tasks and some resources --- macros/src/codegen/hardware_tasks.rs | 19 ++++++++++++++++++- macros/src/codegen/resources.rs | 12 +++++++++++- macros/src/codegen/software_tasks.rs | 18 +++++++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) (limited to 'macros/src/codegen') diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index 7f14b5e1..4f60876a 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -23,10 +23,13 @@ pub fn codegen( Vec, // user_hardware_tasks -- the `#[task]` functions written by the user Vec, + // user_hardware_tasks_imports -- the imports for `#[task]` functions written by the user + Vec, ) { let mut const_app = vec![]; let mut root = vec![]; let mut user_tasks = vec![]; + let mut hardware_tasks_imports = vec![]; for (name, task) in &app.hardware_tasks { let (let_instant, instant) = if app.uses_schedule() { @@ -78,6 +81,13 @@ pub fn codegen( analysis, ); + // Add resources to imports + let name_res = format_ident!("{}Resources", name); + hardware_tasks_imports.push(quote!( + #[allow(non_snake_case)] + use super::#name_res; + )); + root.push(item); const_app.push(constructor); @@ -112,7 +122,14 @@ pub fn codegen( #(#stmts)* } )); + + hardware_tasks_imports.push(quote!( + #(#attrs)* + #[allow(non_snake_case)] + use super::#name; + )); + } - (const_app, root, user_tasks) + (const_app, root, user_tasks, hardware_tasks_imports) } diff --git a/macros/src/codegen/resources.rs b/macros/src/codegen/resources.rs index 4196ee7a..80e63c79 100644 --- a/macros/src/codegen/resources.rs +++ b/macros/src/codegen/resources.rs @@ -14,9 +14,12 @@ pub fn codegen( Vec, // mod_resources -- the `resources` module TokenStream2, + // mod_resources_imports -- the `resources` module imports + Vec, ) { let mut const_app = vec![]; let mut mod_resources = vec![]; + let mut mod_resources_imports = vec![]; for (name, res, expr, _) in app.resources(analysis) { let cfgs = &res.cfgs; @@ -82,6 +85,13 @@ pub fn codegen( ) }; + mod_resources_imports.push(quote!( + #[allow(non_camel_case_types)] + #(#cfgs)* + #cfg_core + use super::#name; + )); + const_app.push(util::impl_mutex( extra, cfgs, @@ -104,5 +114,5 @@ pub fn codegen( }) }; - (const_app, mod_resources) + (const_app, mod_resources, mod_resources_imports) } diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index b56db419..07edd1db 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -22,10 +22,13 @@ pub fn codegen( Vec, // user_software_tasks -- the `#[task]` functions written by the user Vec, + // user_software_tasks_imports -- the imports for `#[task]` functions written by the user + Vec, ) { let mut const_app = vec![]; let mut root = vec![]; let mut user_tasks = vec![]; + let mut software_tasks_imports = vec![]; for (name, task) in &app.software_tasks { let inputs = &task.inputs; @@ -112,6 +115,13 @@ pub fn codegen( analysis, ); + // Add resources to imports + let name_res = format_ident!("{}Resources", name); + software_tasks_imports.push(quote!( + #[allow(non_snake_case)] + use super::#name_res; + )); + root.push(item); const_app.push(constructor); @@ -141,6 +151,12 @@ pub fn codegen( #(#stmts)* } )); + software_tasks_imports.push(quote!( + #(#attrs)* + #(#cfgs)* + #[allow(non_snake_case)] + use super::#name; + )); root.push(module::codegen( Context::SoftwareTask(name), @@ -150,5 +166,5 @@ pub fn codegen( )); } - (const_app, root, user_tasks) + (const_app, root, user_tasks, software_tasks_imports) } -- cgit v1.2.3 From 9fd052b876581e5aef3442b17c17b0b597f84a47 Mon Sep 17 00:00:00 2001 From: Henrik Tjäder Date: Tue, 26 May 2020 10:52:10 +0000 Subject: Collect and generate required use-statements --- macros/src/codegen/idle.rs | 25 ++++++++++++++++++++++--- macros/src/codegen/init.rs | 28 +++++++++++++++++++++++++--- macros/src/codegen/resources.rs | 7 ++++++- macros/src/codegen/resources_struct.rs | 2 +- macros/src/codegen/software_tasks.rs | 3 +-- macros/src/codegen/spawn.rs | 4 ++-- 6 files changed, 57 insertions(+), 12 deletions(-) (limited to 'macros/src/codegen') diff --git a/macros/src/codegen/idle.rs b/macros/src/codegen/idle.rs index d0bff3e7..db454a58 100644 --- a/macros/src/codegen/idle.rs +++ b/macros/src/codegen/idle.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::quote; +use quote::{quote, format_ident}; use rtic_syntax::{ast::App, Context}; use crate::{ @@ -23,6 +23,8 @@ pub fn codegen( Vec, // user_idle Option, + // user_idle_imports + Vec, // call_idle TokenStream2, ) { @@ -34,15 +36,25 @@ pub fn codegen( let mut locals_pat = None; let mut locals_new = None; + let mut user_idle_imports = vec![]; + + let name = &idle.name; + if !idle.args.resources.is_empty() { let (item, constructor) = resources_struct::codegen(Context::Idle, 0, &mut needs_lt, app, analysis); root_idle.push(item); const_app = Some(constructor); + + let name_resource = format_ident!("{}Resources", name); + user_idle_imports.push(quote!( + #[allow(non_snake_case)] + use super::#name_resource; + )); + } - let name = &idle.name; if !idle.locals.is_empty() { let (locals, pat) = locals::codegen(Context::Idle, &idle.locals, app); @@ -66,6 +78,12 @@ pub fn codegen( #(#stmts)* } )); + user_idle_imports.push(quote!( + #(#attrs)* + #[allow(non_snake_case)] + #cfg_core + use super::#name; + )); let locals_new = locals_new.iter(); let call_idle = quote!(crate::#name( @@ -73,12 +91,13 @@ pub fn codegen( #name::Context::new(&rtic::export::Priority::new(0)) )); - (const_app, root_idle, user_idle, call_idle) + (const_app, root_idle, user_idle, user_idle_imports, call_idle) } else { ( None, vec![], None, + vec![], quote!(loop { rtic::export::wfi() }), diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index e0b7d699..88a7a23b 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::quote; +use quote::{quote, format_ident}; use rtic_syntax::{ast::App, Context}; use crate::{ @@ -24,6 +24,8 @@ pub fn codegen( Vec, // user_init -- the `#[init]` function written by the user Option, + // user_init_imports -- the imports for `#[init]` functio written by the user + Vec, // call_init -- the call to the user `#[init]` if there's one Option, ) { @@ -34,6 +36,8 @@ pub fn codegen( let mut root_init = vec![]; + let mut user_init_imports = vec![]; + let ret = { let late_fields = analysis .late_resources @@ -62,6 +66,12 @@ pub fn codegen( } )); + let name_late = format_ident!("{}LateResources", name); + user_init_imports.push(quote!( + #[allow(non_snake_case)] + use super::#name_late; + )); + Some(quote!(-> #name::LateResources)) } else { None @@ -89,6 +99,12 @@ pub fn codegen( #(#stmts)* } )); + user_init_imports.push(quote!( + #(#attrs)* + #cfg_core + #[allow(non_snake_case)] + use super::#name; + )); let mut const_app = None; if !init.args.resources.is_empty() { @@ -97,6 +113,12 @@ pub fn codegen( root_init.push(item); const_app = Some(constructor); + + let name_late = format_ident!("{}Resources", name); + user_init_imports.push(quote!( + #[allow(non_snake_case)] + use super::#name_late; + )); } let locals_new = locals_new.iter(); @@ -106,8 +128,8 @@ pub fn codegen( root_init.push(module::codegen(Context::Init, needs_lt, app, extra)); - (const_app, root_init, user_init, call_init) + (const_app, root_init, user_init, user_init_imports, call_init) } else { - (None, vec![], None, None) + (None, vec![], None, vec![], None) } } diff --git a/macros/src/codegen/resources.rs b/macros/src/codegen/resources.rs index 80e63c79..a326e68c 100644 --- a/macros/src/codegen/resources.rs +++ b/macros/src/codegen/resources.rs @@ -89,7 +89,7 @@ pub fn codegen( #[allow(non_camel_case_types)] #(#cfgs)* #cfg_core - use super::#name; + use super::resources::#name; )); const_app.push(util::impl_mutex( @@ -107,6 +107,11 @@ pub fn codegen( let mod_resources = if mod_resources.is_empty() { quote!() } else { + // Also import the resource module + mod_resources_imports.push(quote!( + use super::resources; + )); + quote!(mod resources { use rtic::export::Priority; diff --git a/macros/src/codegen/resources_struct.rs b/macros/src/codegen/resources_struct.rs index dbbba30e..92d5b666 100644 --- a/macros/src/codegen/resources_struct.rs +++ b/macros/src/codegen/resources_struct.rs @@ -165,7 +165,7 @@ pub fn codegen( let constructor = quote!( impl<#lt> #ident<#lt> { #[inline(always)] - unsafe fn new(#arg) -> Self { + pub unsafe fn new(#arg) -> Self { #ident { #(#values,)* } diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index 07edd1db..f3a0db16 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -145,14 +145,13 @@ pub fn codegen( #(#attrs)* #(#cfgs)* #[allow(non_snake_case)] - fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) { + pub fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) { use rtic::Mutex as _; #(#stmts)* } )); software_tasks_imports.push(quote!( - #(#attrs)* #(#cfgs)* #[allow(non_snake_case)] use super::#name; diff --git a/macros/src/codegen/spawn.rs b/macros/src/codegen/spawn.rs index 4b824f56..da281516 100644 --- a/macros/src/codegen/spawn.rs +++ b/macros/src/codegen/spawn.rs @@ -40,7 +40,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec Result<(), #ty> { + pub fn #name(&self #(,#args)*) -> Result<(), #ty> { #let_instant #body } @@ -92,7 +92,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec Result<(), #ty> { + pub fn #name(&self #(,#args)*) -> Result<(), #ty> { unsafe { #let_instant #spawn(self.priority() #instant #(,#untupled)*) -- cgit v1.2.3 From 86578b76fbd0a644f2d5008ac6c0661b40301a8d Mon Sep 17 00:00:00 2001 From: Henrik Tjäder Date: Tue, 1 Sep 2020 20:49:15 +0000 Subject: Add format_ident imports --- macros/src/codegen/hardware_tasks.rs | 2 +- macros/src/codegen/software_tasks.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'macros/src/codegen') diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index 4f60876a..8f2ab2f6 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::quote; +use quote::{quote, format_ident}; use rtic_syntax::{ast::App, Context}; use crate::{ diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index f3a0db16..854c083d 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::quote; +use quote::{quote, format_ident}; use rtic_syntax::{ast::App, Context}; use crate::{ -- cgit v1.2.3 From a151974245a994ec4c30bb0518677c4b99dce7e9 Mon Sep 17 00:00:00 2001 From: Henrik Tjäder Date: Tue, 8 Sep 2020 15:22:32 +0000 Subject: cfg_core is gone, cargo fmt --- macros/src/codegen.rs | 26 ++++++++++++++++++-------- macros/src/codegen/hardware_tasks.rs | 3 +-- macros/src/codegen/idle.rs | 12 ++++++++---- macros/src/codegen/init.rs | 11 ++++++++--- macros/src/codegen/resources.rs | 1 - macros/src/codegen/software_tasks.rs | 2 +- 6 files changed, 36 insertions(+), 19 deletions(-) (limited to 'macros/src/codegen') diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index fde9490b..e45f1a38 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -37,11 +37,13 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { let pre_init_stmts = pre_init::codegen(&app, analysis, extra); - let (const_app_init, root_init, user_init, user_init_imports, call_init) = init::codegen(app, analysis, extra); + let (const_app_init, root_init, user_init, user_init_imports, call_init) = + init::codegen(app, analysis, extra); let post_init_stmts = post_init::codegen(&app, analysis); - let (const_app_idle, root_idle, user_idle, user_idle_imports, call_idle) = idle::codegen(app, analysis, extra); + let (const_app_idle, root_idle, user_idle, user_idle_imports, call_idle) = + idle::codegen(app, analysis, extra); if user_init.is_some() { const_app_imports.push(quote!( @@ -95,13 +97,22 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { } )); - let (const_app_resources, mod_resources, mod_resources_imports) = resources::codegen(app, analysis, extra); + let (const_app_resources, mod_resources, mod_resources_imports) = + resources::codegen(app, analysis, extra); - let (const_app_hardware_tasks, root_hardware_tasks, user_hardware_tasks, user_hardware_tasks_imports) = - hardware_tasks::codegen(app, analysis, extra); + let ( + const_app_hardware_tasks, + root_hardware_tasks, + user_hardware_tasks, + user_hardware_tasks_imports, + ) = hardware_tasks::codegen(app, analysis, extra); - let (const_app_software_tasks, root_software_tasks, user_software_tasks, user_software_tasks_imports) = - software_tasks::codegen(app, analysis, extra); + let ( + const_app_software_tasks, + root_software_tasks, + user_software_tasks, + user_software_tasks_imports, + ) = software_tasks::codegen(app, analysis, extra); let const_app_dispatchers = dispatchers::codegen(app, analysis, extra); @@ -111,7 +122,6 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { let const_app_schedule = schedule::codegen(app, extra); - let user_imports = app.user_imports.clone(); let name = &app.name; let device = extra.device; diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index 8f2ab2f6..a03fd779 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::{quote, format_ident}; +use quote::{format_ident, quote}; use rtic_syntax::{ast::App, Context}; use crate::{ @@ -128,7 +128,6 @@ pub fn codegen( #[allow(non_snake_case)] use super::#name; )); - } (const_app, root, user_tasks, hardware_tasks_imports) diff --git a/macros/src/codegen/idle.rs b/macros/src/codegen/idle.rs index db454a58..2aa99751 100644 --- a/macros/src/codegen/idle.rs +++ b/macros/src/codegen/idle.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::{quote, format_ident}; +use quote::{format_ident, quote}; use rtic_syntax::{ast::App, Context}; use crate::{ @@ -52,7 +52,6 @@ pub fn codegen( #[allow(non_snake_case)] use super::#name_resource; )); - } if !idle.locals.is_empty() { @@ -81,7 +80,6 @@ pub fn codegen( user_idle_imports.push(quote!( #(#attrs)* #[allow(non_snake_case)] - #cfg_core use super::#name; )); @@ -91,7 +89,13 @@ pub fn codegen( #name::Context::new(&rtic::export::Priority::new(0)) )); - (const_app, root_idle, user_idle, user_idle_imports, call_idle) + ( + const_app, + root_idle, + user_idle, + user_idle_imports, + call_idle, + ) } else { ( None, diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index 88a7a23b..b350298c 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::{quote, format_ident}; +use quote::{format_ident, quote}; use rtic_syntax::{ast::App, Context}; use crate::{ @@ -101,7 +101,6 @@ pub fn codegen( )); user_init_imports.push(quote!( #(#attrs)* - #cfg_core #[allow(non_snake_case)] use super::#name; )); @@ -128,7 +127,13 @@ pub fn codegen( root_init.push(module::codegen(Context::Init, needs_lt, app, extra)); - (const_app, root_init, user_init, user_init_imports, call_init) + ( + const_app, + root_init, + user_init, + user_init_imports, + call_init, + ) } else { (None, vec![], None, vec![], None) } diff --git a/macros/src/codegen/resources.rs b/macros/src/codegen/resources.rs index a326e68c..d18a4655 100644 --- a/macros/src/codegen/resources.rs +++ b/macros/src/codegen/resources.rs @@ -88,7 +88,6 @@ pub fn codegen( mod_resources_imports.push(quote!( #[allow(non_camel_case_types)] #(#cfgs)* - #cfg_core use super::resources::#name; )); diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index 854c083d..9e011152 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -1,5 +1,5 @@ use proc_macro2::TokenStream as TokenStream2; -use quote::{quote, format_ident}; +use quote::{format_ident, quote}; use rtic_syntax::{ast::App, Context}; use crate::{ -- cgit v1.2.3 From 5b17f8b599c75cf44f2d1bfb528c5dfa1f003ada Mon Sep 17 00:00:00 2001 From: Henrik Tjäder Date: Wed, 23 Sep 2020 13:32:42 +0000 Subject: Due to new module boundaries the schedule fn needs to be pub --- macros/src/codegen/schedule.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'macros/src/codegen') diff --git a/macros/src/codegen/schedule.rs b/macros/src/codegen/schedule.rs index 46b0f384..5a887496 100644 --- a/macros/src/codegen/schedule.rs +++ b/macros/src/codegen/schedule.rs @@ -34,7 +34,7 @@ pub fn codegen(app: &App, extra: &Extra) -> Vec { methods.push(quote!( #(#cfgs)* - fn #name(&self, instant: #instant #(,#args)*) -> Result<(), #ty> { + pub fn #name(&self, instant: #instant #(,#args)*) -> Result<(), #ty> { #body } )); @@ -49,7 +49,7 @@ pub fn codegen(app: &App, extra: &Extra) -> Vec { items.push(quote!( #(#cfgs)* - unsafe fn #schedule( + pub unsafe fn #schedule( priority: &rtic::export::Priority, instant: #instant #(,#args)* @@ -62,7 +62,7 @@ pub fn codegen(app: &App, extra: &Extra) -> Vec { methods.push(quote!( #(#cfgs)* #[inline(always)] - fn #name(&self, instant: #instant #(,#args)*) -> Result<(), #ty> { + pub fn #name(&self, instant: #instant #(,#args)*) -> Result<(), #ty> { unsafe { #schedule(self.priority(), instant #(,#untupled)*) } -- cgit v1.2.3 From 96e6350c0dfae37c3ea8032b4cc3113e37323ae5 Mon Sep 17 00:00:00 2001 From: Henrik Tjäder Date: Thu, 1 Oct 2020 16:17:15 +0000 Subject: Rename const_app to mod_app --- macros/src/codegen.rs | 50 ++++++++++++++++++------------------ macros/src/codegen/hardware_tasks.rs | 10 ++++---- macros/src/codegen/idle.rs | 14 +++------- macros/src/codegen/init.rs | 14 +++------- macros/src/codegen/resources.rs | 10 ++++---- macros/src/codegen/software_tasks.rs | 18 ++++++------- 6 files changed, 52 insertions(+), 64 deletions(-) (limited to 'macros/src/codegen') diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index 26d7dc2d..f230d395 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -25,8 +25,8 @@ mod util; // TODO document the syntax here or in `rtic-syntax` pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { - let mut const_app = vec![]; - let mut const_app_imports = vec![]; + let mut mod_app = vec![]; + let mut mod_app_imports = vec![]; let mut mains = vec![]; let mut root = vec![]; let mut user = vec![]; @@ -37,21 +37,21 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { let pre_init_stmts = pre_init::codegen(&app, analysis, extra); - let (const_app_init, root_init, user_init, user_init_imports, call_init) = + let (mod_app_init, root_init, user_init, user_init_imports, call_init) = init::codegen(app, analysis, extra); let post_init_stmts = post_init::codegen(&app, analysis); - let (const_app_idle, root_idle, user_idle, user_idle_imports, call_idle) = + let (mod_app_idle, root_idle, user_idle, user_idle_imports, call_idle) = idle::codegen(app, analysis, extra); if user_init.is_some() { - const_app_imports.push(quote!( + mod_app_imports.push(quote!( use super::init; )) } if user_idle.is_some() { - const_app_imports.push(quote!( + mod_app_imports.push(quote!( use super::idle; )) } @@ -73,10 +73,10 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { #(#root_idle)* )); - const_app.push(quote!( - #const_app_init + mod_app.push(quote!( + #mod_app_init - #const_app_idle + #mod_app_idle )); let main = util::suffixed("main"); @@ -97,30 +97,30 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { } )); - let (const_app_resources, mod_resources, mod_resources_imports) = + let (mod_app_resources, mod_resources, mod_resources_imports) = resources::codegen(app, analysis, extra); let ( - const_app_hardware_tasks, + mod_app_hardware_tasks, root_hardware_tasks, user_hardware_tasks, user_hardware_tasks_imports, ) = hardware_tasks::codegen(app, analysis, extra); let ( - const_app_software_tasks, + mod_app_software_tasks, root_software_tasks, user_software_tasks, user_software_tasks_imports, ) = software_tasks::codegen(app, analysis, extra); - let const_app_dispatchers = dispatchers::codegen(app, analysis, extra); + let mod_app_dispatchers = dispatchers::codegen(app, analysis, extra); - let const_app_spawn = spawn::codegen(app, analysis, extra); + let mod_app_spawn = spawn::codegen(app, analysis, extra); - let const_app_timer_queue = timer_queue::codegen(app, analysis, extra); + let mod_app_timer_queue = timer_queue::codegen(app, analysis, extra); - let const_app_schedule = schedule::codegen(app, extra); + let mod_app_schedule = schedule::codegen(app, extra); let user_imports = app.user_imports.clone(); let user_code = app.user_code.clone(); @@ -159,22 +159,22 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { #(#mod_resources_imports)* - /// Const app - #(#const_app)* + /// app module + #(#mod_app)* - #(#const_app_resources)* + #(#mod_app_resources)* - #(#const_app_hardware_tasks)* + #(#mod_app_hardware_tasks)* - #(#const_app_software_tasks)* + #(#mod_app_software_tasks)* - #(#const_app_dispatchers)* + #(#mod_app_dispatchers)* - #(#const_app_spawn)* + #(#mod_app_spawn)* - #(#const_app_timer_queue)* + #(#mod_app_timer_queue)* - #(#const_app_schedule)* + #(#mod_app_schedule)* #(#mains)* } diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index a03fd779..25f1df41 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -14,7 +14,7 @@ pub fn codegen( analysis: &Analysis, extra: &Extra, ) -> ( - // const_app_hardware_tasks -- interrupt handlers and `${task}Resources` constructors + // mod_app_hardware_tasks -- interrupt handlers and `${task}Resources` constructors Vec, // root_hardware_tasks -- items that must be placed in the root of the crate: // - `${task}Locals` structs @@ -26,7 +26,7 @@ pub fn codegen( // user_hardware_tasks_imports -- the imports for `#[task]` functions written by the user Vec, ) { - let mut const_app = vec![]; + let mut mod_app = vec![]; let mut root = vec![]; let mut user_tasks = vec![]; let mut hardware_tasks_imports = vec![]; @@ -52,7 +52,7 @@ pub fn codegen( let symbol = task.args.binds.clone(); let priority = task.args.priority; - const_app.push(quote!( + mod_app.push(quote!( #[allow(non_snake_case)] #[no_mangle] unsafe fn #symbol() { @@ -90,7 +90,7 @@ pub fn codegen( root.push(item); - const_app.push(constructor); + mod_app.push(constructor); } root.push(module::codegen( @@ -130,5 +130,5 @@ pub fn codegen( )); } - (const_app, root, user_tasks, hardware_tasks_imports) + (mod_app, root, user_tasks, hardware_tasks_imports) } diff --git a/macros/src/codegen/idle.rs b/macros/src/codegen/idle.rs index 2aa99751..2e2932d7 100644 --- a/macros/src/codegen/idle.rs +++ b/macros/src/codegen/idle.rs @@ -14,7 +14,7 @@ pub fn codegen( analysis: &Analysis, extra: &Extra, ) -> ( - // const_app_idle -- the `${idle}Resources` constructor + // mod_app_idle -- the `${idle}Resources` constructor Option, // root_idle -- items that must be placed in the root of the crate: // - the `${idle}Locals` struct @@ -31,7 +31,7 @@ pub fn codegen( if app.idles.len() > 0 { let idle = &app.idles.first().unwrap(); let mut needs_lt = false; - let mut const_app = None; + let mut mod_app = None; let mut root_idle = vec![]; let mut locals_pat = None; let mut locals_new = None; @@ -45,7 +45,7 @@ pub fn codegen( resources_struct::codegen(Context::Idle, 0, &mut needs_lt, app, analysis); root_idle.push(item); - const_app = Some(constructor); + mod_app = Some(constructor); let name_resource = format_ident!("{}Resources", name); user_idle_imports.push(quote!( @@ -89,13 +89,7 @@ pub fn codegen( #name::Context::new(&rtic::export::Priority::new(0)) )); - ( - const_app, - root_idle, - user_idle, - user_idle_imports, - call_idle, - ) + (mod_app, root_idle, user_idle, user_idle_imports, call_idle) } else { ( None, diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index b350298c..77d186e5 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -14,7 +14,7 @@ pub fn codegen( analysis: &Analysis, extra: &Extra, ) -> ( - // const_app_idle -- the `${init}Resources` constructor + // mod_app_idle -- the `${init}Resources` constructor Option, // root_init -- items that must be placed in the root of the crate: // - the `${init}Locals` struct @@ -105,13 +105,13 @@ pub fn codegen( use super::#name; )); - let mut const_app = None; + let mut mod_app = None; if !init.args.resources.is_empty() { let (item, constructor) = resources_struct::codegen(Context::Init, 0, &mut needs_lt, app, analysis); root_init.push(item); - const_app = Some(constructor); + mod_app = Some(constructor); let name_late = format_ident!("{}Resources", name); user_init_imports.push(quote!( @@ -127,13 +127,7 @@ pub fn codegen( root_init.push(module::codegen(Context::Init, needs_lt, app, extra)); - ( - const_app, - root_init, - user_init, - user_init_imports, - call_init, - ) + (mod_app, root_init, user_init, user_init_imports, call_init) } else { (None, vec![], None, vec![], None) } diff --git a/macros/src/codegen/resources.rs b/macros/src/codegen/resources.rs index d18a4655..38ea5245 100644 --- a/macros/src/codegen/resources.rs +++ b/macros/src/codegen/resources.rs @@ -10,14 +10,14 @@ pub fn codegen( analysis: &Analysis, extra: &Extra, ) -> ( - // const_app -- the `static [mut]` variables behind the proxies + // mod_app -- the `static [mut]` variables behind the proxies Vec, // mod_resources -- the `resources` module TokenStream2, // mod_resources_imports -- the `resources` module imports Vec, ) { - let mut const_app = vec![]; + let mut mod_app = vec![]; let mut mod_resources = vec![]; let mut mod_resources_imports = vec![]; @@ -42,7 +42,7 @@ pub fn codegen( }; let attrs = &res.attrs; - const_app.push(quote!( + mod_app.push(quote!( #[allow(non_upper_case_globals)] #(#attrs)* #(#cfgs)* @@ -91,7 +91,7 @@ pub fn codegen( use super::resources::#name; )); - const_app.push(util::impl_mutex( + mod_app.push(util::impl_mutex( extra, cfgs, true, @@ -118,5 +118,5 @@ pub fn codegen( }) }; - (const_app, mod_resources, mod_resources_imports) + (mod_app, mod_resources, mod_resources_imports) } diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index 9e011152..4ae37e4e 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -13,7 +13,7 @@ pub fn codegen( analysis: &Analysis, extra: &Extra, ) -> ( - // const_app_software_tasks -- free queues, buffers and `${task}Resources` constructors + // mod_app_software_tasks -- free queues, buffers and `${task}Resources` constructors Vec, // root_software_tasks -- items that must be placed in the root of the crate: // - `${task}Locals` structs @@ -25,7 +25,7 @@ pub fn codegen( // user_software_tasks_imports -- the imports for `#[task]` functions written by the user Vec, ) { - let mut const_app = vec![]; + let mut mod_app = vec![]; let mut root = vec![]; let mut user_tasks = vec![]; let mut software_tasks_imports = vec![]; @@ -51,7 +51,7 @@ pub fn codegen( Box::new(|| util::link_section_uninit(true)), ) }; - const_app.push(quote!( + mod_app.push(quote!( /// Queue version of a free-list that keeps track of empty slots in /// the following buffers static mut #fq: #fq_ty = #fq_expr; @@ -59,13 +59,13 @@ pub fn codegen( // Generate a resource proxy if needed if let Some(ceiling) = ceiling { - const_app.push(quote!( + mod_app.push(quote!( struct #fq<'a> { priority: &'a rtic::export::Priority, } )); - const_app.push(util::impl_mutex( + mod_app.push(util::impl_mutex( extra, &[], false, @@ -85,7 +85,7 @@ pub fn codegen( let instants = util::instants_ident(name); let uninit = mk_uninit(); - const_app.push(quote!( + mod_app.push(quote!( #uninit /// Buffer that holds the instants associated to the inputs of a task static mut #instants: @@ -96,7 +96,7 @@ pub fn codegen( let uninit = mk_uninit(); let inputs = util::inputs_ident(name); - const_app.push(quote!( + mod_app.push(quote!( #uninit /// Buffer that holds the inputs of a task static mut #inputs: [core::mem::MaybeUninit<#input_ty>; #cap_lit] = @@ -124,7 +124,7 @@ pub fn codegen( root.push(item); - const_app.push(constructor); + mod_app.push(constructor); } // `${task}Locals` @@ -165,5 +165,5 @@ pub fn codegen( )); } - (const_app, root, user_tasks, software_tasks_imports) + (mod_app, root, user_tasks, software_tasks_imports) } -- cgit v1.2.3