diff options
author | 2021-07-05 21:40:01 +0200 | |
---|---|---|
committer | 2021-07-05 21:40:01 +0200 | |
commit | 3f85cb5caf1ae930e6551e139978ceec859a2348 (patch) | |
tree | 8c29ac6fa1095f33cf984d2565e2e7bea9504566 /macros/src/codegen/util.rs | |
parent | 13dc3992e616d817e38c167c4b47db816855f18b (diff) | |
download | rtic-3f85cb5caf1ae930e6551e139978ceec859a2348.tar.gz rtic-3f85cb5caf1ae930e6551e139978ceec859a2348.tar.zst rtic-3f85cb5caf1ae930e6551e139978ceec859a2348.zip |
Started work
Diffstat (limited to 'macros/src/codegen/util.rs')
-rw-r--r-- | macros/src/codegen/util.rs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index 3e42eda9..21b31411 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -166,8 +166,8 @@ pub fn link_section_uninit(empty_expr: bool) -> Option<TokenStream2> { /// Generates a pre-reexport identifier for the "locals" struct pub fn locals_ident(ctxt: Context, app: &App) -> Ident { let mut s = match ctxt { - Context::Init => app.inits.first().unwrap().name.to_string(), - Context::Idle => app.idles.first().unwrap().name.to_string(), + Context::Init => app.init.name.to_string(), + Context::Idle => app.idle.unwrap().name.to_string(), Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(), }; @@ -225,15 +225,28 @@ pub fn regroup_inputs( } } -/// Generates a pre-reexport identifier for the "resources" struct -pub fn resources_ident(ctxt: Context, app: &App) -> Ident { +/// Generates a pre-reexport identifier for the "shared resources" struct +pub fn shared_resources_ident(ctxt: Context, app: &App) -> Ident { let mut s = match ctxt { - Context::Init => app.inits.first().unwrap().name.to_string(), - Context::Idle => app.idles.first().unwrap().name.to_string(), + Context::Init => app.init.name.to_string(), + Context::Idle => app.idle.unwrap().name.to_string(), Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(), }; - s.push_str("Resources"); + s.push_str("SharedResources"); + + Ident::new(&s, Span::call_site()) +} + +/// Generates a pre-reexport identifier for the "local resources" struct +pub fn local_resources_ident(ctxt: Context, app: &App) -> Ident { + let mut s = match ctxt { + Context::Init => app.init.name.to_string(), + Context::Idle => app.idle.unwrap().name.to_string(), + Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(), + }; + + s.push_str("LocalResources"); Ident::new(&s, Span::call_site()) } |