mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
rename rtfm! to app! and adapt to changes in rtfm-syntax
This commit is contained in:
parent
98596554b3
commit
e9788ff9b6
4 changed files with 27 additions and 28 deletions
|
@ -1,10 +1,11 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use quote::Tokens;
|
||||
use rtfm_syntax::{Idents, Idle, Init, Statics};
|
||||
use syn::Ident;
|
||||
use syntax::check::{self, Idle, Init};
|
||||
use syntax::{self, Idents, Statics};
|
||||
|
||||
use error::*;
|
||||
use syntax::error::*;
|
||||
|
||||
pub struct App {
|
||||
pub device: Tokens,
|
||||
|
@ -22,27 +23,28 @@ pub struct Task {
|
|||
pub resources: Idents,
|
||||
}
|
||||
|
||||
pub fn app(app: ::rtfm_syntax::App) -> Result<App> {
|
||||
let mut tasks = HashMap::new();
|
||||
|
||||
for (k, v) in app.tasks {
|
||||
let name = k.clone();
|
||||
tasks.insert(
|
||||
k,
|
||||
::check::task(v)
|
||||
.chain_err(|| format!("checking task `{}`", name))?,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn app(app: check::App) -> Result<App> {
|
||||
let app = App {
|
||||
device: app.device,
|
||||
idle: app.idle,
|
||||
init: app.init,
|
||||
resources: app.resources,
|
||||
tasks,
|
||||
tasks: app.tasks
|
||||
.into_iter()
|
||||
.map(|(k, v)| {
|
||||
let name = k.clone();
|
||||
Ok((
|
||||
k,
|
||||
::check::task(v)
|
||||
.chain_err(|| format!("checking task `{}`", name))?,
|
||||
))
|
||||
})
|
||||
.collect::<Result<_>>()
|
||||
.chain_err(|| "checking `tasks`")?,
|
||||
};
|
||||
|
||||
::check::resources(&app)?;
|
||||
::check::resources(&app)
|
||||
.chain_err(|| "checking `resources`")?;
|
||||
|
||||
Ok(app)
|
||||
}
|
||||
|
@ -66,7 +68,7 @@ fn resources(app: &App) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn task(task: ::rtfm_syntax::Task) -> Result<Task> {
|
||||
fn task(task: syntax::check::Task) -> Result<Task> {
|
||||
if let Some(priority) = task.priority {
|
||||
Ok(Task {
|
||||
enabled: task.enabled,
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
error_chain!();
|
|
@ -6,21 +6,20 @@ extern crate error_chain;
|
|||
extern crate proc_macro;
|
||||
#[macro_use]
|
||||
extern crate quote;
|
||||
extern crate rtfm_syntax;
|
||||
extern crate rtfm_syntax as syntax;
|
||||
extern crate syn;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use rtfm_syntax::App;
|
||||
use syntax::App;
|
||||
|
||||
use error::*;
|
||||
use syntax::error::*;
|
||||
|
||||
mod analyze;
|
||||
mod check;
|
||||
mod error;
|
||||
mod trans;
|
||||
|
||||
#[proc_macro]
|
||||
pub fn rtfm(ts: TokenStream) -> TokenStream {
|
||||
pub fn app(ts: TokenStream) -> TokenStream {
|
||||
match run(ts) {
|
||||
Err(e) => panic!("{}", error_chain::ChainedError::display(&e)),
|
||||
Ok(ts) => ts,
|
||||
|
@ -30,10 +29,9 @@ pub fn rtfm(ts: TokenStream) -> TokenStream {
|
|||
fn run(ts: TokenStream) -> Result<TokenStream> {
|
||||
let input = format!("{}", ts);
|
||||
|
||||
let app = check::app(App::parse(&input)
|
||||
.chain_err(|| "parsing the `rtfm!` macro")?).chain_err(
|
||||
|| "checking the application specification",
|
||||
)?;
|
||||
let app = App::parse(&input).chain_err(|| "parsing")?;
|
||||
let app = syntax::check::app(app).chain_err(|| "checking the AST")?;
|
||||
let app = check::app(app)?;
|
||||
|
||||
let ownerships = analyze::app(&app);
|
||||
let tokens = trans::app(&app, &ownerships);
|
||||
|
|
|
@ -10,7 +10,7 @@ extern crate static_ref;
|
|||
|
||||
use core::cell::UnsafeCell;
|
||||
|
||||
pub use cortex_m_rtfm_macros::rtfm;
|
||||
pub use cortex_m_rtfm_macros::app;
|
||||
pub use cortex_m::asm::{bkpt, wfi};
|
||||
pub use cortex_m::interrupt::CriticalSection;
|
||||
pub use cortex_m::interrupt::free as atomic;
|
||||
|
|
Loading…
Reference in a new issue