aboutsummaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
Diffstat (limited to 'macros')
-rw-r--r--macros/src/codegen.rs35
-rw-r--r--macros/src/codegen/dispatchers.rs2
-rw-r--r--macros/src/codegen/post_init.rs5
-rw-r--r--macros/src/codegen/resources.rs16
-rw-r--r--macros/src/codegen/software_tasks.rs8
-rw-r--r--macros/src/codegen/timer_queue.rs4
6 files changed, 18 insertions, 52 deletions
diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs
index c38b47c9..b9755368 100644
--- a/macros/src/codegen.rs
+++ b/macros/src/codegen.rs
@@ -73,14 +73,10 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
}
));
- let (mod_app_resources, mod_resources, mod_resources_imports) =
- resources::codegen(app, analysis, extra);
+ let (mod_app_resources, mod_resources) = resources::codegen(app, analysis, extra);
- let (
- mod_app_hardware_tasks,
- root_hardware_tasks,
- user_hardware_tasks,
- ) = hardware_tasks::codegen(app, analysis, extra);
+ let (mod_app_hardware_tasks, root_hardware_tasks, user_hardware_tasks) =
+ hardware_tasks::codegen(app, analysis, extra);
let (mod_app_software_tasks, root_software_tasks, user_software_tasks) =
software_tasks::codegen(app, analysis, extra);
@@ -97,9 +93,11 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
let task_list = analysis.tasks.clone();
let mut tasks = vec![];
+
if !task_list.is_empty() {
tasks.push(quote!(
- enum Tasks {
+ #[allow(non_camel_case_types)]
+ pub enum Tasks {
#(#task_list),*
}
));
@@ -107,65 +105,46 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
quote!(
/// Implementation details
- mod #name {
+ pub mod #name {
/// Always include the device crate which contains the vector table
use #device as you_must_enable_the_rt_feature_for_the_pac_in_your_cargo_toml;
- /// 2
#(#user_imports)*
/// User code from within the module
#(#user_code)*
/// User code end
- /// 3
#(#user)*
- /// 4
#(#user_hardware_tasks)*
- /// 5
#(#user_software_tasks)*
- /// 6
#(#root)*
- /// 7
#mod_resources
- /// 8
#(#root_hardware_tasks)*
- /// 9
#(#root_software_tasks)*
- /// 10
/// Unused
#(#tasks)*
- /// 13
- #(#mod_resources_imports)*
-
- /// 14
/// app module
#(#mod_app)*
- /// 15
#(#mod_app_resources)*
- /// 16
#(#mod_app_hardware_tasks)*
- /// 17
#(#mod_app_software_tasks)*
- /// 18
#(#mod_app_dispatchers)*
- /// 19
#(#mod_app_timer_queue)*
- /// 20
#(#mains)*
}
)
diff --git a/macros/src/codegen/dispatchers.rs b/macros/src/codegen/dispatchers.rs
index bd4061d1..a76f622e 100644
--- a/macros/src/codegen/dispatchers.rs
+++ b/macros/src/codegen/dispatchers.rs
@@ -57,7 +57,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
);
items.push(quote!(
#[doc = #doc]
- pub static mut #rq: #rq_ty = #rq_expr;
+ static mut #rq: #rq_ty = #rq_expr;
));
let arms = channel
diff --git a/macros/src/codegen/post_init.rs b/macros/src/codegen/post_init.rs
index c35c6976..8defc85d 100644
--- a/macros/src/codegen/post_init.rs
+++ b/macros/src/codegen/post_init.rs
@@ -2,7 +2,7 @@ use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use rtic_syntax::ast::App;
-use crate::analyze::Analysis;
+use crate::{analyze::Analysis, codegen::util};
/// Generates code that runs after `#[init]` returns
pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
@@ -12,13 +12,14 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
if analysis.late_resources.len() > 0 {
// BTreeSet wrapped in a vector
for name in analysis.late_resources.first().unwrap() {
+ let mangled_name = util::mangle_ident(&name);
// If it's live
let cfgs = app.late_resources[name].cfgs.clone();
if analysis.locations.get(name).is_some() {
// Need to also include the cfgs
stmts.push(quote!(
#(#cfgs)*
- #name.as_mut_ptr().write(late.#name);
+ #mangled_name.as_mut_ptr().write(late.#name);
));
}
}
diff --git a/macros/src/codegen/resources.rs b/macros/src/codegen/resources.rs
index d5ec583e..0db4f728 100644
--- a/macros/src/codegen/resources.rs
+++ b/macros/src/codegen/resources.rs
@@ -14,12 +14,9 @@ pub fn codegen(
Vec<TokenStream2>,
// mod_resources -- the `resources` module
TokenStream2,
- // mod_resources_imports -- the `resources` module imports
- Vec<TokenStream2>,
) {
let mut mod_app = vec![];
let mut mod_resources = vec![];
- let mut mod_resources_imports = vec![];
for (name, res, expr, _) in app.resources(analysis) {
let cfgs = &res.cfgs;
@@ -86,12 +83,6 @@ pub fn codegen(
)
};
- mod_resources_imports.push(quote!(
- #[allow(non_camel_case_types)]
- #(#cfgs)*
- use super::resources::#name;
- ));
-
mod_app.push(util::impl_mutex(
extra,
cfgs,
@@ -107,11 +98,6 @@ pub fn codegen(
let mod_resources = if mod_resources.is_empty() {
quote!()
} else {
- // Also import the resource module
- mod_resources_imports.push(quote!(
- use super::resources;
- ));
-
quote!(mod resources {
use rtic::export::Priority;
@@ -119,5 +105,5 @@ pub fn codegen(
})
};
- (mod_app, mod_resources, mod_resources_imports)
+ (mod_app, mod_resources)
}
diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs
index f5757a12..323060c4 100644
--- a/macros/src/codegen/software_tasks.rs
+++ b/macros/src/codegen/software_tasks.rs
@@ -50,7 +50,7 @@ pub fn codegen(
mod_app.push(quote!(
/// Queue version of a free-list that keeps track of empty slots in
/// the following buffers
- pub static mut #fq: #fq_ty = #fq_expr;
+ static mut #fq: #fq_ty = #fq_expr;
));
let ref elems = (0..cap)
@@ -64,7 +64,7 @@ pub fn codegen(
mod_app.push(quote!(
#uninit
/// Buffer that holds the instants associated to the inputs of a task
- pub static mut #instants:
+ static mut #instants:
[core::mem::MaybeUninit<<#m as rtic::Monotonic>::Instant>; #cap_lit] =
[#(#elems,)*];
));
@@ -75,7 +75,7 @@ pub fn codegen(
mod_app.push(quote!(
#uninit
/// Buffer that holds the inputs of a task
- pub static mut #inputs_ident: [core::mem::MaybeUninit<#input_ty>; #cap_lit] =
+ static mut #inputs_ident: [core::mem::MaybeUninit<#input_ty>; #cap_lit] =
[#(#elems,)*];
));
@@ -113,7 +113,7 @@ pub fn codegen(
#(#attrs)*
#(#cfgs)*
#[allow(non_snake_case)]
- pub fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) {
+ fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) {
use rtic::Mutex as _;
#(#stmts)*
diff --git a/macros/src/codegen/timer_queue.rs b/macros/src/codegen/timer_queue.rs
index c898a7fd..c081076e 100644
--- a/macros/src/codegen/timer_queue.rs
+++ b/macros/src/codegen/timer_queue.rs
@@ -31,7 +31,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
#[doc = #doc]
#[allow(non_camel_case_types)]
#[derive(Clone, Copy)]
- pub enum #t {
+ enum #t {
#(#variants,)*
}
));
@@ -52,7 +52,7 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
items.push(quote!(
#[doc = #doc]
- pub static mut #tq: #tq_ty = rtic::export::TimerQueue(
+ static mut #tq: #tq_ty = rtic::export::TimerQueue(
rtic::export::BinaryHeap(
rtic::export::iBinaryHeap::new()
)
k&id=b5e25afa9423aa7ade559c28be010f788a857375&follow=1'>Update seven-shrimps-hope.md (#4934)Gravatar Tony Sullivan 1-1/+1 2022-09-30[ci] update lockfile (#4927)Gravatar Fred K. Bot 1-280/+280 2022-09-30Move module declarations for Markdown and MDX so they're available everywhere...Gravatar Erika 4-35/+46 2022-09-29[ci] formatGravatar tony-sull 4-17/+29 2022-09-29[@astrojs/image] adding caching support for SSG builds (#4909)Gravatar Tony Sullivan 8-10/+240 2022-09-29[ci] release (#4903)astro@1.4.0@astrojs/vue@1.1.0@astrojs/vercel@2.1.0@astrojs/telemetry@1.0.1@astrojs/tailwind@2.0.2@astrojs/svelte@1.0.1@astrojs/rss@1.0.2@astrojs/preact@1.1.1@astrojs/node@1.1.0@astrojs/netlify@1.1.0@astrojs/mdx@0.11.3@astrojs/markdown-remark@1.1.3@astrojs/image@0.8.1@astrojs/deno@1.1.0@astrojs/cloudflare@2.1.0Gravatar Fred K. Bot 65-235/+512 2022-09-29[ci] update lockfile (#4899)Gravatar Fred K. Bot 1-735/+718 2022-09-29[ci] formatGravatar matthewp 1-1/+3 2022-09-29fix trailing slash mismatch in dev vs build in docs example (#4912)Gravatar Rishi Raj Jain 1-1/+1 2022-09-29[ci] formatGravatar bluwy 1-1/+1 2022-09-29Support Vue JSX (#4897)Gravatar Bjorn Lu 12-5/+329 2022-09-28[ci] formatGravatar matthewp 1-8/+4 2022-09-28Fix CSS ordering between imported and Astro styles (#4907)Gravatar Matthew Phillips 12-7/+218 2022-09-28[ci] formatGravatar matthewp 23-137/+127 2022-09-28Astro.cookies implementation (#4876)Gravatar Matthew Phillips 32-29/+943 2022-09-28Fix: let Squoosh default image quality internally (#4906)Gravatar Tony Sullivan 5-11/+20 2022-09-28Update README.md (#4898)Gravatar stijlmassi 1-2/+3 2022-09-28Fix test (#4904)Gravatar Bjorn Lu 2-1/+7 2022-09-28[ci] formatGravatar FredKSchott 2-4/+4 2022-09-28redesign basics template (#4879)Gravatar Fred K. Schott 3-88/+34 2022-09-28[ci] formatGravatar bluwy 1-2/+2 2022-09-28Remove shamefully-hoist (#4842)Gravatar Bjorn Lu 104-527/+768 2022-09-28[ci] formatGravatar matthewp 4-14/+16 2022-09-28Hoist hydration script out of slot templates (#4891)Gravatar Matthew Phillips 13-43/+165 2022-09-28Ensure head content rendered once with lazy layouts (#4892)Gravatar Matthew Phillips 9-3/+59 2022-09-27fixed typing (#4893)Gravatar tweenietomatoes 1-1/+1 2022-09-27[ci] release (#4846)create-astro@1.1.0astro@1.3.1@astrojs/webapi@1.1.0@astrojs/vercel@2.0.1@astrojs/mdx@0.11.2@astrojs/image@0.8.0Gravatar Fred K. Bot 60-185/+169 2022-09-27fix: post API routes in SSG should warn or error during dev mode (#4878)Gravatar Rishi Raj Jain 3-2/+17 2022-09-27docs: Fix links to Tailwind examples (#4883)Gravatar Deanmv 1-1/+1 2022-09-27Set SSR target webworker for Vercel edge (#4884)Gravatar Bjorn Lu 2-0/+6 2022-09-27[ci] update lockfile (#4885)Gravatar Fred K. Bot 1-86/+79 2022-09-26[ci] formatGravatar bholmesdev 3-23/+19 2022-09-26Fix: correctly transform `import.meta.env.*` in MDX (#4858)Gravatar Ben Holmes 12-233/+454 2022-09-26Change negative lookbehind to lookahead (#4866)Gravatar Rishi Raj Jain 1-1/+1 2022-09-26add double check on astro file return type to display more human readable err...Gravatar Steven Yung 6-2/+61 2022-09-26[ci] update lockfile (#4862)Gravatar Fred K. Bot 1-81/+81 2022-09-26fix: Script with innerHTML not working on Safari (#4861)Gravatar Rishi Raj Jain 3-3/+10 2022-09-26Prevent /undefined catch-all routes in dev (#4873)Gravatar Bjorn Lu 6-9/+66 2022-09-26fix: 🐛 BUG: class:list directive adding class attribute when undefined (#4...Gravatar Rishi Raj Jain 2-2/+9 2022-09-26docs: Standardize common integration READMEs (#4874)Gravatar Jake Strawn 7-6/+66 2022-09-26docs: Update references to support channel in Discord. (#4872)Gravatar Jake Strawn 12-12/+12 2022-09-26[ci] formatGravatar bluwy 1-1/+1 2022-09-26fix: "chunks" directory appears in build output, if custom modules are import...Gravatar Rishi Raj Jain 2-6/+34 2022-09-23[ci] formatGravatar matthewp 1-1/+1 2022-09-23Define toStringTag another way (#4855)Gravatar Matthew Phillips 2-4/+12 2022-09-23update SSR example to match recent change on Astro API Context (#4854)Gravatar Steven Yung 2-4/+6 2022-09-23[ci] update lockfile (#4852)Gravatar Fred K. Bot 1-373/+402