aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen/util.rs
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2021-07-07 22:50:59 +0200
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2021-07-07 23:07:09 +0200
commit98d2af9d73da56910c8bb6cb662fbc4d609a704a (patch)
tree46914250a980b9164b2d20cbeb08e126a86cf7ea /macros/src/codegen/util.rs
parent633012190baa0801efc7e3ab2f699778c5038d54 (diff)
downloadrtic-98d2af9d73da56910c8bb6cb662fbc4d609a704a.tar.gz
rtic-98d2af9d73da56910c8bb6cb662fbc4d609a704a.tar.zst
rtic-98d2af9d73da56910c8bb6cb662fbc4d609a704a.zip
Fixing tests
Diffstat (limited to 'macros/src/codegen/util.rs')
-rw-r--r--macros/src/codegen/util.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs
index e3df2076..3b0b9e4f 100644
--- a/macros/src/codegen/util.rs
+++ b/macros/src/codegen/util.rs
@@ -212,6 +212,17 @@ pub fn regroup_inputs(
}
}
+/// Get the ident for the name of the task
+pub fn get_task_name(ctxt: Context, app: &App) -> Ident {
+ let s = match ctxt {
+ Context::Init => app.init.name.to_string(),
+ Context::Idle => app.idle.as_ref().unwrap().name.to_string(),
+ Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(),
+ };
+
+ Ident::new(&s, Span::call_site())
+}
+
/// 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 {
@@ -276,11 +287,24 @@ pub fn monotonic_ident(name: &str) -> Ident {
}
pub fn static_shared_resource_ident(name: &Ident) -> Ident {
- Ident::new(&format!("shared_{}", name.to_string()), Span::call_site())
+ Ident::new(
+ &format!("shared_resource_{}", name.to_string()),
+ Span::call_site(),
+ )
}
pub fn static_local_resource_ident(name: &Ident) -> Ident {
- Ident::new(&format!("local_{}", name.to_string()), Span::call_site())
+ Ident::new(
+ &format!("local_resource_{}", name.to_string()),
+ Span::call_site(),
+ )
+}
+
+pub fn declared_static_local_resource_ident(name: &Ident, task_name: &Ident) -> Ident {
+ Ident::new(
+ &format!("local_{}_{}", task_name.to_string(), name.to_string()),
+ Span::call_site(),
+ )
}
/// The name to get better RT flag errors