diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-10-23 22:03:08 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-23 22:03:08 +0000 |
| commit | 4f4c95be40019f6656d4eee549932ee811a40116 (patch) | |
| tree | 092cede9ccdaa9b7a4381f7c369db79583d7eb8b /macros/src/analyze.rs | |
| parent | bbcae14e37c5f4ab5701b2a688bee52bfa7aaa1b (diff) | |
| parent | 1c244a995d54332649c1643aa0a3178f169406e4 (diff) | |
Merge #400
400: codegen and examples r=AfoHT a=perlindgren
just a test
Co-authored-by: Per Lindgren <per.lindgren@ltu.se>
Diffstat (limited to 'macros/src/analyze.rs')
| -rw-r--r-- | macros/src/analyze.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/macros/src/analyze.rs b/macros/src/analyze.rs index 2301167..6b26138 100644 --- a/macros/src/analyze.rs +++ b/macros/src/analyze.rs @@ -3,7 +3,7 @@ use std::collections::{BTreeMap, BTreeSet}; use rtic_syntax::{ analyze::{self, Priority}, - ast::App, + ast::{App, ExternInterrupt}, P, }; use syn::Ident; @@ -11,7 +11,7 @@ use syn::Ident; /// Extend the upstream `Analysis` struct with our field pub struct Analysis { parent: P<analyze::Analysis>, - pub interrupts: BTreeMap<Priority, Ident>, + pub interrupts: BTreeMap<Priority, (Ident, ExternInterrupt)>, } impl ops::Deref for Analysis { @@ -22,23 +22,23 @@ impl ops::Deref for Analysis { } } -// Assign an `extern` interrupt to each priority level +// Assign an interrupt to each priority level pub fn app(analysis: P<analyze::Analysis>, app: &App) -> P<Analysis> { - let mut interrupts = BTreeMap::new(); + // the set of priorities (each priority only once) let priorities = app .software_tasks .values() .map(|task| task.args.priority) .collect::<BTreeSet<_>>(); - if !priorities.is_empty() { - interrupts = priorities - .iter() - .cloned() - .rev() - .zip(app.extern_interrupts.keys().cloned()) - .collect(); - } + // map from priorities to interrupts (holding name and attributes) + let interrupts: BTreeMap<Priority, _> = priorities + .iter() + .cloned() + .rev() + .zip(&app.args.extern_interrupts) + .map(|(p, (id, ext))| (p, (id.clone(), ext.clone()))) + .collect(); P::new(Analysis { parent: analysis, |
