mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-18 22:05:37 +01:00
Fixing tests
This commit is contained in:
parent
633012190b
commit
98d2af9d73
75 changed files with 591 additions and 1183 deletions
|
|
@ -20,7 +20,6 @@ mod software_tasks;
|
|||
mod timer_queue;
|
||||
mod util;
|
||||
|
||||
// TODO document the syntax here or in `rtic-syntax`
|
||||
pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||
let mut mod_app = vec![];
|
||||
let mut mains = vec![];
|
||||
|
|
|
|||
|
|
@ -76,13 +76,6 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
|||
let inputs = util::mark_internal_ident(&inputs);
|
||||
let (_, tupled, pats, _) = util::regroup_inputs(&task.inputs);
|
||||
|
||||
// TODO Fix me
|
||||
// let locals_new = if task.args.local_resources.is_empty() {
|
||||
// quote!()
|
||||
// } else {
|
||||
// quote!(#name::Locals::new(),)
|
||||
// };
|
||||
|
||||
quote!(
|
||||
#(#cfgs)*
|
||||
#t::#name => {
|
||||
|
|
|
|||
|
|
@ -29,13 +29,6 @@ pub fn codegen(
|
|||
let mut user_tasks = vec![];
|
||||
|
||||
for (name, task) in &app.hardware_tasks {
|
||||
// TODO: Fix locals
|
||||
// let locals_new = if task.args.local_resources.is_empty() {
|
||||
// quote!()
|
||||
// } else {
|
||||
// quote!(#name::Locals::new(),)
|
||||
// };
|
||||
|
||||
let symbol = task.args.binds.clone();
|
||||
let priority = task.args.priority;
|
||||
let cfgs = &task.cfgs;
|
||||
|
|
@ -60,7 +53,6 @@ pub fn codegen(
|
|||
let mut shared_needs_lt = false;
|
||||
let mut local_needs_lt = false;
|
||||
|
||||
// TODO: Fix locals
|
||||
// `${task}Locals`
|
||||
if !task.args.local_resources.is_empty() {
|
||||
let (item, constructor) = local_resources_struct::codegen(
|
||||
|
|
|
|||
|
|
@ -31,17 +31,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
|
||||
let mut root_init = vec![];
|
||||
|
||||
// TODO: Fix locals
|
||||
// let mut locals_pat = None;
|
||||
// let mut locals_new = None;
|
||||
// if !init.locals.is_empty() {
|
||||
// let (struct_, pat) = locals::codegen(Context::Init, &init.locals, app);
|
||||
|
||||
// locals_new = Some(quote!(#name::Locals::new()));
|
||||
// locals_pat = Some(pat);
|
||||
// root_init.push(struct_);
|
||||
// }
|
||||
|
||||
let context = &init.context;
|
||||
let attrs = &init.attrs;
|
||||
let stmts = &init.stmts;
|
||||
|
|
|
|||
|
|
@ -44,13 +44,16 @@ pub fn codegen(
|
|||
}
|
||||
|
||||
// All declared `local = [NAME: TY = EXPR]` local resources
|
||||
for (name, task_local) in app.declared_local_resources() {
|
||||
for (task_name, resource_name, task_local) in app.declared_local_resources() {
|
||||
let cfgs = &task_local.cfgs;
|
||||
let ty = &task_local.ty;
|
||||
let expr = &task_local.expr;
|
||||
let attrs = &task_local.attrs;
|
||||
|
||||
let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name));
|
||||
let mangled_name = util::mark_internal_ident(&util::declared_static_local_resource_ident(
|
||||
resource_name,
|
||||
&task_name,
|
||||
));
|
||||
|
||||
// For future use
|
||||
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
||||
|
|
@ -64,13 +67,5 @@ pub fn codegen(
|
|||
));
|
||||
}
|
||||
|
||||
// let mod_resources = if mod_resources.is_empty() {
|
||||
// quote!()
|
||||
// } else {
|
||||
// quote!(mod local_resources {
|
||||
// #(#mod_resources)*
|
||||
// })
|
||||
// };
|
||||
|
||||
(mod_app, TokenStream2::new())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
|||
Context::SoftwareTask(name) => &app.software_tasks[name].args.local_resources,
|
||||
};
|
||||
|
||||
let task_name = util::get_task_name(ctxt, app);
|
||||
|
||||
let mut fields = vec![];
|
||||
let mut values = vec![];
|
||||
let mut has_cfgs = false;
|
||||
|
|
@ -41,7 +43,13 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
|||
quote!('a)
|
||||
};
|
||||
|
||||
let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name));
|
||||
let mangled_name = if matches!(task_local, TaskLocal::External) {
|
||||
util::mark_internal_ident(&util::static_local_resource_ident(name))
|
||||
} else {
|
||||
util::mark_internal_ident(&util::declared_static_local_resource_ident(
|
||||
name, &task_name,
|
||||
))
|
||||
};
|
||||
|
||||
fields.push(quote!(
|
||||
#(#cfgs)*
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
|||
None
|
||||
};
|
||||
let ty = &res.ty;
|
||||
let mangled_name = util::mark_internal_ident(&name);
|
||||
let mangled_name = util::mark_internal_ident(&util::static_shared_resource_ident(&name));
|
||||
|
||||
if !res.properties.lock_free {
|
||||
if access.is_shared() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -10,6 +10,17 @@ fn analyze() {
|
|||
quote!(device = pac, dispatchers = [B, A]),
|
||||
quote!(
|
||||
mod app {
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(Shared {}, Local {}, init::Monotonics {})
|
||||
}
|
||||
|
||||
#[task(priority = 1)]
|
||||
fn a(_: a::Context) {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue