Rename const_app to mod_app

This commit is contained in:
Henrik Tjäder 2020-10-01 16:17:15 +00:00
parent b4ec6f5eff
commit 96e6350c0d
6 changed files with 52 additions and 64 deletions

View file

@ -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)*
}

View file

@ -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<TokenStream2>,
// 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<TokenStream2>,
) {
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)
}

View file

@ -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<TokenStream2>,
// 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,

View file

@ -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<TokenStream2>,
// 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)
}

View file

@ -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<TokenStream2>,
// mod_resources -- the `resources` module
TokenStream2,
// mod_resources_imports -- the `resources` module imports
Vec<TokenStream2>,
) {
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)
}

View file

@ -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<TokenStream2>,
// 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<TokenStream2>,
) {
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)
}