aboutsummaryrefslogtreecommitdiff
path: root/macros/src/codegen
diff options
context:
space:
mode:
authorGravatar Henrik Tjäder <henrik@tjaders.com> 2020-09-01 14:39:05 +0000
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2020-09-01 14:50:06 +0000
commitf151d5871c559012173356259030c1dd36a442cc (patch)
treef86408528b852678cda9cc94454e047fdcb92381 /macros/src/codegen
parentfea6d2facfc871111cef64e906bd74e3b6b66aef (diff)
downloadrtic-f151d5871c559012173356259030c1dd36a442cc.tar.gz
rtic-f151d5871c559012173356259030c1dd36a442cc.tar.zst
rtic-f151d5871c559012173356259030c1dd36a442cc.zip
Cargo fmt
Diffstat (limited to 'macros/src/codegen')
-rw-r--r--macros/src/codegen/assertions.rs12
-rw-r--r--macros/src/codegen/hardware_tasks.rs4
-rw-r--r--macros/src/codegen/init.rs20
-rw-r--r--macros/src/codegen/post_init.rs7
-rw-r--r--macros/src/codegen/pre_init.rs9
-rw-r--r--macros/src/codegen/resources.rs14
-rw-r--r--macros/src/codegen/spawn_body.rs3
-rw-r--r--macros/src/codegen/util.rs27
8 files changed, 32 insertions, 64 deletions
diff --git a/macros/src/codegen/assertions.rs b/macros/src/codegen/assertions.rs
index a7c26a5e..ab1b26cd 100644
--- a/macros/src/codegen/assertions.rs
+++ b/macros/src/codegen/assertions.rs
@@ -11,15 +11,15 @@ pub fn codegen(analysis: &Analysis) -> Vec<TokenStream2> {
// type only on some core (e.g. `#[cfg(core = "0")] use some::Type;`)
//if let Some(types) = analysis.send_types {
- for ty in &analysis.send_types {
- stmts.push(quote!(rtic::export::assert_send::<#ty>();));
- }
+ for ty in &analysis.send_types {
+ stmts.push(quote!(rtic::export::assert_send::<#ty>();));
+ }
//}
//if let Some(types) = analysis.sync_types {
- for ty in &analysis.sync_types {
- stmts.push(quote!(rtic::export::assert_sync::<#ty>();));
- }
+ for ty in &analysis.sync_types {
+ stmts.push(quote!(rtic::export::assert_sync::<#ty>();));
+ }
//}
// if the `schedule` API is used in more than one core then we need to check that the
diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs
index 37df33de..eb86c8d8 100644
--- a/macros/src/codegen/hardware_tasks.rs
+++ b/macros/src/codegen/hardware_tasks.rs
@@ -29,7 +29,6 @@ pub fn codegen(
let mut user_tasks = vec![];
for (name, task) in &app.hardware_tasks {
-
let (let_instant, instant) = if app.uses_schedule() {
let m = extra.monotonic();
@@ -96,8 +95,7 @@ pub fn codegen(
// `${task}Locals`
let mut locals_pat = None;
if !task.locals.is_empty() {
- let (struct_, pat) =
- locals::codegen(Context::HardwareTask(name), &task.locals, app);
+ let (struct_, pat) = locals::codegen(Context::HardwareTask(name), &task.locals, app);
root.push(struct_);
locals_pat = Some(pat);
diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs
index 4ae9fa62..01074db6 100644
--- a/macros/src/codegen/init.rs
+++ b/macros/src/codegen/init.rs
@@ -40,17 +40,15 @@ pub fn codegen(
.late_resources
.iter()
.flat_map(|resources| {
- resources
- .iter()
- .map(|name| {
- let ty = &app.late_resources[name].ty;
- let cfgs = &app.late_resources[name].cfgs;
-
- quote!(
- #(#cfgs)*
- pub #name: #ty
- )
- })
+ resources.iter().map(|name| {
+ let ty = &app.late_resources[name].ty;
+ let cfgs = &app.late_resources[name].cfgs;
+
+ quote!(
+ #(#cfgs)*
+ pub #name: #ty
+ )
+ })
})
.collect::<Vec<_>>();
diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs
index 098d1cc9..93d57049 100644
--- a/macros/src/codegen/post_init.rs
+++ b/macros/src/codegen/post_init.rs
@@ -5,17 +5,14 @@ use rtic_syntax::ast::App;
use crate::analyze::Analysis;
/// Generates code that runs after `#[init]` returns
-pub fn codegen(
- app: &App,
- analysis: &Analysis,
-) -> (Vec<TokenStream2>, Vec<TokenStream2>) {
+pub fn codegen(app: &App, analysis: &Analysis) -> (Vec<TokenStream2>, Vec<TokenStream2>) {
//#TODO remove
let const_app = vec![];
let mut stmts = vec![];
// initialize late resources
//if let Some(late_resources) = analysis.late_resources {
- //for name in late_resources {
+ //for name in late_resources {
if analysis.late_resources.len() > 0 {
// #TODO, check soundness of this, why the wrapping
// BTreeSet wrapped in a vector
diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs
index 7b577390..80849aea 100644
--- a/macros/src/codegen/pre_init.rs
+++ b/macros/src/codegen/pre_init.rs
@@ -5,14 +5,7 @@ use rtic_syntax::ast::App;
use crate::{analyze::Analysis, check::Extra, codegen::util};
/// Generates code that runs before `#[init]`
-pub fn codegen(
- app: &App,
- analysis: &Analysis,
- extra: &Extra,
-) ->
- // `pre_init_stmts`
- Vec<TokenStream2>
-{
+pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream2> {
let mut stmts = vec![];
// disable interrupts -- `init` must run with interrupts disabled
diff --git a/macros/src/codegen/resources.rs b/macros/src/codegen/resources.rs
index 07e01cb1..51467618 100644
--- a/macros/src/codegen/resources.rs
+++ b/macros/src/codegen/resources.rs
@@ -1,9 +1,6 @@
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
-use rtic_syntax::{
- analyze::Ownership,
- ast::App,
-};
+use rtic_syntax::{analyze::Ownership, ast::App};
use crate::{analyze::Analysis, check::Extra, codegen::util};
@@ -28,10 +25,10 @@ pub fn codegen(
{
//let loc_attr = None;
let section = if expr.is_none() {
- util::link_section_uninit(true)
- } else {
- None
- };
+ util::link_section_uninit(true)
+ } else {
+ None
+ };
/*
let (loc_attr, section) = match loc {
Location::Owned => (
@@ -66,7 +63,6 @@ pub fn codegen(
}
if let Some(Ownership::Contended { ceiling }) = analysis.ownerships.get(name) {
-
mod_resources.push(quote!(
#[allow(non_camel_case_types)]
#(#cfgs)*
diff --git a/macros/src/codegen/spawn_body.rs b/macros/src/codegen/spawn_body.rs
index 3c2e8a03..4ecd0757 100644
--- a/macros/src/codegen/spawn_body.rs
+++ b/macros/src/codegen/spawn_body.rs
@@ -45,7 +45,8 @@ pub fn codegen(
let device = extra.device;
let enum_ = util::interrupt_ident();
let interrupt = &analysis.interrupts.get(&priority);
- let pend = {quote!(
+ let pend = {
+ quote!(
rtic::pend(#device::#enum_::#interrupt);
)
};
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs
index c375e4eb..369025f3 100644
--- a/macros/src/codegen/util.rs
+++ b/macros/src/codegen/util.rs
@@ -44,10 +44,7 @@ pub fn cfg_core(core: Core, cores: u8) -> Option<TokenStream2> {
/// There may be more than one free queue per task because we need one for each sender core so we
/// include the sender (e.g. `S0`) in the name
pub fn fq_ident(task: &Ident) -> Ident {
- Ident::new(
- &format!("{}_FQ", task.to_string()),
- Span::call_site(),
- )
+ Ident::new(&format!("{}_FQ", task.to_string()), Span::call_site())
}
/// Generates a `Mutex` implementation
@@ -112,7 +109,7 @@ pub fn instants_ident(task: &Ident) -> Ident {
pub fn interrupt_ident() -> Ident {
let span = Span::call_site();
- Ident::new("Interrupt", span)
+ Ident::new("Interrupt", span)
}
/// Whether `name` is an exception with configurable priority
@@ -253,10 +250,7 @@ pub fn resources_ident(ctxt: Context, app: &App) -> Ident {
/// in turn may use more than one ready queue because the queues are SPSC queues so one is needed
/// per sender core.
pub fn rq_ident(priority: u8) -> Ident {
- Ident::new(
- &format!("P{}_RQ", priority),
- Span::call_site(),
- )
+ Ident::new(&format!("P{}_RQ", priority), Span::call_site())
}
/// Generates an identifier for a "schedule" function
@@ -264,10 +258,7 @@ pub fn rq_ident(priority: u8) -> Ident {
/// The methods of the `Schedule` structs invoke these functions. As one task may be `schedule`-ed
/// by different cores we need one "schedule" function per possible task-sender pair
pub fn schedule_ident(name: &Ident) -> Ident {
- Ident::new(
- &format!("schedule_{}", name.to_string()),
- Span::call_site(),
- )
+ Ident::new(&format!("schedule_{}", name.to_string()), Span::call_site())
}
/// Generates an identifier for the `enum` of `schedule`-able tasks
@@ -287,10 +278,7 @@ pub fn spawn_barrier() -> Ident {
/// The methods of the `Spawn` structs invoke these functions. As one task may be `spawn`-ed by
/// different cores we need one "spawn" function per possible task-sender pair
pub fn spawn_ident(name: &Ident) -> Ident {
- Ident::new(
- &format!("spawn_{}", name.to_string()),
- Span::call_site(),
- )
+ Ident::new(&format!("spawn_{}", name.to_string()), Span::call_site())
}
/// Generates an identifier for the `enum` of `spawn`-able tasks
@@ -298,10 +286,7 @@ pub fn spawn_ident(name: &Ident) -> Ident {
/// This identifier needs the same structure as the `RQ` identifier because there's one ready queue
/// for each of these `T` enums
pub fn spawn_t_ident(priority: u8) -> Ident {
- Ident::new(
- &format!("P{}_T", priority),
- Span::call_site(),
- )
+ Ident::new(&format!("P{}_T", priority), Span::call_site())
}
pub fn suffixed(name: &str) -> Ident {